@somewhere-cloud/cli 0.38.146 → 0.38.148
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 +10 -0
- package/dist/lib/bundle.js +230 -123
- package/dist/lib/bundle.js.map +3 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
package/dist/lib/bundle.js
CHANGED
|
@@ -87249,6 +87249,92 @@ var init_advisor_runs = __esm({
|
|
|
87249
87249
|
}
|
|
87250
87250
|
});
|
|
87251
87251
|
|
|
87252
|
+
// dist/lib/advisor-app.js
|
|
87253
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
87254
|
+
import { existsSync as existsSync32, mkdirSync as mkdirSync17, readFileSync as readFileSync34, rmSync as rmSync13, writeFileSync as writeFileSync22 } from "node:fs";
|
|
87255
|
+
import { join as join37 } from "node:path";
|
|
87256
|
+
async function gatherAdvisorApp(client, ref) {
|
|
87257
|
+
const project = await client.call("GET", `/projects/${encodeURIComponent(ref)}`);
|
|
87258
|
+
if (typeof project.id !== "string" || project.deleted === true)
|
|
87259
|
+
throw new Error(`The app linked in this folder ("${ref}") is not readable with this sign-in.`);
|
|
87260
|
+
const id = project.id;
|
|
87261
|
+
const facts = { projectId: id };
|
|
87262
|
+
const release2 = project.live_release;
|
|
87263
|
+
if (release2?.id) {
|
|
87264
|
+
const docs = await client.call("GET", "/project-docs", void 0, { project_id: id, view: "overview" }).catch(() => null);
|
|
87265
|
+
if (docs?.project_overview && docs.release_id === release2.id)
|
|
87266
|
+
facts.app_overview = docs.project_overview;
|
|
87267
|
+
} else {
|
|
87268
|
+
facts.app_overview = { app: "No live version yet: nothing has been deployed, so the app has no pages, routes, tables or jobs." };
|
|
87269
|
+
}
|
|
87270
|
+
const deploys = await client.call("GET", `/projects/${encodeURIComponent(id)}/deploys`, void 0, { limit: 3 }).catch(() => null);
|
|
87271
|
+
const newest = (deploys?.deploys ?? []).slice().sort((a, b2) => String(b2.at ?? b2.promoted_at ?? "").localeCompare(String(a.at ?? a.promoted_at ?? "")))[0];
|
|
87272
|
+
if (newest?.status === "rejected") {
|
|
87273
|
+
const failure2 = await client.call("GET", "/deploy/log", void 0, { project_id: id, view: "last_failure" }).catch(() => null);
|
|
87274
|
+
const first = (failure2?.last_failure?.errors ?? []).find((e) => typeof e.file === "string");
|
|
87275
|
+
facts.last_deploy = {
|
|
87276
|
+
status: "failed",
|
|
87277
|
+
...typeof newest.code === "string" && /^[A-Z0-9_]{1,64}$/.test(newest.code) ? { code: newest.code } : {},
|
|
87278
|
+
...first?.file ? { file: first.file.slice(0, 300) } : {},
|
|
87279
|
+
...Number.isSafeInteger(first?.line) ? { line: first.line } : {},
|
|
87280
|
+
...Number.isSafeInteger(first?.column) ? { column: first.column } : {},
|
|
87281
|
+
message: String(first?.message ?? newest.message ?? "").slice(0, 500)
|
|
87282
|
+
};
|
|
87283
|
+
} else if (newest)
|
|
87284
|
+
facts.last_deploy = { status: "succeeded" };
|
|
87285
|
+
return facts;
|
|
87286
|
+
}
|
|
87287
|
+
function loadAdvisorTurns(dir, projectId, account, now2 = Date.now()) {
|
|
87288
|
+
try {
|
|
87289
|
+
const saved = JSON.parse(readFileSync34(join37(dir, FILE), "utf8"));
|
|
87290
|
+
if (saved.project_id !== projectId || saved.owner !== ownerOf(account) || !Array.isArray(saved.turns))
|
|
87291
|
+
return [];
|
|
87292
|
+
const last = saved.turns.at(-1);
|
|
87293
|
+
return last && now2 - last.at <= IDLE_MS ? saved.turns.slice(-3) : [];
|
|
87294
|
+
} catch {
|
|
87295
|
+
return [];
|
|
87296
|
+
}
|
|
87297
|
+
}
|
|
87298
|
+
function saveAdvisorTurn(dir, projectId, account, earlier, turn) {
|
|
87299
|
+
mkdirSync17(join37(dir, DIR), { recursive: true, mode: 448 });
|
|
87300
|
+
writeFileSync22(join37(dir, FILE), JSON.stringify({ project_id: projectId, owner: ownerOf(account), turns: [...earlier, { question: turn.question.slice(0, 2e3), answer: turn.answer.slice(0, 3e3), at: turn.at }].slice(-3) }) + "\n", { mode: 384 });
|
|
87301
|
+
ensureAdvisorStateIgnored(dir);
|
|
87302
|
+
}
|
|
87303
|
+
function clearAdvisorTurns(dir) {
|
|
87304
|
+
if (existsSync32(join37(dir, FILE)))
|
|
87305
|
+
rmSync13(join37(dir, FILE), { force: true });
|
|
87306
|
+
}
|
|
87307
|
+
function ensureAdvisorStateIgnored(dir) {
|
|
87308
|
+
const path3 = join37(dir, ".gitignore");
|
|
87309
|
+
const covered = [".somewhere/", ".somewhere", "/.somewhere/", "/.somewhere", ".somewhere/advisor-conversation.json"];
|
|
87310
|
+
if (!existsSync32(path3)) {
|
|
87311
|
+
writeFileSync22(path3, "# somewhere: local CLI state (Advisor follow-ups, test users)\n.somewhere/\n");
|
|
87312
|
+
return;
|
|
87313
|
+
}
|
|
87314
|
+
const text = readFileSync34(path3, "utf8");
|
|
87315
|
+
if (text.split(/\r?\n/).map((l) => l.trim()).some((l) => covered.includes(l)))
|
|
87316
|
+
return;
|
|
87317
|
+
writeFileSync22(path3, `${text}${text.endsWith("\n") || !text ? "" : "\n"}
|
|
87318
|
+
# somewhere: local CLI state (Advisor follow-ups, test users)
|
|
87319
|
+
.somewhere/
|
|
87320
|
+
`);
|
|
87321
|
+
}
|
|
87322
|
+
var DIR, FILE, IDLE_MS, ownerOf;
|
|
87323
|
+
var init_advisor_app = __esm({
|
|
87324
|
+
"dist/lib/advisor-app.js"() {
|
|
87325
|
+
"use strict";
|
|
87326
|
+
__name(gatherAdvisorApp, "gatherAdvisorApp");
|
|
87327
|
+
DIR = ".somewhere";
|
|
87328
|
+
FILE = join37(DIR, "advisor-conversation.json");
|
|
87329
|
+
IDLE_MS = 30 * 6e4;
|
|
87330
|
+
ownerOf = /* @__PURE__ */ __name((account) => createHash8("sha256").update(`advisor:${account}`).digest("hex"), "ownerOf");
|
|
87331
|
+
__name(loadAdvisorTurns, "loadAdvisorTurns");
|
|
87332
|
+
__name(saveAdvisorTurn, "saveAdvisorTurn");
|
|
87333
|
+
__name(clearAdvisorTurns, "clearAdvisorTurns");
|
|
87334
|
+
__name(ensureAdvisorStateIgnored, "ensureAdvisorStateIgnored");
|
|
87335
|
+
}
|
|
87336
|
+
});
|
|
87337
|
+
|
|
87252
87338
|
// dist/commands/advisor.js
|
|
87253
87339
|
function publicAdvisorUrl() {
|
|
87254
87340
|
const url3 = new URL(MCP_BASE_URL2);
|
|
@@ -87297,7 +87383,7 @@ async function callAnonymousAdvisor(question, context) {
|
|
|
87297
87383
|
return answer;
|
|
87298
87384
|
}
|
|
87299
87385
|
function registerAdvisor(program2) {
|
|
87300
|
-
program2.command("advisor [question]").description("Ask the somewhere.cloud platform advisor; local context is attached only with --file").option("--async", "Use the durable Advisor candidate when enabled by the server").option("--resume <request-id>", "Reconnect to the same saved Advisor request").option("--status <request-id>", "Read one saved Advisor request status").option("--cancel <request-id>", "Request cancellation of a saved Advisor run").option("--json", "Print the advisor response in a JSON envelope").option("--file <path>", "Attach a trimmed, redacted local file as context").option("--no-context", "
|
|
87386
|
+
program2.command("advisor [question]").description("Ask the somewhere.cloud platform advisor; local context is attached only with --file").option("--async", "Use the durable Advisor candidate when enabled by the server").option("--resume <request-id>", "Reconnect to the same saved Advisor request").option("--status <request-id>", "Read one saved Advisor request status").option("--cancel <request-id>", "Request cancellation of a saved Advisor run").option("--json", "Print the advisor response in a JSON envelope").option("--file <path>", "Attach a trimmed, redacted local file as context").option("--no-context", "Send nothing but the question: not this folder's app, earlier questions, or a --file").option("--new", "Start a new conversation in this folder (forget the earlier questions)").action(async (question, opts) => {
|
|
87301
87387
|
try {
|
|
87302
87388
|
if (opts.async || opts.resume || opts.status || opts.cancel) {
|
|
87303
87389
|
if ([opts.resume, opts.status, opts.cancel].filter(Boolean).length > 1)
|
|
@@ -87322,9 +87408,26 @@ function registerAdvisor(program2) {
|
|
|
87322
87408
|
const context = permanentCredential ? localContext : anonymousAdvisorContext(localContext);
|
|
87323
87409
|
process.stderr.write(`${contextNotice(context)}
|
|
87324
87410
|
`);
|
|
87411
|
+
const linked = opts.context === false ? void 0 : loadProjectConfig()?.project_id;
|
|
87412
|
+
if (linked && !permanentCredential)
|
|
87413
|
+
process.stderr.write("Not signed in, so this folder's app was not sent: `somewhere login` lets the Advisor answer about it.\n");
|
|
87414
|
+
const account = permanentCredential ? config2?.user?.email ?? null : null;
|
|
87415
|
+
const app = linked && permanentCredential ? await gatherAdvisorApp(new ApiClient(getToken()), linked).catch((err) => {
|
|
87416
|
+
process.stderr.write(`Could not read this folder's app (${err instanceof Error ? err.message : String(err)}); asking with the question only.
|
|
87417
|
+
`);
|
|
87418
|
+
return null;
|
|
87419
|
+
}) : null;
|
|
87420
|
+
if (opts.new && app)
|
|
87421
|
+
clearAdvisorTurns(process.cwd());
|
|
87422
|
+
const earlier = app && account ? loadAdvisorTurns(process.cwd(), app.projectId, account) : [];
|
|
87423
|
+
const sentWhat = app ? [app.app_overview ? "this app's overview" : null, app.last_deploy ? "its last deploy" : null].filter(Boolean).join(" and ") : "";
|
|
87424
|
+
if (app)
|
|
87425
|
+
process.stderr.write(`Sent ${sentWhat || "nothing about this app (it could not be summarized)"}, read with your sign-in${earlier.length ? `, and ${earlier.length} earlier question${earlier.length === 1 ? "" : "s"} from this folder` : ""} (--no-context sends only the question; --new forgets the earlier questions).
|
|
87426
|
+
`);
|
|
87427
|
+
const sent = app ? { ...context ?? {}, ...app.app_overview ? { app_overview: app.app_overview } : {}, ...app.last_deploy ? { last_deploy: app.last_deploy } : {}, ...earlier.length ? { earlier: earlier.map(({ question: q2, answer: a }) => ({ question: q2, answer: a })) } : {} } : context;
|
|
87325
87428
|
let answer = permanentCredential ? await callPlatformHelpTool("advisor", {
|
|
87326
87429
|
question,
|
|
87327
|
-
...
|
|
87430
|
+
...sent ? { context: sent } : {}
|
|
87328
87431
|
}) : await callAnonymousAdvisor(question, context);
|
|
87329
87432
|
if (permanentCredential) {
|
|
87330
87433
|
const run = await consumeAdvisorRun(answer, (message3) => process.stderr.write(message3 + "\n"));
|
|
@@ -87334,6 +87437,8 @@ function registerAdvisor(program2) {
|
|
|
87334
87437
|
answer = run.answer ?? JSON.stringify(run);
|
|
87335
87438
|
}
|
|
87336
87439
|
}
|
|
87440
|
+
if (app && account && !/^\s*\{\s*"ok"\s*:\s*false/.test(answer))
|
|
87441
|
+
saveAdvisorTurn(process.cwd(), app.projectId, account, earlier, { question, answer, at: Date.now() });
|
|
87337
87442
|
if (opts.json) {
|
|
87338
87443
|
printJson({ question, answer });
|
|
87339
87444
|
} else {
|
|
@@ -87354,6 +87459,8 @@ var init_advisor = __esm({
|
|
|
87354
87459
|
init_output();
|
|
87355
87460
|
init_platform_tools();
|
|
87356
87461
|
init_config();
|
|
87462
|
+
init_client();
|
|
87463
|
+
init_advisor_app();
|
|
87357
87464
|
init_http();
|
|
87358
87465
|
init_advisor_context();
|
|
87359
87466
|
ADVISOR_TIMEOUT_MS = 6e4;
|
|
@@ -88502,7 +88609,7 @@ var init_envfile_write = __esm({
|
|
|
88502
88609
|
});
|
|
88503
88610
|
|
|
88504
88611
|
// dist/commands/env.js
|
|
88505
|
-
import { existsSync as
|
|
88612
|
+
import { existsSync as existsSync33, readFileSync as readFileSync35, writeFileSync as writeFileSync23 } from "node:fs";
|
|
88506
88613
|
import { resolve as resolve19 } from "node:path";
|
|
88507
88614
|
function resolveProjectId(explicit) {
|
|
88508
88615
|
if (explicit)
|
|
@@ -88567,12 +88674,12 @@ function registerEnv(program2) {
|
|
|
88567
88674
|
return;
|
|
88568
88675
|
}
|
|
88569
88676
|
const outPath = resolve19(process.cwd(), String(opts.out));
|
|
88570
|
-
if (
|
|
88677
|
+
if (existsSync33(outPath) && !opts.force && opts.json) {
|
|
88571
88678
|
error(`${opts.out} exists. Pass --force to overwrite in --json mode.`);
|
|
88572
88679
|
process.exit(1);
|
|
88573
88680
|
}
|
|
88574
|
-
if (
|
|
88575
|
-
const existing =
|
|
88681
|
+
if (existsSync33(outPath) && !opts.force) {
|
|
88682
|
+
const existing = readFileSync35(outPath, "utf-8");
|
|
88576
88683
|
const hasValues = existing.split("\n").some((l) => /^[^#=]+=.+/.test(l.trim()));
|
|
88577
88684
|
const { ok } = await (0, import_prompts9.default)({
|
|
88578
88685
|
type: "confirm",
|
|
@@ -88585,7 +88692,7 @@ function registerEnv(program2) {
|
|
|
88585
88692
|
return;
|
|
88586
88693
|
}
|
|
88587
88694
|
}
|
|
88588
|
-
|
|
88695
|
+
writeFileSync23(outPath, buildEnvTemplate(keys, { projectId: pid }));
|
|
88589
88696
|
if (opts.json) {
|
|
88590
88697
|
printJson(result);
|
|
88591
88698
|
return;
|
|
@@ -88625,7 +88732,7 @@ function registerEnv(program2) {
|
|
|
88625
88732
|
if (inputNote && !opts.json)
|
|
88626
88733
|
process.stderr.write(`Note: ${inputNote}
|
|
88627
88734
|
`);
|
|
88628
|
-
const value = opts.stdin ?
|
|
88735
|
+
const value = opts.stdin ? readFileSync35(0, "utf8").replace(/\r?\n$/, "") : positionalValue;
|
|
88629
88736
|
const client = new ApiClient(getToken());
|
|
88630
88737
|
const pid = resolveProjectId(opts.project);
|
|
88631
88738
|
try {
|
|
@@ -88694,7 +88801,7 @@ var init_env = __esm({
|
|
|
88694
88801
|
});
|
|
88695
88802
|
|
|
88696
88803
|
// dist/commands/run.js
|
|
88697
|
-
import { existsSync as
|
|
88804
|
+
import { existsSync as existsSync34, readFileSync as readFileSync36 } from "node:fs";
|
|
88698
88805
|
import { isAbsolute as isAbsolute6, resolve as resolve20 } from "node:path";
|
|
88699
88806
|
import { createRequire as createRequire7 } from "node:module";
|
|
88700
88807
|
function parseArgs(values) {
|
|
@@ -88761,11 +88868,11 @@ function registerRun(program2) {
|
|
|
88761
88868
|
projectId = config2.project_id;
|
|
88762
88869
|
}
|
|
88763
88870
|
const absPath = isAbsolute6(script) ? script : resolve20(process.cwd(), script);
|
|
88764
|
-
if (!
|
|
88871
|
+
if (!existsSync34(absPath)) {
|
|
88765
88872
|
error(`File not found: ${script}`);
|
|
88766
88873
|
process.exit(1);
|
|
88767
88874
|
}
|
|
88768
|
-
const code =
|
|
88875
|
+
const code = readFileSync36(absPath, "utf-8");
|
|
88769
88876
|
if (!code.trim()) {
|
|
88770
88877
|
error(`${script} is empty \u2014 nothing to run.`);
|
|
88771
88878
|
process.exit(1);
|
|
@@ -89203,7 +89310,7 @@ var init_claim = __esm({
|
|
|
89203
89310
|
import { createRequire as createRequire8 } from "node:module";
|
|
89204
89311
|
import { realpathSync as realpathSync4 } from "node:fs";
|
|
89205
89312
|
import { createConnection, createServer as createNetServer } from "node:net";
|
|
89206
|
-
import { join as
|
|
89313
|
+
import { join as join38 } from "node:path";
|
|
89207
89314
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
89208
89315
|
function deployedOrigin(value) {
|
|
89209
89316
|
const url3 = new URL(value);
|
|
@@ -89301,7 +89408,7 @@ async function startFrontendDev(cwd, target, port = 8787, open4 = false) {
|
|
|
89301
89408
|
throw new Error(INSTALL_PROJECT_DEPENDENCIES);
|
|
89302
89409
|
let vitePath;
|
|
89303
89410
|
try {
|
|
89304
|
-
vitePath = createRequire8(
|
|
89411
|
+
vitePath = createRequire8(join38(cwd, "package.json")).resolve("vite");
|
|
89305
89412
|
} catch {
|
|
89306
89413
|
if (readProjectPin(cwd)?.versionOnly) {
|
|
89307
89414
|
throw new Error("Install the local frontend tools: npm install -D --save-exact vite@7.2.2");
|
|
@@ -89421,8 +89528,8 @@ var init_preview_jobs = __esm({
|
|
|
89421
89528
|
|
|
89422
89529
|
// dist/commands/dev.js
|
|
89423
89530
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
89424
|
-
import { existsSync as
|
|
89425
|
-
import { join as
|
|
89531
|
+
import { existsSync as existsSync35, readFileSync as readFileSync37 } from "node:fs";
|
|
89532
|
+
import { join as join39, relative as relative11 } from "node:path";
|
|
89426
89533
|
function previewFinishedReason(err) {
|
|
89427
89534
|
if (!(err instanceof CliApiError) || err.code !== "DRAFT_SESSION_TERMINAL")
|
|
89428
89535
|
return null;
|
|
@@ -90405,16 +90512,16 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
|
|
|
90405
90512
|
const updateBinary = {};
|
|
90406
90513
|
const deleteKeys = [];
|
|
90407
90514
|
for (const rel of changed) {
|
|
90408
|
-
const abs =
|
|
90409
|
-
if (!
|
|
90515
|
+
const abs = join39(cwd, rel);
|
|
90516
|
+
if (!existsSync35(abs))
|
|
90410
90517
|
continue;
|
|
90411
90518
|
const { kind, key } = classifyKey(rel);
|
|
90412
90519
|
if (kind === "function")
|
|
90413
|
-
updateFunctions[key] =
|
|
90520
|
+
updateFunctions[key] = readFileSync37(abs, "utf-8");
|
|
90414
90521
|
else if (kind === "binary")
|
|
90415
|
-
updateBinary[key] =
|
|
90522
|
+
updateBinary[key] = readFileSync37(abs).toString("base64");
|
|
90416
90523
|
else
|
|
90417
|
-
updateFiles[key] =
|
|
90524
|
+
updateFiles[key] = readFileSync37(abs, "utf-8");
|
|
90418
90525
|
}
|
|
90419
90526
|
for (const rel of deleted)
|
|
90420
90527
|
deleteKeys.push(classifyKey(rel).key);
|
|
@@ -90477,7 +90584,7 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
|
|
|
90477
90584
|
for (const rel of deleted)
|
|
90478
90585
|
delete nextFiles[rel];
|
|
90479
90586
|
for (const rel of changed)
|
|
90480
|
-
if (
|
|
90587
|
+
if (existsSync35(join39(cwd, rel)))
|
|
90481
90588
|
Object.assign(nextFiles, hashFiles(cwd, [rel]));
|
|
90482
90589
|
savePreviewRecord(cwd, { ...record3, preview_id: nextCandidate, files: nextFiles });
|
|
90483
90590
|
}
|
|
@@ -90672,8 +90779,8 @@ var init_dev = __esm({
|
|
|
90672
90779
|
});
|
|
90673
90780
|
|
|
90674
90781
|
// dist/commands/check.js
|
|
90675
|
-
import { existsSync as
|
|
90676
|
-
import { join as
|
|
90782
|
+
import { existsSync as existsSync36 } from "node:fs";
|
|
90783
|
+
import { join as join40, resolve as resolve21 } from "node:path";
|
|
90677
90784
|
function buildCheckBody(collected, projectId) {
|
|
90678
90785
|
const body = { project_id: projectId, files: collected.files };
|
|
90679
90786
|
if (Object.keys(collected.functions).length > 0)
|
|
@@ -90778,7 +90885,7 @@ async function runLocalPreflight(targetDir, collected, typecheck = async (dir) =
|
|
|
90778
90885
|
if (collected.excluded.length)
|
|
90779
90886
|
source.not_published = collected.excluded;
|
|
90780
90887
|
let typecheckStep;
|
|
90781
|
-
if (!
|
|
90888
|
+
if (!existsSync36(join40(targetDir, "tsconfig.json"))) {
|
|
90782
90889
|
typecheckStep = { name: "typecheck", status: "skipped", reason: MISSING_TSCONFIG_GUIDANCE };
|
|
90783
90890
|
} else if (missingProjectDependencies(targetDir).length) {
|
|
90784
90891
|
typecheckStep = { name: "typecheck", status: "skipped", reason: missingTypecheckDependenciesMessage() };
|
|
@@ -91195,7 +91302,7 @@ var init_api2 = __esm({
|
|
|
91195
91302
|
import { createReadStream as createReadStream2, createWriteStream as createWriteStream2 } from "node:fs";
|
|
91196
91303
|
import { stat as stat5, rename, unlink } from "node:fs/promises";
|
|
91197
91304
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
91198
|
-
import { basename as basename8, dirname as dirname13, extname as extname6, join as
|
|
91305
|
+
import { basename as basename8, dirname as dirname13, extname as extname6, join as join41, resolve as resolve23 } from "node:path";
|
|
91199
91306
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
91200
91307
|
function registerFs(program2) {
|
|
91201
91308
|
const fs2 = program2.command("fs").description("Manage project file storage");
|
|
@@ -91239,7 +91346,7 @@ function registerFs(program2) {
|
|
|
91239
91346
|
if (!response.body)
|
|
91240
91347
|
throw new Error("The server returned an empty file response.");
|
|
91241
91348
|
const destination = resolve23(local);
|
|
91242
|
-
tempPath =
|
|
91349
|
+
tempPath = join41(dirname13(destination), `.${basename8(destination)}.${randomUUID9()}.tmp`);
|
|
91243
91350
|
await pipeline2(response.body, createWriteStream2(tempPath, { flags: "wx" }));
|
|
91244
91351
|
await rename(tempPath, destination);
|
|
91245
91352
|
tempPath = void 0;
|
|
@@ -109029,7 +109136,7 @@ var require_polyfill = __commonJS({
|
|
|
109029
109136
|
var {
|
|
109030
109137
|
dirname: dirname16,
|
|
109031
109138
|
isAbsolute: isAbsolute7,
|
|
109032
|
-
join:
|
|
109139
|
+
join: join51,
|
|
109033
109140
|
parse: parse3,
|
|
109034
109141
|
resolve: resolve26,
|
|
109035
109142
|
sep: sep2,
|
|
@@ -109310,8 +109417,8 @@ var require_polyfill = __commonJS({
|
|
|
109310
109417
|
const dir = await readdir3(src);
|
|
109311
109418
|
for (let i = 0; i < dir.length; i++) {
|
|
109312
109419
|
const item = dir[i];
|
|
109313
|
-
const srcItem =
|
|
109314
|
-
const destItem =
|
|
109420
|
+
const srcItem = join51(src, item);
|
|
109421
|
+
const destItem = join51(dest, item);
|
|
109315
109422
|
const { destStat } = await checkPaths(srcItem, destItem, opts);
|
|
109316
109423
|
await startCopy(destStat, srcItem, destItem, opts);
|
|
109317
109424
|
}
|
|
@@ -109387,7 +109494,7 @@ var require_cp = __commonJS({
|
|
|
109387
109494
|
// node_modules/@npmcli/fs/lib/with-temp-dir.js
|
|
109388
109495
|
var require_with_temp_dir = __commonJS({
|
|
109389
109496
|
"node_modules/@npmcli/fs/lib/with-temp-dir.js"(exports, module) {
|
|
109390
|
-
var { join:
|
|
109497
|
+
var { join: join51, sep: sep2 } = __require("path");
|
|
109391
109498
|
var getOptions = require_get_options();
|
|
109392
109499
|
var { mkdir, mkdtemp, rm } = __require("fs/promises");
|
|
109393
109500
|
var withTempDir = /* @__PURE__ */ __name(async (root, fn, opts) => {
|
|
@@ -109395,7 +109502,7 @@ var require_with_temp_dir = __commonJS({
|
|
|
109395
109502
|
copy: ["tmpPrefix"]
|
|
109396
109503
|
});
|
|
109397
109504
|
await mkdir(root, { recursive: true });
|
|
109398
|
-
const target = await mkdtemp(
|
|
109505
|
+
const target = await mkdtemp(join51(`${root}${sep2}`, options2.tmpPrefix || ""));
|
|
109399
109506
|
let err;
|
|
109400
109507
|
let result;
|
|
109401
109508
|
try {
|
|
@@ -109420,13 +109527,13 @@ var require_with_temp_dir = __commonJS({
|
|
|
109420
109527
|
var require_readdir_scoped = __commonJS({
|
|
109421
109528
|
"node_modules/@npmcli/fs/lib/readdir-scoped.js"(exports, module) {
|
|
109422
109529
|
var { readdir: readdir3 } = __require("fs/promises");
|
|
109423
|
-
var { join:
|
|
109530
|
+
var { join: join51 } = __require("path");
|
|
109424
109531
|
var readdirScoped = /* @__PURE__ */ __name(async (dir) => {
|
|
109425
109532
|
const results = [];
|
|
109426
109533
|
for (const item of await readdir3(dir)) {
|
|
109427
109534
|
if (item.startsWith("@")) {
|
|
109428
|
-
for (const scopedItem of await readdir3(
|
|
109429
|
-
results.push(
|
|
109535
|
+
for (const scopedItem of await readdir3(join51(dir, item))) {
|
|
109536
|
+
results.push(join51(item, scopedItem));
|
|
109430
109537
|
}
|
|
109431
109538
|
} else {
|
|
109432
109539
|
results.push(item);
|
|
@@ -109441,7 +109548,7 @@ var require_readdir_scoped = __commonJS({
|
|
|
109441
109548
|
// node_modules/@npmcli/fs/lib/move-file.js
|
|
109442
109549
|
var require_move_file = __commonJS({
|
|
109443
109550
|
"node_modules/@npmcli/fs/lib/move-file.js"(exports, module) {
|
|
109444
|
-
var { dirname: dirname16, join:
|
|
109551
|
+
var { dirname: dirname16, join: join51, resolve: resolve26, relative: relative15, isAbsolute: isAbsolute7 } = __require("path");
|
|
109445
109552
|
var fs2 = __require("fs/promises");
|
|
109446
109553
|
var pathExists = /* @__PURE__ */ __name(async (path3) => {
|
|
109447
109554
|
try {
|
|
@@ -109471,7 +109578,7 @@ var require_move_file = __commonJS({
|
|
|
109471
109578
|
if (sourceStat.isDirectory()) {
|
|
109472
109579
|
const files = await fs2.readdir(source);
|
|
109473
109580
|
await Promise.all(files.map(
|
|
109474
|
-
(file) => moveFile(
|
|
109581
|
+
(file) => moveFile(join51(source, file), join51(destination, file), options2, false, symlinks)
|
|
109475
109582
|
));
|
|
109476
109583
|
} else if (sourceStat.isSymbolicLink()) {
|
|
109477
109584
|
symlinks.push({ source, destination });
|
|
@@ -128839,12 +128946,12 @@ var require_url = __commonJS({
|
|
|
128839
128946
|
"node_modules/tuf-js/dist/utils/url.js"(exports) {
|
|
128840
128947
|
"use strict";
|
|
128841
128948
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
128842
|
-
exports.join =
|
|
128949
|
+
exports.join = join51;
|
|
128843
128950
|
var url_1 = __require("url");
|
|
128844
|
-
function
|
|
128951
|
+
function join51(base, path3) {
|
|
128845
128952
|
return new url_1.URL(ensureTrailingSlash(base) + removeLeadingSlash(path3)).toString();
|
|
128846
128953
|
}
|
|
128847
|
-
__name(
|
|
128954
|
+
__name(join51, "join");
|
|
128848
128955
|
function ensureTrailingSlash(path3) {
|
|
128849
128956
|
return path3.endsWith("/") ? path3 : path3 + "/";
|
|
128850
128957
|
}
|
|
@@ -131179,9 +131286,9 @@ var require_dist15 = __commonJS({
|
|
|
131179
131286
|
});
|
|
131180
131287
|
|
|
131181
131288
|
// dist/lib/update-security.js
|
|
131182
|
-
import { createHash as
|
|
131183
|
-
import { mkdirSync as
|
|
131184
|
-
import { join as
|
|
131289
|
+
import { createHash as createHash9, timingSafeEqual } from "node:crypto";
|
|
131290
|
+
import { mkdirSync as mkdirSync18, readFileSync as readFileSync38, statSync as statSync7 } from "node:fs";
|
|
131291
|
+
import { join as join42 } from "node:path";
|
|
131185
131292
|
import { Readable as Readable2 } from "node:stream";
|
|
131186
131293
|
import { pipeline as pipeline3 } from "node:stream/promises";
|
|
131187
131294
|
function expectedTarballUrl(version2) {
|
|
@@ -131334,7 +131441,7 @@ async function verifyPublishedProvenance(body, release2) {
|
|
|
131334
131441
|
}
|
|
131335
131442
|
function verifyTarballIntegrity(bytes, integrity) {
|
|
131336
131443
|
const expected = sha512Digest(integrity);
|
|
131337
|
-
const actual =
|
|
131444
|
+
const actual = createHash9("sha512").update(bytes).digest();
|
|
131338
131445
|
if (!timingSafeEqual(actual, expected)) {
|
|
131339
131446
|
throw new Error("the downloaded update does not match its published integrity digest");
|
|
131340
131447
|
}
|
|
@@ -131529,7 +131636,7 @@ async function extractArtifactSnapshot(artifact, extractionDir, filter) {
|
|
|
131529
131636
|
await pipeline3(Readable2.from([artifact]), So({ cwd: extractionDir, strip: 1, strict: true, filter }));
|
|
131530
131637
|
}
|
|
131531
131638
|
async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
131532
|
-
|
|
131639
|
+
mkdirSync18(extractionDir, { recursive: true, mode: 448 });
|
|
131533
131640
|
const allowed = /* @__PURE__ */ new Map([
|
|
131534
131641
|
["package/package.json", MAX_MANIFEST_BYTES],
|
|
131535
131642
|
["package/npm-shrinkwrap.json", MAX_LOCKFILE_BYTES]
|
|
@@ -131546,15 +131653,15 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
|
131546
131653
|
seen2.add(path3);
|
|
131547
131654
|
return true;
|
|
131548
131655
|
});
|
|
131549
|
-
const manifestPath =
|
|
131550
|
-
const lockPath =
|
|
131656
|
+
const manifestPath = join42(extractionDir, "package.json");
|
|
131657
|
+
const lockPath = join42(extractionDir, "npm-shrinkwrap.json");
|
|
131551
131658
|
let manifest;
|
|
131552
131659
|
let lock;
|
|
131553
131660
|
try {
|
|
131554
131661
|
if (statSync7(lockPath).size > MAX_LOCKFILE_BYTES)
|
|
131555
131662
|
throw new Error("lockfile too large");
|
|
131556
|
-
manifest = JSON.parse(
|
|
131557
|
-
lock = JSON.parse(
|
|
131663
|
+
manifest = JSON.parse(readFileSync38(manifestPath, "utf8"));
|
|
131664
|
+
lock = JSON.parse(readFileSync38(lockPath, "utf8"));
|
|
131558
131665
|
} catch (cause) {
|
|
131559
131666
|
throw new Error(`the verified artifact has no readable npm-shrinkwrap dependency lock: ${message(cause)}`);
|
|
131560
131667
|
}
|
|
@@ -131591,8 +131698,8 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
|
131591
131698
|
}
|
|
131592
131699
|
let bundledManifest;
|
|
131593
131700
|
try {
|
|
131594
|
-
const bundledPath =
|
|
131595
|
-
bundledManifest = JSON.parse(
|
|
131701
|
+
const bundledPath = join42(extractionDir, ...lockPath2.split("/"), "package.json");
|
|
131702
|
+
bundledManifest = JSON.parse(readFileSync38(bundledPath, "utf8"));
|
|
131596
131703
|
} catch (cause) {
|
|
131597
131704
|
throw new Error(`the verified artifact has an unreadable bundled dependency ${lockPath2}: ${message(cause)}`);
|
|
131598
131705
|
}
|
|
@@ -131662,10 +131769,10 @@ ${GITHUB_REPOSITORY_ID}`,
|
|
|
131662
131769
|
// dist/commands/update.js
|
|
131663
131770
|
import { spawn as spawn6 } from "node:child_process";
|
|
131664
131771
|
import { randomBytes as randomBytes8 } from "node:crypto";
|
|
131665
|
-
import { closeSync as closeSync5, constants as constants2, fstatSync, mkdtempSync as mkdtempSync3, openSync as openSync5, readFileSync as
|
|
131772
|
+
import { closeSync as closeSync5, constants as constants2, fstatSync, mkdtempSync as mkdtempSync3, openSync as openSync5, readFileSync as readFileSync39, readSync, rmSync as rmSync14, unlinkSync as unlinkSync5, writeFileSync as writeFileSync24 } from "node:fs";
|
|
131666
131773
|
import { createServer } from "node:http";
|
|
131667
131774
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
131668
|
-
import { join as
|
|
131775
|
+
import { join as join43 } from "node:path";
|
|
131669
131776
|
function refuse2(cause) {
|
|
131670
131777
|
error(`Update refused: ${message2(cause)}.`);
|
|
131671
131778
|
info(`To install the latest release with npm instead, run: ${teal(NPM_UPDATE_COMMAND)}`);
|
|
@@ -131673,7 +131780,7 @@ function refuse2(cause) {
|
|
|
131673
131780
|
}
|
|
131674
131781
|
function currentVersion2() {
|
|
131675
131782
|
try {
|
|
131676
|
-
const pkg = JSON.parse(
|
|
131783
|
+
const pkg = JSON.parse(readFileSync39(join43(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
131677
131784
|
return pkg.version;
|
|
131678
131785
|
} catch {
|
|
131679
131786
|
return "0.0.0";
|
|
@@ -131812,12 +131919,12 @@ async function serveArtifactSnapshot(artifact) {
|
|
|
131812
131919
|
}
|
|
131813
131920
|
async function installVerifiedTarball(tarballPath, tempDir, release2) {
|
|
131814
131921
|
const ambientEnvironment = { ...process.env };
|
|
131815
|
-
const packageDir =
|
|
131816
|
-
const cacheDir =
|
|
131817
|
-
const userConfigPath =
|
|
131818
|
-
const globalConfigPath =
|
|
131819
|
-
|
|
131820
|
-
|
|
131922
|
+
const packageDir = join43(tempDir, "authenticated-package");
|
|
131923
|
+
const cacheDir = join43(tempDir, "empty-cache");
|
|
131924
|
+
const userConfigPath = join43(tempDir, "user-npmrc");
|
|
131925
|
+
const globalConfigPath = join43(tempDir, "global-npmrc");
|
|
131926
|
+
writeFileSync24(userConfigPath, "", { mode: 384 });
|
|
131927
|
+
writeFileSync24(globalConfigPath, "", { mode: 384 });
|
|
131821
131928
|
const artifact = snapshotAuthenticatedArtifact(tarballPath);
|
|
131822
131929
|
let artifactServer;
|
|
131823
131930
|
try {
|
|
@@ -131887,9 +131994,9 @@ async function runUpdate(opts, dependencies = {}) {
|
|
|
131887
131994
|
const provenance = await fetchJson(fetchImpl, release2.attestationUrl, "the official npm provenance endpoint");
|
|
131888
131995
|
await (dependencies.verifyProvenance ?? verifyPublishedProvenance)(provenance, release2);
|
|
131889
131996
|
const tarball = await downloadTarball(fetchImpl, release2);
|
|
131890
|
-
tempDir = mkdtempSync3(
|
|
131891
|
-
const tarballPath =
|
|
131892
|
-
|
|
131997
|
+
tempDir = mkdtempSync3(join43(tmpdir2(), "somewhere-update-"));
|
|
131998
|
+
const tarballPath = join43(tempDir, `cli-${release2.version}.tgz`);
|
|
131999
|
+
writeFileSync24(tarballPath, tarball, { mode: 384 });
|
|
131893
132000
|
info(`Cryptographically verified provenance and integrity for ${CLI_PACKAGE}@${release2.version}.`);
|
|
131894
132001
|
info(`Updating ${CLI_PACKAGE} from its authenticated dependency lock \u2026`);
|
|
131895
132002
|
await (dependencies.install ?? installVerifiedTarball)(tarballPath, tempDir, release2);
|
|
@@ -131897,7 +132004,7 @@ async function runUpdate(opts, dependencies = {}) {
|
|
|
131897
132004
|
return refuse2(cause);
|
|
131898
132005
|
} finally {
|
|
131899
132006
|
if (tempDir)
|
|
131900
|
-
|
|
132007
|
+
rmSync14(tempDir, { recursive: true, force: true });
|
|
131901
132008
|
}
|
|
131902
132009
|
success(`Updated to ${release2.version}. Run ${teal(`${cliInvocation()} --version`)} to confirm.`);
|
|
131903
132010
|
info(PROJECT_PIN_NOTE);
|
|
@@ -132020,7 +132127,7 @@ var init_upgrade = __esm({
|
|
|
132020
132127
|
});
|
|
132021
132128
|
|
|
132022
132129
|
// dist/commands/call.js
|
|
132023
|
-
import { readFileSync as
|
|
132130
|
+
import { readFileSync as readFileSync40 } from "node:fs";
|
|
132024
132131
|
function parseArguments(value, file) {
|
|
132025
132132
|
if (value === void 0)
|
|
132026
132133
|
return {};
|
|
@@ -132044,7 +132151,7 @@ function readCallArguments(jsonArgs, file) {
|
|
|
132044
132151
|
}
|
|
132045
132152
|
let text;
|
|
132046
132153
|
try {
|
|
132047
|
-
text =
|
|
132154
|
+
text = readFileSync40(file, "utf8");
|
|
132048
132155
|
} catch (err) {
|
|
132049
132156
|
const code = err?.code;
|
|
132050
132157
|
throw new Error(`Could not read --file ${file}${code ? ` (${code})` : ""}. The requested tool was not called.`);
|
|
@@ -132729,7 +132836,7 @@ async function waitForDeploy(client, projectId, commitSha) {
|
|
|
132729
132836
|
function urls(projectId, servingUrl) {
|
|
132730
132837
|
return {
|
|
132731
132838
|
live_url: servingUrl,
|
|
132732
|
-
|
|
132839
|
+
logs_command: `${cliInvocation()} logs ${projectId}`
|
|
132733
132840
|
};
|
|
132734
132841
|
}
|
|
132735
132842
|
function registerGit(program2) {
|
|
@@ -132774,7 +132881,7 @@ function registerGit(program2) {
|
|
|
132774
132881
|
} else {
|
|
132775
132882
|
success(`Deployed ${connection.repo}@${commitSha.slice(0, 7)}`);
|
|
132776
132883
|
info(`Status: ${connection.last_status}`);
|
|
132777
|
-
info(`Logs: ${dim(links.
|
|
132884
|
+
info(`Logs: ${dim(links.logs_command)}`);
|
|
132778
132885
|
if (links.live_url)
|
|
132779
132886
|
info(`Live: ${teal(links.live_url)}`);
|
|
132780
132887
|
}
|
|
@@ -132806,7 +132913,7 @@ function registerGit(program2) {
|
|
|
132806
132913
|
info(`Status: ${connection.last_status || "waiting for first deploy"}`);
|
|
132807
132914
|
if (connection.last_error)
|
|
132808
132915
|
info(`Error: ${connection.last_error}`);
|
|
132809
|
-
info(`Logs: ${dim(links.
|
|
132916
|
+
info(`Logs: ${dim(links.logs_command)}`);
|
|
132810
132917
|
if (links.live_url)
|
|
132811
132918
|
info(`Live: ${teal(links.live_url)}`);
|
|
132812
132919
|
console.log("");
|
|
@@ -132855,7 +132962,7 @@ var init_git = __esm({
|
|
|
132855
132962
|
init_output();
|
|
132856
132963
|
init_project_urls();
|
|
132857
132964
|
init_link_hint();
|
|
132858
|
-
DASHBOARD = "https://somewhere.cloud/
|
|
132965
|
+
DASHBOARD = "https://somewhere.cloud/app";
|
|
132859
132966
|
INSTALL_TIMEOUT_MS = 5 * 6e4;
|
|
132860
132967
|
DEPLOY_POLL_MS = 1500;
|
|
132861
132968
|
__name(sleep2, "sleep");
|
|
@@ -133757,34 +133864,34 @@ var init_test_report = __esm({
|
|
|
133757
133864
|
|
|
133758
133865
|
// dist/lib/test-scripts.js
|
|
133759
133866
|
import { createRequire as createRequire9 } from "node:module";
|
|
133760
|
-
import { existsSync as
|
|
133761
|
-
import { dirname as dirname14, join as
|
|
133867
|
+
import { existsSync as existsSync37, mkdirSync as mkdirSync19, readFileSync as readFileSync41, readdirSync as readdirSync8, rmSync as rmSync15, statSync as statSync8, writeFileSync as writeFileSync25 } from "node:fs";
|
|
133868
|
+
import { dirname as dirname14, join as join44, relative as relative12, resolve as resolve24 } from "node:path";
|
|
133762
133869
|
import { spawn as spawn7, spawnSync as spawnSync5 } from "node:child_process";
|
|
133763
133870
|
function hasSpecFiles(root) {
|
|
133764
133871
|
const walk2 = /* @__PURE__ */ __name((dir) => {
|
|
133765
|
-
if (!
|
|
133872
|
+
if (!existsSync37(dir))
|
|
133766
133873
|
return false;
|
|
133767
133874
|
for (const entry of readdirSync8(dir, { withFileTypes: true })) {
|
|
133768
133875
|
if (entry.name === "node_modules" || entry.name.startsWith("."))
|
|
133769
133876
|
continue;
|
|
133770
|
-
const path3 =
|
|
133877
|
+
const path3 = join44(dir, entry.name);
|
|
133771
133878
|
if (entry.isDirectory() ? walk2(path3) : /\.spec\.ts$/.test(entry.name))
|
|
133772
133879
|
return true;
|
|
133773
133880
|
}
|
|
133774
133881
|
return false;
|
|
133775
133882
|
}, "walk");
|
|
133776
|
-
return walk2(
|
|
133883
|
+
return walk2(join44(root, "tests"));
|
|
133777
133884
|
}
|
|
133778
133885
|
function listScripts(root, files) {
|
|
133779
133886
|
if (files.length)
|
|
133780
133887
|
return files.map((file) => relative12(root, resolve24(root, file)));
|
|
133781
|
-
const dir =
|
|
133782
|
-
if (!
|
|
133888
|
+
const dir = join44(root, "tests");
|
|
133889
|
+
if (!existsSync37(dir))
|
|
133783
133890
|
return [];
|
|
133784
|
-
return readdirSync8(dir).filter((name) => isScript(name) && statSync8(
|
|
133891
|
+
return readdirSync8(dir).filter((name) => isScript(name) && statSync8(join44(dir, name)).isFile()).sort().map((name) => join44("tests", name));
|
|
133785
133892
|
}
|
|
133786
133893
|
function scriptBrowserEnv(root) {
|
|
133787
|
-
const require5 = createRequire9(
|
|
133894
|
+
const require5 = createRequire9(join44(root, "package.json"));
|
|
133788
133895
|
let cli;
|
|
133789
133896
|
try {
|
|
133790
133897
|
cli = require5.resolve("@playwright/test/cli");
|
|
@@ -133795,7 +133902,7 @@ function scriptBrowserEnv(root) {
|
|
|
133795
133902
|
const probe = spawnSync5(process.execPath, ["-e", "require(process.argv[1]).chromium.launch().then(b => b.close()).then(() => process.exit(0), () => process.exit(3))", require5.resolve("@playwright/test")], { env, stdio: "ignore" });
|
|
133796
133903
|
if (probe.status === 0)
|
|
133797
133904
|
return env;
|
|
133798
|
-
env.PLAYWRIGHT_BROWSERS_PATH ??=
|
|
133905
|
+
env.PLAYWRIGHT_BROWSERS_PATH ??= join44(cliConfigDir(), "cache", "playwright");
|
|
133799
133906
|
process.stderr.write("Installing Playwright Chromium in the CLI cache (once).\n");
|
|
133800
133907
|
const install = spawnSync5(process.execPath, [cli, "install", "chromium"], { stdio: "inherit", env });
|
|
133801
133908
|
if (install.status !== 0)
|
|
@@ -133818,7 +133925,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
133818
133925
|
env = testImportEnv(root, env);
|
|
133819
133926
|
const results = [];
|
|
133820
133927
|
for (const script of scripts) {
|
|
133821
|
-
if (!
|
|
133928
|
+
if (!existsSync37(join44(root, script))) {
|
|
133822
133929
|
results.push({ script, ok: false, exitCode: 1, ms: 0, reason: "no such file" });
|
|
133823
133930
|
continue;
|
|
133824
133931
|
}
|
|
@@ -133827,9 +133934,9 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
133827
133934
|
`);
|
|
133828
133935
|
const started = performance.now();
|
|
133829
133936
|
let output = "";
|
|
133830
|
-
const handOver =
|
|
133831
|
-
|
|
133832
|
-
|
|
133937
|
+
const handOver = join44(root, ".somewhere", "tests", `report-${results.length}.json`);
|
|
133938
|
+
mkdirSync19(dirname14(handOver), { recursive: true });
|
|
133939
|
+
rmSync15(handOver, { force: true });
|
|
133833
133940
|
const askedForBrowserLog = /(^|,)\s*(pw:browser|pw:\*|\*)\s*(,|$)/.test(env.DEBUG ?? "");
|
|
133834
133941
|
const childEnv = { ...env, SW_TEST_REPORT: handOver, DEBUG: askedForBrowserLog ? env.DEBUG : [env.DEBUG, "pw:browser"].filter(Boolean).join(",") };
|
|
133835
133942
|
const child = spawn7(process.execPath, [script, ...extraArgs], { cwd: root, env: childEnv, stdio: ["inherit", "pipe", "pipe"] });
|
|
@@ -133857,11 +133964,11 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
133857
133964
|
stderrLines("", true);
|
|
133858
133965
|
let report2 = null;
|
|
133859
133966
|
try {
|
|
133860
|
-
report2 =
|
|
133967
|
+
report2 = existsSync37(handOver) ? JSON.parse(readFileSync41(handOver, "utf8")) : null;
|
|
133861
133968
|
} catch {
|
|
133862
133969
|
report2 = null;
|
|
133863
133970
|
}
|
|
133864
|
-
|
|
133971
|
+
rmSync15(handOver, { force: true });
|
|
133865
133972
|
results.push({
|
|
133866
133973
|
script,
|
|
133867
133974
|
ok: exitCode === 0,
|
|
@@ -133890,20 +133997,20 @@ function describeScriptResults(results, options2 = {}) {
|
|
|
133890
133997
|
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;
|
|
133891
133998
|
}
|
|
133892
133999
|
function lastFailedScripts(root) {
|
|
133893
|
-
const path3 =
|
|
133894
|
-
if (!
|
|
134000
|
+
const path3 = join44(root, LAST);
|
|
134001
|
+
if (!existsSync37(path3))
|
|
133895
134002
|
return [];
|
|
133896
134003
|
try {
|
|
133897
|
-
return (JSON.parse(
|
|
134004
|
+
return (JSON.parse(readFileSync41(path3, "utf8")).results ?? []).filter((r) => !r.ok).map((r) => r.script);
|
|
133898
134005
|
} catch {
|
|
133899
134006
|
return [];
|
|
133900
134007
|
}
|
|
133901
134008
|
}
|
|
133902
134009
|
function recordScriptResults(root, results, rerunOnly) {
|
|
133903
|
-
const previous = rerunOnly &&
|
|
134010
|
+
const previous = rerunOnly && existsSync37(join44(root, LAST)) ? JSON.parse(readFileSync41(join44(root, LAST), "utf8")).results ?? [] : [];
|
|
133904
134011
|
const merged = [...previous.filter((p2) => !results.some((r) => r.script === p2.script)), ...results];
|
|
133905
|
-
|
|
133906
|
-
|
|
134012
|
+
mkdirSync19(join44(root, ".somewhere", "tests"), { recursive: true });
|
|
134013
|
+
writeFileSync25(join44(root, LAST), JSON.stringify({ finished: (/* @__PURE__ */ new Date()).toISOString(), results: merged }, null, 2) + "\n");
|
|
133907
134014
|
}
|
|
133908
134015
|
var BROWSER_CRASH, BROWSER_CRASH_REASON, isScript, LAST;
|
|
133909
134016
|
var init_test_scripts = __esm({
|
|
@@ -133921,7 +134028,7 @@ var init_test_scripts = __esm({
|
|
|
133921
134028
|
__name(failureReason, "failureReason");
|
|
133922
134029
|
__name(runScripts, "runScripts");
|
|
133923
134030
|
__name(describeScriptResults, "describeScriptResults");
|
|
133924
|
-
LAST =
|
|
134031
|
+
LAST = join44(".somewhere", "tests", "scripts-last.json");
|
|
133925
134032
|
__name(lastFailedScripts, "lastFailedScripts");
|
|
133926
134033
|
__name(recordScriptResults, "recordScriptResults");
|
|
133927
134034
|
}
|
|
@@ -134002,8 +134109,8 @@ var init_test = __esm({
|
|
|
134002
134109
|
});
|
|
134003
134110
|
|
|
134004
134111
|
// dist/commands/test-users.js
|
|
134005
|
-
import { existsSync as
|
|
134006
|
-
import { basename as basename9, join as
|
|
134112
|
+
import { existsSync as existsSync38, readFileSync as readFileSync42, rmSync as rmSync16 } from "node:fs";
|
|
134113
|
+
import { basename as basename9, join as join45 } from "node:path";
|
|
134007
134114
|
import { randomBytes as randomBytes9 } from "node:crypto";
|
|
134008
134115
|
async function resolveTarget(projectOpt, originOpt) {
|
|
134009
134116
|
const root = process.cwd();
|
|
@@ -134093,7 +134200,7 @@ function registerTestUsers(program2) {
|
|
|
134093
134200
|
const record3 = /* @__PURE__ */ __name((spec, issued, receivedAt) => {
|
|
134094
134201
|
const times = expiryOf(issued, receivedAt);
|
|
134095
134202
|
const file = `${spec.name}.state.json`;
|
|
134096
|
-
writePrivateFile(
|
|
134203
|
+
writePrivateFile(join45(dir, file), JSON.stringify(buildStorageState(target.origin, target.host, issued, times), null, 2) + "\n");
|
|
134097
134204
|
const actor = {
|
|
134098
134205
|
name: spec.name,
|
|
134099
134206
|
user_id: issued.user.id,
|
|
@@ -134194,7 +134301,7 @@ function registerTestUsers(program2) {
|
|
|
134194
134301
|
if (name !== opts.linkOut || !/^[A-Za-z0-9._-]{1,64}$/.test(name))
|
|
134195
134302
|
throw new Error(`--link-out takes a file name; it is written under ${TEST_STATE_DIR}/.`);
|
|
134196
134303
|
ensurePrivateDir(stateDir(target.root));
|
|
134197
|
-
writePrivateFile(
|
|
134304
|
+
writePrivateFile(join45(stateDir(target.root), name), newest.magic_link + "\n");
|
|
134198
134305
|
linkFile = `${TEST_STATE_DIR}/${name}`;
|
|
134199
134306
|
}
|
|
134200
134307
|
const message3 = {
|
|
@@ -134265,12 +134372,12 @@ function registerTestUsers(program2) {
|
|
|
134265
134372
|
local_state: { removed: localRemoved, kept: manifest.actors.map((actor) => actor.state_file).filter((file) => !localRemoved.includes(file)) },
|
|
134266
134373
|
actors: manifest.actors.map(({ name, user_id, email: email2, role, created_at }) => ({ name, user_id, email: email2, role, created_at }))
|
|
134267
134374
|
};
|
|
134268
|
-
writePrivateFile(
|
|
134375
|
+
writePrivateFile(join45(stateDir(target.root), CLEANUP_RECEIPT_FILE), JSON.stringify(receipt, null, 2) + "\n");
|
|
134269
134376
|
const left = manifest.actors.filter((actor) => !removed.includes(actor.user_id));
|
|
134270
134377
|
if (left.length)
|
|
134271
134378
|
writeManifest(target.root, { ...manifest, actors: left, status: "partial" });
|
|
134272
134379
|
else
|
|
134273
|
-
|
|
134380
|
+
rmSync16(join45(stateDir(target.root), MANIFEST_FILE), { force: true });
|
|
134274
134381
|
if (opts.json) {
|
|
134275
134382
|
printJson(receipt);
|
|
134276
134383
|
if (left.length)
|
|
@@ -134310,7 +134417,7 @@ var init_test_users = __esm({
|
|
|
134310
134417
|
});
|
|
134311
134418
|
|
|
134312
134419
|
// dist/commands/support.js
|
|
134313
|
-
import { join as
|
|
134420
|
+
import { join as join46 } from "node:path";
|
|
134314
134421
|
function commandPaths(program2) {
|
|
134315
134422
|
const paths = /* @__PURE__ */ new Set();
|
|
134316
134423
|
const walk2 = /* @__PURE__ */ __name((command, prefix) => {
|
|
@@ -134395,7 +134502,7 @@ function emitPacket(packet, opts) {
|
|
|
134395
134502
|
if (opts.out) {
|
|
134396
134503
|
if (!/^[A-Za-z0-9._-]{1,64}$/.test(opts.out))
|
|
134397
134504
|
throw new Error("--out takes a plain file name in the current folder.");
|
|
134398
|
-
writePrivateFile(
|
|
134505
|
+
writePrivateFile(join46(process.cwd(), opts.out), JSON.stringify(packet, null, 2) + "\n");
|
|
134399
134506
|
}
|
|
134400
134507
|
if (opts.json) {
|
|
134401
134508
|
printJson(packet);
|
|
@@ -134517,7 +134624,7 @@ var init_skills = __esm({
|
|
|
134517
134624
|
});
|
|
134518
134625
|
|
|
134519
134626
|
// dist/commands/ai.js
|
|
134520
|
-
import { readFileSync as
|
|
134627
|
+
import { readFileSync as readFileSync43 } from "node:fs";
|
|
134521
134628
|
function fail4(message3) {
|
|
134522
134629
|
error(message3);
|
|
134523
134630
|
process.exit(1);
|
|
@@ -134538,7 +134645,7 @@ async function readKey(stdin) {
|
|
|
134538
134645
|
if (stdin) {
|
|
134539
134646
|
if (process.stdin.isTTY)
|
|
134540
134647
|
fail4("Pipe the key into --stdin, or leave out --stdin to type it into a hidden prompt.");
|
|
134541
|
-
raw =
|
|
134648
|
+
raw = readFileSync43(0, "utf8");
|
|
134542
134649
|
} else {
|
|
134543
134650
|
if (!process.stdin.isTTY)
|
|
134544
134651
|
fail4("Pass --stdin to read the key from a pipe. Nothing was sent.");
|
|
@@ -134685,11 +134792,11 @@ var init_startup_notice = __esm({
|
|
|
134685
134792
|
});
|
|
134686
134793
|
|
|
134687
134794
|
// dist/lib/last-run.js
|
|
134688
|
-
import { lstatSync as lstatSync5, mkdirSync as
|
|
134689
|
-
import { join as
|
|
134795
|
+
import { lstatSync as lstatSync5, mkdirSync as mkdirSync20, renameSync as renameSync6, unlinkSync as unlinkSync6, writeFileSync as writeFileSync26 } from "node:fs";
|
|
134796
|
+
import { join as join47 } from "node:path";
|
|
134690
134797
|
function removeStaleRunRecord(dir = cliConfigDir()) {
|
|
134691
134798
|
for (const name of RUN_RECORD_FILES) {
|
|
134692
|
-
const path3 =
|
|
134799
|
+
const path3 = join47(dir, name);
|
|
134693
134800
|
try {
|
|
134694
134801
|
if (lstatSync5(path3).isDirectory()) {
|
|
134695
134802
|
process.stderr.write(`Could not remove ${path3}: it is a directory, not this CLI's run record. Check it yourself.
|
|
@@ -134720,7 +134827,7 @@ function recordLastRun(cliVersion) {
|
|
|
134720
134827
|
process.once("exit", (exitCode) => {
|
|
134721
134828
|
try {
|
|
134722
134829
|
const dir = cliConfigDir();
|
|
134723
|
-
|
|
134830
|
+
mkdirSync20(dir, { recursive: true, mode: 448 });
|
|
134724
134831
|
const record3 = {
|
|
134725
134832
|
// A usage error never reaches a command: no command and no options.
|
|
134726
134833
|
command: invocation?.command ?? "",
|
|
@@ -134729,9 +134836,9 @@ function recordLastRun(cliVersion) {
|
|
|
134729
134836
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
134730
134837
|
cli_version: cliVersion
|
|
134731
134838
|
};
|
|
134732
|
-
const path3 =
|
|
134733
|
-
const temporary =
|
|
134734
|
-
|
|
134839
|
+
const path3 = join47(dir, "last-run.json");
|
|
134840
|
+
const temporary = join47(dir, "last-run.json.tmp");
|
|
134841
|
+
writeFileSync26(temporary, JSON.stringify(record3) + "\n", { mode: 384 });
|
|
134735
134842
|
renameSync6(temporary, path3);
|
|
134736
134843
|
} catch {
|
|
134737
134844
|
}
|
|
@@ -134768,8 +134875,8 @@ __export(dist_exports, {
|
|
|
134768
134875
|
runCli: () => runCli
|
|
134769
134876
|
});
|
|
134770
134877
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
134771
|
-
import { readFileSync as
|
|
134772
|
-
import { join as
|
|
134878
|
+
import { readFileSync as readFileSync44 } from "node:fs";
|
|
134879
|
+
import { join as join48 } from "node:path";
|
|
134773
134880
|
async function runCli() {
|
|
134774
134881
|
const pinned = decidePin(process.cwd(), CLI_VERSION, process.argv, process.env);
|
|
134775
134882
|
if (pinned.notice)
|
|
@@ -134797,7 +134904,7 @@ async function runCli() {
|
|
|
134797
134904
|
process.exit(child.status ?? 1);
|
|
134798
134905
|
}
|
|
134799
134906
|
removeStaleRunRecord();
|
|
134800
|
-
const pkg = JSON.parse(
|
|
134907
|
+
const pkg = JSON.parse(readFileSync44(join48(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
134801
134908
|
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);
|
|
134802
134909
|
recordLastRun(pkg.version);
|
|
134803
134910
|
const jsonOutputRequested = process.argv.includes("--json");
|
|
@@ -135585,8 +135692,8 @@ var init_form_auth = __esm({
|
|
|
135585
135692
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
135586
135693
|
import { setDefaultResultOrder } from "node:dns";
|
|
135587
135694
|
import { lookup } from "node:dns/promises";
|
|
135588
|
-
import { existsSync as
|
|
135589
|
-
import { basename as basename10, dirname as dirname15, join as
|
|
135695
|
+
import { existsSync as existsSync39, mkdirSync as mkdirSync21, readFileSync as readFileSync45, writeFileSync as writeFileSync27 } from "node:fs";
|
|
135696
|
+
import { basename as basename10, dirname as dirname15, join as join49, relative as relative14, resolve as resolve25 } from "node:path";
|
|
135590
135697
|
function launchOptions(extra = {}) {
|
|
135591
135698
|
return { ...extra, args: ["--disable-features=AsyncDns", ...extra.args ?? []] };
|
|
135592
135699
|
}
|
|
@@ -135636,10 +135743,10 @@ function undeployedChanges(root, projectId, preview = false) {
|
|
|
135636
135743
|
return null;
|
|
135637
135744
|
base = { project_id: record3.project_id, release_id: record3.preview_id, files: record3.files };
|
|
135638
135745
|
} else {
|
|
135639
|
-
const path3 =
|
|
135640
|
-
if (!
|
|
135746
|
+
const path3 = join49(root, ".somewhere", "base-files.json");
|
|
135747
|
+
if (!existsSync39(path3))
|
|
135641
135748
|
return null;
|
|
135642
|
-
base = JSON.parse(
|
|
135749
|
+
base = JSON.parse(readFileSync45(path3, "utf8"));
|
|
135643
135750
|
}
|
|
135644
135751
|
if (base.project_id !== projectId || !base.files)
|
|
135645
135752
|
return null;
|
|
@@ -135806,7 +135913,7 @@ var init_app_test = __esm({
|
|
|
135806
135913
|
for (const line of describeSweep(await sweepAccounts(control, root), "Before this script"))
|
|
135807
135914
|
process.stderr.write(line + "\n");
|
|
135808
135915
|
const scriptName = process.argv[1] ? basename10(process.argv[1]).replace(/\.[cm]?[jt]s$/, "") : "app-check";
|
|
135809
|
-
const app = new _AppTest(root, control, resolve25(root, options2.results ??
|
|
135916
|
+
const app = new _AppTest(root, control, resolve25(root, options2.results ?? join49(".somewhere", `${scriptName}${preview ? "-preview" : ""}.json`)));
|
|
135810
135917
|
return app;
|
|
135811
135918
|
}
|
|
135812
135919
|
/** What this run tests: the project, environment, preview, origin and script. */
|
|
@@ -135988,8 +136095,8 @@ page ${i + 1}: ${state}`).join("");
|
|
|
135988
136095
|
}
|
|
135989
136096
|
const passed = this.checks.filter((check) => check.ok).length;
|
|
135990
136097
|
const failed = this.checks.filter((check) => !check.ok && !check.skipped).length;
|
|
135991
|
-
|
|
135992
|
-
|
|
136098
|
+
mkdirSync21(dirname15(this.resultsPath), { recursive: true });
|
|
136099
|
+
writeFileSync27(this.resultsPath, JSON.stringify({
|
|
135993
136100
|
identity: this.identity(),
|
|
135994
136101
|
origin: this.origin,
|
|
135995
136102
|
environment: this.control.environment,
|
|
@@ -136008,7 +136115,7 @@ page ${i + 1}: ${state}`).join("");
|
|
|
136008
136115
|
const resultFile = relative14(this.root, this.resultsPath);
|
|
136009
136116
|
const handOver = process.env.SW_TEST_REPORT;
|
|
136010
136117
|
if (handOver)
|
|
136011
|
-
|
|
136118
|
+
writeFileSync27(handOver, JSON.stringify({ checks: reported, resultFile }) + "\n");
|
|
136012
136119
|
else {
|
|
136013
136120
|
const verbose = process.argv.includes("--verbose") || process.env.SW_TEST_VERBOSE === "1";
|
|
136014
136121
|
const script = process.argv[1] ? relative14(this.root, resolve25(process.argv[1])) : "this script";
|
|
@@ -136077,7 +136184,7 @@ var init_screenshot_guard = __esm({
|
|
|
136077
136184
|
|
|
136078
136185
|
// dist/lib/playwright-fixtures.js
|
|
136079
136186
|
import { createRequire as createRequire10 } from "node:module";
|
|
136080
|
-
import { join as
|
|
136187
|
+
import { join as join50 } from "node:path";
|
|
136081
136188
|
function runTarget(projectId) {
|
|
136082
136189
|
if (!process.env.SW_TEST_TARGET)
|
|
136083
136190
|
return null;
|
|
@@ -136102,7 +136209,7 @@ async function previewControlForWorker() {
|
|
|
136102
136209
|
function runner() {
|
|
136103
136210
|
if (loaded)
|
|
136104
136211
|
return loaded;
|
|
136105
|
-
const require5 = createRequire10(
|
|
136212
|
+
const require5 = createRequire10(join50(process.cwd(), "package.json"));
|
|
136106
136213
|
let pw;
|
|
136107
136214
|
try {
|
|
136108
136215
|
pw = require5("@playwright/test");
|