@construct-space/cli 1.4.5 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +190 -115
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2790,6 +2790,7 @@ var require_lib = __commonJS((exports, module) => {
|
|
|
2790
2790
|
});
|
|
2791
2791
|
|
|
2792
2792
|
// src/lib/appdir.ts
|
|
2793
|
+
import { existsSync as existsSync8, readFileSync as readFileSync6 } from "fs";
|
|
2793
2794
|
import { join as join10 } from "path";
|
|
2794
2795
|
import { homedir } from "os";
|
|
2795
2796
|
import { platform } from "process";
|
|
@@ -2810,23 +2811,45 @@ function dataDir() {
|
|
|
2810
2811
|
}
|
|
2811
2812
|
}
|
|
2812
2813
|
}
|
|
2813
|
-
function spacesDir() {
|
|
2814
|
-
return join10(dataDir(), "spaces");
|
|
2815
|
-
}
|
|
2816
2814
|
function profilesDir() {
|
|
2817
2815
|
return join10(dataDir(), "profiles");
|
|
2818
2816
|
}
|
|
2817
|
+
function activeProfileId() {
|
|
2818
|
+
try {
|
|
2819
|
+
const credsPath = join10(dataDir(), "credentials.json");
|
|
2820
|
+
if (existsSync8(credsPath)) {
|
|
2821
|
+
const c = JSON.parse(readFileSync6(credsPath, "utf-8"));
|
|
2822
|
+
if (c.profileId)
|
|
2823
|
+
return c.profileId;
|
|
2824
|
+
}
|
|
2825
|
+
} catch {}
|
|
2826
|
+
try {
|
|
2827
|
+
const regPath = join10(dataDir(), "profiles.json");
|
|
2828
|
+
if (existsSync8(regPath)) {
|
|
2829
|
+
const r = JSON.parse(readFileSync6(regPath, "utf-8"));
|
|
2830
|
+
if (r.active_profile)
|
|
2831
|
+
return r.active_profile;
|
|
2832
|
+
}
|
|
2833
|
+
} catch {}
|
|
2834
|
+
return "";
|
|
2835
|
+
}
|
|
2836
|
+
function spacesDir() {
|
|
2837
|
+
const profileId = activeProfileId();
|
|
2838
|
+
if (profileId)
|
|
2839
|
+
return join10(profilesDir(), profileId, "spaces");
|
|
2840
|
+
return join10(dataDir(), "spaces");
|
|
2841
|
+
}
|
|
2819
2842
|
function spaceDir(spaceId) {
|
|
2820
2843
|
return join10(spacesDir(), spaceId);
|
|
2821
2844
|
}
|
|
2822
2845
|
var init_appdir = () => {};
|
|
2823
2846
|
|
|
2824
2847
|
// src/lib/auth.ts
|
|
2825
|
-
import { readFileSync as
|
|
2848
|
+
import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, unlinkSync, existsSync as existsSync10, readdirSync as readdirSync4, statSync as statSync4 } from "fs";
|
|
2826
2849
|
import { join as join12, dirname as dirname4 } from "path";
|
|
2827
2850
|
function listDesktopProfiles() {
|
|
2828
2851
|
const dir = profilesDir();
|
|
2829
|
-
if (!
|
|
2852
|
+
if (!existsSync10(dir))
|
|
2830
2853
|
return [];
|
|
2831
2854
|
const results = [];
|
|
2832
2855
|
for (const entry of readdirSync4(dir)) {
|
|
@@ -2835,9 +2858,9 @@ function listDesktopProfiles() {
|
|
|
2835
2858
|
if (!statSync4(full).isDirectory())
|
|
2836
2859
|
continue;
|
|
2837
2860
|
const authPath = join12(full, "auth.json");
|
|
2838
|
-
if (!
|
|
2861
|
+
if (!existsSync10(authPath))
|
|
2839
2862
|
continue;
|
|
2840
|
-
const data = JSON.parse(
|
|
2863
|
+
const data = JSON.parse(readFileSync7(authPath, "utf-8"));
|
|
2841
2864
|
if (!data.token)
|
|
2842
2865
|
continue;
|
|
2843
2866
|
if (data.authenticated !== undefined && !data.authenticated)
|
|
@@ -2864,10 +2887,10 @@ function store(creds) {
|
|
|
2864
2887
|
}
|
|
2865
2888
|
function load2() {
|
|
2866
2889
|
const path = credentialsPath();
|
|
2867
|
-
if (!
|
|
2890
|
+
if (!existsSync10(path)) {
|
|
2868
2891
|
throw new Error("not logged in \u2014 run 'construct login' first");
|
|
2869
2892
|
}
|
|
2870
|
-
const data = JSON.parse(
|
|
2893
|
+
const data = JSON.parse(readFileSync7(path, "utf-8"));
|
|
2871
2894
|
if (!data.token) {
|
|
2872
2895
|
throw new Error("not logged in \u2014 run 'construct login' first");
|
|
2873
2896
|
}
|
|
@@ -2883,7 +2906,7 @@ function isAuthenticated() {
|
|
|
2883
2906
|
}
|
|
2884
2907
|
function clear() {
|
|
2885
2908
|
const path = credentialsPath();
|
|
2886
|
-
if (
|
|
2909
|
+
if (existsSync10(path))
|
|
2887
2910
|
unlinkSync(path);
|
|
2888
2911
|
}
|
|
2889
2912
|
var CREDENTIALS_FILE = "credentials.json", DEFAULT_PORTAL = "https://my.construct.space/api/developer";
|
|
@@ -2955,7 +2978,15 @@ function graphBaseURL() {
|
|
|
2955
2978
|
function resolveOrgId(explicit) {
|
|
2956
2979
|
if (explicit)
|
|
2957
2980
|
return explicit;
|
|
2958
|
-
|
|
2981
|
+
if (process.env.CONSTRUCT_ORG_ID)
|
|
2982
|
+
return process.env.CONSTRUCT_ORG_ID;
|
|
2983
|
+
try {
|
|
2984
|
+
const creds = load2();
|
|
2985
|
+
const pid = creds.profileId || "";
|
|
2986
|
+
if (pid.startsWith("org:"))
|
|
2987
|
+
return pid.slice("org:".length);
|
|
2988
|
+
} catch {}
|
|
2989
|
+
return "";
|
|
2959
2990
|
}
|
|
2960
2991
|
function loadCreds() {
|
|
2961
2992
|
try {
|
|
@@ -7941,8 +7972,8 @@ function validate2(m) {
|
|
|
7941
7972
|
errors2.push("author: must be an object with a name");
|
|
7942
7973
|
if (!m.icon)
|
|
7943
7974
|
errors2.push("icon: must be a string");
|
|
7944
|
-
if (!["app", "project", "org"
|
|
7945
|
-
errors2.push('scope: must be "app", "project",
|
|
7975
|
+
if (!["app", "project", "org"].includes(m.scope))
|
|
7976
|
+
errors2.push('scope: must be "app", "project", or "org"');
|
|
7946
7977
|
if (!m.pages?.length)
|
|
7947
7978
|
errors2.push("pages: must be a non-empty array");
|
|
7948
7979
|
if (!m.navigation?.label)
|
|
@@ -8282,16 +8313,16 @@ import { existsSync as existsSync7, readFileSync as readFileSync5 } from "fs";
|
|
|
8282
8313
|
import { join as join9 } from "path";
|
|
8283
8314
|
import { createHash as createHash2 } from "crypto";
|
|
8284
8315
|
|
|
8285
|
-
// node_modules/chokidar/
|
|
8286
|
-
import { stat as statcb } from "fs";
|
|
8287
|
-
import { stat as stat3, readdir as readdir2 } from "fs/promises";
|
|
8316
|
+
// node_modules/chokidar/index.js
|
|
8288
8317
|
import { EventEmitter } from "events";
|
|
8289
|
-
import
|
|
8318
|
+
import { stat as statcb, Stats } from "fs";
|
|
8319
|
+
import { readdir as readdir2, stat as stat3 } from "fs/promises";
|
|
8320
|
+
import * as sp2 from "path";
|
|
8290
8321
|
|
|
8291
|
-
// node_modules/readdirp/
|
|
8292
|
-
import {
|
|
8322
|
+
// node_modules/readdirp/index.js
|
|
8323
|
+
import { lstat, readdir, realpath, stat } from "fs/promises";
|
|
8324
|
+
import { join as pjoin, relative as prelative, resolve as presolve, sep as psep } from "path";
|
|
8293
8325
|
import { Readable } from "stream";
|
|
8294
|
-
import { resolve as presolve, relative as prelative, join as pjoin, sep as psep } from "path";
|
|
8295
8326
|
var EntryTypes = {
|
|
8296
8327
|
FILE_TYPE: "files",
|
|
8297
8328
|
DIR_TYPE: "directories",
|
|
@@ -8347,6 +8378,20 @@ var normalizeFilter = (filter) => {
|
|
|
8347
8378
|
};
|
|
8348
8379
|
|
|
8349
8380
|
class ReaddirpStream extends Readable {
|
|
8381
|
+
parents;
|
|
8382
|
+
reading;
|
|
8383
|
+
parent;
|
|
8384
|
+
_stat;
|
|
8385
|
+
_maxDepth;
|
|
8386
|
+
_wantsDir;
|
|
8387
|
+
_wantsFile;
|
|
8388
|
+
_wantsEverything;
|
|
8389
|
+
_root;
|
|
8390
|
+
_isDirent;
|
|
8391
|
+
_statsProp;
|
|
8392
|
+
_rdOptions;
|
|
8393
|
+
_fileFilter;
|
|
8394
|
+
_directoryFilter;
|
|
8350
8395
|
constructor(options = {}) {
|
|
8351
8396
|
super({
|
|
8352
8397
|
objectMode: true,
|
|
@@ -8363,7 +8408,7 @@ class ReaddirpStream extends Readable {
|
|
|
8363
8408
|
} else {
|
|
8364
8409
|
this._stat = statMethod;
|
|
8365
8410
|
}
|
|
8366
|
-
this._maxDepth = opts.depth
|
|
8411
|
+
this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions.depth;
|
|
8367
8412
|
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
8368
8413
|
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
8369
8414
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
@@ -8508,11 +8553,11 @@ function readdirp(root, options = {}) {
|
|
|
8508
8553
|
return new ReaddirpStream(options);
|
|
8509
8554
|
}
|
|
8510
8555
|
|
|
8511
|
-
// node_modules/chokidar/
|
|
8512
|
-
import {
|
|
8513
|
-
import {
|
|
8514
|
-
import * as sysPath from "path";
|
|
8556
|
+
// node_modules/chokidar/handler.js
|
|
8557
|
+
import { watch as fs_watch, unwatchFile, watchFile } from "fs";
|
|
8558
|
+
import { realpath as fsrealpath, lstat as lstat2, open, stat as stat2 } from "fs/promises";
|
|
8515
8559
|
import { type as osType } from "os";
|
|
8560
|
+
import * as sp from "path";
|
|
8516
8561
|
var STR_DATA = "data";
|
|
8517
8562
|
var STR_END = "end";
|
|
8518
8563
|
var STR_CLOSE = "close";
|
|
@@ -8804,7 +8849,7 @@ var binaryExtensions = new Set([
|
|
|
8804
8849
|
"zip",
|
|
8805
8850
|
"zipx"
|
|
8806
8851
|
]);
|
|
8807
|
-
var isBinaryPath = (filePath) => binaryExtensions.has(
|
|
8852
|
+
var isBinaryPath = (filePath) => binaryExtensions.has(sp.extname(filePath).slice(1).toLowerCase());
|
|
8808
8853
|
var foreach = (val, fn) => {
|
|
8809
8854
|
if (val instanceof Set) {
|
|
8810
8855
|
val.forEach(fn);
|
|
@@ -8842,7 +8887,7 @@ function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
|
|
|
8842
8887
|
listener(path);
|
|
8843
8888
|
emitRaw(rawEvent, evPath, { watchedPath: path });
|
|
8844
8889
|
if (evPath && path !== evPath) {
|
|
8845
|
-
fsWatchBroadcast(
|
|
8890
|
+
fsWatchBroadcast(sp.resolve(path, evPath), KEY_LISTENERS, sp.join(path, evPath));
|
|
8846
8891
|
}
|
|
8847
8892
|
};
|
|
8848
8893
|
try {
|
|
@@ -8957,17 +9002,19 @@ var setFsWatchFileListener = (path, fullPath, options, handlers) => {
|
|
|
8957
9002
|
};
|
|
8958
9003
|
|
|
8959
9004
|
class NodeFsHandler {
|
|
9005
|
+
fsw;
|
|
9006
|
+
_boundHandleError;
|
|
8960
9007
|
constructor(fsW) {
|
|
8961
9008
|
this.fsw = fsW;
|
|
8962
9009
|
this._boundHandleError = (error2) => fsW._handleError(error2);
|
|
8963
9010
|
}
|
|
8964
9011
|
_watchWithNodeFs(path, listener) {
|
|
8965
9012
|
const opts = this.fsw.options;
|
|
8966
|
-
const directory =
|
|
8967
|
-
const basename4 =
|
|
9013
|
+
const directory = sp.dirname(path);
|
|
9014
|
+
const basename4 = sp.basename(path);
|
|
8968
9015
|
const parent = this.fsw._getWatchedDir(directory);
|
|
8969
9016
|
parent.add(basename4);
|
|
8970
|
-
const absolutePath =
|
|
9017
|
+
const absolutePath = sp.resolve(path);
|
|
8971
9018
|
const options = {
|
|
8972
9019
|
persistent: opts.persistent
|
|
8973
9020
|
};
|
|
@@ -8994,8 +9041,8 @@ class NodeFsHandler {
|
|
|
8994
9041
|
if (this.fsw.closed) {
|
|
8995
9042
|
return;
|
|
8996
9043
|
}
|
|
8997
|
-
const dirname3 =
|
|
8998
|
-
const basename4 =
|
|
9044
|
+
const dirname3 = sp.dirname(file);
|
|
9045
|
+
const basename4 = sp.basename(file);
|
|
8999
9046
|
const parent = this.fsw._getWatchedDir(dirname3);
|
|
9000
9047
|
let prevStats = stats;
|
|
9001
9048
|
if (parent.has(basename4))
|
|
@@ -9078,8 +9125,9 @@ class NodeFsHandler {
|
|
|
9078
9125
|
this.fsw._symlinkPaths.set(full, true);
|
|
9079
9126
|
}
|
|
9080
9127
|
_handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
|
|
9081
|
-
directory =
|
|
9082
|
-
|
|
9128
|
+
directory = sp.join(directory, "");
|
|
9129
|
+
const throttleKey = target ? `${directory}:${target}` : directory;
|
|
9130
|
+
throttler = this.fsw._throttle("readdir", throttleKey, 1000);
|
|
9083
9131
|
if (!throttler)
|
|
9084
9132
|
return;
|
|
9085
9133
|
const previous = this.fsw._getWatchedDir(wh.path);
|
|
@@ -9096,7 +9144,7 @@ class NodeFsHandler {
|
|
|
9096
9144
|
return;
|
|
9097
9145
|
}
|
|
9098
9146
|
const item = entry.path;
|
|
9099
|
-
let path =
|
|
9147
|
+
let path = sp.join(directory, item);
|
|
9100
9148
|
current.add(item);
|
|
9101
9149
|
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) {
|
|
9102
9150
|
return;
|
|
@@ -9107,7 +9155,7 @@ class NodeFsHandler {
|
|
|
9107
9155
|
}
|
|
9108
9156
|
if (item === target || !target && !previous.has(item)) {
|
|
9109
9157
|
this.fsw._incrReadyCount();
|
|
9110
|
-
path =
|
|
9158
|
+
path = sp.join(dir, sp.relative(dir, path));
|
|
9111
9159
|
this._addToNodeFs(path, initialAdd, wh, depth + 1);
|
|
9112
9160
|
}
|
|
9113
9161
|
}).on(EV.ERROR, this._boundHandleError);
|
|
@@ -9133,12 +9181,12 @@ class NodeFsHandler {
|
|
|
9133
9181
|
});
|
|
9134
9182
|
}
|
|
9135
9183
|
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath2) {
|
|
9136
|
-
const parentDir = this.fsw._getWatchedDir(
|
|
9137
|
-
const tracked = parentDir.has(
|
|
9184
|
+
const parentDir = this.fsw._getWatchedDir(sp.dirname(dir));
|
|
9185
|
+
const tracked = parentDir.has(sp.basename(dir));
|
|
9138
9186
|
if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
|
|
9139
9187
|
this.fsw._emit(EV.ADD_DIR, dir, stats);
|
|
9140
9188
|
}
|
|
9141
|
-
parentDir.add(
|
|
9189
|
+
parentDir.add(sp.basename(dir));
|
|
9142
9190
|
this.fsw._getWatchedDir(dir);
|
|
9143
9191
|
let throttler;
|
|
9144
9192
|
let closer;
|
|
@@ -9179,7 +9227,7 @@ class NodeFsHandler {
|
|
|
9179
9227
|
const follow = this.fsw.options.followSymlinks;
|
|
9180
9228
|
let closer;
|
|
9181
9229
|
if (stats.isDirectory()) {
|
|
9182
|
-
const absPath =
|
|
9230
|
+
const absPath = sp.resolve(path);
|
|
9183
9231
|
const targetPath = follow ? await fsrealpath(path) : path;
|
|
9184
9232
|
if (this.fsw.closed)
|
|
9185
9233
|
return;
|
|
@@ -9193,14 +9241,14 @@ class NodeFsHandler {
|
|
|
9193
9241
|
const targetPath = follow ? await fsrealpath(path) : path;
|
|
9194
9242
|
if (this.fsw.closed)
|
|
9195
9243
|
return;
|
|
9196
|
-
const parent =
|
|
9244
|
+
const parent = sp.dirname(wh.watchPath);
|
|
9197
9245
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
9198
9246
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
9199
9247
|
closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
|
|
9200
9248
|
if (this.fsw.closed)
|
|
9201
9249
|
return;
|
|
9202
9250
|
if (targetPath !== undefined) {
|
|
9203
|
-
this.fsw._symlinkPaths.set(
|
|
9251
|
+
this.fsw._symlinkPaths.set(sp.resolve(path), targetPath);
|
|
9204
9252
|
}
|
|
9205
9253
|
} else {
|
|
9206
9254
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
@@ -9218,7 +9266,7 @@ class NodeFsHandler {
|
|
|
9218
9266
|
}
|
|
9219
9267
|
}
|
|
9220
9268
|
|
|
9221
|
-
// node_modules/chokidar/
|
|
9269
|
+
// node_modules/chokidar/index.js
|
|
9222
9270
|
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
|
|
9223
9271
|
var SLASH = "/";
|
|
9224
9272
|
var SLASH_SLASH = "//";
|
|
@@ -9226,7 +9274,7 @@ var ONE_DOT = ".";
|
|
|
9226
9274
|
var TWO_DOTS = "..";
|
|
9227
9275
|
var STRING_TYPE = "string";
|
|
9228
9276
|
var BACK_SLASH_RE = /\\/g;
|
|
9229
|
-
var DOUBLE_SLASH_RE =
|
|
9277
|
+
var DOUBLE_SLASH_RE = /\/\//g;
|
|
9230
9278
|
var DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
|
|
9231
9279
|
var REPLACER_RE = /^\.[/\\]/;
|
|
9232
9280
|
function arrify(item) {
|
|
@@ -9245,11 +9293,11 @@ function createPattern(matcher) {
|
|
|
9245
9293
|
if (matcher.path === string)
|
|
9246
9294
|
return true;
|
|
9247
9295
|
if (matcher.recursive) {
|
|
9248
|
-
const relative4 =
|
|
9296
|
+
const relative4 = sp2.relative(matcher.path, string);
|
|
9249
9297
|
if (!relative4) {
|
|
9250
9298
|
return false;
|
|
9251
9299
|
}
|
|
9252
|
-
return !relative4.startsWith("..") && !
|
|
9300
|
+
return !relative4.startsWith("..") && !sp2.isAbsolute(relative4);
|
|
9253
9301
|
}
|
|
9254
9302
|
return false;
|
|
9255
9303
|
};
|
|
@@ -9259,14 +9307,12 @@ function createPattern(matcher) {
|
|
|
9259
9307
|
function normalizePath(path) {
|
|
9260
9308
|
if (typeof path !== "string")
|
|
9261
9309
|
throw new Error("string expected");
|
|
9262
|
-
path =
|
|
9310
|
+
path = sp2.normalize(path);
|
|
9263
9311
|
path = path.replace(/\\/g, "/");
|
|
9264
9312
|
let prepend = false;
|
|
9265
9313
|
if (path.startsWith("//"))
|
|
9266
9314
|
prepend = true;
|
|
9267
|
-
|
|
9268
|
-
while (path.match(DOUBLE_SLASH_RE2))
|
|
9269
|
-
path = path.replace(DOUBLE_SLASH_RE2, "/");
|
|
9315
|
+
path = path.replace(DOUBLE_SLASH_RE, "/");
|
|
9270
9316
|
if (prepend)
|
|
9271
9317
|
path = "/" + path;
|
|
9272
9318
|
return path;
|
|
@@ -9307,31 +9353,32 @@ var toUnix = (string) => {
|
|
|
9307
9353
|
if (str.startsWith(SLASH_SLASH)) {
|
|
9308
9354
|
prepend = true;
|
|
9309
9355
|
}
|
|
9310
|
-
|
|
9311
|
-
str = str.replace(DOUBLE_SLASH_RE, SLASH);
|
|
9312
|
-
}
|
|
9356
|
+
str = str.replace(DOUBLE_SLASH_RE, SLASH);
|
|
9313
9357
|
if (prepend) {
|
|
9314
9358
|
str = SLASH + str;
|
|
9315
9359
|
}
|
|
9316
9360
|
return str;
|
|
9317
9361
|
};
|
|
9318
|
-
var normalizePathToUnix = (path) => toUnix(
|
|
9362
|
+
var normalizePathToUnix = (path) => toUnix(sp2.normalize(toUnix(path)));
|
|
9319
9363
|
var normalizeIgnored = (cwd = "") => (path) => {
|
|
9320
9364
|
if (typeof path === "string") {
|
|
9321
|
-
return normalizePathToUnix(
|
|
9365
|
+
return normalizePathToUnix(sp2.isAbsolute(path) ? path : sp2.join(cwd, path));
|
|
9322
9366
|
} else {
|
|
9323
9367
|
return path;
|
|
9324
9368
|
}
|
|
9325
9369
|
};
|
|
9326
9370
|
var getAbsolutePath = (path, cwd) => {
|
|
9327
|
-
if (
|
|
9371
|
+
if (sp2.isAbsolute(path)) {
|
|
9328
9372
|
return path;
|
|
9329
9373
|
}
|
|
9330
|
-
return
|
|
9374
|
+
return sp2.join(cwd, path);
|
|
9331
9375
|
};
|
|
9332
9376
|
var EMPTY_SET = Object.freeze(new Set);
|
|
9333
9377
|
|
|
9334
9378
|
class DirEntry {
|
|
9379
|
+
path;
|
|
9380
|
+
_removeWatcher;
|
|
9381
|
+
items;
|
|
9335
9382
|
constructor(dir, removeWatcher) {
|
|
9336
9383
|
this.path = dir;
|
|
9337
9384
|
this._removeWatcher = removeWatcher;
|
|
@@ -9356,7 +9403,7 @@ class DirEntry {
|
|
|
9356
9403
|
await readdir2(dir);
|
|
9357
9404
|
} catch (err) {
|
|
9358
9405
|
if (this._removeWatcher) {
|
|
9359
|
-
this._removeWatcher(
|
|
9406
|
+
this._removeWatcher(sp2.dirname(dir), sp2.basename(dir));
|
|
9360
9407
|
}
|
|
9361
9408
|
}
|
|
9362
9409
|
}
|
|
@@ -9384,12 +9431,19 @@ var STAT_METHOD_F = "stat";
|
|
|
9384
9431
|
var STAT_METHOD_L = "lstat";
|
|
9385
9432
|
|
|
9386
9433
|
class WatchHelper {
|
|
9434
|
+
fsw;
|
|
9435
|
+
path;
|
|
9436
|
+
watchPath;
|
|
9437
|
+
fullWatchPath;
|
|
9438
|
+
dirParts;
|
|
9439
|
+
followSymlinks;
|
|
9440
|
+
statMethod;
|
|
9387
9441
|
constructor(path, follow, fsw) {
|
|
9388
9442
|
this.fsw = fsw;
|
|
9389
9443
|
const watchPath = path;
|
|
9390
9444
|
this.path = path = path.replace(REPLACER_RE, "");
|
|
9391
9445
|
this.watchPath = watchPath;
|
|
9392
|
-
this.fullWatchPath =
|
|
9446
|
+
this.fullWatchPath = sp2.resolve(watchPath);
|
|
9393
9447
|
this.dirParts = [];
|
|
9394
9448
|
this.dirParts.forEach((parts) => {
|
|
9395
9449
|
if (parts.length > 1)
|
|
@@ -9399,7 +9453,7 @@ class WatchHelper {
|
|
|
9399
9453
|
this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
|
|
9400
9454
|
}
|
|
9401
9455
|
entryPath(entry) {
|
|
9402
|
-
return
|
|
9456
|
+
return sp2.join(this.watchPath, sp2.relative(this.watchPath, entry.fullPath));
|
|
9403
9457
|
}
|
|
9404
9458
|
filterPath(entry) {
|
|
9405
9459
|
const { stats } = entry;
|
|
@@ -9414,6 +9468,24 @@ class WatchHelper {
|
|
|
9414
9468
|
}
|
|
9415
9469
|
|
|
9416
9470
|
class FSWatcher extends EventEmitter {
|
|
9471
|
+
closed;
|
|
9472
|
+
options;
|
|
9473
|
+
_closers;
|
|
9474
|
+
_ignoredPaths;
|
|
9475
|
+
_throttled;
|
|
9476
|
+
_streams;
|
|
9477
|
+
_symlinkPaths;
|
|
9478
|
+
_watched;
|
|
9479
|
+
_pendingWrites;
|
|
9480
|
+
_pendingUnlinks;
|
|
9481
|
+
_readyCount;
|
|
9482
|
+
_emitReady;
|
|
9483
|
+
_closePromise;
|
|
9484
|
+
_userIgnored;
|
|
9485
|
+
_readyEmitted;
|
|
9486
|
+
_emitRaw;
|
|
9487
|
+
_boundRemove;
|
|
9488
|
+
_nodeFsHandler;
|
|
9417
9489
|
constructor(_opts = {}) {
|
|
9418
9490
|
super();
|
|
9419
9491
|
this.closed = false;
|
|
@@ -9522,7 +9594,7 @@ class FSWatcher extends EventEmitter {
|
|
|
9522
9594
|
return;
|
|
9523
9595
|
results.forEach((item) => {
|
|
9524
9596
|
if (item)
|
|
9525
|
-
this.add(
|
|
9597
|
+
this.add(sp2.dirname(item), sp2.basename(_origAdd || item));
|
|
9526
9598
|
});
|
|
9527
9599
|
});
|
|
9528
9600
|
return this;
|
|
@@ -9533,10 +9605,10 @@ class FSWatcher extends EventEmitter {
|
|
|
9533
9605
|
const paths = unifyPaths(paths_);
|
|
9534
9606
|
const { cwd } = this.options;
|
|
9535
9607
|
paths.forEach((path) => {
|
|
9536
|
-
if (!
|
|
9608
|
+
if (!sp2.isAbsolute(path) && !this._closers.has(path)) {
|
|
9537
9609
|
if (cwd)
|
|
9538
|
-
path =
|
|
9539
|
-
path =
|
|
9610
|
+
path = sp2.join(cwd, path);
|
|
9611
|
+
path = sp2.resolve(path);
|
|
9540
9612
|
}
|
|
9541
9613
|
this._closePath(path);
|
|
9542
9614
|
this._addIgnoredPath(path);
|
|
@@ -9580,7 +9652,7 @@ class FSWatcher extends EventEmitter {
|
|
|
9580
9652
|
getWatched() {
|
|
9581
9653
|
const watchList = {};
|
|
9582
9654
|
this._watched.forEach((entry, dir) => {
|
|
9583
|
-
const key = this.options.cwd ?
|
|
9655
|
+
const key = this.options.cwd ? sp2.relative(this.options.cwd, dir) : dir;
|
|
9584
9656
|
const index = key || ONE_DOT;
|
|
9585
9657
|
watchList[index] = entry.getChildren().sort();
|
|
9586
9658
|
});
|
|
@@ -9596,9 +9668,9 @@ class FSWatcher extends EventEmitter {
|
|
|
9596
9668
|
return;
|
|
9597
9669
|
const opts = this.options;
|
|
9598
9670
|
if (isWindows)
|
|
9599
|
-
path =
|
|
9671
|
+
path = sp2.normalize(path);
|
|
9600
9672
|
if (opts.cwd)
|
|
9601
|
-
path =
|
|
9673
|
+
path = sp2.relative(opts.cwd, path);
|
|
9602
9674
|
const args = [path];
|
|
9603
9675
|
if (stats != null)
|
|
9604
9676
|
args.push(stats);
|
|
@@ -9649,7 +9721,7 @@ class FSWatcher extends EventEmitter {
|
|
|
9649
9721
|
return this;
|
|
9650
9722
|
}
|
|
9651
9723
|
if (opts.alwaysStat && stats === undefined && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
9652
|
-
const fullPath = opts.cwd ?
|
|
9724
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path) : path;
|
|
9653
9725
|
let stats2;
|
|
9654
9726
|
try {
|
|
9655
9727
|
stats2 = await stat3(fullPath);
|
|
@@ -9705,8 +9777,8 @@ class FSWatcher extends EventEmitter {
|
|
|
9705
9777
|
const pollInterval = awf.pollInterval;
|
|
9706
9778
|
let timeoutHandler;
|
|
9707
9779
|
let fullPath = path;
|
|
9708
|
-
if (this.options.cwd && !
|
|
9709
|
-
fullPath =
|
|
9780
|
+
if (this.options.cwd && !sp2.isAbsolute(path)) {
|
|
9781
|
+
fullPath = sp2.join(this.options.cwd, path);
|
|
9710
9782
|
}
|
|
9711
9783
|
const now = new Date;
|
|
9712
9784
|
const writes = this._pendingWrites;
|
|
@@ -9763,7 +9835,7 @@ class FSWatcher extends EventEmitter {
|
|
|
9763
9835
|
return new WatchHelper(path, this.options.followSymlinks, this);
|
|
9764
9836
|
}
|
|
9765
9837
|
_getWatchedDir(directory) {
|
|
9766
|
-
const dir =
|
|
9838
|
+
const dir = sp2.resolve(directory);
|
|
9767
9839
|
if (!this._watched.has(dir))
|
|
9768
9840
|
this._watched.set(dir, new DirEntry(dir, this._boundRemove));
|
|
9769
9841
|
return this._watched.get(dir);
|
|
@@ -9774,8 +9846,8 @@ class FSWatcher extends EventEmitter {
|
|
|
9774
9846
|
return Boolean(Number(stats.mode) & 256);
|
|
9775
9847
|
}
|
|
9776
9848
|
_remove(directory, item, isDirectory) {
|
|
9777
|
-
const path =
|
|
9778
|
-
const fullPath =
|
|
9849
|
+
const path = sp2.join(directory, item);
|
|
9850
|
+
const fullPath = sp2.resolve(path);
|
|
9779
9851
|
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
|
|
9780
9852
|
if (!this._throttle("remove", path, 100))
|
|
9781
9853
|
return;
|
|
@@ -9793,7 +9865,7 @@ class FSWatcher extends EventEmitter {
|
|
|
9793
9865
|
}
|
|
9794
9866
|
let relPath = path;
|
|
9795
9867
|
if (this.options.cwd)
|
|
9796
|
-
relPath =
|
|
9868
|
+
relPath = sp2.relative(this.options.cwd, path);
|
|
9797
9869
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
9798
9870
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
9799
9871
|
if (event === EVENTS.ADD)
|
|
@@ -9808,8 +9880,8 @@ class FSWatcher extends EventEmitter {
|
|
|
9808
9880
|
}
|
|
9809
9881
|
_closePath(path) {
|
|
9810
9882
|
this._closeFile(path);
|
|
9811
|
-
const dir =
|
|
9812
|
-
this._getWatchedDir(dir).remove(
|
|
9883
|
+
const dir = sp2.dirname(path);
|
|
9884
|
+
this._getWatchedDir(dir).remove(sp2.basename(path));
|
|
9813
9885
|
}
|
|
9814
9886
|
_closeFile(path) {
|
|
9815
9887
|
const closers = this._closers.get(path);
|
|
@@ -9923,7 +9995,7 @@ async function dev() {
|
|
|
9923
9995
|
|
|
9924
9996
|
// src/commands/run.ts
|
|
9925
9997
|
init_source();
|
|
9926
|
-
import { existsSync as
|
|
9998
|
+
import { existsSync as existsSync9, cpSync, mkdirSync as mkdirSync3 } from "fs";
|
|
9927
9999
|
import { join as join11 } from "path";
|
|
9928
10000
|
init_appdir();
|
|
9929
10001
|
function install() {
|
|
@@ -9933,13 +10005,13 @@ function install() {
|
|
|
9933
10005
|
process.exit(1);
|
|
9934
10006
|
}
|
|
9935
10007
|
const distDir = join11(root, "dist");
|
|
9936
|
-
if (!
|
|
10008
|
+
if (!existsSync9(distDir)) {
|
|
9937
10009
|
console.error(source_default.red("No dist/ directory found. Run 'construct build' first."));
|
|
9938
10010
|
process.exit(1);
|
|
9939
10011
|
}
|
|
9940
10012
|
const m = read(root);
|
|
9941
10013
|
const agentDir = join11(root, "agent");
|
|
9942
|
-
if (
|
|
10014
|
+
if (existsSync9(agentDir)) {
|
|
9943
10015
|
bundleAgentDir(agentDir, distDir);
|
|
9944
10016
|
}
|
|
9945
10017
|
const installDir = spaceDir(m.id);
|
|
@@ -9951,12 +10023,12 @@ function install() {
|
|
|
9951
10023
|
|
|
9952
10024
|
// src/commands/publish.ts
|
|
9953
10025
|
init_source();
|
|
9954
|
-
import { readFileSync as
|
|
10026
|
+
import { readFileSync as readFileSync8, writeFileSync as writeFileSync6, statSync as statSync6, unlinkSync as unlinkSync2 } from "fs";
|
|
9955
10027
|
import { join as join14, basename as basename6 } from "path";
|
|
9956
10028
|
init_auth();
|
|
9957
10029
|
|
|
9958
10030
|
// src/lib/pack.ts
|
|
9959
|
-
import { readdirSync as readdirSync5, statSync as statSync5, existsSync as
|
|
10031
|
+
import { readdirSync as readdirSync5, statSync as statSync5, existsSync as existsSync11 } from "fs";
|
|
9960
10032
|
import { join as join13 } from "path";
|
|
9961
10033
|
import { tmpdir } from "os";
|
|
9962
10034
|
import { execSync as execSync3 } from "child_process";
|
|
@@ -9995,7 +10067,7 @@ async function packSource(root) {
|
|
|
9995
10067
|
const tarballPath = join13(tmpdir(), `space-source-${Date.now()}.tar.gz`);
|
|
9996
10068
|
const entries = [];
|
|
9997
10069
|
for (const name of allowedRootFiles) {
|
|
9998
|
-
if (
|
|
10070
|
+
if (existsSync11(join13(root, name)))
|
|
9999
10071
|
entries.push(name);
|
|
10000
10072
|
}
|
|
10001
10073
|
for (const entry of readdirSync5(root)) {
|
|
@@ -10009,10 +10081,10 @@ async function packSource(root) {
|
|
|
10009
10081
|
entries.push(entry);
|
|
10010
10082
|
}
|
|
10011
10083
|
for (const dir of allowedDirs) {
|
|
10012
|
-
if (
|
|
10084
|
+
if (existsSync11(join13(root, dir)))
|
|
10013
10085
|
entries.push(dir);
|
|
10014
10086
|
}
|
|
10015
|
-
const validEntries = entries.filter((e) =>
|
|
10087
|
+
const validEntries = entries.filter((e) => existsSync11(join13(root, e)));
|
|
10016
10088
|
if (validEntries.length === 0) {
|
|
10017
10089
|
throw new Error("No files to pack");
|
|
10018
10090
|
}
|
|
@@ -10030,7 +10102,7 @@ async function packSource(root) {
|
|
|
10030
10102
|
async function uploadSource(portalURL, token, tarballPath, m) {
|
|
10031
10103
|
const formData = new FormData;
|
|
10032
10104
|
formData.append("manifest", JSON.stringify(m));
|
|
10033
|
-
const fileData =
|
|
10105
|
+
const fileData = readFileSync8(tarballPath);
|
|
10034
10106
|
const blob = new Blob([fileData]);
|
|
10035
10107
|
formData.append("source", blob, basename6(tarballPath));
|
|
10036
10108
|
const resp = await fetch(`${portalURL}/publish`, {
|
|
@@ -10064,7 +10136,7 @@ function setVersionInFiles(root, oldVer, newVer) {
|
|
|
10064
10136
|
for (const file of ["package.json", "space.manifest.json"]) {
|
|
10065
10137
|
const path = join14(root, file);
|
|
10066
10138
|
try {
|
|
10067
|
-
const data =
|
|
10139
|
+
const data = readFileSync8(path, "utf-8");
|
|
10068
10140
|
writeFileSync6(path, data.replace(oldStr, newStr));
|
|
10069
10141
|
} catch {}
|
|
10070
10142
|
}
|
|
@@ -10209,7 +10281,7 @@ async function publish(options) {
|
|
|
10209
10281
|
|
|
10210
10282
|
// src/commands/validate.ts
|
|
10211
10283
|
init_source();
|
|
10212
|
-
import { existsSync as
|
|
10284
|
+
import { existsSync as existsSync12, readFileSync as readFileSync9 } from "fs";
|
|
10213
10285
|
import { join as join15 } from "path";
|
|
10214
10286
|
function validate3() {
|
|
10215
10287
|
const root = process.cwd();
|
|
@@ -10229,21 +10301,21 @@ function validate3() {
|
|
|
10229
10301
|
for (const page of m.pages) {
|
|
10230
10302
|
const component = page.component || (page.path === "" ? "pages/index.vue" : `pages/${page.path}.vue`);
|
|
10231
10303
|
const fullPath = join15(root, "src", component);
|
|
10232
|
-
if (!
|
|
10304
|
+
if (!existsSync12(fullPath)) {
|
|
10233
10305
|
console.log(source_default.yellow(` \u26A0 Page component not found: src/${component}`));
|
|
10234
10306
|
warnings++;
|
|
10235
10307
|
}
|
|
10236
10308
|
}
|
|
10237
10309
|
if (m.agent) {
|
|
10238
10310
|
const agentPath = join15(root, m.agent);
|
|
10239
|
-
if (!
|
|
10311
|
+
if (!existsSync12(agentPath)) {
|
|
10240
10312
|
console.log(source_default.yellow(` \u26A0 Agent config not found: ${m.agent}`));
|
|
10241
10313
|
warnings++;
|
|
10242
10314
|
}
|
|
10243
10315
|
}
|
|
10244
10316
|
const pkgPath = join15(root, "package.json");
|
|
10245
|
-
if (
|
|
10246
|
-
const pkg = JSON.parse(
|
|
10317
|
+
if (existsSync12(pkgPath)) {
|
|
10318
|
+
const pkg = JSON.parse(readFileSync9(pkgPath, "utf-8"));
|
|
10247
10319
|
if (pkg.version && pkg.version !== m.version) {
|
|
10248
10320
|
console.log(source_default.yellow(` \u26A0 Version mismatch: manifest=${m.version} package.json=${pkg.version}`));
|
|
10249
10321
|
warnings++;
|
|
@@ -10259,7 +10331,7 @@ function validate3() {
|
|
|
10259
10331
|
// src/commands/check.ts
|
|
10260
10332
|
init_source();
|
|
10261
10333
|
import { execSync as execSync4 } from "child_process";
|
|
10262
|
-
import { existsSync as
|
|
10334
|
+
import { existsSync as existsSync13, readFileSync as readFileSync10 } from "fs";
|
|
10263
10335
|
import { join as join16 } from "path";
|
|
10264
10336
|
function check() {
|
|
10265
10337
|
const root = process.cwd();
|
|
@@ -10279,18 +10351,18 @@ function check() {
|
|
|
10279
10351
|
let warnings = 0;
|
|
10280
10352
|
for (const page of m.pages) {
|
|
10281
10353
|
const component = page.component || (page.path === "" ? "pages/index.vue" : `pages/${page.path}.vue`);
|
|
10282
|
-
if (!
|
|
10354
|
+
if (!existsSync13(join16(root, "src", component))) {
|
|
10283
10355
|
console.log(source_default.yellow(` \u26A0 Page not found: src/${component}`));
|
|
10284
10356
|
warnings++;
|
|
10285
10357
|
}
|
|
10286
10358
|
}
|
|
10287
|
-
if (m.agent && !
|
|
10359
|
+
if (m.agent && !existsSync13(join16(root, m.agent))) {
|
|
10288
10360
|
console.log(source_default.yellow(` \u26A0 Agent config not found: ${m.agent}`));
|
|
10289
10361
|
warnings++;
|
|
10290
10362
|
}
|
|
10291
10363
|
const pkgPath = join16(root, "package.json");
|
|
10292
|
-
if (
|
|
10293
|
-
const pkg = JSON.parse(
|
|
10364
|
+
if (existsSync13(pkgPath)) {
|
|
10365
|
+
const pkg = JSON.parse(readFileSync10(pkgPath, "utf-8"));
|
|
10294
10366
|
if (pkg.version && pkg.version !== m.version) {
|
|
10295
10367
|
console.log(source_default.yellow(` \u26A0 Version mismatch: manifest=${m.version} package.json=${pkg.version}`));
|
|
10296
10368
|
warnings++;
|
|
@@ -10322,7 +10394,7 @@ function check() {
|
|
|
10322
10394
|
|
|
10323
10395
|
// src/commands/clean.ts
|
|
10324
10396
|
init_source();
|
|
10325
|
-
import { rmSync, existsSync as
|
|
10397
|
+
import { rmSync, existsSync as existsSync14 } from "fs";
|
|
10326
10398
|
import { join as join17 } from "path";
|
|
10327
10399
|
function clean(options) {
|
|
10328
10400
|
const root = process.cwd();
|
|
@@ -10333,7 +10405,7 @@ function clean(options) {
|
|
|
10333
10405
|
const lockfiles = ["bun.lockb", "package-lock.json", "yarn.lock", "pnpm-lock.yaml"];
|
|
10334
10406
|
for (const dir of dirs) {
|
|
10335
10407
|
const path = join17(root, dir);
|
|
10336
|
-
if (
|
|
10408
|
+
if (existsSync14(path)) {
|
|
10337
10409
|
rmSync(path, { recursive: true });
|
|
10338
10410
|
console.log(source_default.dim(` Removed ${dir}/`));
|
|
10339
10411
|
}
|
|
@@ -10341,7 +10413,7 @@ function clean(options) {
|
|
|
10341
10413
|
if (options?.all) {
|
|
10342
10414
|
for (const file of lockfiles) {
|
|
10343
10415
|
const path = join17(root, file);
|
|
10344
|
-
if (
|
|
10416
|
+
if (existsSync14(path)) {
|
|
10345
10417
|
rmSync(path);
|
|
10346
10418
|
console.log(source_default.dim(` Removed ${file}`));
|
|
10347
10419
|
}
|
|
@@ -10396,7 +10468,7 @@ async function loginFromProfile(profiles) {
|
|
|
10396
10468
|
name: picked.user?.name || picked.user?.username || picked.id,
|
|
10397
10469
|
email: picked.user?.email || ""
|
|
10398
10470
|
};
|
|
10399
|
-
store({ token: picked.token, portal: DEFAULT_PORTAL, user });
|
|
10471
|
+
store({ token: picked.token, portal: DEFAULT_PORTAL, user, profileId: picked.id });
|
|
10400
10472
|
console.log(source_default.green(`Logged in as ${user.name}`));
|
|
10401
10473
|
if (user.email)
|
|
10402
10474
|
console.log(source_default.dim(` ${user.email}`));
|
|
@@ -10489,7 +10561,7 @@ function update() {
|
|
|
10489
10561
|
|
|
10490
10562
|
// src/commands/graph/init.ts
|
|
10491
10563
|
init_source();
|
|
10492
|
-
import { existsSync as
|
|
10564
|
+
import { existsSync as existsSync15, readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync5 } from "fs";
|
|
10493
10565
|
import { join as join18 } from "path";
|
|
10494
10566
|
import { execSync as execSync6 } from "child_process";
|
|
10495
10567
|
function graphInit() {
|
|
@@ -10503,7 +10575,7 @@ function graphInit() {
|
|
|
10503
10575
|
const modelsDir = join18(root, "src", "models");
|
|
10504
10576
|
mkdirSync5(modelsDir, { recursive: true });
|
|
10505
10577
|
const indexPath = join18(modelsDir, "index.ts");
|
|
10506
|
-
if (!
|
|
10578
|
+
if (!existsSync15(indexPath)) {
|
|
10507
10579
|
writeFileSync7(indexPath, `// Data models for ${m.name}
|
|
10508
10580
|
// Generated by construct graph init
|
|
10509
10581
|
|
|
@@ -10512,7 +10584,7 @@ function graphInit() {
|
|
|
10512
10584
|
`);
|
|
10513
10585
|
}
|
|
10514
10586
|
const pkgPath = join18(root, "package.json");
|
|
10515
|
-
const pkg = JSON.parse(
|
|
10587
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
|
|
10516
10588
|
if (!pkg.dependencies)
|
|
10517
10589
|
pkg.dependencies = {};
|
|
10518
10590
|
if (!pkg.dependencies["@construct-space/graph"]) {
|
|
@@ -10543,7 +10615,7 @@ function graphInit() {
|
|
|
10543
10615
|
|
|
10544
10616
|
// src/commands/graph/generate.ts
|
|
10545
10617
|
init_source();
|
|
10546
|
-
import { existsSync as
|
|
10618
|
+
import { existsSync as existsSync16, readFileSync as readFileSync12, writeFileSync as writeFileSync8, mkdirSync as mkdirSync6 } from "fs";
|
|
10547
10619
|
import { join as join19 } from "path";
|
|
10548
10620
|
var FIELD_TYPES = {
|
|
10549
10621
|
string: "field.string()",
|
|
@@ -10699,7 +10771,7 @@ function generate2(modelName, fieldSpecs, options) {
|
|
|
10699
10771
|
const modelsDir = join19(root, "src", "models");
|
|
10700
10772
|
mkdirSync6(modelsDir, { recursive: true });
|
|
10701
10773
|
const filePath = join19(modelsDir, `${name}.ts`);
|
|
10702
|
-
if (
|
|
10774
|
+
if (existsSync16(filePath)) {
|
|
10703
10775
|
console.log(source_default.yellow(` Model file already exists: src/models/${name}.ts`));
|
|
10704
10776
|
console.log(source_default.dim(" Overwriting..."));
|
|
10705
10777
|
}
|
|
@@ -10718,8 +10790,8 @@ function generate2(modelName, fieldSpecs, options) {
|
|
|
10718
10790
|
function updateBarrel(modelsDir, modelName) {
|
|
10719
10791
|
const indexPath = join19(modelsDir, "index.ts");
|
|
10720
10792
|
const exportLine = `export { ${modelName} } from './${modelName}'`;
|
|
10721
|
-
if (
|
|
10722
|
-
const content =
|
|
10793
|
+
if (existsSync16(indexPath)) {
|
|
10794
|
+
const content = readFileSync12(indexPath, "utf-8");
|
|
10723
10795
|
if (content.includes(exportLine))
|
|
10724
10796
|
return;
|
|
10725
10797
|
writeFileSync8(indexPath, content.trimEnd() + `
|
|
@@ -10734,7 +10806,7 @@ function updateBarrel(modelsDir, modelName) {
|
|
|
10734
10806
|
|
|
10735
10807
|
// src/commands/graph/push.ts
|
|
10736
10808
|
init_source();
|
|
10737
|
-
import { existsSync as
|
|
10809
|
+
import { existsSync as existsSync17, readdirSync as readdirSync6, readFileSync as readFileSync13 } from "fs";
|
|
10738
10810
|
import { join as join20, basename as basename7 } from "path";
|
|
10739
10811
|
init_auth();
|
|
10740
10812
|
async function graphPush() {
|
|
@@ -10745,7 +10817,7 @@ async function graphPush() {
|
|
|
10745
10817
|
}
|
|
10746
10818
|
const m = read(root);
|
|
10747
10819
|
const modelsDir = join20(root, "src", "models");
|
|
10748
|
-
if (!
|
|
10820
|
+
if (!existsSync17(modelsDir)) {
|
|
10749
10821
|
console.error(source_default.red("No src/models/ directory found. Run 'construct graph init' first."));
|
|
10750
10822
|
process.exit(1);
|
|
10751
10823
|
}
|
|
@@ -10758,7 +10830,7 @@ async function graphPush() {
|
|
|
10758
10830
|
console.log(source_default.blue(`Pushing ${modelFiles.length} model(s) for space: ${m.id}`));
|
|
10759
10831
|
const models = [];
|
|
10760
10832
|
for (const file of modelFiles) {
|
|
10761
|
-
const content =
|
|
10833
|
+
const content = readFileSync13(join20(modelsDir, file), "utf-8");
|
|
10762
10834
|
const model = parseModelFile(content, basename7(file, ".ts"));
|
|
10763
10835
|
if (model)
|
|
10764
10836
|
models.push(model);
|
|
@@ -10789,7 +10861,10 @@ async function graphPush() {
|
|
|
10789
10861
|
"X-Space-ID": m.id,
|
|
10790
10862
|
"X-Auth-User-ID": userID
|
|
10791
10863
|
};
|
|
10792
|
-
|
|
10864
|
+
let pushOrgID = process.env.CONSTRUCT_ORG_ID || "";
|
|
10865
|
+
if (!pushOrgID && creds.profileId?.startsWith("org:")) {
|
|
10866
|
+
pushOrgID = creds.profileId.slice("org:".length);
|
|
10867
|
+
}
|
|
10793
10868
|
if (pushOrgID)
|
|
10794
10869
|
headers["X-Auth-Org-ID"] = pushOrgID;
|
|
10795
10870
|
const resp = await fetch(`${graphURL}/api/schemas/register`, {
|
|
@@ -10900,7 +10975,7 @@ function parseModelFile(content, fileName) {
|
|
|
10900
10975
|
|
|
10901
10976
|
// src/commands/graph/migrate.ts
|
|
10902
10977
|
init_source();
|
|
10903
|
-
import { existsSync as
|
|
10978
|
+
import { existsSync as existsSync18, readdirSync as readdirSync7, readFileSync as readFileSync14 } from "fs";
|
|
10904
10979
|
import { join as join21, basename as basename8 } from "path";
|
|
10905
10980
|
init_auth();
|
|
10906
10981
|
async function graphMigrate(options) {
|
|
@@ -10911,7 +10986,7 @@ async function graphMigrate(options) {
|
|
|
10911
10986
|
}
|
|
10912
10987
|
const m = read(root);
|
|
10913
10988
|
const modelsDir = join21(root, "src", "models");
|
|
10914
|
-
if (!
|
|
10989
|
+
if (!existsSync18(modelsDir)) {
|
|
10915
10990
|
console.error(source_default.red("No src/models/ directory. Run 'construct graph init' first."));
|
|
10916
10991
|
process.exit(1);
|
|
10917
10992
|
}
|
|
@@ -10941,7 +11016,7 @@ async function graphMigrate(options) {
|
|
|
10941
11016
|
const modelFiles = readdirSync7(modelsDir).filter((f) => f.endsWith(".ts") && f !== "index.ts");
|
|
10942
11017
|
const localModels = [];
|
|
10943
11018
|
for (const file of modelFiles) {
|
|
10944
|
-
const content =
|
|
11019
|
+
const content = readFileSync14(join21(modelsDir, file), "utf-8");
|
|
10945
11020
|
const model = parseModelFields(content, basename8(file, ".ts"));
|
|
10946
11021
|
if (model)
|
|
10947
11022
|
localModels.push(model);
|
|
@@ -11046,7 +11121,7 @@ function parseModelFields(content, fileName) {
|
|
|
11046
11121
|
// package.json
|
|
11047
11122
|
var package_default = {
|
|
11048
11123
|
name: "@construct-space/cli",
|
|
11049
|
-
version: "1.
|
|
11124
|
+
version: "1.5.0",
|
|
11050
11125
|
description: "Construct CLI \u2014 scaffold, build, develop, and publish spaces",
|
|
11051
11126
|
type: "module",
|
|
11052
11127
|
bin: {
|