@somewhere-cloud/cli 0.38.155 → 0.38.157
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 +8 -1
- package/dist/commands/docs.js +1 -1
- package/dist/lib/bundle.js +286 -188
- package/dist/lib/bundle.js.map +3 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -3
- package/dist/docs/adopt.md +0 -39
- package/dist/docs/analytics.md +0 -161
- package/dist/docs/api-reference.md +0 -339
- package/dist/docs/api-surface.md +0 -2067
- package/dist/docs/app-mcp.md +0 -162
- package/dist/docs/architecture-patterns.md +0 -334
- package/dist/docs/auth-client.md +0 -531
- package/dist/docs/billing.md +0 -76
- package/dist/docs/browser.md +0 -639
- package/dist/docs/calendar.md +0 -298
- package/dist/docs/changes.md +0 -323
- package/dist/docs/cli.md +0 -407
- package/dist/docs/common-mistakes.md +0 -199
- package/dist/docs/connect-agent.md +0 -72
- package/dist/docs/cors.md +0 -114
- package/dist/docs/cron.md +0 -167
- package/dist/docs/database-engine.md +0 -167
- package/dist/docs/declared-data.md +0 -1656
- package/dist/docs/declared-files.md +0 -475
- package/dist/docs/deploy-intelligence.md +0 -188
- package/dist/docs/deploy.md +0 -733
- package/dist/docs/design-system.md +0 -273
- package/dist/docs/dev-environments.md +0 -496
- package/dist/docs/domain-ownership.md +0 -31
- package/dist/docs/domains.md +0 -370
- package/dist/docs/feedback.md +0 -88
- package/dist/docs/file-tools.md +0 -116
- package/dist/docs/functions.md +0 -489
- package/dist/docs/getting-started.md +0 -238
- package/dist/docs/github.md +0 -95
- package/dist/docs/google-calendar.md +0 -212
- package/dist/docs/groups.md +0 -836
- package/dist/docs/guarantees.md +0 -58
- package/dist/docs/handled-for-you.md +0 -224
- package/dist/docs/inspect.md +0 -171
- package/dist/docs/limits.md +0 -68
- package/dist/docs/live-data.md +0 -197
- package/dist/docs/live.md +0 -92
- package/dist/docs/local-dev.md +0 -30
- package/dist/docs/migration-supabase.md +0 -58
- package/dist/docs/payments.md +0 -1102
- package/dist/docs/portability.md +0 -194
- package/dist/docs/postgres.md +0 -301
- package/dist/docs/pricing-comparison.md +0 -42
- package/dist/docs/pricing.md +0 -39
- package/dist/docs/project-groups.md +0 -107
- package/dist/docs/projects.md +0 -380
- package/dist/docs/recipe-ai-agent.md +0 -112
- package/dist/docs/recipe-ai-features.md +0 -227
- package/dist/docs/recipe-ai-receipts.md +0 -783
- package/dist/docs/recipe-background-jobs.md +0 -369
- package/dist/docs/recipe-booking.md +0 -348
- package/dist/docs/recipe-csv-import.md +0 -390
- package/dist/docs/recipe-ecommerce.md +0 -127
- package/dist/docs/recipe-email.md +0 -282
- package/dist/docs/recipe-escalation.md +0 -133
- package/dist/docs/recipe-file-uploads.md +0 -159
- package/dist/docs/recipe-import-app.md +0 -110
- package/dist/docs/recipe-login.md +0 -457
- package/dist/docs/recipe-multi-chat.md +0 -198
- package/dist/docs/recipe-paid-api.md +0 -161
- package/dist/docs/recipe-pdfs.md +0 -205
- package/dist/docs/recipe-push-notifications.md +0 -107
- package/dist/docs/recipe-seo.md +0 -200
- package/dist/docs/recipe-signed-in-app.md +0 -330
- package/dist/docs/render.md +0 -99
- package/dist/docs/rooms.md +0 -554
- package/dist/docs/sdk.md +0 -287
- package/dist/docs/sdks.md +0 -24
- package/dist/docs/search.md +0 -199
- package/dist/docs/security-model.md +0 -168
- package/dist/docs/setup.md +0 -212
- package/dist/docs/smoke.md +0 -102
- package/dist/docs/speed.md +0 -298
- package/dist/docs/sql-compatibility.md +0 -96
- package/dist/docs/sw.agent.md +0 -248
- package/dist/docs/sw.ai.md +0 -1291
- package/dist/docs/sw.auth.md +0 -1811
- package/dist/docs/sw.billing.md +0 -171
- package/dist/docs/sw.db.md +0 -2128
- package/dist/docs/sw.email.md +0 -661
- package/dist/docs/sw.endpoint.md +0 -187
- package/dist/docs/sw.env.md +0 -303
- package/dist/docs/sw.fetch.md +0 -115
- package/dist/docs/sw.fs.md +0 -424
- package/dist/docs/sw.groups.md +0 -836
- package/dist/docs/sw.image.md +0 -69
- package/dist/docs/sw.jobs.md +0 -520
- package/dist/docs/sw.logs.md +0 -61
- package/dist/docs/sw.mail.md +0 -106
- package/dist/docs/sw.notifications.md +0 -78
- package/dist/docs/sw.push.md +0 -161
- package/dist/docs/sw.rateLimit.md +0 -67
- package/dist/docs/sw.web.md +0 -128
- package/dist/docs/tasks.md +0 -269
- package/dist/docs/test.md +0 -220
- package/dist/docs/tool-reference-account.md +0 -7
- package/dist/docs/tool-reference-ai.md +0 -121
- package/dist/docs/tool-reference-analytics.md +0 -37
- package/dist/docs/tool-reference-api.md +0 -19
- package/dist/docs/tool-reference-artifacts.md +0 -35
- package/dist/docs/tool-reference-auth.md +0 -163
- package/dist/docs/tool-reference-browser.md +0 -114
- package/dist/docs/tool-reference-code.md +0 -26
- package/dist/docs/tool-reference-connect.md +0 -21
- package/dist/docs/tool-reference-cron.md +0 -48
- package/dist/docs/tool-reference-db.md +0 -282
- package/dist/docs/tool-reference-domains.md +0 -107
- package/dist/docs/tool-reference-email.md +0 -55
- package/dist/docs/tool-reference-env.md +0 -19
- package/dist/docs/tool-reference-feedback.md +0 -56
- package/dist/docs/tool-reference-fs.md +0 -265
- package/dist/docs/tool-reference-github.md +0 -57
- package/dist/docs/tool-reference-groups.md +0 -85
- package/dist/docs/tool-reference-help.md +0 -29
- package/dist/docs/tool-reference-jobs.md +0 -39
- package/dist/docs/tool-reference-live.md +0 -48
- package/dist/docs/tool-reference-logs.md +0 -16
- package/dist/docs/tool-reference-payments.md +0 -44
- package/dist/docs/tool-reference-project.md +0 -706
- package/dist/docs/tool-reference-push.md +0 -78
- package/dist/docs/tool-reference-rate-limit.md +0 -18
- package/dist/docs/tool-reference-search.md +0 -68
- package/dist/docs/tool-reference-security.md +0 -42
- package/dist/docs/tool-reference-smoke.md +0 -17
- package/dist/docs/tool-reference-stock-photos.md +0 -20
- package/dist/docs/tool-reference-tasks.md +0 -73
- package/dist/docs/tool-reference-telegram.md +0 -32
- package/dist/docs/tool-reference-usage.md +0 -9
- package/dist/docs/tool-reference-web.md +0 -71
- package/dist/docs/tool-reference-webhooks.md +0 -9
- package/dist/docs/troubleshooting.md +0 -411
- package/dist/docs/typed-functions.md +0 -94
- package/dist/docs/verify-before-deploy.md +0 -67
- package/dist/docs/vs-supabase.md +0 -75
- package/dist/docs/vs-vercel.md +0 -103
package/dist/lib/bundle.js
CHANGED
|
@@ -44183,8 +44183,19 @@ Use \`somewhere docs <topic> --section <id>\` for one section or \`--full\` for
|
|
|
44183
44183
|
PREVIEW_POINTER = "Preview users are separate from live users. Sign up in the preview or use `somewhere preview user-add`. Check captured mail with `somewhere preview mail`.";
|
|
44184
44184
|
INIT_AGENTS_MD = `# somewhere.cloud project contract
|
|
44185
44185
|
${AGENT_WORKFLOW}
|
|
44186
|
+
### CSV imports
|
|
44187
|
+
|
|
44188
|
+
Use one background job for a large import. Normalize and deduplicate keys
|
|
44189
|
+
before writing. Pair schema uniqueness with an \`onConflict\` action that makes
|
|
44190
|
+
each batch safe to retry. Send up to 100 writes per transaction with \`sw.db.tx\` or \`sw.db.server.tx\`.
|
|
44191
|
+
Await dependent batches in order. Run up to four independent batches together,
|
|
44192
|
+
then write one progress update for the group. Set the job deadline from a timed
|
|
44193
|
+
import on your deployed app. See \`somewhere docs recipe-csv-import --full\`
|
|
44194
|
+
for the upload, job and ownership checks.
|
|
44195
|
+
|
|
44186
44196
|
${SKILLS_POINTER}
|
|
44187
|
-
Search the
|
|
44197
|
+
Search the live docs with \`somewhere docs --search "<words>"\`.
|
|
44198
|
+
Download Markdown to \`.somewhere/docs/\` with \`somewhere docs pull\`.
|
|
44188
44199
|
Without a global CLI, use \`npx @somewhere-cloud/cli deploy\` and \`npx @somewhere-cloud/cli test\`.
|
|
44189
44200
|
|
|
44190
44201
|
For Node or Playwright tests, see [Testing your app](https://somewhere.cloud/docs/test).
|
|
@@ -87274,8 +87285,76 @@ var init_postgres = __esm({
|
|
|
87274
87285
|
}
|
|
87275
87286
|
});
|
|
87276
87287
|
|
|
87288
|
+
// dist/lib/local-docs.js
|
|
87289
|
+
import { appendFileSync as appendFileSync3, existsSync as existsSync31, lstatSync as lstatSync5, mkdirSync as mkdirSync16, mkdtempSync as mkdtempSync3, readFileSync as readFileSync32, renameSync as renameSync5, rmSync as rmSync13, writeFileSync as writeFileSync21 } from "node:fs";
|
|
87290
|
+
import { join as join36 } from "node:path";
|
|
87291
|
+
function localDocsVersion(root = process.cwd()) {
|
|
87292
|
+
const path3 = join36(root, FOLDER, DOCS, STAMP);
|
|
87293
|
+
if (!existsSync31(path3))
|
|
87294
|
+
return void 0;
|
|
87295
|
+
const stamp2 = JSON.parse(readFileSync32(path3, "utf8"));
|
|
87296
|
+
return typeof stamp2.version === "string" && /^[a-f0-9]{16}$/.test(stamp2.version) ? stamp2.version : void 0;
|
|
87297
|
+
}
|
|
87298
|
+
function ensureGitIgnore(root) {
|
|
87299
|
+
const path3 = join36(root, ".gitignore");
|
|
87300
|
+
const text = existsSync31(path3) ? readFileSync32(path3, "utf8") : "";
|
|
87301
|
+
if (text.split(/\r?\n/).some((line) => line === ".somewhere/" || line === "/.somewhere/"))
|
|
87302
|
+
return;
|
|
87303
|
+
appendFileSync3(path3, `${text && !text.endsWith("\n") ? "\n" : ""}/.somewhere/
|
|
87304
|
+
`);
|
|
87305
|
+
}
|
|
87306
|
+
function saveLocalDocs(version2, files, root = process.cwd()) {
|
|
87307
|
+
const state = join36(root, FOLDER);
|
|
87308
|
+
const target = join36(state, DOCS);
|
|
87309
|
+
if (existsSync31(state) && !lstatSync5(state).isDirectory())
|
|
87310
|
+
throw new Error(`${state} must be a directory.`);
|
|
87311
|
+
if (existsSync31(target) && (!lstatSync5(target).isDirectory() || !localDocsVersion(root))) {
|
|
87312
|
+
throw new Error(`Move the existing folder at ${target} before pulling docs.`);
|
|
87313
|
+
}
|
|
87314
|
+
ensureGitIgnore(root);
|
|
87315
|
+
mkdirSync16(state, { recursive: true });
|
|
87316
|
+
const staging = mkdtempSync3(join36(state, "docs-pull-"));
|
|
87317
|
+
const next = join36(staging, "next");
|
|
87318
|
+
const previous = join36(staging, "previous");
|
|
87319
|
+
let installed = false;
|
|
87320
|
+
try {
|
|
87321
|
+
mkdirSync16(next);
|
|
87322
|
+
for (const [name, content] of files)
|
|
87323
|
+
writeFileSync21(join36(next, name), content, { flag: "wx" });
|
|
87324
|
+
const pulledAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
87325
|
+
writeFileSync21(join36(next, STAMP), JSON.stringify({ version: version2, pulledAt }) + "\n");
|
|
87326
|
+
writeFileSync21(join36(next, "README.md"), `# Somewhere docs
|
|
87327
|
+
|
|
87328
|
+
Pulled platform docs version ${version2} on ${pulledAt}. Run \`${cliInvocation()} docs\` to check whether this copy is older than the current docs and \`${cliInvocation()} docs pull\` to refresh it.
|
|
87329
|
+
`, { flag: "wx" });
|
|
87330
|
+
if (existsSync31(target))
|
|
87331
|
+
renameSync5(target, previous);
|
|
87332
|
+
renameSync5(next, target);
|
|
87333
|
+
installed = true;
|
|
87334
|
+
return target;
|
|
87335
|
+
} finally {
|
|
87336
|
+
if (!installed && existsSync31(previous) && !existsSync31(target))
|
|
87337
|
+
renameSync5(previous, target);
|
|
87338
|
+
if (installed || !existsSync31(previous))
|
|
87339
|
+
rmSync13(staging, { recursive: true, force: true });
|
|
87340
|
+
}
|
|
87341
|
+
}
|
|
87342
|
+
var FOLDER, DOCS, STAMP;
|
|
87343
|
+
var init_local_docs = __esm({
|
|
87344
|
+
"dist/lib/local-docs.js"() {
|
|
87345
|
+
"use strict";
|
|
87346
|
+
init_cli_invocation();
|
|
87347
|
+
FOLDER = ".somewhere";
|
|
87348
|
+
DOCS = "docs";
|
|
87349
|
+
STAMP = ".stamp.json";
|
|
87350
|
+
__name(localDocsVersion, "localDocsVersion");
|
|
87351
|
+
__name(ensureGitIgnore, "ensureGitIgnore");
|
|
87352
|
+
__name(saveLocalDocs, "saveLocalDocs");
|
|
87353
|
+
}
|
|
87354
|
+
});
|
|
87355
|
+
|
|
87277
87356
|
// dist/lib/advisor-context.js
|
|
87278
|
-
import { readFileSync as
|
|
87357
|
+
import { readFileSync as readFileSync33, statSync as statSync6 } from "node:fs";
|
|
87279
87358
|
import { basename as basename7 } from "node:path";
|
|
87280
87359
|
function tail(value, limit) {
|
|
87281
87360
|
return value.length <= limit ? value : `\u2026${value.slice(-limit)}`;
|
|
@@ -87297,7 +87376,7 @@ function buildAdvisorContext(filePath) {
|
|
|
87297
87376
|
const stat6 = statSync6(filePath);
|
|
87298
87377
|
if (!stat6.isFile())
|
|
87299
87378
|
throw new Error("--file must name a regular file.");
|
|
87300
|
-
const content =
|
|
87379
|
+
const content = readFileSync33(filePath, "utf8");
|
|
87301
87380
|
context.file = {
|
|
87302
87381
|
path: filePath,
|
|
87303
87382
|
content: tail(redactAdvisorText(content, isDotenvPath(filePath)), FILE_LIMIT)
|
|
@@ -87323,19 +87402,19 @@ var init_advisor_context = __esm({
|
|
|
87323
87402
|
|
|
87324
87403
|
// dist/lib/advisor-runs.js
|
|
87325
87404
|
import { randomBytes as randomBytes7, randomUUID as randomUUID7 } from "node:crypto";
|
|
87326
|
-
import { chmodSync as chmodSync4, existsSync as
|
|
87327
|
-
import { join as
|
|
87405
|
+
import { chmodSync as chmodSync4, existsSync as existsSync32, mkdirSync as mkdirSync17, readFileSync as readFileSync34, renameSync as renameSync6, writeFileSync as writeFileSync22 } from "node:fs";
|
|
87406
|
+
import { join as join37 } from "node:path";
|
|
87328
87407
|
function path2(id) {
|
|
87329
87408
|
if (!/^[a-f0-9-]{36}$/i.test(id))
|
|
87330
87409
|
throw Error("Invalid Advisor request ID.");
|
|
87331
|
-
return
|
|
87410
|
+
return join37(directory(), id + ".json");
|
|
87332
87411
|
}
|
|
87333
87412
|
function save(record3) {
|
|
87334
|
-
|
|
87413
|
+
mkdirSync17(directory(), { recursive: true, mode: 448 });
|
|
87335
87414
|
chmodSync4(directory(), 448);
|
|
87336
87415
|
const target = path2(record3.request_id), temporary = target + "." + randomUUID7() + ".tmp";
|
|
87337
|
-
|
|
87338
|
-
|
|
87416
|
+
writeFileSync22(temporary, JSON.stringify(record3), { mode: 384, flag: "wx" });
|
|
87417
|
+
renameSync6(temporary, target);
|
|
87339
87418
|
chmodSync4(target, 384);
|
|
87340
87419
|
}
|
|
87341
87420
|
function payloadDeadline(record3) {
|
|
@@ -87358,9 +87437,9 @@ function expiredResult(record3) {
|
|
|
87358
87437
|
return { run_id: record3.run_id, request_id: record3.request_id, status: record3.provider_settled ? "settled" : "delivery_expired", payload_expired: true, payload_expires_at: payloadDeadline(record3), error: "ADVISOR_PAYLOAD_EXPIRED", incomplete: true, next_step: record3.provider_settled ? "none" : "status" };
|
|
87359
87438
|
}
|
|
87360
87439
|
function load(id) {
|
|
87361
|
-
if (!
|
|
87440
|
+
if (!existsSync32(path2(id)))
|
|
87362
87441
|
throw Error("Advisor request was not found in this CLI configuration.");
|
|
87363
|
-
const record3 = JSON.parse(
|
|
87442
|
+
const record3 = JSON.parse(readFileSync34(path2(id), "utf8"));
|
|
87364
87443
|
prune(record3);
|
|
87365
87444
|
save(record3);
|
|
87366
87445
|
return record3;
|
|
@@ -87466,7 +87545,7 @@ var init_advisor_runs = __esm({
|
|
|
87466
87545
|
init_config();
|
|
87467
87546
|
init_http();
|
|
87468
87547
|
init_advisor_context();
|
|
87469
|
-
directory = /* @__PURE__ */ __name(() =>
|
|
87548
|
+
directory = /* @__PURE__ */ __name(() => join37(cliConfigDir(), "advisor-runs"), "directory");
|
|
87470
87549
|
__name(path2, "path");
|
|
87471
87550
|
__name(save, "save");
|
|
87472
87551
|
PAYLOAD_RETENTION_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -87484,8 +87563,8 @@ var init_advisor_runs = __esm({
|
|
|
87484
87563
|
|
|
87485
87564
|
// dist/lib/advisor-app.js
|
|
87486
87565
|
import { createHash as createHash8 } from "node:crypto";
|
|
87487
|
-
import { existsSync as
|
|
87488
|
-
import { join as
|
|
87566
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync18, readFileSync as readFileSync35, rmSync as rmSync14, writeFileSync as writeFileSync23 } from "node:fs";
|
|
87567
|
+
import { join as join38 } from "node:path";
|
|
87489
87568
|
async function gatherAdvisorApp(client, ref) {
|
|
87490
87569
|
const project = await client.call("GET", `/projects/${encodeURIComponent(ref)}`);
|
|
87491
87570
|
if (typeof project.id !== "string" || project.deleted === true)
|
|
@@ -87519,7 +87598,7 @@ async function gatherAdvisorApp(client, ref) {
|
|
|
87519
87598
|
}
|
|
87520
87599
|
function loadAdvisorTurns(dir, projectId, account, now2 = Date.now()) {
|
|
87521
87600
|
try {
|
|
87522
|
-
const saved = JSON.parse(
|
|
87601
|
+
const saved = JSON.parse(readFileSync35(join38(dir, FILE), "utf8"));
|
|
87523
87602
|
if (saved.project_id !== projectId || saved.owner !== ownerOf(account) || !Array.isArray(saved.turns))
|
|
87524
87603
|
return [];
|
|
87525
87604
|
const last = saved.turns.at(-1);
|
|
@@ -87529,25 +87608,25 @@ function loadAdvisorTurns(dir, projectId, account, now2 = Date.now()) {
|
|
|
87529
87608
|
}
|
|
87530
87609
|
}
|
|
87531
87610
|
function saveAdvisorTurn(dir, projectId, account, earlier, turn) {
|
|
87532
|
-
|
|
87533
|
-
|
|
87611
|
+
mkdirSync18(join38(dir, DIR), { recursive: true, mode: 448 });
|
|
87612
|
+
writeFileSync23(join38(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 });
|
|
87534
87613
|
ensureAdvisorStateIgnored(dir);
|
|
87535
87614
|
}
|
|
87536
87615
|
function clearAdvisorTurns(dir) {
|
|
87537
|
-
if (
|
|
87538
|
-
|
|
87616
|
+
if (existsSync33(join38(dir, FILE)))
|
|
87617
|
+
rmSync14(join38(dir, FILE), { force: true });
|
|
87539
87618
|
}
|
|
87540
87619
|
function ensureAdvisorStateIgnored(dir) {
|
|
87541
|
-
const path3 =
|
|
87620
|
+
const path3 = join38(dir, ".gitignore");
|
|
87542
87621
|
const covered = [".somewhere/", ".somewhere", "/.somewhere/", "/.somewhere", ".somewhere/advisor-conversation.json"];
|
|
87543
|
-
if (!
|
|
87544
|
-
|
|
87622
|
+
if (!existsSync33(path3)) {
|
|
87623
|
+
writeFileSync23(path3, "# somewhere: local CLI state (Advisor follow-ups, test users)\n.somewhere/\n");
|
|
87545
87624
|
return;
|
|
87546
87625
|
}
|
|
87547
|
-
const text =
|
|
87626
|
+
const text = readFileSync35(path3, "utf8");
|
|
87548
87627
|
if (text.split(/\r?\n/).map((l) => l.trim()).some((l) => covered.includes(l)))
|
|
87549
87628
|
return;
|
|
87550
|
-
|
|
87629
|
+
writeFileSync23(path3, `${text}${text.endsWith("\n") || !text ? "" : "\n"}
|
|
87551
87630
|
# somewhere: local CLI state (Advisor follow-ups, test users)
|
|
87552
87631
|
.somewhere/
|
|
87553
87632
|
`);
|
|
@@ -87558,7 +87637,7 @@ var init_advisor_app = __esm({
|
|
|
87558
87637
|
"use strict";
|
|
87559
87638
|
__name(gatherAdvisorApp, "gatherAdvisorApp");
|
|
87560
87639
|
DIR = ".somewhere";
|
|
87561
|
-
FILE =
|
|
87640
|
+
FILE = join38(DIR, "advisor-conversation.json");
|
|
87562
87641
|
IDLE_MS = 30 * 6e4;
|
|
87563
87642
|
ownerOf = /* @__PURE__ */ __name((account) => createHash8("sha256").update(`advisor:${account}`).digest("hex"), "ownerOf");
|
|
87564
87643
|
__name(loadAdvisorTurns, "loadAdvisorTurns");
|
|
@@ -87717,12 +87796,32 @@ __export(docs_exports, {
|
|
|
87717
87796
|
registerDocs: () => registerDocs,
|
|
87718
87797
|
renderDocsIndex: () => renderDocsIndex,
|
|
87719
87798
|
renderPublicDocsView: () => renderPublicDocsView,
|
|
87720
|
-
searchPublicDocs: () => searchPublicDocs,
|
|
87721
87799
|
writeResponseBodyToStdout: () => writeResponseBodyToStdout
|
|
87722
87800
|
});
|
|
87723
|
-
import { existsSync as existsSync33 } from "node:fs";
|
|
87724
|
-
import { join as join38 } from "node:path";
|
|
87725
87801
|
import { once } from "node:events";
|
|
87802
|
+
function docsVersion(value) {
|
|
87803
|
+
return typeof value === "string" && /^[a-f0-9]{16}$/.test(value) ? value : void 0;
|
|
87804
|
+
}
|
|
87805
|
+
async function warnIfLocalDocsOlder(platformVersion) {
|
|
87806
|
+
try {
|
|
87807
|
+
const local = localDocsVersion();
|
|
87808
|
+
if (!local)
|
|
87809
|
+
return;
|
|
87810
|
+
if (!platformVersion) {
|
|
87811
|
+
const response = await fetchWithProxy(DOCS_BASE2 + PUBLIC_MANIFEST_PATH, { method: "HEAD" });
|
|
87812
|
+
if (!response.ok)
|
|
87813
|
+
throw new Error(`HTTP ${response.status}`);
|
|
87814
|
+
platformVersion = docsVersion(response.headers.get("etag")?.replace(/^(?:W\/)?"|"$/g, ""));
|
|
87815
|
+
}
|
|
87816
|
+
if (!platformVersion)
|
|
87817
|
+
throw new Error("the platform did not return a docs version");
|
|
87818
|
+
if (local !== platformVersion) {
|
|
87819
|
+
console.error(`The Markdown copy in .somewhere/docs/ is from an older version (${local}). Current platform docs: ${platformVersion}. Refresh with ${cliInvocation()} docs pull.`);
|
|
87820
|
+
}
|
|
87821
|
+
} catch (cause) {
|
|
87822
|
+
console.error(`Could not check the local Markdown version (${cause instanceof Error ? cause.message : String(cause)}). Refresh with ${cliInvocation()} docs pull.`);
|
|
87823
|
+
}
|
|
87824
|
+
}
|
|
87726
87825
|
function closestMatches(wanted, candidates) {
|
|
87727
87826
|
const query = wanted.trim().toLowerCase();
|
|
87728
87827
|
const distance = /* @__PURE__ */ __name((candidate) => {
|
|
@@ -87769,7 +87868,7 @@ function renderPublicDocsView(page, view) {
|
|
|
87769
87868
|
if (view.kind === "full")
|
|
87770
87869
|
return { content: renderPublicPage(page), view: "full", complete: true };
|
|
87771
87870
|
if (view.kind === "default") {
|
|
87772
|
-
return page.summary ? { content: withNewline(page.summary), view: "summary", complete: page.summary_complete === true } : { content: renderPublicPage(page), view: "full", complete: true };
|
|
87871
|
+
return page.summary ? { content: page.summary_complete === true ? withNewline(page.summary) : topicSummary(page.summary, page.id, page.body.length), view: "summary", complete: page.summary_complete === true } : { content: renderPublicPage(page), view: "full", complete: true };
|
|
87773
87872
|
}
|
|
87774
87873
|
const sections = parseSections(page.sections, page.body.length);
|
|
87775
87874
|
const fail5 = /* @__PURE__ */ __name((failure2) => ({
|
|
@@ -87834,9 +87933,6 @@ function parseDocsStatusLine(content) {
|
|
|
87834
87933
|
function normalizeSectionHeading(value) {
|
|
87835
87934
|
return value.trim().replace(/^#+\s*/, "").replace(/`([^`]*)`/g, "$1").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/\*([^*]+)\*/g, "$1").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").toLowerCase().replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").slice(0, 80);
|
|
87836
87935
|
}
|
|
87837
|
-
function headingText(section) {
|
|
87838
|
-
return section.heading.replace(/^#+\s*/, "").trim();
|
|
87839
|
-
}
|
|
87840
87936
|
function withNewline(value) {
|
|
87841
87937
|
return value.endsWith("\n") ? value : `${value}
|
|
87842
87938
|
`;
|
|
@@ -87913,14 +88009,12 @@ async function fetchPublicManifestWithGroups() {
|
|
|
87913
88009
|
}
|
|
87914
88010
|
try {
|
|
87915
88011
|
const body = await res.json();
|
|
87916
|
-
|
|
88012
|
+
const version2 = body && typeof body === "object" && "sourceHash" in body ? docsVersion(body.sourceHash) : void 0;
|
|
88013
|
+
return { pages: parsePublicDocsManifest(body), groups: parsePublicDocsGroups(body), aliases: parsePublicDocsAliases(body), version: version2 };
|
|
87917
88014
|
} catch (cause) {
|
|
87918
88015
|
throw new Error(`Could not read ${DOCS_BASE2}${PUBLIC_MANIFEST_PATH}: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
87919
88016
|
}
|
|
87920
88017
|
}
|
|
87921
|
-
async function fetchPublicManifest() {
|
|
87922
|
-
return (await fetchPublicManifestWithGroups()).pages;
|
|
87923
|
-
}
|
|
87924
88018
|
function renderDocsIndex(pages, groups) {
|
|
87925
88019
|
const byId = new Map(pages.map((page) => [page.id, page]));
|
|
87926
88020
|
const listed = /* @__PURE__ */ new Set();
|
|
@@ -87957,49 +88051,31 @@ function renderDocsIndex(pages, groups) {
|
|
|
87957
88051
|
lines.push("", "Quick links:");
|
|
87958
88052
|
for (const [name, entry] of Object.entries(TOPICS))
|
|
87959
88053
|
lines.push(` ${name.padEnd(10)} ${entry.blurb}`);
|
|
87960
|
-
lines.push("", `Open a topic: ${cliInvocation()} docs <topic> (
|
|
88054
|
+
lines.push("", `Open a topic: ${cliInvocation()} docs <topic> (full when piped or redirected)`, `Open a section: ${cliInvocation()} docs <topic> --section <id>`, `Whole topic: ${cliInvocation()} docs <topic> --full`, `Search all docs: ${cliInvocation()} docs --search "<words>"`, `Download Markdown: ${cliInvocation()} docs pull`, `Full manual: ${cliInvocation()} docs --full (very large)`);
|
|
87961
88055
|
return lines.join("\n") + "\n";
|
|
87962
88056
|
}
|
|
87963
|
-
function
|
|
87964
|
-
const
|
|
87965
|
-
if (
|
|
87966
|
-
|
|
87967
|
-
const
|
|
87968
|
-
|
|
87969
|
-
|
|
87970
|
-
|
|
87971
|
-
|
|
87972
|
-
|
|
87973
|
-
|
|
87974
|
-
const start = starts[index];
|
|
87975
|
-
const end = starts[index + 1] ?? page.body.length;
|
|
87976
|
-
const span2 = lower.slice(start, end);
|
|
87977
|
-
if (!words.every((word) => span2.includes(word)))
|
|
87978
|
-
continue;
|
|
87979
|
-
const innermost = sections.filter((section) => section.start <= start && section.end >= end).sort((a, b2) => a.end - a.start - (b2.end - b2.start))[0];
|
|
87980
|
-
const key = innermost?.id ?? "";
|
|
87981
|
-
if (seen2.has(key))
|
|
87982
|
-
continue;
|
|
87983
|
-
seen2.add(key);
|
|
87984
|
-
const at2 = start + span2.indexOf(words[0]);
|
|
87985
|
-
const from = Math.max(0, at2 - SNIPPET_RADIUS);
|
|
87986
|
-
const to2 = Math.min(page.body.length, at2 + words[0].length + SNIPPET_RADIUS);
|
|
87987
|
-
const snippet = `${from > 0 ? "\u2026" : ""}${page.body.slice(from, to2).replace(/\s+/g, " ").trim()}${to2 < page.body.length ? "\u2026" : ""}`;
|
|
87988
|
-
const heading = innermost ? headingText(innermost) : null;
|
|
87989
|
-
const occurrences = words.reduce((count2, word) => count2 + span2.split(word).length - 1, 0);
|
|
87990
|
-
const titleHit = words.every((word) => `${page.id} ${page.title} ${heading ?? ""}`.toLowerCase().includes(word));
|
|
87991
|
-
scored.push({
|
|
87992
|
-
topic: page.id,
|
|
87993
|
-
title: page.title,
|
|
87994
|
-
section: innermost?.id ?? null,
|
|
87995
|
-
heading,
|
|
87996
|
-
snippet,
|
|
87997
|
-
open: innermost ? `${cliInvocation()} docs ${commandArg(page.id)} --section ${commandArg(innermost.id)}` : `${cliInvocation()} docs ${commandArg(page.id)} --full`,
|
|
87998
|
-
score: (titleHit ? 1e3 : 0) + occurrences
|
|
87999
|
-
});
|
|
88000
|
-
}
|
|
88057
|
+
async function fetchDocsSearch(query, topic) {
|
|
88058
|
+
const params = new URLSearchParams({ q: query });
|
|
88059
|
+
if (topic)
|
|
88060
|
+
params.set("topic", topic);
|
|
88061
|
+
const res = await fetchWithProxy(`${DOCS_BASE2}${DOCS_SEARCH_PATH}?${params}`, {
|
|
88062
|
+
headers: { "User-Agent": "somewhere-cli" }
|
|
88063
|
+
});
|
|
88064
|
+
if (!res.ok) {
|
|
88065
|
+
if (topic && res.status === 404)
|
|
88066
|
+
throw new Error(`Unknown docs topic "${topic}". Run ${cliInvocation()} docs for the topic index.`);
|
|
88067
|
+
throw new Error(`Could not search docs at ${DOCS_BASE2} (HTTP ${res.status}).`);
|
|
88001
88068
|
}
|
|
88002
|
-
|
|
88069
|
+
const { results, total, version: version2 } = await res.json();
|
|
88070
|
+
return {
|
|
88071
|
+
results: results.map(({ content, ...match }) => ({
|
|
88072
|
+
...match,
|
|
88073
|
+
snippet: content,
|
|
88074
|
+
open: match.section ? `${cliInvocation()} docs ${commandArg(match.topic)} --section ${commandArg(match.section)}` : `${cliInvocation()} docs ${commandArg(match.topic)} --full`
|
|
88075
|
+
})),
|
|
88076
|
+
total,
|
|
88077
|
+
version: docsVersion(version2)
|
|
88078
|
+
};
|
|
88003
88079
|
}
|
|
88004
88080
|
function warnIfDocsNewerThanCli() {
|
|
88005
88081
|
if (process.env.CI || process.env.SOMEWHERE_NO_NOTIFICATIONS)
|
|
@@ -88035,27 +88111,20 @@ async function writeResponseBodyToStdout(res) {
|
|
|
88035
88111
|
reader.releaseLock();
|
|
88036
88112
|
}
|
|
88037
88113
|
}
|
|
88038
|
-
function
|
|
88039
|
-
|
|
88040
|
-
|
|
88041
|
-
|
|
88042
|
-
|
|
88043
|
-
|
|
88044
|
-
function printDocsHint(topic, view, complete) {
|
|
88045
|
-
const path3 = bundledDocsPath(topic) ?? bundledDocsPath();
|
|
88046
|
-
if (view === "summary" && complete === false) {
|
|
88047
|
-
const read = `Run ${cliInvocation()} docs ${commandArg(topic)} --full for the whole topic or --section <id> for one section.`;
|
|
88048
|
-
console.error(path3 ? `${read} Search installed Markdown in ${path3}.` : read);
|
|
88049
|
-
} else if (path3) {
|
|
88050
|
-
console.error(`Search installed Markdown in ${path3}.`);
|
|
88051
|
-
}
|
|
88114
|
+
function topicSummary(content, topic, full) {
|
|
88115
|
+
const command = `${cliInvocation()} docs ${commandArg(topic)}`;
|
|
88116
|
+
return `${content.trimEnd()}
|
|
88117
|
+
|
|
88118
|
+
Full topic (${full} characters): ${command} --full
|
|
88119
|
+
`;
|
|
88052
88120
|
}
|
|
88053
88121
|
function registerDocs(program2) {
|
|
88054
|
-
program2.command("docs [topic] [terms...]").description(`Read platform docs. No login needed \u2014 every topic is public. With no topic, prints the topic index. Search with \`${cliInvocation()} docs
|
|
88122
|
+
program2.command("docs [topic] [terms...]").description(`Read platform docs. No login needed \u2014 every topic is public. With no topic, prints the topic index. Search with \`${cliInvocation()} docs --search "<words>"\`. Quick topics: ` + Object.keys(TOPICS).join(", ") + `. Example manual topic: \`${cliInvocation()} docs sw.db\`.`).option("--list", `List available topics (the same index bare \`${cliInvocation()} docs\` prints)`).option("--full", "Print the complete topic in a terminal; with no topic, the full manual").option("--search <words>", "Search matching sections across all live docs topics").option("--section <id>", "Print one section of a topic (ids are listed in the summary)").option("--json", "Print the selected document in a JSON envelope").addHelpText("after", `
|
|
88055
88123
|
Examples:
|
|
88056
88124
|
${cliInvocation()} docs # topic index
|
|
88057
|
-
${cliInvocation()} docs search magic link
|
|
88058
|
-
${cliInvocation()} docs
|
|
88125
|
+
${cliInvocation()} docs --search "magic link" # matching sections across every topic
|
|
88126
|
+
${cliInvocation()} docs pull # download Markdown into .somewhere/docs/
|
|
88127
|
+
${cliInvocation()} docs sw.auth # full when piped or redirected
|
|
88059
88128
|
${cliInvocation()} docs sw.auth setRoles # search within this topic
|
|
88060
88129
|
${cliInvocation()} docs sw.auth --section <id> # one section
|
|
88061
88130
|
${cliInvocation()} docs --full # the whole manual (very large)
|
|
@@ -88067,39 +88136,73 @@ Examples:
|
|
|
88067
88136
|
process.exitCode = 1;
|
|
88068
88137
|
return;
|
|
88069
88138
|
}
|
|
88070
|
-
const searching = terms.length > 0;
|
|
88071
|
-
const within = topic && topic !== "search" ? ALIASES[topic] ?? topic : void 0;
|
|
88072
88139
|
warnIfDocsNewerThanCli();
|
|
88140
|
+
if (topic === "pull") {
|
|
88141
|
+
if (terms.length || opts.list || opts.full || opts.section !== void 0 || opts.search !== void 0) {
|
|
88142
|
+
error("docs pull accepts only --json.");
|
|
88143
|
+
process.exitCode = 1;
|
|
88144
|
+
return;
|
|
88145
|
+
}
|
|
88146
|
+
try {
|
|
88147
|
+
const { pages, version: version2 } = await fetchPublicManifestWithGroups();
|
|
88148
|
+
if (!version2 || !pages.length)
|
|
88149
|
+
throw new Error("The platform did not return a versioned docs collection.");
|
|
88150
|
+
const files = /* @__PURE__ */ new Map();
|
|
88151
|
+
const names = /* @__PURE__ */ new Set(["readme"]);
|
|
88152
|
+
for (const page of pages) {
|
|
88153
|
+
const name = page.id.toLowerCase();
|
|
88154
|
+
if (!/^[a-z0-9][a-z0-9.-]*$/.test(name) || names.has(name)) {
|
|
88155
|
+
throw new Error(`Invalid docs topic ID ${JSON.stringify(page.id)}.`);
|
|
88156
|
+
}
|
|
88157
|
+
names.add(name);
|
|
88158
|
+
files.set(page.id + ".md", renderPublicPage(page));
|
|
88159
|
+
}
|
|
88160
|
+
const path3 = saveLocalDocs(version2, files);
|
|
88161
|
+
if (opts.json)
|
|
88162
|
+
printJson({ path: path3, version: version2, count: files.size });
|
|
88163
|
+
else
|
|
88164
|
+
console.log(path3);
|
|
88165
|
+
} catch (e) {
|
|
88166
|
+
error(e instanceof Error ? e.message : String(e), e);
|
|
88167
|
+
process.exitCode = 1;
|
|
88168
|
+
}
|
|
88169
|
+
return;
|
|
88170
|
+
}
|
|
88171
|
+
const searching = opts.search !== void 0 || terms.length > 0;
|
|
88172
|
+
const within = topic && topic !== "search" ? ALIASES[topic] ?? topic : void 0;
|
|
88073
88173
|
if (searching) {
|
|
88074
|
-
if (opts.full || opts.section !== void 0 || opts.list) {
|
|
88075
|
-
error(
|
|
88174
|
+
if (opts.full || opts.section !== void 0 || opts.list || opts.search !== void 0 && topic !== void 0) {
|
|
88175
|
+
error('Use docs --search "<words>" with optional --json.');
|
|
88176
|
+
process.exitCode = 1;
|
|
88177
|
+
return;
|
|
88178
|
+
}
|
|
88179
|
+
const query = (opts.search ?? terms.join(" ")).trim();
|
|
88180
|
+
if (!/[a-z0-9]/i.test(query) || query.length > 200) {
|
|
88181
|
+
error("Enter search words of up to 200 characters.");
|
|
88076
88182
|
process.exitCode = 1;
|
|
88077
88183
|
return;
|
|
88078
88184
|
}
|
|
88079
|
-
const query = terms.join(" ");
|
|
88080
88185
|
try {
|
|
88081
|
-
const
|
|
88082
|
-
|
|
88083
|
-
error(`Unknown docs topic "${within}". Run: ${cliInvocation()} docs`);
|
|
88084
|
-
process.exitCode = 1;
|
|
88085
|
-
return;
|
|
88086
|
-
}
|
|
88087
|
-
const results = searchPublicDocs(within ? pages.filter((page) => page.id === within) : pages, query);
|
|
88186
|
+
const { results, total, version: version2 } = await fetchDocsSearch(query, within);
|
|
88187
|
+
await warnIfLocalDocsOlder(version2);
|
|
88088
88188
|
if (opts.json) {
|
|
88089
|
-
printJson({ query, ...within ? { topic: within } : {}, count: results.length, results });
|
|
88189
|
+
printJson({ query, ...within ? { topic: within } : {}, count: results.length, total, results });
|
|
88090
88190
|
return;
|
|
88091
88191
|
}
|
|
88092
88192
|
if (!results.length) {
|
|
88093
|
-
console.log(`No docs sections${within ? ` in ${within}` : ""}
|
|
88193
|
+
console.log(`No docs sections${within ? ` in ${within}` : ""} match ${JSON.stringify(query)}.`);
|
|
88094
88194
|
return;
|
|
88095
88195
|
}
|
|
88096
88196
|
for (const result of results) {
|
|
88097
88197
|
console.log(`${result.topic}${result.section ? ` \u203A ${result.section}` : ""} ${dim(result.heading ?? result.title)}`);
|
|
88098
|
-
console.log(`
|
|
88099
|
-
|
|
88198
|
+
console.log(`
|
|
88199
|
+
${result.snippet}
|
|
88200
|
+
|
|
88201
|
+
${dim(result.open)}
|
|
88202
|
+
`);
|
|
88100
88203
|
}
|
|
88101
|
-
if (results.length
|
|
88102
|
-
console.log(dim(`Showing
|
|
88204
|
+
if (results.length < total) {
|
|
88205
|
+
console.log(dim(`Showing ${results.length} of ${total} matches. Add a word to narrow the search.`));
|
|
88103
88206
|
}
|
|
88104
88207
|
} catch (e) {
|
|
88105
88208
|
error(e instanceof Error ? e.message : String(e), e);
|
|
@@ -88107,10 +88210,11 @@ Examples:
|
|
|
88107
88210
|
}
|
|
88108
88211
|
return;
|
|
88109
88212
|
}
|
|
88110
|
-
const view = opts.section !== void 0 ? { kind: "section", id: opts.section } : opts.full ? { kind: "full" } : { kind: "default" };
|
|
88213
|
+
const view = opts.section !== void 0 ? { kind: "section", id: opts.section } : opts.full || topic !== void 0 && !process.stdout.isTTY ? { kind: "full" } : { kind: "default" };
|
|
88111
88214
|
if (opts.list || topic === void 0 && view.kind === "default") {
|
|
88112
88215
|
try {
|
|
88113
|
-
const { pages, groups } = await fetchPublicManifestWithGroups();
|
|
88216
|
+
const { pages, groups, version: version2 } = await fetchPublicManifestWithGroups();
|
|
88217
|
+
await warnIfLocalDocsOlder(version2);
|
|
88114
88218
|
const quickLinks = Object.entries(TOPICS).map(([name, entry2]) => ({
|
|
88115
88219
|
name,
|
|
88116
88220
|
path: entry2.path,
|
|
@@ -88129,9 +88233,6 @@ Examples:
|
|
|
88129
88233
|
return;
|
|
88130
88234
|
}
|
|
88131
88235
|
process.stdout.write(renderDocsIndex(pages, groups));
|
|
88132
|
-
const docs = bundledDocsPath();
|
|
88133
|
-
if (docs)
|
|
88134
|
-
console.log("\nSearch installed Markdown in " + docs + ".");
|
|
88135
88236
|
console.log(`
|
|
88136
88237
|
${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
|
|
88137
88238
|
} catch (e) {
|
|
@@ -88158,29 +88259,32 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
|
|
|
88158
88259
|
let authenticatedFailure = null;
|
|
88159
88260
|
if (hasUsableCredential()) {
|
|
88160
88261
|
try {
|
|
88161
|
-
|
|
88262
|
+
let content = await callPlatformHelpTool("docs", {
|
|
88162
88263
|
topic: resolvedTopic,
|
|
88163
88264
|
...view.kind === "full" ? { detail: "full" } : {},
|
|
88164
88265
|
...view.kind === "section" ? { section: view.id } : {}
|
|
88165
88266
|
});
|
|
88166
88267
|
const status = parseDocsStatusLine(content);
|
|
88167
|
-
|
|
88268
|
+
const first = content.split("\n", 1)[0];
|
|
88269
|
+
const full = /\bfull=(\d+)/.exec(first)?.[1];
|
|
88270
|
+
if (/^Topic "[^\n]*" not found\./.test(content) || view.kind === "full" && status.complete === false || status.view === "summary" && status.complete === false && !full || view.kind === "section" && (status.view !== "section" || /(?:^|\n)No section "/.test(content))) {
|
|
88168
88271
|
throw new Error("Authenticated docs did not return the requested view; trying the public index.");
|
|
88169
88272
|
}
|
|
88273
|
+
if (status.view === "summary" && status.complete === false)
|
|
88274
|
+
content = topicSummary(content, resolvedTopic, Number(full));
|
|
88275
|
+
await warnIfLocalDocsOlder();
|
|
88170
88276
|
if (opts.json)
|
|
88171
88277
|
printJson({ topic: requestedTopic, ...status, content });
|
|
88172
|
-
else
|
|
88278
|
+
else
|
|
88173
88279
|
process.stdout.write(withNewline(content));
|
|
88174
|
-
if (view.kind === "default")
|
|
88175
|
-
printDocsHint(resolvedTopic, status.view, status.complete);
|
|
88176
|
-
}
|
|
88177
88280
|
return;
|
|
88178
88281
|
} catch (e) {
|
|
88179
88282
|
authenticatedFailure = e instanceof Error ? e.message : String(e);
|
|
88180
88283
|
}
|
|
88181
88284
|
}
|
|
88182
88285
|
try {
|
|
88183
|
-
const { pages, aliases } = await fetchPublicManifestWithGroups();
|
|
88286
|
+
const { pages, aliases, version: version2 } = await fetchPublicManifestWithGroups();
|
|
88287
|
+
await warnIfLocalDocsOlder(version2);
|
|
88184
88288
|
const page = findPublicDocsPage(pages, aliases, resolvedTopic);
|
|
88185
88289
|
if (page) {
|
|
88186
88290
|
const rendered = renderPublicDocsView(page, view);
|
|
@@ -88198,8 +88302,6 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
|
|
|
88198
88302
|
});
|
|
88199
88303
|
} else {
|
|
88200
88304
|
process.stdout.write(rendered.content);
|
|
88201
|
-
if (view.kind === "default")
|
|
88202
|
-
printDocsHint(page.id, rendered.view, rendered.complete);
|
|
88203
88305
|
}
|
|
88204
88306
|
return;
|
|
88205
88307
|
}
|
|
@@ -88225,6 +88327,7 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
|
|
|
88225
88327
|
error(`Could not fetch ${DOCS_BASE2}${entry.path} (HTTP ${res.status}). Try again shortly, or open it in a browser.`);
|
|
88226
88328
|
process.exit(1);
|
|
88227
88329
|
}
|
|
88330
|
+
await warnIfLocalDocsOlder();
|
|
88228
88331
|
if (opts.json) {
|
|
88229
88332
|
printJson({
|
|
88230
88333
|
topic: key,
|
|
@@ -88234,21 +88337,19 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
|
|
|
88234
88337
|
return;
|
|
88235
88338
|
}
|
|
88236
88339
|
await writeResponseBodyToStdout(res);
|
|
88237
|
-
if (view.kind === "default")
|
|
88238
|
-
printDocsHint(key ?? requestedTopic);
|
|
88239
88340
|
} catch (e) {
|
|
88240
88341
|
error(`Could not reach ${DOCS_BASE2} \u2014 check your connection. (${e instanceof Error ? e.message : String(e)})`, e);
|
|
88241
88342
|
process.exit(1);
|
|
88242
88343
|
}
|
|
88243
88344
|
});
|
|
88244
88345
|
}
|
|
88245
|
-
var DOCS_BASE2, TOPICS, ALIASES, PUBLIC_MANIFEST_PATH,
|
|
88346
|
+
var DOCS_BASE2, TOPICS, ALIASES, PUBLIC_MANIFEST_PATH, DOCS_SEARCH_PATH, DOCS_SECTION_MAX_CHARS;
|
|
88246
88347
|
var init_docs = __esm({
|
|
88247
88348
|
"dist/commands/docs.js"() {
|
|
88248
88349
|
"use strict";
|
|
88249
|
-
init_package_root();
|
|
88250
88350
|
init_cli_invocation();
|
|
88251
88351
|
init_http();
|
|
88352
|
+
init_local_docs();
|
|
88252
88353
|
init_config();
|
|
88253
88354
|
init_output();
|
|
88254
88355
|
init_update();
|
|
@@ -88291,6 +88392,9 @@ var init_docs = __esm({
|
|
|
88291
88392
|
schema: "declared-data"
|
|
88292
88393
|
};
|
|
88293
88394
|
PUBLIC_MANIFEST_PATH = "/docs-manifest.json";
|
|
88395
|
+
DOCS_SEARCH_PATH = "/docs-search.json";
|
|
88396
|
+
__name(docsVersion, "docsVersion");
|
|
88397
|
+
__name(warnIfLocalDocsOlder, "warnIfLocalDocsOlder");
|
|
88294
88398
|
DOCS_SECTION_MAX_CHARS = 12e3;
|
|
88295
88399
|
__name(closestMatches, "closestMatches");
|
|
88296
88400
|
__name(commandArg, "commandArg");
|
|
@@ -88299,24 +88403,18 @@ var init_docs = __esm({
|
|
|
88299
88403
|
__name(renderPublicDocsView, "renderPublicDocsView");
|
|
88300
88404
|
__name(parseDocsStatusLine, "parseDocsStatusLine");
|
|
88301
88405
|
__name(normalizeSectionHeading, "normalizeSectionHeading");
|
|
88302
|
-
__name(headingText, "headingText");
|
|
88303
88406
|
__name(withNewline, "withNewline");
|
|
88304
88407
|
__name(parsePublicDocsManifest, "parsePublicDocsManifest");
|
|
88305
88408
|
__name(parsePublicDocsGroups, "parsePublicDocsGroups");
|
|
88306
88409
|
__name(parsePublicDocsAliases, "parsePublicDocsAliases");
|
|
88307
88410
|
__name(findPublicDocsPage, "findPublicDocsPage");
|
|
88308
88411
|
__name(fetchPublicManifestWithGroups, "fetchPublicManifestWithGroups");
|
|
88309
|
-
__name(fetchPublicManifest, "fetchPublicManifest");
|
|
88310
88412
|
__name(renderDocsIndex, "renderDocsIndex");
|
|
88311
|
-
|
|
88312
|
-
SNIPPET_RADIUS = 90;
|
|
88313
|
-
__name(searchPublicDocs, "searchPublicDocs");
|
|
88413
|
+
__name(fetchDocsSearch, "fetchDocsSearch");
|
|
88314
88414
|
__name(warnIfDocsNewerThanCli, "warnIfDocsNewerThanCli");
|
|
88315
88415
|
__name(renderPublicPage, "renderPublicPage");
|
|
88316
88416
|
__name(writeResponseBodyToStdout, "writeResponseBodyToStdout");
|
|
88317
|
-
|
|
88318
|
-
__name(bundledDocsPath, "bundledDocsPath");
|
|
88319
|
-
__name(printDocsHint, "printDocsHint");
|
|
88417
|
+
__name(topicSummary, "topicSummary");
|
|
88320
88418
|
__name(registerDocs, "registerDocs");
|
|
88321
88419
|
}
|
|
88322
88420
|
});
|
|
@@ -88873,7 +88971,7 @@ var init_envfile_write = __esm({
|
|
|
88873
88971
|
});
|
|
88874
88972
|
|
|
88875
88973
|
// dist/commands/env.js
|
|
88876
|
-
import { existsSync as existsSync34, readFileSync as
|
|
88974
|
+
import { existsSync as existsSync34, readFileSync as readFileSync36, writeFileSync as writeFileSync24 } from "node:fs";
|
|
88877
88975
|
import { resolve as resolve19 } from "node:path";
|
|
88878
88976
|
function resolveProjectId(explicit) {
|
|
88879
88977
|
if (explicit)
|
|
@@ -88943,7 +89041,7 @@ function registerEnv(program2) {
|
|
|
88943
89041
|
process.exit(1);
|
|
88944
89042
|
}
|
|
88945
89043
|
if (existsSync34(outPath) && !opts.force) {
|
|
88946
|
-
const existing =
|
|
89044
|
+
const existing = readFileSync36(outPath, "utf-8");
|
|
88947
89045
|
const hasValues = existing.split("\n").some((l) => /^[^#=]+=.+/.test(l.trim()));
|
|
88948
89046
|
const { ok } = await (0, import_prompts9.default)({
|
|
88949
89047
|
type: "confirm",
|
|
@@ -88956,7 +89054,7 @@ function registerEnv(program2) {
|
|
|
88956
89054
|
return;
|
|
88957
89055
|
}
|
|
88958
89056
|
}
|
|
88959
|
-
|
|
89057
|
+
writeFileSync24(outPath, buildEnvTemplate(keys, { projectId: pid }));
|
|
88960
89058
|
if (opts.json) {
|
|
88961
89059
|
printJson(result);
|
|
88962
89060
|
return;
|
|
@@ -88996,7 +89094,7 @@ function registerEnv(program2) {
|
|
|
88996
89094
|
if (inputNote && !opts.json)
|
|
88997
89095
|
process.stderr.write(`Note: ${inputNote}
|
|
88998
89096
|
`);
|
|
88999
|
-
const value = opts.stdin ?
|
|
89097
|
+
const value = opts.stdin ? readFileSync36(0, "utf8").replace(/\r?\n$/, "") : positionalValue;
|
|
89000
89098
|
const client = new ApiClient(getToken());
|
|
89001
89099
|
const pid = resolveProjectId(opts.project);
|
|
89002
89100
|
try {
|
|
@@ -89065,7 +89163,7 @@ var init_env = __esm({
|
|
|
89065
89163
|
});
|
|
89066
89164
|
|
|
89067
89165
|
// dist/commands/run.js
|
|
89068
|
-
import { existsSync as existsSync35, readFileSync as
|
|
89166
|
+
import { existsSync as existsSync35, readFileSync as readFileSync37 } from "node:fs";
|
|
89069
89167
|
import { isAbsolute as isAbsolute6, resolve as resolve20 } from "node:path";
|
|
89070
89168
|
import { createRequire as createRequire8 } from "node:module";
|
|
89071
89169
|
function parseArgs(values) {
|
|
@@ -89136,7 +89234,7 @@ function registerRun(program2) {
|
|
|
89136
89234
|
error(`File not found: ${script}`);
|
|
89137
89235
|
process.exit(1);
|
|
89138
89236
|
}
|
|
89139
|
-
const code =
|
|
89237
|
+
const code = readFileSync37(absPath, "utf-8");
|
|
89140
89238
|
if (!code.trim()) {
|
|
89141
89239
|
error(`${script} is empty \u2014 nothing to run.`);
|
|
89142
89240
|
process.exit(1);
|
|
@@ -89815,7 +89913,7 @@ var init_preview_jobs = __esm({
|
|
|
89815
89913
|
|
|
89816
89914
|
// dist/commands/dev.js
|
|
89817
89915
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
89818
|
-
import { existsSync as existsSync36, readFileSync as
|
|
89916
|
+
import { existsSync as existsSync36, readFileSync as readFileSync38 } from "node:fs";
|
|
89819
89917
|
import { join as join40, relative as relative11 } from "node:path";
|
|
89820
89918
|
function previewFinishedReason(err) {
|
|
89821
89919
|
if (!(err instanceof CliApiError) || err.code !== "DRAFT_SESSION_TERMINAL")
|
|
@@ -90804,11 +90902,11 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
|
|
|
90804
90902
|
continue;
|
|
90805
90903
|
const { kind, key } = classifyKey(rel);
|
|
90806
90904
|
if (kind === "function")
|
|
90807
|
-
updateFunctions[key] =
|
|
90905
|
+
updateFunctions[key] = readFileSync38(abs, "utf-8");
|
|
90808
90906
|
else if (kind === "binary")
|
|
90809
|
-
updateBinary[key] =
|
|
90907
|
+
updateBinary[key] = readFileSync38(abs).toString("base64");
|
|
90810
90908
|
else
|
|
90811
|
-
updateFiles[key] =
|
|
90909
|
+
updateFiles[key] = readFileSync38(abs, "utf-8");
|
|
90812
90910
|
}
|
|
90813
90911
|
for (const rel of deleted)
|
|
90814
90912
|
deleteKeys.push(classifyKey(rel).key);
|
|
@@ -131574,7 +131672,7 @@ var require_dist15 = __commonJS({
|
|
|
131574
131672
|
|
|
131575
131673
|
// dist/lib/update-security.js
|
|
131576
131674
|
import { createHash as createHash9, timingSafeEqual } from "node:crypto";
|
|
131577
|
-
import { mkdirSync as
|
|
131675
|
+
import { mkdirSync as mkdirSync19, readFileSync as readFileSync39, statSync as statSync7 } from "node:fs";
|
|
131578
131676
|
import { join as join43 } from "node:path";
|
|
131579
131677
|
import { Readable as Readable2 } from "node:stream";
|
|
131580
131678
|
import { pipeline as pipeline3 } from "node:stream/promises";
|
|
@@ -131923,7 +132021,7 @@ async function extractArtifactSnapshot(artifact, extractionDir, filter) {
|
|
|
131923
132021
|
await pipeline3(Readable2.from([artifact]), So({ cwd: extractionDir, strip: 1, strict: true, filter }));
|
|
131924
132022
|
}
|
|
131925
132023
|
async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
131926
|
-
|
|
132024
|
+
mkdirSync19(extractionDir, { recursive: true, mode: 448 });
|
|
131927
132025
|
const allowed = /* @__PURE__ */ new Map([
|
|
131928
132026
|
["package/package.json", MAX_MANIFEST_BYTES],
|
|
131929
132027
|
["package/npm-shrinkwrap.json", MAX_LOCKFILE_BYTES]
|
|
@@ -131947,8 +132045,8 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
|
131947
132045
|
try {
|
|
131948
132046
|
if (statSync7(lockPath).size > MAX_LOCKFILE_BYTES)
|
|
131949
132047
|
throw new Error("lockfile too large");
|
|
131950
|
-
manifest = JSON.parse(
|
|
131951
|
-
lock = JSON.parse(
|
|
132048
|
+
manifest = JSON.parse(readFileSync39(manifestPath, "utf8"));
|
|
132049
|
+
lock = JSON.parse(readFileSync39(lockPath, "utf8"));
|
|
131952
132050
|
} catch (cause) {
|
|
131953
132051
|
throw new Error(`the verified artifact has no readable npm-shrinkwrap dependency lock: ${message(cause)}`);
|
|
131954
132052
|
}
|
|
@@ -131986,7 +132084,7 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
|
131986
132084
|
let bundledManifest;
|
|
131987
132085
|
try {
|
|
131988
132086
|
const bundledPath = join43(extractionDir, ...lockPath2.split("/"), "package.json");
|
|
131989
|
-
bundledManifest = JSON.parse(
|
|
132087
|
+
bundledManifest = JSON.parse(readFileSync39(bundledPath, "utf8"));
|
|
131990
132088
|
} catch (cause) {
|
|
131991
132089
|
throw new Error(`the verified artifact has an unreadable bundled dependency ${lockPath2}: ${message(cause)}`);
|
|
131992
132090
|
}
|
|
@@ -132056,7 +132154,7 @@ ${GITHUB_REPOSITORY_ID}`,
|
|
|
132056
132154
|
// dist/commands/update.js
|
|
132057
132155
|
import { spawn as spawn6 } from "node:child_process";
|
|
132058
132156
|
import { randomBytes as randomBytes8 } from "node:crypto";
|
|
132059
|
-
import { closeSync as closeSync5, constants as constants2, fstatSync, mkdtempSync as
|
|
132157
|
+
import { closeSync as closeSync5, constants as constants2, fstatSync, mkdtempSync as mkdtempSync4, openSync as openSync5, readFileSync as readFileSync40, readSync, rmSync as rmSync15, unlinkSync as unlinkSync5, writeFileSync as writeFileSync25 } from "node:fs";
|
|
132060
132158
|
import { createServer } from "node:http";
|
|
132061
132159
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
132062
132160
|
import { join as join44 } from "node:path";
|
|
@@ -132067,7 +132165,7 @@ function refuse2(cause) {
|
|
|
132067
132165
|
}
|
|
132068
132166
|
function currentVersion2() {
|
|
132069
132167
|
try {
|
|
132070
|
-
const pkg = JSON.parse(
|
|
132168
|
+
const pkg = JSON.parse(readFileSync40(join44(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
132071
132169
|
return pkg.version;
|
|
132072
132170
|
} catch {
|
|
132073
132171
|
return "0.0.0";
|
|
@@ -132210,8 +132308,8 @@ async function installVerifiedTarball(tarballPath, tempDir, release2) {
|
|
|
132210
132308
|
const cacheDir = join44(tempDir, "empty-cache");
|
|
132211
132309
|
const userConfigPath = join44(tempDir, "user-npmrc");
|
|
132212
132310
|
const globalConfigPath = join44(tempDir, "global-npmrc");
|
|
132213
|
-
|
|
132214
|
-
|
|
132311
|
+
writeFileSync25(userConfigPath, "", { mode: 384 });
|
|
132312
|
+
writeFileSync25(globalConfigPath, "", { mode: 384 });
|
|
132215
132313
|
const artifact = snapshotAuthenticatedArtifact(tarballPath);
|
|
132216
132314
|
let artifactServer;
|
|
132217
132315
|
try {
|
|
@@ -132281,9 +132379,9 @@ async function runUpdate(opts, dependencies = {}) {
|
|
|
132281
132379
|
const provenance = await fetchJson(fetchImpl, release2.attestationUrl, "the official npm provenance endpoint");
|
|
132282
132380
|
await (dependencies.verifyProvenance ?? verifyPublishedProvenance)(provenance, release2);
|
|
132283
132381
|
const tarball = await downloadTarball(fetchImpl, release2);
|
|
132284
|
-
tempDir =
|
|
132382
|
+
tempDir = mkdtempSync4(join44(tmpdir2(), "somewhere-update-"));
|
|
132285
132383
|
const tarballPath = join44(tempDir, `cli-${release2.version}.tgz`);
|
|
132286
|
-
|
|
132384
|
+
writeFileSync25(tarballPath, tarball, { mode: 384 });
|
|
132287
132385
|
info(`Cryptographically verified provenance and integrity for ${CLI_PACKAGE}@${release2.version}.`);
|
|
132288
132386
|
info(`Updating ${CLI_PACKAGE} from its authenticated dependency lock \u2026`);
|
|
132289
132387
|
await (dependencies.install ?? installVerifiedTarball)(tarballPath, tempDir, release2);
|
|
@@ -132291,7 +132389,7 @@ async function runUpdate(opts, dependencies = {}) {
|
|
|
132291
132389
|
return refuse2(cause);
|
|
132292
132390
|
} finally {
|
|
132293
132391
|
if (tempDir)
|
|
132294
|
-
|
|
132392
|
+
rmSync15(tempDir, { recursive: true, force: true });
|
|
132295
132393
|
}
|
|
132296
132394
|
success(`Updated to ${release2.version}. Run ${teal(`${cliInvocation()} --version`)} to confirm.`);
|
|
132297
132395
|
info(PROJECT_PIN_NOTE);
|
|
@@ -132414,7 +132512,7 @@ var init_upgrade = __esm({
|
|
|
132414
132512
|
});
|
|
132415
132513
|
|
|
132416
132514
|
// dist/commands/call.js
|
|
132417
|
-
import { readFileSync as
|
|
132515
|
+
import { readFileSync as readFileSync41 } from "node:fs";
|
|
132418
132516
|
function parseArguments(value, file) {
|
|
132419
132517
|
if (value === void 0)
|
|
132420
132518
|
return {};
|
|
@@ -132438,7 +132536,7 @@ function readCallArguments(jsonArgs, file) {
|
|
|
132438
132536
|
}
|
|
132439
132537
|
let text;
|
|
132440
132538
|
try {
|
|
132441
|
-
text =
|
|
132539
|
+
text = readFileSync41(file, "utf8");
|
|
132442
132540
|
} catch (err) {
|
|
132443
132541
|
const code = err?.code;
|
|
132444
132542
|
throw new Error(`Could not read --file ${file}${code ? ` (${code})` : ""}. The requested tool was not called.`);
|
|
@@ -134756,7 +134854,7 @@ var init_test_response_capture = __esm({
|
|
|
134756
134854
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
134757
134855
|
import { setDefaultResultOrder } from "node:dns";
|
|
134758
134856
|
import { lookup } from "node:dns/promises";
|
|
134759
|
-
import { existsSync as existsSync38, mkdirSync as
|
|
134857
|
+
import { existsSync as existsSync38, mkdirSync as mkdirSync20, readFileSync as readFileSync42, writeFileSync as writeFileSync26 } from "node:fs";
|
|
134760
134858
|
import { basename as basename9, dirname as dirname14, join as join45, relative as relative12, resolve as resolve24 } from "node:path";
|
|
134761
134859
|
function launchOptions(extra = {}) {
|
|
134762
134860
|
return { ...extra, args: ["--disable-features=AsyncDns", ...extra.args ?? []] };
|
|
@@ -134810,7 +134908,7 @@ function undeployedChanges(root, projectId, preview = false) {
|
|
|
134810
134908
|
const path3 = join45(root, ".somewhere", "base-files.json");
|
|
134811
134909
|
if (!existsSync38(path3))
|
|
134812
134910
|
return null;
|
|
134813
|
-
base = JSON.parse(
|
|
134911
|
+
base = JSON.parse(readFileSync42(path3, "utf8"));
|
|
134814
134912
|
}
|
|
134815
134913
|
if (base.project_id !== projectId || !base.files)
|
|
134816
134914
|
return null;
|
|
@@ -135162,8 +135260,8 @@ page ${i + 1}: ${state}`).join("");
|
|
|
135162
135260
|
}
|
|
135163
135261
|
const passed = this.checks.filter((check) => check.ok).length;
|
|
135164
135262
|
const failed = this.checks.filter((check) => !check.ok && !check.skipped).length;
|
|
135165
|
-
|
|
135166
|
-
|
|
135263
|
+
mkdirSync20(dirname14(this.resultsPath), { recursive: true });
|
|
135264
|
+
writeFileSync26(this.resultsPath, JSON.stringify({
|
|
135167
135265
|
identity: this.identity(),
|
|
135168
135266
|
origin: this.origin,
|
|
135169
135267
|
environment: this.control.environment,
|
|
@@ -135182,7 +135280,7 @@ page ${i + 1}: ${state}`).join("");
|
|
|
135182
135280
|
const resultFile = relative12(this.root, this.resultsPath);
|
|
135183
135281
|
const handOver = process.env.SW_TEST_REPORT;
|
|
135184
135282
|
if (handOver)
|
|
135185
|
-
|
|
135283
|
+
writeFileSync26(handOver, JSON.stringify({ checks: reported, resultFile }) + "\n");
|
|
135186
135284
|
else {
|
|
135187
135285
|
const verbose = process.argv.includes("--verbose") || process.env.SW_TEST_VERBOSE === "1";
|
|
135188
135286
|
const script = process.argv[1] ? relative12(this.root, resolve24(process.argv[1])) : "this script";
|
|
@@ -135497,7 +135595,7 @@ var init_test_session = __esm({
|
|
|
135497
135595
|
|
|
135498
135596
|
// dist/lib/prepared-actor-session.js
|
|
135499
135597
|
import { createHash as createHash10 } from "node:crypto";
|
|
135500
|
-
import { closeSync as closeSync6, openSync as openSync6, rmSync as
|
|
135598
|
+
import { closeSync as closeSync6, openSync as openSync6, rmSync as rmSync16 } from "node:fs";
|
|
135501
135599
|
import { setTimeout as delay } from "node:timers/promises";
|
|
135502
135600
|
async function preparedActorSession(root, target, name) {
|
|
135503
135601
|
const read = /* @__PURE__ */ __name(() => preparedActorState(root, target, name), "read");
|
|
@@ -135533,7 +135631,7 @@ async function preparedActorSession(root, target, name) {
|
|
|
135533
135631
|
return token;
|
|
135534
135632
|
} finally {
|
|
135535
135633
|
closeSync6(fd);
|
|
135536
|
-
|
|
135634
|
+
rmSync16(lock, { force: true });
|
|
135537
135635
|
}
|
|
135538
135636
|
}
|
|
135539
135637
|
throw new Error(`Another command is refreshing test user ${name}. Wait for it to finish, or clean up and prepare the test users again.`);
|
|
@@ -135640,7 +135738,7 @@ var init_reference_check_note = __esm({
|
|
|
135640
135738
|
|
|
135641
135739
|
// dist/lib/test-scripts.js
|
|
135642
135740
|
import { createRequire as createRequire10 } from "node:module";
|
|
135643
|
-
import { existsSync as existsSync39, mkdirSync as
|
|
135741
|
+
import { existsSync as existsSync39, mkdirSync as mkdirSync21, readFileSync as readFileSync43, readdirSync as readdirSync8, rmSync as rmSync17, statSync as statSync8, writeFileSync as writeFileSync27 } from "node:fs";
|
|
135644
135742
|
import { dirname as dirname15, join as join46, relative as relative13, resolve as resolve25 } from "node:path";
|
|
135645
135743
|
import { spawn as spawn7, spawnSync as spawnSync5 } from "node:child_process";
|
|
135646
135744
|
function hasSpecFiles(root) {
|
|
@@ -135711,8 +135809,8 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
135711
135809
|
const started = performance.now();
|
|
135712
135810
|
let output = "";
|
|
135713
135811
|
const handOver = join46(root, ".somewhere", "tests", `report-${results.length}.json`);
|
|
135714
|
-
|
|
135715
|
-
|
|
135812
|
+
mkdirSync21(dirname15(handOver), { recursive: true });
|
|
135813
|
+
rmSync17(handOver, { force: true });
|
|
135716
135814
|
const askedForBrowserLog = /(^|,)\s*(pw:browser|pw:\*|\*)\s*(,|$)/.test(env.DEBUG ?? "");
|
|
135717
135815
|
const childEnv = { ...env, SW_TEST_REPORT: handOver, DEBUG: askedForBrowserLog ? env.DEBUG : [env.DEBUG, "pw:browser"].filter(Boolean).join(",") };
|
|
135718
135816
|
const child = spawn7(process.execPath, [script, ...extraArgs], { cwd: root, env: childEnv, stdio: ["inherit", "pipe", "pipe"] });
|
|
@@ -135740,11 +135838,11 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
135740
135838
|
stderrLines("", true);
|
|
135741
135839
|
let report2 = null;
|
|
135742
135840
|
try {
|
|
135743
|
-
report2 = existsSync39(handOver) ? JSON.parse(
|
|
135841
|
+
report2 = existsSync39(handOver) ? JSON.parse(readFileSync43(handOver, "utf8")) : null;
|
|
135744
135842
|
} catch {
|
|
135745
135843
|
report2 = null;
|
|
135746
135844
|
}
|
|
135747
|
-
|
|
135845
|
+
rmSync17(handOver, { force: true });
|
|
135748
135846
|
results.push({
|
|
135749
135847
|
script,
|
|
135750
135848
|
ok: exitCode === 0,
|
|
@@ -135777,16 +135875,16 @@ function lastFailedScripts(root) {
|
|
|
135777
135875
|
if (!existsSync39(path3))
|
|
135778
135876
|
return [];
|
|
135779
135877
|
try {
|
|
135780
|
-
return (JSON.parse(
|
|
135878
|
+
return (JSON.parse(readFileSync43(path3, "utf8")).results ?? []).filter((r) => !r.ok).map((r) => r.script);
|
|
135781
135879
|
} catch {
|
|
135782
135880
|
return [];
|
|
135783
135881
|
}
|
|
135784
135882
|
}
|
|
135785
135883
|
function recordScriptResults(root, results, rerunOnly) {
|
|
135786
|
-
const previous = rerunOnly && existsSync39(join46(root, LAST)) ? JSON.parse(
|
|
135884
|
+
const previous = rerunOnly && existsSync39(join46(root, LAST)) ? JSON.parse(readFileSync43(join46(root, LAST), "utf8")).results ?? [] : [];
|
|
135787
135885
|
const merged = [...previous.filter((p2) => !results.some((r) => r.script === p2.script)), ...results];
|
|
135788
|
-
|
|
135789
|
-
|
|
135886
|
+
mkdirSync21(join46(root, ".somewhere", "tests"), { recursive: true });
|
|
135887
|
+
writeFileSync27(join46(root, LAST), JSON.stringify({ finished: (/* @__PURE__ */ new Date()).toISOString(), results: merged }, null, 2) + "\n");
|
|
135790
135888
|
}
|
|
135791
135889
|
var BROWSER_CRASH, BROWSER_CRASH_REASON, isScript, LAST;
|
|
135792
135890
|
var init_test_scripts = __esm({
|
|
@@ -135899,7 +135997,7 @@ var init_test = __esm({
|
|
|
135899
135997
|
});
|
|
135900
135998
|
|
|
135901
135999
|
// dist/commands/test-users.js
|
|
135902
|
-
import { existsSync as existsSync40, readFileSync as
|
|
136000
|
+
import { existsSync as existsSync40, readFileSync as readFileSync44, rmSync as rmSync18 } from "node:fs";
|
|
135903
136001
|
import { basename as basename10, join as join47 } from "node:path";
|
|
135904
136002
|
import { randomBytes as randomBytes9 } from "node:crypto";
|
|
135905
136003
|
async function resolveTarget(projectOpt, originOpt) {
|
|
@@ -136168,7 +136266,7 @@ function registerTestUsers(program2) {
|
|
|
136168
136266
|
if (left.length)
|
|
136169
136267
|
writeManifest(target.root, { ...manifest, actors: left, status: "partial" });
|
|
136170
136268
|
else
|
|
136171
|
-
|
|
136269
|
+
rmSync18(join47(stateDir(target.root), MANIFEST_FILE), { force: true });
|
|
136172
136270
|
if (opts.json) {
|
|
136173
136271
|
printJson(receipt);
|
|
136174
136272
|
if (left.length)
|
|
@@ -136415,7 +136513,7 @@ var init_skills = __esm({
|
|
|
136415
136513
|
});
|
|
136416
136514
|
|
|
136417
136515
|
// dist/commands/ai.js
|
|
136418
|
-
import { readFileSync as
|
|
136516
|
+
import { readFileSync as readFileSync45 } from "node:fs";
|
|
136419
136517
|
function fail4(message3) {
|
|
136420
136518
|
error(message3);
|
|
136421
136519
|
process.exit(1);
|
|
@@ -136436,7 +136534,7 @@ async function readKey(stdin) {
|
|
|
136436
136534
|
if (stdin) {
|
|
136437
136535
|
if (process.stdin.isTTY)
|
|
136438
136536
|
fail4("Pipe the key into --stdin, or leave out --stdin to type it into a hidden prompt.");
|
|
136439
|
-
raw =
|
|
136537
|
+
raw = readFileSync45(0, "utf8");
|
|
136440
136538
|
} else {
|
|
136441
136539
|
if (!process.stdin.isTTY)
|
|
136442
136540
|
fail4("Pass --stdin to read the key from a pipe. Nothing was sent.");
|
|
@@ -136583,13 +136681,13 @@ var init_startup_notice = __esm({
|
|
|
136583
136681
|
});
|
|
136584
136682
|
|
|
136585
136683
|
// dist/lib/last-run.js
|
|
136586
|
-
import { lstatSync as
|
|
136684
|
+
import { lstatSync as lstatSync6, mkdirSync as mkdirSync22, renameSync as renameSync7, unlinkSync as unlinkSync6, writeFileSync as writeFileSync28 } from "node:fs";
|
|
136587
136685
|
import { join as join49 } from "node:path";
|
|
136588
136686
|
function removeStaleRunRecord(dir = cliConfigDir()) {
|
|
136589
136687
|
for (const name of RUN_RECORD_FILES) {
|
|
136590
136688
|
const path3 = join49(dir, name);
|
|
136591
136689
|
try {
|
|
136592
|
-
if (
|
|
136690
|
+
if (lstatSync6(path3).isDirectory()) {
|
|
136593
136691
|
process.stderr.write(`Could not remove ${path3}: it is a directory, not this CLI's run record. Check it yourself.
|
|
136594
136692
|
`);
|
|
136595
136693
|
continue;
|
|
@@ -136618,7 +136716,7 @@ function recordLastRun(cliVersion) {
|
|
|
136618
136716
|
process.once("exit", (exitCode) => {
|
|
136619
136717
|
try {
|
|
136620
136718
|
const dir = cliConfigDir();
|
|
136621
|
-
|
|
136719
|
+
mkdirSync22(dir, { recursive: true, mode: 448 });
|
|
136622
136720
|
const record3 = {
|
|
136623
136721
|
// A usage error never reaches a command: no command and no options.
|
|
136624
136722
|
command: invocation?.command ?? "",
|
|
@@ -136629,8 +136727,8 @@ function recordLastRun(cliVersion) {
|
|
|
136629
136727
|
};
|
|
136630
136728
|
const path3 = join49(dir, "last-run.json");
|
|
136631
136729
|
const temporary = join49(dir, "last-run.json.tmp");
|
|
136632
|
-
|
|
136633
|
-
|
|
136730
|
+
writeFileSync28(temporary, JSON.stringify(record3) + "\n", { mode: 384 });
|
|
136731
|
+
renameSync7(temporary, path3);
|
|
136634
136732
|
} catch {
|
|
136635
136733
|
}
|
|
136636
136734
|
});
|
|
@@ -136666,7 +136764,7 @@ __export(dist_exports, {
|
|
|
136666
136764
|
runCli: () => runCli
|
|
136667
136765
|
});
|
|
136668
136766
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
136669
|
-
import { readFileSync as
|
|
136767
|
+
import { readFileSync as readFileSync46 } from "node:fs";
|
|
136670
136768
|
import { join as join50 } from "node:path";
|
|
136671
136769
|
async function runCli() {
|
|
136672
136770
|
const pinned = decidePin(process.cwd(), CLI_VERSION, process.argv, process.env);
|
|
@@ -136695,7 +136793,7 @@ async function runCli() {
|
|
|
136695
136793
|
process.exit(child.status ?? 1);
|
|
136696
136794
|
}
|
|
136697
136795
|
removeStaleRunRecord();
|
|
136698
|
-
const pkg = JSON.parse(
|
|
136796
|
+
const pkg = JSON.parse(readFileSync46(join50(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
136699
136797
|
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);
|
|
136700
136798
|
recordLastRun(pkg.version);
|
|
136701
136799
|
const jsonOutputRequested = process.argv.includes("--json");
|