@construct-space/cli 1.4.4 → 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 +107 -56
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,25 +5,43 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
function __accessProp(key) {
|
|
9
|
+
return this[key];
|
|
10
|
+
}
|
|
11
|
+
var __toESMCache_node;
|
|
12
|
+
var __toESMCache_esm;
|
|
8
13
|
var __toESM = (mod, isNodeMode, target) => {
|
|
14
|
+
var canCache = mod != null && typeof mod === "object";
|
|
15
|
+
if (canCache) {
|
|
16
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
17
|
+
var cached = cache.get(mod);
|
|
18
|
+
if (cached)
|
|
19
|
+
return cached;
|
|
20
|
+
}
|
|
9
21
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
10
22
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
11
23
|
for (let key of __getOwnPropNames(mod))
|
|
12
24
|
if (!__hasOwnProp.call(to, key))
|
|
13
25
|
__defProp(to, key, {
|
|
14
|
-
get: (
|
|
26
|
+
get: __accessProp.bind(mod, key),
|
|
15
27
|
enumerable: true
|
|
16
28
|
});
|
|
29
|
+
if (canCache)
|
|
30
|
+
cache.set(mod, to);
|
|
17
31
|
return to;
|
|
18
32
|
};
|
|
19
33
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
|
+
var __returnValue = (v) => v;
|
|
35
|
+
function __exportSetter(name, newValue) {
|
|
36
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
37
|
+
}
|
|
20
38
|
var __export = (target, all) => {
|
|
21
39
|
for (var name in all)
|
|
22
40
|
__defProp(target, name, {
|
|
23
41
|
get: all[name],
|
|
24
42
|
enumerable: true,
|
|
25
43
|
configurable: true,
|
|
26
|
-
set: (
|
|
44
|
+
set: __exportSetter.bind(all, name)
|
|
27
45
|
});
|
|
28
46
|
};
|
|
29
47
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
@@ -2772,6 +2790,7 @@ var require_lib = __commonJS((exports, module) => {
|
|
|
2772
2790
|
});
|
|
2773
2791
|
|
|
2774
2792
|
// src/lib/appdir.ts
|
|
2793
|
+
import { existsSync as existsSync8, readFileSync as readFileSync6 } from "fs";
|
|
2775
2794
|
import { join as join10 } from "path";
|
|
2776
2795
|
import { homedir } from "os";
|
|
2777
2796
|
import { platform } from "process";
|
|
@@ -2792,23 +2811,45 @@ function dataDir() {
|
|
|
2792
2811
|
}
|
|
2793
2812
|
}
|
|
2794
2813
|
}
|
|
2795
|
-
function spacesDir() {
|
|
2796
|
-
return join10(dataDir(), "spaces");
|
|
2797
|
-
}
|
|
2798
2814
|
function profilesDir() {
|
|
2799
2815
|
return join10(dataDir(), "profiles");
|
|
2800
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
|
+
}
|
|
2801
2842
|
function spaceDir(spaceId) {
|
|
2802
2843
|
return join10(spacesDir(), spaceId);
|
|
2803
2844
|
}
|
|
2804
2845
|
var init_appdir = () => {};
|
|
2805
2846
|
|
|
2806
2847
|
// src/lib/auth.ts
|
|
2807
|
-
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";
|
|
2808
2849
|
import { join as join12, dirname as dirname4 } from "path";
|
|
2809
2850
|
function listDesktopProfiles() {
|
|
2810
2851
|
const dir = profilesDir();
|
|
2811
|
-
if (!
|
|
2852
|
+
if (!existsSync10(dir))
|
|
2812
2853
|
return [];
|
|
2813
2854
|
const results = [];
|
|
2814
2855
|
for (const entry of readdirSync4(dir)) {
|
|
@@ -2817,9 +2858,9 @@ function listDesktopProfiles() {
|
|
|
2817
2858
|
if (!statSync4(full).isDirectory())
|
|
2818
2859
|
continue;
|
|
2819
2860
|
const authPath = join12(full, "auth.json");
|
|
2820
|
-
if (!
|
|
2861
|
+
if (!existsSync10(authPath))
|
|
2821
2862
|
continue;
|
|
2822
|
-
const data = JSON.parse(
|
|
2863
|
+
const data = JSON.parse(readFileSync7(authPath, "utf-8"));
|
|
2823
2864
|
if (!data.token)
|
|
2824
2865
|
continue;
|
|
2825
2866
|
if (data.authenticated !== undefined && !data.authenticated)
|
|
@@ -2846,10 +2887,10 @@ function store(creds) {
|
|
|
2846
2887
|
}
|
|
2847
2888
|
function load2() {
|
|
2848
2889
|
const path = credentialsPath();
|
|
2849
|
-
if (!
|
|
2890
|
+
if (!existsSync10(path)) {
|
|
2850
2891
|
throw new Error("not logged in \u2014 run 'construct login' first");
|
|
2851
2892
|
}
|
|
2852
|
-
const data = JSON.parse(
|
|
2893
|
+
const data = JSON.parse(readFileSync7(path, "utf-8"));
|
|
2853
2894
|
if (!data.token) {
|
|
2854
2895
|
throw new Error("not logged in \u2014 run 'construct login' first");
|
|
2855
2896
|
}
|
|
@@ -2865,7 +2906,7 @@ function isAuthenticated() {
|
|
|
2865
2906
|
}
|
|
2866
2907
|
function clear() {
|
|
2867
2908
|
const path = credentialsPath();
|
|
2868
|
-
if (
|
|
2909
|
+
if (existsSync10(path))
|
|
2869
2910
|
unlinkSync(path);
|
|
2870
2911
|
}
|
|
2871
2912
|
var CREDENTIALS_FILE = "credentials.json", DEFAULT_PORTAL = "https://my.construct.space/api/developer";
|
|
@@ -2937,7 +2978,15 @@ function graphBaseURL() {
|
|
|
2937
2978
|
function resolveOrgId(explicit) {
|
|
2938
2979
|
if (explicit)
|
|
2939
2980
|
return explicit;
|
|
2940
|
-
|
|
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 "";
|
|
2941
2990
|
}
|
|
2942
2991
|
function loadCreds() {
|
|
2943
2992
|
try {
|
|
@@ -3364,7 +3413,6 @@ var {
|
|
|
3364
3413
|
init_source();
|
|
3365
3414
|
import { mkdirSync, writeFileSync, existsSync as existsSync2, readFileSync } from "fs";
|
|
3366
3415
|
import { join as join2, dirname } from "path";
|
|
3367
|
-
|
|
3368
3416
|
// node_modules/@inquirer/core/dist/lib/key.js
|
|
3369
3417
|
var isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p";
|
|
3370
3418
|
var isDownKey = (key, keybindings = []) => key.name === "down" || keybindings.includes("vim") && key.name === "j" || keybindings.includes("emacs") && key.ctrl && key.name === "n";
|
|
@@ -3509,7 +3557,7 @@ var effectScheduler = {
|
|
|
3509
3557
|
// node_modules/@inquirer/core/dist/lib/use-state.js
|
|
3510
3558
|
function useState(defaultValue) {
|
|
3511
3559
|
return withPointer((pointer) => {
|
|
3512
|
-
const setState = AsyncResource2.bind(function
|
|
3560
|
+
const setState = AsyncResource2.bind(function setState2(newValue) {
|
|
3513
3561
|
if (pointer.get() !== newValue) {
|
|
3514
3562
|
pointer.set(newValue);
|
|
3515
3563
|
handleChange();
|
|
@@ -7924,8 +7972,8 @@ function validate2(m) {
|
|
|
7924
7972
|
errors2.push("author: must be an object with a name");
|
|
7925
7973
|
if (!m.icon)
|
|
7926
7974
|
errors2.push("icon: must be a string");
|
|
7927
|
-
if (!["app", "project", "org"
|
|
7928
|
-
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"');
|
|
7929
7977
|
if (!m.pages?.length)
|
|
7930
7978
|
errors2.push("pages: must be a non-empty array");
|
|
7931
7979
|
if (!m.navigation?.label)
|
|
@@ -9947,7 +9995,7 @@ async function dev() {
|
|
|
9947
9995
|
|
|
9948
9996
|
// src/commands/run.ts
|
|
9949
9997
|
init_source();
|
|
9950
|
-
import { existsSync as
|
|
9998
|
+
import { existsSync as existsSync9, cpSync, mkdirSync as mkdirSync3 } from "fs";
|
|
9951
9999
|
import { join as join11 } from "path";
|
|
9952
10000
|
init_appdir();
|
|
9953
10001
|
function install() {
|
|
@@ -9957,13 +10005,13 @@ function install() {
|
|
|
9957
10005
|
process.exit(1);
|
|
9958
10006
|
}
|
|
9959
10007
|
const distDir = join11(root, "dist");
|
|
9960
|
-
if (!
|
|
10008
|
+
if (!existsSync9(distDir)) {
|
|
9961
10009
|
console.error(source_default.red("No dist/ directory found. Run 'construct build' first."));
|
|
9962
10010
|
process.exit(1);
|
|
9963
10011
|
}
|
|
9964
10012
|
const m = read(root);
|
|
9965
10013
|
const agentDir = join11(root, "agent");
|
|
9966
|
-
if (
|
|
10014
|
+
if (existsSync9(agentDir)) {
|
|
9967
10015
|
bundleAgentDir(agentDir, distDir);
|
|
9968
10016
|
}
|
|
9969
10017
|
const installDir = spaceDir(m.id);
|
|
@@ -9975,12 +10023,12 @@ function install() {
|
|
|
9975
10023
|
|
|
9976
10024
|
// src/commands/publish.ts
|
|
9977
10025
|
init_source();
|
|
9978
|
-
import { readFileSync as
|
|
10026
|
+
import { readFileSync as readFileSync8, writeFileSync as writeFileSync6, statSync as statSync6, unlinkSync as unlinkSync2 } from "fs";
|
|
9979
10027
|
import { join as join14, basename as basename6 } from "path";
|
|
9980
10028
|
init_auth();
|
|
9981
10029
|
|
|
9982
10030
|
// src/lib/pack.ts
|
|
9983
|
-
import { readdirSync as readdirSync5, statSync as statSync5, existsSync as
|
|
10031
|
+
import { readdirSync as readdirSync5, statSync as statSync5, existsSync as existsSync11 } from "fs";
|
|
9984
10032
|
import { join as join13 } from "path";
|
|
9985
10033
|
import { tmpdir } from "os";
|
|
9986
10034
|
import { execSync as execSync3 } from "child_process";
|
|
@@ -10019,7 +10067,7 @@ async function packSource(root) {
|
|
|
10019
10067
|
const tarballPath = join13(tmpdir(), `space-source-${Date.now()}.tar.gz`);
|
|
10020
10068
|
const entries = [];
|
|
10021
10069
|
for (const name of allowedRootFiles) {
|
|
10022
|
-
if (
|
|
10070
|
+
if (existsSync11(join13(root, name)))
|
|
10023
10071
|
entries.push(name);
|
|
10024
10072
|
}
|
|
10025
10073
|
for (const entry of readdirSync5(root)) {
|
|
@@ -10033,10 +10081,10 @@ async function packSource(root) {
|
|
|
10033
10081
|
entries.push(entry);
|
|
10034
10082
|
}
|
|
10035
10083
|
for (const dir of allowedDirs) {
|
|
10036
|
-
if (
|
|
10084
|
+
if (existsSync11(join13(root, dir)))
|
|
10037
10085
|
entries.push(dir);
|
|
10038
10086
|
}
|
|
10039
|
-
const validEntries = entries.filter((e) =>
|
|
10087
|
+
const validEntries = entries.filter((e) => existsSync11(join13(root, e)));
|
|
10040
10088
|
if (validEntries.length === 0) {
|
|
10041
10089
|
throw new Error("No files to pack");
|
|
10042
10090
|
}
|
|
@@ -10054,7 +10102,7 @@ async function packSource(root) {
|
|
|
10054
10102
|
async function uploadSource(portalURL, token, tarballPath, m) {
|
|
10055
10103
|
const formData = new FormData;
|
|
10056
10104
|
formData.append("manifest", JSON.stringify(m));
|
|
10057
|
-
const fileData =
|
|
10105
|
+
const fileData = readFileSync8(tarballPath);
|
|
10058
10106
|
const blob = new Blob([fileData]);
|
|
10059
10107
|
formData.append("source", blob, basename6(tarballPath));
|
|
10060
10108
|
const resp = await fetch(`${portalURL}/publish`, {
|
|
@@ -10088,7 +10136,7 @@ function setVersionInFiles(root, oldVer, newVer) {
|
|
|
10088
10136
|
for (const file of ["package.json", "space.manifest.json"]) {
|
|
10089
10137
|
const path = join14(root, file);
|
|
10090
10138
|
try {
|
|
10091
|
-
const data =
|
|
10139
|
+
const data = readFileSync8(path, "utf-8");
|
|
10092
10140
|
writeFileSync6(path, data.replace(oldStr, newStr));
|
|
10093
10141
|
} catch {}
|
|
10094
10142
|
}
|
|
@@ -10233,7 +10281,7 @@ async function publish(options) {
|
|
|
10233
10281
|
|
|
10234
10282
|
// src/commands/validate.ts
|
|
10235
10283
|
init_source();
|
|
10236
|
-
import { existsSync as
|
|
10284
|
+
import { existsSync as existsSync12, readFileSync as readFileSync9 } from "fs";
|
|
10237
10285
|
import { join as join15 } from "path";
|
|
10238
10286
|
function validate3() {
|
|
10239
10287
|
const root = process.cwd();
|
|
@@ -10253,21 +10301,21 @@ function validate3() {
|
|
|
10253
10301
|
for (const page of m.pages) {
|
|
10254
10302
|
const component = page.component || (page.path === "" ? "pages/index.vue" : `pages/${page.path}.vue`);
|
|
10255
10303
|
const fullPath = join15(root, "src", component);
|
|
10256
|
-
if (!
|
|
10304
|
+
if (!existsSync12(fullPath)) {
|
|
10257
10305
|
console.log(source_default.yellow(` \u26A0 Page component not found: src/${component}`));
|
|
10258
10306
|
warnings++;
|
|
10259
10307
|
}
|
|
10260
10308
|
}
|
|
10261
10309
|
if (m.agent) {
|
|
10262
10310
|
const agentPath = join15(root, m.agent);
|
|
10263
|
-
if (!
|
|
10311
|
+
if (!existsSync12(agentPath)) {
|
|
10264
10312
|
console.log(source_default.yellow(` \u26A0 Agent config not found: ${m.agent}`));
|
|
10265
10313
|
warnings++;
|
|
10266
10314
|
}
|
|
10267
10315
|
}
|
|
10268
10316
|
const pkgPath = join15(root, "package.json");
|
|
10269
|
-
if (
|
|
10270
|
-
const pkg = JSON.parse(
|
|
10317
|
+
if (existsSync12(pkgPath)) {
|
|
10318
|
+
const pkg = JSON.parse(readFileSync9(pkgPath, "utf-8"));
|
|
10271
10319
|
if (pkg.version && pkg.version !== m.version) {
|
|
10272
10320
|
console.log(source_default.yellow(` \u26A0 Version mismatch: manifest=${m.version} package.json=${pkg.version}`));
|
|
10273
10321
|
warnings++;
|
|
@@ -10283,7 +10331,7 @@ function validate3() {
|
|
|
10283
10331
|
// src/commands/check.ts
|
|
10284
10332
|
init_source();
|
|
10285
10333
|
import { execSync as execSync4 } from "child_process";
|
|
10286
|
-
import { existsSync as
|
|
10334
|
+
import { existsSync as existsSync13, readFileSync as readFileSync10 } from "fs";
|
|
10287
10335
|
import { join as join16 } from "path";
|
|
10288
10336
|
function check() {
|
|
10289
10337
|
const root = process.cwd();
|
|
@@ -10303,18 +10351,18 @@ function check() {
|
|
|
10303
10351
|
let warnings = 0;
|
|
10304
10352
|
for (const page of m.pages) {
|
|
10305
10353
|
const component = page.component || (page.path === "" ? "pages/index.vue" : `pages/${page.path}.vue`);
|
|
10306
|
-
if (!
|
|
10354
|
+
if (!existsSync13(join16(root, "src", component))) {
|
|
10307
10355
|
console.log(source_default.yellow(` \u26A0 Page not found: src/${component}`));
|
|
10308
10356
|
warnings++;
|
|
10309
10357
|
}
|
|
10310
10358
|
}
|
|
10311
|
-
if (m.agent && !
|
|
10359
|
+
if (m.agent && !existsSync13(join16(root, m.agent))) {
|
|
10312
10360
|
console.log(source_default.yellow(` \u26A0 Agent config not found: ${m.agent}`));
|
|
10313
10361
|
warnings++;
|
|
10314
10362
|
}
|
|
10315
10363
|
const pkgPath = join16(root, "package.json");
|
|
10316
|
-
if (
|
|
10317
|
-
const pkg = JSON.parse(
|
|
10364
|
+
if (existsSync13(pkgPath)) {
|
|
10365
|
+
const pkg = JSON.parse(readFileSync10(pkgPath, "utf-8"));
|
|
10318
10366
|
if (pkg.version && pkg.version !== m.version) {
|
|
10319
10367
|
console.log(source_default.yellow(` \u26A0 Version mismatch: manifest=${m.version} package.json=${pkg.version}`));
|
|
10320
10368
|
warnings++;
|
|
@@ -10346,7 +10394,7 @@ function check() {
|
|
|
10346
10394
|
|
|
10347
10395
|
// src/commands/clean.ts
|
|
10348
10396
|
init_source();
|
|
10349
|
-
import { rmSync, existsSync as
|
|
10397
|
+
import { rmSync, existsSync as existsSync14 } from "fs";
|
|
10350
10398
|
import { join as join17 } from "path";
|
|
10351
10399
|
function clean(options) {
|
|
10352
10400
|
const root = process.cwd();
|
|
@@ -10357,7 +10405,7 @@ function clean(options) {
|
|
|
10357
10405
|
const lockfiles = ["bun.lockb", "package-lock.json", "yarn.lock", "pnpm-lock.yaml"];
|
|
10358
10406
|
for (const dir of dirs) {
|
|
10359
10407
|
const path = join17(root, dir);
|
|
10360
|
-
if (
|
|
10408
|
+
if (existsSync14(path)) {
|
|
10361
10409
|
rmSync(path, { recursive: true });
|
|
10362
10410
|
console.log(source_default.dim(` Removed ${dir}/`));
|
|
10363
10411
|
}
|
|
@@ -10365,7 +10413,7 @@ function clean(options) {
|
|
|
10365
10413
|
if (options?.all) {
|
|
10366
10414
|
for (const file of lockfiles) {
|
|
10367
10415
|
const path = join17(root, file);
|
|
10368
|
-
if (
|
|
10416
|
+
if (existsSync14(path)) {
|
|
10369
10417
|
rmSync(path);
|
|
10370
10418
|
console.log(source_default.dim(` Removed ${file}`));
|
|
10371
10419
|
}
|
|
@@ -10420,7 +10468,7 @@ async function loginFromProfile(profiles) {
|
|
|
10420
10468
|
name: picked.user?.name || picked.user?.username || picked.id,
|
|
10421
10469
|
email: picked.user?.email || ""
|
|
10422
10470
|
};
|
|
10423
|
-
store({ token: picked.token, portal: DEFAULT_PORTAL, user });
|
|
10471
|
+
store({ token: picked.token, portal: DEFAULT_PORTAL, user, profileId: picked.id });
|
|
10424
10472
|
console.log(source_default.green(`Logged in as ${user.name}`));
|
|
10425
10473
|
if (user.email)
|
|
10426
10474
|
console.log(source_default.dim(` ${user.email}`));
|
|
@@ -10513,7 +10561,7 @@ function update() {
|
|
|
10513
10561
|
|
|
10514
10562
|
// src/commands/graph/init.ts
|
|
10515
10563
|
init_source();
|
|
10516
|
-
import { existsSync as
|
|
10564
|
+
import { existsSync as existsSync15, readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync5 } from "fs";
|
|
10517
10565
|
import { join as join18 } from "path";
|
|
10518
10566
|
import { execSync as execSync6 } from "child_process";
|
|
10519
10567
|
function graphInit() {
|
|
@@ -10527,7 +10575,7 @@ function graphInit() {
|
|
|
10527
10575
|
const modelsDir = join18(root, "src", "models");
|
|
10528
10576
|
mkdirSync5(modelsDir, { recursive: true });
|
|
10529
10577
|
const indexPath = join18(modelsDir, "index.ts");
|
|
10530
|
-
if (!
|
|
10578
|
+
if (!existsSync15(indexPath)) {
|
|
10531
10579
|
writeFileSync7(indexPath, `// Data models for ${m.name}
|
|
10532
10580
|
// Generated by construct graph init
|
|
10533
10581
|
|
|
@@ -10536,7 +10584,7 @@ function graphInit() {
|
|
|
10536
10584
|
`);
|
|
10537
10585
|
}
|
|
10538
10586
|
const pkgPath = join18(root, "package.json");
|
|
10539
|
-
const pkg = JSON.parse(
|
|
10587
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
|
|
10540
10588
|
if (!pkg.dependencies)
|
|
10541
10589
|
pkg.dependencies = {};
|
|
10542
10590
|
if (!pkg.dependencies["@construct-space/graph"]) {
|
|
@@ -10567,7 +10615,7 @@ function graphInit() {
|
|
|
10567
10615
|
|
|
10568
10616
|
// src/commands/graph/generate.ts
|
|
10569
10617
|
init_source();
|
|
10570
|
-
import { existsSync as
|
|
10618
|
+
import { existsSync as existsSync16, readFileSync as readFileSync12, writeFileSync as writeFileSync8, mkdirSync as mkdirSync6 } from "fs";
|
|
10571
10619
|
import { join as join19 } from "path";
|
|
10572
10620
|
var FIELD_TYPES = {
|
|
10573
10621
|
string: "field.string()",
|
|
@@ -10723,7 +10771,7 @@ function generate2(modelName, fieldSpecs, options) {
|
|
|
10723
10771
|
const modelsDir = join19(root, "src", "models");
|
|
10724
10772
|
mkdirSync6(modelsDir, { recursive: true });
|
|
10725
10773
|
const filePath = join19(modelsDir, `${name}.ts`);
|
|
10726
|
-
if (
|
|
10774
|
+
if (existsSync16(filePath)) {
|
|
10727
10775
|
console.log(source_default.yellow(` Model file already exists: src/models/${name}.ts`));
|
|
10728
10776
|
console.log(source_default.dim(" Overwriting..."));
|
|
10729
10777
|
}
|
|
@@ -10742,8 +10790,8 @@ function generate2(modelName, fieldSpecs, options) {
|
|
|
10742
10790
|
function updateBarrel(modelsDir, modelName) {
|
|
10743
10791
|
const indexPath = join19(modelsDir, "index.ts");
|
|
10744
10792
|
const exportLine = `export { ${modelName} } from './${modelName}'`;
|
|
10745
|
-
if (
|
|
10746
|
-
const content =
|
|
10793
|
+
if (existsSync16(indexPath)) {
|
|
10794
|
+
const content = readFileSync12(indexPath, "utf-8");
|
|
10747
10795
|
if (content.includes(exportLine))
|
|
10748
10796
|
return;
|
|
10749
10797
|
writeFileSync8(indexPath, content.trimEnd() + `
|
|
@@ -10758,7 +10806,7 @@ function updateBarrel(modelsDir, modelName) {
|
|
|
10758
10806
|
|
|
10759
10807
|
// src/commands/graph/push.ts
|
|
10760
10808
|
init_source();
|
|
10761
|
-
import { existsSync as
|
|
10809
|
+
import { existsSync as existsSync17, readdirSync as readdirSync6, readFileSync as readFileSync13 } from "fs";
|
|
10762
10810
|
import { join as join20, basename as basename7 } from "path";
|
|
10763
10811
|
init_auth();
|
|
10764
10812
|
async function graphPush() {
|
|
@@ -10769,7 +10817,7 @@ async function graphPush() {
|
|
|
10769
10817
|
}
|
|
10770
10818
|
const m = read(root);
|
|
10771
10819
|
const modelsDir = join20(root, "src", "models");
|
|
10772
|
-
if (!
|
|
10820
|
+
if (!existsSync17(modelsDir)) {
|
|
10773
10821
|
console.error(source_default.red("No src/models/ directory found. Run 'construct graph init' first."));
|
|
10774
10822
|
process.exit(1);
|
|
10775
10823
|
}
|
|
@@ -10782,7 +10830,7 @@ async function graphPush() {
|
|
|
10782
10830
|
console.log(source_default.blue(`Pushing ${modelFiles.length} model(s) for space: ${m.id}`));
|
|
10783
10831
|
const models = [];
|
|
10784
10832
|
for (const file of modelFiles) {
|
|
10785
|
-
const content =
|
|
10833
|
+
const content = readFileSync13(join20(modelsDir, file), "utf-8");
|
|
10786
10834
|
const model = parseModelFile(content, basename7(file, ".ts"));
|
|
10787
10835
|
if (model)
|
|
10788
10836
|
models.push(model);
|
|
@@ -10813,7 +10861,10 @@ async function graphPush() {
|
|
|
10813
10861
|
"X-Space-ID": m.id,
|
|
10814
10862
|
"X-Auth-User-ID": userID
|
|
10815
10863
|
};
|
|
10816
|
-
|
|
10864
|
+
let pushOrgID = process.env.CONSTRUCT_ORG_ID || "";
|
|
10865
|
+
if (!pushOrgID && creds.profileId?.startsWith("org:")) {
|
|
10866
|
+
pushOrgID = creds.profileId.slice("org:".length);
|
|
10867
|
+
}
|
|
10817
10868
|
if (pushOrgID)
|
|
10818
10869
|
headers["X-Auth-Org-ID"] = pushOrgID;
|
|
10819
10870
|
const resp = await fetch(`${graphURL}/api/schemas/register`, {
|
|
@@ -10924,7 +10975,7 @@ function parseModelFile(content, fileName) {
|
|
|
10924
10975
|
|
|
10925
10976
|
// src/commands/graph/migrate.ts
|
|
10926
10977
|
init_source();
|
|
10927
|
-
import { existsSync as
|
|
10978
|
+
import { existsSync as existsSync18, readdirSync as readdirSync7, readFileSync as readFileSync14 } from "fs";
|
|
10928
10979
|
import { join as join21, basename as basename8 } from "path";
|
|
10929
10980
|
init_auth();
|
|
10930
10981
|
async function graphMigrate(options) {
|
|
@@ -10935,7 +10986,7 @@ async function graphMigrate(options) {
|
|
|
10935
10986
|
}
|
|
10936
10987
|
const m = read(root);
|
|
10937
10988
|
const modelsDir = join21(root, "src", "models");
|
|
10938
|
-
if (!
|
|
10989
|
+
if (!existsSync18(modelsDir)) {
|
|
10939
10990
|
console.error(source_default.red("No src/models/ directory. Run 'construct graph init' first."));
|
|
10940
10991
|
process.exit(1);
|
|
10941
10992
|
}
|
|
@@ -10965,7 +11016,7 @@ async function graphMigrate(options) {
|
|
|
10965
11016
|
const modelFiles = readdirSync7(modelsDir).filter((f) => f.endsWith(".ts") && f !== "index.ts");
|
|
10966
11017
|
const localModels = [];
|
|
10967
11018
|
for (const file of modelFiles) {
|
|
10968
|
-
const content =
|
|
11019
|
+
const content = readFileSync14(join21(modelsDir, file), "utf-8");
|
|
10969
11020
|
const model = parseModelFields(content, basename8(file, ".ts"));
|
|
10970
11021
|
if (model)
|
|
10971
11022
|
localModels.push(model);
|
|
@@ -11070,7 +11121,7 @@ function parseModelFields(content, fileName) {
|
|
|
11070
11121
|
// package.json
|
|
11071
11122
|
var package_default = {
|
|
11072
11123
|
name: "@construct-space/cli",
|
|
11073
|
-
version: "1.
|
|
11124
|
+
version: "1.5.0",
|
|
11074
11125
|
description: "Construct CLI \u2014 scaffold, build, develop, and publish spaces",
|
|
11075
11126
|
type: "module",
|
|
11076
11127
|
bin: {
|