@somewhere-cloud/cli 0.38.149 → 0.38.150

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 CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.38.150
4
+
5
+ - `somewhere typecheck` now checks the source and functions sent to deploy, using the platform's TypeScript version, generated types and checker settings. Use `somewhere typecheck --project` for the full local project check.
6
+ - A server read with an empty `columns` array now has the same row type as a read that omits `columns`.
7
+
3
8
  ## 0.38.149
4
9
 
5
10
  - The local browser and Playwright test fixtures wait for an app's SDK session check after navigation.
package/README.md CHANGED
@@ -71,8 +71,11 @@ when no compiler is installed in the project.
71
71
  `init` installs React, the SDK, TypeScript, and editor types. For a local Vite server, use
72
72
  `npm install -D --save-exact vite@7.2.2` for `somewhere dev`.
73
73
  Save each journey you want re-checked after every deploy as `checks/<plain-name>.json`;
74
- the platform runs them in its browser after each deploy and `somewhere test` runs them now
75
- (nothing to install). A Playwright script or spec runs locally with
74
+ the platform runs them in its browser after each deploy, with nothing to install. Run `somewhere test`
75
+ for the latest result or add `--again` to start a fresh run. The last line is JSON
76
+ with `outcome` and `counts`. Exit codes are 0 for passed, 1 for a named failure,
77
+ and 2 for an incomplete check or cleanup. Warnings leave the exit status unchanged.
78
+ A Playwright script or spec runs locally with
76
79
  `somewhere test <file>` after `npm install -D --save-exact @playwright/test@1.65.0`.
77
80
  `init --template bare` is the same as `init --bare` and installs no dependencies.
78
81
 
@@ -110,7 +113,7 @@ For optional after-edit checking, explicitly run `somewhere hooks install --host
110
113
  | `somewhere git status` | Show connected repo, commit, deploy status, logs link, and live URL |
111
114
  | `somewhere git disconnect` | Stop push-to-deploy; the currently deployed site stays live |
112
115
  | `somewhere pull <app>` | Download the live source of an existing app and link the folder before editing |
113
- | `somewhere typecheck` | Checks the project with `tsc --noEmit` and reports advisory platform source warnings with a suggested fix. Install the project dependencies first. If TypeScript is absent, the CLI tells you before fetching it through npm. |
116
+ | `somewhere typecheck` | Checks deployable source with the platform's TypeScript version, generated types and checker settings. Install project dependencies first. Use `--project` for the full project check with your own TypeScript and tsconfig.json. |
114
117
  | `somewhere logs` | Show recent logs |
115
118
  | `somewhere logs --follow` | Stream logs in real-time |
116
119
  | `somewhere logs --level error` | Filter by level |
@@ -77374,7 +77374,7 @@ function parseDeployOutput(output, projectDir, functions) {
77374
77374
  if (contract.isIgnoredDiagnostic(code))
77375
77375
  continue;
77376
77376
  const kind = contract.classifyDiagnostic(code);
77377
- if (!kind)
77377
+ if (!kind || kind === "type" && vendor2.isPlainPageScript(file, functions))
77378
77378
  continue;
77379
77379
  const finding = { kind, code, file, line: Number(lineText), column: Number(columnText), message: message3 };
77380
77380
  if (vendor2.isRuntimeEndpointGlobal(finding, functions))
@@ -77384,9 +77384,9 @@ function parseDeployOutput(output, projectDir, functions) {
77384
77384
  }
77385
77385
  return { findings, problems };
77386
77386
  }
77387
- async function runDeployCheck(projectDir) {
77387
+ async function runDeployCheck(projectDir, onFetch) {
77388
77388
  try {
77389
- return await startDeployCheck(projectDir);
77389
+ return await startDeployCheck(projectDir, onFetch);
77390
77390
  } catch (error3) {
77391
77391
  return {
77392
77392
  ok: false,
@@ -77397,7 +77397,7 @@ async function runDeployCheck(projectDir) {
77397
77397
  };
77398
77398
  }
77399
77399
  }
77400
- async function startDeployCheck(projectDir) {
77400
+ async function startDeployCheck(projectDir, onFetch) {
77401
77401
  const typescript = DEPLOY_CHECK_TYPESCRIPT_VERSION;
77402
77402
  const collected = collectFiles(projectDir);
77403
77403
  const graph = {};
@@ -77408,6 +77408,7 @@ async function startDeployCheck(projectDir) {
77408
77408
  const checked = Object.keys(graph);
77409
77409
  if (checked.length === 0)
77410
77410
  return { ok: true, findings: [], typescript, checkedFiles: 0 };
77411
+ const { command, args } = deployCheckTsc(projectDir);
77411
77412
  const tsconfigPath = join17(projectDir, "tsconfig.json");
77412
77413
  const own2 = projectCompilerOptions(existsSync14(tsconfigPath) ? readFileSync16(tsconfigPath, "utf8") : void 0);
77413
77414
  const id = randomUUID5();
@@ -77429,11 +77430,12 @@ async function startDeployCheck(projectDir) {
77429
77430
  compilerOptions: contract.localCheckCompilerOptions(own2),
77430
77431
  files: [...checked, ...declarations]
77431
77432
  }));
77433
+ if (command !== process.execPath)
77434
+ onFetch?.();
77432
77435
  } catch (error3) {
77433
77436
  cleanup();
77434
77437
  throw error3;
77435
77438
  }
77436
- const { command, args } = deployCheckTsc(projectDir);
77437
77439
  const run = await runBounded(command, [...args, "--project", config2, "--pretty", "false"], projectDir, { onAbort: cleanup });
77438
77440
  cleanup();
77439
77441
  const out = run.out;
@@ -77927,7 +77929,7 @@ var init_lint = __esm({
77927
77929
  import { existsSync as existsSync17 } from "node:fs";
77928
77930
  import { join as join20, relative as relative9, resolve as resolve11 } from "node:path";
77929
77931
  function registerTypecheck(program2) {
77930
- program2.command("typecheck [dir]").description(`Check TypeScript and report advisory Somewhere source warnings. Reports TypeScript errors with file:line before deploy and exits 1 when there are any; \`${cliInvocation()} deploy\` stops on type errors. Requires a local tsconfig.json; add one for a new app, or run \`${cliInvocation()} pull\` for an existing deployed app. It never installs the project's dependencies: if the project has missing dependencies, it says so and stops; run npm install first. Without TypeScript in the project it fetches TypeScript with npx (network; npm caches it) and says so on stderr. Every run stops after SOMEWHERE_TYPECHECK_TIMEOUT_MS (default 300000). With --deploy, runs the deploy's advisory reference check instead (the files a deploy uploads, its generated types, options and TypeScript ${DEPLOY_CHECK_TYPESCRIPT_VERSION}) against the packages installed here; no tsconfig.json needed. It reports a narrower set than the default project check, which stays the stricter of the two.`).option("--json", "Print typecheck and platform source findings as JSON").option("--deploy", "Run the deploy's reference check: the undefined-name and type findings a deploy reports. Fetches TypeScript " + DEPLOY_CHECK_TYPESCRIPT_VERSION + " through npx unless the project has exactly that version").option("--hook <host>", `With --deploy: run as an agent after-edit hook (${AGENT_HOSTS.join(", ")}), reading the host's event on stdin. Installed by \`${cliInvocation()} hooks install\``).option("--watch", "Keep running and re-check after each save while this command is open. It is not installed into your editor or agent; start it yourself. Never deploys or touches live data").action(async (dirArg, opts) => {
77932
+ program2.command("typecheck [dir]").description(`Check the deployable source with the platform's TypeScript ${DEPLOY_CHECK_TYPESCRIPT_VERSION}, generated types and checker settings. Reports file and line for deploy-check type findings and exits 1 when there are findings. Install the project dependencies first. The CLI fetches the pinned TypeScript with npx if needed. Use --project to check the full project with its own tsconfig.json and compiler.`).option("--json", "Print typecheck and platform source findings as JSON").option("--deploy", "Run the deploy reference check and return its findings").addOption(new Option("--project", "Run the full project TypeScript check using tsconfig.json").conflicts("deploy")).option("--hook <host>", `With --deploy: run as an agent after-edit hook (${AGENT_HOSTS.join(", ")}), reading the host's event on stdin. Installed by \`${cliInvocation()} hooks install\``).option("--watch", "Keep running and re-check after each save while this command is open. It is not installed into your editor or agent; start it yourself. Never deploys or touches live data").action(async (dirArg, opts) => {
77931
77933
  const dir = resolve11(process.cwd(), dirArg ?? ".");
77932
77934
  for (const hint of roleMethodHints(dir))
77933
77935
  console.error(hint);
@@ -77950,11 +77952,16 @@ function registerTypecheck(program2) {
77950
77952
  process.stderr.write(outcome2.stderr);
77951
77953
  process.exit(outcome2.exitCode);
77952
77954
  }
77955
+ let deployFetchAnnounced = false;
77956
+ const announceDeployFetch = /* @__PURE__ */ __name(() => {
77957
+ if (deployFetchAnnounced)
77958
+ return;
77959
+ deployFetchAnnounced = true;
77960
+ announceDeployCheckFetch(dir);
77961
+ }, "announceDeployFetch");
77953
77962
  if (opts.deploy) {
77954
- if (/^npx(\.cmd)?$/.test(deployCheckTsc(dir).command))
77955
- announceDeployCheckFetch(dir);
77956
77963
  const check2 = /* @__PURE__ */ __name(async () => {
77957
- const result3 = await runDeployCheck(dir);
77964
+ const result3 = await runDeployCheck(dir, announceDeployFetch);
77958
77965
  if (opts.json)
77959
77966
  printJson(result3);
77960
77967
  else
@@ -77966,7 +77973,7 @@ function registerTypecheck(program2) {
77966
77973
  const result2 = await check2();
77967
77974
  process.exit(result2.ok ? 0 : 1);
77968
77975
  }
77969
- if (!existsSync17(join20(dir, "tsconfig.json"))) {
77976
+ if (opts.project && !existsSync17(join20(dir, "tsconfig.json"))) {
77970
77977
  if (opts.json) {
77971
77978
  printJson({
77972
77979
  ok: false,
@@ -77980,23 +77987,33 @@ function registerTypecheck(program2) {
77980
77987
  error(MISSING_TSCONFIG_GUIDANCE);
77981
77988
  process.exit(1);
77982
77989
  }
77990
+ const deployVia = deployCheckTsc(dir).command === process.execPath ? "project" : "npx";
77991
+ const via = opts.project ? typecheckCompilerSource(dir) : deployVia;
77983
77992
  const notInstalled = /* @__PURE__ */ __name(() => {
77984
77993
  const missing = missingProjectDependencies(dir);
77985
- return missing.length ? { ok: false, errors: [], via: typecheckCompilerSource(dir), raw: "", spawnError: missingTypecheckDependenciesMessage() } : null;
77994
+ return missing.length ? { ok: false, errors: [], via, raw: "", spawnError: missingTypecheckDependenciesMessage() } : null;
77986
77995
  }, "notInstalled");
77987
77996
  let announced = false;
77988
77997
  const announceFetch = /* @__PURE__ */ __name(() => {
77989
- if (announced || typecheckCompilerSource(dir) !== "npx")
77998
+ if (announced || via !== "npx")
77990
77999
  return;
77991
78000
  announced = true;
77992
78001
  announceNpxTypeScriptFetch(TYPECHECK_TYPESCRIPT_VERSION);
77993
78002
  }, "announceFetch");
77994
78003
  const check = /* @__PURE__ */ __name(async () => {
77995
78004
  const refused = notInstalled();
77996
- if (!refused)
78005
+ if (!refused && opts.project)
77997
78006
  announceFetch();
77998
78007
  const spinner = opts.json || refused || opts.watch ? null : ora("Typechecking (tsc --noEmit)...").start();
77999
- const result2 = refused ?? await runTypecheck(dir);
78008
+ const deployResult = refused || opts.project ? void 0 : await runDeployCheck(dir, announceDeployFetch);
78009
+ const result2 = deployResult ? {
78010
+ ok: deployResult.ok,
78011
+ errors: deployResult.findings,
78012
+ via,
78013
+ raw: deployResult.error ?? "",
78014
+ spawnError: deployResult.error,
78015
+ typescript: deployResult.typescript
78016
+ } : refused ?? await runTypecheck(dir);
78000
78017
  spinner?.stop();
78001
78018
  const sourceLint = await lintProject(dir).catch((failure2) => ({
78002
78019
  ok: false,
@@ -78005,7 +78022,10 @@ function registerTypecheck(program2) {
78005
78022
  if (opts.json)
78006
78023
  printJson({ ...result2, sourceLint });
78007
78024
  else {
78008
- reportTypecheck(result2);
78025
+ if (deployResult)
78026
+ reportDeployCheck(deployResult, "Typecheck");
78027
+ else
78028
+ reportTypecheck(result2);
78009
78029
  if ("error" in sourceLint)
78010
78030
  warn(`Source lint failed: ${sourceLint.error}`);
78011
78031
  else
@@ -78055,18 +78075,18 @@ function reportTypecheck(result) {
78055
78075
  }
78056
78076
  console.log("");
78057
78077
  }
78058
- function reportDeployCheck(result) {
78078
+ function reportDeployCheck(result, label = "Deploy check") {
78059
78079
  if (result.error) {
78060
78080
  error(`Could not run the deploy check (TypeScript ${result.typescript}): ${result.error}`);
78061
78081
  return;
78062
78082
  }
78063
78083
  if (result.ok) {
78064
- success(`Deploy check clean ${dim(`(${result.checkedFiles} file${result.checkedFiles === 1 ? "" : "s"}, TypeScript ${result.typescript})`)}.`);
78084
+ success(`${label} clean ${dim(`(${result.checkedFiles} file${result.checkedFiles === 1 ? "" : "s"}, TypeScript ${result.typescript})`)}.`);
78065
78085
  return;
78066
78086
  }
78067
78087
  const references = result.findings.filter((f2) => f2.kind === "reference").length;
78068
78088
  const n = result.findings.length;
78069
- error(`${bold(String(n))} deploy finding${n === 1 ? "" : "s"} ${dim(`(TypeScript ${result.typescript})`)} \u2014 a deploy reports these as warnings${references ? `; ${references} undefined name${references === 1 ? "" : "s"} will fail at runtime` : ""}.`);
78089
+ error(`${bold(String(n))} deploy finding${n === 1 ? "" : "s"} ${dim(`(TypeScript ${result.typescript})`)} \u2014 fix these before running \`${cliInvocation()} deploy-check\`${references ? `. Found ${references} undefined name${references === 1 ? "" : "s"}` : ""}.`);
78070
78090
  console.log("");
78071
78091
  for (const f2 of result.findings) {
78072
78092
  const tag = f2.kind === "reference" ? red(f2.code) : dim(f2.code);
@@ -78121,6 +78141,7 @@ var init_typecheck2 = __esm({
78121
78141
  "use strict";
78122
78142
  init_cli_invocation();
78123
78143
  init_role_method_hints();
78144
+ init_esm();
78124
78145
  init_esm4();
78125
78146
  init_spinner();
78126
78147
  init_deploy_check();
@@ -78140,6 +78161,21 @@ var init_typecheck2 = __esm({
78140
78161
  }
78141
78162
  });
78142
78163
 
78164
+ // dist/lib/check-summary.js
78165
+ function summarizeChecks(counts) {
78166
+ return { outcome: counts.failed ? "failed" : counts.could_not_check ? "could_not_check" : "passed", counts };
78167
+ }
78168
+ function checkSummaryExitCode(summary) {
78169
+ return summary.outcome === "failed" ? 1 : summary.outcome === "could_not_check" ? 2 : 0;
78170
+ }
78171
+ var init_check_summary = __esm({
78172
+ "dist/lib/check-summary.js"() {
78173
+ "use strict";
78174
+ __name(summarizeChecks, "summarizeChecks");
78175
+ __name(checkSummaryExitCode, "checkSummaryExitCode");
78176
+ }
78177
+ });
78178
+
78143
78179
  // dist/lib/deploy-checks.js
78144
78180
  function parseChecksRead(read) {
78145
78181
  const match = /^GET\s+(\/\S+)$/.exec(read.trim());
@@ -78183,33 +78219,104 @@ async function runChecksNow(client, projectId, opts = {}) {
78183
78219
  const started = await client.call("POST", "/deploy/checks", { project_id: projectId });
78184
78220
  return awaitDeployChecks(client, { read: started?.read }, { waitMs: TEST_CHECKS_WAIT_MS, ...opts });
78185
78221
  }
78186
- function formatChecksReport(check) {
78187
- if (!check || check.status === "pending") {
78188
- return [`The checks did not finish within ${TEST_CHECKS_WAIT_MS / 1e3} s; \`${cliInvocation()} call project_deploy_log '{}'\` shows the result when they do.`];
78189
- }
78190
- const lines = Array.isArray(check.checks) ? check.checks : [];
78222
+ function lineOutcome(line) {
78223
+ if (line.outcome)
78224
+ return line.outcome;
78225
+ if (line.pass)
78226
+ return "passed";
78227
+ return line.as === "stranger" || line.as === "signed_out" && line.method !== "flow" ? "could_not_check" : "failed";
78228
+ }
78229
+ function deployChecksSummary(check) {
78230
+ const lines = check?.checks ?? [];
78231
+ const counts = { passed: 0, failed: 0, could_not_check: cleanupFindings(check).length, warnings: functionWarnings(check).length };
78232
+ for (const line of lines)
78233
+ counts[lineOutcome(line)]++;
78234
+ if (check?.status !== "checked" || !lines.length || check.passed === false && !counts.failed && !counts.could_not_check && (!check.findings?.length || check.findings.some((finding) => finding.kind !== "crash")))
78235
+ counts.could_not_check++;
78236
+ return summarizeChecks(counts);
78237
+ }
78238
+ function checksJsonReport(check) {
78239
+ const summary = deployChecksSummary(check);
78240
+ const checked = check?.checks ?? [];
78241
+ const confirmedAccessFailure = checked.some((line) => line.outcome === "failed" && (line.as === "stranger" || line.as === "signed_out") && line.method !== "flow");
78242
+ const findings = (check?.findings ?? []).filter((item) => (item.kind !== "crash" || Boolean(item.request_id)) && (item.kind !== "read" && item.kind !== "write" || confirmedAccessFailure));
78243
+ return {
78244
+ ...check,
78245
+ checks: checked.map((line) => ({ ...line, pass: lineOutcome(line) === "passed", outcome: lineOutcome(line) })),
78246
+ findings,
78247
+ sentence: findings.length !== (check?.findings?.length ?? 0) ? null : check?.sentence ?? null,
78248
+ passed: summary.outcome === "passed",
78249
+ ...summary
78250
+ };
78251
+ }
78252
+ function resultEvidence(line) {
78253
+ const request2 = line.request ?? { method: line.method, url: line.path };
78254
+ const responses = line.responses?.length ? line.responses : [{ status: line.status, observed: line.detail }];
78191
78255
  return [
78192
- ...lines.filter((line) => !line.pass).map((line) => `FAIL ${line.name}`),
78193
- ...lines.filter((line) => line.pass).map((line) => `PASS ${line.name}`),
78194
- ...check.sentence ? [check.sentence] : []
78256
+ ` Did: ${request2.method ?? "check"} ${request2.url ?? line.name} as ${line.as ?? "the test actor"}`,
78257
+ ...line.expected ? [` Expected: ${line.expected}`] : [],
78258
+ ...responses.map((r, i) => ` Response ${i + 1}: ${r.status ? `HTTP ${r.status}` : "no HTTP status"}${r.observed ? ` \u2014 ${r.observed}` : ""}${"request_id" in r && r.request_id ? ` (request ID ${r.request_id})` : ""}`),
78259
+ ` Reproduce: ${JSON.stringify(request2)}`,
78260
+ ...responses.flatMap((r) => "request" in r && r.request ? [` Confirmation request: ${JSON.stringify(r.request)}`] : [])
78195
78261
  ];
78196
78262
  }
78197
- function checksExitCode(check) {
78198
- return check?.passed === true ? 0 : 1;
78263
+ function formatChecksReport(check) {
78264
+ const summary = deployChecksSummary(check);
78265
+ const lines = [];
78266
+ if (!check || check.status === "pending") {
78267
+ lines.push(`Could not check: the run did not finish within ${TEST_CHECKS_WAIT_MS / 1e3} s.`);
78268
+ } else if (check.status !== "checked") {
78269
+ lines.push(`Could not check: ${check.sentence ?? "The check run is unavailable."}`);
78270
+ } else {
78271
+ const checks = check.checks ?? [];
78272
+ for (const line of checks.filter((item) => lineOutcome(item) !== "passed")) {
78273
+ const label = lineOutcome(line) === "failed" ? "FAIL" : "Could not check";
78274
+ lines.push(`${label} ${line.name}`, ...resultEvidence(line));
78275
+ if (line.detail && line.responses?.length)
78276
+ lines.push(` ${line.detail}`);
78277
+ if (!line.outcome && label === "Could not check")
78278
+ lines.push(` Run ${cliInvocation()} test --again to confirm this access check.`);
78279
+ }
78280
+ for (const line of checks.filter((item) => lineOutcome(item) === "passed"))
78281
+ lines.push(`PASS ${line.name}`);
78282
+ for (const finding of functionWarnings(check)) {
78283
+ if (finding.kind === "crash") {
78284
+ lines.push(`Warning: A server function crashed: ${finding.via} (request ID ${finding.request_id}).`);
78285
+ } else {
78286
+ const receipt = [finding.status ? `HTTP ${finding.status}` : "", finding.request_id ? `request ID ${finding.request_id}` : ""].filter(Boolean).join(", ");
78287
+ lines.push(`Warning: ${finding.via} returned 5xx; no error record found yet${receipt ? ` (${receipt})` : ""}.`);
78288
+ }
78289
+ }
78290
+ for (const finding of cleanupFindings(check)) {
78291
+ const receipt = [finding.status ? `HTTP ${finding.status}` : "", finding.request_id ? `request ID ${finding.request_id}` : ""].filter(Boolean).join(", ");
78292
+ lines.push(`Could not check cleanup: ${finding.left_behind ?? (finding.table ? `A test row in ${finding.table} may remain.` : `Check whether any ${finding.via ?? "test data"} remain.`)}${receipt ? ` (${receipt})` : ""}`);
78293
+ }
78294
+ if (!checks.length)
78295
+ lines.push("Could not check: no named checks ran.");
78296
+ if (summary.counts.could_not_check && !lines.some((line) => line.startsWith("Could not check")))
78297
+ lines.push(`Could not check: run ${cliInvocation()} test --again to get named results.`);
78298
+ }
78299
+ return [...lines, JSON.stringify(summary)];
78199
78300
  }
78200
- var DEPLOY_CHECKS_POLL_MS, DEPLOY_CHECKS_RUNNING, TEST_CHECKS_WAIT_MS;
78301
+ var DEPLOY_CHECKS_POLL_MS, DEPLOY_CHECKS_RUNNING, TEST_CHECKS_WAIT_MS, cleanupFindings, functionWarnings;
78201
78302
  var init_deploy_checks = __esm({
78202
78303
  "dist/lib/deploy-checks.js"() {
78203
78304
  "use strict";
78204
78305
  init_cli_invocation();
78306
+ init_check_summary();
78205
78307
  DEPLOY_CHECKS_POLL_MS = 3e3;
78206
78308
  __name(parseChecksRead, "parseChecksRead");
78207
78309
  __name(awaitDeployChecks, "awaitDeployChecks");
78208
78310
  DEPLOY_CHECKS_RUNNING = `Checks: running in the background; \`${cliInvocation()} test\` shows the result.`;
78209
78311
  TEST_CHECKS_WAIT_MS = 15e4;
78210
78312
  __name(runChecksNow, "runChecksNow");
78313
+ __name(lineOutcome, "lineOutcome");
78314
+ cleanupFindings = /* @__PURE__ */ __name((check) => (check?.findings ?? []).filter((f2) => f2.kind === "cleanup"), "cleanupFindings");
78315
+ functionWarnings = /* @__PURE__ */ __name((check) => (check?.findings ?? []).filter((finding) => finding.kind === "function_http_error" || finding.kind === "crash" && Boolean(finding.request_id)), "functionWarnings");
78316
+ __name(deployChecksSummary, "deployChecksSummary");
78317
+ __name(checksJsonReport, "checksJsonReport");
78318
+ __name(resultEvidence, "resultEvidence");
78211
78319
  __name(formatChecksReport, "formatChecksReport");
78212
- __name(checksExitCode, "checksExitCode");
78213
78320
  }
78214
78321
  });
78215
78322
 
@@ -82880,7 +82987,8 @@ function createVerifyJourneyRun(target, journey, client, opts = {}) {
82880
82987
  return { status: "kept", reason: "kept with their browsers for the next --keep-actors run; remove them with --close-actors" };
82881
82988
  try {
82882
82989
  const removed = await client.call("DELETE", "/auth/test-users", { project_id: target.project_id, ids: [...testIdentities.values()].map((item) => item.user_id) });
82883
- return { status: "deleted", deleted: typeof removed?.deleted === "number" ? removed.deleted : void 0 };
82990
+ const deleted = removed?.deleted;
82991
+ return deleted === testIdentities.size ? { status: "deleted", deleted } : { status: "unconfirmed", deleted, reason: "The platform did not confirm removal of every test user." };
82884
82992
  } catch (cause) {
82885
82993
  const code = cause instanceof CliApiError ? cause.code : cause instanceof Error ? cause.message : String(cause);
82886
82994
  return { status: "unconfirmed", reason: `delete failed (${code}); the platform removes test users when they expire` };
@@ -83187,6 +83295,11 @@ function createVerifyJourneyRun(target, journey, client, opts = {}) {
83187
83295
  const deleteStartedAt = now2();
83188
83296
  const testUsers = testIdentities.size ? { identities: [...testIdentities].map(([actor, item]) => ({ actor, ...item })), cleanup: await removeTestUsers() } : void 0;
83189
83297
  const testUsersDeleteMs = testUsers ? now2() - deleteStartedAt : void 0;
83298
+ if (testUsers?.cleanup.status === "unconfirmed") {
83299
+ passed = false;
83300
+ const note = `Could not check cleanup. Test users for ${testUsers.identities.map((user) => user.actor).join(", ")} may remain.`;
83301
+ verdict = verdict.startsWith("PASS") ? `INCOMPLETE \u2014 ${note}` : `${verdict} ${note}`;
83302
+ }
83190
83303
  if (cleanup.some((item) => item.status === "unconfirmed")) {
83191
83304
  passed = false;
83192
83305
  const lifecycle = cleanup.filter((item) => item.status === "unconfirmed").map((item) => ({ viewport: item.actor, detail: { status: "cleanup_unknown", outcome_unknown: true } }));
@@ -83205,7 +83318,7 @@ function createVerifyJourneyRun(target, journey, client, opts = {}) {
83205
83318
  limits: VERIFY_JOURNEY_LIMITS,
83206
83319
  cleanup,
83207
83320
  cleanup_ms,
83208
- cleanup_confirmed: cleanup.every((item) => item.status !== "unconfirmed"),
83321
+ cleanup_confirmed: cleanup.every((item) => item.status !== "unconfirmed") && testUsers?.cleanup.status !== "unconfirmed",
83209
83322
  kept_sessions: [...kept.values()],
83210
83323
  ...testUsers ? { test_users: testUsers } : {},
83211
83324
  ...keep ? { keep_actors: {
@@ -83461,6 +83574,40 @@ function formatJourneyCleanup(cleanup, cleanupMs) {
83461
83574
  }
83462
83575
  return lines;
83463
83576
  }
83577
+ function verifyResultSummary(report2) {
83578
+ const failedSteps = report2.steps.filter((step2) => step2.ran !== false && !step2.passed).length;
83579
+ const failedRequests = report2.health.network.failed_requests.length + report2.health.network.expectations.filter((item) => !item.detail.ok).length;
83580
+ const refused = report2.refusals?.length ?? 0;
83581
+ const cleanup = "cleanup" in report2 ? Number(report2.test_users?.cleanup.status === "unconfirmed") : 0;
83582
+ const segmentsNotStarted = "segments" in report2 ? report2.segments.filter((segment) => !segment.ran && segment.error).length : 0;
83583
+ const incomplete = report2.incomplete.length + (report2.lifecycle?.length ?? 0) + refused + segmentsNotStarted + cleanup;
83584
+ const failed = failedSteps + failedRequests + report2.health.page.errors.length + report2.health.console.errors.length;
83585
+ return summarizeChecks({
83586
+ passed: report2.steps.filter((step2) => step2.ran !== false && step2.passed).length || report2.viewports.filter((item) => item.passed).length,
83587
+ failed: failed || Number(!report2.passed && incomplete === 0 && report2.verdict.startsWith("FAIL")),
83588
+ could_not_check: incomplete || Number(!report2.passed && failed === 0 && !report2.verdict.startsWith("FAIL")),
83589
+ warnings: report2.layout.filter((item) => OVERFLOW_FINDING.test(item.detail)).length
83590
+ });
83591
+ }
83592
+ function printVerificationResult(report2, opts) {
83593
+ const result = verifyResultSummary(report2);
83594
+ if (opts.out !== void 0) {
83595
+ writeVerifyReportTo(opts.out, report2);
83596
+ const summary = summarizeVerifyReport(report2);
83597
+ if (opts.json)
83598
+ console.log(JSON.stringify({ ...summary, ...result }));
83599
+ else
83600
+ console.log(formatVerifySummaryLine(summary) + "\n" + JSON.stringify(result));
83601
+ noteVerifyRefusal(summary);
83602
+ } else if (opts.json) {
83603
+ console.log(JSON.stringify({ ...report2, ...result }));
83604
+ } else {
83605
+ for (const line of formatVerifyOutput(report2))
83606
+ console.log(line);
83607
+ console.log(JSON.stringify(result));
83608
+ }
83609
+ process.exitCode = checkSummaryExitCode(result);
83610
+ }
83464
83611
  function registerVerify(program2) {
83465
83612
  const cliCookies = [];
83466
83613
  const collectCookie = /* @__PURE__ */ __name((value) => {
@@ -83491,6 +83638,8 @@ Signed-in check (from a linked folder):
83491
83638
  Run: ${cliInvocation()} verify --path /admin --flow owner-flow.json
83492
83639
  When done, run: ${cliInvocation()} test-users cleanup
83493
83640
 
83641
+ A run ends with one JSON line containing outcome and counts.
83642
+ Exit 0 means passed, 1 means a named check failed, and 2 means a check or cleanup could not finish.
83494
83643
  Reports default to verify-reports/ inside the CLI config directory.
83495
83644
  Set SOMEWHERE_CONFIG_DIR before signing in to relocate both the CLI config
83496
83645
  and default reports. Use --out to choose just the report file for one run.
@@ -83646,7 +83795,7 @@ with account access. Print the full flow schema with ${cliInvocation()} verify -
83646
83795
  console.log("Some cleanup is unconfirmed; its record is kept so --close-actors can run again.");
83647
83796
  }
83648
83797
  if (!allConfirmed)
83649
- process.exitCode = 1;
83798
+ process.exitCode = 2;
83650
83799
  return;
83651
83800
  }
83652
83801
  const releaseKeepLock = keepKeyValue ? lockKeep(root, keepKeyValue) : void 0;
@@ -83695,17 +83844,8 @@ with account access. Print the full flow schema with ${cliInvocation()} verify -
83695
83844
  releaseKeepLock?.();
83696
83845
  }
83697
83846
  }
83698
- if (opts.out !== void 0) {
83699
- writeVerifyReportTo(opts.out, report3);
83700
- const summary = summarizeVerifyReport(report3);
83701
- console.log(opts.json ? JSON.stringify(summary, null, 2) : formatVerifySummaryLine(summary));
83702
- noteVerifyRefusal(summary);
83703
- } else if (opts.json)
83704
- console.log(JSON.stringify(report3, null, 2));
83705
- else
83706
- for (const line of formatVerifyOutput(report3))
83707
- console.log(line);
83708
- process.exit(report3.passed ? 0 : 1);
83847
+ printVerificationResult(report3, opts);
83848
+ return;
83709
83849
  }
83710
83850
  const loadedFlow = input.flow;
83711
83851
  const flow = {
@@ -83715,17 +83855,7 @@ with account access. Print the full flow schema with ${cliInvocation()} verify -
83715
83855
  };
83716
83856
  assertSessionSeedSize(flow);
83717
83857
  const report2 = await withVerifyProgress(() => runVerification({ ...project ? { project_id: project } : {}, ...url3 ? { url: url3 } : {} }, flow, client), !opts.json);
83718
- if (opts.out !== void 0) {
83719
- writeVerifyReportTo(opts.out, report2);
83720
- const summary = summarizeVerifyReport(report2);
83721
- console.log(opts.json ? JSON.stringify(summary, null, 2) : formatVerifySummaryLine(summary));
83722
- noteVerifyRefusal(summary);
83723
- } else if (opts.json)
83724
- console.log(JSON.stringify(report2, null, 2));
83725
- else
83726
- for (const line of formatVerifyOutput(report2))
83727
- console.log(line);
83728
- process.exit(report2.passed ? 0 : 1);
83858
+ printVerificationResult(report2, opts);
83729
83859
  } catch (cause) {
83730
83860
  if (cause instanceof CliApiError && cause.code === "VALIDATION_ERROR" && /provide exactly one of|unknown action|unsupported action|upload is not supported|screenshot is not supported/i.test(cause.message)) {
83731
83861
  error("VERIFY_ACTION_NOT_AVAILABLE: Browser upload and named screenshot actions are not available on this platform version yet.");
@@ -83748,6 +83878,7 @@ var VERIFY_TIMEOUT_MS, VERIFY_BUDGET_MS, VERIFY_MIN_BUDGET_MS, VERIFY_TRANSPORT_
83748
83878
  var init_verify = __esm({
83749
83879
  "dist/commands/verify.js"() {
83750
83880
  "use strict";
83881
+ init_check_summary();
83751
83882
  init_cli_invocation();
83752
83883
  init_repro_packet();
83753
83884
  init_browser_flow_preflight();
@@ -83844,6 +83975,8 @@ var init_verify = __esm({
83844
83975
  __name(noteVerifyRefusal, "noteVerifyRefusal");
83845
83976
  __name(formatVerifySummaryLine, "formatVerifySummaryLine");
83846
83977
  __name(formatJourneyCleanup, "formatJourneyCleanup");
83978
+ __name(verifyResultSummary, "verifyResultSummary");
83979
+ __name(printVerificationResult, "printVerificationResult");
83847
83980
  __name(registerVerify, "registerVerify");
83848
83981
  }
83849
83982
  });
@@ -135059,7 +135192,7 @@ var init_test_scripts = __esm({
135059
135192
 
135060
135193
  // dist/commands/test.js
135061
135194
  function registerTest(program2) {
135062
- program2.command("test [files...]").description("Run the live release's checks now in Somewhere's browser: your saved checks/*.json journeys, the stranger and signed-out access probes and a page crawl (the same check that runs after every deploy). Exits 1 when one fails. With a file, runs that tests/*.mjs or *.cjs script; a project with tests/**/*.spec.ts runs its Playwright specs (--preview: this folder's open preview)").option("--preview", "Test this folder's open preview (its own users, data copy and captured mail), pinned to the version saved when the run starts. Production is never touched.").option("--workers <count>", "Parallel workers", "5").option("--again", "Start a fresh run of the checks on the live release instead of reading the result of the last deploy's run").option("--failed", "Rerun what failed last time: each failed tests/*.mjs or *.cjs script, all its checks (specs: only the failed tests)").option("--fail-fast", "Stop app-check scripts at their first failed check").option("--grep <name>", "Filter test names (subset)").option("--url <url>", "Unsupported in phase 1").option("--phone", "Run every test again in a 390x844 phone viewport ([phone] in results)").option("--json", "Print structured results").option("--verbose", "Also print where the full result file is when everything passed").addHelpText("after", "\nSave each journey you want re-checked after every deploy as checks/<plain-name>.json; the platform runs them in its browser after each deploy and `somewhere test` runs them now.\n").action(async (files, opts) => {
135195
+ program2.command("test [files...]").description("Read the live release's latest checks, run in Somewhere's browser: your saved checks/*.json journeys, the stranger and signed-out access probes and a page crawl (the same check that runs after every deploy). Exits 0 when they pass, 1 for a named failure, or 2 when a check or cleanup could not finish. With a file, runs that tests/*.mjs or *.cjs script; a project with tests/**/*.spec.ts runs its Playwright specs (--preview: this folder's open preview)").option("--preview", "Test this folder's open preview (its own users, data copy and captured mail), pinned to the version saved when the run starts. Production is never touched.").option("--workers <count>", "Parallel workers", "5").option("--again", "Start a fresh run of the checks on the live release instead of reading the result of the last deploy's run").option("--failed", "Rerun what failed last time: each failed tests/*.mjs or *.cjs script, all its checks (specs: only the failed tests)").option("--fail-fast", "Stop app-check scripts at their first failed check").option("--grep <name>", "Filter test names (subset)").option("--url <url>", "Unsupported in phase 1").option("--phone", "Run every test again in a 390x844 phone viewport ([phone] in results)").option("--json", "Print structured results").option("--verbose", "Also print where the full result file is when everything passed").addHelpText("after", "\nSave each journey you want re-checked after every deploy as checks/<plain-name>.json; the platform runs them in its browser after each deploy and `somewhere test` reads the latest result. Use --again for a fresh run. The last line of a platform run is JSON with outcome and counts.\n").action(async (files, opts) => {
135063
135196
  markProcessStart("cli");
135064
135197
  mark("cli:action");
135065
135198
  if (opts.url)
@@ -135074,13 +135207,19 @@ function registerTest(program2) {
135074
135207
  const unsupported = [opts.phone && "--phone", opts.grep && "--grep", opts.workers !== "5" && "--workers", opts.failFast && "--fail-fast"].filter(Boolean);
135075
135208
  if (unsupported.length)
135076
135209
  throw new Error(`${unsupported.join(", ")} apply to Playwright specs and scripts; the platform runs checks/*.json as saved.`);
135077
- const check = await runChecksNow(new ApiClient(getToken()), projectId, { again: opts.again === true });
135210
+ let check;
135211
+ try {
135212
+ check = await runChecksNow(new ApiClient(getToken()), projectId, { again: opts.again === true });
135213
+ } catch (cause) {
135214
+ check = { status: "unavailable", sentence: cause instanceof Error ? cause.message : "The platform could not start the checks." };
135215
+ }
135078
135216
  mark("cli:exit");
135217
+ const summary = deployChecksSummary(check);
135079
135218
  if (opts.json)
135080
- process.stdout.write(JSON.stringify(check, null, 2) + "\n");
135219
+ process.stdout.write(JSON.stringify(checksJsonReport(check)) + "\n");
135081
135220
  else
135082
135221
  process.stdout.write(formatChecksReport(check).join("\n") + "\n");
135083
- process.exitCode = checksExitCode(check);
135222
+ process.exitCode = checkSummaryExitCode(summary);
135084
135223
  return;
135085
135224
  }
135086
135225
  const note = (opts.preview ? Promise.resolve(null) : referenceCheckNote(() => new ApiClient(getToken()), projectId)).then((line) => {
@@ -135126,6 +135265,7 @@ var init_test = __esm({
135126
135265
  init_test_timeline();
135127
135266
  init_reference_check_note();
135128
135267
  init_deploy_checks();
135268
+ init_check_summary();
135129
135269
  init_test_scripts();
135130
135270
  __name(registerTest, "registerTest");
135131
135271
  }