@somewhere-cloud/cli 0.38.183 → 0.38.185
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/CHANGELOG.md +14 -0
- package/dist/lib/bundle.js +529 -400
- package/dist/lib/bundle.js.map +3 -3
- package/dist/types/lib/client.d.ts +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
- package/runtime/DECLARED-DATA-VENDOR.json +5 -5
- package/runtime/PLATFORM-SOURCE.json +1 -1
- package/runtime/VENDOR.json +1 -1
- package/runtime/browser-probes.mjs +1 -1
- package/runtime/declared-data.cjs +27 -2
package/dist/lib/bundle.js
CHANGED
|
@@ -33775,10 +33775,31 @@ var init_package_root = __esm({
|
|
|
33775
33775
|
}
|
|
33776
33776
|
});
|
|
33777
33777
|
|
|
33778
|
+
// dist/lib/version.js
|
|
33779
|
+
import { readFileSync as readFileSync3 } from "node:fs";
|
|
33780
|
+
import { join as join3 } from "node:path";
|
|
33781
|
+
function readVersion() {
|
|
33782
|
+
try {
|
|
33783
|
+
const pkg = JSON.parse(readFileSync3(join3(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
33784
|
+
return typeof pkg.version === "string" ? pkg.version : "unknown";
|
|
33785
|
+
} catch {
|
|
33786
|
+
return "unknown";
|
|
33787
|
+
}
|
|
33788
|
+
}
|
|
33789
|
+
var CLI_VERSION2;
|
|
33790
|
+
var init_version = __esm({
|
|
33791
|
+
"dist/lib/version.js"() {
|
|
33792
|
+
"use strict";
|
|
33793
|
+
init_package_root();
|
|
33794
|
+
__name(readVersion, "readVersion");
|
|
33795
|
+
CLI_VERSION2 = readVersion();
|
|
33796
|
+
}
|
|
33797
|
+
});
|
|
33798
|
+
|
|
33778
33799
|
// dist/lib/platform-contract.js
|
|
33779
|
-
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as
|
|
33800
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
33780
33801
|
import { createRequire } from "node:module";
|
|
33781
|
-
import { join as
|
|
33802
|
+
import { join as join4 } from "node:path";
|
|
33782
33803
|
import { debuglog } from "node:util";
|
|
33783
33804
|
function cliConsumerContract() {
|
|
33784
33805
|
return vendor().CONSUMER_CONTRACT ?? null;
|
|
@@ -33787,8 +33808,10 @@ function readSeenFile() {
|
|
|
33787
33808
|
if (!existsSync3(seenPath()))
|
|
33788
33809
|
return { origins: {} };
|
|
33789
33810
|
try {
|
|
33790
|
-
const value = JSON.parse(
|
|
33791
|
-
|
|
33811
|
+
const value = JSON.parse(readFileSync4(seenPath(), "utf8"));
|
|
33812
|
+
if (!value || typeof value !== "object" || !value.origins || typeof value.origins !== "object")
|
|
33813
|
+
return { origins: {} };
|
|
33814
|
+
return { origins: value.origins, warned: value.warned && typeof value.warned === "object" ? value.warned : {} };
|
|
33792
33815
|
} catch {
|
|
33793
33816
|
return { origins: {} };
|
|
33794
33817
|
}
|
|
@@ -33806,10 +33829,13 @@ function recordPlatformContract(headers, url3, now2 = Date.now()) {
|
|
|
33806
33829
|
const file = readSeenFile();
|
|
33807
33830
|
const seen2 = { ...announced, seen_at: now2, origin };
|
|
33808
33831
|
file.origins[origin] = seen2;
|
|
33832
|
+
writeSeenFile(file);
|
|
33833
|
+
observeContract(contractVerdict(seen2, now2), now2);
|
|
33834
|
+
return seen2;
|
|
33835
|
+
}
|
|
33836
|
+
function writeSeenFile(file) {
|
|
33809
33837
|
mkdirSync3(cliConfigDir(), { recursive: true, mode: 448 });
|
|
33810
33838
|
writeFileSync3(seenPath(), JSON.stringify(file, null, 2) + "\n", { mode: 384 });
|
|
33811
|
-
observeContract(contractVerdict(seen2, now2));
|
|
33812
|
-
return seen2;
|
|
33813
33839
|
}
|
|
33814
33840
|
function seenPlatformContract(apiBase) {
|
|
33815
33841
|
let origin;
|
|
@@ -33827,7 +33853,7 @@ function contractVerdict(platform2, now2) {
|
|
|
33827
33853
|
}
|
|
33828
33854
|
function platformContractVerdict(apiBase, now2 = Date.now()) {
|
|
33829
33855
|
const verdict = contractVerdict(seenPlatformContract(apiBase), now2);
|
|
33830
|
-
observeContract(verdict);
|
|
33856
|
+
observeContract(verdict, now2);
|
|
33831
33857
|
return verdict;
|
|
33832
33858
|
}
|
|
33833
33859
|
function describePlatformContract(verdict) {
|
|
@@ -33846,26 +33872,34 @@ function configureContractWarning(command, apiBase) {
|
|
|
33846
33872
|
} catch {
|
|
33847
33873
|
}
|
|
33848
33874
|
}
|
|
33849
|
-
function observeContract(verdict) {
|
|
33875
|
+
function observeContract(verdict, now2) {
|
|
33850
33876
|
debug("%s", describePlatformContract(verdict));
|
|
33851
33877
|
if (warned || !warningOrigin || verdict.platform?.origin !== warningOrigin || verdict.status !== "outdated")
|
|
33852
33878
|
return;
|
|
33853
33879
|
warned = true;
|
|
33854
|
-
|
|
33880
|
+
const file = readSeenFile();
|
|
33881
|
+
const last = file.warned?.[warningOrigin];
|
|
33882
|
+
if (typeof last === "number" && now2 - last < CONTRACT_WARNING_INTERVAL_MS)
|
|
33883
|
+
return;
|
|
33884
|
+
file.warned = { ...file.warned, [warningOrigin]: now2 };
|
|
33885
|
+
writeSeenFile(file);
|
|
33886
|
+
console.error(CONTRACT_WARNING);
|
|
33855
33887
|
}
|
|
33856
|
-
var require2, CONTRACT_HEADER, vendor, seenPath, debug, warningOrigin, warned;
|
|
33888
|
+
var require2, CONTRACT_HEADER, vendor, seenPath, debug, warningOrigin, warned, CONTRACT_WARNING_INTERVAL_MS, CONTRACT_WARNING;
|
|
33857
33889
|
var init_platform_contract = __esm({
|
|
33858
33890
|
"dist/lib/platform-contract.js"() {
|
|
33859
33891
|
"use strict";
|
|
33860
33892
|
init_package_root();
|
|
33861
33893
|
init_config();
|
|
33894
|
+
init_version();
|
|
33862
33895
|
require2 = createRequire(CLI_PACKAGE_ROOT);
|
|
33863
33896
|
CONTRACT_HEADER = "x-sw-consumer-contract";
|
|
33864
33897
|
vendor = /* @__PURE__ */ __name(() => require2("./runtime/declared-data.cjs"), "vendor");
|
|
33865
|
-
seenPath = /* @__PURE__ */ __name(() =>
|
|
33898
|
+
seenPath = /* @__PURE__ */ __name(() => join4(cliConfigDir(), "platform-contract.json"), "seenPath");
|
|
33866
33899
|
__name(cliConsumerContract, "cliConsumerContract");
|
|
33867
33900
|
__name(readSeenFile, "readSeenFile");
|
|
33868
33901
|
__name(recordPlatformContract, "recordPlatformContract");
|
|
33902
|
+
__name(writeSeenFile, "writeSeenFile");
|
|
33869
33903
|
__name(seenPlatformContract, "seenPlatformContract");
|
|
33870
33904
|
__name(contractVerdict, "contractVerdict");
|
|
33871
33905
|
__name(platformContractVerdict, "platformContractVerdict");
|
|
@@ -33874,6 +33908,8 @@ var init_platform_contract = __esm({
|
|
|
33874
33908
|
debug = debuglog("somewhere-contract");
|
|
33875
33909
|
warned = false;
|
|
33876
33910
|
__name(configureContractWarning, "configureContractWarning");
|
|
33911
|
+
CONTRACT_WARNING_INTERVAL_MS = 12 * 60 * 60 * 1e3;
|
|
33912
|
+
CONTRACT_WARNING = `This Somewhere CLI (${CLI_VERSION2}) is older than the platform, so its local checks may miss newer rules. To update this project, run npx -y @somewhere-cloud/cli@latest upgrade here. Shown once every 12 hours.`;
|
|
33877
33913
|
__name(observeContract, "observeContract");
|
|
33878
33914
|
}
|
|
33879
33915
|
});
|
|
@@ -34045,6 +34081,15 @@ var init_client = __esm({
|
|
|
34045
34081
|
const target = `/projects/${encodeURIComponent(id)}`;
|
|
34046
34082
|
if (path3 !== target && !path3.startsWith(target + "/") && query?.project_id !== id && !(body && typeof body === "object" && "project_id" in body && body.project_id === id))
|
|
34047
34083
|
return error3;
|
|
34084
|
+
const excludesLink = await this.call("GET", "/keys/sessions", void 0, void 0, { timeoutMs: 3e3, refresh: false }).then((answer) => {
|
|
34085
|
+
const projects = answer?.sessions?.find((session) => session.current === true)?.scope?.projects;
|
|
34086
|
+
return Array.isArray(projects) && projects.every((project) => typeof project === "string") && !projects.includes(id);
|
|
34087
|
+
}).catch(() => false);
|
|
34088
|
+
if (excludesLink) {
|
|
34089
|
+
error3.linkedProjectGrantExcluded = true;
|
|
34090
|
+
error3.message = `This CLI session's grant does not include the project this folder is linked to. Run \`${cliInvocation()} login\` and include this project or choose All projects.`;
|
|
34091
|
+
return error3;
|
|
34092
|
+
}
|
|
34048
34093
|
const identity = await this.call("GET", "/auth/whoami", void 0, void 0, { timeoutMs: 3e3, refresh: false }).then((answer) => {
|
|
34049
34094
|
if (typeof answer?.user?.email !== "string")
|
|
34050
34095
|
return "";
|
|
@@ -34346,6 +34391,7 @@ var init_client = __esm({
|
|
|
34346
34391
|
meta;
|
|
34347
34392
|
/** Original body-reader failure, retained only so raw command output stays unchanged. */
|
|
34348
34393
|
originalCause;
|
|
34394
|
+
linkedProjectGrantExcluded;
|
|
34349
34395
|
constructor(code, message3, statusCode, data2, hint, meta2 = {}) {
|
|
34350
34396
|
super(message3);
|
|
34351
34397
|
this.code = code;
|
|
@@ -37420,6 +37466,20 @@ var init_esm = __esm({
|
|
|
37420
37466
|
}
|
|
37421
37467
|
});
|
|
37422
37468
|
|
|
37469
|
+
// dist/lib/stdin.js
|
|
37470
|
+
async function readAllStdin() {
|
|
37471
|
+
const chunks = [];
|
|
37472
|
+
for await (const chunk of process.stdin)
|
|
37473
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
|
|
37474
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
37475
|
+
}
|
|
37476
|
+
var init_stdin = __esm({
|
|
37477
|
+
"dist/lib/stdin.js"() {
|
|
37478
|
+
"use strict";
|
|
37479
|
+
__name(readAllStdin, "readAllStdin");
|
|
37480
|
+
}
|
|
37481
|
+
});
|
|
37482
|
+
|
|
37423
37483
|
// node_modules/kleur/index.js
|
|
37424
37484
|
var require_kleur = __commonJS({
|
|
37425
37485
|
"node_modules/kleur/index.js"(exports, module) {
|
|
@@ -39936,9 +39996,9 @@ var require_prompts = __commonJS({
|
|
|
39936
39996
|
$2.date = (args) => toPrompt("DatePrompt", args);
|
|
39937
39997
|
$2.confirm = (args) => toPrompt("ConfirmPrompt", args);
|
|
39938
39998
|
$2.list = (args) => {
|
|
39939
|
-
const
|
|
39999
|
+
const sep3 = args.separator || ",";
|
|
39940
40000
|
return toPrompt("TextPrompt", args, {
|
|
39941
|
-
onSubmit: /* @__PURE__ */ __name((str2) => str2.split(
|
|
40001
|
+
onSubmit: /* @__PURE__ */ __name((str2) => str2.split(sep3).map((s3) => s3.trim()), "onSubmit")
|
|
39942
40002
|
});
|
|
39943
40003
|
};
|
|
39944
40004
|
$2.toggle = (args) => toPrompt("TogglePrompt", args);
|
|
@@ -42299,9 +42359,9 @@ var require_prompts2 = __commonJS({
|
|
|
42299
42359
|
$2.date = (args) => toPrompt("DatePrompt", args);
|
|
42300
42360
|
$2.confirm = (args) => toPrompt("ConfirmPrompt", args);
|
|
42301
42361
|
$2.list = (args) => {
|
|
42302
|
-
const
|
|
42362
|
+
const sep3 = args.separator || ",";
|
|
42303
42363
|
return toPrompt("TextPrompt", args, {
|
|
42304
|
-
onSubmit: /* @__PURE__ */ __name((str2) => str2.split(
|
|
42364
|
+
onSubmit: /* @__PURE__ */ __name((str2) => str2.split(sep3).map((s3) => s3.trim()), "onSubmit")
|
|
42305
42365
|
});
|
|
42306
42366
|
};
|
|
42307
42367
|
$2.toggle = (args) => toPrompt("TogglePrompt", args);
|
|
@@ -42548,10 +42608,10 @@ var init_spinner = __esm({
|
|
|
42548
42608
|
});
|
|
42549
42609
|
|
|
42550
42610
|
// dist/lib/device.js
|
|
42551
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as
|
|
42611
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "node:fs";
|
|
42552
42612
|
import { hostname } from "node:os";
|
|
42553
42613
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
42554
|
-
import { join as
|
|
42614
|
+
import { join as join5 } from "node:path";
|
|
42555
42615
|
function ensureDir2() {
|
|
42556
42616
|
if (!existsSync4(CONFIG_DIR2))
|
|
42557
42617
|
mkdirSync4(CONFIG_DIR2, { recursive: true });
|
|
@@ -42560,7 +42620,7 @@ function loadDevice() {
|
|
|
42560
42620
|
if (!existsSync4(DEVICE_PATH))
|
|
42561
42621
|
return null;
|
|
42562
42622
|
try {
|
|
42563
|
-
const parsed = JSON.parse(
|
|
42623
|
+
const parsed = JSON.parse(readFileSync5(DEVICE_PATH, "utf-8"));
|
|
42564
42624
|
if (typeof parsed.id !== "string" || parsed.id.length < 8)
|
|
42565
42625
|
return null;
|
|
42566
42626
|
return parsed;
|
|
@@ -42595,7 +42655,7 @@ var init_device = __esm({
|
|
|
42595
42655
|
"use strict";
|
|
42596
42656
|
init_config();
|
|
42597
42657
|
CONFIG_DIR2 = cliConfigDir();
|
|
42598
|
-
DEVICE_PATH =
|
|
42658
|
+
DEVICE_PATH = join5(CONFIG_DIR2, "device.json");
|
|
42599
42659
|
__name(ensureDir2, "ensureDir");
|
|
42600
42660
|
__name(loadDevice, "loadDevice");
|
|
42601
42661
|
__name(saveDevice, "saveDevice");
|
|
@@ -42761,27 +42821,6 @@ var init_auth = __esm({
|
|
|
42761
42821
|
}
|
|
42762
42822
|
});
|
|
42763
42823
|
|
|
42764
|
-
// dist/lib/version.js
|
|
42765
|
-
import { readFileSync as readFileSync5 } from "node:fs";
|
|
42766
|
-
import { join as join5 } from "node:path";
|
|
42767
|
-
function readVersion() {
|
|
42768
|
-
try {
|
|
42769
|
-
const pkg = JSON.parse(readFileSync5(join5(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
42770
|
-
return typeof pkg.version === "string" ? pkg.version : "unknown";
|
|
42771
|
-
} catch {
|
|
42772
|
-
return "unknown";
|
|
42773
|
-
}
|
|
42774
|
-
}
|
|
42775
|
-
var CLI_VERSION2;
|
|
42776
|
-
var init_version = __esm({
|
|
42777
|
-
"dist/lib/version.js"() {
|
|
42778
|
-
"use strict";
|
|
42779
|
-
init_package_root();
|
|
42780
|
-
__name(readVersion, "readVersion");
|
|
42781
|
-
CLI_VERSION2 = readVersion();
|
|
42782
|
-
}
|
|
42783
|
-
});
|
|
42784
|
-
|
|
42785
42824
|
// dist/lib/device-login.js
|
|
42786
42825
|
import { createHash, randomBytes, randomInt } from "node:crypto";
|
|
42787
42826
|
import { arch, hostname as hostname2, platform, release } from "node:os";
|
|
@@ -43063,7 +43102,7 @@ var init_platform_command = __esm({
|
|
|
43063
43102
|
});
|
|
43064
43103
|
|
|
43065
43104
|
// dist/commands/auth.js
|
|
43066
|
-
import { closeSync as closeSync3, constants as fsConstants, createWriteStream, fchmodSync as fchmodSync2, openSync as openSync3,
|
|
43105
|
+
import { closeSync as closeSync3, constants as fsConstants, createWriteStream, fchmodSync as fchmodSync2, openSync as openSync3, unlinkSync as unlinkSync3 } from "node:fs";
|
|
43067
43106
|
import { resolve as resolve2 } from "node:path";
|
|
43068
43107
|
import { pipeline } from "node:stream/promises";
|
|
43069
43108
|
async function readAuthToken() {
|
|
@@ -43071,7 +43110,7 @@ async function readAuthToken() {
|
|
|
43071
43110
|
if (envToken)
|
|
43072
43111
|
return envToken;
|
|
43073
43112
|
if (!process.stdin.isTTY) {
|
|
43074
|
-
return
|
|
43113
|
+
return (await readAllStdin()).trim();
|
|
43075
43114
|
}
|
|
43076
43115
|
const response = await (0, import_prompts.default)({
|
|
43077
43116
|
type: "password",
|
|
@@ -43627,6 +43666,7 @@ var init_auth2 = __esm({
|
|
|
43627
43666
|
"dist/commands/auth.js"() {
|
|
43628
43667
|
"use strict";
|
|
43629
43668
|
init_cli_invocation();
|
|
43669
|
+
init_stdin();
|
|
43630
43670
|
import_prompts = __toESM(require_prompts3(), 1);
|
|
43631
43671
|
init_open();
|
|
43632
43672
|
init_spinner();
|
|
@@ -43897,14 +43937,14 @@ var init_publish_surface = __esm({
|
|
|
43897
43937
|
});
|
|
43898
43938
|
|
|
43899
43939
|
// dist/lib/init-scaffold.js
|
|
43900
|
-
import { existsSync as existsSync5, lstatSync, mkdirSync as mkdirSync5, readFileSync as
|
|
43940
|
+
import { existsSync as existsSync5, lstatSync, mkdirSync as mkdirSync5, readFileSync as readFileSync6, readdirSync, writeFileSync as writeFileSync5 } from "node:fs";
|
|
43901
43941
|
import { dirname, relative, resolve as resolve3 } from "node:path";
|
|
43902
43942
|
function starterNameSlug(name) {
|
|
43903
43943
|
return name.toLowerCase().replace(/[^a-z0-9\s-]/g, "").replace(/[\s-]+/g, "-").replace(/^-|-$/g, "");
|
|
43904
43944
|
}
|
|
43905
43945
|
function readStarterProjectName(dir) {
|
|
43906
43946
|
try {
|
|
43907
|
-
const pkg = JSON.parse(
|
|
43947
|
+
const pkg = JSON.parse(readFileSync6(resolve3(dir, "package.json"), "utf8"));
|
|
43908
43948
|
const name = pkg?.somewhere?.project_name;
|
|
43909
43949
|
return typeof name === "string" ? name.trim() || void 0 : void 0;
|
|
43910
43950
|
} catch {
|
|
@@ -44003,7 +44043,7 @@ var init_init_scaffold = __esm({
|
|
|
44003
44043
|
|
|
44004
44044
|
// dist/lib/skills-pack.js
|
|
44005
44045
|
import { createHash as createHash2 } from "node:crypto";
|
|
44006
|
-
import { existsSync as existsSync6, lstatSync as lstatSync2, mkdirSync as mkdirSync6, readFileSync as
|
|
44046
|
+
import { existsSync as existsSync6, lstatSync as lstatSync2, mkdirSync as mkdirSync6, readFileSync as readFileSync7, readlinkSync, rmSync, rmdirSync, symlinkSync, writeFileSync as writeFileSync6 } from "node:fs";
|
|
44007
44047
|
import { join as join6 } from "node:path";
|
|
44008
44048
|
function verifyPack(pack) {
|
|
44009
44049
|
if (!pack || pack.schema !== 1 || pack.name !== "somewhere-skills" || typeof pack.version !== "string" || !Array.isArray(pack.files) || pack.files.length === 0) {
|
|
@@ -44037,7 +44077,7 @@ function readLock(dir) {
|
|
|
44037
44077
|
return null;
|
|
44038
44078
|
if (isSymlink(path3))
|
|
44039
44079
|
throw new Error("Skills lock must not be a symlink.");
|
|
44040
|
-
const lock = JSON.parse(
|
|
44080
|
+
const lock = JSON.parse(readFileSync7(path3, "utf8"));
|
|
44041
44081
|
if (!lock || lock.pack !== "somewhere-skills" || typeof lock.version !== "string" || !lock.files || typeof lock.files !== "object" || Array.isArray(lock.files) || Object.entries(lock.files).some(([file, hash]) => !/^\.agents\/skills\/[a-z0-9][a-z0-9-]*\/SKILL\.md$/.test(file) || typeof hash !== "string" || !/^[a-f0-9]{64}$/.test(hash))) {
|
|
44042
44082
|
throw new Error("Skills lock is malformed; nothing was changed.");
|
|
44043
44083
|
}
|
|
@@ -44050,7 +44090,7 @@ function linkForClaude(dir, name) {
|
|
|
44050
44090
|
if (existsSync6(at2) || isSymlink(at2)) {
|
|
44051
44091
|
if (isSymlink(at2) && readlinkSync(at2) === target)
|
|
44052
44092
|
return "link";
|
|
44053
|
-
writeFileSync6(join6(at2, "SKILL.md"),
|
|
44093
|
+
writeFileSync6(join6(at2, "SKILL.md"), readFileSync7(join6(dir, SKILLS_DIR, name, "SKILL.md")));
|
|
44054
44094
|
return "copy";
|
|
44055
44095
|
}
|
|
44056
44096
|
try {
|
|
@@ -44058,7 +44098,7 @@ function linkForClaude(dir, name) {
|
|
|
44058
44098
|
return "link";
|
|
44059
44099
|
} catch {
|
|
44060
44100
|
mkdirSync6(at2, { recursive: true });
|
|
44061
|
-
writeFileSync6(join6(at2, "SKILL.md"),
|
|
44101
|
+
writeFileSync6(join6(at2, "SKILL.md"), readFileSync7(join6(dir, SKILLS_DIR, name, "SKILL.md")));
|
|
44062
44102
|
return "copy";
|
|
44063
44103
|
}
|
|
44064
44104
|
}
|
|
@@ -44144,7 +44184,7 @@ function preflightInstall(dir, pack, previous, state) {
|
|
|
44144
44184
|
conflicts.push(claude);
|
|
44145
44185
|
} else if (existsSync6(claude)) {
|
|
44146
44186
|
const copy = join6(claude, "SKILL.md");
|
|
44147
|
-
if (!owned || isSymlink(copy) || !existsSync6(copy) || sha256(
|
|
44187
|
+
if (!owned || isSymlink(copy) || !existsSync6(copy) || sha256(readFileSync7(copy, "utf8")) !== owned)
|
|
44148
44188
|
conflicts.push(claude);
|
|
44149
44189
|
}
|
|
44150
44190
|
}
|
|
@@ -44158,7 +44198,7 @@ function inspectFiles(dir, lock) {
|
|
|
44158
44198
|
const full = join6(dir, path3);
|
|
44159
44199
|
if (!existsSync6(full))
|
|
44160
44200
|
missing.push(path3);
|
|
44161
|
-
else if (sha256(
|
|
44201
|
+
else if (sha256(readFileSync7(full, "utf8")) !== hash)
|
|
44162
44202
|
modified.push(path3);
|
|
44163
44203
|
}
|
|
44164
44204
|
return { missing, modified };
|
|
@@ -44290,6 +44330,8 @@ Use \`client.intake\` for public submissions to a private parent row. See
|
|
|
44290
44330
|
- Add React pages where your app handles navigation. To serve a dynamic endpoint such as \`/api/notes/:id\`, create \`api/notes/[id].ts\`. A root \`[...path].ts\` handles document routes, including \`/\`. Underscore-prefixed files are import-only helpers.
|
|
44291
44331
|
- JSON routes use \`sw.endpoint({ auth, body, rateLimit, handler })\`. Set \`auth\` to \`'required'\`, \`'optional'\` or \`'none'\`. Use a limit like \`'30/minute'\`. Read route parameters from the handler's \`params\`. Use a default handler or named HTTP method exports. For streaming, webhooks or custom responses, use a bare \`(req, sw)\` handler and \`sw.params\`. See \`somewhere docs functions\`.
|
|
44292
44332
|
- Keep the SDK auth handler at \`api/auth/[...path].ts\` when your app uses sign-in. Gate private UI on auth state. Password sign-up starts unverified, and signed-in unverified users pass \`auth: 'required'\`. See \`somewhere docs auth-client\`.
|
|
44333
|
+
- Mail from the app's built-in address reaches only the owner and app users who verified their email and signed in. Password sign-up starts unverified: if the app emails its users (confirmations, reminders), keep the starter's "Verify your email" step, or verify your own sender domain. See \`somewhere docs sw.email\`.
|
|
44334
|
+
- When users must see each other's changes without reloading (a queue, chat or status board), do not poll. Return the list through \`sw.rooms.live\` and follow it in the page with \`watchLive\`. See \`somewhere docs live --section realtime-live-updates-two-users-see-the-same-change\`.
|
|
44293
44335
|
- Render a view when the reads it depends on finish. Keep inputs disabled until their initial data and identity are ready, and preserve edits when a late response arrives.
|
|
44294
44336
|
- Browser requests use same-origin cookies. For scripted writes with a cookie session, send the app's origin in the \`Origin\` header. Use the CLI test helper to send data endpoint calls with the deployed contract digest. For an update, use \`data(table, { operation: 'update', id, values: { title } })\`.
|
|
44295
44337
|
|
|
@@ -44393,7 +44435,7 @@ var init_typecheck_version = __esm({
|
|
|
44393
44435
|
|
|
44394
44436
|
// dist/lib/base-files.js
|
|
44395
44437
|
import { createHash as createHash3 } from "node:crypto";
|
|
44396
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync7, readFileSync as
|
|
44438
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync7, readFileSync as readFileSync8, rmSync as rmSync2, writeFileSync as writeFileSync7 } from "node:fs";
|
|
44397
44439
|
import { join as join7 } from "node:path";
|
|
44398
44440
|
function sha2562(content) {
|
|
44399
44441
|
return createHash3("sha256").update(content).digest("hex");
|
|
@@ -44401,7 +44443,7 @@ function sha2562(content) {
|
|
|
44401
44443
|
function hashFiles(dir, paths) {
|
|
44402
44444
|
const out = {};
|
|
44403
44445
|
for (const path3 of paths)
|
|
44404
|
-
out[path3] = sha2562(
|
|
44446
|
+
out[path3] = sha2562(readFileSync8(join7(dir, path3)));
|
|
44405
44447
|
return out;
|
|
44406
44448
|
}
|
|
44407
44449
|
function saveBaseFiles(dir, base) {
|
|
@@ -44416,7 +44458,7 @@ function loadBaseFiles(dir, projectId, releaseId) {
|
|
|
44416
44458
|
if (!existsSync7(path3) || releaseId === void 0)
|
|
44417
44459
|
return null;
|
|
44418
44460
|
try {
|
|
44419
|
-
const parsed = JSON.parse(
|
|
44461
|
+
const parsed = JSON.parse(readFileSync8(path3, "utf8"));
|
|
44420
44462
|
if (parsed.project_id !== projectId || parsed.release_id !== releaseId || !parsed.files || typeof parsed.files !== "object")
|
|
44421
44463
|
return null;
|
|
44422
44464
|
return parsed;
|
|
@@ -44433,7 +44475,7 @@ function loadLastActivation(dir) {
|
|
|
44433
44475
|
if (!existsSync7(path3))
|
|
44434
44476
|
return null;
|
|
44435
44477
|
try {
|
|
44436
|
-
return JSON.parse(
|
|
44478
|
+
return JSON.parse(readFileSync8(path3, "utf8"));
|
|
44437
44479
|
} catch {
|
|
44438
44480
|
return null;
|
|
44439
44481
|
}
|
|
@@ -44455,7 +44497,7 @@ var init_base_files = __esm({
|
|
|
44455
44497
|
});
|
|
44456
44498
|
|
|
44457
44499
|
// dist/lib/scaffold.js
|
|
44458
|
-
import { lstatSync as lstatSync3, readFileSync as
|
|
44500
|
+
import { lstatSync as lstatSync3, readFileSync as readFileSync9 } from "node:fs";
|
|
44459
44501
|
import { basename, join as join8 } from "node:path";
|
|
44460
44502
|
function buildScaffoldGitignore() {
|
|
44461
44503
|
return "node_modules\ndist\nbuild\n.env\n# Generated from db/schema.ts by somewhere typecheck, dev and deploy.\n__somewhere_data.d.ts\n__somewhere_files.d.ts\n.somewhere/\n";
|
|
@@ -44540,7 +44582,7 @@ function unchangedPullScaffolds(dir, base) {
|
|
|
44540
44582
|
const local = join8(dir, path3);
|
|
44541
44583
|
if (!lstatSync3(local, { throwIfNoEntry: false })?.isFile())
|
|
44542
44584
|
continue;
|
|
44543
|
-
const hash = sha2562(
|
|
44585
|
+
const hash = sha2562(readFileSync9(local));
|
|
44544
44586
|
if (hash === (base.scaffolds ? base.scaffolds[path3] : sha2562(generated)))
|
|
44545
44587
|
hashes[path3] = hash;
|
|
44546
44588
|
}
|
|
@@ -44742,8 +44784,8 @@ var init_skills_pack_generated = __esm({
|
|
|
44742
44784
|
BUNDLED_SKILLS_PACK = {
|
|
44743
44785
|
"schema": 1,
|
|
44744
44786
|
"name": "somewhere-skills",
|
|
44745
|
-
"version": "1+
|
|
44746
|
-
"sha256": "
|
|
44787
|
+
"version": "1+7afa5a8a338d",
|
|
44788
|
+
"sha256": "7afa5a8a338d554b0f90630eb85dccad9ff8e0e170e550b73650bee538d1e927",
|
|
44747
44789
|
"files": [
|
|
44748
44790
|
{
|
|
44749
44791
|
"path": "adopt/SKILL.md",
|
|
@@ -44757,8 +44799,8 @@ var init_skills_pack_generated = __esm({
|
|
|
44757
44799
|
},
|
|
44758
44800
|
{
|
|
44759
44801
|
"path": "schema-changes/SKILL.md",
|
|
44760
|
-
"sha256": "
|
|
44761
|
-
"content": "---\nname: schema-changes\ndescription: Before adding, changing, or removing a table or column in db/schema.ts.\n---\n\n# Change the database schema safely\n\n## The file is the contract\n\nThe default `somewhere init` starter has no `db/schema.ts`: create it at the project root, or run `somewhere init --name my-app --features private-data` to start with a schema.\n\n```ts\n// db/schema.ts\nimport { id, owner, schema, table, text, timestamp } from 'somewhere/db';\n\nexport default schema({\n notes: table(\n {\n id: id(),\n title: text(),\n body: text({ default: '' }),\n created_at: timestamp({ default: 'now' }),\n },\n {\n scope: owner(),\n client: {\n read: ['id', 'title', 'body', 'created_at'],\n create: ['title', 'body'],\n update: ['title', 'body'],\n delete: true,\n },\n },\n ),\n});\n```\n\nA table without a `client` block can't be reached from the browser at all.\n\nChoose the `parent({ author })` column and its author permissions in the table's first deploy. To change them on a deployed table, declare a new table with the desired rule and move the rows from server code.\n\nDelete a never-deployed starter table's declaration and references. A `removedTable()` marker for it is a no-op. **Removing a table** is `old_table: removedTable()`. The deploy keeps the table while your previous version is still serving; once the new version is live it retires the table and keeps its data for 30 days.\n\nRun `somewhere typecheck` before deploying schema changes.\n\n## What a deploy does with it\n\n- **Additive changes apply**: a new table, a new nullable-or-defaulted column, a new index, a new unique group. Unchanged schema is a no-op.\n- **Unmarked removals and shape changes refuse** with `409 SCHEMA_DEPLOY_REFUSED` and a message naming the change.\n- **Supported table scope changes apply in place.** See Two worlds for the supported transitions, including role-list edits on an existing `group()` or `appRole()` rule.\n- **Column rules and child author rules are set on a new table.** A deploy refuses additions, edits or removals of `columns` rules (`write` and `memberOf`) or `parent({ author })` rules on a deployed table. Keep its current declaration and handle the operation in an authorized server endpoint, closing any direct browser write path that could bypass the endpoint. To change the declared rule, create a new table with the desired rule and migrate the rows from server code.\n- a production deploy or a promotion that would remove or rename a column is refused before anything changes, so a running release never loses a column it uses. Keep the column declared and leave its data in place.\n\n## Failure: raw SQL refused after the schema file deploys\n\
|
|
44802
|
+
"sha256": "05fa17d25e504a44b3e8f6b88710dffc85a367a7bed289e81bca65c5cc6bb492",
|
|
44803
|
+
"content": "---\nname: schema-changes\ndescription: Before adding, changing, or removing a table or column in db/schema.ts.\n---\n\n# Change the database schema safely\n\n## The file is the contract\n\nThe default `somewhere init` starter has no `db/schema.ts`: create it at the project root, or run `somewhere init --name my-app --features private-data` to start with a schema.\n\n```ts\n// db/schema.ts\nimport { id, owner, schema, table, text, timestamp } from 'somewhere/db';\n\nexport default schema({\n notes: table(\n {\n id: id(),\n title: text(),\n body: text({ default: '' }),\n created_at: timestamp({ default: 'now' }),\n },\n {\n scope: owner(),\n client: {\n read: ['id', 'title', 'body', 'created_at'],\n create: ['title', 'body'],\n update: ['title', 'body'],\n delete: true,\n },\n },\n ),\n});\n```\n\nA table without a `client` block can't be reached from the browser at all.\n\nChoose the `parent({ author })` column and its author permissions in the table's first deploy. To change them on a deployed table, declare a new table with the desired rule and move the rows from server code.\n\nDelete a never-deployed starter table's declaration and references. A `removedTable()` marker for it is a no-op. **Removing a table** is `old_table: removedTable()`. The deploy keeps the table while your previous version is still serving; once the new version is live it retires the table and keeps its data for 30 days.\n\nRun `somewhere typecheck` before deploying schema changes.\n\n## What a deploy does with it\n\n- **Additive changes apply**: a new table, a new nullable-or-defaulted column, a new index, a new unique group. Unchanged schema is a no-op.\n- **Unmarked removals and shape changes refuse** with `409 SCHEMA_DEPLOY_REFUSED` and a message naming the change.\n- **Supported table scope changes apply in place.** See Two worlds for the supported transitions, including role-list edits on an existing `group()` or `appRole()` rule.\n- **Column rules and child author rules are set on a new table.** A deploy refuses additions, edits or removals of `columns` rules (`write` and `memberOf`) or `parent({ author })` rules on a deployed table. Keep its current declaration and handle the operation in an authorized server endpoint, closing any direct browser write path that could bypass the endpoint. To change the declared rule, create a new table with the desired rule and migrate the rows from server code.\n- a production deploy or a promotion that would remove or rename a column is refused before anything changes, so a running release never loses a column it uses. Keep the column declared and leave its data in place.\n\n## Failure: raw SQL refused after the schema file deploys\n\nRaw SQL (`sw.db.query`, `sw.db.server.query` and their batch forms) never reads or writes declared tables, including in job, queue, and cron handlers: Fix: read with `sw.db.from` / `sw.db.count` / `sw.db.aggregate` and write with `sw.db.insert` / `sw.db.update` / `sw.db.remove` (the table needs a declared intent)\n\nSources (`somewhere docs <topic>`): declared-data, getting-started, sw.db, troubleshooting.\n"
|
|
44762
44804
|
},
|
|
44763
44805
|
{
|
|
44764
44806
|
"path": "sign-in-setup/SKILL.md",
|
|
@@ -44772,8 +44814,8 @@ var init_skills_pack_generated = __esm({
|
|
|
44772
44814
|
},
|
|
44773
44815
|
{
|
|
44774
44816
|
"path": "realtime-and-background/SKILL.md",
|
|
44775
|
-
"sha256": "
|
|
44776
|
-
"content": "---\nname: realtime-and-background\ndescription: When the page must update without a reload, or work must run outside one request.\n---\n\n# Live lists, jobs, cron\n\n## Live list: the page updates when rows change\n\nDeclare the list in a function with `sw.rooms.live(name, sw.db.from(...))` and follow it with `watchLive` from `/__sw/rooms/client.js`.\n\n```ts\n// api/open-notes.ts\nexport default async function (_req: Request, sw: SomewhereRuntimeContext) {\n return Response.json(await sw.rooms.live('notes.open', sw.db.from('notes', {\n where: { done: false },\n columns: ['id', 'title', 'done', 'created_at'],\n order: [['created_at', 'desc'], ['id', 'asc']],\n limit: 20,\n })))\n}\n```\n\n```js\n// browser\nimport { watchLive } from '/__sw/rooms/client.js'\
|
|
44817
|
+
"sha256": "b67dd797fd09f655584ad779605ec2d5526e329aba9ea18069e12db0f41deaf3",
|
|
44818
|
+
"content": "---\nname: realtime-and-background\ndescription: When the page must update without a reload, or work must run outside one request.\n---\n\n# Live lists, jobs, cron\n\n## Live list: the page updates when rows change\n\nDeclare the list in a function with `sw.rooms.live(name, sw.db.from(...))` and follow it with `watchLive` from `/__sw/rooms/client.js`.\n\n```ts\n// api/open-notes.ts\nexport default async function (_req: Request, sw: SomewhereRuntimeContext) {\n return Response.json(await sw.rooms.live('notes.open', sw.db.from('notes', {\n where: { done: false },\n columns: ['id', 'title', 'done', 'created_at'],\n order: [['created_at', 'desc'], ['id', 'asc']],\n limit: 20,\n })))\n}\n```\n\n```js\n// browser\nimport { watchLive } from '/__sw/rooms/client.js'\nconst stop = watchLive(\n () => fetch('/api/tickets', { credentials: 'include' }).then((r) => r.json()),\n (rows) => render(rows),\n)\n```\n\n## Job: slow work with a status\n\nRun work that shouldn't block a user request in a job. Make handlers idempotent \u2014 they may run more than once.\n\n```ts\nconst job = await sw.jobs.create({\n handler: '/api/jobs/summarize-notes',\n idempotency_key: `summary:${user.id}:${operationId}`,\n // user_id comes from the verified session, so the handler can trust it.\n payload: { summary_id: `${user.id}:${operationId}`, user_id: user.id },\n});\n```\n\n```ts\nif (!(await sw.jobs.verifyInvocation(request))) {\n return Response.json({ error: 'forbidden' }, { status: 403 });\n}\n```\n\n## Cron: on a schedule\n\nThe finest granularity is one minute: a 5-field expression has no seconds field.\n\n```js\ncron_create({\n project_id: \"my-app\",\n schedule: \"0 9 * * *\", // 5-field cron expression\n timezone: \"America/Los_Angeles\", // optional; defaults to UTC\n handler: \"/api/jobs/daily-digest\",\n payload: { segment: \"daily\" } // optional\n})\n```\n\n## Failure 1: CRON_SCHEDULE_TOO_FREQUENT\n\nA schedule tighter than `min_interval_minutes` is refused when you create or edit it, with `CRON_SCHEDULE_TOO_FREQUENT` naming both intervals.\n\nSources (`somewhere docs <topic>`): cron, live, sw.jobs.\n"
|
|
44777
44819
|
},
|
|
44778
44820
|
{
|
|
44779
44821
|
"path": "email-and-test-inbox/SKILL.md",
|
|
@@ -46797,13 +46839,13 @@ var require_semver2 = __commonJS({
|
|
|
46797
46839
|
});
|
|
46798
46840
|
|
|
46799
46841
|
// dist/lib/project-pin.js
|
|
46800
|
-
import { existsSync as existsSync8, readFileSync as
|
|
46842
|
+
import { existsSync as existsSync8, readFileSync as readFileSync10, writeFileSync as writeFileSync8 } from "node:fs";
|
|
46801
46843
|
import { dirname as dirname2, join as join9 } from "node:path";
|
|
46802
46844
|
function readJson(path3) {
|
|
46803
46845
|
if (!existsSync8(path3))
|
|
46804
46846
|
return null;
|
|
46805
46847
|
try {
|
|
46806
|
-
const value = JSON.parse(
|
|
46848
|
+
const value = JSON.parse(readFileSync10(path3, "utf8"));
|
|
46807
46849
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
46808
46850
|
} catch {
|
|
46809
46851
|
return null;
|
|
@@ -46861,7 +46903,7 @@ function pinNotice(pin, running, delegatedTo) {
|
|
|
46861
46903
|
const newer = import_semver.default.valid(running) !== null && import_semver.default.gtr(running, pin.spec, { includePrerelease: true });
|
|
46862
46904
|
const move = `Run \`${cliInvocation()} upgrade\` to move the project to ${running}.`;
|
|
46863
46905
|
if (delegatedTo) {
|
|
46864
|
-
return `${head}; running its installed ${delegatedTo}
|
|
46906
|
+
return newer ? `${head}; running its installed ${delegatedTo}, not ${running}. ${move}` : null;
|
|
46865
46907
|
}
|
|
46866
46908
|
if (newer)
|
|
46867
46909
|
return `${head}; you are running ${running}. ${move}`;
|
|
@@ -46927,7 +46969,7 @@ function writeProjectPins(dir, pins, version2) {
|
|
|
46927
46969
|
let repairedStarter = false;
|
|
46928
46970
|
for (const pin of pins) {
|
|
46929
46971
|
const path3 = join9(dir, pin.source);
|
|
46930
|
-
const raw =
|
|
46972
|
+
const raw = readFileSync10(path3, "utf8");
|
|
46931
46973
|
const json = JSON.parse(raw);
|
|
46932
46974
|
if (pin.versionOnly) {
|
|
46933
46975
|
repairedStarter = repairStarterReact(json, pin.spec);
|
|
@@ -46960,7 +47002,7 @@ function recordPinIfMissing(dir, version2) {
|
|
|
46960
47002
|
return true;
|
|
46961
47003
|
}
|
|
46962
47004
|
function readBundledChangelog() {
|
|
46963
|
-
return
|
|
47005
|
+
return readFileSync10(join9(CLI_PACKAGE_ROOT, "CHANGELOG.md"), "utf8");
|
|
46964
47006
|
}
|
|
46965
47007
|
function changelogBetween(markdown, from, to2) {
|
|
46966
47008
|
const entries = [];
|
|
@@ -48587,7 +48629,7 @@ export const APP_TAGLINE = "Build your app in src/pages/HomePage.tsx.";
|
|
|
48587
48629
|
|
|
48588
48630
|
// "Continue with \u2026" buttons above the email form, in this order. The platform
|
|
48589
48631
|
// owns the OAuth clients. Add providers when this app uses social sign-in:
|
|
48590
|
-
// add '
|
|
48632
|
+
// add 'google' / 'discord' and deploy. GitHub sign-in is not available.
|
|
48591
48633
|
export const SIGN_IN_PROVIDERS: SignInProvider[] = [];
|
|
48592
48634
|
export const SHOW_EMAIL_VERIFICATION = false;
|
|
48593
48635
|
`;
|
|
@@ -52764,10 +52806,10 @@ function registerProject(program2) {
|
|
|
52764
52806
|
process.exit(1);
|
|
52765
52807
|
}
|
|
52766
52808
|
});
|
|
52767
|
-
proj.command("delete <
|
|
52809
|
+
proj.command("delete <id-or-address>").description("Delete a project: it goes offline now and its data is erased after 30 days. --undo restores it within those 30 days.").option("--confirm-code <code>", "Confirm deletion using the confirm_code returned by the first call").option("--undo", "Restore a project you deleted within the last 30 days. It comes back offline; deploy it again to put it online.").option("--json", "Print the deletion result as JSON").addOption(new Option("--yes").hideHelp()).addOption(new Option("--force").hideHelp()).action(async (nameOrId, opts) => {
|
|
52768
52810
|
const unsupported = opts.yes ? "--yes" : opts.force ? "--force" : void 0;
|
|
52769
52811
|
if (unsupported) {
|
|
52770
|
-
const message3 = `Unknown option '${unsupported}'. Run ${cliInvocation()} project delete <
|
|
52812
|
+
const message3 = `Unknown option '${unsupported}'. Run ${cliInvocation()} project delete <id-or-address> to get a code, then repeat with --confirm-code <code>.`;
|
|
52771
52813
|
if (opts.json)
|
|
52772
52814
|
printJsonError("UNKNOWN_OPTION", message3);
|
|
52773
52815
|
else
|
|
@@ -52878,21 +52920,11 @@ function registerProject(program2) {
|
|
|
52878
52920
|
});
|
|
52879
52921
|
}
|
|
52880
52922
|
async function resolveDeleteTarget(client, ref) {
|
|
52881
|
-
|
|
52882
|
-
|
|
52883
|
-
|
|
52884
|
-
|
|
52885
|
-
|
|
52886
|
-
}
|
|
52887
|
-
const listed = await client.call("GET", "/projects", void 0, { q: ref, fields: "compact" });
|
|
52888
|
-
const refLower = ref.toLowerCase();
|
|
52889
|
-
const exact = listed.projects.filter((p2) => p2.id === ref || p2.name?.toLowerCase() === refLower || p2.subdomain?.toLowerCase() === refLower || p2.slug?.toLowerCase() === refLower);
|
|
52890
|
-
if (exact.length === 1)
|
|
52891
|
-
return exact[0];
|
|
52892
|
-
if (exact.length > 1) {
|
|
52893
|
-
throw new CliApiError("AMBIGUOUS_PROJECT", `Multiple projects match "${ref}". Delete by project ID or subdomain instead.`, 400);
|
|
52894
|
-
}
|
|
52895
|
-
throw new CliApiError("PROJECT_NOT_FOUND", "Project not found.", 404);
|
|
52923
|
+
const project = await client.call("GET", `/projects/${encodeURIComponent(ref)}`);
|
|
52924
|
+
const normalized = ref.toLowerCase();
|
|
52925
|
+
if (project.id.toLowerCase() === normalized || !PROJECT_ID_RE.test(ref) && [project.subdomain, project.slug].some((address) => address?.toLowerCase() === normalized))
|
|
52926
|
+
return project;
|
|
52927
|
+
throw new CliApiError("PROJECT_NOT_FOUND", "Project not found. Use an exact project ID or address.", 404);
|
|
52896
52928
|
}
|
|
52897
52929
|
async function requestDeleteConfirmationCode(client, projectId) {
|
|
52898
52930
|
try {
|
|
@@ -53004,7 +53036,7 @@ function printAllowedOrigins(result) {
|
|
|
53004
53036
|
info(` ${teal(origin)}`);
|
|
53005
53037
|
info(dim(" The project's own address and any verified custom domain are always trusted and are not listed here."));
|
|
53006
53038
|
}
|
|
53007
|
-
var import_prompts3;
|
|
53039
|
+
var import_prompts3, PROJECT_ID_RE;
|
|
53008
53040
|
var init_project = __esm({
|
|
53009
53041
|
"dist/commands/project.js"() {
|
|
53010
53042
|
"use strict";
|
|
@@ -53021,6 +53053,7 @@ var init_project = __esm({
|
|
|
53021
53053
|
init_platform_command();
|
|
53022
53054
|
init_allowed_origins();
|
|
53023
53055
|
__name(registerProject, "registerProject");
|
|
53056
|
+
PROJECT_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
53024
53057
|
__name(resolveDeleteTarget, "resolveDeleteTarget");
|
|
53025
53058
|
__name(requestDeleteConfirmationCode, "requestDeleteConfirmationCode");
|
|
53026
53059
|
__name(printDeleteNote, "printDeleteNote");
|
|
@@ -69552,50 +69585,50 @@ var require_fast_uri = __commonJS({
|
|
|
69552
69585
|
return serialize(resolved, schemelessOptions);
|
|
69553
69586
|
}
|
|
69554
69587
|
__name(resolve27, "resolve");
|
|
69555
|
-
function resolveComponent(base,
|
|
69588
|
+
function resolveComponent(base, relative16, options2, skipNormalization) {
|
|
69556
69589
|
const target = {};
|
|
69557
69590
|
if (!skipNormalization) {
|
|
69558
69591
|
base = parse3(serialize(base, options2), options2);
|
|
69559
|
-
|
|
69592
|
+
relative16 = parse3(serialize(relative16, options2), options2);
|
|
69560
69593
|
}
|
|
69561
69594
|
options2 = options2 || {};
|
|
69562
|
-
if (!options2.tolerant &&
|
|
69563
|
-
target.scheme =
|
|
69564
|
-
target.userinfo =
|
|
69565
|
-
target.host =
|
|
69566
|
-
target.port =
|
|
69567
|
-
target.path = removeDotSegments(
|
|
69568
|
-
target.query =
|
|
69595
|
+
if (!options2.tolerant && relative16.scheme) {
|
|
69596
|
+
target.scheme = relative16.scheme;
|
|
69597
|
+
target.userinfo = relative16.userinfo;
|
|
69598
|
+
target.host = relative16.host;
|
|
69599
|
+
target.port = relative16.port;
|
|
69600
|
+
target.path = removeDotSegments(relative16.path || "");
|
|
69601
|
+
target.query = relative16.query;
|
|
69569
69602
|
} else {
|
|
69570
|
-
if (
|
|
69571
|
-
target.userinfo =
|
|
69572
|
-
target.host =
|
|
69573
|
-
target.port =
|
|
69574
|
-
target.path = removeDotSegments(
|
|
69575
|
-
target.query =
|
|
69603
|
+
if (relative16.userinfo !== void 0 || relative16.host !== void 0 || relative16.port !== void 0) {
|
|
69604
|
+
target.userinfo = relative16.userinfo;
|
|
69605
|
+
target.host = relative16.host;
|
|
69606
|
+
target.port = relative16.port;
|
|
69607
|
+
target.path = removeDotSegments(relative16.path || "");
|
|
69608
|
+
target.query = relative16.query;
|
|
69576
69609
|
} else {
|
|
69577
|
-
if (!
|
|
69610
|
+
if (!relative16.path) {
|
|
69578
69611
|
target.path = base.path;
|
|
69579
|
-
if (
|
|
69580
|
-
target.query =
|
|
69612
|
+
if (relative16.query !== void 0) {
|
|
69613
|
+
target.query = relative16.query;
|
|
69581
69614
|
} else {
|
|
69582
69615
|
target.query = base.query;
|
|
69583
69616
|
}
|
|
69584
69617
|
} else {
|
|
69585
|
-
if (
|
|
69586
|
-
target.path = removeDotSegments(
|
|
69618
|
+
if (relative16.path[0] === "/") {
|
|
69619
|
+
target.path = removeDotSegments(relative16.path);
|
|
69587
69620
|
} else {
|
|
69588
69621
|
const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
|
|
69589
69622
|
if (baseHasAuthority && !base.path) {
|
|
69590
|
-
target.path = "/" +
|
|
69623
|
+
target.path = "/" + relative16.path;
|
|
69591
69624
|
} else if (!base.path) {
|
|
69592
|
-
target.path =
|
|
69625
|
+
target.path = relative16.path;
|
|
69593
69626
|
} else {
|
|
69594
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
69627
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative16.path;
|
|
69595
69628
|
}
|
|
69596
69629
|
target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
|
|
69597
69630
|
}
|
|
69598
|
-
target.query =
|
|
69631
|
+
target.query = relative16.query;
|
|
69599
69632
|
}
|
|
69600
69633
|
target.userinfo = base.userinfo;
|
|
69601
69634
|
target.host = base.host;
|
|
@@ -69603,7 +69636,7 @@ var require_fast_uri = __commonJS({
|
|
|
69603
69636
|
}
|
|
69604
69637
|
target.scheme = base.scheme;
|
|
69605
69638
|
}
|
|
69606
|
-
target.fragment =
|
|
69639
|
+
target.fragment = relative16.fragment;
|
|
69607
69640
|
return target;
|
|
69608
69641
|
}
|
|
69609
69642
|
__name(resolveComponent, "resolveComponent");
|
|
@@ -74300,7 +74333,7 @@ var init_deploy_protected_files = __esm({
|
|
|
74300
74333
|
});
|
|
74301
74334
|
|
|
74302
74335
|
// dist/lib/role-method-hints.js
|
|
74303
|
-
import { existsSync as existsSync10, readdirSync as readdirSync2, readFileSync as
|
|
74336
|
+
import { existsSync as existsSync10, readdirSync as readdirSync2, readFileSync as readFileSync11 } from "node:fs";
|
|
74304
74337
|
import { createRequire as createRequire3 } from "node:module";
|
|
74305
74338
|
import { join as join11, relative as relative2, resolve as resolve4 } from "node:path";
|
|
74306
74339
|
function roleMethodHints(projectDir, { removedOnly = false } = {}) {
|
|
@@ -74339,7 +74372,7 @@ function roleMethodHints(projectDir, { removedOnly = false } = {}) {
|
|
|
74339
74372
|
}
|
|
74340
74373
|
if (!entry.isFile() || !/\.[cm]?[jt]sx?$/.test(entry.name) || /\.d\.ts$/.test(entry.name))
|
|
74341
74374
|
continue;
|
|
74342
|
-
const file = ts2.createSourceFile(path3,
|
|
74375
|
+
const file = ts2.createSourceFile(path3, readFileSync11(path3, "utf8"), ts2.ScriptTarget.Latest, true);
|
|
74343
74376
|
const exports = /* @__PURE__ */ new Set();
|
|
74344
74377
|
let unknown2 = false;
|
|
74345
74378
|
for (const statement of file.statements) {
|
|
@@ -74397,7 +74430,7 @@ var init_role_method_hints = __esm({
|
|
|
74397
74430
|
});
|
|
74398
74431
|
|
|
74399
74432
|
// dist/lib/notify/providers/update.js
|
|
74400
|
-
import { existsSync as existsSync11, mkdirSync as mkdirSync8, readFileSync as
|
|
74433
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync8, readFileSync as readFileSync12, writeFileSync as writeFileSync9 } from "node:fs";
|
|
74401
74434
|
import { dirname as dirname3, join as join12 } from "node:path";
|
|
74402
74435
|
function isNewer(a, b2) {
|
|
74403
74436
|
const parse3 = /* @__PURE__ */ __name((v2) => v2.split("-")[0].split(".").map((n) => Number(n)), "parse");
|
|
@@ -74413,7 +74446,7 @@ function isNewer(a, b2) {
|
|
|
74413
74446
|
}
|
|
74414
74447
|
function readCache(cachePath = CACHE_PATH) {
|
|
74415
74448
|
try {
|
|
74416
|
-
const c = JSON.parse(
|
|
74449
|
+
const c = JSON.parse(readFileSync12(cachePath, "utf8"));
|
|
74417
74450
|
if (typeof c?.checkedAt !== "number")
|
|
74418
74451
|
return null;
|
|
74419
74452
|
return c;
|
|
@@ -74476,7 +74509,7 @@ async function getOutdatedWarning(currentVersion3, options2 = {}) {
|
|
|
74476
74509
|
const warnedPath = options2.warnedPath ?? WARNED_PATH;
|
|
74477
74510
|
const now2 = (options2.now ?? Date.now)();
|
|
74478
74511
|
try {
|
|
74479
|
-
const warned2 = JSON.parse(
|
|
74512
|
+
const warned2 = JSON.parse(readFileSync12(warnedPath, "utf8"));
|
|
74480
74513
|
if (typeof warned2.warnedAt === "number" && now2 - warned2.warnedAt < ONE_DAY && now2 >= warned2.warnedAt)
|
|
74481
74514
|
return null;
|
|
74482
74515
|
} catch {
|
|
@@ -74548,7 +74581,7 @@ var init_update = __esm({
|
|
|
74548
74581
|
});
|
|
74549
74582
|
|
|
74550
74583
|
// dist/lib/notify/index.js
|
|
74551
|
-
import { readFileSync as
|
|
74584
|
+
import { readFileSync as readFileSync13 } from "node:fs";
|
|
74552
74585
|
import { join as join13 } from "node:path";
|
|
74553
74586
|
function suppressExitNotices() {
|
|
74554
74587
|
exitNoticesSuppressed = true;
|
|
@@ -74563,7 +74596,7 @@ function subcommandSuppressesNotifications(argv) {
|
|
|
74563
74596
|
}
|
|
74564
74597
|
function currentVersion() {
|
|
74565
74598
|
try {
|
|
74566
|
-
const pkg = JSON.parse(
|
|
74599
|
+
const pkg = JSON.parse(readFileSync13(join13(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
74567
74600
|
return pkg.version;
|
|
74568
74601
|
} catch {
|
|
74569
74602
|
return "0.0.0";
|
|
@@ -74626,19 +74659,19 @@ __export(declared_data_exports, {
|
|
|
74626
74659
|
localFilesContract: () => localFilesContract,
|
|
74627
74660
|
prepareDeclaredData: () => prepareDeclaredData
|
|
74628
74661
|
});
|
|
74629
|
-
import { existsSync as existsSync12, readFileSync as
|
|
74662
|
+
import { existsSync as existsSync12, readFileSync as readFileSync14, rmSync as rmSync3, writeFileSync as writeFileSync10 } from "node:fs";
|
|
74630
74663
|
import { createRequire as createRequire4 } from "node:module";
|
|
74631
74664
|
import { join as join14, resolve as resolve5 } from "node:path";
|
|
74632
74665
|
function localFilesContract(projectDir) {
|
|
74633
74666
|
const path3 = join14(projectDir, "db", "schema.ts");
|
|
74634
74667
|
const generator = require4("./runtime/declared-data.cjs");
|
|
74635
|
-
const digest = existsSync12(path3) && generator.filesContractFromFiles({ "db/schema.ts":
|
|
74668
|
+
const digest = existsSync12(path3) && generator.filesContractFromFiles({ "db/schema.ts": readFileSync14(path3, "utf8") });
|
|
74636
74669
|
if (!digest)
|
|
74637
74670
|
throw new Error("Declare file collections in db/schema.ts and deploy the app before testing files.");
|
|
74638
74671
|
return { digest, singleRequestMaxBytes: generator.SINGLE_REQUEST_MAX_BYTES };
|
|
74639
74672
|
}
|
|
74640
74673
|
function generatedContents(path3) {
|
|
74641
|
-
const previous = existsSync12(path3) ?
|
|
74674
|
+
const previous = existsSync12(path3) ? readFileSync14(path3, "utf8") : void 0;
|
|
74642
74675
|
if (previous !== void 0 && !previous.startsWith(GENERATED_DATA_HEADER)) {
|
|
74643
74676
|
throw new Error(`Cannot overwrite ${path3}; this path is reserved for a generated declaration.`);
|
|
74644
74677
|
}
|
|
@@ -74649,8 +74682,8 @@ function prepareDeclaredData(projectDir) {
|
|
|
74649
74682
|
const declarationDir = existsSync12(join14(projectDir, "src")) ? join14(projectDir, "src") : projectDir;
|
|
74650
74683
|
const declarationPath = join14(declarationDir, DATA_DECLARATION_FILE);
|
|
74651
74684
|
const filesPath = join14(declarationDir, FILES_DECLARATION_FILE);
|
|
74652
|
-
const previous = existsSync12(declarationPath) ?
|
|
74653
|
-
const previousFiles = existsSync12(filesPath) ?
|
|
74685
|
+
const previous = existsSync12(declarationPath) ? readFileSync14(declarationPath, "utf8") : void 0;
|
|
74686
|
+
const previousFiles = existsSync12(filesPath) ? readFileSync14(filesPath, "utf8") : void 0;
|
|
74654
74687
|
if (!existsSync12(schemaPath)) {
|
|
74655
74688
|
if (previousFiles?.startsWith(GENERATED_DATA_HEADER))
|
|
74656
74689
|
rmSync3(filesPath);
|
|
@@ -74671,7 +74704,7 @@ function prepareDeclaredData(projectDir) {
|
|
|
74671
74704
|
let filesDeclaration;
|
|
74672
74705
|
const generator = require4("./runtime/declared-data.cjs");
|
|
74673
74706
|
try {
|
|
74674
|
-
const files = { "db/schema.ts":
|
|
74707
|
+
const files = { "db/schema.ts": readFileSync14(schemaPath, "utf8") };
|
|
74675
74708
|
client = generator.generateFromFiles(files);
|
|
74676
74709
|
localDeclaration = generator.localDeclarationFromFiles(files);
|
|
74677
74710
|
tables = generator.declaredTablesFromFiles(files);
|
|
@@ -74793,7 +74826,7 @@ __export(typecheck_exports, {
|
|
|
74793
74826
|
typecheckTimeoutMs: () => typecheckTimeoutMs
|
|
74794
74827
|
});
|
|
74795
74828
|
import { spawn as spawn3, spawnSync } from "node:child_process";
|
|
74796
|
-
import { existsSync as existsSync13, readFileSync as
|
|
74829
|
+
import { existsSync as existsSync13, readFileSync as readFileSync15, rmSync as rmSync4, writeFileSync as writeFileSync11 } from "node:fs";
|
|
74797
74830
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
74798
74831
|
import { dirname as dirname4, join as join15, relative as relative3 } from "node:path";
|
|
74799
74832
|
function isGeneratedApiImport(e) {
|
|
@@ -74838,7 +74871,7 @@ function resolveTsc(projectDir) {
|
|
|
74838
74871
|
function declaredDependencies(projectDir) {
|
|
74839
74872
|
let manifest;
|
|
74840
74873
|
try {
|
|
74841
|
-
manifest = JSON.parse(
|
|
74874
|
+
manifest = JSON.parse(readFileSync15(join15(projectDir, "package.json"), "utf8"));
|
|
74842
74875
|
} catch {
|
|
74843
74876
|
return {};
|
|
74844
74877
|
}
|
|
@@ -76224,11 +76257,11 @@ function createPattern(matcher) {
|
|
|
76224
76257
|
if (matcher.path === string4)
|
|
76225
76258
|
return true;
|
|
76226
76259
|
if (matcher.recursive) {
|
|
76227
|
-
const
|
|
76228
|
-
if (!
|
|
76260
|
+
const relative16 = sysPath2.relative(matcher.path, string4);
|
|
76261
|
+
if (!relative16) {
|
|
76229
76262
|
return false;
|
|
76230
76263
|
}
|
|
76231
|
-
return !
|
|
76264
|
+
return !relative16.startsWith("..") && !sysPath2.isAbsolute(relative16);
|
|
76232
76265
|
}
|
|
76233
76266
|
return false;
|
|
76234
76267
|
};
|
|
@@ -77056,7 +77089,7 @@ __export(files_exports, {
|
|
|
77056
77089
|
testFolderOf: () => testFolderOf
|
|
77057
77090
|
});
|
|
77058
77091
|
import { isUtf8 } from "node:buffer";
|
|
77059
|
-
import { existsSync as existsSync14, readdirSync as readdirSync3, readFileSync as
|
|
77092
|
+
import { closeSync as closeSync4, existsSync as existsSync14, openSync as openSync4, readdirSync as readdirSync3, readFileSync as readFileSync16, readSync, statSync as statSync2 } from "node:fs";
|
|
77060
77093
|
import { extname as extname3, isAbsolute as isAbsolute2, join as join18, posix as posix2, relative as relative6 } from "node:path";
|
|
77061
77094
|
function isTestSourcePath(relPath) {
|
|
77062
77095
|
return TEST_SOURCE_NAME.test(relPath.slice(relPath.lastIndexOf("/") + 1));
|
|
@@ -77122,11 +77155,11 @@ function compilerAssetMatcher(sources) {
|
|
|
77122
77155
|
};
|
|
77123
77156
|
}
|
|
77124
77157
|
function collectFiles(baseDir, options2 = {}) {
|
|
77125
|
-
const out = { dotfilesLeftOut: false, files: {}, binaryFiles: {}, functions: {}, skipped: [], oversize: [], notes: [], excluded: [], sensitive: [], published: [] };
|
|
77158
|
+
const out = { dotfilesLeftOut: false, cliCredentialFiles: [], files: {}, binaryFiles: {}, functions: {}, skipped: [], oversize: [], notes: [], excluded: [], sensitive: [], published: [] };
|
|
77126
77159
|
const ignore = loadDeployIgnore(baseDir);
|
|
77127
77160
|
const candidates = [];
|
|
77128
77161
|
const sizes = /* @__PURE__ */ new Map();
|
|
77129
|
-
walk(baseDir, baseDir, out, ignore, candidates, sizes);
|
|
77162
|
+
walk(baseDir, baseDir, out, ignore, candidates, sizes, options2.checkCliCredentials ? Buffer.alloc(512) : null);
|
|
77130
77163
|
const optIn = new Set((options2.include ?? []).map((p2) => toDeployPath(p2.trim()).replace(/^\.\//, "").replace(/\/+$/, "")).filter(Boolean));
|
|
77131
77164
|
const publish = [];
|
|
77132
77165
|
const deferred = [];
|
|
@@ -77151,9 +77184,10 @@ function collectFiles(baseDir, options2 = {}) {
|
|
|
77151
77184
|
deferred.push(relPath);
|
|
77152
77185
|
}
|
|
77153
77186
|
}
|
|
77154
|
-
const
|
|
77187
|
+
const inlineFileLimit = options2.inlineFileLimitBytes ?? MAX_FILE_SIZE;
|
|
77188
|
+
const corpusFiles = /* @__PURE__ */ __name((paths) => paths.filter((relPath) => isReferenceCorpusPath(relPath) && (sizes.get(relPath) ?? 0) <= inlineFileLimit).map((relPath) => {
|
|
77155
77189
|
try {
|
|
77156
|
-
return [relPath,
|
|
77190
|
+
return [relPath, readFileSync16(join18(baseDir, relPath), "utf-8")];
|
|
77157
77191
|
} catch {
|
|
77158
77192
|
return [relPath, ""];
|
|
77159
77193
|
}
|
|
@@ -77208,9 +77242,9 @@ function collectFiles(baseDir, options2 = {}) {
|
|
|
77208
77242
|
out.published.push(relPath);
|
|
77209
77243
|
continue;
|
|
77210
77244
|
}
|
|
77211
|
-
if (bytes >
|
|
77245
|
+
if (bytes > inlineFileLimit) {
|
|
77212
77246
|
out.oversize.push({ path: relPath, bytes });
|
|
77213
|
-
out.skipped.push({ path: relPath, reason: `${formatBytes(bytes)} exceeds the ${formatBytes(
|
|
77247
|
+
out.skipped.push({ path: relPath, reason: `${formatBytes(bytes)} exceeds the ${formatBytes(inlineFileLimit)} per-file limit` });
|
|
77214
77248
|
continue;
|
|
77215
77249
|
}
|
|
77216
77250
|
classifyInto(out, baseDir, relPath, options2.readBinary !== false);
|
|
@@ -77227,7 +77261,34 @@ function collectFiles(baseDir, options2 = {}) {
|
|
|
77227
77261
|
}
|
|
77228
77262
|
return out;
|
|
77229
77263
|
}
|
|
77230
|
-
function
|
|
77264
|
+
function looksLikeCliCredential(path3, bytes, header) {
|
|
77265
|
+
if (bytes === 0 || bytes > MAX_DEPLOY_BLOB_BYTES)
|
|
77266
|
+
return false;
|
|
77267
|
+
const fd = openSync4(path3, "r");
|
|
77268
|
+
try {
|
|
77269
|
+
const size = readSync(fd, header, 0, header.length, 0);
|
|
77270
|
+
const prefix = header.toString("utf8", 0, size).trimStart();
|
|
77271
|
+
if (!prefix.startsWith("{") && !/^(?:smt|smtr)_/i.test(prefix))
|
|
77272
|
+
return false;
|
|
77273
|
+
} finally {
|
|
77274
|
+
closeSync4(fd);
|
|
77275
|
+
}
|
|
77276
|
+
const text = readFileSync16(path3, "utf8").trim();
|
|
77277
|
+
const cliKey = /^(?:smt|smtr)_[a-z0-9_-]+$/i;
|
|
77278
|
+
if (cliKey.test(text))
|
|
77279
|
+
return true;
|
|
77280
|
+
if (!text.startsWith("{"))
|
|
77281
|
+
return false;
|
|
77282
|
+
try {
|
|
77283
|
+
const value = JSON.parse(text);
|
|
77284
|
+
if (typeof value !== "object" || value === null)
|
|
77285
|
+
return false;
|
|
77286
|
+
return "token" in value && typeof value.token === "string" && cliKey.test(value.token) || "refresh_token" in value && typeof value.refresh_token === "string" && cliKey.test(value.refresh_token);
|
|
77287
|
+
} catch {
|
|
77288
|
+
return false;
|
|
77289
|
+
}
|
|
77290
|
+
}
|
|
77291
|
+
function walk(baseDir, currentDir, out, ignore, candidates, sizes, credentialHeader) {
|
|
77231
77292
|
for (const entry of readdirSync3(currentDir, { withFileTypes: true })) {
|
|
77232
77293
|
const fullPath = join18(currentDir, entry.name);
|
|
77233
77294
|
const relPath = toDeployPath(relative6(baseDir, fullPath));
|
|
@@ -77241,7 +77302,7 @@ function walk(baseDir, currentDir, out, ignore, candidates, sizes) {
|
|
|
77241
77302
|
continue;
|
|
77242
77303
|
}
|
|
77243
77304
|
if (entry.isDirectory()) {
|
|
77244
|
-
walk(baseDir, fullPath, out, ignore, candidates, sizes);
|
|
77305
|
+
walk(baseDir, fullPath, out, ignore, candidates, sizes, credentialHeader);
|
|
77245
77306
|
continue;
|
|
77246
77307
|
}
|
|
77247
77308
|
if (!entry.isFile())
|
|
@@ -77250,9 +77311,14 @@ function walk(baseDir, currentDir, out, ignore, candidates, sizes) {
|
|
|
77250
77311
|
out.sensitive.push({ path: relPath, reason: SENSITIVE_FILE_REASON, referencedBy: [] });
|
|
77251
77312
|
continue;
|
|
77252
77313
|
}
|
|
77253
|
-
if ((entry.name === DATA_DECLARATION_FILE || entry.name === FILES_DECLARATION_FILE) &&
|
|
77314
|
+
if ((entry.name === DATA_DECLARATION_FILE || entry.name === FILES_DECLARATION_FILE) && readFileSync16(fullPath, "utf8").startsWith(GENERATED_DATA_HEADER))
|
|
77254
77315
|
continue;
|
|
77255
|
-
|
|
77316
|
+
const bytes = statSync2(fullPath).size;
|
|
77317
|
+
if (credentialHeader && looksLikeCliCredential(fullPath, bytes, credentialHeader)) {
|
|
77318
|
+
out.cliCredentialFiles.push(relPath);
|
|
77319
|
+
continue;
|
|
77320
|
+
}
|
|
77321
|
+
sizes.set(relPath, bytes);
|
|
77256
77322
|
candidates.push(relPath);
|
|
77257
77323
|
}
|
|
77258
77324
|
}
|
|
@@ -77272,7 +77338,7 @@ function classifyKey(relPath) {
|
|
|
77272
77338
|
}
|
|
77273
77339
|
function classifyInto(out, baseDir, relPath, readBinary = true) {
|
|
77274
77340
|
const { kind, key } = classifyKey(relPath);
|
|
77275
|
-
const bytes = kind === "binary" && !readBinary ? Buffer.alloc(0) :
|
|
77341
|
+
const bytes = kind === "binary" && !readBinary ? Buffer.alloc(0) : readFileSync16(join18(baseDir, relPath));
|
|
77276
77342
|
const binary = kind === "binary" || !isUtf8(bytes);
|
|
77277
77343
|
if (binary) {
|
|
77278
77344
|
if (kind === "function")
|
|
@@ -77301,7 +77367,7 @@ function loadDeployIgnore(baseDir) {
|
|
|
77301
77367
|
const path3 = join18(baseDir, fileName2);
|
|
77302
77368
|
if (!existsSync14(path3))
|
|
77303
77369
|
continue;
|
|
77304
|
-
const lines =
|
|
77370
|
+
const lines = readFileSync16(path3, "utf8").split(/\r?\n/);
|
|
77305
77371
|
for (const raw of lines) {
|
|
77306
77372
|
const rule = parseIgnoreRule(raw);
|
|
77307
77373
|
if (!rule)
|
|
@@ -77385,11 +77451,12 @@ function globToRegExp(pattern) {
|
|
|
77385
77451
|
function escapeRegExp(ch) {
|
|
77386
77452
|
return /[\\^$+?.()|[\]{}]/.test(ch) ? `\\${ch}` : ch;
|
|
77387
77453
|
}
|
|
77388
|
-
function oversizeRefusal(collected) {
|
|
77454
|
+
function oversizeRefusal(collected, limitBytes = MAX_FILE_SIZE) {
|
|
77389
77455
|
if (collected.oversize.length === 0)
|
|
77390
77456
|
return null;
|
|
77457
|
+
const limit = limitBytes === MAX_INLINE_DEPLOY_BYTES ? "20 MiB inline deploy" : `${formatBytes(limitBytes)} per-file`;
|
|
77391
77458
|
return [
|
|
77392
|
-
`Nothing was sent. ${collected.oversize.length === 1 ? "This file is" : "These files are"} over the ${
|
|
77459
|
+
`Nothing was sent. ${collected.oversize.length === 1 ? "This file is" : "These files are"} over the ${limit} limit and would be left out, which removes any copy already live:`,
|
|
77393
77460
|
...collected.oversize.map((entry) => ` ${entry.path} (${formatBytes(entry.bytes)})`),
|
|
77394
77461
|
...fileStorageRecovery(collected.oversize)
|
|
77395
77462
|
].join("\n");
|
|
@@ -77524,6 +77591,7 @@ var init_files = __esm({
|
|
|
77524
77591
|
SENSITIVE_FILE_REASON = "blocked by the sensitive-path policy \u2014 never uploaded";
|
|
77525
77592
|
__name(compilerAssetMatcher, "compilerAssetMatcher");
|
|
77526
77593
|
__name(collectFiles, "collectFiles");
|
|
77594
|
+
__name(looksLikeCliCredential, "looksLikeCliCredential");
|
|
77527
77595
|
__name(walk, "walk");
|
|
77528
77596
|
__name(classifyKey, "classifyKey");
|
|
77529
77597
|
__name(classifyInto, "classifyInto");
|
|
@@ -77572,12 +77640,12 @@ var init_files = __esm({
|
|
|
77572
77640
|
|
|
77573
77641
|
// dist/lib/deploy-check.js
|
|
77574
77642
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
77575
|
-
import { existsSync as existsSync15, mkdirSync as mkdirSync9, readFileSync as
|
|
77643
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync9, readFileSync as readFileSync17, realpathSync as realpathSync2, rmSync as rmSync5, writeFileSync as writeFileSync12 } from "node:fs";
|
|
77576
77644
|
import { createRequire as createRequire5 } from "node:module";
|
|
77577
77645
|
import { isAbsolute as isAbsolute3, join as join19, relative as relative7, resolve as resolve8 } from "node:path";
|
|
77578
77646
|
function projectTypeScriptVersion(projectDir) {
|
|
77579
77647
|
try {
|
|
77580
|
-
const version2 = JSON.parse(
|
|
77648
|
+
const version2 = JSON.parse(readFileSync17(join19(projectDir, "node_modules", "typescript", "package.json"), "utf8")).version;
|
|
77581
77649
|
return typeof version2 === "string" && version2 ? version2 : null;
|
|
77582
77650
|
} catch {
|
|
77583
77651
|
return null;
|
|
@@ -77694,7 +77762,7 @@ async function startDeployCheck(projectDir, onFetch) {
|
|
|
77694
77762
|
return { ok: true, findings: [], typescript, checkedFiles: 0 };
|
|
77695
77763
|
const { command, args } = deployCheckTsc(projectDir);
|
|
77696
77764
|
const tsconfigPath = join19(projectDir, "tsconfig.json");
|
|
77697
|
-
const own2 = projectCompilerOptions(existsSync15(tsconfigPath) ?
|
|
77765
|
+
const own2 = projectCompilerOptions(existsSync15(tsconfigPath) ? readFileSync17(tsconfigPath, "utf8") : void 0);
|
|
77698
77766
|
const id = randomUUID5();
|
|
77699
77767
|
const config2 = join19(projectDir, `.__somewhere_deploy_check_${id}.json`);
|
|
77700
77768
|
const declarationsDir = join19(projectDir, `.__somewhere_deploy_check_${id}`);
|
|
@@ -77767,7 +77835,7 @@ var init_deploy_check = __esm({
|
|
|
77767
77835
|
});
|
|
77768
77836
|
|
|
77769
77837
|
// dist/lib/agent-hooks.js
|
|
77770
|
-
import { existsSync as existsSync16, lstatSync as lstatSync4, mkdirSync as mkdirSync10, readFileSync as
|
|
77838
|
+
import { existsSync as existsSync16, lstatSync as lstatSync4, mkdirSync as mkdirSync10, readFileSync as readFileSync18, realpathSync as realpathSync3, statSync as statSync3, writeFileSync as writeFileSync13 } from "node:fs";
|
|
77771
77839
|
import { homedir as homedir2 } from "node:os";
|
|
77772
77840
|
import { delimiter, dirname as dirname7, isAbsolute as isAbsolute4, join as join20, relative as relative8, resolve as resolve9, sep } from "node:path";
|
|
77773
77841
|
function isAgentHost(value) {
|
|
@@ -77805,7 +77873,7 @@ function readConfig(path3) {
|
|
|
77805
77873
|
if (!existsSync16(path3))
|
|
77806
77874
|
return {};
|
|
77807
77875
|
try {
|
|
77808
|
-
const parsed = JSON.parse(
|
|
77876
|
+
const parsed = JSON.parse(readFileSync18(path3, "utf8"));
|
|
77809
77877
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : new Error("is not a JSON object");
|
|
77810
77878
|
} catch (error3) {
|
|
77811
77879
|
return error3 instanceof Error ? error3 : new Error(String(error3));
|
|
@@ -77945,7 +78013,7 @@ function hookProjectRoot(host, payload, env = process.env, cwd = process.cwd())
|
|
|
77945
78013
|
return null;
|
|
77946
78014
|
for (let dir = resolve9(start); ; dir = dirname7(dir)) {
|
|
77947
78015
|
const config2 = join20(dir, HOSTS[host].configPath);
|
|
77948
|
-
if (existsSync16(config2) && HOOK_MARKER.test(
|
|
78016
|
+
if (existsSync16(config2) && HOOK_MARKER.test(readFileSync18(config2, "utf8")))
|
|
77949
78017
|
return dir;
|
|
77950
78018
|
if (dirname7(dir) === dir)
|
|
77951
78019
|
return null;
|
|
@@ -78147,7 +78215,7 @@ __export(source_lint_exports, {
|
|
|
78147
78215
|
});
|
|
78148
78216
|
import { createRequire as createRequire6 } from "node:module";
|
|
78149
78217
|
import { performance as performance2 } from "node:perf_hooks";
|
|
78150
|
-
import { readdirSync as readdirSync4, readFileSync as
|
|
78218
|
+
import { readdirSync as readdirSync4, readFileSync as readFileSync19, statSync as statSync4 } from "node:fs";
|
|
78151
78219
|
import { join as join22 } from "node:path";
|
|
78152
78220
|
async function lintProject(directory2, options2 = {}) {
|
|
78153
78221
|
const started = performance2.now();
|
|
@@ -78262,7 +78330,7 @@ function readHeldBackTests(root, paths) {
|
|
|
78262
78330
|
return;
|
|
78263
78331
|
}
|
|
78264
78332
|
if (stat7?.isFile() && SOURCE2.test(rel) && stat7.size <= 1024 * 1024)
|
|
78265
|
-
out[rel] =
|
|
78333
|
+
out[rel] = readFileSync19(full, "utf8");
|
|
78266
78334
|
}, "visit");
|
|
78267
78335
|
for (const path3 of paths)
|
|
78268
78336
|
visit(path3);
|
|
@@ -78750,8 +78818,8 @@ function formatChecksReport(check) {
|
|
|
78750
78818
|
}
|
|
78751
78819
|
const coverage = check?.not_checked ?? null;
|
|
78752
78820
|
if (coverage) {
|
|
78753
|
-
if (typeof check?.routes_discovered === "number"
|
|
78754
|
-
lines.push(`${check.routes_checked} of ${check.routes_discovered} app routes had a completed read check.`);
|
|
78821
|
+
if (typeof check?.routes_discovered === "number")
|
|
78822
|
+
lines.push(check.routes_checked ? `${check.routes_checked} of ${check.routes_discovered} app routes had a completed read check.` : `This check called none of your ${check.routes_discovered} app routes: it covers your tables, pages and saved checks/ lists. Check the routes in tests/starter.mjs (npm test).`);
|
|
78755
78823
|
const { routes_without_read_check: reads, routes_without_write_check: writes, schedules_not_run: schedules, other } = coverage;
|
|
78756
78824
|
if (reads === null || writes === null)
|
|
78757
78825
|
lines.push("App route coverage could not be listed.");
|
|
@@ -78765,11 +78833,10 @@ function formatChecksReport(check) {
|
|
|
78765
78833
|
lines.push(`This check skips scheduled tasks (${schedules.join(", ")}). To verify one on your preview, use ${cliInvocation()} cron run <name> --preview --wait.`);
|
|
78766
78834
|
if (other.length)
|
|
78767
78835
|
lines.push(`Other checks skipped or out of scope: ${other.join(", ")}.`);
|
|
78768
|
-
if (!check?.routes_checked)
|
|
78769
|
-
lines.push("Your app's own routes, screens and rules are proven by your own tests (npm test), not by this check.");
|
|
78770
78836
|
} else {
|
|
78771
78837
|
lines.push("Coverage details are unavailable for this run.");
|
|
78772
78838
|
}
|
|
78839
|
+
lines.push("Prove the brief in tests/starter.mjs (npm test). To rerun a check after every deploy, save it as checks/<name>.json (users and steps). See somewhere docs test.");
|
|
78773
78840
|
return [...lines, JSON.stringify({
|
|
78774
78841
|
...summary,
|
|
78775
78842
|
not_checked: coverage,
|
|
@@ -78896,7 +78963,7 @@ var init_live_refusal = __esm({
|
|
|
78896
78963
|
});
|
|
78897
78964
|
|
|
78898
78965
|
// dist/lib/build-errors.js
|
|
78899
|
-
import { existsSync as existsSync19, readFileSync as
|
|
78966
|
+
import { existsSync as existsSync19, readFileSync as readFileSync20 } from "node:fs";
|
|
78900
78967
|
import { isAbsolute as isAbsolute5, join as join24 } from "node:path";
|
|
78901
78968
|
function parseBundleErrorText(text) {
|
|
78902
78969
|
const out = [];
|
|
@@ -78930,7 +78997,7 @@ function frameFor(detail, baseDir, serverFrame) {
|
|
|
78930
78997
|
const abs = isAbsolute5(detail.file) ? detail.file : join24(baseDir, detail.file);
|
|
78931
78998
|
if (existsSync19(abs)) {
|
|
78932
78999
|
try {
|
|
78933
|
-
const frame = localCodeFrame(
|
|
79000
|
+
const frame = localCodeFrame(readFileSync20(abs, "utf-8"), detail.line, detail.column);
|
|
78934
79001
|
if (frame)
|
|
78935
79002
|
return frame;
|
|
78936
79003
|
} catch {
|
|
@@ -79199,7 +79266,7 @@ var init_temp_auth = __esm({
|
|
|
79199
79266
|
});
|
|
79200
79267
|
|
|
79201
79268
|
// dist/lib/project-notices.js
|
|
79202
|
-
import { existsSync as existsSync20, mkdirSync as mkdirSync11, readFileSync as
|
|
79269
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync11, readFileSync as readFileSync21, writeFileSync as writeFileSync14 } from "node:fs";
|
|
79203
79270
|
import { dirname as dirname8, join as join26 } from "node:path";
|
|
79204
79271
|
function localDay(now2) {
|
|
79205
79272
|
const date4 = new Date(now2);
|
|
@@ -79209,7 +79276,7 @@ function readState(path3) {
|
|
|
79209
79276
|
if (!existsSync20(path3))
|
|
79210
79277
|
return { shown: {} };
|
|
79211
79278
|
try {
|
|
79212
|
-
const parsed = JSON.parse(
|
|
79279
|
+
const parsed = JSON.parse(readFileSync21(path3, "utf8"));
|
|
79213
79280
|
return parsed.shown && typeof parsed.shown === "object" ? { shown: parsed.shown } : { shown: {} };
|
|
79214
79281
|
} catch {
|
|
79215
79282
|
return { shown: {} };
|
|
@@ -79261,7 +79328,7 @@ var init_project_notices = __esm({
|
|
|
79261
79328
|
});
|
|
79262
79329
|
|
|
79263
79330
|
// dist/lib/test-identities.js
|
|
79264
|
-
import { chmodSync as chmodSync2, existsSync as existsSync21, mkdirSync as mkdirSync12, readFileSync as
|
|
79331
|
+
import { chmodSync as chmodSync2, existsSync as existsSync21, mkdirSync as mkdirSync12, readFileSync as readFileSync22, renameSync as renameSync3, rmSync as rmSync6, writeFileSync as writeFileSync15 } from "node:fs";
|
|
79265
79332
|
import { join as join27 } from "node:path";
|
|
79266
79333
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
79267
79334
|
function parseActorSpecs(values) {
|
|
@@ -79318,7 +79385,7 @@ ${TEST_STATE_GITIGNORE_LINE}
|
|
|
79318
79385
|
`);
|
|
79319
79386
|
return "created";
|
|
79320
79387
|
}
|
|
79321
|
-
const text =
|
|
79388
|
+
const text = readFileSync22(path3, "utf8");
|
|
79322
79389
|
const lines = text.split(/\r?\n/).map((line) => line.trim());
|
|
79323
79390
|
if (lines.some((line) => [".somewhere/test/", ".somewhere/test", "/.somewhere/test/", "/.somewhere/test", ".somewhere/", ".somewhere", "/.somewhere/", "/.somewhere"].includes(line)))
|
|
79324
79391
|
return "present";
|
|
@@ -79335,7 +79402,7 @@ function readManifest(root) {
|
|
|
79335
79402
|
const invalid = /* @__PURE__ */ __name((why) => Object.assign(new Error(`${path3} is not a valid test-users manifest (${why}); nothing was changed.`), { code: "MANIFEST_INVALID" }), "invalid");
|
|
79336
79403
|
let value;
|
|
79337
79404
|
try {
|
|
79338
|
-
value = JSON.parse(
|
|
79405
|
+
value = JSON.parse(readFileSync22(path3, "utf8"));
|
|
79339
79406
|
} catch {
|
|
79340
79407
|
throw invalid("not JSON");
|
|
79341
79408
|
}
|
|
@@ -79363,7 +79430,7 @@ function preparedActorState(root, target, name) {
|
|
|
79363
79430
|
const domain = new URL(target.origin).hostname;
|
|
79364
79431
|
let state;
|
|
79365
79432
|
try {
|
|
79366
|
-
state = JSON.parse(
|
|
79433
|
+
state = JSON.parse(readFileSync22(path3, "utf8"));
|
|
79367
79434
|
} catch {
|
|
79368
79435
|
throw new Error("Could not read the saved test user session.");
|
|
79369
79436
|
}
|
|
@@ -79532,7 +79599,7 @@ var init_test_identities = __esm({
|
|
|
79532
79599
|
});
|
|
79533
79600
|
|
|
79534
79601
|
// dist/lib/form-accounts.js
|
|
79535
|
-
import { existsSync as existsSync22, readdirSync as readdirSync5, readFileSync as
|
|
79602
|
+
import { existsSync as existsSync22, readdirSync as readdirSync5, readFileSync as readFileSync23, rmSync as rmSync7 } from "node:fs";
|
|
79536
79603
|
import { join as join28 } from "node:path";
|
|
79537
79604
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
79538
79605
|
function readDeletionAnswer(ids, answer) {
|
|
@@ -79629,7 +79696,7 @@ function recordAttempt(control, root, email2) {
|
|
|
79629
79696
|
return path3;
|
|
79630
79697
|
}
|
|
79631
79698
|
function recordId(path3, id) {
|
|
79632
|
-
const record3 = JSON.parse(
|
|
79699
|
+
const record3 = JSON.parse(readFileSync23(path3, "utf8"));
|
|
79633
79700
|
writePrivateFile(path3, JSON.stringify({ ...record3, id }) + "\n");
|
|
79634
79701
|
}
|
|
79635
79702
|
function forgetRecord(path3) {
|
|
@@ -79665,7 +79732,7 @@ async function sweepAccounts(control, root) {
|
|
|
79665
79732
|
const path3 = join28(dir, name);
|
|
79666
79733
|
let record3;
|
|
79667
79734
|
try {
|
|
79668
|
-
record3 = JSON.parse(
|
|
79735
|
+
record3 = JSON.parse(readFileSync23(path3, "utf8"));
|
|
79669
79736
|
} catch {
|
|
79670
79737
|
result.failed.push(name);
|
|
79671
79738
|
continue;
|
|
@@ -79852,14 +79919,14 @@ var init_test_target = __esm({
|
|
|
79852
79919
|
});
|
|
79853
79920
|
|
|
79854
79921
|
// dist/lib/preview-credential.js
|
|
79855
|
-
import { existsSync as existsSync23, readFileSync as
|
|
79922
|
+
import { existsSync as existsSync23, readFileSync as readFileSync24, unlinkSync as unlinkSync4 } from "node:fs";
|
|
79856
79923
|
import { join as join29 } from "node:path";
|
|
79857
79924
|
function loadPreviewCredential(projectId, previewSessionId) {
|
|
79858
79925
|
const path3 = join29(cliConfigDir(), SUBDIR, fileName(projectId, previewSessionId));
|
|
79859
79926
|
if (!existsSync23(path3))
|
|
79860
79927
|
return null;
|
|
79861
79928
|
try {
|
|
79862
|
-
const stored = JSON.parse(
|
|
79929
|
+
const stored = JSON.parse(readFileSync24(path3, "utf8"));
|
|
79863
79930
|
return stored.project_id === projectId && stored.preview_session_id === previewSessionId && typeof stored.credential === "string" ? stored.credential : null;
|
|
79864
79931
|
} catch {
|
|
79865
79932
|
return null;
|
|
@@ -79903,14 +79970,14 @@ var init_preview_credential = __esm({
|
|
|
79903
79970
|
});
|
|
79904
79971
|
|
|
79905
79972
|
// dist/lib/preview-record.js
|
|
79906
|
-
import { existsSync as existsSync24, mkdirSync as mkdirSync13, readFileSync as
|
|
79973
|
+
import { existsSync as existsSync24, mkdirSync as mkdirSync13, readFileSync as readFileSync25, rmSync as rmSync8, writeFileSync as writeFileSync16 } from "node:fs";
|
|
79907
79974
|
import { join as join30 } from "node:path";
|
|
79908
79975
|
function loadPreviewRecord(dir, projectId) {
|
|
79909
79976
|
const path3 = join30(dir, PREVIEW_RECORD);
|
|
79910
79977
|
if (!existsSync24(path3))
|
|
79911
79978
|
return null;
|
|
79912
79979
|
try {
|
|
79913
|
-
const parsed = JSON.parse(
|
|
79980
|
+
const parsed = JSON.parse(readFileSync25(path3, "utf8"));
|
|
79914
79981
|
if (parsed.project_id !== projectId || typeof parsed.preview_session_id !== "string" || typeof parsed.preview_id !== "string" || !isRecord(parsed.files))
|
|
79915
79982
|
return null;
|
|
79916
79983
|
return parsed;
|
|
@@ -80314,7 +80381,7 @@ import { createRequire as createRequire7 } from "node:module";
|
|
|
80314
80381
|
import { pathToFileURL } from "node:url";
|
|
80315
80382
|
import { join as join32, dirname as dirname9 } from "node:path";
|
|
80316
80383
|
import { spawn as spawn4, spawnSync as spawnSync3 } from "node:child_process";
|
|
80317
|
-
import { appendFileSync as appendFileSync2, existsSync as existsSync25, readFileSync as
|
|
80384
|
+
import { appendFileSync as appendFileSync2, existsSync as existsSync25, readFileSync as readFileSync26, readdirSync as readdirSync6, rmSync as rmSync9 } from "node:fs";
|
|
80318
80385
|
import { createHash as createHash6, randomUUID as randomUUID6 } from "node:crypto";
|
|
80319
80386
|
function testImportEnv(root, env) {
|
|
80320
80387
|
if (!readProjectPin(root)?.versionOnly)
|
|
@@ -80361,7 +80428,7 @@ async function prepareRunner(root) {
|
|
|
80361
80428
|
mark("browser-probe:end");
|
|
80362
80429
|
let playwright = "unknown";
|
|
80363
80430
|
try {
|
|
80364
|
-
playwright = JSON.parse(
|
|
80431
|
+
playwright = JSON.parse(readFileSync26(join32(dirname9(cli), "package.json"), "utf8")).version ?? "unknown";
|
|
80365
80432
|
} catch {
|
|
80366
80433
|
}
|
|
80367
80434
|
return { cli, channel, version: version2, browserLaunchMs, playwright };
|
|
@@ -80393,7 +80460,7 @@ async function runTests(input) {
|
|
|
80393
80460
|
const dir = join32(root, ".somewhere", "tests");
|
|
80394
80461
|
ensurePrivateDir(dir);
|
|
80395
80462
|
const ignorePath = join32(root, ".gitignore");
|
|
80396
|
-
const ignored = existsSync25(ignorePath) ?
|
|
80463
|
+
const ignored = existsSync25(ignorePath) ? readFileSync26(ignorePath, "utf8") : "";
|
|
80397
80464
|
for (const line of [".somewhere/", "playwright-report/", "test-results/"])
|
|
80398
80465
|
if (!ignored.split(/\r?\n/).includes(line))
|
|
80399
80466
|
appendFileSync2(ignorePath, `
|
|
@@ -80407,7 +80474,7 @@ ${line}
|
|
|
80407
80474
|
const artifacts = join32(dir, createHash6("sha256").update(projectId + origin + (target.environment === "preview" ? `${target.previewSessionId}:${target.releaseId}` : "")).digest("hex").slice(0, 16));
|
|
80408
80475
|
if (failed) {
|
|
80409
80476
|
const lastRun = join32(artifacts, ".last-run.json");
|
|
80410
|
-
if (!existsSync25(lastRun) || !JSON.parse(
|
|
80477
|
+
if (!existsSync25(lastRun) || !JSON.parse(readFileSync26(lastRun, "utf8")).failedTests?.length) {
|
|
80411
80478
|
throw new Error("No failed tests are recorded from the last run here; run somewhere test.");
|
|
80412
80479
|
}
|
|
80413
80480
|
}
|
|
@@ -80454,7 +80521,7 @@ ${line}
|
|
|
80454
80521
|
}, "cleanArtifacts");
|
|
80455
80522
|
cleanArtifacts(artifacts);
|
|
80456
80523
|
const exitCode = status === null ? 1 : status || (after === null || after.failed.length || after.unknownId.length ? 1 : 0);
|
|
80457
|
-
const results = existsSync25(resultsPath) ? JSON.parse(
|
|
80524
|
+
const results = existsSync25(resultsPath) ? JSON.parse(readFileSync26(resultsPath, "utf8")) : null;
|
|
80458
80525
|
return { exitCode, results, target };
|
|
80459
80526
|
}
|
|
80460
80527
|
var init_test_run = __esm({
|
|
@@ -80769,7 +80836,7 @@ var init_browser_refusal = __esm({
|
|
|
80769
80836
|
});
|
|
80770
80837
|
|
|
80771
80838
|
// dist/lib/browser-actions.js
|
|
80772
|
-
import { readFileSync as
|
|
80839
|
+
import { readFileSync as readFileSync27, statSync as statSync5 } from "node:fs";
|
|
80773
80840
|
import { basename as basename5, extname as extname4, resolve as resolve12 } from "node:path";
|
|
80774
80841
|
function decodedBase64Bytes(base642) {
|
|
80775
80842
|
if (!base642 || base642.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(base642))
|
|
@@ -80825,7 +80892,7 @@ function resolveBrowserUpload(raw, baseDir = process.cwd()) {
|
|
|
80825
80892
|
}
|
|
80826
80893
|
const name = basename5(absolute);
|
|
80827
80894
|
const contentType2 = MIME_TYPES[extname4(name).toLowerCase()] ?? "application/octet-stream";
|
|
80828
|
-
const bytes =
|
|
80895
|
+
const bytes = readFileSync27(absolute);
|
|
80829
80896
|
if (bytes.length > MAX_BROWSER_UPLOAD_BYTES) {
|
|
80830
80897
|
throw new Error(`BROWSER_UPLOAD_TOO_LARGE: Upload file is ${bytes.length} bytes; the browser upload limit is ${MAX_BROWSER_UPLOAD_BYTES} bytes (10 MB).`);
|
|
80831
80898
|
}
|
|
@@ -81981,7 +82048,7 @@ var init_verify_report = __esm({
|
|
|
81981
82048
|
|
|
81982
82049
|
// dist/commands/browser.js
|
|
81983
82050
|
import { dirname as dirname10, resolve as resolve14 } from "node:path";
|
|
81984
|
-
import { readFileSync as
|
|
82051
|
+
import { readFileSync as readFileSync28 } from "node:fs";
|
|
81985
82052
|
function readBrowserIncomplete(r) {
|
|
81986
82053
|
const raw = r.incomplete;
|
|
81987
82054
|
if (!raw || typeof raw !== "object")
|
|
@@ -82350,7 +82417,7 @@ function registerBrowser(program2) {
|
|
|
82350
82417
|
const collectActionsFile = /* @__PURE__ */ __name((file) => {
|
|
82351
82418
|
try {
|
|
82352
82419
|
const absolute = resolve14(file);
|
|
82353
|
-
const raw = JSON.parse(
|
|
82420
|
+
const raw = JSON.parse(readFileSync28(absolute, "utf8"));
|
|
82354
82421
|
const normalized = normalizeBrowserActions(raw, dirname10(absolute));
|
|
82355
82422
|
if (!normalized.ok)
|
|
82356
82423
|
throw new InvalidArgumentError(normalized.error);
|
|
@@ -82504,7 +82571,7 @@ var init_browser = __esm({
|
|
|
82504
82571
|
|
|
82505
82572
|
// dist/lib/verify-keep.js
|
|
82506
82573
|
import { createHash as createHash7, randomBytes as randomBytes5 } from "node:crypto";
|
|
82507
|
-
import { closeSync as
|
|
82574
|
+
import { closeSync as closeSync5, existsSync as existsSync27, openSync as openSync5, readFileSync as readFileSync29, rmSync as rmSync11, statSync as statSync6, writeSync } from "node:fs";
|
|
82508
82575
|
import { join as join36 } from "node:path";
|
|
82509
82576
|
function path(root) {
|
|
82510
82577
|
return join36(stateDir(root), KEEP_FILE);
|
|
@@ -82513,7 +82580,7 @@ function readFile(root) {
|
|
|
82513
82580
|
if (!existsSync27(path(root)))
|
|
82514
82581
|
return {};
|
|
82515
82582
|
try {
|
|
82516
|
-
const parsed = JSON.parse(
|
|
82583
|
+
const parsed = JSON.parse(readFileSync29(path(root), "utf-8"));
|
|
82517
82584
|
return parsed && typeof parsed === "object" ? parsed : {};
|
|
82518
82585
|
} catch {
|
|
82519
82586
|
return {};
|
|
@@ -82571,9 +82638,9 @@ function lockKeep(root, key, now2 = Date.now()) {
|
|
|
82571
82638
|
const lock = join36(stateDir(root), `verify-actors-${key}.lock`);
|
|
82572
82639
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
82573
82640
|
try {
|
|
82574
|
-
const fd =
|
|
82641
|
+
const fd = openSync5(lock, "wx", 384);
|
|
82575
82642
|
writeSync(fd, JSON.stringify({ pid: process.pid, at: now2 }));
|
|
82576
|
-
|
|
82643
|
+
closeSync5(fd);
|
|
82577
82644
|
return () => {
|
|
82578
82645
|
try {
|
|
82579
82646
|
rmSync11(lock, { force: true });
|
|
@@ -82585,7 +82652,7 @@ function lockKeep(root, key, now2 = Date.now()) {
|
|
|
82585
82652
|
throw cause;
|
|
82586
82653
|
let stale = true;
|
|
82587
82654
|
try {
|
|
82588
|
-
const held = JSON.parse(
|
|
82655
|
+
const held = JSON.parse(readFileSync29(lock, "utf-8"));
|
|
82589
82656
|
const alive2 = typeof held.pid === "number" && (() => {
|
|
82590
82657
|
try {
|
|
82591
82658
|
process.kill(held.pid, 0);
|
|
@@ -82707,7 +82774,7 @@ var init_verify_keep = __esm({
|
|
|
82707
82774
|
|
|
82708
82775
|
// dist/commands/verify.js
|
|
82709
82776
|
import { randomBytes as randomBytes6 } from "node:crypto";
|
|
82710
|
-
import { existsSync as existsSync28, readFileSync as
|
|
82777
|
+
import { existsSync as existsSync28, readFileSync as readFileSync30 } from "node:fs";
|
|
82711
82778
|
import { dirname as dirname11, resolve as resolve15 } from "node:path";
|
|
82712
82779
|
function navigationRetryNote(retries) {
|
|
82713
82780
|
if (!retries.length)
|
|
@@ -82928,7 +82995,7 @@ function normalizeVerifyFlow(raw, baseDir = process.cwd()) {
|
|
|
82928
82995
|
function readVerifyFlowFile(absolute, flag) {
|
|
82929
82996
|
let source;
|
|
82930
82997
|
try {
|
|
82931
|
-
source =
|
|
82998
|
+
source = readFileSync30(absolute, "utf8");
|
|
82932
82999
|
} catch (cause) {
|
|
82933
83000
|
if (cause instanceof Error && "code" in cause && cause.code === "ENOENT") {
|
|
82934
83001
|
throw new Error(`Flow file not found. Pass ${flag} <path> with an existing JSON file. Run \`${cliInvocation()} verify --schema\` for the flow format.`);
|
|
@@ -84527,8 +84594,8 @@ var init_verify = __esm({
|
|
|
84527
84594
|
});
|
|
84528
84595
|
|
|
84529
84596
|
// dist/commands/deploy.js
|
|
84530
|
-
import { existsSync as existsSync29, readFileSync as
|
|
84531
|
-
import { join as join37 } from "node:path";
|
|
84597
|
+
import { existsSync as existsSync29, readFileSync as readFileSync31, realpathSync as realpathSync4 } from "node:fs";
|
|
84598
|
+
import { isAbsolute as isAbsolute6, join as join37, relative as relative10, sep as sep2 } from "node:path";
|
|
84532
84599
|
import { basename as basename6, resolve as resolve16 } from "node:path";
|
|
84533
84600
|
function resolveTargetDir(dir, cwd = process.cwd()) {
|
|
84534
84601
|
return dir ? resolve16(cwd, dir) : cwd;
|
|
@@ -84886,8 +84953,29 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
84886
84953
|
error(message3);
|
|
84887
84954
|
process.exit(1);
|
|
84888
84955
|
}
|
|
84956
|
+
const refuseCredential = /* @__PURE__ */ __name((path3) => {
|
|
84957
|
+
const message3 = `Nothing was sent. ${JSON.stringify(path3)} is a CLI login or key location. Move it outside the deploy folder and try again.`;
|
|
84958
|
+
if (opts.json)
|
|
84959
|
+
printJsonError("CLI_CREDENTIAL_IN_DEPLOY", message3);
|
|
84960
|
+
else
|
|
84961
|
+
error(message3);
|
|
84962
|
+
process.exit(1);
|
|
84963
|
+
}, "refuseCredential");
|
|
84964
|
+
const configDir = cliConfigDir();
|
|
84965
|
+
if (existsSync29(configDir) && existsSync29(targetDir)) {
|
|
84966
|
+
const config2 = realpathSync4(configDir);
|
|
84967
|
+
const target = realpathSync4(targetDir);
|
|
84968
|
+
const inside = /* @__PURE__ */ __name((path3) => !isAbsolute6(path3) && path3 !== ".." && !path3.startsWith(".." + sep2), "inside");
|
|
84969
|
+
const configInTarget = relative10(target, config2);
|
|
84970
|
+
if (inside(configInTarget))
|
|
84971
|
+
refuseCredential(join37(configInTarget, "config.json"));
|
|
84972
|
+
if (inside(relative10(config2, target)))
|
|
84973
|
+
refuseCredential(join37(configDir, "config.json"));
|
|
84974
|
+
}
|
|
84889
84975
|
if (opts.listUnpublished) {
|
|
84890
|
-
const { excluded: excluded2, sensitive: sensitive2, skipped: skipped2, dotfilesLeftOut } = collectFiles(targetDir, { include: opts.include ?? [] });
|
|
84976
|
+
const { excluded: excluded2, sensitive: sensitive2, skipped: skipped2, dotfilesLeftOut, cliCredentialFiles } = collectFiles(targetDir, { include: opts.include ?? [], checkCliCredentials: true });
|
|
84977
|
+
if (cliCredentialFiles.length)
|
|
84978
|
+
refuseCredential(cliCredentialFiles.sort()[0]);
|
|
84891
84979
|
if (dotfilesLeftOut)
|
|
84892
84980
|
console.error(DOTFILE_NOTICE);
|
|
84893
84981
|
if (opts.json)
|
|
@@ -84916,9 +85004,13 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
84916
85004
|
const localScaffolds = unchangedPullScaffolds(targetDir, localBase);
|
|
84917
85005
|
const collected = collectFiles(targetDir, {
|
|
84918
85006
|
localScaffolds: new Set(Object.keys(localScaffolds)),
|
|
85007
|
+
checkCliCredentials: true,
|
|
84919
85008
|
include: opts.include ?? [],
|
|
84920
|
-
deployBlobs:
|
|
85009
|
+
deployBlobs: !opts.dryRun && opts.scope !== "functions",
|
|
85010
|
+
inlineFileLimitBytes: MAX_INLINE_DEPLOY_BYTES
|
|
84921
85011
|
});
|
|
85012
|
+
if (collected.cliCredentialFiles.length)
|
|
85013
|
+
refuseCredential(collected.cliCredentialFiles.sort()[0]);
|
|
84922
85014
|
const hashStartedAt = collected.blobs?.size && opts.timing ? performance.now() : void 0;
|
|
84923
85015
|
const publishedHashes = hashFiles(targetDir, collected.published);
|
|
84924
85016
|
const collectionEndedAt = performance.now();
|
|
@@ -84935,7 +85027,7 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
84935
85027
|
process.exit(1);
|
|
84936
85028
|
}
|
|
84937
85029
|
const tooLargeBlob = [...collected.blobs ?? []].find(([, size]) => size > MAX_DEPLOY_BLOB_BYTES);
|
|
84938
|
-
const sizeRefusal = tooLargeBlob ? `"${tooLargeBlob[0]}" exceeds the 25 MiB static file limit. Reduce its size or serve it from file storage.` : oversizeRefusal(collected);
|
|
85030
|
+
const sizeRefusal = tooLargeBlob ? `"${tooLargeBlob[0]}" exceeds the 25 MiB static file limit. Reduce its size or serve it from file storage.` : oversizeRefusal(collected, MAX_INLINE_DEPLOY_BYTES);
|
|
84939
85031
|
if (sizeRefusal) {
|
|
84940
85032
|
if (opts.json)
|
|
84941
85033
|
printJsonError("FILE_TOO_LARGE", sizeRefusal);
|
|
@@ -84965,7 +85057,7 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
84965
85057
|
process.exit(1);
|
|
84966
85058
|
}
|
|
84967
85059
|
if (collected.blobs?.size && collected.published.length > 2e4) {
|
|
84968
|
-
const message3 = "A site can contain up to 20,000 files.";
|
|
85060
|
+
const message3 = "A site can contain up to 20,000 files. Move extra assets to file storage.";
|
|
84969
85061
|
if (opts.json)
|
|
84970
85062
|
printJsonError("DEPLOY_TOO_MANY_FILES", message3);
|
|
84971
85063
|
else
|
|
@@ -85759,13 +85851,14 @@ ${dim("Build")}`);
|
|
|
85759
85851
|
process.exit(1);
|
|
85760
85852
|
}
|
|
85761
85853
|
if (err instanceof CliApiError && targetFromLink && !deployAnswered && (err.code === "PROJECT_NOT_FOUND" || err.code === "FORBIDDEN" && err.statusCode === 403)) {
|
|
85762
|
-
const
|
|
85854
|
+
const nextStep = err.linkedProjectGrantExcluded ? `${cliInvocation()} login` : newProjectCommand(dir);
|
|
85855
|
+
const message3 = err.linkedProjectGrantExcluded ? err.message : err.statusCode === 404 ? `${err.message} To publish a new project instead and update .somewhere.json, run \`${nextStep}\`.` : formatLinkedProjectAccessRefusal(!tempSession, dir);
|
|
85763
85856
|
if (opts.json) {
|
|
85764
85857
|
printJsonError(err.code, message3, {
|
|
85765
85858
|
...platformErrorEnvelope(err)?.extra ?? {},
|
|
85766
85859
|
linked_project_id: projectId,
|
|
85767
85860
|
deployed: false,
|
|
85768
|
-
next_steps: [
|
|
85861
|
+
next_steps: [nextStep]
|
|
85769
85862
|
});
|
|
85770
85863
|
} else {
|
|
85771
85864
|
error(message3, void 0, err);
|
|
@@ -85890,7 +85983,7 @@ function withLocalEnvHint(warning, dir) {
|
|
|
85890
85983
|
if (!key)
|
|
85891
85984
|
return warning;
|
|
85892
85985
|
try {
|
|
85893
|
-
const source =
|
|
85986
|
+
const source = readFileSync31(join37(dir, ".env"), "utf8");
|
|
85894
85987
|
if (new RegExp(`^\\s*(?:export\\s+)?${key}\\s*=`, "m").test(source)) {
|
|
85895
85988
|
return `${warning} Copy ${key} from your local .env file.`;
|
|
85896
85989
|
}
|
|
@@ -86406,8 +86499,8 @@ var init_deploys = __esm({
|
|
|
86406
86499
|
});
|
|
86407
86500
|
|
|
86408
86501
|
// dist/commands/pull.js
|
|
86409
|
-
import { existsSync as existsSync30, lstatSync as lstatSync5, mkdirSync as mkdirSync15, readFileSync as
|
|
86410
|
-
import { basename as basename7, dirname as dirname12, join as join38, relative as
|
|
86502
|
+
import { existsSync as existsSync30, lstatSync as lstatSync5, mkdirSync as mkdirSync15, readFileSync as readFileSync32, readdirSync as readdirSync8, rmSync as rmSync12, writeFileSync as writeFileSync19 } from "node:fs";
|
|
86503
|
+
import { basename as basename7, dirname as dirname12, join as join38, relative as relative11, resolve as resolve17 } from "node:path";
|
|
86411
86504
|
function registerPull(program2) {
|
|
86412
86505
|
program2.command("pull [project]").description(`Download a project's deployed source files to the current directory. Scaffolds a tsconfig.json + package.json (only if absent) so \`${cliInvocation()} typecheck\` can catch undefined symbols locally before you deploy. In a linked folder, plain pull is the safe update when live is newer: files you have not edited move to the live version, your local edits and local-only files (AGENTS.md, notes, tests) are kept, and it stops without writing anything if a file changed both here and live.`).option("--env <env>", "Environment to pull from (dev or prod)", "prod").option("--out <dir>", "Output directory", ".").option("--force", "Also replace files you edited here with live, and delete published files you edited that live no longer has. Never deletes a file a deploy would not upload (AGENTS.md, CLAUDE.md, README.md, tests, dotfiles, .somewhereignore matches)").option("--json", "Print the raw source response as JSON").action(async (projectArg, opts) => {
|
|
86413
86506
|
const token = getToken();
|
|
@@ -86501,7 +86594,7 @@ function registerPull(program2) {
|
|
|
86501
86594
|
}
|
|
86502
86595
|
continue;
|
|
86503
86596
|
}
|
|
86504
|
-
const local =
|
|
86597
|
+
const local = readFileSync32(target);
|
|
86505
86598
|
if (local.equals(contents))
|
|
86506
86599
|
continue;
|
|
86507
86600
|
if (opts.force || Object.hasOwn(localScaffolds, path3)) {
|
|
@@ -86570,7 +86663,7 @@ function registerPull(program2) {
|
|
|
86570
86663
|
const scaffolded = scaffoldTypecheckFiles(outDir, body.static_files);
|
|
86571
86664
|
for (const path3 of scaffolded) {
|
|
86572
86665
|
if (path3 !== SCAFFOLD_GITIGNORE_FILENAME)
|
|
86573
|
-
localScaffolds[path3] = sha2562(
|
|
86666
|
+
localScaffolds[path3] = sha2562(readFileSync32(join38(outDir, path3)));
|
|
86574
86667
|
}
|
|
86575
86668
|
for (const path3 of source.keys())
|
|
86576
86669
|
delete localScaffolds[path3];
|
|
@@ -86655,13 +86748,13 @@ function planRemovedFiles(outDir, expected, force, base = null) {
|
|
|
86655
86748
|
}
|
|
86656
86749
|
if (!entry.isFile())
|
|
86657
86750
|
continue;
|
|
86658
|
-
const relPath = normalizeRelPath(
|
|
86751
|
+
const relPath = normalizeRelPath(relative11(outDir, fullPath));
|
|
86659
86752
|
if (expected.has(relPath) || !publishable.has(relPath))
|
|
86660
86753
|
continue;
|
|
86661
86754
|
const was = base?.files[relPath];
|
|
86662
86755
|
if (base && was === void 0)
|
|
86663
86756
|
continue;
|
|
86664
|
-
const unedited = was !== void 0 && was === sha2562(
|
|
86757
|
+
const unedited = was !== void 0 && was === sha2562(readFileSync32(fullPath));
|
|
86665
86758
|
if (!force && !unedited) {
|
|
86666
86759
|
skipped.push(relPath);
|
|
86667
86760
|
continue;
|
|
@@ -87299,7 +87392,7 @@ var init_rollback = __esm({
|
|
|
87299
87392
|
|
|
87300
87393
|
// dist/commands/restore.js
|
|
87301
87394
|
function registerRestore(program2) {
|
|
87302
|
-
program2.command("restore <version>").description(`Make an earlier deployed version live again, by number (e.g. \`${cliInvocation()} restore 3\`). The platform puts that version's build back in production, with its functions; nothing is re-uploaded and this folder is not changed. Restoring by number leaves the database schema and data unchanged. \`${cliInvocation()} rollback\` is the shortcut for the previous version. Afterwards \`${cliInvocation()} pull\` brings this folder to the restored version.`).option("--project <ref>", "Project ID,
|
|
87395
|
+
program2.command("restore <version>").description(`Make an earlier deployed version live again, by number (e.g. \`${cliInvocation()} restore 3\`). The platform puts that version's build back in production, with its functions; nothing is re-uploaded and this folder is not changed. Restoring by number leaves the database schema and data unchanged. \`${cliInvocation()} rollback\` is the shortcut for the previous version. Afterwards \`${cliInvocation()} pull\` brings this folder to the restored version.`).option("--project <ref>", "Project ID, slug, or subdomain (defaults to the linked project)").option("-y, --yes", "Skip the confirmation prompt").option("--json", "Print the raw restore response as JSON").action(async (versionArg, opts) => {
|
|
87303
87396
|
const fail5 = /* @__PURE__ */ __name((code, message3) => {
|
|
87304
87397
|
if (opts.json)
|
|
87305
87398
|
printJsonError(code, message3);
|
|
@@ -87901,7 +87994,6 @@ var init_db = __esm({
|
|
|
87901
87994
|
});
|
|
87902
87995
|
|
|
87903
87996
|
// dist/commands/postgres.js
|
|
87904
|
-
import { readFileSync as readFileSync34 } from "node:fs";
|
|
87905
87997
|
function str(value) {
|
|
87906
87998
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
87907
87999
|
}
|
|
@@ -87910,7 +88002,7 @@ async function readNeonApiKey() {
|
|
|
87910
88002
|
if (fromEnv)
|
|
87911
88003
|
return fromEnv;
|
|
87912
88004
|
if (!process.stdin.isTTY) {
|
|
87913
|
-
return
|
|
88005
|
+
return (await readAllStdin()).trim();
|
|
87914
88006
|
}
|
|
87915
88007
|
const response = await (0, import_prompts8.default)({
|
|
87916
88008
|
type: "password",
|
|
@@ -88210,6 +88302,7 @@ var init_postgres = __esm({
|
|
|
88210
88302
|
"dist/commands/postgres.js"() {
|
|
88211
88303
|
"use strict";
|
|
88212
88304
|
init_cli_invocation();
|
|
88305
|
+
init_stdin();
|
|
88213
88306
|
import_prompts8 = __toESM(require_prompts3(), 1);
|
|
88214
88307
|
init_client();
|
|
88215
88308
|
init_config();
|
|
@@ -88239,18 +88332,18 @@ var init_postgres = __esm({
|
|
|
88239
88332
|
});
|
|
88240
88333
|
|
|
88241
88334
|
// dist/lib/local-docs.js
|
|
88242
|
-
import { appendFileSync as appendFileSync3, existsSync as existsSync31, lstatSync as lstatSync6, mkdirSync as mkdirSync16, mkdtempSync as mkdtempSync3, readFileSync as
|
|
88335
|
+
import { appendFileSync as appendFileSync3, existsSync as existsSync31, lstatSync as lstatSync6, mkdirSync as mkdirSync16, mkdtempSync as mkdtempSync3, readFileSync as readFileSync33, renameSync as renameSync5, rmSync as rmSync13, writeFileSync as writeFileSync21 } from "node:fs";
|
|
88243
88336
|
import { join as join40 } from "node:path";
|
|
88244
88337
|
function localDocsVersion(root = process.cwd()) {
|
|
88245
88338
|
const path3 = join40(root, FOLDER, DOCS, STAMP);
|
|
88246
88339
|
if (!existsSync31(path3))
|
|
88247
88340
|
return void 0;
|
|
88248
|
-
const stamp2 = JSON.parse(
|
|
88341
|
+
const stamp2 = JSON.parse(readFileSync33(path3, "utf8"));
|
|
88249
88342
|
return typeof stamp2.version === "string" && /^[a-f0-9]{16}$/.test(stamp2.version) ? stamp2.version : void 0;
|
|
88250
88343
|
}
|
|
88251
88344
|
function ensureGitIgnore(root) {
|
|
88252
88345
|
const path3 = join40(root, ".gitignore");
|
|
88253
|
-
const text = existsSync31(path3) ?
|
|
88346
|
+
const text = existsSync31(path3) ? readFileSync33(path3, "utf8") : "";
|
|
88254
88347
|
if (text.split(/\r?\n/).some((line) => line === ".somewhere/" || line === "/.somewhere/"))
|
|
88255
88348
|
return;
|
|
88256
88349
|
appendFileSync3(path3, `${text && !text.endsWith("\n") ? "\n" : ""}/.somewhere/
|
|
@@ -88307,7 +88400,7 @@ var init_local_docs = __esm({
|
|
|
88307
88400
|
});
|
|
88308
88401
|
|
|
88309
88402
|
// dist/lib/advisor-context.js
|
|
88310
|
-
import { readFileSync as
|
|
88403
|
+
import { readFileSync as readFileSync34, statSync as statSync7 } from "node:fs";
|
|
88311
88404
|
import { basename as basename9 } from "node:path";
|
|
88312
88405
|
function tail(value, limit) {
|
|
88313
88406
|
return value.length <= limit ? value : `\u2026${value.slice(-limit)}`;
|
|
@@ -88329,7 +88422,7 @@ function buildAdvisorContext(filePath) {
|
|
|
88329
88422
|
const stat7 = statSync7(filePath);
|
|
88330
88423
|
if (!stat7.isFile())
|
|
88331
88424
|
throw new Error("--file must name a regular file.");
|
|
88332
|
-
const content =
|
|
88425
|
+
const content = readFileSync34(filePath, "utf8");
|
|
88333
88426
|
context.file = {
|
|
88334
88427
|
path: filePath,
|
|
88335
88428
|
content: tail(redactAdvisorText(content, isDotenvPath(filePath)), FILE_LIMIT)
|
|
@@ -88355,7 +88448,7 @@ var init_advisor_context = __esm({
|
|
|
88355
88448
|
|
|
88356
88449
|
// dist/lib/advisor-runs.js
|
|
88357
88450
|
import { randomBytes as randomBytes7, randomUUID as randomUUID8 } from "node:crypto";
|
|
88358
|
-
import { chmodSync as chmodSync4, existsSync as existsSync32, mkdirSync as mkdirSync17, readFileSync as
|
|
88451
|
+
import { chmodSync as chmodSync4, existsSync as existsSync32, mkdirSync as mkdirSync17, readFileSync as readFileSync35, renameSync as renameSync6, writeFileSync as writeFileSync22 } from "node:fs";
|
|
88359
88452
|
import { join as join41 } from "node:path";
|
|
88360
88453
|
function path2(id) {
|
|
88361
88454
|
if (!/^[a-f0-9-]{36}$/i.test(id))
|
|
@@ -88392,7 +88485,7 @@ function expiredResult(record3) {
|
|
|
88392
88485
|
function load(id) {
|
|
88393
88486
|
if (!existsSync32(path2(id)))
|
|
88394
88487
|
throw Error("Advisor request was not found in this CLI configuration.");
|
|
88395
|
-
const record3 = JSON.parse(
|
|
88488
|
+
const record3 = JSON.parse(readFileSync35(path2(id), "utf8"));
|
|
88396
88489
|
prune(record3);
|
|
88397
88490
|
save(record3);
|
|
88398
88491
|
return record3;
|
|
@@ -88516,7 +88609,7 @@ var init_advisor_runs = __esm({
|
|
|
88516
88609
|
|
|
88517
88610
|
// dist/lib/advisor-app.js
|
|
88518
88611
|
import { createHash as createHash8 } from "node:crypto";
|
|
88519
|
-
import { existsSync as existsSync33, mkdirSync as mkdirSync18, readFileSync as
|
|
88612
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync18, readFileSync as readFileSync36, rmSync as rmSync14, writeFileSync as writeFileSync23 } from "node:fs";
|
|
88520
88613
|
import { join as join42 } from "node:path";
|
|
88521
88614
|
async function gatherAdvisorApp(client, ref) {
|
|
88522
88615
|
const project = await client.call("GET", `/projects/${encodeURIComponent(ref)}`);
|
|
@@ -88551,7 +88644,7 @@ async function gatherAdvisorApp(client, ref) {
|
|
|
88551
88644
|
}
|
|
88552
88645
|
function loadAdvisorTurns(dir, projectId, account, now2 = Date.now()) {
|
|
88553
88646
|
try {
|
|
88554
|
-
const saved = JSON.parse(
|
|
88647
|
+
const saved = JSON.parse(readFileSync36(join42(dir, FILE), "utf8"));
|
|
88555
88648
|
if (saved.project_id !== projectId || saved.owner !== ownerOf(account) || !Array.isArray(saved.turns))
|
|
88556
88649
|
return [];
|
|
88557
88650
|
const last = saved.turns.at(-1);
|
|
@@ -88576,7 +88669,7 @@ function ensureAdvisorStateIgnored(dir) {
|
|
|
88576
88669
|
writeFileSync23(path3, "# somewhere: local CLI state (Advisor follow-ups, test users)\n.somewhere/\n");
|
|
88577
88670
|
return;
|
|
88578
88671
|
}
|
|
88579
|
-
const text =
|
|
88672
|
+
const text = readFileSync36(path3, "utf8");
|
|
88580
88673
|
if (text.split(/\r?\n/).map((l) => l.trim()).some((l) => covered.includes(l)))
|
|
88581
88674
|
return;
|
|
88582
88675
|
writeFileSync23(path3, `${text}${text.endsWith("\n") || !text ? "" : "\n"}
|
|
@@ -90005,8 +90098,8 @@ var init_envfile_write = __esm({
|
|
|
90005
90098
|
});
|
|
90006
90099
|
|
|
90007
90100
|
// dist/commands/env.js
|
|
90008
|
-
import { existsSync as existsSync34, readFileSync as
|
|
90009
|
-
import { resolve as resolve19 } from "node:path";
|
|
90101
|
+
import { existsSync as existsSync34, mkdirSync as mkdirSync19, readFileSync as readFileSync37, writeFileSync as writeFileSync24 } from "node:fs";
|
|
90102
|
+
import { join as join43, resolve as resolve19 } from "node:path";
|
|
90010
90103
|
function resolveProjectId(explicit) {
|
|
90011
90104
|
if (explicit)
|
|
90012
90105
|
return explicit;
|
|
@@ -90017,6 +90110,17 @@ function resolveProjectId(explicit) {
|
|
|
90017
90110
|
}
|
|
90018
90111
|
return config2.project_id;
|
|
90019
90112
|
}
|
|
90113
|
+
function keepPipedValue(key, value) {
|
|
90114
|
+
try {
|
|
90115
|
+
const dir = join43(cliConfigDir(), "unsaved-values");
|
|
90116
|
+
mkdirSync19(dir, { recursive: true, mode: 448 });
|
|
90117
|
+
const file = join43(dir, `${key.replace(/[^A-Za-z0-9_.-]/g, "_")}-${Date.now()}.txt`);
|
|
90118
|
+
writeFileSync24(file, value, { mode: 384, flag: "wx" });
|
|
90119
|
+
return `The value was not set. It is kept in ${file} (readable only by you). After fixing the cause, run: ${cliInvocation()} env set ${key} --stdin < "${file}", then delete the file.`;
|
|
90120
|
+
} catch (err) {
|
|
90121
|
+
return `The value was not set and could not be kept on disk (${err instanceof Error ? err.message : String(err)}); copy it from its source again before it is gone.`;
|
|
90122
|
+
}
|
|
90123
|
+
}
|
|
90020
90124
|
function reportEnvError(err, json) {
|
|
90021
90125
|
const platform2 = platformErrorEnvelope(err);
|
|
90022
90126
|
if (platform2?.code === "TEMP_ACCOUNT_RESTRICTED") {
|
|
@@ -90087,7 +90191,7 @@ function registerEnv(program2) {
|
|
|
90087
90191
|
process.exit(1);
|
|
90088
90192
|
}
|
|
90089
90193
|
if (existsSync34(outPath) && !opts.force) {
|
|
90090
|
-
const existing =
|
|
90194
|
+
const existing = readFileSync37(outPath, "utf-8");
|
|
90091
90195
|
const hasValues = existing.split("\n").some((l) => /^[^#=]+=.+/.test(l.trim()));
|
|
90092
90196
|
const { ok } = await (0, import_prompts9.default)({
|
|
90093
90197
|
type: "confirm",
|
|
@@ -90124,25 +90228,25 @@ function registerEnv(program2) {
|
|
|
90124
90228
|
error("Pipe a value into --stdin.");
|
|
90125
90229
|
process.exit(1);
|
|
90126
90230
|
}
|
|
90127
|
-
|
|
90128
|
-
|
|
90129
|
-
|
|
90130
|
-
|
|
90131
|
-
|
|
90132
|
-
error("--provider must be at most 64 characters.");
|
|
90133
|
-
process.exit(1);
|
|
90134
|
-
}
|
|
90135
|
-
if (opts.purpose && opts.purpose.length > 240) {
|
|
90136
|
-
error("--purpose must be at most 240 characters.");
|
|
90231
|
+
const value = opts.stdin ? (await readAllStdin()).replace(/\r?\n$/, "") : positionalValue;
|
|
90232
|
+
const stop = /* @__PURE__ */ __name((message3) => {
|
|
90233
|
+
error(message3);
|
|
90234
|
+
if (opts.stdin)
|
|
90235
|
+
process.stderr.write(keepPipedValue(key, value) + "\n");
|
|
90137
90236
|
process.exit(1);
|
|
90138
|
-
}
|
|
90237
|
+
}, "stop");
|
|
90238
|
+
if (opts.scope && !["all", "dev", "prod"].includes(opts.scope))
|
|
90239
|
+
stop("--scope must be all, dev, or prod.");
|
|
90240
|
+
if (opts.provider && opts.provider.length > 64)
|
|
90241
|
+
stop("--provider must be at most 64 characters.");
|
|
90242
|
+
if (opts.purpose && opts.purpose.length > 240)
|
|
90243
|
+
stop("--purpose must be at most 240 characters.");
|
|
90139
90244
|
const inputNote = opts.stdin ? null : `A value passed as an argument can be seen in your shell history and the process list. To keep it out, pipe it in: printf %s "$VALUE" | ${cliInvocation()} env set ${key} --stdin`;
|
|
90140
90245
|
if (inputNote && !opts.json)
|
|
90141
90246
|
process.stderr.write(`Note: ${inputNote}
|
|
90142
90247
|
`);
|
|
90143
|
-
const value = opts.stdin ? readFileSync39(0, "utf8").replace(/\r?\n$/, "") : positionalValue;
|
|
90144
90248
|
const client = new ApiClient(getToken());
|
|
90145
|
-
const pid =
|
|
90249
|
+
const pid = opts.project ?? loadProjectConfig()?.project_id ?? stop("No project. Pass --project or run from a linked directory." + unlinkedFolderHint());
|
|
90146
90250
|
try {
|
|
90147
90251
|
const result = await client.call("POST", "/env", {
|
|
90148
90252
|
project_id: pid,
|
|
@@ -90173,6 +90277,8 @@ function registerEnv(program2) {
|
|
|
90173
90277
|
warn(w2);
|
|
90174
90278
|
} catch (err) {
|
|
90175
90279
|
reportEnvError(err, Boolean(opts.json));
|
|
90280
|
+
if (opts.stdin)
|
|
90281
|
+
process.stderr.write(keepPipedValue(key, value) + "\n");
|
|
90176
90282
|
process.exit(1);
|
|
90177
90283
|
}
|
|
90178
90284
|
});
|
|
@@ -90200,18 +90306,20 @@ var init_env = __esm({
|
|
|
90200
90306
|
import_prompts9 = __toESM(require_prompts3(), 1);
|
|
90201
90307
|
init_client();
|
|
90202
90308
|
init_config();
|
|
90309
|
+
init_stdin();
|
|
90203
90310
|
init_envfile_write();
|
|
90204
90311
|
init_output();
|
|
90205
90312
|
init_link_hint();
|
|
90206
90313
|
__name(resolveProjectId, "resolveProjectId");
|
|
90314
|
+
__name(keepPipedValue, "keepPipedValue");
|
|
90207
90315
|
__name(reportEnvError, "reportEnvError");
|
|
90208
90316
|
__name(registerEnv, "registerEnv");
|
|
90209
90317
|
}
|
|
90210
90318
|
});
|
|
90211
90319
|
|
|
90212
90320
|
// dist/commands/run.js
|
|
90213
|
-
import { existsSync as existsSync35, readFileSync as
|
|
90214
|
-
import { isAbsolute as
|
|
90321
|
+
import { existsSync as existsSync35, readFileSync as readFileSync38 } from "node:fs";
|
|
90322
|
+
import { isAbsolute as isAbsolute7, resolve as resolve20 } from "node:path";
|
|
90215
90323
|
import { createRequire as createRequire8 } from "node:module";
|
|
90216
90324
|
function parseArgs(values) {
|
|
90217
90325
|
if (!values.length)
|
|
@@ -90245,14 +90353,14 @@ function hasRelativeRuntimeImport(fileName2, code) {
|
|
|
90245
90353
|
return false;
|
|
90246
90354
|
}
|
|
90247
90355
|
const source = ts2.createSourceFile(fileName2, code, ts2.ScriptTarget.Latest, true);
|
|
90248
|
-
const
|
|
90356
|
+
const relative16 = /* @__PURE__ */ __name((node2) => node2 !== void 0 && ts2.isStringLiteralLike(node2) && /^\.\.?\//.test(node2.text), "relative");
|
|
90249
90357
|
const scan = /* @__PURE__ */ __name((node2) => {
|
|
90250
90358
|
if (ts2.isImportDeclaration(node2))
|
|
90251
|
-
return !node2.importClause?.isTypeOnly &&
|
|
90359
|
+
return !node2.importClause?.isTypeOnly && relative16(node2.moduleSpecifier);
|
|
90252
90360
|
if (ts2.isExportDeclaration(node2))
|
|
90253
|
-
return !node2.isTypeOnly &&
|
|
90361
|
+
return !node2.isTypeOnly && relative16(node2.moduleSpecifier);
|
|
90254
90362
|
if (ts2.isCallExpression(node2) && node2.expression.kind === ts2.SyntaxKind.ImportKeyword) {
|
|
90255
|
-
return
|
|
90363
|
+
return relative16(node2.arguments[0]);
|
|
90256
90364
|
}
|
|
90257
90365
|
return ts2.forEachChild(node2, (child) => scan(child) || void 0) === true;
|
|
90258
90366
|
}, "scan");
|
|
@@ -90276,12 +90384,12 @@ function registerRun(program2) {
|
|
|
90276
90384
|
}
|
|
90277
90385
|
projectId = config2.project_id;
|
|
90278
90386
|
}
|
|
90279
|
-
const absPath =
|
|
90387
|
+
const absPath = isAbsolute7(script) ? script : resolve20(process.cwd(), script);
|
|
90280
90388
|
if (!existsSync35(absPath)) {
|
|
90281
90389
|
error(`File not found: ${script}`);
|
|
90282
90390
|
process.exit(1);
|
|
90283
90391
|
}
|
|
90284
|
-
const code =
|
|
90392
|
+
const code = readFileSync38(absPath, "utf-8");
|
|
90285
90393
|
if (!code.trim()) {
|
|
90286
90394
|
error(`${script} is empty \u2014 nothing to run.`);
|
|
90287
90395
|
process.exit(1);
|
|
@@ -90717,9 +90825,9 @@ var init_claim = __esm({
|
|
|
90717
90825
|
|
|
90718
90826
|
// dist/lib/frontend-dev.js
|
|
90719
90827
|
import { createRequire as createRequire9 } from "node:module";
|
|
90720
|
-
import { realpathSync as
|
|
90828
|
+
import { realpathSync as realpathSync5 } from "node:fs";
|
|
90721
90829
|
import { createConnection, createServer as createNetServer } from "node:net";
|
|
90722
|
-
import { join as
|
|
90830
|
+
import { join as join44 } from "node:path";
|
|
90723
90831
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
90724
90832
|
function deployedOrigin(value) {
|
|
90725
90833
|
const url3 = new URL(value);
|
|
@@ -90811,13 +90919,13 @@ async function relayIpv6Loopback(port) {
|
|
|
90811
90919
|
async function startFrontendDev(cwd, target, port = 8787, open4 = false) {
|
|
90812
90920
|
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
90813
90921
|
throw new Error("Port must be an integer from 1 through 65535.");
|
|
90814
|
-
cwd =
|
|
90922
|
+
cwd = realpathSync5(cwd);
|
|
90815
90923
|
const origin = deployedOrigin(target);
|
|
90816
90924
|
if (missingProjectDependencies(cwd).length)
|
|
90817
90925
|
throw new Error(INSTALL_PROJECT_DEPENDENCIES);
|
|
90818
90926
|
let vitePath;
|
|
90819
90927
|
try {
|
|
90820
|
-
vitePath = createRequire9(
|
|
90928
|
+
vitePath = createRequire9(join44(cwd, "package.json")).resolve("vite");
|
|
90821
90929
|
} catch {
|
|
90822
90930
|
if (readProjectPin(cwd)?.versionOnly) {
|
|
90823
90931
|
throw new Error("Install the local frontend tools: npm install -D --save-exact vite@7.2.2");
|
|
@@ -90961,7 +91069,7 @@ var init_preview_jobs = __esm({
|
|
|
90961
91069
|
// dist/commands/dev.js
|
|
90962
91070
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
90963
91071
|
import { existsSync as existsSync36 } from "node:fs";
|
|
90964
|
-
import { join as
|
|
91072
|
+
import { join as join45, relative as relative12 } from "node:path";
|
|
90965
91073
|
function previewFinishedReason(err) {
|
|
90966
91074
|
if (!(err instanceof CliApiError) || err.code !== "DRAFT_SESSION_TERMINAL")
|
|
90967
91075
|
return null;
|
|
@@ -91799,7 +91907,7 @@ async function runHotDeploy(opts) {
|
|
|
91799
91907
|
const watcher = esm_default.watch(cwd, {
|
|
91800
91908
|
ignoreInitial: true,
|
|
91801
91909
|
ignored: /* @__PURE__ */ __name((p2) => {
|
|
91802
|
-
const rel =
|
|
91910
|
+
const rel = relative12(cwd, p2);
|
|
91803
91911
|
if (!rel || rel.startsWith(".."))
|
|
91804
91912
|
return false;
|
|
91805
91913
|
const segments = rel.split(/[\\/]/);
|
|
@@ -91874,7 +91982,7 @@ async function runHotDeploy(opts) {
|
|
|
91874
91982
|
}
|
|
91875
91983
|
}, "flush");
|
|
91876
91984
|
const onChange = /* @__PURE__ */ __name((abs) => {
|
|
91877
|
-
const rel =
|
|
91985
|
+
const rel = relative12(cwd, abs);
|
|
91878
91986
|
if (!WATCH_EXTS.test(rel))
|
|
91879
91987
|
return;
|
|
91880
91988
|
pendingChanged.add(rel);
|
|
@@ -91882,7 +91990,7 @@ async function runHotDeploy(opts) {
|
|
|
91882
91990
|
schedule();
|
|
91883
91991
|
}, "onChange");
|
|
91884
91992
|
const onUnlink = /* @__PURE__ */ __name((abs) => {
|
|
91885
|
-
const rel =
|
|
91993
|
+
const rel = relative12(cwd, abs);
|
|
91886
91994
|
if (!WATCH_EXTS.test(rel))
|
|
91887
91995
|
return;
|
|
91888
91996
|
pendingDeleted.add(rel);
|
|
@@ -91949,7 +92057,7 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
|
|
|
91949
92057
|
const updateBinary = {};
|
|
91950
92058
|
const deleteKeys = [];
|
|
91951
92059
|
for (const rel of changed) {
|
|
91952
|
-
const abs =
|
|
92060
|
+
const abs = join45(cwd, rel);
|
|
91953
92061
|
if (!existsSync36(abs))
|
|
91954
92062
|
continue;
|
|
91955
92063
|
classifyInto({ files: updateFiles, functions: updateFunctions, binaryFiles: updateBinary }, cwd, rel);
|
|
@@ -92015,7 +92123,7 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
|
|
|
92015
92123
|
for (const rel of deleted)
|
|
92016
92124
|
delete nextFiles[rel];
|
|
92017
92125
|
for (const rel of changed)
|
|
92018
|
-
if (existsSync36(
|
|
92126
|
+
if (existsSync36(join45(cwd, rel)))
|
|
92019
92127
|
Object.assign(nextFiles, hashFiles(cwd, [rel]));
|
|
92020
92128
|
savePreviewRecord(cwd, { ...record3, preview_id: nextCandidate, files: nextFiles });
|
|
92021
92129
|
}
|
|
@@ -92211,7 +92319,7 @@ var init_dev = __esm({
|
|
|
92211
92319
|
|
|
92212
92320
|
// dist/commands/check.js
|
|
92213
92321
|
import { existsSync as existsSync37 } from "node:fs";
|
|
92214
|
-
import { join as
|
|
92322
|
+
import { join as join46, resolve as resolve21 } from "node:path";
|
|
92215
92323
|
function buildCheckBody(collected, projectId) {
|
|
92216
92324
|
const body = { project_id: projectId, files: collected.files };
|
|
92217
92325
|
if (Object.keys(collected.functions).length > 0)
|
|
@@ -92316,7 +92424,7 @@ async function runLocalPreflight(targetDir, collected, typecheck = async (dir) =
|
|
|
92316
92424
|
if (collected.excluded.length)
|
|
92317
92425
|
source.not_published = collected.excluded;
|
|
92318
92426
|
let typecheckStep;
|
|
92319
|
-
if (!existsSync37(
|
|
92427
|
+
if (!existsSync37(join46(targetDir, "tsconfig.json"))) {
|
|
92320
92428
|
typecheckStep = { name: "typecheck", status: "skipped", reason: MISSING_TSCONFIG_GUIDANCE };
|
|
92321
92429
|
} else if (missingProjectDependencies(targetDir).length) {
|
|
92322
92430
|
typecheckStep = { name: "typecheck", status: "skipped", reason: missingTypecheckDependenciesMessage() };
|
|
@@ -92733,7 +92841,7 @@ var init_api2 = __esm({
|
|
|
92733
92841
|
import { createReadStream as createReadStream3, createWriteStream as createWriteStream3 } from "node:fs";
|
|
92734
92842
|
import { stat as stat6, rename as rename2, unlink as unlink2 } from "node:fs/promises";
|
|
92735
92843
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
92736
|
-
import { basename as basename10, dirname as dirname14, extname as extname6, join as
|
|
92844
|
+
import { basename as basename10, dirname as dirname14, extname as extname6, join as join47, resolve as resolve23 } from "node:path";
|
|
92737
92845
|
import { pipeline as pipeline3 } from "node:stream/promises";
|
|
92738
92846
|
function registerFs(program2) {
|
|
92739
92847
|
const fs2 = program2.command("fs").description("Manage project file storage");
|
|
@@ -92777,7 +92885,7 @@ function registerFs(program2) {
|
|
|
92777
92885
|
if (!response.body)
|
|
92778
92886
|
throw new Error("The server returned an empty file response.");
|
|
92779
92887
|
const destination = resolve23(local);
|
|
92780
|
-
tempPath =
|
|
92888
|
+
tempPath = join47(dirname14(destination), `.${basename10(destination)}.${randomUUID10()}.tmp`);
|
|
92781
92889
|
await pipeline3(response.body, createWriteStream3(tempPath, { flags: "wx" }));
|
|
92782
92890
|
await rename2(tempPath, destination);
|
|
92783
92891
|
tempPath = void 0;
|
|
@@ -108651,7 +108759,7 @@ var require_lib5 = __commonJS({
|
|
|
108651
108759
|
return `${this.algorithm}-${this.digest}${getOptString(this.options)}`;
|
|
108652
108760
|
}
|
|
108653
108761
|
};
|
|
108654
|
-
function integrityHashToString(toString,
|
|
108762
|
+
function integrityHashToString(toString, sep3, opts, hashes) {
|
|
108655
108763
|
const toStringIsNotEmpty = toString !== "";
|
|
108656
108764
|
let shouldAddFirstSep = false;
|
|
108657
108765
|
let complement = "";
|
|
@@ -108661,7 +108769,7 @@ var require_lib5 = __commonJS({
|
|
|
108661
108769
|
if (hashString) {
|
|
108662
108770
|
shouldAddFirstSep = true;
|
|
108663
108771
|
complement += hashString;
|
|
108664
|
-
complement +=
|
|
108772
|
+
complement += sep3;
|
|
108665
108773
|
}
|
|
108666
108774
|
}
|
|
108667
108775
|
const finalHashString = Hash.prototype.toString.call(hashes[lastIndex], opts);
|
|
@@ -108670,7 +108778,7 @@ var require_lib5 = __commonJS({
|
|
|
108670
108778
|
complement += finalHashString;
|
|
108671
108779
|
}
|
|
108672
108780
|
if (toStringIsNotEmpty && shouldAddFirstSep) {
|
|
108673
|
-
return toString +
|
|
108781
|
+
return toString + sep3 + complement;
|
|
108674
108782
|
}
|
|
108675
108783
|
return toString + complement;
|
|
108676
108784
|
}
|
|
@@ -108689,18 +108797,18 @@ var require_lib5 = __commonJS({
|
|
|
108689
108797
|
return Object.keys(this).length === 0;
|
|
108690
108798
|
}
|
|
108691
108799
|
toString(opts) {
|
|
108692
|
-
let
|
|
108800
|
+
let sep3 = opts?.sep || " ";
|
|
108693
108801
|
let toString = "";
|
|
108694
108802
|
if (opts?.strict) {
|
|
108695
|
-
|
|
108803
|
+
sep3 = sep3.replace(/\S+/g, " ");
|
|
108696
108804
|
for (const hash of SPEC_ALGORITHMS) {
|
|
108697
108805
|
if (this[hash]) {
|
|
108698
|
-
toString = integrityHashToString(toString,
|
|
108806
|
+
toString = integrityHashToString(toString, sep3, opts, this[hash]);
|
|
108699
108807
|
}
|
|
108700
108808
|
}
|
|
108701
108809
|
} else {
|
|
108702
108810
|
for (const hash of Object.keys(this)) {
|
|
108703
|
-
toString = integrityHashToString(toString,
|
|
108811
|
+
toString = integrityHashToString(toString, sep3, opts, this[hash]);
|
|
108704
108812
|
}
|
|
108705
108813
|
}
|
|
108706
108814
|
return toString;
|
|
@@ -110586,11 +110694,11 @@ var require_polyfill = __commonJS({
|
|
|
110586
110694
|
} = __require("fs/promises");
|
|
110587
110695
|
var {
|
|
110588
110696
|
dirname: dirname18,
|
|
110589
|
-
isAbsolute:
|
|
110590
|
-
join:
|
|
110697
|
+
isAbsolute: isAbsolute8,
|
|
110698
|
+
join: join58,
|
|
110591
110699
|
parse: parse3,
|
|
110592
110700
|
resolve: resolve27,
|
|
110593
|
-
sep:
|
|
110701
|
+
sep: sep3,
|
|
110594
110702
|
toNamespacedPath
|
|
110595
110703
|
} = __require("path");
|
|
110596
110704
|
var { fileURLToPath: fileURLToPath2 } = __require("url");
|
|
@@ -110732,7 +110840,7 @@ var require_polyfill = __commonJS({
|
|
|
110732
110840
|
return checkParentPaths(src, srcStat, destParent);
|
|
110733
110841
|
}
|
|
110734
110842
|
__name(checkParentPaths, "checkParentPaths");
|
|
110735
|
-
var normalizePathToArray = /* @__PURE__ */ __name((path3) => resolve27(path3).split(
|
|
110843
|
+
var normalizePathToArray = /* @__PURE__ */ __name((path3) => resolve27(path3).split(sep3).filter(Boolean), "normalizePathToArray");
|
|
110736
110844
|
function isSrcSubdir(src, dest) {
|
|
110737
110845
|
const srcArr = normalizePathToArray(src);
|
|
110738
110846
|
const destArr = normalizePathToArray(dest);
|
|
@@ -110868,8 +110976,8 @@ var require_polyfill = __commonJS({
|
|
|
110868
110976
|
const dir = await readdir3(src);
|
|
110869
110977
|
for (let i = 0; i < dir.length; i++) {
|
|
110870
110978
|
const item = dir[i];
|
|
110871
|
-
const srcItem =
|
|
110872
|
-
const destItem =
|
|
110979
|
+
const srcItem = join58(src, item);
|
|
110980
|
+
const destItem = join58(dest, item);
|
|
110873
110981
|
const { destStat } = await checkPaths(srcItem, destItem, opts);
|
|
110874
110982
|
await startCopy(destStat, srcItem, destItem, opts);
|
|
110875
110983
|
}
|
|
@@ -110877,7 +110985,7 @@ var require_polyfill = __commonJS({
|
|
|
110877
110985
|
__name(copyDir, "copyDir");
|
|
110878
110986
|
async function onLink(destStat, src, dest) {
|
|
110879
110987
|
let resolvedSrc = await readlink(src);
|
|
110880
|
-
if (!
|
|
110988
|
+
if (!isAbsolute8(resolvedSrc)) {
|
|
110881
110989
|
resolvedSrc = resolve27(dirname18(src), resolvedSrc);
|
|
110882
110990
|
}
|
|
110883
110991
|
if (!destStat) {
|
|
@@ -110892,7 +111000,7 @@ var require_polyfill = __commonJS({
|
|
|
110892
111000
|
}
|
|
110893
111001
|
throw err;
|
|
110894
111002
|
}
|
|
110895
|
-
if (!
|
|
111003
|
+
if (!isAbsolute8(resolvedDest)) {
|
|
110896
111004
|
resolvedDest = resolve27(dirname18(dest), resolvedDest);
|
|
110897
111005
|
}
|
|
110898
111006
|
if (isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
@@ -110945,7 +111053,7 @@ var require_cp = __commonJS({
|
|
|
110945
111053
|
// node_modules/@npmcli/fs/lib/with-temp-dir.js
|
|
110946
111054
|
var require_with_temp_dir = __commonJS({
|
|
110947
111055
|
"node_modules/@npmcli/fs/lib/with-temp-dir.js"(exports, module) {
|
|
110948
|
-
var { join:
|
|
111056
|
+
var { join: join58, sep: sep3 } = __require("path");
|
|
110949
111057
|
var getOptions = require_get_options();
|
|
110950
111058
|
var { mkdir, mkdtemp, rm } = __require("fs/promises");
|
|
110951
111059
|
var withTempDir = /* @__PURE__ */ __name(async (root, fn, opts) => {
|
|
@@ -110953,7 +111061,7 @@ var require_with_temp_dir = __commonJS({
|
|
|
110953
111061
|
copy: ["tmpPrefix"]
|
|
110954
111062
|
});
|
|
110955
111063
|
await mkdir(root, { recursive: true });
|
|
110956
|
-
const target = await mkdtemp(
|
|
111064
|
+
const target = await mkdtemp(join58(`${root}${sep3}`, options2.tmpPrefix || ""));
|
|
110957
111065
|
let err;
|
|
110958
111066
|
let result;
|
|
110959
111067
|
try {
|
|
@@ -110978,13 +111086,13 @@ var require_with_temp_dir = __commonJS({
|
|
|
110978
111086
|
var require_readdir_scoped = __commonJS({
|
|
110979
111087
|
"node_modules/@npmcli/fs/lib/readdir-scoped.js"(exports, module) {
|
|
110980
111088
|
var { readdir: readdir3 } = __require("fs/promises");
|
|
110981
|
-
var { join:
|
|
111089
|
+
var { join: join58 } = __require("path");
|
|
110982
111090
|
var readdirScoped = /* @__PURE__ */ __name(async (dir) => {
|
|
110983
111091
|
const results = [];
|
|
110984
111092
|
for (const item of await readdir3(dir)) {
|
|
110985
111093
|
if (item.startsWith("@")) {
|
|
110986
|
-
for (const scopedItem of await readdir3(
|
|
110987
|
-
results.push(
|
|
111094
|
+
for (const scopedItem of await readdir3(join58(dir, item))) {
|
|
111095
|
+
results.push(join58(item, scopedItem));
|
|
110988
111096
|
}
|
|
110989
111097
|
} else {
|
|
110990
111098
|
results.push(item);
|
|
@@ -110999,7 +111107,7 @@ var require_readdir_scoped = __commonJS({
|
|
|
110999
111107
|
// node_modules/@npmcli/fs/lib/move-file.js
|
|
111000
111108
|
var require_move_file = __commonJS({
|
|
111001
111109
|
"node_modules/@npmcli/fs/lib/move-file.js"(exports, module) {
|
|
111002
|
-
var { dirname: dirname18, join:
|
|
111110
|
+
var { dirname: dirname18, join: join58, resolve: resolve27, relative: relative16, isAbsolute: isAbsolute8 } = __require("path");
|
|
111003
111111
|
var fs2 = __require("fs/promises");
|
|
111004
111112
|
var pathExists = /* @__PURE__ */ __name(async (path3) => {
|
|
111005
111113
|
try {
|
|
@@ -111029,7 +111137,7 @@ var require_move_file = __commonJS({
|
|
|
111029
111137
|
if (sourceStat.isDirectory()) {
|
|
111030
111138
|
const files = await fs2.readdir(source);
|
|
111031
111139
|
await Promise.all(files.map(
|
|
111032
|
-
(file) => moveFile(
|
|
111140
|
+
(file) => moveFile(join58(source, file), join58(destination, file), options2, false, symlinks)
|
|
111033
111141
|
));
|
|
111034
111142
|
} else if (sourceStat.isSymbolicLink()) {
|
|
111035
111143
|
symlinks.push({ source, destination });
|
|
@@ -111043,8 +111151,8 @@ var require_move_file = __commonJS({
|
|
|
111043
111151
|
if (root) {
|
|
111044
111152
|
await Promise.all(symlinks.map(async ({ source: symSource, destination: symDestination }) => {
|
|
111045
111153
|
let target = await fs2.readlink(symSource);
|
|
111046
|
-
if (
|
|
111047
|
-
target = resolve27(symDestination,
|
|
111154
|
+
if (isAbsolute8(target)) {
|
|
111155
|
+
target = resolve27(symDestination, relative16(symSource, target));
|
|
111048
111156
|
}
|
|
111049
111157
|
let targetStat = "file";
|
|
111050
111158
|
try {
|
|
@@ -130397,12 +130505,12 @@ var require_url = __commonJS({
|
|
|
130397
130505
|
"node_modules/tuf-js/dist/utils/url.js"(exports) {
|
|
130398
130506
|
"use strict";
|
|
130399
130507
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
130400
|
-
exports.join =
|
|
130508
|
+
exports.join = join58;
|
|
130401
130509
|
var url_1 = __require("url");
|
|
130402
|
-
function
|
|
130510
|
+
function join58(base, path3) {
|
|
130403
130511
|
return new url_1.URL(ensureTrailingSlash(base) + removeLeadingSlash(path3)).toString();
|
|
130404
130512
|
}
|
|
130405
|
-
__name(
|
|
130513
|
+
__name(join58, "join");
|
|
130406
130514
|
function ensureTrailingSlash(path3) {
|
|
130407
130515
|
return path3.endsWith("/") ? path3 : path3 + "/";
|
|
130408
130516
|
}
|
|
@@ -132738,8 +132846,8 @@ var require_dist15 = __commonJS({
|
|
|
132738
132846
|
|
|
132739
132847
|
// dist/lib/update-security.js
|
|
132740
132848
|
import { createHash as createHash9, timingSafeEqual } from "node:crypto";
|
|
132741
|
-
import { mkdirSync as
|
|
132742
|
-
import { join as
|
|
132849
|
+
import { mkdirSync as mkdirSync20, readFileSync as readFileSync39, statSync as statSync8 } from "node:fs";
|
|
132850
|
+
import { join as join48 } from "node:path";
|
|
132743
132851
|
import { Readable as Readable3 } from "node:stream";
|
|
132744
132852
|
import { pipeline as pipeline4 } from "node:stream/promises";
|
|
132745
132853
|
function expectedTarballUrl(version2) {
|
|
@@ -133087,7 +133195,7 @@ async function extractArtifactSnapshot(artifact, extractionDir, filter) {
|
|
|
133087
133195
|
await pipeline4(Readable3.from([artifact]), So({ cwd: extractionDir, strip: 1, strict: true, filter }));
|
|
133088
133196
|
}
|
|
133089
133197
|
async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
133090
|
-
|
|
133198
|
+
mkdirSync20(extractionDir, { recursive: true, mode: 448 });
|
|
133091
133199
|
const allowed = /* @__PURE__ */ new Map([
|
|
133092
133200
|
["package/package.json", MAX_MANIFEST_BYTES],
|
|
133093
133201
|
["package/npm-shrinkwrap.json", MAX_LOCKFILE_BYTES]
|
|
@@ -133104,15 +133212,15 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
|
133104
133212
|
seen2.add(path3);
|
|
133105
133213
|
return true;
|
|
133106
133214
|
});
|
|
133107
|
-
const manifestPath =
|
|
133108
|
-
const lockPath =
|
|
133215
|
+
const manifestPath = join48(extractionDir, "package.json");
|
|
133216
|
+
const lockPath = join48(extractionDir, "npm-shrinkwrap.json");
|
|
133109
133217
|
let manifest;
|
|
133110
133218
|
let lock;
|
|
133111
133219
|
try {
|
|
133112
133220
|
if (statSync8(lockPath).size > MAX_LOCKFILE_BYTES)
|
|
133113
133221
|
throw new Error("lockfile too large");
|
|
133114
|
-
manifest = JSON.parse(
|
|
133115
|
-
lock = JSON.parse(
|
|
133222
|
+
manifest = JSON.parse(readFileSync39(manifestPath, "utf8"));
|
|
133223
|
+
lock = JSON.parse(readFileSync39(lockPath, "utf8"));
|
|
133116
133224
|
} catch (cause) {
|
|
133117
133225
|
throw new Error(`the verified artifact has no readable npm-shrinkwrap dependency lock: ${message(cause)}`);
|
|
133118
133226
|
}
|
|
@@ -133149,8 +133257,8 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
|
133149
133257
|
}
|
|
133150
133258
|
let bundledManifest;
|
|
133151
133259
|
try {
|
|
133152
|
-
const bundledPath =
|
|
133153
|
-
bundledManifest = JSON.parse(
|
|
133260
|
+
const bundledPath = join48(extractionDir, ...lockPath2.split("/"), "package.json");
|
|
133261
|
+
bundledManifest = JSON.parse(readFileSync39(bundledPath, "utf8"));
|
|
133154
133262
|
} catch (cause) {
|
|
133155
133263
|
throw new Error(`the verified artifact has an unreadable bundled dependency ${lockPath2}: ${message(cause)}`);
|
|
133156
133264
|
}
|
|
@@ -133220,10 +133328,10 @@ ${GITHUB_REPOSITORY_ID}`,
|
|
|
133220
133328
|
// dist/commands/update.js
|
|
133221
133329
|
import { spawn as spawn6 } from "node:child_process";
|
|
133222
133330
|
import { randomBytes as randomBytes8 } from "node:crypto";
|
|
133223
|
-
import { closeSync as
|
|
133331
|
+
import { closeSync as closeSync6, constants as constants2, fstatSync, mkdtempSync as mkdtempSync4, openSync as openSync6, readFileSync as readFileSync40, readSync as readSync2, rmSync as rmSync15, unlinkSync as unlinkSync5, writeFileSync as writeFileSync25 } from "node:fs";
|
|
133224
133332
|
import { createServer } from "node:http";
|
|
133225
133333
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
133226
|
-
import { join as
|
|
133334
|
+
import { join as join49 } from "node:path";
|
|
133227
133335
|
function refuse2(cause) {
|
|
133228
133336
|
error(`Update refused: ${message2(cause)}.`);
|
|
133229
133337
|
info(`To install the latest release with npm instead, run: ${teal(NPM_UPDATE_COMMAND)}`);
|
|
@@ -133231,7 +133339,7 @@ function refuse2(cause) {
|
|
|
133231
133339
|
}
|
|
133232
133340
|
function currentVersion2() {
|
|
133233
133341
|
try {
|
|
133234
|
-
const pkg = JSON.parse(
|
|
133342
|
+
const pkg = JSON.parse(readFileSync40(join49(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
133235
133343
|
return pkg.version;
|
|
133236
133344
|
} catch {
|
|
133237
133345
|
return "0.0.0";
|
|
@@ -133295,7 +133403,7 @@ async function runPinnedNpm(args, cwd, ambientEnvironment, userConfigPath, globa
|
|
|
133295
133403
|
});
|
|
133296
133404
|
}
|
|
133297
133405
|
function snapshotAuthenticatedArtifact(tarballPath) {
|
|
133298
|
-
const fd =
|
|
133406
|
+
const fd = openSync6(tarballPath, constants2.O_RDONLY | (constants2.O_NOFOLLOW ?? 0));
|
|
133299
133407
|
try {
|
|
133300
133408
|
const stat7 = fstatSync(fd);
|
|
133301
133409
|
if (!stat7.isFile() || stat7.size <= 0 || stat7.size > MAX_UPDATE_BYTES) {
|
|
@@ -133304,14 +133412,14 @@ function snapshotAuthenticatedArtifact(tarballPath) {
|
|
|
133304
133412
|
unlinkSync5(tarballPath);
|
|
133305
133413
|
return readOpenArtifact(fd, stat7.size);
|
|
133306
133414
|
} finally {
|
|
133307
|
-
|
|
133415
|
+
closeSync6(fd);
|
|
133308
133416
|
}
|
|
133309
133417
|
}
|
|
133310
133418
|
function readOpenArtifact(fd, size) {
|
|
133311
133419
|
const bytes = Buffer.allocUnsafe(size);
|
|
133312
133420
|
let offset = 0;
|
|
133313
133421
|
while (offset < size) {
|
|
133314
|
-
const count2 =
|
|
133422
|
+
const count2 = readSync2(fd, bytes, offset, size - offset, offset);
|
|
133315
133423
|
if (count2 === 0)
|
|
133316
133424
|
throw new Error("the downloaded update artifact ended while being verified");
|
|
133317
133425
|
offset += count2;
|
|
@@ -133370,10 +133478,10 @@ async function serveArtifactSnapshot(artifact) {
|
|
|
133370
133478
|
}
|
|
133371
133479
|
async function installVerifiedTarball(tarballPath, tempDir, release2) {
|
|
133372
133480
|
const ambientEnvironment = { ...process.env };
|
|
133373
|
-
const packageDir =
|
|
133374
|
-
const cacheDir =
|
|
133375
|
-
const userConfigPath =
|
|
133376
|
-
const globalConfigPath =
|
|
133481
|
+
const packageDir = join49(tempDir, "authenticated-package");
|
|
133482
|
+
const cacheDir = join49(tempDir, "empty-cache");
|
|
133483
|
+
const userConfigPath = join49(tempDir, "user-npmrc");
|
|
133484
|
+
const globalConfigPath = join49(tempDir, "global-npmrc");
|
|
133377
133485
|
writeFileSync25(userConfigPath, "", { mode: 384 });
|
|
133378
133486
|
writeFileSync25(globalConfigPath, "", { mode: 384 });
|
|
133379
133487
|
const artifact = snapshotAuthenticatedArtifact(tarballPath);
|
|
@@ -133445,8 +133553,8 @@ async function runUpdate(opts, dependencies = {}) {
|
|
|
133445
133553
|
const provenance = await fetchJson(fetchImpl, release2.attestationUrl, "the official npm provenance endpoint");
|
|
133446
133554
|
await (dependencies.verifyProvenance ?? verifyPublishedProvenance)(provenance, release2);
|
|
133447
133555
|
const tarball = await downloadTarball(fetchImpl, release2);
|
|
133448
|
-
tempDir = mkdtempSync4(
|
|
133449
|
-
const tarballPath =
|
|
133556
|
+
tempDir = mkdtempSync4(join49(tmpdir2(), "somewhere-update-"));
|
|
133557
|
+
const tarballPath = join49(tempDir, `cli-${release2.version}.tgz`);
|
|
133450
133558
|
writeFileSync25(tarballPath, tarball, { mode: 384 });
|
|
133451
133559
|
info(`Cryptographically verified provenance and integrity for ${CLI_PACKAGE}@${release2.version}.`);
|
|
133452
133560
|
info(`Updating ${CLI_PACKAGE} from its authenticated dependency lock \u2026`);
|
|
@@ -133578,7 +133686,7 @@ var init_upgrade = __esm({
|
|
|
133578
133686
|
});
|
|
133579
133687
|
|
|
133580
133688
|
// dist/commands/call.js
|
|
133581
|
-
import { readFileSync as
|
|
133689
|
+
import { readFileSync as readFileSync41 } from "node:fs";
|
|
133582
133690
|
function parseArguments(value, file) {
|
|
133583
133691
|
if (value === void 0)
|
|
133584
133692
|
return {};
|
|
@@ -133602,7 +133710,7 @@ function readCallArguments(jsonArgs, file) {
|
|
|
133602
133710
|
}
|
|
133603
133711
|
let text;
|
|
133604
133712
|
try {
|
|
133605
|
-
text =
|
|
133713
|
+
text = readFileSync41(file, "utf8");
|
|
133606
133714
|
} catch (err) {
|
|
133607
133715
|
const code = err?.code;
|
|
133608
133716
|
throw new Error(`Could not read --file ${file}${code ? ` (${code})` : ""}. The requested tool was not called.`);
|
|
@@ -135944,8 +136052,8 @@ var init_test_response_capture = __esm({
|
|
|
135944
136052
|
import { randomUUID as randomUUID12 } from "node:crypto";
|
|
135945
136053
|
import { setDefaultResultOrder } from "node:dns";
|
|
135946
136054
|
import { lookup } from "node:dns/promises";
|
|
135947
|
-
import { existsSync as existsSync38, mkdirSync as
|
|
135948
|
-
import { basename as basename11, dirname as dirname15, join as
|
|
136055
|
+
import { existsSync as existsSync38, mkdirSync as mkdirSync21, readFileSync as readFileSync42, writeFileSync as writeFileSync26 } from "node:fs";
|
|
136056
|
+
import { basename as basename11, dirname as dirname15, join as join50, relative as relative13, resolve as resolve24 } from "node:path";
|
|
135949
136057
|
function launchOptions(extra = {}) {
|
|
135950
136058
|
return { ...extra, args: ["--disable-features=AsyncDns", ...extra.args ?? []] };
|
|
135951
136059
|
}
|
|
@@ -135995,10 +136103,10 @@ function undeployedChanges(root, projectId, preview = false) {
|
|
|
135995
136103
|
return null;
|
|
135996
136104
|
base = { project_id: record3.project_id, release_id: record3.preview_id, files: record3.files };
|
|
135997
136105
|
} else {
|
|
135998
|
-
const path3 =
|
|
136106
|
+
const path3 = join50(root, ".somewhere", "base-files.json");
|
|
135999
136107
|
if (!existsSync38(path3))
|
|
136000
136108
|
return null;
|
|
136001
|
-
base = JSON.parse(
|
|
136109
|
+
base = JSON.parse(readFileSync42(path3, "utf8"));
|
|
136002
136110
|
}
|
|
136003
136111
|
if (base.project_id !== projectId || !base.files)
|
|
136004
136112
|
return null;
|
|
@@ -136168,12 +136276,12 @@ var init_app_test = __esm({
|
|
|
136168
136276
|
for (const line of describeSweep(await sweepAccounts(control, root), "Before this script"))
|
|
136169
136277
|
process.stderr.write(line + "\n");
|
|
136170
136278
|
const scriptName = process.argv[1] ? basename11(process.argv[1]).replace(/\.[cm]?[jt]s$/, "") : "app-check";
|
|
136171
|
-
const app = new _AppTest(root, control, resolve24(root, options2.results ??
|
|
136279
|
+
const app = new _AppTest(root, control, resolve24(root, options2.results ?? join50(".somewhere", `${scriptName}${preview ? "-preview" : ""}.json`)));
|
|
136172
136280
|
return app;
|
|
136173
136281
|
}
|
|
136174
136282
|
/** What this run tests: the project, environment, preview, origin and script. */
|
|
136175
136283
|
identity() {
|
|
136176
|
-
const script = process.argv[1] ?
|
|
136284
|
+
const script = process.argv[1] ? relative13(this.root, resolve24(process.argv[1])) : null;
|
|
136177
136285
|
return {
|
|
136178
136286
|
project_id: this.control.projectId,
|
|
136179
136287
|
environment: this.control.environment,
|
|
@@ -136350,7 +136458,7 @@ page ${i + 1}: ${state}`).join("");
|
|
|
136350
136458
|
}
|
|
136351
136459
|
const passed = this.checks.filter((check) => check.ok).length;
|
|
136352
136460
|
const failed = this.checks.filter((check) => !check.ok && !check.skipped).length;
|
|
136353
|
-
|
|
136461
|
+
mkdirSync21(dirname15(this.resultsPath), { recursive: true });
|
|
136354
136462
|
writeFileSync26(this.resultsPath, JSON.stringify({
|
|
136355
136463
|
identity: this.identity(),
|
|
136356
136464
|
origin: this.origin,
|
|
@@ -136367,13 +136475,13 @@ page ${i + 1}: ${state}`).join("");
|
|
|
136367
136475
|
...check,
|
|
136368
136476
|
...check.error ? { error: scrub(check.error) } : {}
|
|
136369
136477
|
}));
|
|
136370
|
-
const resultFile =
|
|
136478
|
+
const resultFile = relative13(this.root, this.resultsPath);
|
|
136371
136479
|
const handOver = process.env.SW_TEST_REPORT;
|
|
136372
136480
|
if (handOver)
|
|
136373
136481
|
writeFileSync26(handOver, JSON.stringify({ checks: reported, resultFile }) + "\n");
|
|
136374
136482
|
else {
|
|
136375
136483
|
const verbose = process.argv.includes("--verbose") || process.env.SW_TEST_VERBOSE === "1";
|
|
136376
|
-
const script = process.argv[1] ?
|
|
136484
|
+
const script = process.argv[1] ? relative13(this.root, resolve24(process.argv[1])) : "this script";
|
|
136377
136485
|
process.stdout.write(describeReport([{ script, checks: reported, resultFile }], { verbose }).join("\n") + "\n");
|
|
136378
136486
|
}
|
|
136379
136487
|
if (live !== this.release) {
|
|
@@ -136798,7 +136906,7 @@ var init_test_session = __esm({
|
|
|
136798
136906
|
|
|
136799
136907
|
// dist/lib/prepared-actor-session.js
|
|
136800
136908
|
import { createHash as createHash10 } from "node:crypto";
|
|
136801
|
-
import { closeSync as
|
|
136909
|
+
import { closeSync as closeSync7, openSync as openSync7, rmSync as rmSync16 } from "node:fs";
|
|
136802
136910
|
import { setTimeout as delay2 } from "node:timers/promises";
|
|
136803
136911
|
async function preparedActorSession(root, target, name) {
|
|
136804
136912
|
const read = /* @__PURE__ */ __name(() => preparedActorState(root, target, name), "read");
|
|
@@ -136811,7 +136919,7 @@ async function preparedActorSession(root, target, name) {
|
|
|
136811
136919
|
while (Date.now() < deadline) {
|
|
136812
136920
|
let fd;
|
|
136813
136921
|
try {
|
|
136814
|
-
fd =
|
|
136922
|
+
fd = openSync7(lock, "wx", 384);
|
|
136815
136923
|
} catch (error3) {
|
|
136816
136924
|
if (error3.code !== "EEXIST")
|
|
136817
136925
|
throw error3;
|
|
@@ -136833,7 +136941,7 @@ async function preparedActorSession(root, target, name) {
|
|
|
136833
136941
|
writePrivateFile(latest.path, JSON.stringify(renewed, null, 2) + "\n");
|
|
136834
136942
|
return token;
|
|
136835
136943
|
} finally {
|
|
136836
|
-
|
|
136944
|
+
closeSync7(fd);
|
|
136837
136945
|
rmSync16(lock, { force: true });
|
|
136838
136946
|
}
|
|
136839
136947
|
}
|
|
@@ -136941,8 +137049,8 @@ var init_reference_check_note = __esm({
|
|
|
136941
137049
|
|
|
136942
137050
|
// dist/lib/test-scripts.js
|
|
136943
137051
|
import { createRequire as createRequire10 } from "node:module";
|
|
136944
|
-
import { existsSync as existsSync39, mkdirSync as
|
|
136945
|
-
import { dirname as dirname16, join as
|
|
137052
|
+
import { existsSync as existsSync39, mkdirSync as mkdirSync22, readFileSync as readFileSync43, readdirSync as readdirSync9, rmSync as rmSync17, statSync as statSync9, writeFileSync as writeFileSync27 } from "node:fs";
|
|
137053
|
+
import { dirname as dirname16, join as join51, relative as relative14, resolve as resolve25 } from "node:path";
|
|
136946
137054
|
import { spawn as spawn7, spawnSync as spawnSync5 } from "node:child_process";
|
|
136947
137055
|
function hasSpecFiles(root) {
|
|
136948
137056
|
const walk2 = /* @__PURE__ */ __name((dir) => {
|
|
@@ -136951,24 +137059,24 @@ function hasSpecFiles(root) {
|
|
|
136951
137059
|
for (const entry of readdirSync9(dir, { withFileTypes: true })) {
|
|
136952
137060
|
if (entry.name === "node_modules" || entry.name.startsWith("."))
|
|
136953
137061
|
continue;
|
|
136954
|
-
const path3 =
|
|
137062
|
+
const path3 = join51(dir, entry.name);
|
|
136955
137063
|
if (entry.isDirectory() ? walk2(path3) : /\.spec\.ts$/.test(entry.name))
|
|
136956
137064
|
return true;
|
|
136957
137065
|
}
|
|
136958
137066
|
return false;
|
|
136959
137067
|
}, "walk");
|
|
136960
|
-
return walk2(
|
|
137068
|
+
return walk2(join51(root, "tests"));
|
|
136961
137069
|
}
|
|
136962
137070
|
function listScripts(root, files) {
|
|
136963
137071
|
if (files.length)
|
|
136964
|
-
return files.map((file) =>
|
|
136965
|
-
const dir =
|
|
137072
|
+
return files.map((file) => relative14(root, resolve25(root, file)));
|
|
137073
|
+
const dir = join51(root, "tests");
|
|
136966
137074
|
if (!existsSync39(dir))
|
|
136967
137075
|
return [];
|
|
136968
|
-
return readdirSync9(dir).filter((name) => isScript(name) && statSync9(
|
|
137076
|
+
return readdirSync9(dir).filter((name) => isScript(name) && statSync9(join51(dir, name)).isFile()).sort().map((name) => join51("tests", name));
|
|
136969
137077
|
}
|
|
136970
137078
|
function scriptBrowserEnv(root) {
|
|
136971
|
-
const require6 = createRequire10(
|
|
137079
|
+
const require6 = createRequire10(join51(root, "package.json"));
|
|
136972
137080
|
let cli;
|
|
136973
137081
|
try {
|
|
136974
137082
|
cli = require6.resolve("@playwright/test/cli");
|
|
@@ -136979,7 +137087,7 @@ function scriptBrowserEnv(root) {
|
|
|
136979
137087
|
const probe = spawnSync5(process.execPath, ["-e", "require(process.argv[1]).chromium.launch().then(b => b.close()).then(() => process.exit(0), () => process.exit(3))", require6.resolve("@playwright/test")], { env, stdio: "ignore" });
|
|
136980
137088
|
if (probe.status === 0)
|
|
136981
137089
|
return env;
|
|
136982
|
-
env.PLAYWRIGHT_BROWSERS_PATH ??=
|
|
137090
|
+
env.PLAYWRIGHT_BROWSERS_PATH ??= join51(cliConfigDir(), "cache", "playwright");
|
|
136983
137091
|
process.stderr.write("Installing Playwright Chromium in the CLI cache (once).\n");
|
|
136984
137092
|
const install = spawnSync5(process.execPath, [cli, "install", "chromium"], { stdio: "inherit", env });
|
|
136985
137093
|
if (install.status !== 0)
|
|
@@ -137002,7 +137110,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
137002
137110
|
env = testImportEnv(root, env);
|
|
137003
137111
|
const results = [];
|
|
137004
137112
|
for (const script of scripts) {
|
|
137005
|
-
if (!existsSync39(
|
|
137113
|
+
if (!existsSync39(join51(root, script))) {
|
|
137006
137114
|
results.push({ script, ok: false, exitCode: 1, ms: 0, reason: "no such file" });
|
|
137007
137115
|
continue;
|
|
137008
137116
|
}
|
|
@@ -137011,8 +137119,8 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
137011
137119
|
`);
|
|
137012
137120
|
const started = performance.now();
|
|
137013
137121
|
let output = "";
|
|
137014
|
-
const handOver =
|
|
137015
|
-
|
|
137122
|
+
const handOver = join51(root, ".somewhere", "tests", `report-${results.length}.json`);
|
|
137123
|
+
mkdirSync22(dirname16(handOver), { recursive: true });
|
|
137016
137124
|
rmSync17(handOver, { force: true });
|
|
137017
137125
|
const askedForBrowserLog = /(^|,)\s*(pw:browser|pw:\*|\*)\s*(,|$)/.test(env.DEBUG ?? "");
|
|
137018
137126
|
const childEnv = { ...env, SW_TEST_REPORT: handOver, DEBUG: askedForBrowserLog ? env.DEBUG : [env.DEBUG, "pw:browser"].filter(Boolean).join(",") };
|
|
@@ -137041,7 +137149,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
137041
137149
|
stderrLines("", true);
|
|
137042
137150
|
let report2 = null;
|
|
137043
137151
|
try {
|
|
137044
|
-
report2 = existsSync39(handOver) ? JSON.parse(
|
|
137152
|
+
report2 = existsSync39(handOver) ? JSON.parse(readFileSync43(handOver, "utf8")) : null;
|
|
137045
137153
|
} catch {
|
|
137046
137154
|
report2 = null;
|
|
137047
137155
|
}
|
|
@@ -137074,20 +137182,20 @@ function describeScriptResults(results, options2 = {}) {
|
|
|
137074
137182
|
return results.some((result) => result.browserCrashed) ? lines.map((line) => line.startsWith("Next: ") ? `Next: give the browser access as the FAIL line says, then run ${TEST_COMMAND} again.` : line) : lines;
|
|
137075
137183
|
}
|
|
137076
137184
|
function lastFailedScripts(root) {
|
|
137077
|
-
const path3 =
|
|
137185
|
+
const path3 = join51(root, LAST);
|
|
137078
137186
|
if (!existsSync39(path3))
|
|
137079
137187
|
return [];
|
|
137080
137188
|
try {
|
|
137081
|
-
return (JSON.parse(
|
|
137189
|
+
return (JSON.parse(readFileSync43(path3, "utf8")).results ?? []).filter((r) => !r.ok).map((r) => r.script);
|
|
137082
137190
|
} catch {
|
|
137083
137191
|
return [];
|
|
137084
137192
|
}
|
|
137085
137193
|
}
|
|
137086
137194
|
function recordScriptResults(root, results, rerunOnly) {
|
|
137087
|
-
const previous = rerunOnly && existsSync39(
|
|
137195
|
+
const previous = rerunOnly && existsSync39(join51(root, LAST)) ? JSON.parse(readFileSync43(join51(root, LAST), "utf8")).results ?? [] : [];
|
|
137088
137196
|
const merged = [...previous.filter((p2) => !results.some((r) => r.script === p2.script)), ...results];
|
|
137089
|
-
|
|
137090
|
-
writeFileSync27(
|
|
137197
|
+
mkdirSync22(join51(root, ".somewhere", "tests"), { recursive: true });
|
|
137198
|
+
writeFileSync27(join51(root, LAST), JSON.stringify({ finished: (/* @__PURE__ */ new Date()).toISOString(), results: merged }, null, 2) + "\n");
|
|
137091
137199
|
}
|
|
137092
137200
|
var BROWSER_CRASH, BROWSER_CRASH_REASON, isScript, LAST;
|
|
137093
137201
|
var init_test_scripts = __esm({
|
|
@@ -137105,7 +137213,7 @@ var init_test_scripts = __esm({
|
|
|
137105
137213
|
__name(failureReason, "failureReason");
|
|
137106
137214
|
__name(runScripts, "runScripts");
|
|
137107
137215
|
__name(describeScriptResults, "describeScriptResults");
|
|
137108
|
-
LAST =
|
|
137216
|
+
LAST = join51(".somewhere", "tests", "scripts-last.json");
|
|
137109
137217
|
__name(lastFailedScripts, "lastFailedScripts");
|
|
137110
137218
|
__name(recordScriptResults, "recordScriptResults");
|
|
137111
137219
|
}
|
|
@@ -137200,8 +137308,8 @@ var init_test = __esm({
|
|
|
137200
137308
|
});
|
|
137201
137309
|
|
|
137202
137310
|
// dist/commands/test-users.js
|
|
137203
|
-
import { existsSync as existsSync40, readFileSync as
|
|
137204
|
-
import { basename as basename12, join as
|
|
137311
|
+
import { existsSync as existsSync40, readFileSync as readFileSync44, rmSync as rmSync18 } from "node:fs";
|
|
137312
|
+
import { basename as basename12, join as join52 } from "node:path";
|
|
137205
137313
|
import { randomBytes as randomBytes9 } from "node:crypto";
|
|
137206
137314
|
async function resolveTarget(projectOpt, originOpt) {
|
|
137207
137315
|
const root = process.cwd();
|
|
@@ -137230,6 +137338,47 @@ function fail2(opts, cause, extra) {
|
|
|
137230
137338
|
error(`${message3} [${code}]`, cause);
|
|
137231
137339
|
process.exitCode = 1;
|
|
137232
137340
|
}
|
|
137341
|
+
async function removeRecorded(target, manifest, keepState) {
|
|
137342
|
+
if (manifest.project_id !== target.projectId)
|
|
137343
|
+
throw Object.assign(new Error(`The manifest belongs to ${manifest.project_id}, not ${target.projectId}.`), { code: "PROJECT_FOLDER_MISMATCH" });
|
|
137344
|
+
const ids = manifest.actors.map((actor) => actor.user_id);
|
|
137345
|
+
let deleteError = null;
|
|
137346
|
+
try {
|
|
137347
|
+
await target.client.call("DELETE", "/auth/test-users", { project_id: target.projectId, ids });
|
|
137348
|
+
} catch (cause) {
|
|
137349
|
+
deleteError = cause instanceof CliApiError ? `${cause.code}: ${cause.message}` : cause instanceof Error ? cause.message : String(cause);
|
|
137350
|
+
}
|
|
137351
|
+
let live = null;
|
|
137352
|
+
try {
|
|
137353
|
+
const listed = await target.client.call("GET", "/auth/test-users", void 0, { project_id: target.projectId });
|
|
137354
|
+
live = new Set((listed?.identities ?? []).map((item) => String(item.id)));
|
|
137355
|
+
} catch {
|
|
137356
|
+
live = null;
|
|
137357
|
+
}
|
|
137358
|
+
const removed = live ? ids.filter((id) => !live.has(id)) : [];
|
|
137359
|
+
const remaining = live ? ids.filter((id) => live.has(id)) : [];
|
|
137360
|
+
const unknown2 = live ? [] : ids;
|
|
137361
|
+
const removedActors = manifest.actors.filter((actor) => removed.includes(actor.user_id));
|
|
137362
|
+
const localRemoved = keepState ? [] : removeStateFiles(target.root, removedActors);
|
|
137363
|
+
const receipt = {
|
|
137364
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
137365
|
+
run_id: manifest.run_id,
|
|
137366
|
+
project_id: manifest.project_id,
|
|
137367
|
+
origin: manifest.origin,
|
|
137368
|
+
identities: { requested: ids.length, removed, remaining, unknown: unknown2, ...deleteError ? { delete_error: deleteError } : {} },
|
|
137369
|
+
sessions: removed.length ? "removed together with each removed identity" : "none removed",
|
|
137370
|
+
app_data_files_and_test_mail: "retained: " + RETAINED_NOTE,
|
|
137371
|
+
local_state: { removed: localRemoved, kept: manifest.actors.map((actor) => actor.state_file).filter((file) => !localRemoved.includes(file)) },
|
|
137372
|
+
actors: manifest.actors.map(({ name, user_id, email: email2, role, created_at }) => ({ name, user_id, email: email2, role, created_at }))
|
|
137373
|
+
};
|
|
137374
|
+
writePrivateFile(join52(stateDir(target.root), CLEANUP_RECEIPT_FILE), JSON.stringify(receipt, null, 2) + "\n");
|
|
137375
|
+
const left = manifest.actors.filter((actor) => !removed.includes(actor.user_id));
|
|
137376
|
+
if (left.length)
|
|
137377
|
+
writeManifest(target.root, { ...manifest, actors: left, status: "partial" });
|
|
137378
|
+
else
|
|
137379
|
+
rmSync18(join52(stateDir(target.root), MANIFEST_FILE), { force: true });
|
|
137380
|
+
return { receipt, left, removed, remaining, unknown: unknown2, localRemoved, deleteError, ids };
|
|
137381
|
+
}
|
|
137233
137382
|
function registerTestUsers(program2) {
|
|
137234
137383
|
const group = program2.command("test-users").description("Signed-in test users for local Playwright, agent-browser and hosted verify: prepare, address, inbox, cleanup").addHelpText("after", [
|
|
137235
137384
|
"",
|
|
@@ -137238,7 +137387,7 @@ function registerTestUsers(program2) {
|
|
|
137238
137387
|
"that signup or email verification works. Use `address` + `inbox` for real signup tests.",
|
|
137239
137388
|
`${RETAINED_NOTE}`
|
|
137240
137389
|
].join("\n"));
|
|
137241
|
-
group.command("prepare <actors...>").description("Create preverified test users and write one Playwright storageState file per actor (e.g. alice bob:admin)").option("-p, --project <project>", "Project slug or ID; defaults to the linked project").option("--origin <url>", "Only the project's production origin is supported; anything else is refused").option("--json", "Print the manifest and browser data contract digest as JSON").addHelpText("after", [
|
|
137390
|
+
group.command("prepare <actors...>").description("Create preverified test users and write one Playwright storageState file per actor (e.g. alice bob:admin)").option("-p, --project <project>", "Project slug or ID; defaults to the linked project").option("--origin <url>", "Only the project's production origin is supported; anything else is refused").option("--replace", "First remove the test users this folder recorded (as cleanup does), then prepare these; use it when a saved session stopped working").option("--json", "Print the manifest and browser data contract digest as JSON").addHelpText("after", [
|
|
137242
137391
|
"",
|
|
137243
137392
|
"From the linked project folder, run somewhere test-users prepare alice. It writes .somewhere/test/<actor>.state.json (a standard Playwright storageState) and manifest.json.",
|
|
137244
137393
|
'Playwright: const alice = await browser.newContext({ storageState: ".somewhere/test/alice.state.json" })',
|
|
@@ -137272,8 +137421,24 @@ function registerTestUsers(program2) {
|
|
|
137272
137421
|
fail2(opts, cause);
|
|
137273
137422
|
return;
|
|
137274
137423
|
}
|
|
137424
|
+
if (existing && existing.actors.length && opts.replace) {
|
|
137425
|
+
try {
|
|
137426
|
+
const removed = await removeRecorded(target, existing, false);
|
|
137427
|
+
if (removed.left.length) {
|
|
137428
|
+
fail2(opts, Object.assign(new Error(`${removed.left.length} recorded test user(s) could not be removed${removed.deleteError ? ` (${removed.deleteError})` : ""}, so none were replaced. Run the same command again.`), { code: "TEST_USERS_NOT_CLEANED" }));
|
|
137429
|
+
return;
|
|
137430
|
+
}
|
|
137431
|
+
if (!opts.json)
|
|
137432
|
+
info(`Removed ${removed.removed.length} recorded test user(s) from run ${existing.run_id}; their app data is kept. Preparing new ones.`);
|
|
137433
|
+
existing = null;
|
|
137434
|
+
} catch (cause) {
|
|
137435
|
+
fail2(opts, cause);
|
|
137436
|
+
return;
|
|
137437
|
+
}
|
|
137438
|
+
}
|
|
137275
137439
|
if (existing && existing.actors.length) {
|
|
137276
|
-
|
|
137440
|
+
const names = existing.actors.map((actor) => actor.role === "admin" ? `${actor.name}:admin` : actor.name).join(" ");
|
|
137441
|
+
fail2(opts, Object.assign(new Error(`${TEST_STATE_DIR}/${MANIFEST_FILE} still records ${existing.actors.length} test user(s) from run ${existing.run_id}. If their saved sessions still sign in, keep using them. If a session stopped working (a run that crashed or shared one state file signs the user out for good), replace them in one step: \`somewhere test-users prepare ${names} --replace\`.`), { code: "TEST_USERS_NOT_CLEANED" }));
|
|
137277
137442
|
return;
|
|
137278
137443
|
}
|
|
137279
137444
|
let contractDigest = null;
|
|
@@ -137302,7 +137467,7 @@ function registerTestUsers(program2) {
|
|
|
137302
137467
|
const record3 = /* @__PURE__ */ __name((spec, issued, receivedAt) => {
|
|
137303
137468
|
const times = expiryOf(issued, receivedAt);
|
|
137304
137469
|
const file = `${spec.name}.state.json`;
|
|
137305
|
-
writePrivateFile(
|
|
137470
|
+
writePrivateFile(join52(dir, file), JSON.stringify(buildStorageState(target.origin, target.host, issued, times), null, 2) + "\n");
|
|
137306
137471
|
const actor = {
|
|
137307
137472
|
name: spec.name,
|
|
137308
137473
|
user_id: issued.user.id,
|
|
@@ -137404,7 +137569,7 @@ function registerTestUsers(program2) {
|
|
|
137404
137569
|
if (name !== opts.linkOut || !/^[A-Za-z0-9._-]{1,64}$/.test(name))
|
|
137405
137570
|
throw new Error(`--link-out takes a file name; it is written under ${TEST_STATE_DIR}/.`);
|
|
137406
137571
|
ensurePrivateDir(stateDir(target.root));
|
|
137407
|
-
writePrivateFile(
|
|
137572
|
+
writePrivateFile(join52(stateDir(target.root), name), newest.magic_link + "\n");
|
|
137408
137573
|
linkFile = `${TEST_STATE_DIR}/${name}`;
|
|
137409
137574
|
}
|
|
137410
137575
|
const message3 = {
|
|
@@ -137443,51 +137608,14 @@ function registerTestUsers(program2) {
|
|
|
137443
137608
|
info(`Nothing to clean up: ${TEST_STATE_DIR}/${MANIFEST_FILE} records no test users.`);
|
|
137444
137609
|
return;
|
|
137445
137610
|
}
|
|
137446
|
-
|
|
137447
|
-
throw Object.assign(new Error(`The manifest belongs to ${manifest.project_id}, not ${target.projectId}.`), { code: "PROJECT_FOLDER_MISMATCH" });
|
|
137448
|
-
const ids = manifest.actors.map((actor) => actor.user_id);
|
|
137449
|
-
let deleteError = null;
|
|
137450
|
-
try {
|
|
137451
|
-
await target.client.call("DELETE", "/auth/test-users", { project_id: target.projectId, ids });
|
|
137452
|
-
} catch (cause) {
|
|
137453
|
-
deleteError = cause instanceof CliApiError ? `${cause.code}: ${cause.message}` : cause instanceof Error ? cause.message : String(cause);
|
|
137454
|
-
}
|
|
137455
|
-
let live = null;
|
|
137456
|
-
try {
|
|
137457
|
-
const listed = await target.client.call("GET", "/auth/test-users", void 0, { project_id: target.projectId });
|
|
137458
|
-
live = new Set((listed?.identities ?? []).map((item) => String(item.id)));
|
|
137459
|
-
} catch {
|
|
137460
|
-
live = null;
|
|
137461
|
-
}
|
|
137462
|
-
const removed = live ? ids.filter((id) => !live.has(id)) : [];
|
|
137463
|
-
const remaining = live ? ids.filter((id) => live.has(id)) : [];
|
|
137464
|
-
const unknown2 = live ? [] : ids;
|
|
137465
|
-
const removedActors = manifest.actors.filter((actor) => removed.includes(actor.user_id));
|
|
137466
|
-
const localRemoved = opts.keepState ? [] : removeStateFiles(target.root, removedActors);
|
|
137467
|
-
const receipt = {
|
|
137468
|
-
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
137469
|
-
run_id: manifest.run_id,
|
|
137470
|
-
project_id: manifest.project_id,
|
|
137471
|
-
origin: manifest.origin,
|
|
137472
|
-
identities: { requested: ids.length, removed, remaining, unknown: unknown2, ...deleteError ? { delete_error: deleteError } : {} },
|
|
137473
|
-
sessions: removed.length ? "removed together with each removed identity" : "none removed",
|
|
137474
|
-
app_data_files_and_test_mail: "retained: " + RETAINED_NOTE,
|
|
137475
|
-
local_state: { removed: localRemoved, kept: manifest.actors.map((actor) => actor.state_file).filter((file) => !localRemoved.includes(file)) },
|
|
137476
|
-
actors: manifest.actors.map(({ name, user_id, email: email2, role, created_at }) => ({ name, user_id, email: email2, role, created_at }))
|
|
137477
|
-
};
|
|
137478
|
-
writePrivateFile(join51(stateDir(target.root), CLEANUP_RECEIPT_FILE), JSON.stringify(receipt, null, 2) + "\n");
|
|
137479
|
-
const left = manifest.actors.filter((actor) => !removed.includes(actor.user_id));
|
|
137480
|
-
if (left.length)
|
|
137481
|
-
writeManifest(target.root, { ...manifest, actors: left, status: "partial" });
|
|
137482
|
-
else
|
|
137483
|
-
rmSync18(join51(stateDir(target.root), MANIFEST_FILE), { force: true });
|
|
137611
|
+
const { receipt, left, removed, remaining, unknown: unknown2, localRemoved, deleteError } = await removeRecorded(target, manifest, Boolean(opts.keepState));
|
|
137484
137612
|
if (opts.json) {
|
|
137485
137613
|
printJson(receipt);
|
|
137486
137614
|
if (left.length)
|
|
137487
137615
|
process.exitCode = 1;
|
|
137488
137616
|
return;
|
|
137489
137617
|
}
|
|
137490
|
-
info(`Identities: ${removed.length} removed, ${remaining.length} remaining, ${unknown2.length} unknown (of ${
|
|
137618
|
+
info(`Identities: ${removed.length} removed, ${remaining.length} remaining, ${unknown2.length} unknown (of ${manifest.actors.length}).`);
|
|
137491
137619
|
if (deleteError)
|
|
137492
137620
|
warn(`Delete reported: ${deleteError}`);
|
|
137493
137621
|
info(`Sessions: ${receipt.sessions}.`);
|
|
@@ -137515,12 +137643,13 @@ var init_test_users = __esm({
|
|
|
137515
137643
|
__name(resolveTarget, "resolveTarget");
|
|
137516
137644
|
__name(fail2, "fail");
|
|
137517
137645
|
iso = /* @__PURE__ */ __name((ms2) => new Date(ms2).toISOString(), "iso");
|
|
137646
|
+
__name(removeRecorded, "removeRecorded");
|
|
137518
137647
|
__name(registerTestUsers, "registerTestUsers");
|
|
137519
137648
|
}
|
|
137520
137649
|
});
|
|
137521
137650
|
|
|
137522
137651
|
// dist/commands/support.js
|
|
137523
|
-
import { join as
|
|
137652
|
+
import { join as join53 } from "node:path";
|
|
137524
137653
|
function commandPaths(program2) {
|
|
137525
137654
|
const paths = /* @__PURE__ */ new Set();
|
|
137526
137655
|
const walk2 = /* @__PURE__ */ __name((command, prefix) => {
|
|
@@ -137605,7 +137734,7 @@ function emitPacket(packet, opts) {
|
|
|
137605
137734
|
if (opts.out) {
|
|
137606
137735
|
if (!/^[A-Za-z0-9._-]{1,64}$/.test(opts.out))
|
|
137607
137736
|
throw new Error("--out takes a plain file name in the current folder.");
|
|
137608
|
-
writePrivateFile(
|
|
137737
|
+
writePrivateFile(join53(process.cwd(), opts.out), JSON.stringify(packet, null, 2) + "\n");
|
|
137609
137738
|
}
|
|
137610
137739
|
if (opts.json) {
|
|
137611
137740
|
printJson(packet);
|
|
@@ -137727,7 +137856,6 @@ var init_skills = __esm({
|
|
|
137727
137856
|
});
|
|
137728
137857
|
|
|
137729
137858
|
// dist/commands/ai.js
|
|
137730
|
-
import { readFileSync as readFileSync47 } from "node:fs";
|
|
137731
137859
|
function fail4(message3) {
|
|
137732
137860
|
error(message3);
|
|
137733
137861
|
process.exit(1);
|
|
@@ -137748,7 +137876,7 @@ async function readKey(stdin) {
|
|
|
137748
137876
|
if (stdin) {
|
|
137749
137877
|
if (process.stdin.isTTY)
|
|
137750
137878
|
fail4("Pipe the key into --stdin, or leave out --stdin to type it into a hidden prompt.");
|
|
137751
|
-
raw =
|
|
137879
|
+
raw = await readAllStdin();
|
|
137752
137880
|
} else {
|
|
137753
137881
|
if (!process.stdin.isTTY)
|
|
137754
137882
|
fail4("Pass --stdin to read the key from a pipe. Nothing was sent.");
|
|
@@ -137860,6 +137988,7 @@ var init_ai = __esm({
|
|
|
137860
137988
|
"dist/commands/ai.js"() {
|
|
137861
137989
|
"use strict";
|
|
137862
137990
|
init_cli_invocation();
|
|
137991
|
+
init_stdin();
|
|
137863
137992
|
import_prompts12 = __toESM(require_prompts3(), 1);
|
|
137864
137993
|
init_client();
|
|
137865
137994
|
init_config();
|
|
@@ -137895,11 +138024,11 @@ var init_startup_notice = __esm({
|
|
|
137895
138024
|
});
|
|
137896
138025
|
|
|
137897
138026
|
// dist/lib/last-run.js
|
|
137898
|
-
import { lstatSync as lstatSync7, mkdirSync as
|
|
137899
|
-
import { join as
|
|
138027
|
+
import { lstatSync as lstatSync7, mkdirSync as mkdirSync23, renameSync as renameSync7, unlinkSync as unlinkSync6, writeFileSync as writeFileSync28 } from "node:fs";
|
|
138028
|
+
import { join as join54 } from "node:path";
|
|
137900
138029
|
function removeStaleRunRecord(dir = cliConfigDir()) {
|
|
137901
138030
|
for (const name of RUN_RECORD_FILES) {
|
|
137902
|
-
const path3 =
|
|
138031
|
+
const path3 = join54(dir, name);
|
|
137903
138032
|
try {
|
|
137904
138033
|
if (lstatSync7(path3).isDirectory()) {
|
|
137905
138034
|
process.stderr.write(`Could not remove ${path3}: it is a directory, not this CLI's run record. Check it yourself.
|
|
@@ -137930,7 +138059,7 @@ function recordLastRun(cliVersion) {
|
|
|
137930
138059
|
process.once("exit", (exitCode) => {
|
|
137931
138060
|
try {
|
|
137932
138061
|
const dir = cliConfigDir();
|
|
137933
|
-
|
|
138062
|
+
mkdirSync23(dir, { recursive: true, mode: 448 });
|
|
137934
138063
|
const record3 = {
|
|
137935
138064
|
// A usage error never reaches a command: no command and no options.
|
|
137936
138065
|
command: invocation?.command ?? "",
|
|
@@ -137939,8 +138068,8 @@ function recordLastRun(cliVersion) {
|
|
|
137939
138068
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
137940
138069
|
cli_version: cliVersion
|
|
137941
138070
|
};
|
|
137942
|
-
const path3 =
|
|
137943
|
-
const temporary =
|
|
138071
|
+
const path3 = join54(dir, "last-run.json");
|
|
138072
|
+
const temporary = join54(dir, "last-run.json.tmp");
|
|
137944
138073
|
writeFileSync28(temporary, JSON.stringify(record3) + "\n", { mode: 384 });
|
|
137945
138074
|
renameSync7(temporary, path3);
|
|
137946
138075
|
} catch {
|
|
@@ -137978,8 +138107,8 @@ __export(dist_exports, {
|
|
|
137978
138107
|
runCli: () => runCli
|
|
137979
138108
|
});
|
|
137980
138109
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
137981
|
-
import { readFileSync as
|
|
137982
|
-
import { join as
|
|
138110
|
+
import { readFileSync as readFileSync45 } from "node:fs";
|
|
138111
|
+
import { join as join55 } from "node:path";
|
|
137983
138112
|
async function runCli() {
|
|
137984
138113
|
const pinned = decidePin(process.cwd(), CLI_VERSION2, process.argv, process.env);
|
|
137985
138114
|
if (pinned.notice)
|
|
@@ -138007,7 +138136,7 @@ async function runCli() {
|
|
|
138007
138136
|
process.exit(child.status ?? 1);
|
|
138008
138137
|
}
|
|
138009
138138
|
removeStaleRunRecord();
|
|
138010
|
-
const pkg = JSON.parse(
|
|
138139
|
+
const pkg = JSON.parse(readFileSync45(join55(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
138011
138140
|
const program2 = new Command().name(cliInvocation()).description(`CLI for somewhere.cloud. Run ${cliInvocation()} init first, then read generated AGENTS.md: call shapes and access patterns for a typical app; docs are for exceptions.`).version(pkg.version);
|
|
138012
138141
|
recordLastRun(pkg.version);
|
|
138013
138142
|
const jsonOutputRequested = process.argv.includes("--json");
|
|
@@ -138221,7 +138350,7 @@ __export(test_reporter_exports, {
|
|
|
138221
138350
|
confirmedRelease: () => confirmedRelease,
|
|
138222
138351
|
default: () => TestReporter
|
|
138223
138352
|
});
|
|
138224
|
-
import { relative as
|
|
138353
|
+
import { relative as relative15 } from "node:path";
|
|
138225
138354
|
function confirmedRelease(start, seen2, live) {
|
|
138226
138355
|
if (!start || !live)
|
|
138227
138356
|
return null;
|
|
@@ -138273,7 +138402,7 @@ var init_test_reporter = __esm({
|
|
|
138273
138402
|
const location2 = result.errors[i]?.location;
|
|
138274
138403
|
return location2 ? describeError({ message: "", location: location2 }).replace(/: $/, "") + ": " + message3 : message3;
|
|
138275
138404
|
}) : result.errors.map((error3) => describeError(error3));
|
|
138276
|
-
const file =
|
|
138405
|
+
const file = relative15(process.cwd(), test2.location.file);
|
|
138277
138406
|
const skipReason = result.status === "skipped" ? scrub(result.annotations.find(({ type, description }) => type === "skip" && description)?.description ?? "no reason given").slice(0, 200) : void 0;
|
|
138278
138407
|
const entry = { ...details, ...skipReason ? { skipReason } : {}, status: result.status, outcome: test2.outcome(), title: scrub(details.title).slice(0, 200), errors, step: result.steps.find((step2) => step2.error)?.category ?? "test body", file, line: test2.location.line };
|
|
138279
138408
|
this.entries.push(entry);
|
|
@@ -138425,7 +138554,7 @@ var init_screenshot_guard = __esm({
|
|
|
138425
138554
|
|
|
138426
138555
|
// dist/lib/playwright-fixtures.js
|
|
138427
138556
|
import { createRequire as createRequire11 } from "node:module";
|
|
138428
|
-
import { join as
|
|
138557
|
+
import { join as join56 } from "node:path";
|
|
138429
138558
|
function waitOnNavigation(page) {
|
|
138430
138559
|
async function wait(options2) {
|
|
138431
138560
|
if (options2?.waitUntil === "commit")
|
|
@@ -138477,7 +138606,7 @@ async function previewControlForWorker() {
|
|
|
138477
138606
|
function runner() {
|
|
138478
138607
|
if (loaded)
|
|
138479
138608
|
return loaded;
|
|
138480
|
-
const require6 = createRequire11(
|
|
138609
|
+
const require6 = createRequire11(join56(process.cwd(), "package.json"));
|
|
138481
138610
|
let pw;
|
|
138482
138611
|
try {
|
|
138483
138612
|
pw = require6("@playwright/test");
|
|
@@ -139151,7 +139280,7 @@ import { resolve as resolve26 } from "node:path";
|
|
|
139151
139280
|
import { createRequire as createRequire12 } from "node:module";
|
|
139152
139281
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
139153
139282
|
import { readdirSync as readdirSync10 } from "node:fs";
|
|
139154
|
-
import { dirname as dirname17, join as
|
|
139283
|
+
import { dirname as dirname17, join as join57 } from "node:path";
|
|
139155
139284
|
async function openTestApp(options2 = {}) {
|
|
139156
139285
|
const root = resolve26(options2.projectDir ?? process.cwd());
|
|
139157
139286
|
const projectId = loadProjectConfig(root)?.project_id;
|
|
@@ -139604,7 +139733,7 @@ function replySummary(reply) {
|
|
|
139604
139733
|
function findPlaywright(root, given) {
|
|
139605
139734
|
if (given && typeof given === "object")
|
|
139606
139735
|
return given;
|
|
139607
|
-
const require6 = createRequire12(
|
|
139736
|
+
const require6 = createRequire12(join57(root, "package.json"));
|
|
139608
139737
|
const load2 = /* @__PURE__ */ __name((name) => {
|
|
139609
139738
|
try {
|
|
139610
139739
|
const pw = require6(name);
|
|
@@ -139622,14 +139751,14 @@ function findPlaywright(root, given) {
|
|
|
139622
139751
|
const browsers = process.env.PLAYWRIGHT_BROWSERS_PATH;
|
|
139623
139752
|
if (browsers) {
|
|
139624
139753
|
const parent = dirname17(resolve26(browsers));
|
|
139625
|
-
dirs.push(
|
|
139754
|
+
dirs.push(join57(parent, "node_modules"), ...readdirSafe(parent).map((entry) => join57(parent, entry, "node_modules")));
|
|
139626
139755
|
}
|
|
139627
139756
|
try {
|
|
139628
139757
|
dirs.push(execFileSync2("npm", ["root", "-g"], { encoding: "utf8", timeout: 5e3 }).trim());
|
|
139629
139758
|
} catch {
|
|
139630
139759
|
}
|
|
139631
139760
|
for (const dir of dirs) {
|
|
139632
|
-
const pw = load2(
|
|
139761
|
+
const pw = load2(join57(dir, "playwright"));
|
|
139633
139762
|
if (pw)
|
|
139634
139763
|
return pw;
|
|
139635
139764
|
}
|