@construct-space/cli 1.4.5 → 1.5.1
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 +237 -121
- 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,14 +2887,47 @@ function store(creds) {
|
|
|
2864
2887
|
}
|
|
2865
2888
|
function load2() {
|
|
2866
2889
|
const path = credentialsPath();
|
|
2867
|
-
if (
|
|
2868
|
-
|
|
2890
|
+
if (existsSync10(path)) {
|
|
2891
|
+
const data = JSON.parse(readFileSync7(path, "utf-8"));
|
|
2892
|
+
if (data.token)
|
|
2893
|
+
return data;
|
|
2869
2894
|
}
|
|
2870
|
-
const
|
|
2871
|
-
if (
|
|
2872
|
-
|
|
2895
|
+
const fromProfile = loadFromActiveProfile();
|
|
2896
|
+
if (fromProfile)
|
|
2897
|
+
return fromProfile;
|
|
2898
|
+
throw new Error("not logged in \u2014 run 'construct login' first");
|
|
2899
|
+
}
|
|
2900
|
+
function loadFromActiveProfile() {
|
|
2901
|
+
try {
|
|
2902
|
+
const regPath = join12(dataDir(), "profiles.json");
|
|
2903
|
+
if (!existsSync10(regPath))
|
|
2904
|
+
return null;
|
|
2905
|
+
const reg = JSON.parse(readFileSync7(regPath, "utf-8"));
|
|
2906
|
+
const activeId = reg.active_profile;
|
|
2907
|
+
if (!activeId)
|
|
2908
|
+
return null;
|
|
2909
|
+
const authPath = join12(profilesDir(), activeId, "auth.json");
|
|
2910
|
+
if (!existsSync10(authPath))
|
|
2911
|
+
return null;
|
|
2912
|
+
const a = JSON.parse(readFileSync7(authPath, "utf-8"));
|
|
2913
|
+
if (!a.token)
|
|
2914
|
+
return null;
|
|
2915
|
+
if (a.authenticated === false)
|
|
2916
|
+
return null;
|
|
2917
|
+
const u = a.user || {};
|
|
2918
|
+
return {
|
|
2919
|
+
token: a.token,
|
|
2920
|
+
portal: DEFAULT_PORTAL,
|
|
2921
|
+
profileId: activeId,
|
|
2922
|
+
user: {
|
|
2923
|
+
id: u.id || u.uuid || activeId,
|
|
2924
|
+
name: u.name || u.username || activeId,
|
|
2925
|
+
email: u.email || ""
|
|
2926
|
+
}
|
|
2927
|
+
};
|
|
2928
|
+
} catch {
|
|
2929
|
+
return null;
|
|
2873
2930
|
}
|
|
2874
|
-
return data;
|
|
2875
2931
|
}
|
|
2876
2932
|
function isAuthenticated() {
|
|
2877
2933
|
try {
|
|
@@ -2883,7 +2939,7 @@ function isAuthenticated() {
|
|
|
2883
2939
|
}
|
|
2884
2940
|
function clear() {
|
|
2885
2941
|
const path = credentialsPath();
|
|
2886
|
-
if (
|
|
2942
|
+
if (existsSync10(path))
|
|
2887
2943
|
unlinkSync(path);
|
|
2888
2944
|
}
|
|
2889
2945
|
var CREDENTIALS_FILE = "credentials.json", DEFAULT_PORTAL = "https://my.construct.space/api/developer";
|
|
@@ -2955,7 +3011,15 @@ function graphBaseURL() {
|
|
|
2955
3011
|
function resolveOrgId(explicit) {
|
|
2956
3012
|
if (explicit)
|
|
2957
3013
|
return explicit;
|
|
2958
|
-
|
|
3014
|
+
if (process.env.CONSTRUCT_ORG_ID)
|
|
3015
|
+
return process.env.CONSTRUCT_ORG_ID;
|
|
3016
|
+
try {
|
|
3017
|
+
const creds = load2();
|
|
3018
|
+
const pid = creds.profileId || "";
|
|
3019
|
+
if (pid.startsWith("org:"))
|
|
3020
|
+
return pid.slice("org:".length);
|
|
3021
|
+
} catch {}
|
|
3022
|
+
return "";
|
|
2959
3023
|
}
|
|
2960
3024
|
function loadCreds() {
|
|
2961
3025
|
try {
|
|
@@ -7941,8 +8005,8 @@ function validate2(m) {
|
|
|
7941
8005
|
errors2.push("author: must be an object with a name");
|
|
7942
8006
|
if (!m.icon)
|
|
7943
8007
|
errors2.push("icon: must be a string");
|
|
7944
|
-
if (!["app", "project", "org"
|
|
7945
|
-
errors2.push('scope: must be "app", "project",
|
|
8008
|
+
if (!["app", "project", "org"].includes(m.scope))
|
|
8009
|
+
errors2.push('scope: must be "app", "project", or "org"');
|
|
7946
8010
|
if (!m.pages?.length)
|
|
7947
8011
|
errors2.push("pages: must be a non-empty array");
|
|
7948
8012
|
if (!m.navigation?.label)
|
|
@@ -8282,16 +8346,16 @@ import { existsSync as existsSync7, readFileSync as readFileSync5 } from "fs";
|
|
|
8282
8346
|
import { join as join9 } from "path";
|
|
8283
8347
|
import { createHash as createHash2 } from "crypto";
|
|
8284
8348
|
|
|
8285
|
-
// node_modules/chokidar/
|
|
8286
|
-
import { stat as statcb } from "fs";
|
|
8287
|
-
import { stat as stat3, readdir as readdir2 } from "fs/promises";
|
|
8349
|
+
// node_modules/chokidar/index.js
|
|
8288
8350
|
import { EventEmitter } from "events";
|
|
8289
|
-
import
|
|
8351
|
+
import { stat as statcb, Stats } from "fs";
|
|
8352
|
+
import { readdir as readdir2, stat as stat3 } from "fs/promises";
|
|
8353
|
+
import * as sp2 from "path";
|
|
8290
8354
|
|
|
8291
|
-
// node_modules/readdirp/
|
|
8292
|
-
import {
|
|
8355
|
+
// node_modules/readdirp/index.js
|
|
8356
|
+
import { lstat, readdir, realpath, stat } from "fs/promises";
|
|
8357
|
+
import { join as pjoin, relative as prelative, resolve as presolve, sep as psep } from "path";
|
|
8293
8358
|
import { Readable } from "stream";
|
|
8294
|
-
import { resolve as presolve, relative as prelative, join as pjoin, sep as psep } from "path";
|
|
8295
8359
|
var EntryTypes = {
|
|
8296
8360
|
FILE_TYPE: "files",
|
|
8297
8361
|
DIR_TYPE: "directories",
|
|
@@ -8347,6 +8411,20 @@ var normalizeFilter = (filter) => {
|
|
|
8347
8411
|
};
|
|
8348
8412
|
|
|
8349
8413
|
class ReaddirpStream extends Readable {
|
|
8414
|
+
parents;
|
|
8415
|
+
reading;
|
|
8416
|
+
parent;
|
|
8417
|
+
_stat;
|
|
8418
|
+
_maxDepth;
|
|
8419
|
+
_wantsDir;
|
|
8420
|
+
_wantsFile;
|
|
8421
|
+
_wantsEverything;
|
|
8422
|
+
_root;
|
|
8423
|
+
_isDirent;
|
|
8424
|
+
_statsProp;
|
|
8425
|
+
_rdOptions;
|
|
8426
|
+
_fileFilter;
|
|
8427
|
+
_directoryFilter;
|
|
8350
8428
|
constructor(options = {}) {
|
|
8351
8429
|
super({
|
|
8352
8430
|
objectMode: true,
|
|
@@ -8363,7 +8441,7 @@ class ReaddirpStream extends Readable {
|
|
|
8363
8441
|
} else {
|
|
8364
8442
|
this._stat = statMethod;
|
|
8365
8443
|
}
|
|
8366
|
-
this._maxDepth = opts.depth
|
|
8444
|
+
this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions.depth;
|
|
8367
8445
|
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
8368
8446
|
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
8369
8447
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
@@ -8508,11 +8586,11 @@ function readdirp(root, options = {}) {
|
|
|
8508
8586
|
return new ReaddirpStream(options);
|
|
8509
8587
|
}
|
|
8510
8588
|
|
|
8511
|
-
// node_modules/chokidar/
|
|
8512
|
-
import {
|
|
8513
|
-
import {
|
|
8514
|
-
import * as sysPath from "path";
|
|
8589
|
+
// node_modules/chokidar/handler.js
|
|
8590
|
+
import { watch as fs_watch, unwatchFile, watchFile } from "fs";
|
|
8591
|
+
import { realpath as fsrealpath, lstat as lstat2, open, stat as stat2 } from "fs/promises";
|
|
8515
8592
|
import { type as osType } from "os";
|
|
8593
|
+
import * as sp from "path";
|
|
8516
8594
|
var STR_DATA = "data";
|
|
8517
8595
|
var STR_END = "end";
|
|
8518
8596
|
var STR_CLOSE = "close";
|
|
@@ -8804,7 +8882,7 @@ var binaryExtensions = new Set([
|
|
|
8804
8882
|
"zip",
|
|
8805
8883
|
"zipx"
|
|
8806
8884
|
]);
|
|
8807
|
-
var isBinaryPath = (filePath) => binaryExtensions.has(
|
|
8885
|
+
var isBinaryPath = (filePath) => binaryExtensions.has(sp.extname(filePath).slice(1).toLowerCase());
|
|
8808
8886
|
var foreach = (val, fn) => {
|
|
8809
8887
|
if (val instanceof Set) {
|
|
8810
8888
|
val.forEach(fn);
|
|
@@ -8842,7 +8920,7 @@ function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
|
|
|
8842
8920
|
listener(path);
|
|
8843
8921
|
emitRaw(rawEvent, evPath, { watchedPath: path });
|
|
8844
8922
|
if (evPath && path !== evPath) {
|
|
8845
|
-
fsWatchBroadcast(
|
|
8923
|
+
fsWatchBroadcast(sp.resolve(path, evPath), KEY_LISTENERS, sp.join(path, evPath));
|
|
8846
8924
|
}
|
|
8847
8925
|
};
|
|
8848
8926
|
try {
|
|
@@ -8957,17 +9035,19 @@ var setFsWatchFileListener = (path, fullPath, options, handlers) => {
|
|
|
8957
9035
|
};
|
|
8958
9036
|
|
|
8959
9037
|
class NodeFsHandler {
|
|
9038
|
+
fsw;
|
|
9039
|
+
_boundHandleError;
|
|
8960
9040
|
constructor(fsW) {
|
|
8961
9041
|
this.fsw = fsW;
|
|
8962
9042
|
this._boundHandleError = (error2) => fsW._handleError(error2);
|
|
8963
9043
|
}
|
|
8964
9044
|
_watchWithNodeFs(path, listener) {
|
|
8965
9045
|
const opts = this.fsw.options;
|
|
8966
|
-
const directory =
|
|
8967
|
-
const basename4 =
|
|
9046
|
+
const directory = sp.dirname(path);
|
|
9047
|
+
const basename4 = sp.basename(path);
|
|
8968
9048
|
const parent = this.fsw._getWatchedDir(directory);
|
|
8969
9049
|
parent.add(basename4);
|
|
8970
|
-
const absolutePath =
|
|
9050
|
+
const absolutePath = sp.resolve(path);
|
|
8971
9051
|
const options = {
|
|
8972
9052
|
persistent: opts.persistent
|
|
8973
9053
|
};
|
|
@@ -8994,8 +9074,8 @@ class NodeFsHandler {
|
|
|
8994
9074
|
if (this.fsw.closed) {
|
|
8995
9075
|
return;
|
|
8996
9076
|
}
|
|
8997
|
-
const dirname3 =
|
|
8998
|
-
const basename4 =
|
|
9077
|
+
const dirname3 = sp.dirname(file);
|
|
9078
|
+
const basename4 = sp.basename(file);
|
|
8999
9079
|
const parent = this.fsw._getWatchedDir(dirname3);
|
|
9000
9080
|
let prevStats = stats;
|
|
9001
9081
|
if (parent.has(basename4))
|
|
@@ -9078,8 +9158,9 @@ class NodeFsHandler {
|
|
|
9078
9158
|
this.fsw._symlinkPaths.set(full, true);
|
|
9079
9159
|
}
|
|
9080
9160
|
_handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
|
|
9081
|
-
directory =
|
|
9082
|
-
|
|
9161
|
+
directory = sp.join(directory, "");
|
|
9162
|
+
const throttleKey = target ? `${directory}:${target}` : directory;
|
|
9163
|
+
throttler = this.fsw._throttle("readdir", throttleKey, 1000);
|
|
9083
9164
|
if (!throttler)
|
|
9084
9165
|
return;
|
|
9085
9166
|
const previous = this.fsw._getWatchedDir(wh.path);
|
|
@@ -9096,7 +9177,7 @@ class NodeFsHandler {
|
|
|
9096
9177
|
return;
|
|
9097
9178
|
}
|
|
9098
9179
|
const item = entry.path;
|
|
9099
|
-
let path =
|
|
9180
|
+
let path = sp.join(directory, item);
|
|
9100
9181
|
current.add(item);
|
|
9101
9182
|
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) {
|
|
9102
9183
|
return;
|
|
@@ -9107,7 +9188,7 @@ class NodeFsHandler {
|
|
|
9107
9188
|
}
|
|
9108
9189
|
if (item === target || !target && !previous.has(item)) {
|
|
9109
9190
|
this.fsw._incrReadyCount();
|
|
9110
|
-
path =
|
|
9191
|
+
path = sp.join(dir, sp.relative(dir, path));
|
|
9111
9192
|
this._addToNodeFs(path, initialAdd, wh, depth + 1);
|
|
9112
9193
|
}
|
|
9113
9194
|
}).on(EV.ERROR, this._boundHandleError);
|
|
@@ -9133,12 +9214,12 @@ class NodeFsHandler {
|
|
|
9133
9214
|
});
|
|
9134
9215
|
}
|
|
9135
9216
|
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath2) {
|
|
9136
|
-
const parentDir = this.fsw._getWatchedDir(
|
|
9137
|
-
const tracked = parentDir.has(
|
|
9217
|
+
const parentDir = this.fsw._getWatchedDir(sp.dirname(dir));
|
|
9218
|
+
const tracked = parentDir.has(sp.basename(dir));
|
|
9138
9219
|
if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
|
|
9139
9220
|
this.fsw._emit(EV.ADD_DIR, dir, stats);
|
|
9140
9221
|
}
|
|
9141
|
-
parentDir.add(
|
|
9222
|
+
parentDir.add(sp.basename(dir));
|
|
9142
9223
|
this.fsw._getWatchedDir(dir);
|
|
9143
9224
|
let throttler;
|
|
9144
9225
|
let closer;
|
|
@@ -9179,7 +9260,7 @@ class NodeFsHandler {
|
|
|
9179
9260
|
const follow = this.fsw.options.followSymlinks;
|
|
9180
9261
|
let closer;
|
|
9181
9262
|
if (stats.isDirectory()) {
|
|
9182
|
-
const absPath =
|
|
9263
|
+
const absPath = sp.resolve(path);
|
|
9183
9264
|
const targetPath = follow ? await fsrealpath(path) : path;
|
|
9184
9265
|
if (this.fsw.closed)
|
|
9185
9266
|
return;
|
|
@@ -9193,14 +9274,14 @@ class NodeFsHandler {
|
|
|
9193
9274
|
const targetPath = follow ? await fsrealpath(path) : path;
|
|
9194
9275
|
if (this.fsw.closed)
|
|
9195
9276
|
return;
|
|
9196
|
-
const parent =
|
|
9277
|
+
const parent = sp.dirname(wh.watchPath);
|
|
9197
9278
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
9198
9279
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
9199
9280
|
closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
|
|
9200
9281
|
if (this.fsw.closed)
|
|
9201
9282
|
return;
|
|
9202
9283
|
if (targetPath !== undefined) {
|
|
9203
|
-
this.fsw._symlinkPaths.set(
|
|
9284
|
+
this.fsw._symlinkPaths.set(sp.resolve(path), targetPath);
|
|
9204
9285
|
}
|
|
9205
9286
|
} else {
|
|
9206
9287
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
@@ -9218,7 +9299,7 @@ class NodeFsHandler {
|
|
|
9218
9299
|
}
|
|
9219
9300
|
}
|
|
9220
9301
|
|
|
9221
|
-
// node_modules/chokidar/
|
|
9302
|
+
// node_modules/chokidar/index.js
|
|
9222
9303
|
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
|
|
9223
9304
|
var SLASH = "/";
|
|
9224
9305
|
var SLASH_SLASH = "//";
|
|
@@ -9226,7 +9307,7 @@ var ONE_DOT = ".";
|
|
|
9226
9307
|
var TWO_DOTS = "..";
|
|
9227
9308
|
var STRING_TYPE = "string";
|
|
9228
9309
|
var BACK_SLASH_RE = /\\/g;
|
|
9229
|
-
var DOUBLE_SLASH_RE =
|
|
9310
|
+
var DOUBLE_SLASH_RE = /\/\//g;
|
|
9230
9311
|
var DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
|
|
9231
9312
|
var REPLACER_RE = /^\.[/\\]/;
|
|
9232
9313
|
function arrify(item) {
|
|
@@ -9245,11 +9326,11 @@ function createPattern(matcher) {
|
|
|
9245
9326
|
if (matcher.path === string)
|
|
9246
9327
|
return true;
|
|
9247
9328
|
if (matcher.recursive) {
|
|
9248
|
-
const relative4 =
|
|
9329
|
+
const relative4 = sp2.relative(matcher.path, string);
|
|
9249
9330
|
if (!relative4) {
|
|
9250
9331
|
return false;
|
|
9251
9332
|
}
|
|
9252
|
-
return !relative4.startsWith("..") && !
|
|
9333
|
+
return !relative4.startsWith("..") && !sp2.isAbsolute(relative4);
|
|
9253
9334
|
}
|
|
9254
9335
|
return false;
|
|
9255
9336
|
};
|
|
@@ -9259,14 +9340,12 @@ function createPattern(matcher) {
|
|
|
9259
9340
|
function normalizePath(path) {
|
|
9260
9341
|
if (typeof path !== "string")
|
|
9261
9342
|
throw new Error("string expected");
|
|
9262
|
-
path =
|
|
9343
|
+
path = sp2.normalize(path);
|
|
9263
9344
|
path = path.replace(/\\/g, "/");
|
|
9264
9345
|
let prepend = false;
|
|
9265
9346
|
if (path.startsWith("//"))
|
|
9266
9347
|
prepend = true;
|
|
9267
|
-
|
|
9268
|
-
while (path.match(DOUBLE_SLASH_RE2))
|
|
9269
|
-
path = path.replace(DOUBLE_SLASH_RE2, "/");
|
|
9348
|
+
path = path.replace(DOUBLE_SLASH_RE, "/");
|
|
9270
9349
|
if (prepend)
|
|
9271
9350
|
path = "/" + path;
|
|
9272
9351
|
return path;
|
|
@@ -9307,31 +9386,32 @@ var toUnix = (string) => {
|
|
|
9307
9386
|
if (str.startsWith(SLASH_SLASH)) {
|
|
9308
9387
|
prepend = true;
|
|
9309
9388
|
}
|
|
9310
|
-
|
|
9311
|
-
str = str.replace(DOUBLE_SLASH_RE, SLASH);
|
|
9312
|
-
}
|
|
9389
|
+
str = str.replace(DOUBLE_SLASH_RE, SLASH);
|
|
9313
9390
|
if (prepend) {
|
|
9314
9391
|
str = SLASH + str;
|
|
9315
9392
|
}
|
|
9316
9393
|
return str;
|
|
9317
9394
|
};
|
|
9318
|
-
var normalizePathToUnix = (path) => toUnix(
|
|
9395
|
+
var normalizePathToUnix = (path) => toUnix(sp2.normalize(toUnix(path)));
|
|
9319
9396
|
var normalizeIgnored = (cwd = "") => (path) => {
|
|
9320
9397
|
if (typeof path === "string") {
|
|
9321
|
-
return normalizePathToUnix(
|
|
9398
|
+
return normalizePathToUnix(sp2.isAbsolute(path) ? path : sp2.join(cwd, path));
|
|
9322
9399
|
} else {
|
|
9323
9400
|
return path;
|
|
9324
9401
|
}
|
|
9325
9402
|
};
|
|
9326
9403
|
var getAbsolutePath = (path, cwd) => {
|
|
9327
|
-
if (
|
|
9404
|
+
if (sp2.isAbsolute(path)) {
|
|
9328
9405
|
return path;
|
|
9329
9406
|
}
|
|
9330
|
-
return
|
|
9407
|
+
return sp2.join(cwd, path);
|
|
9331
9408
|
};
|
|
9332
9409
|
var EMPTY_SET = Object.freeze(new Set);
|
|
9333
9410
|
|
|
9334
9411
|
class DirEntry {
|
|
9412
|
+
path;
|
|
9413
|
+
_removeWatcher;
|
|
9414
|
+
items;
|
|
9335
9415
|
constructor(dir, removeWatcher) {
|
|
9336
9416
|
this.path = dir;
|
|
9337
9417
|
this._removeWatcher = removeWatcher;
|
|
@@ -9356,7 +9436,7 @@ class DirEntry {
|
|
|
9356
9436
|
await readdir2(dir);
|
|
9357
9437
|
} catch (err) {
|
|
9358
9438
|
if (this._removeWatcher) {
|
|
9359
|
-
this._removeWatcher(
|
|
9439
|
+
this._removeWatcher(sp2.dirname(dir), sp2.basename(dir));
|
|
9360
9440
|
}
|
|
9361
9441
|
}
|
|
9362
9442
|
}
|
|
@@ -9384,12 +9464,19 @@ var STAT_METHOD_F = "stat";
|
|
|
9384
9464
|
var STAT_METHOD_L = "lstat";
|
|
9385
9465
|
|
|
9386
9466
|
class WatchHelper {
|
|
9467
|
+
fsw;
|
|
9468
|
+
path;
|
|
9469
|
+
watchPath;
|
|
9470
|
+
fullWatchPath;
|
|
9471
|
+
dirParts;
|
|
9472
|
+
followSymlinks;
|
|
9473
|
+
statMethod;
|
|
9387
9474
|
constructor(path, follow, fsw) {
|
|
9388
9475
|
this.fsw = fsw;
|
|
9389
9476
|
const watchPath = path;
|
|
9390
9477
|
this.path = path = path.replace(REPLACER_RE, "");
|
|
9391
9478
|
this.watchPath = watchPath;
|
|
9392
|
-
this.fullWatchPath =
|
|
9479
|
+
this.fullWatchPath = sp2.resolve(watchPath);
|
|
9393
9480
|
this.dirParts = [];
|
|
9394
9481
|
this.dirParts.forEach((parts) => {
|
|
9395
9482
|
if (parts.length > 1)
|
|
@@ -9399,7 +9486,7 @@ class WatchHelper {
|
|
|
9399
9486
|
this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
|
|
9400
9487
|
}
|
|
9401
9488
|
entryPath(entry) {
|
|
9402
|
-
return
|
|
9489
|
+
return sp2.join(this.watchPath, sp2.relative(this.watchPath, entry.fullPath));
|
|
9403
9490
|
}
|
|
9404
9491
|
filterPath(entry) {
|
|
9405
9492
|
const { stats } = entry;
|
|
@@ -9414,6 +9501,24 @@ class WatchHelper {
|
|
|
9414
9501
|
}
|
|
9415
9502
|
|
|
9416
9503
|
class FSWatcher extends EventEmitter {
|
|
9504
|
+
closed;
|
|
9505
|
+
options;
|
|
9506
|
+
_closers;
|
|
9507
|
+
_ignoredPaths;
|
|
9508
|
+
_throttled;
|
|
9509
|
+
_streams;
|
|
9510
|
+
_symlinkPaths;
|
|
9511
|
+
_watched;
|
|
9512
|
+
_pendingWrites;
|
|
9513
|
+
_pendingUnlinks;
|
|
9514
|
+
_readyCount;
|
|
9515
|
+
_emitReady;
|
|
9516
|
+
_closePromise;
|
|
9517
|
+
_userIgnored;
|
|
9518
|
+
_readyEmitted;
|
|
9519
|
+
_emitRaw;
|
|
9520
|
+
_boundRemove;
|
|
9521
|
+
_nodeFsHandler;
|
|
9417
9522
|
constructor(_opts = {}) {
|
|
9418
9523
|
super();
|
|
9419
9524
|
this.closed = false;
|
|
@@ -9522,7 +9627,7 @@ class FSWatcher extends EventEmitter {
|
|
|
9522
9627
|
return;
|
|
9523
9628
|
results.forEach((item) => {
|
|
9524
9629
|
if (item)
|
|
9525
|
-
this.add(
|
|
9630
|
+
this.add(sp2.dirname(item), sp2.basename(_origAdd || item));
|
|
9526
9631
|
});
|
|
9527
9632
|
});
|
|
9528
9633
|
return this;
|
|
@@ -9533,10 +9638,10 @@ class FSWatcher extends EventEmitter {
|
|
|
9533
9638
|
const paths = unifyPaths(paths_);
|
|
9534
9639
|
const { cwd } = this.options;
|
|
9535
9640
|
paths.forEach((path) => {
|
|
9536
|
-
if (!
|
|
9641
|
+
if (!sp2.isAbsolute(path) && !this._closers.has(path)) {
|
|
9537
9642
|
if (cwd)
|
|
9538
|
-
path =
|
|
9539
|
-
path =
|
|
9643
|
+
path = sp2.join(cwd, path);
|
|
9644
|
+
path = sp2.resolve(path);
|
|
9540
9645
|
}
|
|
9541
9646
|
this._closePath(path);
|
|
9542
9647
|
this._addIgnoredPath(path);
|
|
@@ -9580,7 +9685,7 @@ class FSWatcher extends EventEmitter {
|
|
|
9580
9685
|
getWatched() {
|
|
9581
9686
|
const watchList = {};
|
|
9582
9687
|
this._watched.forEach((entry, dir) => {
|
|
9583
|
-
const key = this.options.cwd ?
|
|
9688
|
+
const key = this.options.cwd ? sp2.relative(this.options.cwd, dir) : dir;
|
|
9584
9689
|
const index = key || ONE_DOT;
|
|
9585
9690
|
watchList[index] = entry.getChildren().sort();
|
|
9586
9691
|
});
|
|
@@ -9596,9 +9701,9 @@ class FSWatcher extends EventEmitter {
|
|
|
9596
9701
|
return;
|
|
9597
9702
|
const opts = this.options;
|
|
9598
9703
|
if (isWindows)
|
|
9599
|
-
path =
|
|
9704
|
+
path = sp2.normalize(path);
|
|
9600
9705
|
if (opts.cwd)
|
|
9601
|
-
path =
|
|
9706
|
+
path = sp2.relative(opts.cwd, path);
|
|
9602
9707
|
const args = [path];
|
|
9603
9708
|
if (stats != null)
|
|
9604
9709
|
args.push(stats);
|
|
@@ -9649,7 +9754,7 @@ class FSWatcher extends EventEmitter {
|
|
|
9649
9754
|
return this;
|
|
9650
9755
|
}
|
|
9651
9756
|
if (opts.alwaysStat && stats === undefined && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
9652
|
-
const fullPath = opts.cwd ?
|
|
9757
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path) : path;
|
|
9653
9758
|
let stats2;
|
|
9654
9759
|
try {
|
|
9655
9760
|
stats2 = await stat3(fullPath);
|
|
@@ -9705,8 +9810,8 @@ class FSWatcher extends EventEmitter {
|
|
|
9705
9810
|
const pollInterval = awf.pollInterval;
|
|
9706
9811
|
let timeoutHandler;
|
|
9707
9812
|
let fullPath = path;
|
|
9708
|
-
if (this.options.cwd && !
|
|
9709
|
-
fullPath =
|
|
9813
|
+
if (this.options.cwd && !sp2.isAbsolute(path)) {
|
|
9814
|
+
fullPath = sp2.join(this.options.cwd, path);
|
|
9710
9815
|
}
|
|
9711
9816
|
const now = new Date;
|
|
9712
9817
|
const writes = this._pendingWrites;
|
|
@@ -9763,7 +9868,7 @@ class FSWatcher extends EventEmitter {
|
|
|
9763
9868
|
return new WatchHelper(path, this.options.followSymlinks, this);
|
|
9764
9869
|
}
|
|
9765
9870
|
_getWatchedDir(directory) {
|
|
9766
|
-
const dir =
|
|
9871
|
+
const dir = sp2.resolve(directory);
|
|
9767
9872
|
if (!this._watched.has(dir))
|
|
9768
9873
|
this._watched.set(dir, new DirEntry(dir, this._boundRemove));
|
|
9769
9874
|
return this._watched.get(dir);
|
|
@@ -9774,8 +9879,8 @@ class FSWatcher extends EventEmitter {
|
|
|
9774
9879
|
return Boolean(Number(stats.mode) & 256);
|
|
9775
9880
|
}
|
|
9776
9881
|
_remove(directory, item, isDirectory) {
|
|
9777
|
-
const path =
|
|
9778
|
-
const fullPath =
|
|
9882
|
+
const path = sp2.join(directory, item);
|
|
9883
|
+
const fullPath = sp2.resolve(path);
|
|
9779
9884
|
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
|
|
9780
9885
|
if (!this._throttle("remove", path, 100))
|
|
9781
9886
|
return;
|
|
@@ -9793,7 +9898,7 @@ class FSWatcher extends EventEmitter {
|
|
|
9793
9898
|
}
|
|
9794
9899
|
let relPath = path;
|
|
9795
9900
|
if (this.options.cwd)
|
|
9796
|
-
relPath =
|
|
9901
|
+
relPath = sp2.relative(this.options.cwd, path);
|
|
9797
9902
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
9798
9903
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
9799
9904
|
if (event === EVENTS.ADD)
|
|
@@ -9808,8 +9913,8 @@ class FSWatcher extends EventEmitter {
|
|
|
9808
9913
|
}
|
|
9809
9914
|
_closePath(path) {
|
|
9810
9915
|
this._closeFile(path);
|
|
9811
|
-
const dir =
|
|
9812
|
-
this._getWatchedDir(dir).remove(
|
|
9916
|
+
const dir = sp2.dirname(path);
|
|
9917
|
+
this._getWatchedDir(dir).remove(sp2.basename(path));
|
|
9813
9918
|
}
|
|
9814
9919
|
_closeFile(path) {
|
|
9815
9920
|
const closers = this._closers.get(path);
|
|
@@ -9923,7 +10028,7 @@ async function dev() {
|
|
|
9923
10028
|
|
|
9924
10029
|
// src/commands/run.ts
|
|
9925
10030
|
init_source();
|
|
9926
|
-
import { existsSync as
|
|
10031
|
+
import { existsSync as existsSync9, cpSync, mkdirSync as mkdirSync3 } from "fs";
|
|
9927
10032
|
import { join as join11 } from "path";
|
|
9928
10033
|
init_appdir();
|
|
9929
10034
|
function install() {
|
|
@@ -9933,13 +10038,13 @@ function install() {
|
|
|
9933
10038
|
process.exit(1);
|
|
9934
10039
|
}
|
|
9935
10040
|
const distDir = join11(root, "dist");
|
|
9936
|
-
if (!
|
|
10041
|
+
if (!existsSync9(distDir)) {
|
|
9937
10042
|
console.error(source_default.red("No dist/ directory found. Run 'construct build' first."));
|
|
9938
10043
|
process.exit(1);
|
|
9939
10044
|
}
|
|
9940
10045
|
const m = read(root);
|
|
9941
10046
|
const agentDir = join11(root, "agent");
|
|
9942
|
-
if (
|
|
10047
|
+
if (existsSync9(agentDir)) {
|
|
9943
10048
|
bundleAgentDir(agentDir, distDir);
|
|
9944
10049
|
}
|
|
9945
10050
|
const installDir = spaceDir(m.id);
|
|
@@ -9951,12 +10056,12 @@ function install() {
|
|
|
9951
10056
|
|
|
9952
10057
|
// src/commands/publish.ts
|
|
9953
10058
|
init_source();
|
|
9954
|
-
import { readFileSync as
|
|
10059
|
+
import { readFileSync as readFileSync8, writeFileSync as writeFileSync6, statSync as statSync6, unlinkSync as unlinkSync2 } from "fs";
|
|
9955
10060
|
import { join as join14, basename as basename6 } from "path";
|
|
9956
10061
|
init_auth();
|
|
9957
10062
|
|
|
9958
10063
|
// src/lib/pack.ts
|
|
9959
|
-
import { readdirSync as readdirSync5, statSync as statSync5, existsSync as
|
|
10064
|
+
import { readdirSync as readdirSync5, statSync as statSync5, existsSync as existsSync11 } from "fs";
|
|
9960
10065
|
import { join as join13 } from "path";
|
|
9961
10066
|
import { tmpdir } from "os";
|
|
9962
10067
|
import { execSync as execSync3 } from "child_process";
|
|
@@ -9995,7 +10100,7 @@ async function packSource(root) {
|
|
|
9995
10100
|
const tarballPath = join13(tmpdir(), `space-source-${Date.now()}.tar.gz`);
|
|
9996
10101
|
const entries = [];
|
|
9997
10102
|
for (const name of allowedRootFiles) {
|
|
9998
|
-
if (
|
|
10103
|
+
if (existsSync11(join13(root, name)))
|
|
9999
10104
|
entries.push(name);
|
|
10000
10105
|
}
|
|
10001
10106
|
for (const entry of readdirSync5(root)) {
|
|
@@ -10009,10 +10114,10 @@ async function packSource(root) {
|
|
|
10009
10114
|
entries.push(entry);
|
|
10010
10115
|
}
|
|
10011
10116
|
for (const dir of allowedDirs) {
|
|
10012
|
-
if (
|
|
10117
|
+
if (existsSync11(join13(root, dir)))
|
|
10013
10118
|
entries.push(dir);
|
|
10014
10119
|
}
|
|
10015
|
-
const validEntries = entries.filter((e) =>
|
|
10120
|
+
const validEntries = entries.filter((e) => existsSync11(join13(root, e)));
|
|
10016
10121
|
if (validEntries.length === 0) {
|
|
10017
10122
|
throw new Error("No files to pack");
|
|
10018
10123
|
}
|
|
@@ -10030,7 +10135,7 @@ async function packSource(root) {
|
|
|
10030
10135
|
async function uploadSource(portalURL, token, tarballPath, m) {
|
|
10031
10136
|
const formData = new FormData;
|
|
10032
10137
|
formData.append("manifest", JSON.stringify(m));
|
|
10033
|
-
const fileData =
|
|
10138
|
+
const fileData = readFileSync8(tarballPath);
|
|
10034
10139
|
const blob = new Blob([fileData]);
|
|
10035
10140
|
formData.append("source", blob, basename6(tarballPath));
|
|
10036
10141
|
const resp = await fetch(`${portalURL}/publish`, {
|
|
@@ -10064,7 +10169,7 @@ function setVersionInFiles(root, oldVer, newVer) {
|
|
|
10064
10169
|
for (const file of ["package.json", "space.manifest.json"]) {
|
|
10065
10170
|
const path = join14(root, file);
|
|
10066
10171
|
try {
|
|
10067
|
-
const data =
|
|
10172
|
+
const data = readFileSync8(path, "utf-8");
|
|
10068
10173
|
writeFileSync6(path, data.replace(oldStr, newStr));
|
|
10069
10174
|
} catch {}
|
|
10070
10175
|
}
|
|
@@ -10209,7 +10314,7 @@ async function publish(options) {
|
|
|
10209
10314
|
|
|
10210
10315
|
// src/commands/validate.ts
|
|
10211
10316
|
init_source();
|
|
10212
|
-
import { existsSync as
|
|
10317
|
+
import { existsSync as existsSync12, readFileSync as readFileSync9 } from "fs";
|
|
10213
10318
|
import { join as join15 } from "path";
|
|
10214
10319
|
function validate3() {
|
|
10215
10320
|
const root = process.cwd();
|
|
@@ -10229,21 +10334,21 @@ function validate3() {
|
|
|
10229
10334
|
for (const page of m.pages) {
|
|
10230
10335
|
const component = page.component || (page.path === "" ? "pages/index.vue" : `pages/${page.path}.vue`);
|
|
10231
10336
|
const fullPath = join15(root, "src", component);
|
|
10232
|
-
if (!
|
|
10337
|
+
if (!existsSync12(fullPath)) {
|
|
10233
10338
|
console.log(source_default.yellow(` \u26A0 Page component not found: src/${component}`));
|
|
10234
10339
|
warnings++;
|
|
10235
10340
|
}
|
|
10236
10341
|
}
|
|
10237
10342
|
if (m.agent) {
|
|
10238
10343
|
const agentPath = join15(root, m.agent);
|
|
10239
|
-
if (!
|
|
10344
|
+
if (!existsSync12(agentPath)) {
|
|
10240
10345
|
console.log(source_default.yellow(` \u26A0 Agent config not found: ${m.agent}`));
|
|
10241
10346
|
warnings++;
|
|
10242
10347
|
}
|
|
10243
10348
|
}
|
|
10244
10349
|
const pkgPath = join15(root, "package.json");
|
|
10245
|
-
if (
|
|
10246
|
-
const pkg = JSON.parse(
|
|
10350
|
+
if (existsSync12(pkgPath)) {
|
|
10351
|
+
const pkg = JSON.parse(readFileSync9(pkgPath, "utf-8"));
|
|
10247
10352
|
if (pkg.version && pkg.version !== m.version) {
|
|
10248
10353
|
console.log(source_default.yellow(` \u26A0 Version mismatch: manifest=${m.version} package.json=${pkg.version}`));
|
|
10249
10354
|
warnings++;
|
|
@@ -10259,7 +10364,7 @@ function validate3() {
|
|
|
10259
10364
|
// src/commands/check.ts
|
|
10260
10365
|
init_source();
|
|
10261
10366
|
import { execSync as execSync4 } from "child_process";
|
|
10262
|
-
import { existsSync as
|
|
10367
|
+
import { existsSync as existsSync13, readFileSync as readFileSync10 } from "fs";
|
|
10263
10368
|
import { join as join16 } from "path";
|
|
10264
10369
|
function check() {
|
|
10265
10370
|
const root = process.cwd();
|
|
@@ -10279,18 +10384,18 @@ function check() {
|
|
|
10279
10384
|
let warnings = 0;
|
|
10280
10385
|
for (const page of m.pages) {
|
|
10281
10386
|
const component = page.component || (page.path === "" ? "pages/index.vue" : `pages/${page.path}.vue`);
|
|
10282
|
-
if (!
|
|
10387
|
+
if (!existsSync13(join16(root, "src", component))) {
|
|
10283
10388
|
console.log(source_default.yellow(` \u26A0 Page not found: src/${component}`));
|
|
10284
10389
|
warnings++;
|
|
10285
10390
|
}
|
|
10286
10391
|
}
|
|
10287
|
-
if (m.agent && !
|
|
10392
|
+
if (m.agent && !existsSync13(join16(root, m.agent))) {
|
|
10288
10393
|
console.log(source_default.yellow(` \u26A0 Agent config not found: ${m.agent}`));
|
|
10289
10394
|
warnings++;
|
|
10290
10395
|
}
|
|
10291
10396
|
const pkgPath = join16(root, "package.json");
|
|
10292
|
-
if (
|
|
10293
|
-
const pkg = JSON.parse(
|
|
10397
|
+
if (existsSync13(pkgPath)) {
|
|
10398
|
+
const pkg = JSON.parse(readFileSync10(pkgPath, "utf-8"));
|
|
10294
10399
|
if (pkg.version && pkg.version !== m.version) {
|
|
10295
10400
|
console.log(source_default.yellow(` \u26A0 Version mismatch: manifest=${m.version} package.json=${pkg.version}`));
|
|
10296
10401
|
warnings++;
|
|
@@ -10322,7 +10427,7 @@ function check() {
|
|
|
10322
10427
|
|
|
10323
10428
|
// src/commands/clean.ts
|
|
10324
10429
|
init_source();
|
|
10325
|
-
import { rmSync, existsSync as
|
|
10430
|
+
import { rmSync, existsSync as existsSync14 } from "fs";
|
|
10326
10431
|
import { join as join17 } from "path";
|
|
10327
10432
|
function clean(options) {
|
|
10328
10433
|
const root = process.cwd();
|
|
@@ -10333,7 +10438,7 @@ function clean(options) {
|
|
|
10333
10438
|
const lockfiles = ["bun.lockb", "package-lock.json", "yarn.lock", "pnpm-lock.yaml"];
|
|
10334
10439
|
for (const dir of dirs) {
|
|
10335
10440
|
const path = join17(root, dir);
|
|
10336
|
-
if (
|
|
10441
|
+
if (existsSync14(path)) {
|
|
10337
10442
|
rmSync(path, { recursive: true });
|
|
10338
10443
|
console.log(source_default.dim(` Removed ${dir}/`));
|
|
10339
10444
|
}
|
|
@@ -10341,7 +10446,7 @@ function clean(options) {
|
|
|
10341
10446
|
if (options?.all) {
|
|
10342
10447
|
for (const file of lockfiles) {
|
|
10343
10448
|
const path = join17(root, file);
|
|
10344
|
-
if (
|
|
10449
|
+
if (existsSync14(path)) {
|
|
10345
10450
|
rmSync(path);
|
|
10346
10451
|
console.log(source_default.dim(` Removed ${file}`));
|
|
10347
10452
|
}
|
|
@@ -10396,7 +10501,7 @@ async function loginFromProfile(profiles) {
|
|
|
10396
10501
|
name: picked.user?.name || picked.user?.username || picked.id,
|
|
10397
10502
|
email: picked.user?.email || ""
|
|
10398
10503
|
};
|
|
10399
|
-
store({ token: picked.token, portal: DEFAULT_PORTAL, user });
|
|
10504
|
+
store({ token: picked.token, portal: DEFAULT_PORTAL, user, profileId: picked.id });
|
|
10400
10505
|
console.log(source_default.green(`Logged in as ${user.name}`));
|
|
10401
10506
|
if (user.email)
|
|
10402
10507
|
console.log(source_default.dim(` ${user.email}`));
|
|
@@ -10489,7 +10594,7 @@ function update() {
|
|
|
10489
10594
|
|
|
10490
10595
|
// src/commands/graph/init.ts
|
|
10491
10596
|
init_source();
|
|
10492
|
-
import { existsSync as
|
|
10597
|
+
import { existsSync as existsSync15, readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync5 } from "fs";
|
|
10493
10598
|
import { join as join18 } from "path";
|
|
10494
10599
|
import { execSync as execSync6 } from "child_process";
|
|
10495
10600
|
function graphInit() {
|
|
@@ -10503,7 +10608,7 @@ function graphInit() {
|
|
|
10503
10608
|
const modelsDir = join18(root, "src", "models");
|
|
10504
10609
|
mkdirSync5(modelsDir, { recursive: true });
|
|
10505
10610
|
const indexPath = join18(modelsDir, "index.ts");
|
|
10506
|
-
if (!
|
|
10611
|
+
if (!existsSync15(indexPath)) {
|
|
10507
10612
|
writeFileSync7(indexPath, `// Data models for ${m.name}
|
|
10508
10613
|
// Generated by construct graph init
|
|
10509
10614
|
|
|
@@ -10512,7 +10617,7 @@ function graphInit() {
|
|
|
10512
10617
|
`);
|
|
10513
10618
|
}
|
|
10514
10619
|
const pkgPath = join18(root, "package.json");
|
|
10515
|
-
const pkg = JSON.parse(
|
|
10620
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
|
|
10516
10621
|
if (!pkg.dependencies)
|
|
10517
10622
|
pkg.dependencies = {};
|
|
10518
10623
|
if (!pkg.dependencies["@construct-space/graph"]) {
|
|
@@ -10543,7 +10648,7 @@ function graphInit() {
|
|
|
10543
10648
|
|
|
10544
10649
|
// src/commands/graph/generate.ts
|
|
10545
10650
|
init_source();
|
|
10546
|
-
import { existsSync as
|
|
10651
|
+
import { existsSync as existsSync16, readFileSync as readFileSync12, writeFileSync as writeFileSync8, mkdirSync as mkdirSync6 } from "fs";
|
|
10547
10652
|
import { join as join19 } from "path";
|
|
10548
10653
|
var FIELD_TYPES = {
|
|
10549
10654
|
string: "field.string()",
|
|
@@ -10699,7 +10804,7 @@ function generate2(modelName, fieldSpecs, options) {
|
|
|
10699
10804
|
const modelsDir = join19(root, "src", "models");
|
|
10700
10805
|
mkdirSync6(modelsDir, { recursive: true });
|
|
10701
10806
|
const filePath = join19(modelsDir, `${name}.ts`);
|
|
10702
|
-
if (
|
|
10807
|
+
if (existsSync16(filePath)) {
|
|
10703
10808
|
console.log(source_default.yellow(` Model file already exists: src/models/${name}.ts`));
|
|
10704
10809
|
console.log(source_default.dim(" Overwriting..."));
|
|
10705
10810
|
}
|
|
@@ -10718,8 +10823,8 @@ function generate2(modelName, fieldSpecs, options) {
|
|
|
10718
10823
|
function updateBarrel(modelsDir, modelName) {
|
|
10719
10824
|
const indexPath = join19(modelsDir, "index.ts");
|
|
10720
10825
|
const exportLine = `export { ${modelName} } from './${modelName}'`;
|
|
10721
|
-
if (
|
|
10722
|
-
const content =
|
|
10826
|
+
if (existsSync16(indexPath)) {
|
|
10827
|
+
const content = readFileSync12(indexPath, "utf-8");
|
|
10723
10828
|
if (content.includes(exportLine))
|
|
10724
10829
|
return;
|
|
10725
10830
|
writeFileSync8(indexPath, content.trimEnd() + `
|
|
@@ -10734,7 +10839,7 @@ function updateBarrel(modelsDir, modelName) {
|
|
|
10734
10839
|
|
|
10735
10840
|
// src/commands/graph/push.ts
|
|
10736
10841
|
init_source();
|
|
10737
|
-
import { existsSync as
|
|
10842
|
+
import { existsSync as existsSync17, readdirSync as readdirSync6, readFileSync as readFileSync13 } from "fs";
|
|
10738
10843
|
import { join as join20, basename as basename7 } from "path";
|
|
10739
10844
|
init_auth();
|
|
10740
10845
|
async function graphPush() {
|
|
@@ -10745,7 +10850,7 @@ async function graphPush() {
|
|
|
10745
10850
|
}
|
|
10746
10851
|
const m = read(root);
|
|
10747
10852
|
const modelsDir = join20(root, "src", "models");
|
|
10748
|
-
if (!
|
|
10853
|
+
if (!existsSync17(modelsDir)) {
|
|
10749
10854
|
console.error(source_default.red("No src/models/ directory found. Run 'construct graph init' first."));
|
|
10750
10855
|
process.exit(1);
|
|
10751
10856
|
}
|
|
@@ -10758,7 +10863,7 @@ async function graphPush() {
|
|
|
10758
10863
|
console.log(source_default.blue(`Pushing ${modelFiles.length} model(s) for space: ${m.id}`));
|
|
10759
10864
|
const models = [];
|
|
10760
10865
|
for (const file of modelFiles) {
|
|
10761
|
-
const content =
|
|
10866
|
+
const content = readFileSync13(join20(modelsDir, file), "utf-8");
|
|
10762
10867
|
const model = parseModelFile(content, basename7(file, ".ts"));
|
|
10763
10868
|
if (model)
|
|
10764
10869
|
models.push(model);
|
|
@@ -10789,7 +10894,10 @@ async function graphPush() {
|
|
|
10789
10894
|
"X-Space-ID": m.id,
|
|
10790
10895
|
"X-Auth-User-ID": userID
|
|
10791
10896
|
};
|
|
10792
|
-
|
|
10897
|
+
let pushOrgID = process.env.CONSTRUCT_ORG_ID || "";
|
|
10898
|
+
if (!pushOrgID && creds.profileId?.startsWith("org:")) {
|
|
10899
|
+
pushOrgID = creds.profileId.slice("org:".length);
|
|
10900
|
+
}
|
|
10793
10901
|
if (pushOrgID)
|
|
10794
10902
|
headers["X-Auth-Org-ID"] = pushOrgID;
|
|
10795
10903
|
const resp = await fetch(`${graphURL}/api/schemas/register`, {
|
|
@@ -10891,16 +10999,24 @@ function parseModelFile(content, fileName) {
|
|
|
10891
10999
|
const [, op, level] = accessMatch;
|
|
10892
11000
|
accessRules[op] = level;
|
|
10893
11001
|
}
|
|
11002
|
+
let scope;
|
|
11003
|
+
const scopeMatch = content.match(/scope\s*:\s*['"](app|project|org)['"]/);
|
|
11004
|
+
if (scopeMatch)
|
|
11005
|
+
scope = scopeMatch[1];
|
|
10894
11006
|
const result = { name: modelName, fields };
|
|
10895
|
-
if (Object.keys(accessRules).length > 0) {
|
|
10896
|
-
result.options = {
|
|
11007
|
+
if (Object.keys(accessRules).length > 0 || scope) {
|
|
11008
|
+
result.options = {};
|
|
11009
|
+
if (Object.keys(accessRules).length > 0)
|
|
11010
|
+
result.options.access = accessRules;
|
|
11011
|
+
if (scope)
|
|
11012
|
+
result.options.scope = scope;
|
|
10897
11013
|
}
|
|
10898
11014
|
return result;
|
|
10899
11015
|
}
|
|
10900
11016
|
|
|
10901
11017
|
// src/commands/graph/migrate.ts
|
|
10902
11018
|
init_source();
|
|
10903
|
-
import { existsSync as
|
|
11019
|
+
import { existsSync as existsSync18, readdirSync as readdirSync7, readFileSync as readFileSync14 } from "fs";
|
|
10904
11020
|
import { join as join21, basename as basename8 } from "path";
|
|
10905
11021
|
init_auth();
|
|
10906
11022
|
async function graphMigrate(options) {
|
|
@@ -10911,7 +11027,7 @@ async function graphMigrate(options) {
|
|
|
10911
11027
|
}
|
|
10912
11028
|
const m = read(root);
|
|
10913
11029
|
const modelsDir = join21(root, "src", "models");
|
|
10914
|
-
if (!
|
|
11030
|
+
if (!existsSync18(modelsDir)) {
|
|
10915
11031
|
console.error(source_default.red("No src/models/ directory. Run 'construct graph init' first."));
|
|
10916
11032
|
process.exit(1);
|
|
10917
11033
|
}
|
|
@@ -10941,7 +11057,7 @@ async function graphMigrate(options) {
|
|
|
10941
11057
|
const modelFiles = readdirSync7(modelsDir).filter((f) => f.endsWith(".ts") && f !== "index.ts");
|
|
10942
11058
|
const localModels = [];
|
|
10943
11059
|
for (const file of modelFiles) {
|
|
10944
|
-
const content =
|
|
11060
|
+
const content = readFileSync14(join21(modelsDir, file), "utf-8");
|
|
10945
11061
|
const model = parseModelFields(content, basename8(file, ".ts"));
|
|
10946
11062
|
if (model)
|
|
10947
11063
|
localModels.push(model);
|
|
@@ -11046,7 +11162,7 @@ function parseModelFields(content, fileName) {
|
|
|
11046
11162
|
// package.json
|
|
11047
11163
|
var package_default = {
|
|
11048
11164
|
name: "@construct-space/cli",
|
|
11049
|
-
version: "1.
|
|
11165
|
+
version: "1.5.1",
|
|
11050
11166
|
description: "Construct CLI \u2014 scaffold, build, develop, and publish spaces",
|
|
11051
11167
|
type: "module",
|
|
11052
11168
|
bin: {
|