@construct-space/cli 1.1.9 → 1.1.11
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 +273 -231
- package/dist/templates/space/full/space.manifest.json.tmpl +1 -1
- package/dist/templates/space/space.manifest.json.tmpl +1 -1
- package/dist/templates/space/widgets/2x1.vue.tmpl +0 -7
- package/dist/templates/space/widgets/4x1.vue.tmpl +0 -7
- package/package.json +1 -1
- package/templates/space/full/space.manifest.json.tmpl +1 -1
- package/templates/space/space.manifest.json.tmpl +1 -1
- package/templates/space/widgets/2x1.vue.tmpl +0 -7
- package/templates/space/widgets/4x1.vue.tmpl +0 -7
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 __require = import.meta.require;
|
|
@@ -2789,7 +2807,6 @@ Object.defineProperties(createChalk.prototype, styles2);
|
|
|
2789
2807
|
var chalk = createChalk();
|
|
2790
2808
|
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
2791
2809
|
var source_default = chalk;
|
|
2792
|
-
|
|
2793
2810
|
// node_modules/@inquirer/core/dist/lib/key.js
|
|
2794
2811
|
var isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p";
|
|
2795
2812
|
var isDownKey = (key, keybindings = []) => key.name === "down" || keybindings.includes("vim") && key.name === "j" || keybindings.includes("emacs") && key.ctrl && key.name === "n";
|
|
@@ -2934,7 +2951,7 @@ var effectScheduler = {
|
|
|
2934
2951
|
// node_modules/@inquirer/core/dist/lib/use-state.js
|
|
2935
2952
|
function useState(defaultValue) {
|
|
2936
2953
|
return withPointer((pointer) => {
|
|
2937
|
-
const setState = AsyncResource2.bind(function
|
|
2954
|
+
const setState = AsyncResource2.bind(function setState2(newValue) {
|
|
2938
2955
|
if (pointer.get() !== newValue) {
|
|
2939
2956
|
pointer.set(newValue);
|
|
2940
2957
|
handleChange();
|
|
@@ -4590,9 +4607,10 @@ function watchCmd(root, _rt) {
|
|
|
4590
4607
|
return spawn("bun", ["run", "vite", "build", "--watch"], { cwd: root, stdio: "pipe" });
|
|
4591
4608
|
}
|
|
4592
4609
|
function runHook(hooks, hookName, root) {
|
|
4593
|
-
|
|
4610
|
+
const cmd = hooks?.[hookName];
|
|
4611
|
+
if (!cmd)
|
|
4594
4612
|
return;
|
|
4595
|
-
execSync2(
|
|
4613
|
+
execSync2(cmd, { cwd: root, stdio: "inherit" });
|
|
4596
4614
|
}
|
|
4597
4615
|
|
|
4598
4616
|
// src/commands/scaffold.ts
|
|
@@ -4709,7 +4727,7 @@ async function scaffold(nameArg, options) {
|
|
|
4709
4727
|
}
|
|
4710
4728
|
|
|
4711
4729
|
// src/commands/build.ts
|
|
4712
|
-
import { existsSync as existsSync6, readFileSync as readFileSync4, readdirSync as
|
|
4730
|
+
import { existsSync as existsSync6, readFileSync as readFileSync4, readdirSync as readdirSync2, renameSync, statSync as statSync2 } from "fs";
|
|
4713
4731
|
import { join as join6 } from "path";
|
|
4714
4732
|
import { createHash } from "crypto";
|
|
4715
4733
|
|
|
@@ -7362,8 +7380,8 @@ function validate2(m) {
|
|
|
7362
7380
|
errors2.push("author: must be an object with a name");
|
|
7363
7381
|
if (!m.icon)
|
|
7364
7382
|
errors2.push("icon: must be a string");
|
|
7365
|
-
if (!["
|
|
7366
|
-
errors2.push('scope: must be "
|
|
7383
|
+
if (!["company", "project", "both"].includes(m.scope))
|
|
7384
|
+
errors2.push('scope: must be "company", "project", or "both"');
|
|
7367
7385
|
if (!m.pages?.length)
|
|
7368
7386
|
errors2.push("pages: must be a non-empty array");
|
|
7369
7387
|
if (!m.navigation?.label)
|
|
@@ -7390,84 +7408,30 @@ function exists(dir) {
|
|
|
7390
7408
|
}
|
|
7391
7409
|
|
|
7392
7410
|
// src/lib/entry.ts
|
|
7393
|
-
import { writeFileSync as writeFileSync3, mkdirSync as mkdirSync2, existsSync as existsSync4
|
|
7394
|
-
import { join as join4, basename, extname
|
|
7411
|
+
import { writeFileSync as writeFileSync3, mkdirSync as mkdirSync2, existsSync as existsSync4 } from "fs";
|
|
7412
|
+
import { join as join4, basename, extname } from "path";
|
|
7395
7413
|
function capitalize(s) {
|
|
7396
7414
|
if (!s)
|
|
7397
7415
|
return s;
|
|
7398
7416
|
return s.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("");
|
|
7399
7417
|
}
|
|
7400
|
-
function
|
|
7401
|
-
const results = [];
|
|
7402
|
-
function walk(dir, routeSegments) {
|
|
7403
|
-
if (!existsSync4(dir))
|
|
7404
|
-
return;
|
|
7405
|
-
const entries = readdirSync(dir).sort();
|
|
7406
|
-
for (const entry of entries) {
|
|
7407
|
-
const fullPath = join4(dir, entry);
|
|
7408
|
-
const stat = statSync(fullPath);
|
|
7409
|
-
if (stat.isDirectory()) {
|
|
7410
|
-
const segment = entry.replace(/^\[(.+)\]$/, ":$1");
|
|
7411
|
-
walk(fullPath, [...routeSegments, segment]);
|
|
7412
|
-
} else if (stat.isFile() && entry.endsWith(".vue")) {
|
|
7413
|
-
const nameWithoutExt = entry.replace(/\.vue$/, "");
|
|
7414
|
-
const relFile = relative(join4(pagesDir, ".."), fullPath).replace(/\\/g, "/");
|
|
7415
|
-
let routePath;
|
|
7416
|
-
if (nameWithoutExt === "index") {
|
|
7417
|
-
routePath = routeSegments.join("/");
|
|
7418
|
-
} else {
|
|
7419
|
-
const segment = nameWithoutExt.replace(/^\[(.+)\]$/, ":$1");
|
|
7420
|
-
routePath = [...routeSegments, segment].join("/");
|
|
7421
|
-
}
|
|
7422
|
-
results.push({ filePath: relFile, routePath });
|
|
7423
|
-
}
|
|
7424
|
-
}
|
|
7425
|
-
}
|
|
7426
|
-
walk(pagesDir, []);
|
|
7427
|
-
return results;
|
|
7428
|
-
}
|
|
7429
|
-
function varNameFromFile(filePath) {
|
|
7430
|
-
let cleaned = filePath.replace(/^pages\//, "").replace(/\.vue$/, "");
|
|
7431
|
-
cleaned = cleaned.replace(/\[([^\]]+)\]/g, "$1");
|
|
7432
|
-
const segments = cleaned.split(/[\/-]/).filter(Boolean);
|
|
7433
|
-
const name = segments.map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join("");
|
|
7434
|
-
return (name || "Index") + "Page";
|
|
7435
|
-
}
|
|
7436
|
-
function resolvePages(m, root, prefix) {
|
|
7437
|
-
const pagesDir = join4(root, "src", "pages");
|
|
7438
|
-
const fsPages = scanPagesDir(pagesDir);
|
|
7439
|
-
const fsMap = new Map;
|
|
7440
|
-
for (const fp of fsPages) {
|
|
7441
|
-
fsMap.set(fp.routePath, fp);
|
|
7442
|
-
}
|
|
7418
|
+
function resolvePages(m, prefix) {
|
|
7443
7419
|
return m.pages.map((p) => {
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
const dir = p.component.replace(/^pages\//, "").replace(/\/[^/]+$/, "");
|
|
7448
|
-
let varName;
|
|
7449
|
-
if (dir && dir !== p.component.replace(/^pages\//, "")) {
|
|
7450
|
-
varName = capitalize(dir.split("/").map((s) => s.replace(/[\[\]]/g, "")).join("-")) + capitalize(nameWithoutExt) + "Page";
|
|
7451
|
-
} else {
|
|
7452
|
-
varName = capitalize(nameWithoutExt) + "Page";
|
|
7453
|
-
}
|
|
7454
|
-
return { varName, importPath: prefix + p.component, path: p.path };
|
|
7455
|
-
}
|
|
7456
|
-
const fsPage = fsMap.get(p.path);
|
|
7457
|
-
if (fsPage) {
|
|
7458
|
-
const varName = varNameFromFile(fsPage.filePath);
|
|
7459
|
-
return { varName, importPath: prefix + fsPage.filePath, path: p.path };
|
|
7420
|
+
let component = p.component;
|
|
7421
|
+
if (!component) {
|
|
7422
|
+
component = p.path === "" ? "pages/index.vue" : `pages/${p.path}.vue`;
|
|
7460
7423
|
}
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7424
|
+
let varName = "IndexPage";
|
|
7425
|
+
if (p.path) {
|
|
7426
|
+
let cleanPath = p.path.replace(/:/g, "");
|
|
7427
|
+
if (p.component) {
|
|
7428
|
+
let base = basename(p.component);
|
|
7429
|
+
base = base.replace(extname(base), "").replace(/[\[\]]/g, "");
|
|
7430
|
+
cleanPath = base;
|
|
7467
7431
|
}
|
|
7468
|
-
|
|
7432
|
+
varName = capitalize(cleanPath) + "Page";
|
|
7469
7433
|
}
|
|
7470
|
-
|
|
7434
|
+
return { varName, importPath: prefix + component, path: p.path };
|
|
7471
7435
|
});
|
|
7472
7436
|
}
|
|
7473
7437
|
function resolveWidgets(m, prefix) {
|
|
@@ -7486,7 +7450,7 @@ function resolveWidgets(m, prefix) {
|
|
|
7486
7450
|
}
|
|
7487
7451
|
function generate(root, m) {
|
|
7488
7452
|
const pagePrefix = existsSync4(join4(root, "src", "pages")) ? "./" : "../";
|
|
7489
|
-
const pages = resolvePages(m,
|
|
7453
|
+
const pages = resolvePages(m, pagePrefix);
|
|
7490
7454
|
const widgets = resolveWidgets(m, "../");
|
|
7491
7455
|
const actionsPath = join4(root, "src", "actions.ts");
|
|
7492
7456
|
const hasActions = existsSync4(actionsPath);
|
|
@@ -7542,7 +7506,7 @@ function writeEntry(root, m) {
|
|
|
7542
7506
|
}
|
|
7543
7507
|
|
|
7544
7508
|
// src/lib/agent.ts
|
|
7545
|
-
import { readFileSync as readFileSync3, writeFileSync as writeFileSync4, readdirSync
|
|
7509
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync4, readdirSync, existsSync as existsSync5 } from "fs";
|
|
7546
7510
|
import { join as join5, extname as extname2, basename as basename2 } from "path";
|
|
7547
7511
|
var AGENT_KEY = "construct-agent-obfuscate-v1";
|
|
7548
7512
|
function encode(content) {
|
|
@@ -7558,7 +7522,7 @@ function readMdFiles(dir) {
|
|
|
7558
7522
|
const result = {};
|
|
7559
7523
|
if (!existsSync5(dir))
|
|
7560
7524
|
return result;
|
|
7561
|
-
for (const f of
|
|
7525
|
+
for (const f of readdirSync(dir)) {
|
|
7562
7526
|
if (extname2(f) !== ".md")
|
|
7563
7527
|
continue;
|
|
7564
7528
|
result[basename2(f, ".md")] = readFileSync3(join5(dir, f), "utf-8");
|
|
@@ -7569,7 +7533,7 @@ function readJsonFiles(dir) {
|
|
|
7569
7533
|
const result = {};
|
|
7570
7534
|
if (!existsSync5(dir))
|
|
7571
7535
|
return result;
|
|
7572
|
-
for (const f of
|
|
7536
|
+
for (const f of readdirSync(dir)) {
|
|
7573
7537
|
if (extname2(f) !== ".json")
|
|
7574
7538
|
continue;
|
|
7575
7539
|
result[basename2(f, ".json")] = readFileSync3(join5(dir, f), "utf-8");
|
|
@@ -7659,7 +7623,7 @@ async function build(options) {
|
|
|
7659
7623
|
}
|
|
7660
7624
|
runHook(m.hooks, "postBuild", root);
|
|
7661
7625
|
const agentDir = join6(root, "agent");
|
|
7662
|
-
if (existsSync6(agentDir) &&
|
|
7626
|
+
if (existsSync6(agentDir) && statSync2(agentDir).isDirectory()) {
|
|
7663
7627
|
const distDir2 = join6(root, "dist");
|
|
7664
7628
|
bundleAgentDir(agentDir, distDir2);
|
|
7665
7629
|
bundleAgentDir(agentDir, root);
|
|
@@ -7668,7 +7632,7 @@ async function build(options) {
|
|
|
7668
7632
|
const expectedBundle = `space-${m.id}.iife.js`;
|
|
7669
7633
|
let bundlePath = join6(distDir, expectedBundle);
|
|
7670
7634
|
if (!existsSync6(bundlePath)) {
|
|
7671
|
-
const matches =
|
|
7635
|
+
const matches = readdirSync2(distDir).filter((f) => f.startsWith("space-") && f.endsWith(".iife.js"));
|
|
7672
7636
|
if (matches.length === 1) {
|
|
7673
7637
|
renameSync(join6(distDir, matches[0]), bundlePath);
|
|
7674
7638
|
const oldCSS = join6(distDir, matches[0].replace(".iife.js", ".css"));
|
|
@@ -7702,16 +7666,16 @@ import { existsSync as existsSync7, readFileSync as readFileSync5 } from "fs";
|
|
|
7702
7666
|
import { join as join9 } from "path";
|
|
7703
7667
|
import { createHash as createHash2 } from "crypto";
|
|
7704
7668
|
|
|
7705
|
-
// node_modules/chokidar/index.js
|
|
7669
|
+
// node_modules/chokidar/esm/index.js
|
|
7670
|
+
import { stat as statcb } from "fs";
|
|
7671
|
+
import { stat as stat3, readdir as readdir2 } from "fs/promises";
|
|
7706
7672
|
import { EventEmitter } from "events";
|
|
7707
|
-
import
|
|
7708
|
-
import { readdir as readdir2, stat as stat3 } from "fs/promises";
|
|
7709
|
-
import * as sp2 from "path";
|
|
7673
|
+
import * as sysPath2 from "path";
|
|
7710
7674
|
|
|
7711
|
-
// node_modules/readdirp/index.js
|
|
7712
|
-
import { lstat, readdir, realpath
|
|
7713
|
-
import { join as pjoin, relative as prelative, resolve as presolve, sep as psep } from "path";
|
|
7675
|
+
// node_modules/readdirp/esm/index.js
|
|
7676
|
+
import { stat, lstat, readdir, realpath } from "fs/promises";
|
|
7714
7677
|
import { Readable } from "stream";
|
|
7678
|
+
import { resolve as presolve, relative as prelative, join as pjoin, sep as psep } from "path";
|
|
7715
7679
|
var EntryTypes = {
|
|
7716
7680
|
FILE_TYPE: "files",
|
|
7717
7681
|
DIR_TYPE: "directories",
|
|
@@ -7767,20 +7731,6 @@ var normalizeFilter = (filter) => {
|
|
|
7767
7731
|
};
|
|
7768
7732
|
|
|
7769
7733
|
class ReaddirpStream extends Readable {
|
|
7770
|
-
parents;
|
|
7771
|
-
reading;
|
|
7772
|
-
parent;
|
|
7773
|
-
_stat;
|
|
7774
|
-
_maxDepth;
|
|
7775
|
-
_wantsDir;
|
|
7776
|
-
_wantsFile;
|
|
7777
|
-
_wantsEverything;
|
|
7778
|
-
_root;
|
|
7779
|
-
_isDirent;
|
|
7780
|
-
_statsProp;
|
|
7781
|
-
_rdOptions;
|
|
7782
|
-
_fileFilter;
|
|
7783
|
-
_directoryFilter;
|
|
7784
7734
|
constructor(options = {}) {
|
|
7785
7735
|
super({
|
|
7786
7736
|
objectMode: true,
|
|
@@ -7797,7 +7747,7 @@ class ReaddirpStream extends Readable {
|
|
|
7797
7747
|
} else {
|
|
7798
7748
|
this._stat = statMethod;
|
|
7799
7749
|
}
|
|
7800
|
-
this._maxDepth = opts.depth
|
|
7750
|
+
this._maxDepth = opts.depth ?? defaultOptions.depth;
|
|
7801
7751
|
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
7802
7752
|
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
7803
7753
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
@@ -7942,11 +7892,11 @@ function readdirp(root, options = {}) {
|
|
|
7942
7892
|
return new ReaddirpStream(options);
|
|
7943
7893
|
}
|
|
7944
7894
|
|
|
7945
|
-
// node_modules/chokidar/handler.js
|
|
7946
|
-
import { watch as fs_watch
|
|
7947
|
-
import {
|
|
7895
|
+
// node_modules/chokidar/esm/handler.js
|
|
7896
|
+
import { watchFile, unwatchFile, watch as fs_watch } from "fs";
|
|
7897
|
+
import { open, stat as stat2, lstat as lstat2, realpath as fsrealpath } from "fs/promises";
|
|
7898
|
+
import * as sysPath from "path";
|
|
7948
7899
|
import { type as osType } from "os";
|
|
7949
|
-
import * as sp from "path";
|
|
7950
7900
|
var STR_DATA = "data";
|
|
7951
7901
|
var STR_END = "end";
|
|
7952
7902
|
var STR_CLOSE = "close";
|
|
@@ -8238,7 +8188,7 @@ var binaryExtensions = new Set([
|
|
|
8238
8188
|
"zip",
|
|
8239
8189
|
"zipx"
|
|
8240
8190
|
]);
|
|
8241
|
-
var isBinaryPath = (filePath) => binaryExtensions.has(
|
|
8191
|
+
var isBinaryPath = (filePath) => binaryExtensions.has(sysPath.extname(filePath).slice(1).toLowerCase());
|
|
8242
8192
|
var foreach = (val, fn) => {
|
|
8243
8193
|
if (val instanceof Set) {
|
|
8244
8194
|
val.forEach(fn);
|
|
@@ -8276,7 +8226,7 @@ function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
|
|
|
8276
8226
|
listener(path);
|
|
8277
8227
|
emitRaw(rawEvent, evPath, { watchedPath: path });
|
|
8278
8228
|
if (evPath && path !== evPath) {
|
|
8279
|
-
fsWatchBroadcast(
|
|
8229
|
+
fsWatchBroadcast(sysPath.resolve(path, evPath), KEY_LISTENERS, sysPath.join(path, evPath));
|
|
8280
8230
|
}
|
|
8281
8231
|
};
|
|
8282
8232
|
try {
|
|
@@ -8391,19 +8341,17 @@ var setFsWatchFileListener = (path, fullPath, options, handlers) => {
|
|
|
8391
8341
|
};
|
|
8392
8342
|
|
|
8393
8343
|
class NodeFsHandler {
|
|
8394
|
-
fsw;
|
|
8395
|
-
_boundHandleError;
|
|
8396
8344
|
constructor(fsW) {
|
|
8397
8345
|
this.fsw = fsW;
|
|
8398
8346
|
this._boundHandleError = (error2) => fsW._handleError(error2);
|
|
8399
8347
|
}
|
|
8400
8348
|
_watchWithNodeFs(path, listener) {
|
|
8401
8349
|
const opts = this.fsw.options;
|
|
8402
|
-
const directory =
|
|
8403
|
-
const basename4 =
|
|
8350
|
+
const directory = sysPath.dirname(path);
|
|
8351
|
+
const basename4 = sysPath.basename(path);
|
|
8404
8352
|
const parent = this.fsw._getWatchedDir(directory);
|
|
8405
8353
|
parent.add(basename4);
|
|
8406
|
-
const absolutePath =
|
|
8354
|
+
const absolutePath = sysPath.resolve(path);
|
|
8407
8355
|
const options = {
|
|
8408
8356
|
persistent: opts.persistent
|
|
8409
8357
|
};
|
|
@@ -8430,8 +8378,8 @@ class NodeFsHandler {
|
|
|
8430
8378
|
if (this.fsw.closed) {
|
|
8431
8379
|
return;
|
|
8432
8380
|
}
|
|
8433
|
-
const dirname3 =
|
|
8434
|
-
const basename4 =
|
|
8381
|
+
const dirname3 = sysPath.dirname(file);
|
|
8382
|
+
const basename4 = sysPath.basename(file);
|
|
8435
8383
|
const parent = this.fsw._getWatchedDir(dirname3);
|
|
8436
8384
|
let prevStats = stats;
|
|
8437
8385
|
if (parent.has(basename4))
|
|
@@ -8514,9 +8462,8 @@ class NodeFsHandler {
|
|
|
8514
8462
|
this.fsw._symlinkPaths.set(full, true);
|
|
8515
8463
|
}
|
|
8516
8464
|
_handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
|
|
8517
|
-
directory =
|
|
8518
|
-
|
|
8519
|
-
throttler = this.fsw._throttle("readdir", throttleKey, 1000);
|
|
8465
|
+
directory = sysPath.join(directory, "");
|
|
8466
|
+
throttler = this.fsw._throttle("readdir", directory, 1000);
|
|
8520
8467
|
if (!throttler)
|
|
8521
8468
|
return;
|
|
8522
8469
|
const previous = this.fsw._getWatchedDir(wh.path);
|
|
@@ -8533,7 +8480,7 @@ class NodeFsHandler {
|
|
|
8533
8480
|
return;
|
|
8534
8481
|
}
|
|
8535
8482
|
const item = entry.path;
|
|
8536
|
-
let path =
|
|
8483
|
+
let path = sysPath.join(directory, item);
|
|
8537
8484
|
current.add(item);
|
|
8538
8485
|
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) {
|
|
8539
8486
|
return;
|
|
@@ -8544,7 +8491,7 @@ class NodeFsHandler {
|
|
|
8544
8491
|
}
|
|
8545
8492
|
if (item === target || !target && !previous.has(item)) {
|
|
8546
8493
|
this.fsw._incrReadyCount();
|
|
8547
|
-
path =
|
|
8494
|
+
path = sysPath.join(dir, sysPath.relative(dir, path));
|
|
8548
8495
|
this._addToNodeFs(path, initialAdd, wh, depth + 1);
|
|
8549
8496
|
}
|
|
8550
8497
|
}).on(EV.ERROR, this._boundHandleError);
|
|
@@ -8570,12 +8517,12 @@ class NodeFsHandler {
|
|
|
8570
8517
|
});
|
|
8571
8518
|
}
|
|
8572
8519
|
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath2) {
|
|
8573
|
-
const parentDir = this.fsw._getWatchedDir(
|
|
8574
|
-
const tracked = parentDir.has(
|
|
8520
|
+
const parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir));
|
|
8521
|
+
const tracked = parentDir.has(sysPath.basename(dir));
|
|
8575
8522
|
if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
|
|
8576
8523
|
this.fsw._emit(EV.ADD_DIR, dir, stats);
|
|
8577
8524
|
}
|
|
8578
|
-
parentDir.add(
|
|
8525
|
+
parentDir.add(sysPath.basename(dir));
|
|
8579
8526
|
this.fsw._getWatchedDir(dir);
|
|
8580
8527
|
let throttler;
|
|
8581
8528
|
let closer;
|
|
@@ -8616,7 +8563,7 @@ class NodeFsHandler {
|
|
|
8616
8563
|
const follow = this.fsw.options.followSymlinks;
|
|
8617
8564
|
let closer;
|
|
8618
8565
|
if (stats.isDirectory()) {
|
|
8619
|
-
const absPath =
|
|
8566
|
+
const absPath = sysPath.resolve(path);
|
|
8620
8567
|
const targetPath = follow ? await fsrealpath(path) : path;
|
|
8621
8568
|
if (this.fsw.closed)
|
|
8622
8569
|
return;
|
|
@@ -8630,14 +8577,14 @@ class NodeFsHandler {
|
|
|
8630
8577
|
const targetPath = follow ? await fsrealpath(path) : path;
|
|
8631
8578
|
if (this.fsw.closed)
|
|
8632
8579
|
return;
|
|
8633
|
-
const parent =
|
|
8580
|
+
const parent = sysPath.dirname(wh.watchPath);
|
|
8634
8581
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
8635
8582
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
8636
8583
|
closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
|
|
8637
8584
|
if (this.fsw.closed)
|
|
8638
8585
|
return;
|
|
8639
8586
|
if (targetPath !== undefined) {
|
|
8640
|
-
this.fsw._symlinkPaths.set(
|
|
8587
|
+
this.fsw._symlinkPaths.set(sysPath.resolve(path), targetPath);
|
|
8641
8588
|
}
|
|
8642
8589
|
} else {
|
|
8643
8590
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
@@ -8655,7 +8602,7 @@ class NodeFsHandler {
|
|
|
8655
8602
|
}
|
|
8656
8603
|
}
|
|
8657
8604
|
|
|
8658
|
-
// node_modules/chokidar/index.js
|
|
8605
|
+
// node_modules/chokidar/esm/index.js
|
|
8659
8606
|
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
|
|
8660
8607
|
var SLASH = "/";
|
|
8661
8608
|
var SLASH_SLASH = "//";
|
|
@@ -8663,7 +8610,7 @@ var ONE_DOT = ".";
|
|
|
8663
8610
|
var TWO_DOTS = "..";
|
|
8664
8611
|
var STRING_TYPE = "string";
|
|
8665
8612
|
var BACK_SLASH_RE = /\\/g;
|
|
8666
|
-
var DOUBLE_SLASH_RE =
|
|
8613
|
+
var DOUBLE_SLASH_RE = /\/\//;
|
|
8667
8614
|
var DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
|
|
8668
8615
|
var REPLACER_RE = /^\.[/\\]/;
|
|
8669
8616
|
function arrify(item) {
|
|
@@ -8682,11 +8629,11 @@ function createPattern(matcher) {
|
|
|
8682
8629
|
if (matcher.path === string)
|
|
8683
8630
|
return true;
|
|
8684
8631
|
if (matcher.recursive) {
|
|
8685
|
-
const
|
|
8686
|
-
if (!
|
|
8632
|
+
const relative3 = sysPath2.relative(matcher.path, string);
|
|
8633
|
+
if (!relative3) {
|
|
8687
8634
|
return false;
|
|
8688
8635
|
}
|
|
8689
|
-
return !
|
|
8636
|
+
return !relative3.startsWith("..") && !sysPath2.isAbsolute(relative3);
|
|
8690
8637
|
}
|
|
8691
8638
|
return false;
|
|
8692
8639
|
};
|
|
@@ -8696,12 +8643,14 @@ function createPattern(matcher) {
|
|
|
8696
8643
|
function normalizePath(path) {
|
|
8697
8644
|
if (typeof path !== "string")
|
|
8698
8645
|
throw new Error("string expected");
|
|
8699
|
-
path =
|
|
8646
|
+
path = sysPath2.normalize(path);
|
|
8700
8647
|
path = path.replace(/\\/g, "/");
|
|
8701
8648
|
let prepend = false;
|
|
8702
8649
|
if (path.startsWith("//"))
|
|
8703
8650
|
prepend = true;
|
|
8704
|
-
|
|
8651
|
+
const DOUBLE_SLASH_RE2 = /\/\//;
|
|
8652
|
+
while (path.match(DOUBLE_SLASH_RE2))
|
|
8653
|
+
path = path.replace(DOUBLE_SLASH_RE2, "/");
|
|
8705
8654
|
if (prepend)
|
|
8706
8655
|
path = "/" + path;
|
|
8707
8656
|
return path;
|
|
@@ -8742,32 +8691,31 @@ var toUnix = (string) => {
|
|
|
8742
8691
|
if (str.startsWith(SLASH_SLASH)) {
|
|
8743
8692
|
prepend = true;
|
|
8744
8693
|
}
|
|
8745
|
-
|
|
8694
|
+
while (str.match(DOUBLE_SLASH_RE)) {
|
|
8695
|
+
str = str.replace(DOUBLE_SLASH_RE, SLASH);
|
|
8696
|
+
}
|
|
8746
8697
|
if (prepend) {
|
|
8747
8698
|
str = SLASH + str;
|
|
8748
8699
|
}
|
|
8749
8700
|
return str;
|
|
8750
8701
|
};
|
|
8751
|
-
var normalizePathToUnix = (path) => toUnix(
|
|
8702
|
+
var normalizePathToUnix = (path) => toUnix(sysPath2.normalize(toUnix(path)));
|
|
8752
8703
|
var normalizeIgnored = (cwd = "") => (path) => {
|
|
8753
8704
|
if (typeof path === "string") {
|
|
8754
|
-
return normalizePathToUnix(
|
|
8705
|
+
return normalizePathToUnix(sysPath2.isAbsolute(path) ? path : sysPath2.join(cwd, path));
|
|
8755
8706
|
} else {
|
|
8756
8707
|
return path;
|
|
8757
8708
|
}
|
|
8758
8709
|
};
|
|
8759
8710
|
var getAbsolutePath = (path, cwd) => {
|
|
8760
|
-
if (
|
|
8711
|
+
if (sysPath2.isAbsolute(path)) {
|
|
8761
8712
|
return path;
|
|
8762
8713
|
}
|
|
8763
|
-
return
|
|
8714
|
+
return sysPath2.join(cwd, path);
|
|
8764
8715
|
};
|
|
8765
8716
|
var EMPTY_SET = Object.freeze(new Set);
|
|
8766
8717
|
|
|
8767
8718
|
class DirEntry {
|
|
8768
|
-
path;
|
|
8769
|
-
_removeWatcher;
|
|
8770
|
-
items;
|
|
8771
8719
|
constructor(dir, removeWatcher) {
|
|
8772
8720
|
this.path = dir;
|
|
8773
8721
|
this._removeWatcher = removeWatcher;
|
|
@@ -8792,7 +8740,7 @@ class DirEntry {
|
|
|
8792
8740
|
await readdir2(dir);
|
|
8793
8741
|
} catch (err) {
|
|
8794
8742
|
if (this._removeWatcher) {
|
|
8795
|
-
this._removeWatcher(
|
|
8743
|
+
this._removeWatcher(sysPath2.dirname(dir), sysPath2.basename(dir));
|
|
8796
8744
|
}
|
|
8797
8745
|
}
|
|
8798
8746
|
}
|
|
@@ -8820,19 +8768,12 @@ var STAT_METHOD_F = "stat";
|
|
|
8820
8768
|
var STAT_METHOD_L = "lstat";
|
|
8821
8769
|
|
|
8822
8770
|
class WatchHelper {
|
|
8823
|
-
fsw;
|
|
8824
|
-
path;
|
|
8825
|
-
watchPath;
|
|
8826
|
-
fullWatchPath;
|
|
8827
|
-
dirParts;
|
|
8828
|
-
followSymlinks;
|
|
8829
|
-
statMethod;
|
|
8830
8771
|
constructor(path, follow, fsw) {
|
|
8831
8772
|
this.fsw = fsw;
|
|
8832
8773
|
const watchPath = path;
|
|
8833
8774
|
this.path = path = path.replace(REPLACER_RE, "");
|
|
8834
8775
|
this.watchPath = watchPath;
|
|
8835
|
-
this.fullWatchPath =
|
|
8776
|
+
this.fullWatchPath = sysPath2.resolve(watchPath);
|
|
8836
8777
|
this.dirParts = [];
|
|
8837
8778
|
this.dirParts.forEach((parts) => {
|
|
8838
8779
|
if (parts.length > 1)
|
|
@@ -8842,7 +8783,7 @@ class WatchHelper {
|
|
|
8842
8783
|
this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
|
|
8843
8784
|
}
|
|
8844
8785
|
entryPath(entry) {
|
|
8845
|
-
return
|
|
8786
|
+
return sysPath2.join(this.watchPath, sysPath2.relative(this.watchPath, entry.fullPath));
|
|
8846
8787
|
}
|
|
8847
8788
|
filterPath(entry) {
|
|
8848
8789
|
const { stats } = entry;
|
|
@@ -8857,24 +8798,6 @@ class WatchHelper {
|
|
|
8857
8798
|
}
|
|
8858
8799
|
|
|
8859
8800
|
class FSWatcher extends EventEmitter {
|
|
8860
|
-
closed;
|
|
8861
|
-
options;
|
|
8862
|
-
_closers;
|
|
8863
|
-
_ignoredPaths;
|
|
8864
|
-
_throttled;
|
|
8865
|
-
_streams;
|
|
8866
|
-
_symlinkPaths;
|
|
8867
|
-
_watched;
|
|
8868
|
-
_pendingWrites;
|
|
8869
|
-
_pendingUnlinks;
|
|
8870
|
-
_readyCount;
|
|
8871
|
-
_emitReady;
|
|
8872
|
-
_closePromise;
|
|
8873
|
-
_userIgnored;
|
|
8874
|
-
_readyEmitted;
|
|
8875
|
-
_emitRaw;
|
|
8876
|
-
_boundRemove;
|
|
8877
|
-
_nodeFsHandler;
|
|
8878
8801
|
constructor(_opts = {}) {
|
|
8879
8802
|
super();
|
|
8880
8803
|
this.closed = false;
|
|
@@ -8983,7 +8906,7 @@ class FSWatcher extends EventEmitter {
|
|
|
8983
8906
|
return;
|
|
8984
8907
|
results.forEach((item) => {
|
|
8985
8908
|
if (item)
|
|
8986
|
-
this.add(
|
|
8909
|
+
this.add(sysPath2.dirname(item), sysPath2.basename(_origAdd || item));
|
|
8987
8910
|
});
|
|
8988
8911
|
});
|
|
8989
8912
|
return this;
|
|
@@ -8994,10 +8917,10 @@ class FSWatcher extends EventEmitter {
|
|
|
8994
8917
|
const paths = unifyPaths(paths_);
|
|
8995
8918
|
const { cwd } = this.options;
|
|
8996
8919
|
paths.forEach((path) => {
|
|
8997
|
-
if (!
|
|
8920
|
+
if (!sysPath2.isAbsolute(path) && !this._closers.has(path)) {
|
|
8998
8921
|
if (cwd)
|
|
8999
|
-
path =
|
|
9000
|
-
path =
|
|
8922
|
+
path = sysPath2.join(cwd, path);
|
|
8923
|
+
path = sysPath2.resolve(path);
|
|
9001
8924
|
}
|
|
9002
8925
|
this._closePath(path);
|
|
9003
8926
|
this._addIgnoredPath(path);
|
|
@@ -9041,7 +8964,7 @@ class FSWatcher extends EventEmitter {
|
|
|
9041
8964
|
getWatched() {
|
|
9042
8965
|
const watchList = {};
|
|
9043
8966
|
this._watched.forEach((entry, dir) => {
|
|
9044
|
-
const key = this.options.cwd ?
|
|
8967
|
+
const key = this.options.cwd ? sysPath2.relative(this.options.cwd, dir) : dir;
|
|
9045
8968
|
const index = key || ONE_DOT;
|
|
9046
8969
|
watchList[index] = entry.getChildren().sort();
|
|
9047
8970
|
});
|
|
@@ -9057,9 +8980,9 @@ class FSWatcher extends EventEmitter {
|
|
|
9057
8980
|
return;
|
|
9058
8981
|
const opts = this.options;
|
|
9059
8982
|
if (isWindows)
|
|
9060
|
-
path =
|
|
8983
|
+
path = sysPath2.normalize(path);
|
|
9061
8984
|
if (opts.cwd)
|
|
9062
|
-
path =
|
|
8985
|
+
path = sysPath2.relative(opts.cwd, path);
|
|
9063
8986
|
const args = [path];
|
|
9064
8987
|
if (stats != null)
|
|
9065
8988
|
args.push(stats);
|
|
@@ -9110,7 +9033,7 @@ class FSWatcher extends EventEmitter {
|
|
|
9110
9033
|
return this;
|
|
9111
9034
|
}
|
|
9112
9035
|
if (opts.alwaysStat && stats === undefined && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
9113
|
-
const fullPath = opts.cwd ?
|
|
9036
|
+
const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path) : path;
|
|
9114
9037
|
let stats2;
|
|
9115
9038
|
try {
|
|
9116
9039
|
stats2 = await stat3(fullPath);
|
|
@@ -9166,8 +9089,8 @@ class FSWatcher extends EventEmitter {
|
|
|
9166
9089
|
const pollInterval = awf.pollInterval;
|
|
9167
9090
|
let timeoutHandler;
|
|
9168
9091
|
let fullPath = path;
|
|
9169
|
-
if (this.options.cwd && !
|
|
9170
|
-
fullPath =
|
|
9092
|
+
if (this.options.cwd && !sysPath2.isAbsolute(path)) {
|
|
9093
|
+
fullPath = sysPath2.join(this.options.cwd, path);
|
|
9171
9094
|
}
|
|
9172
9095
|
const now = new Date;
|
|
9173
9096
|
const writes = this._pendingWrites;
|
|
@@ -9224,7 +9147,7 @@ class FSWatcher extends EventEmitter {
|
|
|
9224
9147
|
return new WatchHelper(path, this.options.followSymlinks, this);
|
|
9225
9148
|
}
|
|
9226
9149
|
_getWatchedDir(directory) {
|
|
9227
|
-
const dir =
|
|
9150
|
+
const dir = sysPath2.resolve(directory);
|
|
9228
9151
|
if (!this._watched.has(dir))
|
|
9229
9152
|
this._watched.set(dir, new DirEntry(dir, this._boundRemove));
|
|
9230
9153
|
return this._watched.get(dir);
|
|
@@ -9235,8 +9158,8 @@ class FSWatcher extends EventEmitter {
|
|
|
9235
9158
|
return Boolean(Number(stats.mode) & 256);
|
|
9236
9159
|
}
|
|
9237
9160
|
_remove(directory, item, isDirectory) {
|
|
9238
|
-
const path =
|
|
9239
|
-
const fullPath =
|
|
9161
|
+
const path = sysPath2.join(directory, item);
|
|
9162
|
+
const fullPath = sysPath2.resolve(path);
|
|
9240
9163
|
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
|
|
9241
9164
|
if (!this._throttle("remove", path, 100))
|
|
9242
9165
|
return;
|
|
@@ -9254,7 +9177,7 @@ class FSWatcher extends EventEmitter {
|
|
|
9254
9177
|
}
|
|
9255
9178
|
let relPath = path;
|
|
9256
9179
|
if (this.options.cwd)
|
|
9257
|
-
relPath =
|
|
9180
|
+
relPath = sysPath2.relative(this.options.cwd, path);
|
|
9258
9181
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
9259
9182
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
9260
9183
|
if (event === EVENTS.ADD)
|
|
@@ -9269,8 +9192,8 @@ class FSWatcher extends EventEmitter {
|
|
|
9269
9192
|
}
|
|
9270
9193
|
_closePath(path) {
|
|
9271
9194
|
this._closeFile(path);
|
|
9272
|
-
const dir =
|
|
9273
|
-
this._getWatchedDir(dir).remove(
|
|
9195
|
+
const dir = sysPath2.dirname(path);
|
|
9196
|
+
this._getWatchedDir(dir).remove(sysPath2.basename(path));
|
|
9274
9197
|
}
|
|
9275
9198
|
_closeFile(path) {
|
|
9276
9199
|
const closers = this._closers.get(path);
|
|
@@ -9439,17 +9362,51 @@ function install() {
|
|
|
9439
9362
|
}
|
|
9440
9363
|
|
|
9441
9364
|
// src/commands/publish.ts
|
|
9442
|
-
import { readFileSync as readFileSync7, writeFileSync as writeFileSync6, statSync as
|
|
9365
|
+
import { readFileSync as readFileSync7, writeFileSync as writeFileSync6, statSync as statSync4, unlinkSync as unlinkSync2 } from "fs";
|
|
9443
9366
|
import { join as join14, basename as basename6 } from "path";
|
|
9444
9367
|
|
|
9445
9368
|
// src/lib/auth.ts
|
|
9446
9369
|
import { readFileSync as readFileSync6, writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, unlinkSync, existsSync as existsSync9 } from "fs";
|
|
9447
9370
|
import { join as join12, dirname as dirname4 } from "path";
|
|
9448
9371
|
var CREDENTIALS_FILE = "credentials.json";
|
|
9372
|
+
var APP_PROFILES_FILE = "profiles.json";
|
|
9449
9373
|
var DEFAULT_PORTAL = "https://developer.construct.space";
|
|
9450
9374
|
function credentialsPath() {
|
|
9451
9375
|
return join12(dataDir(), CREDENTIALS_FILE);
|
|
9452
9376
|
}
|
|
9377
|
+
function appProfilesPath() {
|
|
9378
|
+
return join12(dataDir(), APP_PROFILES_FILE);
|
|
9379
|
+
}
|
|
9380
|
+
function appProfileAuthPath(profileId) {
|
|
9381
|
+
return join12(dataDir(), "profiles", profileId, "auth.json");
|
|
9382
|
+
}
|
|
9383
|
+
function loadFromApp() {
|
|
9384
|
+
try {
|
|
9385
|
+
const profilesPath = appProfilesPath();
|
|
9386
|
+
if (!existsSync9(profilesPath))
|
|
9387
|
+
return null;
|
|
9388
|
+
const profiles = JSON.parse(readFileSync6(profilesPath, "utf-8"));
|
|
9389
|
+
if (!profiles?.active_profile)
|
|
9390
|
+
return null;
|
|
9391
|
+
const authPath = appProfileAuthPath(profiles.active_profile);
|
|
9392
|
+
if (!existsSync9(authPath))
|
|
9393
|
+
return null;
|
|
9394
|
+
const auth = JSON.parse(readFileSync6(authPath, "utf-8"));
|
|
9395
|
+
if (!auth?.authenticated || !auth?.token)
|
|
9396
|
+
return null;
|
|
9397
|
+
return {
|
|
9398
|
+
token: auth.token,
|
|
9399
|
+
portal: DEFAULT_PORTAL,
|
|
9400
|
+
user: {
|
|
9401
|
+
id: auth.user.id,
|
|
9402
|
+
name: auth.user.name || [auth.user.first_name, auth.user.last_name].filter(Boolean).join(" ") || auth.user.email,
|
|
9403
|
+
email: auth.user.email
|
|
9404
|
+
}
|
|
9405
|
+
};
|
|
9406
|
+
} catch {
|
|
9407
|
+
return null;
|
|
9408
|
+
}
|
|
9409
|
+
}
|
|
9453
9410
|
function store(creds) {
|
|
9454
9411
|
const path = credentialsPath();
|
|
9455
9412
|
mkdirSync4(dirname4(path), { recursive: true });
|
|
@@ -9457,9 +9414,12 @@ function store(creds) {
|
|
|
9457
9414
|
`, { mode: 384 });
|
|
9458
9415
|
}
|
|
9459
9416
|
function load2() {
|
|
9417
|
+
const fromApp = loadFromApp();
|
|
9418
|
+
if (fromApp)
|
|
9419
|
+
return fromApp;
|
|
9460
9420
|
const path = credentialsPath();
|
|
9461
9421
|
if (!existsSync9(path)) {
|
|
9462
|
-
throw new Error("not logged in \u2014 run 'construct login' first");
|
|
9422
|
+
throw new Error("not logged in \u2014 run 'construct login' first (or sign in to the Construct app)");
|
|
9463
9423
|
}
|
|
9464
9424
|
const data = JSON.parse(readFileSync6(path, "utf-8"));
|
|
9465
9425
|
if (!data.token) {
|
|
@@ -9482,7 +9442,7 @@ function clear() {
|
|
|
9482
9442
|
}
|
|
9483
9443
|
|
|
9484
9444
|
// src/lib/pack.ts
|
|
9485
|
-
import { readdirSync as
|
|
9445
|
+
import { readdirSync as readdirSync3, statSync as statSync3, existsSync as existsSync10 } from "fs";
|
|
9486
9446
|
import { join as join13 } from "path";
|
|
9487
9447
|
import { tmpdir } from "os";
|
|
9488
9448
|
import { execSync as execSync3 } from "child_process";
|
|
@@ -9524,8 +9484,8 @@ async function packSource(root) {
|
|
|
9524
9484
|
if (existsSync10(join13(root, name)))
|
|
9525
9485
|
entries.push(name);
|
|
9526
9486
|
}
|
|
9527
|
-
for (const entry of
|
|
9528
|
-
if (
|
|
9487
|
+
for (const entry of readdirSync3(root)) {
|
|
9488
|
+
if (statSync3(join13(root, entry)).isDirectory())
|
|
9529
9489
|
continue;
|
|
9530
9490
|
if (allowedRootFiles.includes(entry))
|
|
9531
9491
|
continue;
|
|
@@ -9545,7 +9505,7 @@ async function packSource(root) {
|
|
|
9545
9505
|
const excludes = "--exclude=node_modules --exclude=dist --exclude=.git --exclude=*.env --exclude=*.log --exclude=*.lock --exclude=*.lockb";
|
|
9546
9506
|
const cmd = `tar czf "${tarballPath}" ${excludes} ${validEntries.join(" ")}`;
|
|
9547
9507
|
execSync3(cmd, { cwd: root });
|
|
9548
|
-
const size =
|
|
9508
|
+
const size = statSync3(tarballPath).size;
|
|
9549
9509
|
if (size > MAX_SIZE) {
|
|
9550
9510
|
throw new Error(`Source exceeds maximum size of ${MAX_SIZE / 1024 / 1024}MB`);
|
|
9551
9511
|
}
|
|
@@ -9568,16 +9528,6 @@ async function uploadSource(portalURL, token, tarballPath, m) {
|
|
|
9568
9528
|
if (resp.status === 401) {
|
|
9569
9529
|
throw new Error("authentication failed \u2014 run 'construct login' to re-authenticate");
|
|
9570
9530
|
}
|
|
9571
|
-
if (resp.status === 403) {
|
|
9572
|
-
let msg = result.error || "You are not the owner of this space";
|
|
9573
|
-
if (result.owner_user_id) {
|
|
9574
|
-
msg += `
|
|
9575
|
-
Current owner: ${result.owner_user_id}`;
|
|
9576
|
-
}
|
|
9577
|
-
msg += `
|
|
9578
|
-
Fork to a new space_id to publish your own version.`;
|
|
9579
|
-
throw new Error(msg);
|
|
9580
|
-
}
|
|
9581
9531
|
if (resp.status >= 400) {
|
|
9582
9532
|
const msg = result.error || result.errors?.join("; ") || `server returned ${resp.status}`;
|
|
9583
9533
|
throw new Error(msg);
|
|
@@ -9612,6 +9562,24 @@ async function publish(options) {
|
|
|
9612
9562
|
console.log(source_default.dim(" Run 'construct login' to authenticate."));
|
|
9613
9563
|
process.exit(1);
|
|
9614
9564
|
}
|
|
9565
|
+
const publishers = creds.publishers || [];
|
|
9566
|
+
if (publishers.length === 0) {
|
|
9567
|
+
console.log(source_default.yellow(" No publisher linked to this session. The upload will likely be rejected."));
|
|
9568
|
+
console.log(source_default.dim(" Run 'construct login' after enrolling at developer.construct.space."));
|
|
9569
|
+
} else {
|
|
9570
|
+
const primary = publishers[0];
|
|
9571
|
+
const kindLabel = primary.kind === "org" ? source_default.cyan("org") : primary.kind === "user" ? source_default.blue("personal") : source_default.dim("legacy");
|
|
9572
|
+
console.log(source_default.dim(` Publishing as ${primary.name} (${kindLabel})`));
|
|
9573
|
+
if (publishers.length > 1 && !yes) {
|
|
9574
|
+
const proceed = await dist_default4({
|
|
9575
|
+
message: `You have ${publishers.length} publisher identities. Publish under ${primary.name}?`
|
|
9576
|
+
});
|
|
9577
|
+
if (!proceed) {
|
|
9578
|
+
console.log("Cancelled.");
|
|
9579
|
+
return;
|
|
9580
|
+
}
|
|
9581
|
+
}
|
|
9582
|
+
}
|
|
9615
9583
|
const status = gitSafe(root, "status", "--porcelain");
|
|
9616
9584
|
if (status) {
|
|
9617
9585
|
console.log(source_default.yellow("You have uncommitted changes."));
|
|
@@ -9695,7 +9663,7 @@ async function publish(options) {
|
|
|
9695
9663
|
let tarballPath;
|
|
9696
9664
|
try {
|
|
9697
9665
|
tarballPath = await packSource(root);
|
|
9698
|
-
const size =
|
|
9666
|
+
const size = statSync4(tarballPath).size;
|
|
9699
9667
|
spinner.succeed(`Source packed (${formatBytes(size)})`);
|
|
9700
9668
|
} catch (err) {
|
|
9701
9669
|
spinner.fail("Pack failed");
|
|
@@ -9877,6 +9845,12 @@ function clean(options) {
|
|
|
9877
9845
|
import { createServer } from "http";
|
|
9878
9846
|
async function login(options) {
|
|
9879
9847
|
const portalURL = options?.portal || DEFAULT_PORTAL;
|
|
9848
|
+
const fromApp = loadFromApp();
|
|
9849
|
+
if (fromApp) {
|
|
9850
|
+
console.log(source_default.green(`Using Construct app profile: ${fromApp.user?.name || fromApp.user?.email}`));
|
|
9851
|
+
console.log(source_default.dim(" To use a different identity, sign out of the app or run `construct logout` after login."));
|
|
9852
|
+
return;
|
|
9853
|
+
}
|
|
9880
9854
|
if (isAuthenticated()) {
|
|
9881
9855
|
const creds = load2();
|
|
9882
9856
|
const name = creds.user?.name || "unknown";
|
|
@@ -9942,18 +9916,101 @@ async function login(options) {
|
|
|
9942
9916
|
const resp = await fetch(`${portalURL}/api/auth/cli-verify`, {
|
|
9943
9917
|
headers: { Authorization: `Bearer ${token}` }
|
|
9944
9918
|
});
|
|
9945
|
-
const { user } = await resp.json();
|
|
9946
|
-
store({ token, portal: portalURL, user });
|
|
9919
|
+
const { user, publishers } = await resp.json();
|
|
9920
|
+
store({ token, portal: portalURL, user, publishers });
|
|
9947
9921
|
console.log();
|
|
9948
9922
|
console.log(source_default.green(`Logged in as ${user?.name || "there"}`));
|
|
9923
|
+
const list = publishers || [];
|
|
9924
|
+
if (list.length === 0) {
|
|
9925
|
+
console.log(source_default.yellow(" No publisher yet. Run developer enrollment to publish spaces."));
|
|
9926
|
+
} else {
|
|
9927
|
+
for (const p of list) {
|
|
9928
|
+
const label = p.kind === "org" ? source_default.cyan("org") : p.kind === "user" ? source_default.blue("personal") : source_default.dim("legacy");
|
|
9929
|
+
console.log(source_default.dim(` Publisher: ${p.name} (${label})`));
|
|
9930
|
+
}
|
|
9931
|
+
}
|
|
9949
9932
|
} catch (err) {
|
|
9950
9933
|
console.error(source_default.red(`Login failed: ${err.message}`));
|
|
9951
9934
|
process.exit(1);
|
|
9952
9935
|
}
|
|
9953
9936
|
}
|
|
9954
9937
|
function logout() {
|
|
9938
|
+
const wasCli = isAuthenticated();
|
|
9955
9939
|
clear();
|
|
9956
|
-
|
|
9940
|
+
if (wasCli) {
|
|
9941
|
+
console.log(source_default.green("Logged out of CLI credentials."));
|
|
9942
|
+
} else {
|
|
9943
|
+
console.log(source_default.dim("No CLI credentials to clear."));
|
|
9944
|
+
}
|
|
9945
|
+
const appStill = loadFromApp();
|
|
9946
|
+
if (appStill) {
|
|
9947
|
+
console.log();
|
|
9948
|
+
console.log(source_default.yellow("Note: the Construct app is still signed in as ") + source_default.white(appStill.user?.name || appStill.user?.email || ""));
|
|
9949
|
+
console.log(source_default.dim(" The CLI will continue to use the app profile. Sign out of the app to fully disconnect."));
|
|
9950
|
+
}
|
|
9951
|
+
}
|
|
9952
|
+
|
|
9953
|
+
// src/commands/whoami.ts
|
|
9954
|
+
async function whoami() {
|
|
9955
|
+
const fromApp = loadFromApp();
|
|
9956
|
+
let creds = null;
|
|
9957
|
+
let source = "none";
|
|
9958
|
+
if (fromApp) {
|
|
9959
|
+
creds = fromApp;
|
|
9960
|
+
source = "app";
|
|
9961
|
+
} else {
|
|
9962
|
+
try {
|
|
9963
|
+
creds = load2();
|
|
9964
|
+
source = "cli";
|
|
9965
|
+
} catch {
|
|
9966
|
+
source = "none";
|
|
9967
|
+
}
|
|
9968
|
+
}
|
|
9969
|
+
if (source === "none" || !creds) {
|
|
9970
|
+
console.log(source_default.yellow("Not signed in."));
|
|
9971
|
+
console.log(source_default.dim(" Run ") + source_default.white("construct login") + source_default.dim(" or sign in to the Construct app."));
|
|
9972
|
+
return;
|
|
9973
|
+
}
|
|
9974
|
+
const user = creds.user;
|
|
9975
|
+
const sourceLabel = source === "app" ? source_default.cyan("Construct app profile") : source_default.blue("CLI login");
|
|
9976
|
+
console.log();
|
|
9977
|
+
console.log(source_default.bold(user?.name || "Signed in"));
|
|
9978
|
+
console.log(source_default.dim(" " + (user?.email || "")));
|
|
9979
|
+
console.log(source_default.dim(" id: ") + source_default.dim(user?.id || "\u2014"));
|
|
9980
|
+
console.log(source_default.dim(" source: ") + sourceLabel);
|
|
9981
|
+
console.log(source_default.dim(" portal: ") + (creds.portal || DEFAULT_PORTAL));
|
|
9982
|
+
try {
|
|
9983
|
+
const resp = await fetch(`${creds.portal || DEFAULT_PORTAL}/api/auth/cli-verify`, {
|
|
9984
|
+
headers: { Authorization: `Bearer ${creds.token}` }
|
|
9985
|
+
});
|
|
9986
|
+
if (!resp.ok) {
|
|
9987
|
+
console.log(source_default.dim(" publishers: ") + source_default.red(`error (${resp.status})`));
|
|
9988
|
+
return;
|
|
9989
|
+
}
|
|
9990
|
+
const body = await resp.json();
|
|
9991
|
+
const list = body.publishers || [];
|
|
9992
|
+
if (list.length === 0) {
|
|
9993
|
+
console.log(source_default.dim(" publishers: ") + source_default.yellow("none yet \u2014 enroll at developer.construct.space"));
|
|
9994
|
+
return;
|
|
9995
|
+
}
|
|
9996
|
+
console.log();
|
|
9997
|
+
console.log(source_default.bold("Publishers"));
|
|
9998
|
+
for (const p of list) {
|
|
9999
|
+
const kindLabel = p.kind === "org" ? source_default.cyan("org") : p.kind === "user" ? source_default.blue("personal") : source_default.dim("legacy");
|
|
10000
|
+
const verified = p.verified ? source_default.green(" \u2713") : "";
|
|
10001
|
+
console.log(` ${source_default.white(p.name)} (${kindLabel})${verified}`);
|
|
10002
|
+
if (p.orgId)
|
|
10003
|
+
console.log(source_default.dim(` org: ${p.orgId}`));
|
|
10004
|
+
}
|
|
10005
|
+
} catch (err) {
|
|
10006
|
+
console.log(source_default.dim(" publishers: ") + source_default.red("could not reach portal"));
|
|
10007
|
+
}
|
|
10008
|
+
console.log();
|
|
10009
|
+
if (source === "app") {
|
|
10010
|
+
console.log(source_default.dim("To switch identities, change the active profile in the Construct app."));
|
|
10011
|
+
} else {
|
|
10012
|
+
console.log(source_default.dim("To switch identities, run 'construct logout' then 'construct login'."));
|
|
10013
|
+
}
|
|
9957
10014
|
}
|
|
9958
10015
|
|
|
9959
10016
|
// src/commands/update.ts
|
|
@@ -10228,7 +10285,7 @@ function updateBarrel(modelsDir, modelName) {
|
|
|
10228
10285
|
}
|
|
10229
10286
|
|
|
10230
10287
|
// src/commands/graph/push.ts
|
|
10231
|
-
import { existsSync as existsSync16, readdirSync as
|
|
10288
|
+
import { existsSync as existsSync16, readdirSync as readdirSync4, readFileSync as readFileSync12 } from "fs";
|
|
10232
10289
|
import { join as join20, basename as basename7 } from "path";
|
|
10233
10290
|
async function graphPush() {
|
|
10234
10291
|
const root = process.cwd();
|
|
@@ -10242,7 +10299,7 @@ async function graphPush() {
|
|
|
10242
10299
|
console.error(source_default.red("No src/models/ directory found. Run 'construct graph init' first."));
|
|
10243
10300
|
process.exit(1);
|
|
10244
10301
|
}
|
|
10245
|
-
const modelFiles =
|
|
10302
|
+
const modelFiles = readdirSync4(modelsDir).filter((f) => f.endsWith(".ts") && f !== "index.ts");
|
|
10246
10303
|
if (modelFiles.length === 0) {
|
|
10247
10304
|
console.error(source_default.red("No model files found in src/models/"));
|
|
10248
10305
|
console.log(source_default.dim(" Generate one: construct graph g User name:string email:string"));
|
|
@@ -10270,14 +10327,12 @@ async function graphPush() {
|
|
|
10270
10327
|
const graphURL = process.env.GRAPH_URL || "https://graph.construct.space";
|
|
10271
10328
|
const spinner = ora("Registering models...").start();
|
|
10272
10329
|
try {
|
|
10273
|
-
const userID = creds.user?.id || "";
|
|
10274
10330
|
const resp = await fetch(`${graphURL}/api/schemas/register`, {
|
|
10275
10331
|
method: "POST",
|
|
10276
10332
|
headers: {
|
|
10277
10333
|
"Content-Type": "application/json",
|
|
10278
10334
|
Authorization: `Bearer ${creds.token}`,
|
|
10279
|
-
"X-Space-ID": m.id
|
|
10280
|
-
"X-Auth-User-ID": userID
|
|
10335
|
+
"X-Space-ID": m.id
|
|
10281
10336
|
},
|
|
10282
10337
|
body: JSON.stringify({
|
|
10283
10338
|
space_id: m.id,
|
|
@@ -10287,20 +10342,6 @@ async function graphPush() {
|
|
|
10287
10342
|
manifest: { version: 1, models }
|
|
10288
10343
|
})
|
|
10289
10344
|
});
|
|
10290
|
-
if (resp.status === 403) {
|
|
10291
|
-
spinner.fail("Ownership check failed");
|
|
10292
|
-
try {
|
|
10293
|
-
const errBody = await resp.json();
|
|
10294
|
-
console.error(source_default.red(` ${errBody.error || "You are not the owner of this space"}`));
|
|
10295
|
-
if (errBody.owner_user_id) {
|
|
10296
|
-
console.error(source_default.dim(` Current owner: ${errBody.owner_user_id}`));
|
|
10297
|
-
}
|
|
10298
|
-
console.error(source_default.dim(" Fork to a new space_id to publish your own version."));
|
|
10299
|
-
} catch {
|
|
10300
|
-
console.error(source_default.red(` 403: Forbidden \u2014 ownership check failed`));
|
|
10301
|
-
}
|
|
10302
|
-
process.exit(1);
|
|
10303
|
-
}
|
|
10304
10345
|
if (!resp.ok) {
|
|
10305
10346
|
const body = await resp.text();
|
|
10306
10347
|
spinner.fail("Registration failed");
|
|
@@ -10383,7 +10424,7 @@ function parseModelFile(content, fileName) {
|
|
|
10383
10424
|
}
|
|
10384
10425
|
|
|
10385
10426
|
// src/commands/graph/migrate.ts
|
|
10386
|
-
import { existsSync as existsSync17, readdirSync as
|
|
10427
|
+
import { existsSync as existsSync17, readdirSync as readdirSync5, readFileSync as readFileSync13 } from "fs";
|
|
10387
10428
|
import { join as join21, basename as basename8 } from "path";
|
|
10388
10429
|
async function graphMigrate(options) {
|
|
10389
10430
|
const root = process.cwd();
|
|
@@ -10420,7 +10461,7 @@ async function graphMigrate(options) {
|
|
|
10420
10461
|
spinner.fail("Could not fetch schema");
|
|
10421
10462
|
process.exit(1);
|
|
10422
10463
|
}
|
|
10423
|
-
const modelFiles =
|
|
10464
|
+
const modelFiles = readdirSync5(modelsDir).filter((f) => f.endsWith(".ts") && f !== "index.ts");
|
|
10424
10465
|
const localModels = [];
|
|
10425
10466
|
for (const file of modelFiles) {
|
|
10426
10467
|
const content = readFileSync13(join21(modelsDir, file), "utf-8");
|
|
@@ -10527,7 +10568,7 @@ function parseModelFields(content, fileName) {
|
|
|
10527
10568
|
}
|
|
10528
10569
|
|
|
10529
10570
|
// src/index.ts
|
|
10530
|
-
var VERSION = "1.1.
|
|
10571
|
+
var VERSION = "1.1.11";
|
|
10531
10572
|
var program2 = new Command;
|
|
10532
10573
|
program2.name("construct").description("Construct CLI \u2014 scaffold, build, develop, and publish spaces").version(VERSION);
|
|
10533
10574
|
program2.command("scaffold [name]").alias("new").alias("create").description("Create a new Construct space project").option("--with-tests", "Include E2E testing boilerplate").option("--full", "Full preset: multiple pages, extra skills, widget templates").action(async (name, opts) => scaffold(name, opts));
|
|
@@ -10540,6 +10581,7 @@ program2.command("check").description("Run type-check (vue-tsc) and linter (esli
|
|
|
10540
10581
|
program2.command("clean").description("Remove build artifacts").option("--all", "Also remove node_modules and lockfiles").action((opts) => clean(opts));
|
|
10541
10582
|
program2.command("login").description("Authenticate with Construct").option("--portal <url>", "Portal URL").action(async (opts) => login(opts));
|
|
10542
10583
|
program2.command("logout").description("Sign out").action(() => logout());
|
|
10584
|
+
program2.command("whoami").alias("status").description("Show the active profile, its source (app or CLI), and linked publishers").action(() => whoami());
|
|
10543
10585
|
program2.command("update").description("Update the CLI to the latest version").action(() => update());
|
|
10544
10586
|
var graph = program2.command("graph").description("Construct Graph \u2014 data models and GraphQL");
|
|
10545
10587
|
graph.command("init").description("Initialize Graph in a space project").action(() => graphInit());
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
/**
|
|
3
3
|
* {{.DisplayName}} Summary Widget — 2×1 compact view
|
|
4
|
-
*
|
|
5
|
-
* Widgets run inside a closed Shadow DOM sandbox.
|
|
6
|
-
* Use the injected widgetApi for theme and actions — do not access
|
|
7
|
-
* window, document, or global stores directly.
|
|
8
4
|
*/
|
|
9
|
-
import { inject } from 'vue'
|
|
10
|
-
|
|
11
|
-
const api = inject<{ theme: { mode: string; vars: Record<string, string> }; space: { id: string; name: string } }>('widgetApi')
|
|
12
5
|
</script>
|
|
13
6
|
|
|
14
7
|
<template>
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
/**
|
|
3
3
|
* {{.DisplayName}} Summary Widget — 4×1 wide view
|
|
4
|
-
*
|
|
5
|
-
* Widgets run inside a closed Shadow DOM sandbox.
|
|
6
|
-
* Use the injected widgetApi for theme and actions — do not access
|
|
7
|
-
* window, document, or global stores directly.
|
|
8
4
|
*/
|
|
9
|
-
import { inject } from 'vue'
|
|
10
|
-
|
|
11
|
-
const api = inject<{ theme: { mode: string; vars: Record<string, string> }; space: { id: string; name: string } }>('widgetApi')
|
|
12
5
|
</script>
|
|
13
6
|
|
|
14
7
|
<template>
|
package/package.json
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
/**
|
|
3
3
|
* {{.DisplayName}} Summary Widget — 2×1 compact view
|
|
4
|
-
*
|
|
5
|
-
* Widgets run inside a closed Shadow DOM sandbox.
|
|
6
|
-
* Use the injected widgetApi for theme and actions — do not access
|
|
7
|
-
* window, document, or global stores directly.
|
|
8
4
|
*/
|
|
9
|
-
import { inject } from 'vue'
|
|
10
|
-
|
|
11
|
-
const api = inject<{ theme: { mode: string; vars: Record<string, string> }; space: { id: string; name: string } }>('widgetApi')
|
|
12
5
|
</script>
|
|
13
6
|
|
|
14
7
|
<template>
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
/**
|
|
3
3
|
* {{.DisplayName}} Summary Widget — 4×1 wide view
|
|
4
|
-
*
|
|
5
|
-
* Widgets run inside a closed Shadow DOM sandbox.
|
|
6
|
-
* Use the injected widgetApi for theme and actions — do not access
|
|
7
|
-
* window, document, or global stores directly.
|
|
8
4
|
*/
|
|
9
|
-
import { inject } from 'vue'
|
|
10
|
-
|
|
11
|
-
const api = inject<{ theme: { mode: string; vars: Record<string, string> }; space: { id: string; name: string } }>('widgetApi')
|
|
12
5
|
</script>
|
|
13
6
|
|
|
14
7
|
<template>
|