@somewhere-cloud/cli 0.38.184 → 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 +7 -0
- package/dist/lib/bundle.js +317 -267
- 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/dist/lib/bundle.js
CHANGED
|
@@ -34081,6 +34081,15 @@ var init_client = __esm({
|
|
|
34081
34081
|
const target = `/projects/${encodeURIComponent(id)}`;
|
|
34082
34082
|
if (path3 !== target && !path3.startsWith(target + "/") && query?.project_id !== id && !(body && typeof body === "object" && "project_id" in body && body.project_id === id))
|
|
34083
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
|
+
}
|
|
34084
34093
|
const identity = await this.call("GET", "/auth/whoami", void 0, void 0, { timeoutMs: 3e3, refresh: false }).then((answer) => {
|
|
34085
34094
|
if (typeof answer?.user?.email !== "string")
|
|
34086
34095
|
return "";
|
|
@@ -34382,6 +34391,7 @@ var init_client = __esm({
|
|
|
34382
34391
|
meta;
|
|
34383
34392
|
/** Original body-reader failure, retained only so raw command output stays unchanged. */
|
|
34384
34393
|
originalCause;
|
|
34394
|
+
linkedProjectGrantExcluded;
|
|
34385
34395
|
constructor(code, message3, statusCode, data2, hint, meta2 = {}) {
|
|
34386
34396
|
super(message3);
|
|
34387
34397
|
this.code = code;
|
|
@@ -37456,6 +37466,20 @@ var init_esm = __esm({
|
|
|
37456
37466
|
}
|
|
37457
37467
|
});
|
|
37458
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
|
+
|
|
37459
37483
|
// node_modules/kleur/index.js
|
|
37460
37484
|
var require_kleur = __commonJS({
|
|
37461
37485
|
"node_modules/kleur/index.js"(exports, module) {
|
|
@@ -43078,7 +43102,7 @@ var init_platform_command = __esm({
|
|
|
43078
43102
|
});
|
|
43079
43103
|
|
|
43080
43104
|
// dist/commands/auth.js
|
|
43081
|
-
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";
|
|
43082
43106
|
import { resolve as resolve2 } from "node:path";
|
|
43083
43107
|
import { pipeline } from "node:stream/promises";
|
|
43084
43108
|
async function readAuthToken() {
|
|
@@ -43086,7 +43110,7 @@ async function readAuthToken() {
|
|
|
43086
43110
|
if (envToken)
|
|
43087
43111
|
return envToken;
|
|
43088
43112
|
if (!process.stdin.isTTY) {
|
|
43089
|
-
return
|
|
43113
|
+
return (await readAllStdin()).trim();
|
|
43090
43114
|
}
|
|
43091
43115
|
const response = await (0, import_prompts.default)({
|
|
43092
43116
|
type: "password",
|
|
@@ -43642,6 +43666,7 @@ var init_auth2 = __esm({
|
|
|
43642
43666
|
"dist/commands/auth.js"() {
|
|
43643
43667
|
"use strict";
|
|
43644
43668
|
init_cli_invocation();
|
|
43669
|
+
init_stdin();
|
|
43645
43670
|
import_prompts = __toESM(require_prompts3(), 1);
|
|
43646
43671
|
init_open();
|
|
43647
43672
|
init_spinner();
|
|
@@ -43912,14 +43937,14 @@ var init_publish_surface = __esm({
|
|
|
43912
43937
|
});
|
|
43913
43938
|
|
|
43914
43939
|
// dist/lib/init-scaffold.js
|
|
43915
|
-
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";
|
|
43916
43941
|
import { dirname, relative, resolve as resolve3 } from "node:path";
|
|
43917
43942
|
function starterNameSlug(name) {
|
|
43918
43943
|
return name.toLowerCase().replace(/[^a-z0-9\s-]/g, "").replace(/[\s-]+/g, "-").replace(/^-|-$/g, "");
|
|
43919
43944
|
}
|
|
43920
43945
|
function readStarterProjectName(dir) {
|
|
43921
43946
|
try {
|
|
43922
|
-
const pkg = JSON.parse(
|
|
43947
|
+
const pkg = JSON.parse(readFileSync6(resolve3(dir, "package.json"), "utf8"));
|
|
43923
43948
|
const name = pkg?.somewhere?.project_name;
|
|
43924
43949
|
return typeof name === "string" ? name.trim() || void 0 : void 0;
|
|
43925
43950
|
} catch {
|
|
@@ -44018,7 +44043,7 @@ var init_init_scaffold = __esm({
|
|
|
44018
44043
|
|
|
44019
44044
|
// dist/lib/skills-pack.js
|
|
44020
44045
|
import { createHash as createHash2 } from "node:crypto";
|
|
44021
|
-
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";
|
|
44022
44047
|
import { join as join6 } from "node:path";
|
|
44023
44048
|
function verifyPack(pack) {
|
|
44024
44049
|
if (!pack || pack.schema !== 1 || pack.name !== "somewhere-skills" || typeof pack.version !== "string" || !Array.isArray(pack.files) || pack.files.length === 0) {
|
|
@@ -44052,7 +44077,7 @@ function readLock(dir) {
|
|
|
44052
44077
|
return null;
|
|
44053
44078
|
if (isSymlink(path3))
|
|
44054
44079
|
throw new Error("Skills lock must not be a symlink.");
|
|
44055
|
-
const lock = JSON.parse(
|
|
44080
|
+
const lock = JSON.parse(readFileSync7(path3, "utf8"));
|
|
44056
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))) {
|
|
44057
44082
|
throw new Error("Skills lock is malformed; nothing was changed.");
|
|
44058
44083
|
}
|
|
@@ -44065,7 +44090,7 @@ function linkForClaude(dir, name) {
|
|
|
44065
44090
|
if (existsSync6(at2) || isSymlink(at2)) {
|
|
44066
44091
|
if (isSymlink(at2) && readlinkSync(at2) === target)
|
|
44067
44092
|
return "link";
|
|
44068
|
-
writeFileSync6(join6(at2, "SKILL.md"),
|
|
44093
|
+
writeFileSync6(join6(at2, "SKILL.md"), readFileSync7(join6(dir, SKILLS_DIR, name, "SKILL.md")));
|
|
44069
44094
|
return "copy";
|
|
44070
44095
|
}
|
|
44071
44096
|
try {
|
|
@@ -44073,7 +44098,7 @@ function linkForClaude(dir, name) {
|
|
|
44073
44098
|
return "link";
|
|
44074
44099
|
} catch {
|
|
44075
44100
|
mkdirSync6(at2, { recursive: true });
|
|
44076
|
-
writeFileSync6(join6(at2, "SKILL.md"),
|
|
44101
|
+
writeFileSync6(join6(at2, "SKILL.md"), readFileSync7(join6(dir, SKILLS_DIR, name, "SKILL.md")));
|
|
44077
44102
|
return "copy";
|
|
44078
44103
|
}
|
|
44079
44104
|
}
|
|
@@ -44159,7 +44184,7 @@ function preflightInstall(dir, pack, previous, state) {
|
|
|
44159
44184
|
conflicts.push(claude);
|
|
44160
44185
|
} else if (existsSync6(claude)) {
|
|
44161
44186
|
const copy = join6(claude, "SKILL.md");
|
|
44162
|
-
if (!owned || isSymlink(copy) || !existsSync6(copy) || sha256(
|
|
44187
|
+
if (!owned || isSymlink(copy) || !existsSync6(copy) || sha256(readFileSync7(copy, "utf8")) !== owned)
|
|
44163
44188
|
conflicts.push(claude);
|
|
44164
44189
|
}
|
|
44165
44190
|
}
|
|
@@ -44173,7 +44198,7 @@ function inspectFiles(dir, lock) {
|
|
|
44173
44198
|
const full = join6(dir, path3);
|
|
44174
44199
|
if (!existsSync6(full))
|
|
44175
44200
|
missing.push(path3);
|
|
44176
|
-
else if (sha256(
|
|
44201
|
+
else if (sha256(readFileSync7(full, "utf8")) !== hash)
|
|
44177
44202
|
modified.push(path3);
|
|
44178
44203
|
}
|
|
44179
44204
|
return { missing, modified };
|
|
@@ -44410,7 +44435,7 @@ var init_typecheck_version = __esm({
|
|
|
44410
44435
|
|
|
44411
44436
|
// dist/lib/base-files.js
|
|
44412
44437
|
import { createHash as createHash3 } from "node:crypto";
|
|
44413
|
-
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";
|
|
44414
44439
|
import { join as join7 } from "node:path";
|
|
44415
44440
|
function sha2562(content) {
|
|
44416
44441
|
return createHash3("sha256").update(content).digest("hex");
|
|
@@ -44418,7 +44443,7 @@ function sha2562(content) {
|
|
|
44418
44443
|
function hashFiles(dir, paths) {
|
|
44419
44444
|
const out = {};
|
|
44420
44445
|
for (const path3 of paths)
|
|
44421
|
-
out[path3] = sha2562(
|
|
44446
|
+
out[path3] = sha2562(readFileSync8(join7(dir, path3)));
|
|
44422
44447
|
return out;
|
|
44423
44448
|
}
|
|
44424
44449
|
function saveBaseFiles(dir, base) {
|
|
@@ -44433,7 +44458,7 @@ function loadBaseFiles(dir, projectId, releaseId) {
|
|
|
44433
44458
|
if (!existsSync7(path3) || releaseId === void 0)
|
|
44434
44459
|
return null;
|
|
44435
44460
|
try {
|
|
44436
|
-
const parsed = JSON.parse(
|
|
44461
|
+
const parsed = JSON.parse(readFileSync8(path3, "utf8"));
|
|
44437
44462
|
if (parsed.project_id !== projectId || parsed.release_id !== releaseId || !parsed.files || typeof parsed.files !== "object")
|
|
44438
44463
|
return null;
|
|
44439
44464
|
return parsed;
|
|
@@ -44450,7 +44475,7 @@ function loadLastActivation(dir) {
|
|
|
44450
44475
|
if (!existsSync7(path3))
|
|
44451
44476
|
return null;
|
|
44452
44477
|
try {
|
|
44453
|
-
return JSON.parse(
|
|
44478
|
+
return JSON.parse(readFileSync8(path3, "utf8"));
|
|
44454
44479
|
} catch {
|
|
44455
44480
|
return null;
|
|
44456
44481
|
}
|
|
@@ -44472,7 +44497,7 @@ var init_base_files = __esm({
|
|
|
44472
44497
|
});
|
|
44473
44498
|
|
|
44474
44499
|
// dist/lib/scaffold.js
|
|
44475
|
-
import { lstatSync as lstatSync3, readFileSync as
|
|
44500
|
+
import { lstatSync as lstatSync3, readFileSync as readFileSync9 } from "node:fs";
|
|
44476
44501
|
import { basename, join as join8 } from "node:path";
|
|
44477
44502
|
function buildScaffoldGitignore() {
|
|
44478
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";
|
|
@@ -44557,7 +44582,7 @@ function unchangedPullScaffolds(dir, base) {
|
|
|
44557
44582
|
const local = join8(dir, path3);
|
|
44558
44583
|
if (!lstatSync3(local, { throwIfNoEntry: false })?.isFile())
|
|
44559
44584
|
continue;
|
|
44560
|
-
const hash = sha2562(
|
|
44585
|
+
const hash = sha2562(readFileSync9(local));
|
|
44561
44586
|
if (hash === (base.scaffolds ? base.scaffolds[path3] : sha2562(generated)))
|
|
44562
44587
|
hashes[path3] = hash;
|
|
44563
44588
|
}
|
|
@@ -46814,13 +46839,13 @@ var require_semver2 = __commonJS({
|
|
|
46814
46839
|
});
|
|
46815
46840
|
|
|
46816
46841
|
// dist/lib/project-pin.js
|
|
46817
|
-
import { existsSync as existsSync8, readFileSync as
|
|
46842
|
+
import { existsSync as existsSync8, readFileSync as readFileSync10, writeFileSync as writeFileSync8 } from "node:fs";
|
|
46818
46843
|
import { dirname as dirname2, join as join9 } from "node:path";
|
|
46819
46844
|
function readJson(path3) {
|
|
46820
46845
|
if (!existsSync8(path3))
|
|
46821
46846
|
return null;
|
|
46822
46847
|
try {
|
|
46823
|
-
const value = JSON.parse(
|
|
46848
|
+
const value = JSON.parse(readFileSync10(path3, "utf8"));
|
|
46824
46849
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
46825
46850
|
} catch {
|
|
46826
46851
|
return null;
|
|
@@ -46944,7 +46969,7 @@ function writeProjectPins(dir, pins, version2) {
|
|
|
46944
46969
|
let repairedStarter = false;
|
|
46945
46970
|
for (const pin of pins) {
|
|
46946
46971
|
const path3 = join9(dir, pin.source);
|
|
46947
|
-
const raw =
|
|
46972
|
+
const raw = readFileSync10(path3, "utf8");
|
|
46948
46973
|
const json = JSON.parse(raw);
|
|
46949
46974
|
if (pin.versionOnly) {
|
|
46950
46975
|
repairedStarter = repairStarterReact(json, pin.spec);
|
|
@@ -46977,7 +47002,7 @@ function recordPinIfMissing(dir, version2) {
|
|
|
46977
47002
|
return true;
|
|
46978
47003
|
}
|
|
46979
47004
|
function readBundledChangelog() {
|
|
46980
|
-
return
|
|
47005
|
+
return readFileSync10(join9(CLI_PACKAGE_ROOT, "CHANGELOG.md"), "utf8");
|
|
46981
47006
|
}
|
|
46982
47007
|
function changelogBetween(markdown, from, to2) {
|
|
46983
47008
|
const entries = [];
|
|
@@ -48604,7 +48629,7 @@ export const APP_TAGLINE = "Build your app in src/pages/HomePage.tsx.";
|
|
|
48604
48629
|
|
|
48605
48630
|
// "Continue with \u2026" buttons above the email form, in this order. The platform
|
|
48606
48631
|
// owns the OAuth clients. Add providers when this app uses social sign-in:
|
|
48607
|
-
// add '
|
|
48632
|
+
// add 'google' / 'discord' and deploy. GitHub sign-in is not available.
|
|
48608
48633
|
export const SIGN_IN_PROVIDERS: SignInProvider[] = [];
|
|
48609
48634
|
export const SHOW_EMAIL_VERIFICATION = false;
|
|
48610
48635
|
`;
|
|
@@ -52781,10 +52806,10 @@ function registerProject(program2) {
|
|
|
52781
52806
|
process.exit(1);
|
|
52782
52807
|
}
|
|
52783
52808
|
});
|
|
52784
|
-
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) => {
|
|
52785
52810
|
const unsupported = opts.yes ? "--yes" : opts.force ? "--force" : void 0;
|
|
52786
52811
|
if (unsupported) {
|
|
52787
|
-
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>.`;
|
|
52788
52813
|
if (opts.json)
|
|
52789
52814
|
printJsonError("UNKNOWN_OPTION", message3);
|
|
52790
52815
|
else
|
|
@@ -52895,23 +52920,11 @@ function registerProject(program2) {
|
|
|
52895
52920
|
});
|
|
52896
52921
|
}
|
|
52897
52922
|
async function resolveDeleteTarget(client, ref) {
|
|
52898
|
-
|
|
52899
|
-
|
|
52900
|
-
|
|
52901
|
-
|
|
52902
|
-
|
|
52903
|
-
if (PROJECT_ID_RE.test(ref))
|
|
52904
|
-
throw err;
|
|
52905
|
-
}
|
|
52906
|
-
const listed = await client.call("GET", "/projects", void 0, { q: ref, fields: "compact" });
|
|
52907
|
-
const refLower = ref.toLowerCase();
|
|
52908
|
-
const exact = listed.projects.filter((p2) => p2.id === ref || p2.name?.toLowerCase() === refLower || p2.subdomain?.toLowerCase() === refLower || p2.slug?.toLowerCase() === refLower);
|
|
52909
|
-
if (exact.length === 1)
|
|
52910
|
-
return exact[0];
|
|
52911
|
-
if (exact.length > 1) {
|
|
52912
|
-
throw new CliApiError("AMBIGUOUS_PROJECT", `Multiple projects match "${ref}". Delete by project ID or subdomain instead.`, 400);
|
|
52913
|
-
}
|
|
52914
|
-
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);
|
|
52915
52928
|
}
|
|
52916
52929
|
async function requestDeleteConfirmationCode(client, projectId) {
|
|
52917
52930
|
try {
|
|
@@ -74320,7 +74333,7 @@ var init_deploy_protected_files = __esm({
|
|
|
74320
74333
|
});
|
|
74321
74334
|
|
|
74322
74335
|
// dist/lib/role-method-hints.js
|
|
74323
|
-
import { existsSync as existsSync10, readdirSync as readdirSync2, readFileSync as
|
|
74336
|
+
import { existsSync as existsSync10, readdirSync as readdirSync2, readFileSync as readFileSync11 } from "node:fs";
|
|
74324
74337
|
import { createRequire as createRequire3 } from "node:module";
|
|
74325
74338
|
import { join as join11, relative as relative2, resolve as resolve4 } from "node:path";
|
|
74326
74339
|
function roleMethodHints(projectDir, { removedOnly = false } = {}) {
|
|
@@ -74359,7 +74372,7 @@ function roleMethodHints(projectDir, { removedOnly = false } = {}) {
|
|
|
74359
74372
|
}
|
|
74360
74373
|
if (!entry.isFile() || !/\.[cm]?[jt]sx?$/.test(entry.name) || /\.d\.ts$/.test(entry.name))
|
|
74361
74374
|
continue;
|
|
74362
|
-
const file = ts2.createSourceFile(path3,
|
|
74375
|
+
const file = ts2.createSourceFile(path3, readFileSync11(path3, "utf8"), ts2.ScriptTarget.Latest, true);
|
|
74363
74376
|
const exports = /* @__PURE__ */ new Set();
|
|
74364
74377
|
let unknown2 = false;
|
|
74365
74378
|
for (const statement of file.statements) {
|
|
@@ -74417,7 +74430,7 @@ var init_role_method_hints = __esm({
|
|
|
74417
74430
|
});
|
|
74418
74431
|
|
|
74419
74432
|
// dist/lib/notify/providers/update.js
|
|
74420
|
-
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";
|
|
74421
74434
|
import { dirname as dirname3, join as join12 } from "node:path";
|
|
74422
74435
|
function isNewer(a, b2) {
|
|
74423
74436
|
const parse3 = /* @__PURE__ */ __name((v2) => v2.split("-")[0].split(".").map((n) => Number(n)), "parse");
|
|
@@ -74433,7 +74446,7 @@ function isNewer(a, b2) {
|
|
|
74433
74446
|
}
|
|
74434
74447
|
function readCache(cachePath = CACHE_PATH) {
|
|
74435
74448
|
try {
|
|
74436
|
-
const c = JSON.parse(
|
|
74449
|
+
const c = JSON.parse(readFileSync12(cachePath, "utf8"));
|
|
74437
74450
|
if (typeof c?.checkedAt !== "number")
|
|
74438
74451
|
return null;
|
|
74439
74452
|
return c;
|
|
@@ -74496,7 +74509,7 @@ async function getOutdatedWarning(currentVersion3, options2 = {}) {
|
|
|
74496
74509
|
const warnedPath = options2.warnedPath ?? WARNED_PATH;
|
|
74497
74510
|
const now2 = (options2.now ?? Date.now)();
|
|
74498
74511
|
try {
|
|
74499
|
-
const warned2 = JSON.parse(
|
|
74512
|
+
const warned2 = JSON.parse(readFileSync12(warnedPath, "utf8"));
|
|
74500
74513
|
if (typeof warned2.warnedAt === "number" && now2 - warned2.warnedAt < ONE_DAY && now2 >= warned2.warnedAt)
|
|
74501
74514
|
return null;
|
|
74502
74515
|
} catch {
|
|
@@ -74568,7 +74581,7 @@ var init_update = __esm({
|
|
|
74568
74581
|
});
|
|
74569
74582
|
|
|
74570
74583
|
// dist/lib/notify/index.js
|
|
74571
|
-
import { readFileSync as
|
|
74584
|
+
import { readFileSync as readFileSync13 } from "node:fs";
|
|
74572
74585
|
import { join as join13 } from "node:path";
|
|
74573
74586
|
function suppressExitNotices() {
|
|
74574
74587
|
exitNoticesSuppressed = true;
|
|
@@ -74583,7 +74596,7 @@ function subcommandSuppressesNotifications(argv) {
|
|
|
74583
74596
|
}
|
|
74584
74597
|
function currentVersion() {
|
|
74585
74598
|
try {
|
|
74586
|
-
const pkg = JSON.parse(
|
|
74599
|
+
const pkg = JSON.parse(readFileSync13(join13(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
74587
74600
|
return pkg.version;
|
|
74588
74601
|
} catch {
|
|
74589
74602
|
return "0.0.0";
|
|
@@ -74646,19 +74659,19 @@ __export(declared_data_exports, {
|
|
|
74646
74659
|
localFilesContract: () => localFilesContract,
|
|
74647
74660
|
prepareDeclaredData: () => prepareDeclaredData
|
|
74648
74661
|
});
|
|
74649
|
-
import { existsSync as existsSync12, readFileSync as
|
|
74662
|
+
import { existsSync as existsSync12, readFileSync as readFileSync14, rmSync as rmSync3, writeFileSync as writeFileSync10 } from "node:fs";
|
|
74650
74663
|
import { createRequire as createRequire4 } from "node:module";
|
|
74651
74664
|
import { join as join14, resolve as resolve5 } from "node:path";
|
|
74652
74665
|
function localFilesContract(projectDir) {
|
|
74653
74666
|
const path3 = join14(projectDir, "db", "schema.ts");
|
|
74654
74667
|
const generator = require4("./runtime/declared-data.cjs");
|
|
74655
|
-
const digest = existsSync12(path3) && generator.filesContractFromFiles({ "db/schema.ts":
|
|
74668
|
+
const digest = existsSync12(path3) && generator.filesContractFromFiles({ "db/schema.ts": readFileSync14(path3, "utf8") });
|
|
74656
74669
|
if (!digest)
|
|
74657
74670
|
throw new Error("Declare file collections in db/schema.ts and deploy the app before testing files.");
|
|
74658
74671
|
return { digest, singleRequestMaxBytes: generator.SINGLE_REQUEST_MAX_BYTES };
|
|
74659
74672
|
}
|
|
74660
74673
|
function generatedContents(path3) {
|
|
74661
|
-
const previous = existsSync12(path3) ?
|
|
74674
|
+
const previous = existsSync12(path3) ? readFileSync14(path3, "utf8") : void 0;
|
|
74662
74675
|
if (previous !== void 0 && !previous.startsWith(GENERATED_DATA_HEADER)) {
|
|
74663
74676
|
throw new Error(`Cannot overwrite ${path3}; this path is reserved for a generated declaration.`);
|
|
74664
74677
|
}
|
|
@@ -74669,8 +74682,8 @@ function prepareDeclaredData(projectDir) {
|
|
|
74669
74682
|
const declarationDir = existsSync12(join14(projectDir, "src")) ? join14(projectDir, "src") : projectDir;
|
|
74670
74683
|
const declarationPath = join14(declarationDir, DATA_DECLARATION_FILE);
|
|
74671
74684
|
const filesPath = join14(declarationDir, FILES_DECLARATION_FILE);
|
|
74672
|
-
const previous = existsSync12(declarationPath) ?
|
|
74673
|
-
const previousFiles = existsSync12(filesPath) ?
|
|
74685
|
+
const previous = existsSync12(declarationPath) ? readFileSync14(declarationPath, "utf8") : void 0;
|
|
74686
|
+
const previousFiles = existsSync12(filesPath) ? readFileSync14(filesPath, "utf8") : void 0;
|
|
74674
74687
|
if (!existsSync12(schemaPath)) {
|
|
74675
74688
|
if (previousFiles?.startsWith(GENERATED_DATA_HEADER))
|
|
74676
74689
|
rmSync3(filesPath);
|
|
@@ -74691,7 +74704,7 @@ function prepareDeclaredData(projectDir) {
|
|
|
74691
74704
|
let filesDeclaration;
|
|
74692
74705
|
const generator = require4("./runtime/declared-data.cjs");
|
|
74693
74706
|
try {
|
|
74694
|
-
const files = { "db/schema.ts":
|
|
74707
|
+
const files = { "db/schema.ts": readFileSync14(schemaPath, "utf8") };
|
|
74695
74708
|
client = generator.generateFromFiles(files);
|
|
74696
74709
|
localDeclaration = generator.localDeclarationFromFiles(files);
|
|
74697
74710
|
tables = generator.declaredTablesFromFiles(files);
|
|
@@ -74813,7 +74826,7 @@ __export(typecheck_exports, {
|
|
|
74813
74826
|
typecheckTimeoutMs: () => typecheckTimeoutMs
|
|
74814
74827
|
});
|
|
74815
74828
|
import { spawn as spawn3, spawnSync } from "node:child_process";
|
|
74816
|
-
import { existsSync as existsSync13, readFileSync as
|
|
74829
|
+
import { existsSync as existsSync13, readFileSync as readFileSync15, rmSync as rmSync4, writeFileSync as writeFileSync11 } from "node:fs";
|
|
74817
74830
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
74818
74831
|
import { dirname as dirname4, join as join15, relative as relative3 } from "node:path";
|
|
74819
74832
|
function isGeneratedApiImport(e) {
|
|
@@ -74858,7 +74871,7 @@ function resolveTsc(projectDir) {
|
|
|
74858
74871
|
function declaredDependencies(projectDir) {
|
|
74859
74872
|
let manifest;
|
|
74860
74873
|
try {
|
|
74861
|
-
manifest = JSON.parse(
|
|
74874
|
+
manifest = JSON.parse(readFileSync15(join15(projectDir, "package.json"), "utf8"));
|
|
74862
74875
|
} catch {
|
|
74863
74876
|
return {};
|
|
74864
74877
|
}
|
|
@@ -77076,7 +77089,7 @@ __export(files_exports, {
|
|
|
77076
77089
|
testFolderOf: () => testFolderOf
|
|
77077
77090
|
});
|
|
77078
77091
|
import { isUtf8 } from "node:buffer";
|
|
77079
|
-
import { closeSync as closeSync4, existsSync as existsSync14, openSync as openSync4, 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";
|
|
77080
77093
|
import { extname as extname3, isAbsolute as isAbsolute2, join as join18, posix as posix2, relative as relative6 } from "node:path";
|
|
77081
77094
|
function isTestSourcePath(relPath) {
|
|
77082
77095
|
return TEST_SOURCE_NAME.test(relPath.slice(relPath.lastIndexOf("/") + 1));
|
|
@@ -77174,7 +77187,7 @@ function collectFiles(baseDir, options2 = {}) {
|
|
|
77174
77187
|
const inlineFileLimit = options2.inlineFileLimitBytes ?? MAX_FILE_SIZE;
|
|
77175
77188
|
const corpusFiles = /* @__PURE__ */ __name((paths) => paths.filter((relPath) => isReferenceCorpusPath(relPath) && (sizes.get(relPath) ?? 0) <= inlineFileLimit).map((relPath) => {
|
|
77176
77189
|
try {
|
|
77177
|
-
return [relPath,
|
|
77190
|
+
return [relPath, readFileSync16(join18(baseDir, relPath), "utf-8")];
|
|
77178
77191
|
} catch {
|
|
77179
77192
|
return [relPath, ""];
|
|
77180
77193
|
}
|
|
@@ -77260,7 +77273,7 @@ function looksLikeCliCredential(path3, bytes, header) {
|
|
|
77260
77273
|
} finally {
|
|
77261
77274
|
closeSync4(fd);
|
|
77262
77275
|
}
|
|
77263
|
-
const text =
|
|
77276
|
+
const text = readFileSync16(path3, "utf8").trim();
|
|
77264
77277
|
const cliKey = /^(?:smt|smtr)_[a-z0-9_-]+$/i;
|
|
77265
77278
|
if (cliKey.test(text))
|
|
77266
77279
|
return true;
|
|
@@ -77298,7 +77311,7 @@ function walk(baseDir, currentDir, out, ignore, candidates, sizes, credentialHea
|
|
|
77298
77311
|
out.sensitive.push({ path: relPath, reason: SENSITIVE_FILE_REASON, referencedBy: [] });
|
|
77299
77312
|
continue;
|
|
77300
77313
|
}
|
|
77301
|
-
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))
|
|
77302
77315
|
continue;
|
|
77303
77316
|
const bytes = statSync2(fullPath).size;
|
|
77304
77317
|
if (credentialHeader && looksLikeCliCredential(fullPath, bytes, credentialHeader)) {
|
|
@@ -77325,7 +77338,7 @@ function classifyKey(relPath) {
|
|
|
77325
77338
|
}
|
|
77326
77339
|
function classifyInto(out, baseDir, relPath, readBinary = true) {
|
|
77327
77340
|
const { kind, key } = classifyKey(relPath);
|
|
77328
|
-
const bytes = kind === "binary" && !readBinary ? Buffer.alloc(0) :
|
|
77341
|
+
const bytes = kind === "binary" && !readBinary ? Buffer.alloc(0) : readFileSync16(join18(baseDir, relPath));
|
|
77329
77342
|
const binary = kind === "binary" || !isUtf8(bytes);
|
|
77330
77343
|
if (binary) {
|
|
77331
77344
|
if (kind === "function")
|
|
@@ -77354,7 +77367,7 @@ function loadDeployIgnore(baseDir) {
|
|
|
77354
77367
|
const path3 = join18(baseDir, fileName2);
|
|
77355
77368
|
if (!existsSync14(path3))
|
|
77356
77369
|
continue;
|
|
77357
|
-
const lines =
|
|
77370
|
+
const lines = readFileSync16(path3, "utf8").split(/\r?\n/);
|
|
77358
77371
|
for (const raw of lines) {
|
|
77359
77372
|
const rule = parseIgnoreRule(raw);
|
|
77360
77373
|
if (!rule)
|
|
@@ -77627,12 +77640,12 @@ var init_files = __esm({
|
|
|
77627
77640
|
|
|
77628
77641
|
// dist/lib/deploy-check.js
|
|
77629
77642
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
77630
|
-
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";
|
|
77631
77644
|
import { createRequire as createRequire5 } from "node:module";
|
|
77632
77645
|
import { isAbsolute as isAbsolute3, join as join19, relative as relative7, resolve as resolve8 } from "node:path";
|
|
77633
77646
|
function projectTypeScriptVersion(projectDir) {
|
|
77634
77647
|
try {
|
|
77635
|
-
const version2 = JSON.parse(
|
|
77648
|
+
const version2 = JSON.parse(readFileSync17(join19(projectDir, "node_modules", "typescript", "package.json"), "utf8")).version;
|
|
77636
77649
|
return typeof version2 === "string" && version2 ? version2 : null;
|
|
77637
77650
|
} catch {
|
|
77638
77651
|
return null;
|
|
@@ -77749,7 +77762,7 @@ async function startDeployCheck(projectDir, onFetch) {
|
|
|
77749
77762
|
return { ok: true, findings: [], typescript, checkedFiles: 0 };
|
|
77750
77763
|
const { command, args } = deployCheckTsc(projectDir);
|
|
77751
77764
|
const tsconfigPath = join19(projectDir, "tsconfig.json");
|
|
77752
|
-
const own2 = projectCompilerOptions(existsSync15(tsconfigPath) ?
|
|
77765
|
+
const own2 = projectCompilerOptions(existsSync15(tsconfigPath) ? readFileSync17(tsconfigPath, "utf8") : void 0);
|
|
77753
77766
|
const id = randomUUID5();
|
|
77754
77767
|
const config2 = join19(projectDir, `.__somewhere_deploy_check_${id}.json`);
|
|
77755
77768
|
const declarationsDir = join19(projectDir, `.__somewhere_deploy_check_${id}`);
|
|
@@ -77822,7 +77835,7 @@ var init_deploy_check = __esm({
|
|
|
77822
77835
|
});
|
|
77823
77836
|
|
|
77824
77837
|
// dist/lib/agent-hooks.js
|
|
77825
|
-
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";
|
|
77826
77839
|
import { homedir as homedir2 } from "node:os";
|
|
77827
77840
|
import { delimiter, dirname as dirname7, isAbsolute as isAbsolute4, join as join20, relative as relative8, resolve as resolve9, sep } from "node:path";
|
|
77828
77841
|
function isAgentHost(value) {
|
|
@@ -77860,7 +77873,7 @@ function readConfig(path3) {
|
|
|
77860
77873
|
if (!existsSync16(path3))
|
|
77861
77874
|
return {};
|
|
77862
77875
|
try {
|
|
77863
|
-
const parsed = JSON.parse(
|
|
77876
|
+
const parsed = JSON.parse(readFileSync18(path3, "utf8"));
|
|
77864
77877
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : new Error("is not a JSON object");
|
|
77865
77878
|
} catch (error3) {
|
|
77866
77879
|
return error3 instanceof Error ? error3 : new Error(String(error3));
|
|
@@ -78000,7 +78013,7 @@ function hookProjectRoot(host, payload, env = process.env, cwd = process.cwd())
|
|
|
78000
78013
|
return null;
|
|
78001
78014
|
for (let dir = resolve9(start); ; dir = dirname7(dir)) {
|
|
78002
78015
|
const config2 = join20(dir, HOSTS[host].configPath);
|
|
78003
|
-
if (existsSync16(config2) && HOOK_MARKER.test(
|
|
78016
|
+
if (existsSync16(config2) && HOOK_MARKER.test(readFileSync18(config2, "utf8")))
|
|
78004
78017
|
return dir;
|
|
78005
78018
|
if (dirname7(dir) === dir)
|
|
78006
78019
|
return null;
|
|
@@ -78202,7 +78215,7 @@ __export(source_lint_exports, {
|
|
|
78202
78215
|
});
|
|
78203
78216
|
import { createRequire as createRequire6 } from "node:module";
|
|
78204
78217
|
import { performance as performance2 } from "node:perf_hooks";
|
|
78205
|
-
import { readdirSync as readdirSync4, readFileSync as
|
|
78218
|
+
import { readdirSync as readdirSync4, readFileSync as readFileSync19, statSync as statSync4 } from "node:fs";
|
|
78206
78219
|
import { join as join22 } from "node:path";
|
|
78207
78220
|
async function lintProject(directory2, options2 = {}) {
|
|
78208
78221
|
const started = performance2.now();
|
|
@@ -78317,7 +78330,7 @@ function readHeldBackTests(root, paths) {
|
|
|
78317
78330
|
return;
|
|
78318
78331
|
}
|
|
78319
78332
|
if (stat7?.isFile() && SOURCE2.test(rel) && stat7.size <= 1024 * 1024)
|
|
78320
|
-
out[rel] =
|
|
78333
|
+
out[rel] = readFileSync19(full, "utf8");
|
|
78321
78334
|
}, "visit");
|
|
78322
78335
|
for (const path3 of paths)
|
|
78323
78336
|
visit(path3);
|
|
@@ -78950,7 +78963,7 @@ var init_live_refusal = __esm({
|
|
|
78950
78963
|
});
|
|
78951
78964
|
|
|
78952
78965
|
// dist/lib/build-errors.js
|
|
78953
|
-
import { existsSync as existsSync19, readFileSync as
|
|
78966
|
+
import { existsSync as existsSync19, readFileSync as readFileSync20 } from "node:fs";
|
|
78954
78967
|
import { isAbsolute as isAbsolute5, join as join24 } from "node:path";
|
|
78955
78968
|
function parseBundleErrorText(text) {
|
|
78956
78969
|
const out = [];
|
|
@@ -78984,7 +78997,7 @@ function frameFor(detail, baseDir, serverFrame) {
|
|
|
78984
78997
|
const abs = isAbsolute5(detail.file) ? detail.file : join24(baseDir, detail.file);
|
|
78985
78998
|
if (existsSync19(abs)) {
|
|
78986
78999
|
try {
|
|
78987
|
-
const frame = localCodeFrame(
|
|
79000
|
+
const frame = localCodeFrame(readFileSync20(abs, "utf-8"), detail.line, detail.column);
|
|
78988
79001
|
if (frame)
|
|
78989
79002
|
return frame;
|
|
78990
79003
|
} catch {
|
|
@@ -79253,7 +79266,7 @@ var init_temp_auth = __esm({
|
|
|
79253
79266
|
});
|
|
79254
79267
|
|
|
79255
79268
|
// dist/lib/project-notices.js
|
|
79256
|
-
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";
|
|
79257
79270
|
import { dirname as dirname8, join as join26 } from "node:path";
|
|
79258
79271
|
function localDay(now2) {
|
|
79259
79272
|
const date4 = new Date(now2);
|
|
@@ -79263,7 +79276,7 @@ function readState(path3) {
|
|
|
79263
79276
|
if (!existsSync20(path3))
|
|
79264
79277
|
return { shown: {} };
|
|
79265
79278
|
try {
|
|
79266
|
-
const parsed = JSON.parse(
|
|
79279
|
+
const parsed = JSON.parse(readFileSync21(path3, "utf8"));
|
|
79267
79280
|
return parsed.shown && typeof parsed.shown === "object" ? { shown: parsed.shown } : { shown: {} };
|
|
79268
79281
|
} catch {
|
|
79269
79282
|
return { shown: {} };
|
|
@@ -79315,7 +79328,7 @@ var init_project_notices = __esm({
|
|
|
79315
79328
|
});
|
|
79316
79329
|
|
|
79317
79330
|
// dist/lib/test-identities.js
|
|
79318
|
-
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";
|
|
79319
79332
|
import { join as join27 } from "node:path";
|
|
79320
79333
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
79321
79334
|
function parseActorSpecs(values) {
|
|
@@ -79372,7 +79385,7 @@ ${TEST_STATE_GITIGNORE_LINE}
|
|
|
79372
79385
|
`);
|
|
79373
79386
|
return "created";
|
|
79374
79387
|
}
|
|
79375
|
-
const text =
|
|
79388
|
+
const text = readFileSync22(path3, "utf8");
|
|
79376
79389
|
const lines = text.split(/\r?\n/).map((line) => line.trim());
|
|
79377
79390
|
if (lines.some((line) => [".somewhere/test/", ".somewhere/test", "/.somewhere/test/", "/.somewhere/test", ".somewhere/", ".somewhere", "/.somewhere/", "/.somewhere"].includes(line)))
|
|
79378
79391
|
return "present";
|
|
@@ -79389,7 +79402,7 @@ function readManifest(root) {
|
|
|
79389
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");
|
|
79390
79403
|
let value;
|
|
79391
79404
|
try {
|
|
79392
|
-
value = JSON.parse(
|
|
79405
|
+
value = JSON.parse(readFileSync22(path3, "utf8"));
|
|
79393
79406
|
} catch {
|
|
79394
79407
|
throw invalid("not JSON");
|
|
79395
79408
|
}
|
|
@@ -79417,7 +79430,7 @@ function preparedActorState(root, target, name) {
|
|
|
79417
79430
|
const domain = new URL(target.origin).hostname;
|
|
79418
79431
|
let state;
|
|
79419
79432
|
try {
|
|
79420
|
-
state = JSON.parse(
|
|
79433
|
+
state = JSON.parse(readFileSync22(path3, "utf8"));
|
|
79421
79434
|
} catch {
|
|
79422
79435
|
throw new Error("Could not read the saved test user session.");
|
|
79423
79436
|
}
|
|
@@ -79586,7 +79599,7 @@ var init_test_identities = __esm({
|
|
|
79586
79599
|
});
|
|
79587
79600
|
|
|
79588
79601
|
// dist/lib/form-accounts.js
|
|
79589
|
-
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";
|
|
79590
79603
|
import { join as join28 } from "node:path";
|
|
79591
79604
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
79592
79605
|
function readDeletionAnswer(ids, answer) {
|
|
@@ -79683,7 +79696,7 @@ function recordAttempt(control, root, email2) {
|
|
|
79683
79696
|
return path3;
|
|
79684
79697
|
}
|
|
79685
79698
|
function recordId(path3, id) {
|
|
79686
|
-
const record3 = JSON.parse(
|
|
79699
|
+
const record3 = JSON.parse(readFileSync23(path3, "utf8"));
|
|
79687
79700
|
writePrivateFile(path3, JSON.stringify({ ...record3, id }) + "\n");
|
|
79688
79701
|
}
|
|
79689
79702
|
function forgetRecord(path3) {
|
|
@@ -79719,7 +79732,7 @@ async function sweepAccounts(control, root) {
|
|
|
79719
79732
|
const path3 = join28(dir, name);
|
|
79720
79733
|
let record3;
|
|
79721
79734
|
try {
|
|
79722
|
-
record3 = JSON.parse(
|
|
79735
|
+
record3 = JSON.parse(readFileSync23(path3, "utf8"));
|
|
79723
79736
|
} catch {
|
|
79724
79737
|
result.failed.push(name);
|
|
79725
79738
|
continue;
|
|
@@ -79906,14 +79919,14 @@ var init_test_target = __esm({
|
|
|
79906
79919
|
});
|
|
79907
79920
|
|
|
79908
79921
|
// dist/lib/preview-credential.js
|
|
79909
|
-
import { existsSync as existsSync23, readFileSync as
|
|
79922
|
+
import { existsSync as existsSync23, readFileSync as readFileSync24, unlinkSync as unlinkSync4 } from "node:fs";
|
|
79910
79923
|
import { join as join29 } from "node:path";
|
|
79911
79924
|
function loadPreviewCredential(projectId, previewSessionId) {
|
|
79912
79925
|
const path3 = join29(cliConfigDir(), SUBDIR, fileName(projectId, previewSessionId));
|
|
79913
79926
|
if (!existsSync23(path3))
|
|
79914
79927
|
return null;
|
|
79915
79928
|
try {
|
|
79916
|
-
const stored = JSON.parse(
|
|
79929
|
+
const stored = JSON.parse(readFileSync24(path3, "utf8"));
|
|
79917
79930
|
return stored.project_id === projectId && stored.preview_session_id === previewSessionId && typeof stored.credential === "string" ? stored.credential : null;
|
|
79918
79931
|
} catch {
|
|
79919
79932
|
return null;
|
|
@@ -79957,14 +79970,14 @@ var init_preview_credential = __esm({
|
|
|
79957
79970
|
});
|
|
79958
79971
|
|
|
79959
79972
|
// dist/lib/preview-record.js
|
|
79960
|
-
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";
|
|
79961
79974
|
import { join as join30 } from "node:path";
|
|
79962
79975
|
function loadPreviewRecord(dir, projectId) {
|
|
79963
79976
|
const path3 = join30(dir, PREVIEW_RECORD);
|
|
79964
79977
|
if (!existsSync24(path3))
|
|
79965
79978
|
return null;
|
|
79966
79979
|
try {
|
|
79967
|
-
const parsed = JSON.parse(
|
|
79980
|
+
const parsed = JSON.parse(readFileSync25(path3, "utf8"));
|
|
79968
79981
|
if (parsed.project_id !== projectId || typeof parsed.preview_session_id !== "string" || typeof parsed.preview_id !== "string" || !isRecord(parsed.files))
|
|
79969
79982
|
return null;
|
|
79970
79983
|
return parsed;
|
|
@@ -80368,7 +80381,7 @@ import { createRequire as createRequire7 } from "node:module";
|
|
|
80368
80381
|
import { pathToFileURL } from "node:url";
|
|
80369
80382
|
import { join as join32, dirname as dirname9 } from "node:path";
|
|
80370
80383
|
import { spawn as spawn4, spawnSync as spawnSync3 } from "node:child_process";
|
|
80371
|
-
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";
|
|
80372
80385
|
import { createHash as createHash6, randomUUID as randomUUID6 } from "node:crypto";
|
|
80373
80386
|
function testImportEnv(root, env) {
|
|
80374
80387
|
if (!readProjectPin(root)?.versionOnly)
|
|
@@ -80415,7 +80428,7 @@ async function prepareRunner(root) {
|
|
|
80415
80428
|
mark("browser-probe:end");
|
|
80416
80429
|
let playwright = "unknown";
|
|
80417
80430
|
try {
|
|
80418
|
-
playwright = JSON.parse(
|
|
80431
|
+
playwright = JSON.parse(readFileSync26(join32(dirname9(cli), "package.json"), "utf8")).version ?? "unknown";
|
|
80419
80432
|
} catch {
|
|
80420
80433
|
}
|
|
80421
80434
|
return { cli, channel, version: version2, browserLaunchMs, playwright };
|
|
@@ -80447,7 +80460,7 @@ async function runTests(input) {
|
|
|
80447
80460
|
const dir = join32(root, ".somewhere", "tests");
|
|
80448
80461
|
ensurePrivateDir(dir);
|
|
80449
80462
|
const ignorePath = join32(root, ".gitignore");
|
|
80450
|
-
const ignored = existsSync25(ignorePath) ?
|
|
80463
|
+
const ignored = existsSync25(ignorePath) ? readFileSync26(ignorePath, "utf8") : "";
|
|
80451
80464
|
for (const line of [".somewhere/", "playwright-report/", "test-results/"])
|
|
80452
80465
|
if (!ignored.split(/\r?\n/).includes(line))
|
|
80453
80466
|
appendFileSync2(ignorePath, `
|
|
@@ -80461,7 +80474,7 @@ ${line}
|
|
|
80461
80474
|
const artifacts = join32(dir, createHash6("sha256").update(projectId + origin + (target.environment === "preview" ? `${target.previewSessionId}:${target.releaseId}` : "")).digest("hex").slice(0, 16));
|
|
80462
80475
|
if (failed) {
|
|
80463
80476
|
const lastRun = join32(artifacts, ".last-run.json");
|
|
80464
|
-
if (!existsSync25(lastRun) || !JSON.parse(
|
|
80477
|
+
if (!existsSync25(lastRun) || !JSON.parse(readFileSync26(lastRun, "utf8")).failedTests?.length) {
|
|
80465
80478
|
throw new Error("No failed tests are recorded from the last run here; run somewhere test.");
|
|
80466
80479
|
}
|
|
80467
80480
|
}
|
|
@@ -80508,7 +80521,7 @@ ${line}
|
|
|
80508
80521
|
}, "cleanArtifacts");
|
|
80509
80522
|
cleanArtifacts(artifacts);
|
|
80510
80523
|
const exitCode = status === null ? 1 : status || (after === null || after.failed.length || after.unknownId.length ? 1 : 0);
|
|
80511
|
-
const results = existsSync25(resultsPath) ? JSON.parse(
|
|
80524
|
+
const results = existsSync25(resultsPath) ? JSON.parse(readFileSync26(resultsPath, "utf8")) : null;
|
|
80512
80525
|
return { exitCode, results, target };
|
|
80513
80526
|
}
|
|
80514
80527
|
var init_test_run = __esm({
|
|
@@ -80823,7 +80836,7 @@ var init_browser_refusal = __esm({
|
|
|
80823
80836
|
});
|
|
80824
80837
|
|
|
80825
80838
|
// dist/lib/browser-actions.js
|
|
80826
|
-
import { readFileSync as
|
|
80839
|
+
import { readFileSync as readFileSync27, statSync as statSync5 } from "node:fs";
|
|
80827
80840
|
import { basename as basename5, extname as extname4, resolve as resolve12 } from "node:path";
|
|
80828
80841
|
function decodedBase64Bytes(base642) {
|
|
80829
80842
|
if (!base642 || base642.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(base642))
|
|
@@ -80879,7 +80892,7 @@ function resolveBrowserUpload(raw, baseDir = process.cwd()) {
|
|
|
80879
80892
|
}
|
|
80880
80893
|
const name = basename5(absolute);
|
|
80881
80894
|
const contentType2 = MIME_TYPES[extname4(name).toLowerCase()] ?? "application/octet-stream";
|
|
80882
|
-
const bytes =
|
|
80895
|
+
const bytes = readFileSync27(absolute);
|
|
80883
80896
|
if (bytes.length > MAX_BROWSER_UPLOAD_BYTES) {
|
|
80884
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).`);
|
|
80885
80898
|
}
|
|
@@ -82035,7 +82048,7 @@ var init_verify_report = __esm({
|
|
|
82035
82048
|
|
|
82036
82049
|
// dist/commands/browser.js
|
|
82037
82050
|
import { dirname as dirname10, resolve as resolve14 } from "node:path";
|
|
82038
|
-
import { readFileSync as
|
|
82051
|
+
import { readFileSync as readFileSync28 } from "node:fs";
|
|
82039
82052
|
function readBrowserIncomplete(r) {
|
|
82040
82053
|
const raw = r.incomplete;
|
|
82041
82054
|
if (!raw || typeof raw !== "object")
|
|
@@ -82404,7 +82417,7 @@ function registerBrowser(program2) {
|
|
|
82404
82417
|
const collectActionsFile = /* @__PURE__ */ __name((file) => {
|
|
82405
82418
|
try {
|
|
82406
82419
|
const absolute = resolve14(file);
|
|
82407
|
-
const raw = JSON.parse(
|
|
82420
|
+
const raw = JSON.parse(readFileSync28(absolute, "utf8"));
|
|
82408
82421
|
const normalized = normalizeBrowserActions(raw, dirname10(absolute));
|
|
82409
82422
|
if (!normalized.ok)
|
|
82410
82423
|
throw new InvalidArgumentError(normalized.error);
|
|
@@ -82558,7 +82571,7 @@ var init_browser = __esm({
|
|
|
82558
82571
|
|
|
82559
82572
|
// dist/lib/verify-keep.js
|
|
82560
82573
|
import { createHash as createHash7, randomBytes as randomBytes5 } from "node:crypto";
|
|
82561
|
-
import { closeSync as closeSync5, existsSync as existsSync27, openSync as openSync5, readFileSync 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";
|
|
82562
82575
|
import { join as join36 } from "node:path";
|
|
82563
82576
|
function path(root) {
|
|
82564
82577
|
return join36(stateDir(root), KEEP_FILE);
|
|
@@ -82567,7 +82580,7 @@ function readFile(root) {
|
|
|
82567
82580
|
if (!existsSync27(path(root)))
|
|
82568
82581
|
return {};
|
|
82569
82582
|
try {
|
|
82570
|
-
const parsed = JSON.parse(
|
|
82583
|
+
const parsed = JSON.parse(readFileSync29(path(root), "utf-8"));
|
|
82571
82584
|
return parsed && typeof parsed === "object" ? parsed : {};
|
|
82572
82585
|
} catch {
|
|
82573
82586
|
return {};
|
|
@@ -82639,7 +82652,7 @@ function lockKeep(root, key, now2 = Date.now()) {
|
|
|
82639
82652
|
throw cause;
|
|
82640
82653
|
let stale = true;
|
|
82641
82654
|
try {
|
|
82642
|
-
const held = JSON.parse(
|
|
82655
|
+
const held = JSON.parse(readFileSync29(lock, "utf-8"));
|
|
82643
82656
|
const alive2 = typeof held.pid === "number" && (() => {
|
|
82644
82657
|
try {
|
|
82645
82658
|
process.kill(held.pid, 0);
|
|
@@ -82761,7 +82774,7 @@ var init_verify_keep = __esm({
|
|
|
82761
82774
|
|
|
82762
82775
|
// dist/commands/verify.js
|
|
82763
82776
|
import { randomBytes as randomBytes6 } from "node:crypto";
|
|
82764
|
-
import { existsSync as existsSync28, readFileSync as
|
|
82777
|
+
import { existsSync as existsSync28, readFileSync as readFileSync30 } from "node:fs";
|
|
82765
82778
|
import { dirname as dirname11, resolve as resolve15 } from "node:path";
|
|
82766
82779
|
function navigationRetryNote(retries) {
|
|
82767
82780
|
if (!retries.length)
|
|
@@ -82982,7 +82995,7 @@ function normalizeVerifyFlow(raw, baseDir = process.cwd()) {
|
|
|
82982
82995
|
function readVerifyFlowFile(absolute, flag) {
|
|
82983
82996
|
let source;
|
|
82984
82997
|
try {
|
|
82985
|
-
source =
|
|
82998
|
+
source = readFileSync30(absolute, "utf8");
|
|
82986
82999
|
} catch (cause) {
|
|
82987
83000
|
if (cause instanceof Error && "code" in cause && cause.code === "ENOENT") {
|
|
82988
83001
|
throw new Error(`Flow file not found. Pass ${flag} <path> with an existing JSON file. Run \`${cliInvocation()} verify --schema\` for the flow format.`);
|
|
@@ -84581,7 +84594,7 @@ var init_verify = __esm({
|
|
|
84581
84594
|
});
|
|
84582
84595
|
|
|
84583
84596
|
// dist/commands/deploy.js
|
|
84584
|
-
import { existsSync as existsSync29, readFileSync as
|
|
84597
|
+
import { existsSync as existsSync29, readFileSync as readFileSync31, realpathSync as realpathSync4 } from "node:fs";
|
|
84585
84598
|
import { isAbsolute as isAbsolute6, join as join37, relative as relative10, sep as sep2 } from "node:path";
|
|
84586
84599
|
import { basename as basename6, resolve as resolve16 } from "node:path";
|
|
84587
84600
|
function resolveTargetDir(dir, cwd = process.cwd()) {
|
|
@@ -85838,13 +85851,14 @@ ${dim("Build")}`);
|
|
|
85838
85851
|
process.exit(1);
|
|
85839
85852
|
}
|
|
85840
85853
|
if (err instanceof CliApiError && targetFromLink && !deployAnswered && (err.code === "PROJECT_NOT_FOUND" || err.code === "FORBIDDEN" && err.statusCode === 403)) {
|
|
85841
|
-
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);
|
|
85842
85856
|
if (opts.json) {
|
|
85843
85857
|
printJsonError(err.code, message3, {
|
|
85844
85858
|
...platformErrorEnvelope(err)?.extra ?? {},
|
|
85845
85859
|
linked_project_id: projectId,
|
|
85846
85860
|
deployed: false,
|
|
85847
|
-
next_steps: [
|
|
85861
|
+
next_steps: [nextStep]
|
|
85848
85862
|
});
|
|
85849
85863
|
} else {
|
|
85850
85864
|
error(message3, void 0, err);
|
|
@@ -85969,7 +85983,7 @@ function withLocalEnvHint(warning, dir) {
|
|
|
85969
85983
|
if (!key)
|
|
85970
85984
|
return warning;
|
|
85971
85985
|
try {
|
|
85972
|
-
const source =
|
|
85986
|
+
const source = readFileSync31(join37(dir, ".env"), "utf8");
|
|
85973
85987
|
if (new RegExp(`^\\s*(?:export\\s+)?${key}\\s*=`, "m").test(source)) {
|
|
85974
85988
|
return `${warning} Copy ${key} from your local .env file.`;
|
|
85975
85989
|
}
|
|
@@ -86485,7 +86499,7 @@ var init_deploys = __esm({
|
|
|
86485
86499
|
});
|
|
86486
86500
|
|
|
86487
86501
|
// dist/commands/pull.js
|
|
86488
|
-
import { existsSync as existsSync30, lstatSync as lstatSync5, mkdirSync as mkdirSync15, readFileSync 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";
|
|
86489
86503
|
import { basename as basename7, dirname as dirname12, join as join38, relative as relative11, resolve as resolve17 } from "node:path";
|
|
86490
86504
|
function registerPull(program2) {
|
|
86491
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) => {
|
|
@@ -86580,7 +86594,7 @@ function registerPull(program2) {
|
|
|
86580
86594
|
}
|
|
86581
86595
|
continue;
|
|
86582
86596
|
}
|
|
86583
|
-
const local =
|
|
86597
|
+
const local = readFileSync32(target);
|
|
86584
86598
|
if (local.equals(contents))
|
|
86585
86599
|
continue;
|
|
86586
86600
|
if (opts.force || Object.hasOwn(localScaffolds, path3)) {
|
|
@@ -86649,7 +86663,7 @@ function registerPull(program2) {
|
|
|
86649
86663
|
const scaffolded = scaffoldTypecheckFiles(outDir, body.static_files);
|
|
86650
86664
|
for (const path3 of scaffolded) {
|
|
86651
86665
|
if (path3 !== SCAFFOLD_GITIGNORE_FILENAME)
|
|
86652
|
-
localScaffolds[path3] = sha2562(
|
|
86666
|
+
localScaffolds[path3] = sha2562(readFileSync32(join38(outDir, path3)));
|
|
86653
86667
|
}
|
|
86654
86668
|
for (const path3 of source.keys())
|
|
86655
86669
|
delete localScaffolds[path3];
|
|
@@ -86740,7 +86754,7 @@ function planRemovedFiles(outDir, expected, force, base = null) {
|
|
|
86740
86754
|
const was = base?.files[relPath];
|
|
86741
86755
|
if (base && was === void 0)
|
|
86742
86756
|
continue;
|
|
86743
|
-
const unedited = was !== void 0 && was === sha2562(
|
|
86757
|
+
const unedited = was !== void 0 && was === sha2562(readFileSync32(fullPath));
|
|
86744
86758
|
if (!force && !unedited) {
|
|
86745
86759
|
skipped.push(relPath);
|
|
86746
86760
|
continue;
|
|
@@ -87378,7 +87392,7 @@ var init_rollback = __esm({
|
|
|
87378
87392
|
|
|
87379
87393
|
// dist/commands/restore.js
|
|
87380
87394
|
function registerRestore(program2) {
|
|
87381
|
-
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) => {
|
|
87382
87396
|
const fail5 = /* @__PURE__ */ __name((code, message3) => {
|
|
87383
87397
|
if (opts.json)
|
|
87384
87398
|
printJsonError(code, message3);
|
|
@@ -87980,7 +87994,6 @@ var init_db = __esm({
|
|
|
87980
87994
|
});
|
|
87981
87995
|
|
|
87982
87996
|
// dist/commands/postgres.js
|
|
87983
|
-
import { readFileSync as readFileSync34 } from "node:fs";
|
|
87984
87997
|
function str(value) {
|
|
87985
87998
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
87986
87999
|
}
|
|
@@ -87989,7 +88002,7 @@ async function readNeonApiKey() {
|
|
|
87989
88002
|
if (fromEnv)
|
|
87990
88003
|
return fromEnv;
|
|
87991
88004
|
if (!process.stdin.isTTY) {
|
|
87992
|
-
return
|
|
88005
|
+
return (await readAllStdin()).trim();
|
|
87993
88006
|
}
|
|
87994
88007
|
const response = await (0, import_prompts8.default)({
|
|
87995
88008
|
type: "password",
|
|
@@ -88289,6 +88302,7 @@ var init_postgres = __esm({
|
|
|
88289
88302
|
"dist/commands/postgres.js"() {
|
|
88290
88303
|
"use strict";
|
|
88291
88304
|
init_cli_invocation();
|
|
88305
|
+
init_stdin();
|
|
88292
88306
|
import_prompts8 = __toESM(require_prompts3(), 1);
|
|
88293
88307
|
init_client();
|
|
88294
88308
|
init_config();
|
|
@@ -88318,18 +88332,18 @@ var init_postgres = __esm({
|
|
|
88318
88332
|
});
|
|
88319
88333
|
|
|
88320
88334
|
// dist/lib/local-docs.js
|
|
88321
|
-
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";
|
|
88322
88336
|
import { join as join40 } from "node:path";
|
|
88323
88337
|
function localDocsVersion(root = process.cwd()) {
|
|
88324
88338
|
const path3 = join40(root, FOLDER, DOCS, STAMP);
|
|
88325
88339
|
if (!existsSync31(path3))
|
|
88326
88340
|
return void 0;
|
|
88327
|
-
const stamp2 = JSON.parse(
|
|
88341
|
+
const stamp2 = JSON.parse(readFileSync33(path3, "utf8"));
|
|
88328
88342
|
return typeof stamp2.version === "string" && /^[a-f0-9]{16}$/.test(stamp2.version) ? stamp2.version : void 0;
|
|
88329
88343
|
}
|
|
88330
88344
|
function ensureGitIgnore(root) {
|
|
88331
88345
|
const path3 = join40(root, ".gitignore");
|
|
88332
|
-
const text = existsSync31(path3) ?
|
|
88346
|
+
const text = existsSync31(path3) ? readFileSync33(path3, "utf8") : "";
|
|
88333
88347
|
if (text.split(/\r?\n/).some((line) => line === ".somewhere/" || line === "/.somewhere/"))
|
|
88334
88348
|
return;
|
|
88335
88349
|
appendFileSync3(path3, `${text && !text.endsWith("\n") ? "\n" : ""}/.somewhere/
|
|
@@ -88386,7 +88400,7 @@ var init_local_docs = __esm({
|
|
|
88386
88400
|
});
|
|
88387
88401
|
|
|
88388
88402
|
// dist/lib/advisor-context.js
|
|
88389
|
-
import { readFileSync as
|
|
88403
|
+
import { readFileSync as readFileSync34, statSync as statSync7 } from "node:fs";
|
|
88390
88404
|
import { basename as basename9 } from "node:path";
|
|
88391
88405
|
function tail(value, limit) {
|
|
88392
88406
|
return value.length <= limit ? value : `\u2026${value.slice(-limit)}`;
|
|
@@ -88408,7 +88422,7 @@ function buildAdvisorContext(filePath) {
|
|
|
88408
88422
|
const stat7 = statSync7(filePath);
|
|
88409
88423
|
if (!stat7.isFile())
|
|
88410
88424
|
throw new Error("--file must name a regular file.");
|
|
88411
|
-
const content =
|
|
88425
|
+
const content = readFileSync34(filePath, "utf8");
|
|
88412
88426
|
context.file = {
|
|
88413
88427
|
path: filePath,
|
|
88414
88428
|
content: tail(redactAdvisorText(content, isDotenvPath(filePath)), FILE_LIMIT)
|
|
@@ -88434,7 +88448,7 @@ var init_advisor_context = __esm({
|
|
|
88434
88448
|
|
|
88435
88449
|
// dist/lib/advisor-runs.js
|
|
88436
88450
|
import { randomBytes as randomBytes7, randomUUID as randomUUID8 } from "node:crypto";
|
|
88437
|
-
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";
|
|
88438
88452
|
import { join as join41 } from "node:path";
|
|
88439
88453
|
function path2(id) {
|
|
88440
88454
|
if (!/^[a-f0-9-]{36}$/i.test(id))
|
|
@@ -88471,7 +88485,7 @@ function expiredResult(record3) {
|
|
|
88471
88485
|
function load(id) {
|
|
88472
88486
|
if (!existsSync32(path2(id)))
|
|
88473
88487
|
throw Error("Advisor request was not found in this CLI configuration.");
|
|
88474
|
-
const record3 = JSON.parse(
|
|
88488
|
+
const record3 = JSON.parse(readFileSync35(path2(id), "utf8"));
|
|
88475
88489
|
prune(record3);
|
|
88476
88490
|
save(record3);
|
|
88477
88491
|
return record3;
|
|
@@ -88595,7 +88609,7 @@ var init_advisor_runs = __esm({
|
|
|
88595
88609
|
|
|
88596
88610
|
// dist/lib/advisor-app.js
|
|
88597
88611
|
import { createHash as createHash8 } from "node:crypto";
|
|
88598
|
-
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";
|
|
88599
88613
|
import { join as join42 } from "node:path";
|
|
88600
88614
|
async function gatherAdvisorApp(client, ref) {
|
|
88601
88615
|
const project = await client.call("GET", `/projects/${encodeURIComponent(ref)}`);
|
|
@@ -88630,7 +88644,7 @@ async function gatherAdvisorApp(client, ref) {
|
|
|
88630
88644
|
}
|
|
88631
88645
|
function loadAdvisorTurns(dir, projectId, account, now2 = Date.now()) {
|
|
88632
88646
|
try {
|
|
88633
|
-
const saved = JSON.parse(
|
|
88647
|
+
const saved = JSON.parse(readFileSync36(join42(dir, FILE), "utf8"));
|
|
88634
88648
|
if (saved.project_id !== projectId || saved.owner !== ownerOf(account) || !Array.isArray(saved.turns))
|
|
88635
88649
|
return [];
|
|
88636
88650
|
const last = saved.turns.at(-1);
|
|
@@ -88655,7 +88669,7 @@ function ensureAdvisorStateIgnored(dir) {
|
|
|
88655
88669
|
writeFileSync23(path3, "# somewhere: local CLI state (Advisor follow-ups, test users)\n.somewhere/\n");
|
|
88656
88670
|
return;
|
|
88657
88671
|
}
|
|
88658
|
-
const text =
|
|
88672
|
+
const text = readFileSync36(path3, "utf8");
|
|
88659
88673
|
if (text.split(/\r?\n/).map((l) => l.trim()).some((l) => covered.includes(l)))
|
|
88660
88674
|
return;
|
|
88661
88675
|
writeFileSync23(path3, `${text}${text.endsWith("\n") || !text ? "" : "\n"}
|
|
@@ -90084,8 +90098,8 @@ var init_envfile_write = __esm({
|
|
|
90084
90098
|
});
|
|
90085
90099
|
|
|
90086
90100
|
// dist/commands/env.js
|
|
90087
|
-
import { existsSync as existsSync34, readFileSync as
|
|
90088
|
-
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";
|
|
90089
90103
|
function resolveProjectId(explicit) {
|
|
90090
90104
|
if (explicit)
|
|
90091
90105
|
return explicit;
|
|
@@ -90096,6 +90110,17 @@ function resolveProjectId(explicit) {
|
|
|
90096
90110
|
}
|
|
90097
90111
|
return config2.project_id;
|
|
90098
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
|
+
}
|
|
90099
90124
|
function reportEnvError(err, json) {
|
|
90100
90125
|
const platform2 = platformErrorEnvelope(err);
|
|
90101
90126
|
if (platform2?.code === "TEMP_ACCOUNT_RESTRICTED") {
|
|
@@ -90166,7 +90191,7 @@ function registerEnv(program2) {
|
|
|
90166
90191
|
process.exit(1);
|
|
90167
90192
|
}
|
|
90168
90193
|
if (existsSync34(outPath) && !opts.force) {
|
|
90169
|
-
const existing =
|
|
90194
|
+
const existing = readFileSync37(outPath, "utf-8");
|
|
90170
90195
|
const hasValues = existing.split("\n").some((l) => /^[^#=]+=.+/.test(l.trim()));
|
|
90171
90196
|
const { ok } = await (0, import_prompts9.default)({
|
|
90172
90197
|
type: "confirm",
|
|
@@ -90203,25 +90228,25 @@ function registerEnv(program2) {
|
|
|
90203
90228
|
error("Pipe a value into --stdin.");
|
|
90204
90229
|
process.exit(1);
|
|
90205
90230
|
}
|
|
90206
|
-
|
|
90207
|
-
|
|
90208
|
-
|
|
90209
|
-
|
|
90210
|
-
|
|
90211
|
-
error("--provider must be at most 64 characters.");
|
|
90212
|
-
process.exit(1);
|
|
90213
|
-
}
|
|
90214
|
-
if (opts.purpose && opts.purpose.length > 240) {
|
|
90215
|
-
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");
|
|
90216
90236
|
process.exit(1);
|
|
90217
|
-
}
|
|
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.");
|
|
90218
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`;
|
|
90219
90245
|
if (inputNote && !opts.json)
|
|
90220
90246
|
process.stderr.write(`Note: ${inputNote}
|
|
90221
90247
|
`);
|
|
90222
|
-
const value = opts.stdin ? readFileSync39(0, "utf8").replace(/\r?\n$/, "") : positionalValue;
|
|
90223
90248
|
const client = new ApiClient(getToken());
|
|
90224
|
-
const pid =
|
|
90249
|
+
const pid = opts.project ?? loadProjectConfig()?.project_id ?? stop("No project. Pass --project or run from a linked directory." + unlinkedFolderHint());
|
|
90225
90250
|
try {
|
|
90226
90251
|
const result = await client.call("POST", "/env", {
|
|
90227
90252
|
project_id: pid,
|
|
@@ -90252,6 +90277,8 @@ function registerEnv(program2) {
|
|
|
90252
90277
|
warn(w2);
|
|
90253
90278
|
} catch (err) {
|
|
90254
90279
|
reportEnvError(err, Boolean(opts.json));
|
|
90280
|
+
if (opts.stdin)
|
|
90281
|
+
process.stderr.write(keepPipedValue(key, value) + "\n");
|
|
90255
90282
|
process.exit(1);
|
|
90256
90283
|
}
|
|
90257
90284
|
});
|
|
@@ -90279,17 +90306,19 @@ var init_env = __esm({
|
|
|
90279
90306
|
import_prompts9 = __toESM(require_prompts3(), 1);
|
|
90280
90307
|
init_client();
|
|
90281
90308
|
init_config();
|
|
90309
|
+
init_stdin();
|
|
90282
90310
|
init_envfile_write();
|
|
90283
90311
|
init_output();
|
|
90284
90312
|
init_link_hint();
|
|
90285
90313
|
__name(resolveProjectId, "resolveProjectId");
|
|
90314
|
+
__name(keepPipedValue, "keepPipedValue");
|
|
90286
90315
|
__name(reportEnvError, "reportEnvError");
|
|
90287
90316
|
__name(registerEnv, "registerEnv");
|
|
90288
90317
|
}
|
|
90289
90318
|
});
|
|
90290
90319
|
|
|
90291
90320
|
// dist/commands/run.js
|
|
90292
|
-
import { existsSync as existsSync35, readFileSync as
|
|
90321
|
+
import { existsSync as existsSync35, readFileSync as readFileSync38 } from "node:fs";
|
|
90293
90322
|
import { isAbsolute as isAbsolute7, resolve as resolve20 } from "node:path";
|
|
90294
90323
|
import { createRequire as createRequire8 } from "node:module";
|
|
90295
90324
|
function parseArgs(values) {
|
|
@@ -90360,7 +90389,7 @@ function registerRun(program2) {
|
|
|
90360
90389
|
error(`File not found: ${script}`);
|
|
90361
90390
|
process.exit(1);
|
|
90362
90391
|
}
|
|
90363
|
-
const code =
|
|
90392
|
+
const code = readFileSync38(absPath, "utf-8");
|
|
90364
90393
|
if (!code.trim()) {
|
|
90365
90394
|
error(`${script} is empty \u2014 nothing to run.`);
|
|
90366
90395
|
process.exit(1);
|
|
@@ -90798,7 +90827,7 @@ var init_claim = __esm({
|
|
|
90798
90827
|
import { createRequire as createRequire9 } from "node:module";
|
|
90799
90828
|
import { realpathSync as realpathSync5 } from "node:fs";
|
|
90800
90829
|
import { createConnection, createServer as createNetServer } from "node:net";
|
|
90801
|
-
import { join as
|
|
90830
|
+
import { join as join44 } from "node:path";
|
|
90802
90831
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
90803
90832
|
function deployedOrigin(value) {
|
|
90804
90833
|
const url3 = new URL(value);
|
|
@@ -90896,7 +90925,7 @@ async function startFrontendDev(cwd, target, port = 8787, open4 = false) {
|
|
|
90896
90925
|
throw new Error(INSTALL_PROJECT_DEPENDENCIES);
|
|
90897
90926
|
let vitePath;
|
|
90898
90927
|
try {
|
|
90899
|
-
vitePath = createRequire9(
|
|
90928
|
+
vitePath = createRequire9(join44(cwd, "package.json")).resolve("vite");
|
|
90900
90929
|
} catch {
|
|
90901
90930
|
if (readProjectPin(cwd)?.versionOnly) {
|
|
90902
90931
|
throw new Error("Install the local frontend tools: npm install -D --save-exact vite@7.2.2");
|
|
@@ -91040,7 +91069,7 @@ var init_preview_jobs = __esm({
|
|
|
91040
91069
|
// dist/commands/dev.js
|
|
91041
91070
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
91042
91071
|
import { existsSync as existsSync36 } from "node:fs";
|
|
91043
|
-
import { join as
|
|
91072
|
+
import { join as join45, relative as relative12 } from "node:path";
|
|
91044
91073
|
function previewFinishedReason(err) {
|
|
91045
91074
|
if (!(err instanceof CliApiError) || err.code !== "DRAFT_SESSION_TERMINAL")
|
|
91046
91075
|
return null;
|
|
@@ -92028,7 +92057,7 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
|
|
|
92028
92057
|
const updateBinary = {};
|
|
92029
92058
|
const deleteKeys = [];
|
|
92030
92059
|
for (const rel of changed) {
|
|
92031
|
-
const abs =
|
|
92060
|
+
const abs = join45(cwd, rel);
|
|
92032
92061
|
if (!existsSync36(abs))
|
|
92033
92062
|
continue;
|
|
92034
92063
|
classifyInto({ files: updateFiles, functions: updateFunctions, binaryFiles: updateBinary }, cwd, rel);
|
|
@@ -92094,7 +92123,7 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
|
|
|
92094
92123
|
for (const rel of deleted)
|
|
92095
92124
|
delete nextFiles[rel];
|
|
92096
92125
|
for (const rel of changed)
|
|
92097
|
-
if (existsSync36(
|
|
92126
|
+
if (existsSync36(join45(cwd, rel)))
|
|
92098
92127
|
Object.assign(nextFiles, hashFiles(cwd, [rel]));
|
|
92099
92128
|
savePreviewRecord(cwd, { ...record3, preview_id: nextCandidate, files: nextFiles });
|
|
92100
92129
|
}
|
|
@@ -92290,7 +92319,7 @@ var init_dev = __esm({
|
|
|
92290
92319
|
|
|
92291
92320
|
// dist/commands/check.js
|
|
92292
92321
|
import { existsSync as existsSync37 } from "node:fs";
|
|
92293
|
-
import { join as
|
|
92322
|
+
import { join as join46, resolve as resolve21 } from "node:path";
|
|
92294
92323
|
function buildCheckBody(collected, projectId) {
|
|
92295
92324
|
const body = { project_id: projectId, files: collected.files };
|
|
92296
92325
|
if (Object.keys(collected.functions).length > 0)
|
|
@@ -92395,7 +92424,7 @@ async function runLocalPreflight(targetDir, collected, typecheck = async (dir) =
|
|
|
92395
92424
|
if (collected.excluded.length)
|
|
92396
92425
|
source.not_published = collected.excluded;
|
|
92397
92426
|
let typecheckStep;
|
|
92398
|
-
if (!existsSync37(
|
|
92427
|
+
if (!existsSync37(join46(targetDir, "tsconfig.json"))) {
|
|
92399
92428
|
typecheckStep = { name: "typecheck", status: "skipped", reason: MISSING_TSCONFIG_GUIDANCE };
|
|
92400
92429
|
} else if (missingProjectDependencies(targetDir).length) {
|
|
92401
92430
|
typecheckStep = { name: "typecheck", status: "skipped", reason: missingTypecheckDependenciesMessage() };
|
|
@@ -92812,7 +92841,7 @@ var init_api2 = __esm({
|
|
|
92812
92841
|
import { createReadStream as createReadStream3, createWriteStream as createWriteStream3 } from "node:fs";
|
|
92813
92842
|
import { stat as stat6, rename as rename2, unlink as unlink2 } from "node:fs/promises";
|
|
92814
92843
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
92815
|
-
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";
|
|
92816
92845
|
import { pipeline as pipeline3 } from "node:stream/promises";
|
|
92817
92846
|
function registerFs(program2) {
|
|
92818
92847
|
const fs2 = program2.command("fs").description("Manage project file storage");
|
|
@@ -92856,7 +92885,7 @@ function registerFs(program2) {
|
|
|
92856
92885
|
if (!response.body)
|
|
92857
92886
|
throw new Error("The server returned an empty file response.");
|
|
92858
92887
|
const destination = resolve23(local);
|
|
92859
|
-
tempPath =
|
|
92888
|
+
tempPath = join47(dirname14(destination), `.${basename10(destination)}.${randomUUID10()}.tmp`);
|
|
92860
92889
|
await pipeline3(response.body, createWriteStream3(tempPath, { flags: "wx" }));
|
|
92861
92890
|
await rename2(tempPath, destination);
|
|
92862
92891
|
tempPath = void 0;
|
|
@@ -110666,7 +110695,7 @@ var require_polyfill = __commonJS({
|
|
|
110666
110695
|
var {
|
|
110667
110696
|
dirname: dirname18,
|
|
110668
110697
|
isAbsolute: isAbsolute8,
|
|
110669
|
-
join:
|
|
110698
|
+
join: join58,
|
|
110670
110699
|
parse: parse3,
|
|
110671
110700
|
resolve: resolve27,
|
|
110672
110701
|
sep: sep3,
|
|
@@ -110947,8 +110976,8 @@ var require_polyfill = __commonJS({
|
|
|
110947
110976
|
const dir = await readdir3(src);
|
|
110948
110977
|
for (let i = 0; i < dir.length; i++) {
|
|
110949
110978
|
const item = dir[i];
|
|
110950
|
-
const srcItem =
|
|
110951
|
-
const destItem =
|
|
110979
|
+
const srcItem = join58(src, item);
|
|
110980
|
+
const destItem = join58(dest, item);
|
|
110952
110981
|
const { destStat } = await checkPaths(srcItem, destItem, opts);
|
|
110953
110982
|
await startCopy(destStat, srcItem, destItem, opts);
|
|
110954
110983
|
}
|
|
@@ -111024,7 +111053,7 @@ var require_cp = __commonJS({
|
|
|
111024
111053
|
// node_modules/@npmcli/fs/lib/with-temp-dir.js
|
|
111025
111054
|
var require_with_temp_dir = __commonJS({
|
|
111026
111055
|
"node_modules/@npmcli/fs/lib/with-temp-dir.js"(exports, module) {
|
|
111027
|
-
var { join:
|
|
111056
|
+
var { join: join58, sep: sep3 } = __require("path");
|
|
111028
111057
|
var getOptions = require_get_options();
|
|
111029
111058
|
var { mkdir, mkdtemp, rm } = __require("fs/promises");
|
|
111030
111059
|
var withTempDir = /* @__PURE__ */ __name(async (root, fn, opts) => {
|
|
@@ -111032,7 +111061,7 @@ var require_with_temp_dir = __commonJS({
|
|
|
111032
111061
|
copy: ["tmpPrefix"]
|
|
111033
111062
|
});
|
|
111034
111063
|
await mkdir(root, { recursive: true });
|
|
111035
|
-
const target = await mkdtemp(
|
|
111064
|
+
const target = await mkdtemp(join58(`${root}${sep3}`, options2.tmpPrefix || ""));
|
|
111036
111065
|
let err;
|
|
111037
111066
|
let result;
|
|
111038
111067
|
try {
|
|
@@ -111057,13 +111086,13 @@ var require_with_temp_dir = __commonJS({
|
|
|
111057
111086
|
var require_readdir_scoped = __commonJS({
|
|
111058
111087
|
"node_modules/@npmcli/fs/lib/readdir-scoped.js"(exports, module) {
|
|
111059
111088
|
var { readdir: readdir3 } = __require("fs/promises");
|
|
111060
|
-
var { join:
|
|
111089
|
+
var { join: join58 } = __require("path");
|
|
111061
111090
|
var readdirScoped = /* @__PURE__ */ __name(async (dir) => {
|
|
111062
111091
|
const results = [];
|
|
111063
111092
|
for (const item of await readdir3(dir)) {
|
|
111064
111093
|
if (item.startsWith("@")) {
|
|
111065
|
-
for (const scopedItem of await readdir3(
|
|
111066
|
-
results.push(
|
|
111094
|
+
for (const scopedItem of await readdir3(join58(dir, item))) {
|
|
111095
|
+
results.push(join58(item, scopedItem));
|
|
111067
111096
|
}
|
|
111068
111097
|
} else {
|
|
111069
111098
|
results.push(item);
|
|
@@ -111078,7 +111107,7 @@ var require_readdir_scoped = __commonJS({
|
|
|
111078
111107
|
// node_modules/@npmcli/fs/lib/move-file.js
|
|
111079
111108
|
var require_move_file = __commonJS({
|
|
111080
111109
|
"node_modules/@npmcli/fs/lib/move-file.js"(exports, module) {
|
|
111081
|
-
var { dirname: dirname18, join:
|
|
111110
|
+
var { dirname: dirname18, join: join58, resolve: resolve27, relative: relative16, isAbsolute: isAbsolute8 } = __require("path");
|
|
111082
111111
|
var fs2 = __require("fs/promises");
|
|
111083
111112
|
var pathExists = /* @__PURE__ */ __name(async (path3) => {
|
|
111084
111113
|
try {
|
|
@@ -111108,7 +111137,7 @@ var require_move_file = __commonJS({
|
|
|
111108
111137
|
if (sourceStat.isDirectory()) {
|
|
111109
111138
|
const files = await fs2.readdir(source);
|
|
111110
111139
|
await Promise.all(files.map(
|
|
111111
|
-
(file) => moveFile(
|
|
111140
|
+
(file) => moveFile(join58(source, file), join58(destination, file), options2, false, symlinks)
|
|
111112
111141
|
));
|
|
111113
111142
|
} else if (sourceStat.isSymbolicLink()) {
|
|
111114
111143
|
symlinks.push({ source, destination });
|
|
@@ -130476,12 +130505,12 @@ var require_url = __commonJS({
|
|
|
130476
130505
|
"node_modules/tuf-js/dist/utils/url.js"(exports) {
|
|
130477
130506
|
"use strict";
|
|
130478
130507
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
130479
|
-
exports.join =
|
|
130508
|
+
exports.join = join58;
|
|
130480
130509
|
var url_1 = __require("url");
|
|
130481
|
-
function
|
|
130510
|
+
function join58(base, path3) {
|
|
130482
130511
|
return new url_1.URL(ensureTrailingSlash(base) + removeLeadingSlash(path3)).toString();
|
|
130483
130512
|
}
|
|
130484
|
-
__name(
|
|
130513
|
+
__name(join58, "join");
|
|
130485
130514
|
function ensureTrailingSlash(path3) {
|
|
130486
130515
|
return path3.endsWith("/") ? path3 : path3 + "/";
|
|
130487
130516
|
}
|
|
@@ -132817,8 +132846,8 @@ var require_dist15 = __commonJS({
|
|
|
132817
132846
|
|
|
132818
132847
|
// dist/lib/update-security.js
|
|
132819
132848
|
import { createHash as createHash9, timingSafeEqual } from "node:crypto";
|
|
132820
|
-
import { mkdirSync as
|
|
132821
|
-
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";
|
|
132822
132851
|
import { Readable as Readable3 } from "node:stream";
|
|
132823
132852
|
import { pipeline as pipeline4 } from "node:stream/promises";
|
|
132824
132853
|
function expectedTarballUrl(version2) {
|
|
@@ -133166,7 +133195,7 @@ async function extractArtifactSnapshot(artifact, extractionDir, filter) {
|
|
|
133166
133195
|
await pipeline4(Readable3.from([artifact]), So({ cwd: extractionDir, strip: 1, strict: true, filter }));
|
|
133167
133196
|
}
|
|
133168
133197
|
async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
133169
|
-
|
|
133198
|
+
mkdirSync20(extractionDir, { recursive: true, mode: 448 });
|
|
133170
133199
|
const allowed = /* @__PURE__ */ new Map([
|
|
133171
133200
|
["package/package.json", MAX_MANIFEST_BYTES],
|
|
133172
133201
|
["package/npm-shrinkwrap.json", MAX_LOCKFILE_BYTES]
|
|
@@ -133183,15 +133212,15 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
|
133183
133212
|
seen2.add(path3);
|
|
133184
133213
|
return true;
|
|
133185
133214
|
});
|
|
133186
|
-
const manifestPath =
|
|
133187
|
-
const lockPath =
|
|
133215
|
+
const manifestPath = join48(extractionDir, "package.json");
|
|
133216
|
+
const lockPath = join48(extractionDir, "npm-shrinkwrap.json");
|
|
133188
133217
|
let manifest;
|
|
133189
133218
|
let lock;
|
|
133190
133219
|
try {
|
|
133191
133220
|
if (statSync8(lockPath).size > MAX_LOCKFILE_BYTES)
|
|
133192
133221
|
throw new Error("lockfile too large");
|
|
133193
|
-
manifest = JSON.parse(
|
|
133194
|
-
lock = JSON.parse(
|
|
133222
|
+
manifest = JSON.parse(readFileSync39(manifestPath, "utf8"));
|
|
133223
|
+
lock = JSON.parse(readFileSync39(lockPath, "utf8"));
|
|
133195
133224
|
} catch (cause) {
|
|
133196
133225
|
throw new Error(`the verified artifact has no readable npm-shrinkwrap dependency lock: ${message(cause)}`);
|
|
133197
133226
|
}
|
|
@@ -133228,8 +133257,8 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
|
133228
133257
|
}
|
|
133229
133258
|
let bundledManifest;
|
|
133230
133259
|
try {
|
|
133231
|
-
const bundledPath =
|
|
133232
|
-
bundledManifest = JSON.parse(
|
|
133260
|
+
const bundledPath = join48(extractionDir, ...lockPath2.split("/"), "package.json");
|
|
133261
|
+
bundledManifest = JSON.parse(readFileSync39(bundledPath, "utf8"));
|
|
133233
133262
|
} catch (cause) {
|
|
133234
133263
|
throw new Error(`the verified artifact has an unreadable bundled dependency ${lockPath2}: ${message(cause)}`);
|
|
133235
133264
|
}
|
|
@@ -133299,10 +133328,10 @@ ${GITHUB_REPOSITORY_ID}`,
|
|
|
133299
133328
|
// dist/commands/update.js
|
|
133300
133329
|
import { spawn as spawn6 } from "node:child_process";
|
|
133301
133330
|
import { randomBytes as randomBytes8 } from "node:crypto";
|
|
133302
|
-
import { closeSync as closeSync6, constants as constants2, fstatSync, mkdtempSync as mkdtempSync4, openSync as openSync6, readFileSync 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";
|
|
133303
133332
|
import { createServer } from "node:http";
|
|
133304
133333
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
133305
|
-
import { join as
|
|
133334
|
+
import { join as join49 } from "node:path";
|
|
133306
133335
|
function refuse2(cause) {
|
|
133307
133336
|
error(`Update refused: ${message2(cause)}.`);
|
|
133308
133337
|
info(`To install the latest release with npm instead, run: ${teal(NPM_UPDATE_COMMAND)}`);
|
|
@@ -133310,7 +133339,7 @@ function refuse2(cause) {
|
|
|
133310
133339
|
}
|
|
133311
133340
|
function currentVersion2() {
|
|
133312
133341
|
try {
|
|
133313
|
-
const pkg = JSON.parse(
|
|
133342
|
+
const pkg = JSON.parse(readFileSync40(join49(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
133314
133343
|
return pkg.version;
|
|
133315
133344
|
} catch {
|
|
133316
133345
|
return "0.0.0";
|
|
@@ -133449,10 +133478,10 @@ async function serveArtifactSnapshot(artifact) {
|
|
|
133449
133478
|
}
|
|
133450
133479
|
async function installVerifiedTarball(tarballPath, tempDir, release2) {
|
|
133451
133480
|
const ambientEnvironment = { ...process.env };
|
|
133452
|
-
const packageDir =
|
|
133453
|
-
const cacheDir =
|
|
133454
|
-
const userConfigPath =
|
|
133455
|
-
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");
|
|
133456
133485
|
writeFileSync25(userConfigPath, "", { mode: 384 });
|
|
133457
133486
|
writeFileSync25(globalConfigPath, "", { mode: 384 });
|
|
133458
133487
|
const artifact = snapshotAuthenticatedArtifact(tarballPath);
|
|
@@ -133524,8 +133553,8 @@ async function runUpdate(opts, dependencies = {}) {
|
|
|
133524
133553
|
const provenance = await fetchJson(fetchImpl, release2.attestationUrl, "the official npm provenance endpoint");
|
|
133525
133554
|
await (dependencies.verifyProvenance ?? verifyPublishedProvenance)(provenance, release2);
|
|
133526
133555
|
const tarball = await downloadTarball(fetchImpl, release2);
|
|
133527
|
-
tempDir = mkdtempSync4(
|
|
133528
|
-
const tarballPath =
|
|
133556
|
+
tempDir = mkdtempSync4(join49(tmpdir2(), "somewhere-update-"));
|
|
133557
|
+
const tarballPath = join49(tempDir, `cli-${release2.version}.tgz`);
|
|
133529
133558
|
writeFileSync25(tarballPath, tarball, { mode: 384 });
|
|
133530
133559
|
info(`Cryptographically verified provenance and integrity for ${CLI_PACKAGE}@${release2.version}.`);
|
|
133531
133560
|
info(`Updating ${CLI_PACKAGE} from its authenticated dependency lock \u2026`);
|
|
@@ -133657,7 +133686,7 @@ var init_upgrade = __esm({
|
|
|
133657
133686
|
});
|
|
133658
133687
|
|
|
133659
133688
|
// dist/commands/call.js
|
|
133660
|
-
import { readFileSync as
|
|
133689
|
+
import { readFileSync as readFileSync41 } from "node:fs";
|
|
133661
133690
|
function parseArguments(value, file) {
|
|
133662
133691
|
if (value === void 0)
|
|
133663
133692
|
return {};
|
|
@@ -133681,7 +133710,7 @@ function readCallArguments(jsonArgs, file) {
|
|
|
133681
133710
|
}
|
|
133682
133711
|
let text;
|
|
133683
133712
|
try {
|
|
133684
|
-
text =
|
|
133713
|
+
text = readFileSync41(file, "utf8");
|
|
133685
133714
|
} catch (err) {
|
|
133686
133715
|
const code = err?.code;
|
|
133687
133716
|
throw new Error(`Could not read --file ${file}${code ? ` (${code})` : ""}. The requested tool was not called.`);
|
|
@@ -136023,8 +136052,8 @@ var init_test_response_capture = __esm({
|
|
|
136023
136052
|
import { randomUUID as randomUUID12 } from "node:crypto";
|
|
136024
136053
|
import { setDefaultResultOrder } from "node:dns";
|
|
136025
136054
|
import { lookup } from "node:dns/promises";
|
|
136026
|
-
import { existsSync as existsSync38, mkdirSync as
|
|
136027
|
-
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";
|
|
136028
136057
|
function launchOptions(extra = {}) {
|
|
136029
136058
|
return { ...extra, args: ["--disable-features=AsyncDns", ...extra.args ?? []] };
|
|
136030
136059
|
}
|
|
@@ -136074,10 +136103,10 @@ function undeployedChanges(root, projectId, preview = false) {
|
|
|
136074
136103
|
return null;
|
|
136075
136104
|
base = { project_id: record3.project_id, release_id: record3.preview_id, files: record3.files };
|
|
136076
136105
|
} else {
|
|
136077
|
-
const path3 =
|
|
136106
|
+
const path3 = join50(root, ".somewhere", "base-files.json");
|
|
136078
136107
|
if (!existsSync38(path3))
|
|
136079
136108
|
return null;
|
|
136080
|
-
base = JSON.parse(
|
|
136109
|
+
base = JSON.parse(readFileSync42(path3, "utf8"));
|
|
136081
136110
|
}
|
|
136082
136111
|
if (base.project_id !== projectId || !base.files)
|
|
136083
136112
|
return null;
|
|
@@ -136247,7 +136276,7 @@ var init_app_test = __esm({
|
|
|
136247
136276
|
for (const line of describeSweep(await sweepAccounts(control, root), "Before this script"))
|
|
136248
136277
|
process.stderr.write(line + "\n");
|
|
136249
136278
|
const scriptName = process.argv[1] ? basename11(process.argv[1]).replace(/\.[cm]?[jt]s$/, "") : "app-check";
|
|
136250
|
-
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`)));
|
|
136251
136280
|
return app;
|
|
136252
136281
|
}
|
|
136253
136282
|
/** What this run tests: the project, environment, preview, origin and script. */
|
|
@@ -136429,7 +136458,7 @@ page ${i + 1}: ${state}`).join("");
|
|
|
136429
136458
|
}
|
|
136430
136459
|
const passed = this.checks.filter((check) => check.ok).length;
|
|
136431
136460
|
const failed = this.checks.filter((check) => !check.ok && !check.skipped).length;
|
|
136432
|
-
|
|
136461
|
+
mkdirSync21(dirname15(this.resultsPath), { recursive: true });
|
|
136433
136462
|
writeFileSync26(this.resultsPath, JSON.stringify({
|
|
136434
136463
|
identity: this.identity(),
|
|
136435
136464
|
origin: this.origin,
|
|
@@ -137020,8 +137049,8 @@ var init_reference_check_note = __esm({
|
|
|
137020
137049
|
|
|
137021
137050
|
// dist/lib/test-scripts.js
|
|
137022
137051
|
import { createRequire as createRequire10 } from "node:module";
|
|
137023
|
-
import { existsSync as existsSync39, mkdirSync as
|
|
137024
|
-
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";
|
|
137025
137054
|
import { spawn as spawn7, spawnSync as spawnSync5 } from "node:child_process";
|
|
137026
137055
|
function hasSpecFiles(root) {
|
|
137027
137056
|
const walk2 = /* @__PURE__ */ __name((dir) => {
|
|
@@ -137030,24 +137059,24 @@ function hasSpecFiles(root) {
|
|
|
137030
137059
|
for (const entry of readdirSync9(dir, { withFileTypes: true })) {
|
|
137031
137060
|
if (entry.name === "node_modules" || entry.name.startsWith("."))
|
|
137032
137061
|
continue;
|
|
137033
|
-
const path3 =
|
|
137062
|
+
const path3 = join51(dir, entry.name);
|
|
137034
137063
|
if (entry.isDirectory() ? walk2(path3) : /\.spec\.ts$/.test(entry.name))
|
|
137035
137064
|
return true;
|
|
137036
137065
|
}
|
|
137037
137066
|
return false;
|
|
137038
137067
|
}, "walk");
|
|
137039
|
-
return walk2(
|
|
137068
|
+
return walk2(join51(root, "tests"));
|
|
137040
137069
|
}
|
|
137041
137070
|
function listScripts(root, files) {
|
|
137042
137071
|
if (files.length)
|
|
137043
137072
|
return files.map((file) => relative14(root, resolve25(root, file)));
|
|
137044
|
-
const dir =
|
|
137073
|
+
const dir = join51(root, "tests");
|
|
137045
137074
|
if (!existsSync39(dir))
|
|
137046
137075
|
return [];
|
|
137047
|
-
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));
|
|
137048
137077
|
}
|
|
137049
137078
|
function scriptBrowserEnv(root) {
|
|
137050
|
-
const require6 = createRequire10(
|
|
137079
|
+
const require6 = createRequire10(join51(root, "package.json"));
|
|
137051
137080
|
let cli;
|
|
137052
137081
|
try {
|
|
137053
137082
|
cli = require6.resolve("@playwright/test/cli");
|
|
@@ -137058,7 +137087,7 @@ function scriptBrowserEnv(root) {
|
|
|
137058
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" });
|
|
137059
137088
|
if (probe.status === 0)
|
|
137060
137089
|
return env;
|
|
137061
|
-
env.PLAYWRIGHT_BROWSERS_PATH ??=
|
|
137090
|
+
env.PLAYWRIGHT_BROWSERS_PATH ??= join51(cliConfigDir(), "cache", "playwright");
|
|
137062
137091
|
process.stderr.write("Installing Playwright Chromium in the CLI cache (once).\n");
|
|
137063
137092
|
const install = spawnSync5(process.execPath, [cli, "install", "chromium"], { stdio: "inherit", env });
|
|
137064
137093
|
if (install.status !== 0)
|
|
@@ -137081,7 +137110,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
137081
137110
|
env = testImportEnv(root, env);
|
|
137082
137111
|
const results = [];
|
|
137083
137112
|
for (const script of scripts) {
|
|
137084
|
-
if (!existsSync39(
|
|
137113
|
+
if (!existsSync39(join51(root, script))) {
|
|
137085
137114
|
results.push({ script, ok: false, exitCode: 1, ms: 0, reason: "no such file" });
|
|
137086
137115
|
continue;
|
|
137087
137116
|
}
|
|
@@ -137090,8 +137119,8 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
137090
137119
|
`);
|
|
137091
137120
|
const started = performance.now();
|
|
137092
137121
|
let output = "";
|
|
137093
|
-
const handOver =
|
|
137094
|
-
|
|
137122
|
+
const handOver = join51(root, ".somewhere", "tests", `report-${results.length}.json`);
|
|
137123
|
+
mkdirSync22(dirname16(handOver), { recursive: true });
|
|
137095
137124
|
rmSync17(handOver, { force: true });
|
|
137096
137125
|
const askedForBrowserLog = /(^|,)\s*(pw:browser|pw:\*|\*)\s*(,|$)/.test(env.DEBUG ?? "");
|
|
137097
137126
|
const childEnv = { ...env, SW_TEST_REPORT: handOver, DEBUG: askedForBrowserLog ? env.DEBUG : [env.DEBUG, "pw:browser"].filter(Boolean).join(",") };
|
|
@@ -137120,7 +137149,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
137120
137149
|
stderrLines("", true);
|
|
137121
137150
|
let report2 = null;
|
|
137122
137151
|
try {
|
|
137123
|
-
report2 = existsSync39(handOver) ? JSON.parse(
|
|
137152
|
+
report2 = existsSync39(handOver) ? JSON.parse(readFileSync43(handOver, "utf8")) : null;
|
|
137124
137153
|
} catch {
|
|
137125
137154
|
report2 = null;
|
|
137126
137155
|
}
|
|
@@ -137153,20 +137182,20 @@ function describeScriptResults(results, options2 = {}) {
|
|
|
137153
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;
|
|
137154
137183
|
}
|
|
137155
137184
|
function lastFailedScripts(root) {
|
|
137156
|
-
const path3 =
|
|
137185
|
+
const path3 = join51(root, LAST);
|
|
137157
137186
|
if (!existsSync39(path3))
|
|
137158
137187
|
return [];
|
|
137159
137188
|
try {
|
|
137160
|
-
return (JSON.parse(
|
|
137189
|
+
return (JSON.parse(readFileSync43(path3, "utf8")).results ?? []).filter((r) => !r.ok).map((r) => r.script);
|
|
137161
137190
|
} catch {
|
|
137162
137191
|
return [];
|
|
137163
137192
|
}
|
|
137164
137193
|
}
|
|
137165
137194
|
function recordScriptResults(root, results, rerunOnly) {
|
|
137166
|
-
const previous = rerunOnly && existsSync39(
|
|
137195
|
+
const previous = rerunOnly && existsSync39(join51(root, LAST)) ? JSON.parse(readFileSync43(join51(root, LAST), "utf8")).results ?? [] : [];
|
|
137167
137196
|
const merged = [...previous.filter((p2) => !results.some((r) => r.script === p2.script)), ...results];
|
|
137168
|
-
|
|
137169
|
-
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");
|
|
137170
137199
|
}
|
|
137171
137200
|
var BROWSER_CRASH, BROWSER_CRASH_REASON, isScript, LAST;
|
|
137172
137201
|
var init_test_scripts = __esm({
|
|
@@ -137184,7 +137213,7 @@ var init_test_scripts = __esm({
|
|
|
137184
137213
|
__name(failureReason, "failureReason");
|
|
137185
137214
|
__name(runScripts, "runScripts");
|
|
137186
137215
|
__name(describeScriptResults, "describeScriptResults");
|
|
137187
|
-
LAST =
|
|
137216
|
+
LAST = join51(".somewhere", "tests", "scripts-last.json");
|
|
137188
137217
|
__name(lastFailedScripts, "lastFailedScripts");
|
|
137189
137218
|
__name(recordScriptResults, "recordScriptResults");
|
|
137190
137219
|
}
|
|
@@ -137279,8 +137308,8 @@ var init_test = __esm({
|
|
|
137279
137308
|
});
|
|
137280
137309
|
|
|
137281
137310
|
// dist/commands/test-users.js
|
|
137282
|
-
import { existsSync as existsSync40, readFileSync as
|
|
137283
|
-
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";
|
|
137284
137313
|
import { randomBytes as randomBytes9 } from "node:crypto";
|
|
137285
137314
|
async function resolveTarget(projectOpt, originOpt) {
|
|
137286
137315
|
const root = process.cwd();
|
|
@@ -137309,6 +137338,47 @@ function fail2(opts, cause, extra) {
|
|
|
137309
137338
|
error(`${message3} [${code}]`, cause);
|
|
137310
137339
|
process.exitCode = 1;
|
|
137311
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
|
+
}
|
|
137312
137382
|
function registerTestUsers(program2) {
|
|
137313
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", [
|
|
137314
137384
|
"",
|
|
@@ -137317,7 +137387,7 @@ function registerTestUsers(program2) {
|
|
|
137317
137387
|
"that signup or email verification works. Use `address` + `inbox` for real signup tests.",
|
|
137318
137388
|
`${RETAINED_NOTE}`
|
|
137319
137389
|
].join("\n"));
|
|
137320
|
-
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", [
|
|
137321
137391
|
"",
|
|
137322
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.",
|
|
137323
137393
|
'Playwright: const alice = await browser.newContext({ storageState: ".somewhere/test/alice.state.json" })',
|
|
@@ -137351,8 +137421,24 @@ function registerTestUsers(program2) {
|
|
|
137351
137421
|
fail2(opts, cause);
|
|
137352
137422
|
return;
|
|
137353
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
|
+
}
|
|
137354
137439
|
if (existing && existing.actors.length) {
|
|
137355
|
-
|
|
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" }));
|
|
137356
137442
|
return;
|
|
137357
137443
|
}
|
|
137358
137444
|
let contractDigest = null;
|
|
@@ -137381,7 +137467,7 @@ function registerTestUsers(program2) {
|
|
|
137381
137467
|
const record3 = /* @__PURE__ */ __name((spec, issued, receivedAt) => {
|
|
137382
137468
|
const times = expiryOf(issued, receivedAt);
|
|
137383
137469
|
const file = `${spec.name}.state.json`;
|
|
137384
|
-
writePrivateFile(
|
|
137470
|
+
writePrivateFile(join52(dir, file), JSON.stringify(buildStorageState(target.origin, target.host, issued, times), null, 2) + "\n");
|
|
137385
137471
|
const actor = {
|
|
137386
137472
|
name: spec.name,
|
|
137387
137473
|
user_id: issued.user.id,
|
|
@@ -137483,7 +137569,7 @@ function registerTestUsers(program2) {
|
|
|
137483
137569
|
if (name !== opts.linkOut || !/^[A-Za-z0-9._-]{1,64}$/.test(name))
|
|
137484
137570
|
throw new Error(`--link-out takes a file name; it is written under ${TEST_STATE_DIR}/.`);
|
|
137485
137571
|
ensurePrivateDir(stateDir(target.root));
|
|
137486
|
-
writePrivateFile(
|
|
137572
|
+
writePrivateFile(join52(stateDir(target.root), name), newest.magic_link + "\n");
|
|
137487
137573
|
linkFile = `${TEST_STATE_DIR}/${name}`;
|
|
137488
137574
|
}
|
|
137489
137575
|
const message3 = {
|
|
@@ -137522,51 +137608,14 @@ function registerTestUsers(program2) {
|
|
|
137522
137608
|
info(`Nothing to clean up: ${TEST_STATE_DIR}/${MANIFEST_FILE} records no test users.`);
|
|
137523
137609
|
return;
|
|
137524
137610
|
}
|
|
137525
|
-
|
|
137526
|
-
throw Object.assign(new Error(`The manifest belongs to ${manifest.project_id}, not ${target.projectId}.`), { code: "PROJECT_FOLDER_MISMATCH" });
|
|
137527
|
-
const ids = manifest.actors.map((actor) => actor.user_id);
|
|
137528
|
-
let deleteError = null;
|
|
137529
|
-
try {
|
|
137530
|
-
await target.client.call("DELETE", "/auth/test-users", { project_id: target.projectId, ids });
|
|
137531
|
-
} catch (cause) {
|
|
137532
|
-
deleteError = cause instanceof CliApiError ? `${cause.code}: ${cause.message}` : cause instanceof Error ? cause.message : String(cause);
|
|
137533
|
-
}
|
|
137534
|
-
let live = null;
|
|
137535
|
-
try {
|
|
137536
|
-
const listed = await target.client.call("GET", "/auth/test-users", void 0, { project_id: target.projectId });
|
|
137537
|
-
live = new Set((listed?.identities ?? []).map((item) => String(item.id)));
|
|
137538
|
-
} catch {
|
|
137539
|
-
live = null;
|
|
137540
|
-
}
|
|
137541
|
-
const removed = live ? ids.filter((id) => !live.has(id)) : [];
|
|
137542
|
-
const remaining = live ? ids.filter((id) => live.has(id)) : [];
|
|
137543
|
-
const unknown2 = live ? [] : ids;
|
|
137544
|
-
const removedActors = manifest.actors.filter((actor) => removed.includes(actor.user_id));
|
|
137545
|
-
const localRemoved = opts.keepState ? [] : removeStateFiles(target.root, removedActors);
|
|
137546
|
-
const receipt = {
|
|
137547
|
-
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
137548
|
-
run_id: manifest.run_id,
|
|
137549
|
-
project_id: manifest.project_id,
|
|
137550
|
-
origin: manifest.origin,
|
|
137551
|
-
identities: { requested: ids.length, removed, remaining, unknown: unknown2, ...deleteError ? { delete_error: deleteError } : {} },
|
|
137552
|
-
sessions: removed.length ? "removed together with each removed identity" : "none removed",
|
|
137553
|
-
app_data_files_and_test_mail: "retained: " + RETAINED_NOTE,
|
|
137554
|
-
local_state: { removed: localRemoved, kept: manifest.actors.map((actor) => actor.state_file).filter((file) => !localRemoved.includes(file)) },
|
|
137555
|
-
actors: manifest.actors.map(({ name, user_id, email: email2, role, created_at }) => ({ name, user_id, email: email2, role, created_at }))
|
|
137556
|
-
};
|
|
137557
|
-
writePrivateFile(join51(stateDir(target.root), CLEANUP_RECEIPT_FILE), JSON.stringify(receipt, null, 2) + "\n");
|
|
137558
|
-
const left = manifest.actors.filter((actor) => !removed.includes(actor.user_id));
|
|
137559
|
-
if (left.length)
|
|
137560
|
-
writeManifest(target.root, { ...manifest, actors: left, status: "partial" });
|
|
137561
|
-
else
|
|
137562
|
-
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));
|
|
137563
137612
|
if (opts.json) {
|
|
137564
137613
|
printJson(receipt);
|
|
137565
137614
|
if (left.length)
|
|
137566
137615
|
process.exitCode = 1;
|
|
137567
137616
|
return;
|
|
137568
137617
|
}
|
|
137569
|
-
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}).`);
|
|
137570
137619
|
if (deleteError)
|
|
137571
137620
|
warn(`Delete reported: ${deleteError}`);
|
|
137572
137621
|
info(`Sessions: ${receipt.sessions}.`);
|
|
@@ -137594,12 +137643,13 @@ var init_test_users = __esm({
|
|
|
137594
137643
|
__name(resolveTarget, "resolveTarget");
|
|
137595
137644
|
__name(fail2, "fail");
|
|
137596
137645
|
iso = /* @__PURE__ */ __name((ms2) => new Date(ms2).toISOString(), "iso");
|
|
137646
|
+
__name(removeRecorded, "removeRecorded");
|
|
137597
137647
|
__name(registerTestUsers, "registerTestUsers");
|
|
137598
137648
|
}
|
|
137599
137649
|
});
|
|
137600
137650
|
|
|
137601
137651
|
// dist/commands/support.js
|
|
137602
|
-
import { join as
|
|
137652
|
+
import { join as join53 } from "node:path";
|
|
137603
137653
|
function commandPaths(program2) {
|
|
137604
137654
|
const paths = /* @__PURE__ */ new Set();
|
|
137605
137655
|
const walk2 = /* @__PURE__ */ __name((command, prefix) => {
|
|
@@ -137684,7 +137734,7 @@ function emitPacket(packet, opts) {
|
|
|
137684
137734
|
if (opts.out) {
|
|
137685
137735
|
if (!/^[A-Za-z0-9._-]{1,64}$/.test(opts.out))
|
|
137686
137736
|
throw new Error("--out takes a plain file name in the current folder.");
|
|
137687
|
-
writePrivateFile(
|
|
137737
|
+
writePrivateFile(join53(process.cwd(), opts.out), JSON.stringify(packet, null, 2) + "\n");
|
|
137688
137738
|
}
|
|
137689
137739
|
if (opts.json) {
|
|
137690
137740
|
printJson(packet);
|
|
@@ -137806,7 +137856,6 @@ var init_skills = __esm({
|
|
|
137806
137856
|
});
|
|
137807
137857
|
|
|
137808
137858
|
// dist/commands/ai.js
|
|
137809
|
-
import { readFileSync as readFileSync47 } from "node:fs";
|
|
137810
137859
|
function fail4(message3) {
|
|
137811
137860
|
error(message3);
|
|
137812
137861
|
process.exit(1);
|
|
@@ -137827,7 +137876,7 @@ async function readKey(stdin) {
|
|
|
137827
137876
|
if (stdin) {
|
|
137828
137877
|
if (process.stdin.isTTY)
|
|
137829
137878
|
fail4("Pipe the key into --stdin, or leave out --stdin to type it into a hidden prompt.");
|
|
137830
|
-
raw =
|
|
137879
|
+
raw = await readAllStdin();
|
|
137831
137880
|
} else {
|
|
137832
137881
|
if (!process.stdin.isTTY)
|
|
137833
137882
|
fail4("Pass --stdin to read the key from a pipe. Nothing was sent.");
|
|
@@ -137939,6 +137988,7 @@ var init_ai = __esm({
|
|
|
137939
137988
|
"dist/commands/ai.js"() {
|
|
137940
137989
|
"use strict";
|
|
137941
137990
|
init_cli_invocation();
|
|
137991
|
+
init_stdin();
|
|
137942
137992
|
import_prompts12 = __toESM(require_prompts3(), 1);
|
|
137943
137993
|
init_client();
|
|
137944
137994
|
init_config();
|
|
@@ -137974,11 +138024,11 @@ var init_startup_notice = __esm({
|
|
|
137974
138024
|
});
|
|
137975
138025
|
|
|
137976
138026
|
// dist/lib/last-run.js
|
|
137977
|
-
import { lstatSync as lstatSync7, mkdirSync as
|
|
137978
|
-
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";
|
|
137979
138029
|
function removeStaleRunRecord(dir = cliConfigDir()) {
|
|
137980
138030
|
for (const name of RUN_RECORD_FILES) {
|
|
137981
|
-
const path3 =
|
|
138031
|
+
const path3 = join54(dir, name);
|
|
137982
138032
|
try {
|
|
137983
138033
|
if (lstatSync7(path3).isDirectory()) {
|
|
137984
138034
|
process.stderr.write(`Could not remove ${path3}: it is a directory, not this CLI's run record. Check it yourself.
|
|
@@ -138009,7 +138059,7 @@ function recordLastRun(cliVersion) {
|
|
|
138009
138059
|
process.once("exit", (exitCode) => {
|
|
138010
138060
|
try {
|
|
138011
138061
|
const dir = cliConfigDir();
|
|
138012
|
-
|
|
138062
|
+
mkdirSync23(dir, { recursive: true, mode: 448 });
|
|
138013
138063
|
const record3 = {
|
|
138014
138064
|
// A usage error never reaches a command: no command and no options.
|
|
138015
138065
|
command: invocation?.command ?? "",
|
|
@@ -138018,8 +138068,8 @@ function recordLastRun(cliVersion) {
|
|
|
138018
138068
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
138019
138069
|
cli_version: cliVersion
|
|
138020
138070
|
};
|
|
138021
|
-
const path3 =
|
|
138022
|
-
const temporary =
|
|
138071
|
+
const path3 = join54(dir, "last-run.json");
|
|
138072
|
+
const temporary = join54(dir, "last-run.json.tmp");
|
|
138023
138073
|
writeFileSync28(temporary, JSON.stringify(record3) + "\n", { mode: 384 });
|
|
138024
138074
|
renameSync7(temporary, path3);
|
|
138025
138075
|
} catch {
|
|
@@ -138057,8 +138107,8 @@ __export(dist_exports, {
|
|
|
138057
138107
|
runCli: () => runCli
|
|
138058
138108
|
});
|
|
138059
138109
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
138060
|
-
import { readFileSync as
|
|
138061
|
-
import { join as
|
|
138110
|
+
import { readFileSync as readFileSync45 } from "node:fs";
|
|
138111
|
+
import { join as join55 } from "node:path";
|
|
138062
138112
|
async function runCli() {
|
|
138063
138113
|
const pinned = decidePin(process.cwd(), CLI_VERSION2, process.argv, process.env);
|
|
138064
138114
|
if (pinned.notice)
|
|
@@ -138086,7 +138136,7 @@ async function runCli() {
|
|
|
138086
138136
|
process.exit(child.status ?? 1);
|
|
138087
138137
|
}
|
|
138088
138138
|
removeStaleRunRecord();
|
|
138089
|
-
const pkg = JSON.parse(
|
|
138139
|
+
const pkg = JSON.parse(readFileSync45(join55(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
138090
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);
|
|
138091
138141
|
recordLastRun(pkg.version);
|
|
138092
138142
|
const jsonOutputRequested = process.argv.includes("--json");
|
|
@@ -138504,7 +138554,7 @@ var init_screenshot_guard = __esm({
|
|
|
138504
138554
|
|
|
138505
138555
|
// dist/lib/playwright-fixtures.js
|
|
138506
138556
|
import { createRequire as createRequire11 } from "node:module";
|
|
138507
|
-
import { join as
|
|
138557
|
+
import { join as join56 } from "node:path";
|
|
138508
138558
|
function waitOnNavigation(page) {
|
|
138509
138559
|
async function wait(options2) {
|
|
138510
138560
|
if (options2?.waitUntil === "commit")
|
|
@@ -138556,7 +138606,7 @@ async function previewControlForWorker() {
|
|
|
138556
138606
|
function runner() {
|
|
138557
138607
|
if (loaded)
|
|
138558
138608
|
return loaded;
|
|
138559
|
-
const require6 = createRequire11(
|
|
138609
|
+
const require6 = createRequire11(join56(process.cwd(), "package.json"));
|
|
138560
138610
|
let pw;
|
|
138561
138611
|
try {
|
|
138562
138612
|
pw = require6("@playwright/test");
|
|
@@ -139230,7 +139280,7 @@ import { resolve as resolve26 } from "node:path";
|
|
|
139230
139280
|
import { createRequire as createRequire12 } from "node:module";
|
|
139231
139281
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
139232
139282
|
import { readdirSync as readdirSync10 } from "node:fs";
|
|
139233
|
-
import { dirname as dirname17, join as
|
|
139283
|
+
import { dirname as dirname17, join as join57 } from "node:path";
|
|
139234
139284
|
async function openTestApp(options2 = {}) {
|
|
139235
139285
|
const root = resolve26(options2.projectDir ?? process.cwd());
|
|
139236
139286
|
const projectId = loadProjectConfig(root)?.project_id;
|
|
@@ -139683,7 +139733,7 @@ function replySummary(reply) {
|
|
|
139683
139733
|
function findPlaywright(root, given) {
|
|
139684
139734
|
if (given && typeof given === "object")
|
|
139685
139735
|
return given;
|
|
139686
|
-
const require6 = createRequire12(
|
|
139736
|
+
const require6 = createRequire12(join57(root, "package.json"));
|
|
139687
139737
|
const load2 = /* @__PURE__ */ __name((name) => {
|
|
139688
139738
|
try {
|
|
139689
139739
|
const pw = require6(name);
|
|
@@ -139701,14 +139751,14 @@ function findPlaywright(root, given) {
|
|
|
139701
139751
|
const browsers = process.env.PLAYWRIGHT_BROWSERS_PATH;
|
|
139702
139752
|
if (browsers) {
|
|
139703
139753
|
const parent = dirname17(resolve26(browsers));
|
|
139704
|
-
dirs.push(
|
|
139754
|
+
dirs.push(join57(parent, "node_modules"), ...readdirSafe(parent).map((entry) => join57(parent, entry, "node_modules")));
|
|
139705
139755
|
}
|
|
139706
139756
|
try {
|
|
139707
139757
|
dirs.push(execFileSync2("npm", ["root", "-g"], { encoding: "utf8", timeout: 5e3 }).trim());
|
|
139708
139758
|
} catch {
|
|
139709
139759
|
}
|
|
139710
139760
|
for (const dir of dirs) {
|
|
139711
|
-
const pw = load2(
|
|
139761
|
+
const pw = load2(join57(dir, "playwright"));
|
|
139712
139762
|
if (pw)
|
|
139713
139763
|
return pw;
|
|
139714
139764
|
}
|