@somewhere-cloud/cli 0.38.164 → 0.38.166

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.
@@ -12184,7 +12184,7 @@ var require_client_h2 = __commonJS({
12184
12184
  "node_modules/undici/lib/dispatcher/client-h2.js"(exports, module) {
12185
12185
  "use strict";
12186
12186
  var assert2 = __require("node:assert");
12187
- var { pipeline: pipeline4 } = __require("node:stream");
12187
+ var { pipeline: pipeline5 } = __require("node:stream");
12188
12188
  var util = require_util();
12189
12189
  var {
12190
12190
  RequestContentLengthMismatchError,
@@ -13553,7 +13553,7 @@ var require_client_h2 = __commonJS({
13553
13553
  __name(writeBuffer, "writeBuffer");
13554
13554
  function writeStream(abort, socket, expectsPayload, h2stream, body, client, request2, contentLength) {
13555
13555
  assert2(contentLength !== 0 || client[kRunning] === 0, "stream body cannot be pipelined");
13556
- const pipe2 = pipeline4(
13556
+ const pipe2 = pipeline5(
13557
13557
  body,
13558
13558
  h2stream,
13559
13559
  (err) => {
@@ -17413,7 +17413,7 @@ var require_readable = __commonJS({
17413
17413
  "use strict";
17414
17414
  var assert2 = __require("node:assert");
17415
17415
  var { addAbortListener } = __require("node:events");
17416
- var { Readable: Readable3 } = __require("node:stream");
17416
+ var { Readable: Readable4 } = __require("node:stream");
17417
17417
  var { RequestAbortedError, NotSupportedError, InvalidArgumentError: InvalidArgumentError2, AbortError } = require_errors();
17418
17418
  var util = require_util();
17419
17419
  var kConsume = Symbol("kConsume");
@@ -17426,7 +17426,7 @@ var require_readable = __commonJS({
17426
17426
  var kBytesRead = Symbol("kBytesRead");
17427
17427
  var noop2 = /* @__PURE__ */ __name(() => {
17428
17428
  }, "noop");
17429
- var BodyReadable = class extends Readable3 {
17429
+ var BodyReadable = class extends Readable4 {
17430
17430
  static {
17431
17431
  __name(this, "BodyReadable");
17432
17432
  }
@@ -17925,7 +17925,7 @@ var require_api_request = __commonJS({
17925
17925
  "use strict";
17926
17926
  var assert2 = __require("node:assert");
17927
17927
  var { AsyncResource } = __require("node:async_hooks");
17928
- var { Readable: Readable3 } = require_readable();
17928
+ var { Readable: Readable4 } = require_readable();
17929
17929
  var { InvalidArgumentError: InvalidArgumentError2, RequestAbortedError } = require_errors();
17930
17930
  var util = require_util();
17931
17931
  var { dispatchWithSignal } = require_abort_signal();
@@ -18017,7 +18017,7 @@ var require_api_request = __commonJS({
18017
18017
  const parsedHeaders = headers;
18018
18018
  const contentType2 = parsedHeaders?.["content-type"];
18019
18019
  const contentLength = parsedHeaders?.["content-length"];
18020
- const res = new Readable3({
18020
+ const res = new Readable4({
18021
18021
  resume: /* @__PURE__ */ __name(() => controller.resume(), "resume"),
18022
18022
  abort: /* @__PURE__ */ __name((reason) => controller.abort(reason), "abort"),
18023
18023
  contentType: contentType2,
@@ -18358,7 +18358,7 @@ var require_api_pipeline = __commonJS({
18358
18358
  "node_modules/undici/lib/api/api-pipeline.js"(exports, module) {
18359
18359
  "use strict";
18360
18360
  var {
18361
- Readable: Readable3,
18361
+ Readable: Readable4,
18362
18362
  Duplex,
18363
18363
  PassThrough
18364
18364
  } = __require("node:stream");
@@ -18376,7 +18376,7 @@ var require_api_pipeline = __commonJS({
18376
18376
  }
18377
18377
  __name(noop2, "noop");
18378
18378
  var kResume = Symbol("resume");
18379
- var PipelineRequest = class extends Readable3 {
18379
+ var PipelineRequest = class extends Readable4 {
18380
18380
  static {
18381
18381
  __name(this, "PipelineRequest");
18382
18382
  }
@@ -18397,7 +18397,7 @@ var require_api_pipeline = __commonJS({
18397
18397
  callback(err);
18398
18398
  }
18399
18399
  };
18400
- var PipelineResponse = class extends Readable3 {
18400
+ var PipelineResponse = class extends Readable4 {
18401
18401
  static {
18402
18402
  __name(this, "PipelineResponse");
18403
18403
  }
@@ -18557,7 +18557,7 @@ var require_api_pipeline = __commonJS({
18557
18557
  util.destroy(ret, err);
18558
18558
  }
18559
18559
  };
18560
- function pipeline4(opts, handler) {
18560
+ function pipeline5(opts, handler) {
18561
18561
  try {
18562
18562
  const pipelineHandler = new PipelineHandler(opts, handler);
18563
18563
  const pipelineOpts = { ...opts, body: pipelineHandler.req };
@@ -18571,8 +18571,8 @@ var require_api_pipeline = __commonJS({
18571
18571
  return new PassThrough().destroy(err);
18572
18572
  }
18573
18573
  }
18574
- __name(pipeline4, "pipeline");
18575
- module.exports = pipeline4;
18574
+ __name(pipeline5, "pipeline");
18575
+ module.exports = pipeline5;
18576
18576
  }
18577
18577
  });
18578
18578
 
@@ -20315,7 +20315,7 @@ var require_snapshot_recorder = __commonJS({
20315
20315
  "node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
20316
20316
  "use strict";
20317
20317
  var { writeFile: writeFile2, readFile: readFile2, mkdir } = __require("node:fs/promises");
20318
- var { dirname: dirname16, resolve: resolve27 } = __require("node:path");
20318
+ var { dirname: dirname17, resolve: resolve27 } = __require("node:path");
20319
20319
  var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
20320
20320
  var { InvalidArgumentError: InvalidArgumentError2, UndiciError } = require_errors();
20321
20321
  var { setHeader } = require_util();
@@ -20571,7 +20571,7 @@ var require_snapshot_recorder = __commonJS({
20571
20571
  throw new InvalidArgumentError2("Snapshot path is required");
20572
20572
  }
20573
20573
  const resolvedPath = resolve27(path3);
20574
- await mkdir(dirname16(resolvedPath), { recursive: true });
20574
+ await mkdir(dirname17(resolvedPath), { recursive: true });
20575
20575
  const data2 = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
20576
20576
  hash,
20577
20577
  snapshot
@@ -24300,7 +24300,7 @@ var require_cache2 = __commonJS({
24300
24300
  "node_modules/undici/lib/interceptor/cache.js"(exports, module) {
24301
24301
  "use strict";
24302
24302
  var assert2 = __require("node:assert");
24303
- var { Readable: Readable3 } = __require("node:stream");
24303
+ var { Readable: Readable4 } = __require("node:stream");
24304
24304
  var util = require_util();
24305
24305
  var CacheHandler = require_cache_handler();
24306
24306
  var MemoryCacheStore = require_memory_cache_store();
@@ -24544,7 +24544,7 @@ var require_cache2 = __commonJS({
24544
24544
  }
24545
24545
  __name(handleUncachedResponse, "handleUncachedResponse");
24546
24546
  function sendCachedValue(handler, opts, result, age, context, isStale2) {
24547
- const stream = util.isStream(result.body) ? result.body : Readable3.from(result.body ?? []);
24547
+ const stream = util.isStream(result.body) ? result.body : Readable4.from(result.body ?? []);
24548
24548
  assert2(!stream.destroyed, "stream should not be destroyed");
24549
24549
  assert2(!stream.readableDidRead, "stream should not be readableDidRead");
24550
24550
  let aborted2 = false;
@@ -24854,7 +24854,7 @@ var require_decompress = __commonJS({
24854
24854
  "node_modules/undici/lib/interceptor/decompress.js"(exports, module) {
24855
24855
  "use strict";
24856
24856
  var { createInflate, createGunzip, createBrotliDecompress, createZstdDecompress, constants: constants3 } = __require("node:zlib");
24857
- var { pipeline: pipeline4, Transform: TransformStream2 } = __require("node:stream");
24857
+ var { pipeline: pipeline5, Transform: TransformStream2 } = __require("node:stream");
24858
24858
  var { InvalidArgumentError: InvalidArgumentError2, ResponseExceededMaxSizeError } = require_errors();
24859
24859
  var DecoratorHandler = require_decorator_handler();
24860
24860
  var DecompressController = class {
@@ -25173,7 +25173,7 @@ var require_decompress = __commonJS({
25173
25173
  #setupMultipleDecompressors() {
25174
25174
  const lastDecompressor = this.#decompressors[this.#decompressors.length - 1];
25175
25175
  this.#setupDecompressorEvents(lastDecompressor);
25176
- pipeline4(this.#decompressors, (err) => {
25176
+ pipeline5(this.#decompressors, (err) => {
25177
25177
  if (this.#terminated) {
25178
25178
  return;
25179
25179
  }
@@ -28118,7 +28118,7 @@ var require_fetch = __commonJS({
28118
28118
  subresourceSet
28119
28119
  } = require_constants2();
28120
28120
  var EE = __require("node:events");
28121
- var { Readable: Readable3, pipeline: pipeline4, finished, isErrored, isReadable } = __require("node:stream");
28121
+ var { Readable: Readable4, pipeline: pipeline5, finished, isErrored, isReadable } = __require("node:stream");
28122
28122
  var { addAbortListener, bufferToLowerCasedHeaderName } = require_util();
28123
28123
  var { SocketError, InformationalError } = require_errors();
28124
28124
  var { dataURLProcessor, serializeAMimeType, minimizeSupportedMimeType } = require_data_url();
@@ -29159,13 +29159,13 @@ var require_fetch = __commonJS({
29159
29159
  }
29160
29160
  }
29161
29161
  this.nullBodyStatus = nullBodyStatus.includes(status);
29162
- this.body = new Readable3({ read: /* @__PURE__ */ __name(() => controller.resume(), "read") });
29162
+ this.body = new Readable4({ read: /* @__PURE__ */ __name(() => controller.resume(), "read") });
29163
29163
  const onError = /* @__PURE__ */ __name((err) => this.onResponseError(controller, err), "onError");
29164
29164
  resolve27({
29165
29165
  status,
29166
29166
  statusText,
29167
29167
  headersList,
29168
- body: decoders.length ? pipeline4(this.body, ...decoders, (err) => {
29168
+ body: decoders.length ? pipeline5(this.body, ...decoders, (err) => {
29169
29169
  if (err) {
29170
29170
  this.onResponseError(controller, err);
29171
29171
  }
@@ -33230,7 +33230,7 @@ ${value}`;
33230
33230
  var require_eventsource = __commonJS({
33231
33231
  "node_modules/undici/lib/web/eventsource/eventsource.js"(exports, module) {
33232
33232
  "use strict";
33233
- var { pipeline: pipeline4 } = __require("node:stream");
33233
+ var { pipeline: pipeline5 } = __require("node:stream");
33234
33234
  var { fetching } = require_fetch();
33235
33235
  var { webidl } = require_webidl();
33236
33236
  var { EventSourceStream } = require_eventsource_stream();
@@ -33394,7 +33394,7 @@ var require_eventsource = __commonJS({
33394
33394
  ));
33395
33395
  }, "push")
33396
33396
  });
33397
- pipeline4(
33397
+ pipeline5(
33398
33398
  response.body.stream,
33399
33399
  eventSourceStream,
33400
33400
  (error3) => {
@@ -42934,7 +42934,7 @@ function nextActions(ctx) {
42934
42934
  }
42935
42935
  ];
42936
42936
  case "deploy": {
42937
- const test2 = { command: `${cliInvocation()} test`, why: "journeys, several users and access rules: your tests/*.mjs" };
42937
+ const test2 = { command: `${cliInvocation()} test`, why: "runs your checks/*.json check lists as test users, plus the platform checks" };
42938
42938
  if (ctx.temporary)
42939
42939
  return ctx.liveUrl ? [seeItByUrl(ctx.liveUrl)] : [];
42940
42940
  if (ctx.projectLinked)
@@ -44271,18 +44271,28 @@ Use \`client.intake\` for public submissions to a private parent row. See
44271
44271
 
44272
44272
  ### Run and verify
44273
44273
 
44274
- On a test app, run \`somewhere test-users prepare <name>\`. Pass multiple
44275
- names in the same command to prepare several actors. Use
44276
- \`somewhere data list <table> --as <name>\` and
44277
- \`somewhere data create <table> --as <name> --values '<json>'\` to check
44278
- the table's client access. Run \`somewhere cron run <name> --wait\` for a
44279
- schedule, \`somewhere db rows <table>\` to inspect the stored rows, and
44280
- \`somewhere errors\` to see recent failures. Finish with
44281
- \`somewhere test-users cleanup\`.
44274
+ Prove the brief with a check list in \`checks/<name>.json\` and run \`somewhere test\`. The platform makes the named users itself (no sign-up form, browser or contract digest), runs each step on the live app as that user, prints PASS or FAIL per step with the expected and actual answer and the request ID, then deletes the users and the rows it can prove it created, naming anything it leaves. The list reruns after every deploy if it only reads, or if it sets \`"rerun_after_deploy": true\`.
44275
+
44276
+ \`\`\`json
44277
+ {
44278
+ "users": ["owner", "member", { "name": "carol", "roles": ["staff"] }],
44279
+ "steps": [
44280
+ { "as": "owner", "post": "/api/teams", "body": { "name": "T" }, "expect": 201, "save": { "team": "id" } },
44281
+ { "as": "owner", "post": "/api/teams/{team}/members", "body": { "email": "{member.email}" } },
44282
+ { "as": "member", "data": { "table": "tasks", "operation": "create", "values": { "team_id": "{team}", "title": "x" } }, "save": { "task": "id" } },
44283
+ { "as": "carol", "delete": "/api/tasks/{task}", "expect": [403, 404] },
44284
+ { "as": "signed_out", "get": "/api/teams/{team}/tasks", "expect": 401, "lacks": "{member.email}" },
44285
+ { "run": "daily-summary" }
44286
+ ],
44287
+ "cleanup": [{ "as": "owner", "delete": "/api/teams/{team}" }]
44288
+ }
44289
+ \`\`\`
44282
44290
 
44283
- Run \`somewhere typecheck\` and focused tests. \`somewhere deploy-check\` checks compilation and schema without publishing. \`somewhere deploy\` uploads raw source directly to production. When testing changes with real users or data, use \`somewhere preview\`, test with \`somewhere test --preview\`, then promote. See \`somewhere docs dev-environments\`.
44291
+ - A step is \`as\` (a name from \`users\`, or \`signed_out\`) and one of: \`get\`, \`post\`, \`put\`, \`patch\` or \`delete\` with a path (and \`body\`); \`data\` with the data endpoint's request (\`table\`, \`operation\`, \`values\`, \`id\`, \`where\`); or \`run\` with a schedule name, which runs it now and waits for its job.
44292
+ - \`expect\` is a status or a list of them (default: any 2xx). \`has\` and \`lacks\` take text; \`has_fields\` and \`lacks_fields\` take JSON field names. \`save\` keeps a field of the answer (of the row, for \`data\`) as \`{name}\` for later steps. \`wait: 10\` retries the step for up to 10 seconds.
44293
+ - \`{alice.email}\` and \`{alice.id}\` are each user's address and ID. \`roles\` gives roles your schema declares \`assignedBy: 'server'\`. Up to 6 users and 60 steps per list. \`cleanup\` steps run last, even after a failure. \`wait\` retries only reads. A failing step's output from a run you start can show data from the app; stored results keep only the step, status, request ID and failed expectation.
44284
44294
 
44285
- Save journeys in \`checks/<name>.json\`, using \`checks/add-a-note.json\` from the notes starter as a model. Keep test IDs when restyling and click the item a person would use. Set \`"signed_in": true\` for a test user and \`"viewports": ["desktop", "mobile"]\` to check both sizes. Saved checks run after deploy. Use \`somewhere test\` to rerun them and \`somewhere verify --flow flow.json\` for a focused journey. For shared access, test the owner, a recipient and an unrelated user separately. The team fixture is in \`somewhere docs sw.groups --section team-example\`. For schedules, trigger \`somewhere cron run <id> --wait\` before asserting its effects. Inspect failures with \`somewhere errors\` and \`somewhere logs\`.
44295
+ Run \`somewhere typecheck\` before deploying. \`somewhere deploy-check\` checks compilation and schema without publishing. \`somewhere deploy\` uploads raw source directly to production. When testing changes with real users or data, use \`somewhere preview\`, test with \`somewhere test --preview\`, then promote. See \`somewhere docs dev-environments\`. Inspect failures with \`somewhere errors\` and \`somewhere logs\`. For a check that needs a rendered page, save a browser flow with \`actions\` in \`checks/<name>.json\`, using \`checks/add-a-note.json\` from the notes starter as a model. Keep test IDs when restyling. See \`somewhere docs test\`.
44286
44296
 
44287
44297
  Use \`somewhere docs <topic> --section <id>\` for one section or \`--full\` for all examples. Ask before destructive or paid actions unless the user already authorized them.
44288
44298
  `;
@@ -44322,7 +44332,7 @@ ${PREVIEW_POINTER}
44322
44332
  function starterChecks(options2 = {}) {
44323
44333
  return options2.privateData ? [{ path: "checks/add-a-note.json", content: JSON.stringify(ADD_A_NOTE, null, 2) + "\n" }] : [];
44324
44334
  }
44325
- var ADD_A_NOTE, STARTER_AUTH_TEST;
44335
+ var ADD_A_NOTE, STARTER_CHECK_LIST, STARTER_AUTH_TEST;
44326
44336
  var init_init_test_template = __esm({
44327
44337
  "dist/lib/init-test-template.js"() {
44328
44338
  "use strict";
@@ -44336,6 +44346,17 @@ var init_init_test_template = __esm({
44336
44346
  signed_in: true
44337
44347
  };
44338
44348
  __name(starterChecks, "starterChecks");
44349
+ STARTER_CHECK_LIST = {
44350
+ path: "checks/signed-in.json",
44351
+ content: `{
44352
+ "users": ["ana"],
44353
+ "steps": [
44354
+ { "as": "ana", "get": "/api/auth/me", "has": "{ana.email}" },
44355
+ { "as": "signed_out", "get": "/api/auth/me", "lacks": "{ana.email}" }
44356
+ ]
44357
+ }
44358
+ `
44359
+ };
44339
44360
  STARTER_AUTH_TEST = {
44340
44361
  path: "tests/starter.mjs",
44341
44362
  content: `import assert from 'node:assert/strict';
@@ -44488,6 +44509,7 @@ declare module '*.${ext}' {
44488
44509
  function createGreenTemplate(appName = "somewhere-starter") {
44489
44510
  return [
44490
44511
  { path: ".gitignore", content: buildScaffoldGitignore() },
44512
+ STARTER_CHECK_LIST,
44491
44513
  STARTER_AUTH_TEST,
44492
44514
  { path: "AGENTS.md", content: INIT_AGENTS_MD },
44493
44515
  { path: "CLAUDE.md", content: INIT_CLAUDE_MD },
@@ -48737,6 +48759,7 @@ function createFeatureTemplate(selection, options2) {
48737
48759
  const files = [
48738
48760
  ...starterChecks({ privateData }),
48739
48761
  { path: ".gitignore", content: buildScaffoldGitignore() },
48762
+ STARTER_CHECK_LIST,
48740
48763
  STARTER_AUTH_TEST,
48741
48764
  { path: "AGENTS.md", content: INIT_AGENTS_MD },
48742
48765
  { path: "CLAUDE.md", content: INIT_CLAUDE_MD },
@@ -74903,7 +74926,7 @@ function runTypecheck(projectDir, options2 = {}) {
74903
74926
  ensureDeclaredTypePackages(projectDir, options2.installTypePackages);
74904
74927
  }
74905
74928
  const { command, args, via } = resolveTsc(projectDir);
74906
- return runTypecheckWith(projectDir, command, args, via, declaredData).then(withContract);
74929
+ return runTypecheckWith(projectDir, command, args, via, declaredData, options2.deploy === true).then(withContract);
74907
74930
  }
74908
74931
  function announceNpxTypeScriptFetch(version2) {
74909
74932
  process.stderr.write(`TypeScript is not installed in this project; fetching typescript@${version2} with npx (needs the npm registry; npm keeps it in its cache). Nothing is installed into the project. To skip this fetch on every check: npm install -D typescript@${version2}
@@ -74912,10 +74935,13 @@ function announceNpxTypeScriptFetch(version2) {
74912
74935
  function typecheckCompilerSource(projectDir) {
74913
74936
  return resolveTsc(projectDir).via;
74914
74937
  }
74915
- async function runTypecheckWith(projectDir, command, args, via, declaredData) {
74938
+ async function runTypecheckWith(projectDir, command, args, via, declaredData, deploy) {
74916
74939
  const fullArgs = typecheckArgs(args);
74917
74940
  let overlay;
74918
- if (declaredData) {
74941
+ const foreignDirectories = deploy ? ["supabase/functions/", "netlify/functions/", ".netlify/functions/", ".vercel/"].filter((path3) => existsSync12(join13(projectDir, path3))) : [];
74942
+ const viteClient = "node_modules/vite/client.d.ts";
74943
+ const viteTypes = deploy && existsSync12(join13(projectDir, viteClient)) ? [viteClient] : [];
74944
+ if (declaredData || foreignDirectories.length || viteTypes.length) {
74919
74945
  const config2 = await runBounded(command, [...args, "--project", SCAFFOLD_TSCONFIG_FILENAME, "--showConfig"], projectDir);
74920
74946
  if (config2.timedOut)
74921
74947
  return { ok: false, errors: [], via, raw: config2.out, spawnError: timedOutMessage(via, config2) };
@@ -74937,10 +74963,11 @@ async function runTypecheckWith(projectDir, command, args, via, declaredData) {
74937
74963
  writeFileSync10(overlay, JSON.stringify({
74938
74964
  extends: "./" + SCAFFOLD_TSCONFIG_FILENAME,
74939
74965
  files: [.../* @__PURE__ */ new Set([
74940
- ...parsed.files,
74941
- relative3(projectDir, declaredData.declarationPath),
74942
- ...declaredData.filesDeclarationPath ? [relative3(projectDir, declaredData.filesDeclarationPath)] : [],
74943
- ...declaredData.schemaPath ? [relative3(projectDir, declaredData.schemaPath)] : []
74966
+ ...parsed.files.filter((file) => !foreignDirectories.some((dir) => file.replaceAll("\\", "/").replace(/^\.\//, "").startsWith(dir))),
74967
+ ...viteTypes,
74968
+ ...declaredData ? [relative3(projectDir, declaredData.declarationPath)] : [],
74969
+ ...declaredData?.filesDeclarationPath ? [relative3(projectDir, declaredData.filesDeclarationPath)] : [],
74970
+ ...declaredData?.schemaPath ? [relative3(projectDir, declaredData.schemaPath)] : []
74944
74971
  ])],
74945
74972
  include: [],
74946
74973
  exclude: []
@@ -75190,10 +75217,10 @@ var init_esm3 = __esm({
75190
75217
  }
75191
75218
  async _formatEntry(dirent, path3) {
75192
75219
  let entry;
75193
- const basename11 = this._isDirent ? dirent.name : dirent;
75220
+ const basename12 = this._isDirent ? dirent.name : dirent;
75194
75221
  try {
75195
- const fullPath = presolve(pjoin(path3, basename11));
75196
- entry = { path: prelative(this._root, fullPath), fullPath, basename: basename11 };
75222
+ const fullPath = presolve(pjoin(path3, basename12));
75223
+ entry = { path: prelative(this._root, fullPath), fullPath, basename: basename12 };
75197
75224
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
75198
75225
  } catch (err) {
75199
75226
  this._onError(err);
@@ -75726,9 +75753,9 @@ var init_handler = __esm({
75726
75753
  _watchWithNodeFs(path3, listener) {
75727
75754
  const opts = this.fsw.options;
75728
75755
  const directory2 = sysPath.dirname(path3);
75729
- const basename11 = sysPath.basename(path3);
75756
+ const basename12 = sysPath.basename(path3);
75730
75757
  const parent = this.fsw._getWatchedDir(directory2);
75731
- parent.add(basename11);
75758
+ parent.add(basename12);
75732
75759
  const absolutePath = sysPath.resolve(path3);
75733
75760
  const options2 = {
75734
75761
  persistent: opts.persistent
@@ -75738,7 +75765,7 @@ var init_handler = __esm({
75738
75765
  let closer;
75739
75766
  if (opts.usePolling) {
75740
75767
  const enableBin = opts.interval !== opts.binaryInterval;
75741
- options2.interval = enableBin && isBinaryPath(basename11) ? opts.binaryInterval : opts.interval;
75768
+ options2.interval = enableBin && isBinaryPath(basename12) ? opts.binaryInterval : opts.interval;
75742
75769
  closer = setFsWatchFileListener(path3, absolutePath, options2, {
75743
75770
  listener,
75744
75771
  rawEmitter: this.fsw._emitRaw
@@ -75760,11 +75787,11 @@ var init_handler = __esm({
75760
75787
  if (this.fsw.closed) {
75761
75788
  return;
75762
75789
  }
75763
- const dirname16 = sysPath.dirname(file);
75764
- const basename11 = sysPath.basename(file);
75765
- const parent = this.fsw._getWatchedDir(dirname16);
75790
+ const dirname17 = sysPath.dirname(file);
75791
+ const basename12 = sysPath.basename(file);
75792
+ const parent = this.fsw._getWatchedDir(dirname17);
75766
75793
  let prevStats = stats;
75767
- if (parent.has(basename11))
75794
+ if (parent.has(basename12))
75768
75795
  return;
75769
75796
  const listener = /* @__PURE__ */ __name(async (path3, newStats) => {
75770
75797
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
@@ -75789,9 +75816,9 @@ var init_handler = __esm({
75789
75816
  prevStats = newStats2;
75790
75817
  }
75791
75818
  } catch (error3) {
75792
- this.fsw._remove(dirname16, basename11);
75819
+ this.fsw._remove(dirname17, basename12);
75793
75820
  }
75794
- } else if (parent.has(basename11)) {
75821
+ } else if (parent.has(basename12)) {
75795
75822
  const at2 = newStats.atimeMs;
75796
75823
  const mt2 = newStats.mtimeMs;
75797
75824
  if (!at2 || at2 <= mt2 || mt2 !== prevStats.mtimeMs) {
@@ -78256,7 +78283,7 @@ async function runChecksNow(client, projectId, opts = {}) {
78256
78283
  if (!opts.again && opts.only === void 0) {
78257
78284
  const read = `GET /v1/deploy/log?project_id=${encodeURIComponent(projectId)}`;
78258
78285
  const stored = await awaitDeployChecks(client, { read }, { ...opts, readStored: true });
78259
- if (stored)
78286
+ if (stored && !stored.not_checked?.lists_not_rerun?.length)
78260
78287
  return stored;
78261
78288
  }
78262
78289
  let firstDelayMs = 0;
@@ -78396,7 +78423,7 @@ function formatChecksReport(check) {
78396
78423
  } else {
78397
78424
  lines.push("Coverage details are unavailable for this run.");
78398
78425
  }
78399
- lines.push("For your own app tests, use @somewhere-cloud/cli/testing. See somewhere docs test.");
78426
+ lines.push("Prove the brief with a check list in checks/<name>.json (users and steps). See somewhere docs test.");
78400
78427
  return [...lines, JSON.stringify({
78401
78428
  ...summary,
78402
78429
  not_checked: coverage,
@@ -84103,7 +84130,7 @@ var init_verify = __esm({
84103
84130
  });
84104
84131
 
84105
84132
  // dist/commands/deploy.js
84106
- import { existsSync as existsSync29 } from "node:fs";
84133
+ import { existsSync as existsSync29, readFileSync as readFileSync30 } from "node:fs";
84107
84134
  import { join as join34 } from "node:path";
84108
84135
  import { basename as basename5, resolve as resolve16 } from "node:path";
84109
84136
  function resolveTargetDir(dir, cwd = process.cwd()) {
@@ -84351,16 +84378,16 @@ function formatLinkedProjectMismatchExplanation(linkedProjectId, ref, resolvedPr
84351
84378
  "Next steps:",
84352
84379
  ` Deploy this folder to its linked project: run \`${cliInvocation()} deploy\` (no --project).`,
84353
84380
  ` Work on ${ref}: run \`${cliInvocation()} pull ${shellQuote(ref)} --out <fresh-folder>\`, re-apply your changes there, then run \`${cliInvocation()} deploy\`.`,
84354
- ` Deploy a copy elsewhere: copy the files into an unlinked folder and run \`${cliInvocation()} deploy --project ${ref}\` there.`
84381
+ ` Replace ${ref} with these files on purpose: copy them into an unlinked folder and run \`${cliInvocation()} deploy --project ${ref} --force --yes\` there.`
84355
84382
  ].join("\n");
84356
84383
  }
84357
84384
  function formatExplicitProjectBaseRequiredExplanation(ref) {
84358
84385
  return [
84359
- `The live version of project ${ref} could not be read before deploying, and this folder has no record of which published version its files came from, so the deploy was NOT applied.`,
84386
+ `Project ${ref} is already live, and this folder has no record of deploying or pulling it, so the deploy was NOT applied. The live app is unchanged.`,
84360
84387
  "",
84361
84388
  "Next steps:",
84362
- ` Start with \`${cliInvocation()} pull ${shellQuote(ref)} --out <fresh-folder>\`, re-apply your changes there, then run \`${cliInvocation()} deploy\`.`,
84363
- ` Or replace the live release deliberately: \`${cliInvocation()} deploy --project ${ref} --force --yes\`.`
84389
+ ` To change the live app, start from its current files: \`${cliInvocation()} pull ${shellQuote(ref)} --out <fresh-folder>\`, re-apply your changes there, then run \`${cliInvocation()} deploy\`.`,
84390
+ ` To replace the live app with this folder's files on purpose: \`${cliInvocation()} deploy --project ${ref} --force --yes\`.`
84364
84391
  ].join("\n");
84365
84392
  }
84366
84393
  function startDeployPrestart(client, projectId) {
@@ -84529,7 +84556,7 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
84529
84556
  process.stderr.write(`Still checking types before upload after ${formatDeployElapsed(performance.now() - typecheckStartedAt)}...
84530
84557
  `);
84531
84558
  }, deployHeartbeatMs()).unref() : void 0;
84532
- const typecheck = checkingTypes ? runTypecheck(targetDir).then((value) => ({ value }), (error3) => ({ error: error3 })).finally(() => {
84559
+ const typecheck = checkingTypes ? runTypecheck(targetDir, { deploy: true }).then((value) => ({ value }), (error3) => ({ error: error3 })).finally(() => {
84533
84560
  clearInterval(typecheckHeartbeat);
84534
84561
  typecheckMs = performance.now() - typecheckStartedAt;
84535
84562
  }) : Promise.resolve(null);
@@ -84868,8 +84895,10 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
84868
84895
  // Sending the on-disk static under scope:functions is what bricked
84869
84896
  // compiled SPAs; the worker now ignores it too, but
84870
84897
  // the CLI shouldn't send it in the first place. --scope static is the
84871
- // inverse: no functions.
84872
- files: scope === "functions" ? {} : files
84898
+ // inverse: no functions. The dependency manifest is the functions'
84899
+ // too: a backend change that adds a package sends package.json (and
84900
+ // its lockfile), so the platform builds against the new dependencies.
84901
+ files: scope === "functions" ? functionDependencyManifest(files) : files
84873
84902
  };
84874
84903
  if (scope !== "functions" && Object.keys(binaryFiles).length > 0) {
84875
84904
  body.binary_files = binaryFiles;
@@ -84897,8 +84926,8 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
84897
84926
  body.base_release_id = sourceBase.releaseId;
84898
84927
  } else if (!opts.force && explicitProjectId) {
84899
84928
  const liveBase = earlyLiveBase?.projectId === explicitProjectId ? await earlyLiveBase.read : await readExplicitProjectLiveBase(client, explicitProjectId);
84900
- if (liveBase !== void 0)
84901
- body.base_release_id = liveBase;
84929
+ if (liveBase === null)
84930
+ body.base_release_id = null;
84902
84931
  }
84903
84932
  body.source = "cli";
84904
84933
  if (opts.force)
@@ -84977,6 +85006,8 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
84977
85006
  saveProjectAppUrl(deployStateEntry.dir, deployStateEntry.config.project_id, httpsOrigin(result.url));
84978
85007
  }
84979
85008
  }
85009
+ result.warnings = result.warnings?.map((warning) => withLocalEnvHint(warning, targetDir));
85010
+ result.build_log = result.build_log?.map((line) => line.startsWith("warning: ") ? `warning: ${withLocalEnvHint(line.slice("warning: ".length), targetDir)}` : line);
84980
85011
  const formatted = formatDeploySuccess(result, {
84981
85012
  scope,
84982
85013
  functionCount: countFunctionRoutes(functions),
@@ -85118,7 +85149,7 @@ ${dim("Build")}`);
85118
85149
  }
85119
85150
  }
85120
85151
  if (!tempSession) {
85121
- if (formatted.liveUrl) {
85152
+ if (formatted.liveUrl && !result.warnings?.some(missingSetting)) {
85122
85153
  success(`Live at ${teal(formatted.liveUrl)}`);
85123
85154
  } else {
85124
85155
  success(formatted.liveMessage);
@@ -85368,15 +85399,32 @@ function formatDeploySuccess(result, options2) {
85368
85399
  const linkedSubdomain = typeof options2.linkedProject?.subdomain === "string" ? options2.linkedProject.subdomain.trim() : "";
85369
85400
  const subdomain = result.project_id && result.project_id === options2.linkedProject?.project_id && linkedSubdomain ? linkedSubdomain : null;
85370
85401
  const liveUrl = responseUrl ?? (subdomain && /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(subdomain) ? `https://${subdomain}.${PROJECT_SITE_DOMAIN2}` : null);
85402
+ const missing = result.warnings?.filter(missingSetting).length ?? 0;
85371
85403
  return {
85372
85404
  staticFileCount,
85373
85405
  headline,
85374
85406
  projectRef: typeof result.project_id === "string" && result.project_id.trim() ? result.project_id.trim() : null,
85375
85407
  liveUrl,
85376
85408
  // Only an older platform omits the URL; name the command that shows it.
85377
- liveMessage: liveUrl ? `Live at ${liveUrl}` : `Deployed. The platform did not report the live URL; \`${cliInvocation()} project view ${typeof result.project_id === "string" && result.project_id.trim() ? result.project_id.trim() : "<project>"}\` shows it.`
85409
+ liveMessage: missing ? `Live, but ${missing} ${missing === 1 ? "setting is" : "settings are"} missing${liveUrl ? ` (${liveUrl})` : ""}` : liveUrl ? `Live at ${liveUrl}` : `Deployed. The platform did not report the live URL; \`${cliInvocation()} project view ${typeof result.project_id === "string" && result.project_id.trim() ? result.project_id.trim() : "<project>"}\` shows it.`
85378
85410
  };
85379
85411
  }
85412
+ function missingSetting(warning) {
85413
+ return /^Missing (?:public|server) setting ([A-Za-z_][A-Za-z0-9_]*)\./.exec(warning)?.[1];
85414
+ }
85415
+ function withLocalEnvHint(warning, dir) {
85416
+ const key = missingSetting(warning);
85417
+ if (!key)
85418
+ return warning;
85419
+ try {
85420
+ const source = readFileSync30(join34(dir, ".env"), "utf8");
85421
+ if (new RegExp(`^\\s*(?:export\\s+)?${key}\\s*=`, "m").test(source)) {
85422
+ return `${warning} Copy ${key} from your local .env file.`;
85423
+ }
85424
+ } catch {
85425
+ }
85426
+ return warning;
85427
+ }
85380
85428
  function normalizeWarning(value) {
85381
85429
  return value.replace(/^warning:\s*/i, "").trim();
85382
85430
  }
@@ -85579,6 +85627,9 @@ function formatDryRunNeedsProjectExplanation() {
85579
85627
  `To deploy for real (signed out, this starts a temporary workspace): \`${cliInvocation()} deploy\`.`
85580
85628
  ].join("\n");
85581
85629
  }
85630
+ function functionDependencyManifest(files) {
85631
+ return Object.fromEntries(["package.json", "package-lock.json", "npm-shrinkwrap.json"].filter((path3) => typeof files[path3] === "string").map((path3) => [path3, files[path3]]));
85632
+ }
85582
85633
  function printDryRun(plan, scope) {
85583
85634
  const scopeNote = scope === "functions" ? " (scope: functions \u2014 static unchanged)" : scope === "static" ? " (scope: static \u2014 functions unchanged)" : "";
85584
85635
  console.log(`
@@ -85734,6 +85785,8 @@ var init_deploy = __esm({
85734
85785
  PROJECT_SITE_DOMAIN2 = "somewhere.site";
85735
85786
  __name(linkedProjectWithSubdomain, "linkedProjectWithSubdomain");
85736
85787
  __name(formatDeploySuccess, "formatDeploySuccess");
85788
+ __name(missingSetting, "missingSetting");
85789
+ __name(withLocalEnvHint, "withLocalEnvHint");
85737
85790
  __name(normalizeWarning, "normalizeWarning");
85738
85791
  __name(warningsInBuildLog, "warningsInBuildLog");
85739
85792
  retriedAfterTransportFailure = /* @__PURE__ */ new WeakMap();
@@ -85754,6 +85807,7 @@ var init_deploy = __esm({
85754
85807
  __name(printLocalOmissionsToStderr, "printLocalOmissionsToStderr");
85755
85808
  __name(printSensitiveFiles, "printSensitiveFiles");
85756
85809
  __name(formatDryRunNeedsProjectExplanation, "formatDryRunNeedsProjectExplanation");
85810
+ __name(functionDependencyManifest, "functionDependencyManifest");
85757
85811
  __name(printDryRun, "printDryRun");
85758
85812
  }
85759
85813
  });
@@ -85842,7 +85896,7 @@ var init_deploys = __esm({
85842
85896
  });
85843
85897
 
85844
85898
  // dist/commands/pull.js
85845
- import { existsSync as existsSync30, lstatSync as lstatSync4, mkdirSync as mkdirSync15, readFileSync as readFileSync30, readdirSync as readdirSync7, rmSync as rmSync12, writeFileSync as writeFileSync19 } from "node:fs";
85899
+ import { existsSync as existsSync30, lstatSync as lstatSync4, mkdirSync as mkdirSync15, readFileSync as readFileSync31, readdirSync as readdirSync7, rmSync as rmSync12, writeFileSync as writeFileSync19 } from "node:fs";
85846
85900
  import { basename as basename6, dirname as dirname12, join as join35, relative as relative10, resolve as resolve17 } from "node:path";
85847
85901
  function registerPull(program2) {
85848
85902
  program2.command("pull [project]").description(`Download a project's deployed source files to the current directory. Scaffolds a tsconfig.json + package.json (only if absent) so \`${cliInvocation()} typecheck\` can catch undefined symbols locally before you deploy. In a linked folder, plain pull is the safe update when live is newer: files you have not edited move to the live version, your local edits and local-only files (AGENTS.md, notes, tests) are kept, and it stops without writing anything if a file changed both here and live.`).option("--env <env>", "Environment to pull from (dev or prod)", "prod").option("--out <dir>", "Output directory", ".").option("--force", "Also replace files you edited here with live, and delete published files you edited that live no longer has. Never deletes a file a deploy would not upload (AGENTS.md, CLAUDE.md, README.md, tests, dotfiles, .somewhereignore matches)").option("--json", "Print the raw source response as JSON").action(async (projectArg, opts) => {
@@ -85927,7 +85981,7 @@ function registerPull(program2) {
85927
85981
  const target = join35(outDir, path3);
85928
85982
  if (!existsSync30(target))
85929
85983
  continue;
85930
- const local = readFileSync30(target);
85984
+ const local = readFileSync31(target);
85931
85985
  if (local.equals(contents))
85932
85986
  continue;
85933
85987
  if (opts.force) {
@@ -86061,7 +86115,7 @@ function reconcileRemovedFiles(outDir, expected, force, base = null) {
86061
86115
  const was = base?.files[relPath];
86062
86116
  if (base && was === void 0)
86063
86117
  continue;
86064
- const unedited = was !== void 0 && was === sha2562(readFileSync30(fullPath));
86118
+ const unedited = was !== void 0 && was === sha2562(readFileSync31(fullPath));
86065
86119
  if (!force && !unedited) {
86066
86120
  skipped.push(relPath);
86067
86121
  continue;
@@ -86861,7 +86915,62 @@ var init_db_rows = __esm({
86861
86915
  });
86862
86916
 
86863
86917
  // dist/commands/db.js
86864
- import { writeFileSync as writeFileSync20 } from "node:fs";
86918
+ import { createWriteStream as createWriteStream2, writeFileSync as writeFileSync20 } from "node:fs";
86919
+ import { rename, unlink } from "node:fs/promises";
86920
+ import { randomUUID as randomUUID7 } from "node:crypto";
86921
+ import { basename as basename7, dirname as dirname13, join as join36 } from "node:path";
86922
+ import { Readable as Readable2 } from "node:stream";
86923
+ import { pipeline as pipeline2 } from "node:stream/promises";
86924
+ async function backgroundExport(client, projectId, plane, output, json, spinner) {
86925
+ if (json && !output)
86926
+ throw new Error("This database is exported in the background as a file: pass --output <file> with --json.");
86927
+ const wanted = plane ?? "raw";
86928
+ if (spinner)
86929
+ spinner.text = "The database is larger than one dump response; exporting it in the background\u2026";
86930
+ let current;
86931
+ try {
86932
+ current = (await client.call("POST", "/db/exports", { project_id: projectId, ...plane ? { plane } : {} })).export;
86933
+ } catch (err) {
86934
+ if (err instanceof CliApiError && err.statusCode === 404 && err.code === "NOT_FOUND")
86935
+ return false;
86936
+ throw err;
86937
+ }
86938
+ while (current.state === "running") {
86939
+ await new Promise((resolve27) => setTimeout(resolve27, 3e3));
86940
+ current = (await client.call("GET", `/db/exports/${encodeURIComponent(current.id)}`, void 0, { project_id: projectId })).export;
86941
+ if (spinner)
86942
+ spinner.text = `Exporting in the background: ${current.rows.toLocaleString()} rows, ${sizeText(current.size_bytes)} so far\u2026`;
86943
+ }
86944
+ if (current.state !== "ready")
86945
+ throw new Error(current.detail ?? `The export ended ${current.state}.`);
86946
+ if ((current.plane ?? "raw") !== wanted)
86947
+ throw new Error(`The platform returned an export of the ${current.plane} tables, not the ${wanted} ones. Nothing was written.`);
86948
+ const response = await client.callStream("GET", `/db/exports/${encodeURIComponent(current.id)}/sql?project_id=${encodeURIComponent(projectId)}`, void 0, { timeoutMs: 4 * 60 * 6e4 });
86949
+ if (!response.ok || !response.body)
86950
+ throw new Error(`Downloading the export failed (HTTP ${response.status}).`);
86951
+ const body = Readable2.fromWeb(response.body);
86952
+ if (output) {
86953
+ const temp = join36(dirname13(output), `.${basename7(output)}.${randomUUID7()}.tmp`);
86954
+ try {
86955
+ await pipeline2(body, createWriteStream2(temp, { flags: "wx", mode: 384 }));
86956
+ await rename(temp, output);
86957
+ } catch (err) {
86958
+ await unlink(temp).catch(() => void 0);
86959
+ throw err;
86960
+ }
86961
+ } else {
86962
+ spinner?.stop();
86963
+ await pipeline2(body, process.stdout, { end: false });
86964
+ }
86965
+ const summary = `${current.tables} tables, ${current.rows} rows, ${sizeText(current.size_bytes)}${current.consistency ? `. ${current.consistency}` : ""}`;
86966
+ if (json)
86967
+ printJson({ export: current, output });
86968
+ else if (output)
86969
+ spinner?.succeed(`Wrote ${output} (${summary})`);
86970
+ else
86971
+ process.stderr.write(dim(summary) + "\n");
86972
+ return true;
86973
+ }
86865
86974
  function registerDb(program2) {
86866
86975
  const db = program2.command("db").description("Inspect managed production rows or run SQL against your raw database");
86867
86976
  registerDbRows(db);
@@ -86952,6 +87061,16 @@ function registerDb(program2) {
86952
87061
  ...opts.plane ? { plane: opts.plane } : {}
86953
87062
  });
86954
87063
  if (!res.ok) {
87064
+ let refused = null;
87065
+ try {
87066
+ refused = JSON.parse(res.body);
87067
+ } catch {
87068
+ refused = null;
87069
+ }
87070
+ if (res.status === 413 && refused?.data?.background_export === true && !opts.manifest && ["DUMP_SIZE_LIMIT_EXCEEDED", "DUMP_ROW_LIMIT_EXCEEDED", "EXPORT_SIZE_LIMIT_EXCEEDED", "EXPORT_ROW_LIMIT_EXCEEDED"].includes(refused.error ?? "")) {
87071
+ if (await backgroundExport(client, projectId, opts.plane, opts.output, Boolean(opts.json), spinner))
87072
+ return;
87073
+ }
86955
87074
  spinner?.fail("Dump failed");
86956
87075
  try {
86957
87076
  const json = JSON.parse(res.body);
@@ -86973,7 +87092,7 @@ function registerDb(program2) {
86973
87092
  process.exit(1);
86974
87093
  }
86975
87094
  if (opts.output)
86976
- writeFileSync20(opts.output, res.body);
87095
+ writeFileSync20(opts.output, res.body, { mode: 384 });
86977
87096
  else
86978
87097
  process.stdout.write(res.body + "\n");
86979
87098
  return;
@@ -86994,7 +87113,7 @@ function registerDb(program2) {
86994
87113
  truncated_tables: truncated ?? null
86995
87114
  };
86996
87115
  if (opts.output) {
86997
- writeFileSync20(opts.output, sql);
87116
+ writeFileSync20(opts.output, sql, { mode: 384 });
86998
87117
  if (opts.json) {
86999
87118
  printJson(dumpResult);
87000
87119
  } else {
@@ -87018,6 +87137,81 @@ function registerDb(program2) {
87018
87137
  process.exit(1);
87019
87138
  }
87020
87139
  });
87140
+ db.command("restore-points").description("List the restore points the platform keeps: full copies of the database taken before each deploy that changes its shape, daily when the data changed, and by hand (project owner only)").option("--project <id>", "Project ID (defaults to .somewhere.json)").option("--take", "Take a restore point now").option("--delete <id>", "Delete one restore point now").option("--json", "Print the API response as JSON").action(async (opts) => {
87141
+ if (opts.take && opts.delete) {
87142
+ error("Use --take or --delete, not both.");
87143
+ process.exit(1);
87144
+ }
87145
+ let projectId = opts.project;
87146
+ if (!projectId) {
87147
+ const config2 = loadProjectConfig();
87148
+ if (!config2) {
87149
+ error("No project specified and no .somewhere.json found. Pass --project <id>." + unlinkedFolderHint());
87150
+ process.exit(1);
87151
+ }
87152
+ projectId = config2.project_id;
87153
+ }
87154
+ const size = /* @__PURE__ */ __name((n) => n >= 1e6 ? `${(n / 1e6).toFixed(1)} MB` : `${Math.max(1, Math.round(n / 1e3))} KB`, "size");
87155
+ const client = new ApiClient(getToken());
87156
+ try {
87157
+ if (opts.take) {
87158
+ const spinner = opts.json ? null : ora("Taking a restore point\u2026").start();
87159
+ let point = (await client.call("POST", "/db/restore-points", { project_id: projectId })).restore_point;
87160
+ for (let waited = 0; point.state === "running" && waited < 30 * 6e4; waited += 3e3) {
87161
+ await new Promise((resolve27) => setTimeout(resolve27, 3e3));
87162
+ const listed = await client.call("GET", "/db/restore-points", void 0, { project_id: projectId });
87163
+ point = listed.restore_points.find((p2) => p2.id === point.id) ?? { ...point, state: "failed", detail: "It is no longer listed." };
87164
+ if (spinner)
87165
+ spinner.text = `Taking a restore point\u2026 ${point.rows.toLocaleString()} rows so far`;
87166
+ }
87167
+ if (opts.json) {
87168
+ printJson({ restore_point: point });
87169
+ if (point.state !== "ready")
87170
+ process.exitCode = 1;
87171
+ return;
87172
+ }
87173
+ if (point.state === "running") {
87174
+ spinner?.succeed(`Restore point ${point.id} is still being taken; \`${cliInvocation()} db restore-points\` shows when it is ready.`);
87175
+ return;
87176
+ }
87177
+ if (point.state !== "ready") {
87178
+ spinner?.fail(`No restore point was taken: ${point.detail ?? point.state}`);
87179
+ process.exitCode = 1;
87180
+ return;
87181
+ }
87182
+ spinner?.succeed(`Restore point ${point.id} taken (${size(point.size_bytes)}, ${point.tables} tables, ${point.rows} rows); kept until ${point.expires_at}.`);
87183
+ for (const line of [point.consistency, point.validation])
87184
+ if (line)
87185
+ info(dim(line));
87186
+ return;
87187
+ }
87188
+ if (opts.delete) {
87189
+ const r2 = await client.call("DELETE", `/db/restore-points/${encodeURIComponent(opts.delete)}`, void 0, { project_id: projectId });
87190
+ if (opts.json) {
87191
+ printJson(r2);
87192
+ return;
87193
+ }
87194
+ success(`Deleted restore point ${r2.deleted}.`);
87195
+ return;
87196
+ }
87197
+ const r = await client.call("GET", "/db/restore-points", void 0, { project_id: projectId });
87198
+ if (opts.json) {
87199
+ printJson(r);
87200
+ return;
87201
+ }
87202
+ if (!r.restore_points.length) {
87203
+ info(dim(`No restore points yet. Take one now with \`${cliInvocation()} db restore-points --take\`; the platform also takes them before deploys that change the database (when it can finish within the deploy's wait) and daily when the data changed.`));
87204
+ return;
87205
+ }
87206
+ table(["Restore point", "Taken", "Why", "State", "Size", "Expires"], r.restore_points.map((p2) => [teal(p2.id), p2.taken_at, p2.reason, p2.state === "ready" ? p2.exact === false ? "ready (read while running)" : "ready" : `${p2.state}${p2.detail ? `: ${p2.detail}` : ""}`, p2.state === "ready" ? size(p2.size_bytes) : dim("\u2014"), p2.expires_at]));
87207
+ for (const p2 of r.restore_points)
87208
+ if (p2.state === "ready" && p2.consistency && p2.consistency !== "Read in one moment: an exact copy.")
87209
+ info(dim(`${p2.id}: ${p2.consistency}`));
87210
+ } catch (err) {
87211
+ error(err instanceof Error ? err.message : String(err), err);
87212
+ process.exit(1);
87213
+ }
87214
+ });
87021
87215
  db.command("tables").description("List tables in the project database").option("--project <id>", "Project ID (defaults to .somewhere.json)").option("--json", "Print the raw tables response as JSON").action(async (opts) => {
87022
87216
  const client = new ApiClient(getToken());
87023
87217
  let projectId = opts.project;
@@ -87036,17 +87230,21 @@ function registerDb(program2) {
87036
87230
  return;
87037
87231
  }
87038
87232
  const rows = (r.tables ?? []).map((t) => typeof t === "string" ? { name: t } : t);
87039
- if (!rows.length) {
87040
- info(dim(`No tables yet. Create one with \`${cliInvocation()} db query "CREATE TABLE \u2026"\`.`));
87041
- return;
87233
+ if (rows.length) {
87234
+ table(["Table", "Rows"], rows.map((t) => [teal(t.name), t.row_count != null ? String(t.row_count) : dim("\u2014")]));
87235
+ } else {
87236
+ info(dim("No tables yet."));
87042
87237
  }
87043
- table(["Table", "Rows"], rows.map((t) => [teal(t.name), t.row_count != null ? String(t.row_count) : dim("\u2014")]));
87238
+ const hint = r.hint ?? (rows.length ? void 0 : "To add declared tables, define them in db/schema.ts and deploy.");
87239
+ if (hint)
87240
+ info(dim(hint));
87044
87241
  } catch (err) {
87045
87242
  error(err instanceof Error ? err.message : String(err), err);
87046
87243
  process.exit(1);
87047
87244
  }
87048
87245
  });
87049
87246
  }
87247
+ var sizeText;
87050
87248
  var init_db = __esm({
87051
87249
  "dist/commands/db.js"() {
87052
87250
  "use strict";
@@ -87057,12 +87255,14 @@ var init_db = __esm({
87057
87255
  init_config();
87058
87256
  init_output();
87059
87257
  init_link_hint();
87258
+ sizeText = /* @__PURE__ */ __name((n) => n >= 1e6 ? `${(n / 1e6).toFixed(1)} MB` : `${Math.max(1, Math.round(n / 1e3))} KB`, "sizeText");
87259
+ __name(backgroundExport, "backgroundExport");
87060
87260
  __name(registerDb, "registerDb");
87061
87261
  }
87062
87262
  });
87063
87263
 
87064
87264
  // dist/commands/postgres.js
87065
- import { readFileSync as readFileSync31 } from "node:fs";
87265
+ import { readFileSync as readFileSync32 } from "node:fs";
87066
87266
  function str(value) {
87067
87267
  return typeof value === "string" && value.length > 0 ? value : null;
87068
87268
  }
@@ -87071,7 +87271,7 @@ async function readNeonApiKey() {
87071
87271
  if (fromEnv)
87072
87272
  return fromEnv;
87073
87273
  if (!process.stdin.isTTY) {
87074
- return readFileSync31(0, "utf8").trim();
87274
+ return readFileSync32(0, "utf8").trim();
87075
87275
  }
87076
87276
  const response = await (0, import_prompts8.default)({
87077
87277
  type: "password",
@@ -87400,26 +87600,26 @@ var init_postgres = __esm({
87400
87600
  });
87401
87601
 
87402
87602
  // dist/lib/local-docs.js
87403
- 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";
87404
- import { join as join36 } from "node:path";
87603
+ import { appendFileSync as appendFileSync3, existsSync as existsSync31, lstatSync as lstatSync5, mkdirSync as mkdirSync16, mkdtempSync as mkdtempSync3, readFileSync as readFileSync33, renameSync as renameSync5, rmSync as rmSync13, writeFileSync as writeFileSync21 } from "node:fs";
87604
+ import { join as join37 } from "node:path";
87405
87605
  function localDocsVersion(root = process.cwd()) {
87406
- const path3 = join36(root, FOLDER, DOCS, STAMP);
87606
+ const path3 = join37(root, FOLDER, DOCS, STAMP);
87407
87607
  if (!existsSync31(path3))
87408
87608
  return void 0;
87409
- const stamp2 = JSON.parse(readFileSync32(path3, "utf8"));
87609
+ const stamp2 = JSON.parse(readFileSync33(path3, "utf8"));
87410
87610
  return typeof stamp2.version === "string" && /^[a-f0-9]{16}$/.test(stamp2.version) ? stamp2.version : void 0;
87411
87611
  }
87412
87612
  function ensureGitIgnore(root) {
87413
- const path3 = join36(root, ".gitignore");
87414
- const text = existsSync31(path3) ? readFileSync32(path3, "utf8") : "";
87613
+ const path3 = join37(root, ".gitignore");
87614
+ const text = existsSync31(path3) ? readFileSync33(path3, "utf8") : "";
87415
87615
  if (text.split(/\r?\n/).some((line) => line === ".somewhere/" || line === "/.somewhere/"))
87416
87616
  return;
87417
87617
  appendFileSync3(path3, `${text && !text.endsWith("\n") ? "\n" : ""}/.somewhere/
87418
87618
  `);
87419
87619
  }
87420
87620
  function saveLocalDocs(version2, files, root = process.cwd()) {
87421
- const state = join36(root, FOLDER);
87422
- const target = join36(state, DOCS);
87621
+ const state = join37(root, FOLDER);
87622
+ const target = join37(state, DOCS);
87423
87623
  if (existsSync31(state) && !lstatSync5(state).isDirectory())
87424
87624
  throw new Error(`${state} must be a directory.`);
87425
87625
  if (existsSync31(target) && (!lstatSync5(target).isDirectory() || !localDocsVersion(root))) {
@@ -87427,17 +87627,17 @@ function saveLocalDocs(version2, files, root = process.cwd()) {
87427
87627
  }
87428
87628
  ensureGitIgnore(root);
87429
87629
  mkdirSync16(state, { recursive: true });
87430
- const staging = mkdtempSync3(join36(state, "docs-pull-"));
87431
- const next = join36(staging, "next");
87432
- const previous = join36(staging, "previous");
87630
+ const staging = mkdtempSync3(join37(state, "docs-pull-"));
87631
+ const next = join37(staging, "next");
87632
+ const previous = join37(staging, "previous");
87433
87633
  let installed = false;
87434
87634
  try {
87435
87635
  mkdirSync16(next);
87436
87636
  for (const [name, content] of files)
87437
- writeFileSync21(join36(next, name), content, { flag: "wx" });
87637
+ writeFileSync21(join37(next, name), content, { flag: "wx" });
87438
87638
  const pulledAt = (/* @__PURE__ */ new Date()).toISOString();
87439
- writeFileSync21(join36(next, STAMP), JSON.stringify({ version: version2, pulledAt }) + "\n");
87440
- writeFileSync21(join36(next, "README.md"), `# Somewhere docs
87639
+ writeFileSync21(join37(next, STAMP), JSON.stringify({ version: version2, pulledAt }) + "\n");
87640
+ writeFileSync21(join37(next, "README.md"), `# Somewhere docs
87441
87641
 
87442
87642
  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.
87443
87643
  `, { flag: "wx" });
@@ -87468,8 +87668,8 @@ var init_local_docs = __esm({
87468
87668
  });
87469
87669
 
87470
87670
  // dist/lib/advisor-context.js
87471
- import { readFileSync as readFileSync33, statSync as statSync6 } from "node:fs";
87472
- import { basename as basename7 } from "node:path";
87671
+ import { readFileSync as readFileSync34, statSync as statSync6 } from "node:fs";
87672
+ import { basename as basename8 } from "node:path";
87473
87673
  function tail(value, limit) {
87474
87674
  return value.length <= limit ? value : `\u2026${value.slice(-limit)}`;
87475
87675
  }
@@ -87481,7 +87681,7 @@ function redactAdvisorText(value, redactDotenvValues = false) {
87481
87681
  return redacted;
87482
87682
  }
87483
87683
  function isDotenvPath(path3) {
87484
- const name = basename7(path3);
87684
+ const name = basename8(path3);
87485
87685
  return name === ".env" || name.startsWith(".env.") || name.endsWith(".env");
87486
87686
  }
87487
87687
  function buildAdvisorContext(filePath) {
@@ -87490,7 +87690,7 @@ function buildAdvisorContext(filePath) {
87490
87690
  const stat6 = statSync6(filePath);
87491
87691
  if (!stat6.isFile())
87492
87692
  throw new Error("--file must name a regular file.");
87493
- const content = readFileSync33(filePath, "utf8");
87693
+ const content = readFileSync34(filePath, "utf8");
87494
87694
  context.file = {
87495
87695
  path: filePath,
87496
87696
  content: tail(redactAdvisorText(content, isDotenvPath(filePath)), FILE_LIMIT)
@@ -87515,18 +87715,18 @@ var init_advisor_context = __esm({
87515
87715
  });
87516
87716
 
87517
87717
  // dist/lib/advisor-runs.js
87518
- import { randomBytes as randomBytes7, randomUUID as randomUUID7 } from "node:crypto";
87519
- import { chmodSync as chmodSync4, existsSync as existsSync32, mkdirSync as mkdirSync17, readFileSync as readFileSync34, renameSync as renameSync6, writeFileSync as writeFileSync22 } from "node:fs";
87520
- import { join as join37 } from "node:path";
87718
+ import { randomBytes as randomBytes7, randomUUID as randomUUID8 } from "node:crypto";
87719
+ import { chmodSync as chmodSync4, existsSync as existsSync32, mkdirSync as mkdirSync17, readFileSync as readFileSync35, renameSync as renameSync6, writeFileSync as writeFileSync22 } from "node:fs";
87720
+ import { join as join38 } from "node:path";
87521
87721
  function path2(id) {
87522
87722
  if (!/^[a-f0-9-]{36}$/i.test(id))
87523
87723
  throw Error("Invalid Advisor request ID.");
87524
- return join37(directory(), id + ".json");
87724
+ return join38(directory(), id + ".json");
87525
87725
  }
87526
87726
  function save(record3) {
87527
87727
  mkdirSync17(directory(), { recursive: true, mode: 448 });
87528
87728
  chmodSync4(directory(), 448);
87529
- const target = path2(record3.request_id), temporary = target + "." + randomUUID7() + ".tmp";
87729
+ const target = path2(record3.request_id), temporary = target + "." + randomUUID8() + ".tmp";
87530
87730
  writeFileSync22(temporary, JSON.stringify(record3), { mode: 384, flag: "wx" });
87531
87731
  renameSync6(temporary, target);
87532
87732
  chmodSync4(target, 384);
@@ -87553,7 +87753,7 @@ function expiredResult(record3) {
87553
87753
  function load(id) {
87554
87754
  if (!existsSync32(path2(id)))
87555
87755
  throw Error("Advisor request was not found in this CLI configuration.");
87556
- const record3 = JSON.parse(readFileSync34(path2(id), "utf8"));
87756
+ const record3 = JSON.parse(readFileSync35(path2(id), "utf8"));
87557
87757
  prune(record3);
87558
87758
  save(record3);
87559
87759
  return record3;
@@ -87603,7 +87803,7 @@ async function callAdvisorRun(args) {
87603
87803
  else {
87604
87804
  if (!args.question)
87605
87805
  throw Error("Supply a question or --resume <request-id>.");
87606
- const id = randomUUID7(), created = Date.now(), context = args.context ? { ...args.context } : void 0;
87806
+ const id = randomUUID8(), created = Date.now(), context = args.context ? { ...args.context } : void 0;
87607
87807
  if (context?.file)
87608
87808
  delete context.file;
87609
87809
  const config2 = loadConfig();
@@ -87644,7 +87844,7 @@ async function consumeAdvisorRun(text, progress) {
87644
87844
  }
87645
87845
  if (typeof parsed.run_id !== "string" || typeof parsed.status !== "string")
87646
87846
  return null;
87647
- const config2 = loadConfig(), anonymous = typeof parsed.anonymous_capability === "string", id = randomUUID7();
87847
+ const config2 = loadConfig(), anonymous = typeof parsed.anonymous_capability === "string", id = randomUUID8();
87648
87848
  if (!anonymous && (!config2?.token || config2.temporary === true))
87649
87849
  throw Error("Sign in to the account that owns this Advisor run.");
87650
87850
  const record3 = { owner_mode: anonymous ? "anonymous" : "account", request_id: id, request_created_at: Date.now(), capability: anonymous ? String(parsed.anonymous_capability) : randomBytes7(32).toString("hex"), run_id: parsed.run_id, ...Number.isSafeInteger(parsed.payload_expires_at) ? { payload_expires_at: Number(parsed.payload_expires_at) } : {} };
@@ -87659,7 +87859,7 @@ var init_advisor_runs = __esm({
87659
87859
  init_config();
87660
87860
  init_http();
87661
87861
  init_advisor_context();
87662
- directory = /* @__PURE__ */ __name(() => join37(cliConfigDir(), "advisor-runs"), "directory");
87862
+ directory = /* @__PURE__ */ __name(() => join38(cliConfigDir(), "advisor-runs"), "directory");
87663
87863
  __name(path2, "path");
87664
87864
  __name(save, "save");
87665
87865
  PAYLOAD_RETENTION_MS = 24 * 60 * 60 * 1e3;
@@ -87677,8 +87877,8 @@ var init_advisor_runs = __esm({
87677
87877
 
87678
87878
  // dist/lib/advisor-app.js
87679
87879
  import { createHash as createHash8 } from "node:crypto";
87680
- import { existsSync as existsSync33, mkdirSync as mkdirSync18, readFileSync as readFileSync35, rmSync as rmSync14, writeFileSync as writeFileSync23 } from "node:fs";
87681
- import { join as join38 } from "node:path";
87880
+ import { existsSync as existsSync33, mkdirSync as mkdirSync18, readFileSync as readFileSync36, rmSync as rmSync14, writeFileSync as writeFileSync23 } from "node:fs";
87881
+ import { join as join39 } from "node:path";
87682
87882
  async function gatherAdvisorApp(client, ref) {
87683
87883
  const project = await client.call("GET", `/projects/${encodeURIComponent(ref)}`);
87684
87884
  if (typeof project.id !== "string" || project.deleted === true)
@@ -87712,7 +87912,7 @@ async function gatherAdvisorApp(client, ref) {
87712
87912
  }
87713
87913
  function loadAdvisorTurns(dir, projectId, account, now2 = Date.now()) {
87714
87914
  try {
87715
- const saved = JSON.parse(readFileSync35(join38(dir, FILE), "utf8"));
87915
+ const saved = JSON.parse(readFileSync36(join39(dir, FILE), "utf8"));
87716
87916
  if (saved.project_id !== projectId || saved.owner !== ownerOf(account) || !Array.isArray(saved.turns))
87717
87917
  return [];
87718
87918
  const last = saved.turns.at(-1);
@@ -87722,22 +87922,22 @@ function loadAdvisorTurns(dir, projectId, account, now2 = Date.now()) {
87722
87922
  }
87723
87923
  }
87724
87924
  function saveAdvisorTurn(dir, projectId, account, earlier, turn) {
87725
- mkdirSync18(join38(dir, DIR), { recursive: true, mode: 448 });
87726
- 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 });
87925
+ mkdirSync18(join39(dir, DIR), { recursive: true, mode: 448 });
87926
+ writeFileSync23(join39(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 });
87727
87927
  ensureAdvisorStateIgnored(dir);
87728
87928
  }
87729
87929
  function clearAdvisorTurns(dir) {
87730
- if (existsSync33(join38(dir, FILE)))
87731
- rmSync14(join38(dir, FILE), { force: true });
87930
+ if (existsSync33(join39(dir, FILE)))
87931
+ rmSync14(join39(dir, FILE), { force: true });
87732
87932
  }
87733
87933
  function ensureAdvisorStateIgnored(dir) {
87734
- const path3 = join38(dir, ".gitignore");
87934
+ const path3 = join39(dir, ".gitignore");
87735
87935
  const covered = [".somewhere/", ".somewhere", "/.somewhere/", "/.somewhere", ".somewhere/advisor-conversation.json"];
87736
87936
  if (!existsSync33(path3)) {
87737
87937
  writeFileSync23(path3, "# somewhere: local CLI state (Advisor follow-ups, test users)\n.somewhere/\n");
87738
87938
  return;
87739
87939
  }
87740
- const text = readFileSync35(path3, "utf8");
87940
+ const text = readFileSync36(path3, "utf8");
87741
87941
  if (text.split(/\r?\n/).map((l) => l.trim()).some((l) => covered.includes(l)))
87742
87942
  return;
87743
87943
  writeFileSync23(path3, `${text}${text.endsWith("\n") || !text ? "" : "\n"}
@@ -87751,7 +87951,7 @@ var init_advisor_app = __esm({
87751
87951
  "use strict";
87752
87952
  __name(gatherAdvisorApp, "gatherAdvisorApp");
87753
87953
  DIR = ".somewhere";
87754
- FILE = join38(DIR, "advisor-conversation.json");
87954
+ FILE = join39(DIR, "advisor-conversation.json");
87755
87955
  IDLE_MS = 30 * 6e4;
87756
87956
  ownerOf = /* @__PURE__ */ __name((account) => createHash8("sha256").update(`advisor:${account}`).digest("hex"), "ownerOf");
87757
87957
  __name(loadAdvisorTurns, "loadAdvisorTurns");
@@ -89165,7 +89365,7 @@ var init_envfile_write = __esm({
89165
89365
  });
89166
89366
 
89167
89367
  // dist/commands/env.js
89168
- import { existsSync as existsSync34, readFileSync as readFileSync36, writeFileSync as writeFileSync24 } from "node:fs";
89368
+ import { existsSync as existsSync34, readFileSync as readFileSync37, writeFileSync as writeFileSync24 } from "node:fs";
89169
89369
  import { resolve as resolve19 } from "node:path";
89170
89370
  function resolveProjectId(explicit) {
89171
89371
  if (explicit)
@@ -89247,7 +89447,7 @@ function registerEnv(program2) {
89247
89447
  process.exit(1);
89248
89448
  }
89249
89449
  if (existsSync34(outPath) && !opts.force) {
89250
- const existing = readFileSync36(outPath, "utf-8");
89450
+ const existing = readFileSync37(outPath, "utf-8");
89251
89451
  const hasValues = existing.split("\n").some((l) => /^[^#=]+=.+/.test(l.trim()));
89252
89452
  const { ok } = await (0, import_prompts9.default)({
89253
89453
  type: "confirm",
@@ -89300,7 +89500,7 @@ function registerEnv(program2) {
89300
89500
  if (inputNote && !opts.json)
89301
89501
  process.stderr.write(`Note: ${inputNote}
89302
89502
  `);
89303
- const value = opts.stdin ? readFileSync36(0, "utf8").replace(/\r?\n$/, "") : positionalValue;
89503
+ const value = opts.stdin ? readFileSync37(0, "utf8").replace(/\r?\n$/, "") : positionalValue;
89304
89504
  const client = new ApiClient(getToken());
89305
89505
  const pid = resolveProjectId(opts.project);
89306
89506
  try {
@@ -89370,7 +89570,7 @@ var init_env = __esm({
89370
89570
  });
89371
89571
 
89372
89572
  // dist/commands/run.js
89373
- import { existsSync as existsSync35, readFileSync as readFileSync37 } from "node:fs";
89573
+ import { existsSync as existsSync35, readFileSync as readFileSync38 } from "node:fs";
89374
89574
  import { isAbsolute as isAbsolute6, resolve as resolve20 } from "node:path";
89375
89575
  import { createRequire as createRequire8 } from "node:module";
89376
89576
  function parseArgs(values) {
@@ -89441,7 +89641,7 @@ function registerRun(program2) {
89441
89641
  error(`File not found: ${script}`);
89442
89642
  process.exit(1);
89443
89643
  }
89444
- const code = readFileSync37(absPath, "utf-8");
89644
+ const code = readFileSync38(absPath, "utf-8");
89445
89645
  if (!code.trim()) {
89446
89646
  error(`${script} is empty \u2014 nothing to run.`);
89447
89647
  process.exit(1);
@@ -89879,7 +90079,7 @@ var init_claim = __esm({
89879
90079
  import { createRequire as createRequire9 } from "node:module";
89880
90080
  import { realpathSync as realpathSync4 } from "node:fs";
89881
90081
  import { createConnection, createServer as createNetServer } from "node:net";
89882
- import { join as join39 } from "node:path";
90082
+ import { join as join40 } from "node:path";
89883
90083
  import { pathToFileURL as pathToFileURL3 } from "node:url";
89884
90084
  function deployedOrigin(value) {
89885
90085
  const url3 = new URL(value);
@@ -89977,7 +90177,7 @@ async function startFrontendDev(cwd, target, port = 8787, open4 = false) {
89977
90177
  throw new Error(INSTALL_PROJECT_DEPENDENCIES);
89978
90178
  let vitePath;
89979
90179
  try {
89980
- vitePath = createRequire9(join39(cwd, "package.json")).resolve("vite");
90180
+ vitePath = createRequire9(join40(cwd, "package.json")).resolve("vite");
89981
90181
  } catch {
89982
90182
  if (readProjectPin(cwd)?.versionOnly) {
89983
90183
  throw new Error("Install the local frontend tools: npm install -D --save-exact vite@7.2.2");
@@ -90119,9 +90319,9 @@ var init_preview_jobs = __esm({
90119
90319
  });
90120
90320
 
90121
90321
  // dist/commands/dev.js
90122
- import { randomUUID as randomUUID8 } from "node:crypto";
90123
- import { existsSync as existsSync36, readFileSync as readFileSync38 } from "node:fs";
90124
- import { join as join40, relative as relative11 } from "node:path";
90322
+ import { randomUUID as randomUUID9 } from "node:crypto";
90323
+ import { existsSync as existsSync36, readFileSync as readFileSync39 } from "node:fs";
90324
+ import { join as join41, relative as relative11 } from "node:path";
90125
90325
  function previewFinishedReason(err) {
90126
90326
  if (!(err instanceof CliApiError) || err.code !== "DRAFT_SESSION_TERMINAL")
90127
90327
  return null;
@@ -90747,7 +90947,7 @@ async function runHotDeploy(opts) {
90747
90947
  }
90748
90948
  await showProjectNotices(client, projectId);
90749
90949
  const { files, binaryFiles, functions } = collected;
90750
- const firstOperationId = `previewop_${randomUUID8()}`;
90950
+ const firstOperationId = `previewop_${randomUUID9()}`;
90751
90951
  const showPublishProgress = opts.publishFirst === true && opts.json !== true;
90752
90952
  const phase = /* @__PURE__ */ __name((label, operation) => showPublishProgress ? runPreviewPhase(label, operation) : operation(), "phase");
90753
90953
  const say = opts.json ? () => {
@@ -90779,7 +90979,7 @@ async function runHotDeploy(opts) {
90779
90979
  say(`Continuing this folder's preview ${draftId}${when.length ? ` (${when.join(", ")})` : ""}.`);
90780
90980
  say("Pass --new to open a fresh preview with a new copy of production data instead.");
90781
90981
  } else {
90782
- draftId = `draft_${randomUUID8()}`;
90982
+ draftId = `draft_${randomUUID9()}`;
90783
90983
  expectedPreviewId = null;
90784
90984
  if (decision.reason === "stale") {
90785
90985
  if (!opts.json) {
@@ -91108,20 +91308,20 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
91108
91308
  const updateBinary = {};
91109
91309
  const deleteKeys = [];
91110
91310
  for (const rel of changed) {
91111
- const abs = join40(cwd, rel);
91311
+ const abs = join41(cwd, rel);
91112
91312
  if (!existsSync36(abs))
91113
91313
  continue;
91114
91314
  const { kind, key } = classifyKey(rel);
91115
91315
  if (kind === "function")
91116
- updateFunctions[key] = readFileSync38(abs, "utf-8");
91316
+ updateFunctions[key] = readFileSync39(abs, "utf-8");
91117
91317
  else if (kind === "binary")
91118
- updateBinary[key] = readFileSync38(abs).toString("base64");
91318
+ updateBinary[key] = readFileSync39(abs).toString("base64");
91119
91319
  else
91120
- updateFiles[key] = readFileSync38(abs, "utf-8");
91320
+ updateFiles[key] = readFileSync39(abs, "utf-8");
91121
91321
  }
91122
91322
  for (const rel of deleted)
91123
91323
  deleteKeys.push(classifyKey(rel).key);
91124
- const operationId = `previewop_${randomUUID8()}`;
91324
+ const operationId = `previewop_${randomUUID9()}`;
91125
91325
  const body = {
91126
91326
  project_id: projectId,
91127
91327
  preview: true,
@@ -91180,7 +91380,7 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
91180
91380
  for (const rel of deleted)
91181
91381
  delete nextFiles[rel];
91182
91382
  for (const rel of changed)
91183
- if (existsSync36(join40(cwd, rel)))
91383
+ if (existsSync36(join41(cwd, rel)))
91184
91384
  Object.assign(nextFiles, hashFiles(cwd, [rel]));
91185
91385
  savePreviewRecord(cwd, { ...record3, preview_id: nextCandidate, files: nextFiles });
91186
91386
  }
@@ -91376,7 +91576,7 @@ var init_dev = __esm({
91376
91576
 
91377
91577
  // dist/commands/check.js
91378
91578
  import { existsSync as existsSync37 } from "node:fs";
91379
- import { join as join41, resolve as resolve21 } from "node:path";
91579
+ import { join as join42, resolve as resolve21 } from "node:path";
91380
91580
  function buildCheckBody(collected, projectId) {
91381
91581
  const body = { project_id: projectId, files: collected.files };
91382
91582
  if (Object.keys(collected.functions).length > 0)
@@ -91481,7 +91681,7 @@ async function runLocalPreflight(targetDir, collected, typecheck = async (dir) =
91481
91681
  if (collected.excluded.length)
91482
91682
  source.not_published = collected.excluded;
91483
91683
  let typecheckStep;
91484
- if (!existsSync37(join41(targetDir, "tsconfig.json"))) {
91684
+ if (!existsSync37(join42(targetDir, "tsconfig.json"))) {
91485
91685
  typecheckStep = { name: "typecheck", status: "skipped", reason: MISSING_TSCONFIG_GUIDANCE };
91486
91686
  } else if (missingProjectDependencies(targetDir).length) {
91487
91687
  typecheckStep = { name: "typecheck", status: "skipped", reason: missingTypecheckDependenciesMessage() };
@@ -91895,11 +92095,11 @@ var init_api2 = __esm({
91895
92095
  });
91896
92096
 
91897
92097
  // dist/commands/fs.js
91898
- import { createReadStream as createReadStream2, createWriteStream as createWriteStream2 } from "node:fs";
91899
- import { stat as stat5, rename, unlink } from "node:fs/promises";
91900
- import { randomUUID as randomUUID9 } from "node:crypto";
91901
- import { basename as basename8, dirname as dirname13, extname as extname6, join as join42, resolve as resolve23 } from "node:path";
91902
- import { pipeline as pipeline2 } from "node:stream/promises";
92098
+ import { createReadStream as createReadStream2, createWriteStream as createWriteStream3 } from "node:fs";
92099
+ import { stat as stat5, rename as rename2, unlink as unlink2 } from "node:fs/promises";
92100
+ import { randomUUID as randomUUID10 } from "node:crypto";
92101
+ import { basename as basename9, dirname as dirname14, extname as extname6, join as join43, resolve as resolve23 } from "node:path";
92102
+ import { pipeline as pipeline3 } from "node:stream/promises";
91903
92103
  function registerFs(program2) {
91904
92104
  const fs2 = program2.command("fs").description("Manage project file storage");
91905
92105
  fs2.command("put <local> <remote>").description("Stream a local file into project storage").option("--project <slug>", "Project slug or ID (defaults to the linked project)").option("--content-type <type>", "Stored content type (inferred from the local filename by default)").option("--json", "Print the raw file response as JSON").action(async (local, remote, opts) => {
@@ -91942,9 +92142,9 @@ function registerFs(program2) {
91942
92142
  if (!response.body)
91943
92143
  throw new Error("The server returned an empty file response.");
91944
92144
  const destination = resolve23(local);
91945
- tempPath = join42(dirname13(destination), `.${basename8(destination)}.${randomUUID9()}.tmp`);
91946
- await pipeline2(response.body, createWriteStream2(tempPath, { flags: "wx" }));
91947
- await rename(tempPath, destination);
92145
+ tempPath = join43(dirname14(destination), `.${basename9(destination)}.${randomUUID10()}.tmp`);
92146
+ await pipeline3(response.body, createWriteStream3(tempPath, { flags: "wx" }));
92147
+ await rename2(tempPath, destination);
91948
92148
  tempPath = void 0;
91949
92149
  const size = Number(response.headers.get("content-length"));
91950
92150
  const result = {
@@ -91959,7 +92159,7 @@ function registerFs(program2) {
91959
92159
  success(`Downloaded ${remote} \u2192 ${local}`);
91960
92160
  } catch (err) {
91961
92161
  if (tempPath)
91962
- await unlink(tempPath).catch(() => {
92162
+ await unlink2(tempPath).catch(() => {
91963
92163
  });
91964
92164
  fail(err, opts.json);
91965
92165
  }
@@ -109746,13 +109946,13 @@ var require_polyfill = __commonJS({
109746
109946
  readlink,
109747
109947
  stat: stat6,
109748
109948
  symlink,
109749
- unlink: unlink2,
109949
+ unlink: unlink3,
109750
109950
  utimes
109751
109951
  } = __require("fs/promises");
109752
109952
  var {
109753
- dirname: dirname16,
109953
+ dirname: dirname17,
109754
109954
  isAbsolute: isAbsolute7,
109755
- join: join52,
109955
+ join: join53,
109756
109956
  parse: parse3,
109757
109957
  resolve: resolve27,
109758
109958
  sep: sep2,
@@ -109854,7 +110054,7 @@ var require_polyfill = __commonJS({
109854
110054
  }
109855
110055
  __name(getStats, "getStats");
109856
110056
  async function checkParentDir(destStat, src, dest, opts) {
109857
- const destParent = dirname16(dest);
110057
+ const destParent = dirname17(dest);
109858
110058
  const dirExists = await pathExists(destParent);
109859
110059
  if (dirExists) {
109860
110060
  return getStatsForCopy(destStat, src, dest, opts);
@@ -109872,8 +110072,8 @@ var require_polyfill = __commonJS({
109872
110072
  }
109873
110073
  __name(pathExists, "pathExists");
109874
110074
  async function checkParentPaths(src, srcStat, dest) {
109875
- const srcParent = resolve27(dirname16(src));
109876
- const destParent = resolve27(dirname16(dest));
110075
+ const srcParent = resolve27(dirname17(src));
110076
+ const destParent = resolve27(dirname17(dest));
109877
110077
  if (destParent === srcParent || destParent === parse3(destParent).root) {
109878
110078
  return;
109879
110079
  }
@@ -109966,7 +110166,7 @@ var require_polyfill = __commonJS({
109966
110166
  __name(onFile, "onFile");
109967
110167
  async function mayCopyFile(srcStat, src, dest, opts) {
109968
110168
  if (opts.force) {
109969
- await unlink2(dest);
110169
+ await unlink3(dest);
109970
110170
  return _copyFile(srcStat, src, dest, opts);
109971
110171
  } else if (opts.errorOnExist) {
109972
110172
  throw new ERR_FS_CP_EEXIST({
@@ -110033,8 +110233,8 @@ var require_polyfill = __commonJS({
110033
110233
  const dir = await readdir3(src);
110034
110234
  for (let i = 0; i < dir.length; i++) {
110035
110235
  const item = dir[i];
110036
- const srcItem = join52(src, item);
110037
- const destItem = join52(dest, item);
110236
+ const srcItem = join53(src, item);
110237
+ const destItem = join53(dest, item);
110038
110238
  const { destStat } = await checkPaths(srcItem, destItem, opts);
110039
110239
  await startCopy(destStat, srcItem, destItem, opts);
110040
110240
  }
@@ -110043,7 +110243,7 @@ var require_polyfill = __commonJS({
110043
110243
  async function onLink(destStat, src, dest) {
110044
110244
  let resolvedSrc = await readlink(src);
110045
110245
  if (!isAbsolute7(resolvedSrc)) {
110046
- resolvedSrc = resolve27(dirname16(src), resolvedSrc);
110246
+ resolvedSrc = resolve27(dirname17(src), resolvedSrc);
110047
110247
  }
110048
110248
  if (!destStat) {
110049
110249
  return symlink(resolvedSrc, dest);
@@ -110058,7 +110258,7 @@ var require_polyfill = __commonJS({
110058
110258
  throw err;
110059
110259
  }
110060
110260
  if (!isAbsolute7(resolvedDest)) {
110061
- resolvedDest = resolve27(dirname16(dest), resolvedDest);
110261
+ resolvedDest = resolve27(dirname17(dest), resolvedDest);
110062
110262
  }
110063
110263
  if (isSrcSubdir(resolvedSrc, resolvedDest)) {
110064
110264
  throw new ERR_FS_CP_EINVAL({
@@ -110081,7 +110281,7 @@ var require_polyfill = __commonJS({
110081
110281
  }
110082
110282
  __name(onLink, "onLink");
110083
110283
  async function copyLink(resolvedSrc, dest) {
110084
- await unlink2(dest);
110284
+ await unlink3(dest);
110085
110285
  return symlink(resolvedSrc, dest);
110086
110286
  }
110087
110287
  __name(copyLink, "copyLink");
@@ -110110,7 +110310,7 @@ var require_cp = __commonJS({
110110
110310
  // node_modules/@npmcli/fs/lib/with-temp-dir.js
110111
110311
  var require_with_temp_dir = __commonJS({
110112
110312
  "node_modules/@npmcli/fs/lib/with-temp-dir.js"(exports, module) {
110113
- var { join: join52, sep: sep2 } = __require("path");
110313
+ var { join: join53, sep: sep2 } = __require("path");
110114
110314
  var getOptions = require_get_options();
110115
110315
  var { mkdir, mkdtemp, rm } = __require("fs/promises");
110116
110316
  var withTempDir = /* @__PURE__ */ __name(async (root, fn, opts) => {
@@ -110118,7 +110318,7 @@ var require_with_temp_dir = __commonJS({
110118
110318
  copy: ["tmpPrefix"]
110119
110319
  });
110120
110320
  await mkdir(root, { recursive: true });
110121
- const target = await mkdtemp(join52(`${root}${sep2}`, options2.tmpPrefix || ""));
110321
+ const target = await mkdtemp(join53(`${root}${sep2}`, options2.tmpPrefix || ""));
110122
110322
  let err;
110123
110323
  let result;
110124
110324
  try {
@@ -110143,13 +110343,13 @@ var require_with_temp_dir = __commonJS({
110143
110343
  var require_readdir_scoped = __commonJS({
110144
110344
  "node_modules/@npmcli/fs/lib/readdir-scoped.js"(exports, module) {
110145
110345
  var { readdir: readdir3 } = __require("fs/promises");
110146
- var { join: join52 } = __require("path");
110346
+ var { join: join53 } = __require("path");
110147
110347
  var readdirScoped = /* @__PURE__ */ __name(async (dir) => {
110148
110348
  const results = [];
110149
110349
  for (const item of await readdir3(dir)) {
110150
110350
  if (item.startsWith("@")) {
110151
- for (const scopedItem of await readdir3(join52(dir, item))) {
110152
- results.push(join52(item, scopedItem));
110351
+ for (const scopedItem of await readdir3(join53(dir, item))) {
110352
+ results.push(join53(item, scopedItem));
110153
110353
  }
110154
110354
  } else {
110155
110355
  results.push(item);
@@ -110164,7 +110364,7 @@ var require_readdir_scoped = __commonJS({
110164
110364
  // node_modules/@npmcli/fs/lib/move-file.js
110165
110365
  var require_move_file = __commonJS({
110166
110366
  "node_modules/@npmcli/fs/lib/move-file.js"(exports, module) {
110167
- var { dirname: dirname16, join: join52, resolve: resolve27, relative: relative15, isAbsolute: isAbsolute7 } = __require("path");
110367
+ var { dirname: dirname17, join: join53, resolve: resolve27, relative: relative15, isAbsolute: isAbsolute7 } = __require("path");
110168
110368
  var fs2 = __require("fs/promises");
110169
110369
  var pathExists = /* @__PURE__ */ __name(async (path3) => {
110170
110370
  try {
@@ -110185,7 +110385,7 @@ var require_move_file = __commonJS({
110185
110385
  if (!options2.overwrite && await pathExists(destination)) {
110186
110386
  throw new Error(`The destination file exists: ${destination}`);
110187
110387
  }
110188
- await fs2.mkdir(dirname16(destination), { recursive: true });
110388
+ await fs2.mkdir(dirname17(destination), { recursive: true });
110189
110389
  try {
110190
110390
  await fs2.rename(source, destination);
110191
110391
  } catch (error3) {
@@ -110194,7 +110394,7 @@ var require_move_file = __commonJS({
110194
110394
  if (sourceStat.isDirectory()) {
110195
110395
  const files = await fs2.readdir(source);
110196
110396
  await Promise.all(files.map(
110197
- (file) => moveFile(join52(source, file), join52(destination, file), options2, false, symlinks)
110397
+ (file) => moveFile(join53(source, file), join53(destination, file), options2, false, symlinks)
110198
110398
  ));
110199
110399
  } else if (sourceStat.isSymbolicLink()) {
110200
110400
  symlinks.push({ source, destination });
@@ -110213,7 +110413,7 @@ var require_move_file = __commonJS({
110213
110413
  }
110214
110414
  let targetStat = "file";
110215
110415
  try {
110216
- targetStat = await fs2.stat(resolve27(dirname16(symSource), target));
110416
+ targetStat = await fs2.stat(resolve27(dirname17(symSource), target));
110217
110417
  if (targetStat.isDirectory()) {
110218
110418
  targetStat = "junction";
110219
110419
  }
@@ -112415,8 +112615,8 @@ var require_write = __commonJS({
112415
112615
  hashStream.on("size", (s3) => {
112416
112616
  size = s3;
112417
112617
  });
112418
- const pipeline4 = new Pipeline(inputStream, hashStream, outStream);
112419
- await pipeline4.promise();
112618
+ const pipeline5 = new Pipeline(inputStream, hashStream, outStream);
112619
+ await pipeline5.promise();
112420
112620
  return { integrity, size };
112421
112621
  }
112422
112622
  __name(pipeToTmp, "pipeToTmp");
@@ -112507,12 +112707,12 @@ var require_put = __commonJS({
112507
112707
  let size;
112508
112708
  let error3;
112509
112709
  let memoData;
112510
- const pipeline4 = new Pipeline();
112710
+ const pipeline5 = new Pipeline();
112511
112711
  if (memoize) {
112512
112712
  const memoizer2 = new PassThrough().on("collect", (data2) => {
112513
112713
  memoData = data2;
112514
112714
  });
112515
- pipeline4.push(memoizer2);
112715
+ pipeline5.push(memoizer2);
112516
112716
  }
112517
112717
  const contentStream = write.stream(cache, opts).on("integrity", (int2) => {
112518
112718
  integrity = int2;
@@ -112521,20 +112721,20 @@ var require_put = __commonJS({
112521
112721
  }).on("error", (err) => {
112522
112722
  error3 = err;
112523
112723
  });
112524
- pipeline4.push(contentStream);
112525
- pipeline4.push(new Flush({
112724
+ pipeline5.push(contentStream);
112725
+ pipeline5.push(new Flush({
112526
112726
  async flush() {
112527
112727
  if (!error3) {
112528
112728
  const entry = await index.insert(cache, key, integrity, { ...opts, size });
112529
112729
  if (memoize && memoData) {
112530
112730
  memo2.put(cache, entry, memoData, opts);
112531
112731
  }
112532
- pipeline4.emit("integrity", integrity);
112533
- pipeline4.emit("size", size);
112732
+ pipeline5.emit("integrity", integrity);
112733
+ pipeline5.emit("size", size);
112534
112734
  }
112535
112735
  }
112536
112736
  }));
112537
- return pipeline4;
112737
+ return pipeline5;
112538
112738
  }
112539
112739
  __name(putStream, "putStream");
112540
112740
  }
@@ -123312,12 +123512,12 @@ var require_remote = __commonJS({
123312
123512
  integrity: _opts.integrity,
123313
123513
  size: _opts.size
123314
123514
  });
123315
- const pipeline4 = new CachingMinipassPipeline({
123515
+ const pipeline5 = new CachingMinipassPipeline({
123316
123516
  events: ["integrity", "size"]
123317
123517
  }, res.body, integrityStream);
123318
- integrityStream.on("integrity", (i) => pipeline4.emit("integrity", i));
123319
- integrityStream.on("size", (s3) => pipeline4.emit("size", s3));
123320
- res = new fetch2.Response(pipeline4, res);
123518
+ integrityStream.on("integrity", (i) => pipeline5.emit("integrity", i));
123519
+ integrityStream.on("size", (s3) => pipeline5.emit("size", s3));
123520
+ res = new fetch2.Response(pipeline5, res);
123321
123521
  res.body.hasIntegrityEmitter = true;
123322
123522
  }
123323
123523
  res.headers.set("x-fetch-attempts", attemptNum);
@@ -129562,12 +129762,12 @@ var require_url = __commonJS({
129562
129762
  "node_modules/tuf-js/dist/utils/url.js"(exports) {
129563
129763
  "use strict";
129564
129764
  Object.defineProperty(exports, "__esModule", { value: true });
129565
- exports.join = join52;
129765
+ exports.join = join53;
129566
129766
  var url_1 = __require("url");
129567
- function join52(base, path3) {
129767
+ function join53(base, path3) {
129568
129768
  return new url_1.URL(ensureTrailingSlash(base) + removeLeadingSlash(path3)).toString();
129569
129769
  }
129570
- __name(join52, "join");
129770
+ __name(join53, "join");
129571
129771
  function ensureTrailingSlash(path3) {
129572
129772
  return path3.endsWith("/") ? path3 : path3 + "/";
129573
129773
  }
@@ -131903,10 +132103,10 @@ var require_dist15 = __commonJS({
131903
132103
 
131904
132104
  // dist/lib/update-security.js
131905
132105
  import { createHash as createHash9, timingSafeEqual } from "node:crypto";
131906
- import { mkdirSync as mkdirSync19, readFileSync as readFileSync39, statSync as statSync7 } from "node:fs";
131907
- import { join as join43 } from "node:path";
131908
- import { Readable as Readable2 } from "node:stream";
131909
- import { pipeline as pipeline3 } from "node:stream/promises";
132106
+ import { mkdirSync as mkdirSync19, readFileSync as readFileSync40, statSync as statSync7 } from "node:fs";
132107
+ import { join as join44 } from "node:path";
132108
+ import { Readable as Readable3 } from "node:stream";
132109
+ import { pipeline as pipeline4 } from "node:stream/promises";
131910
132110
  function expectedTarballUrl(version2) {
131911
132111
  return `${OFFICIAL_NPM_REGISTRY}/@somewhere-cloud/cli/-/cli-${encodeURIComponent(version2)}.tgz`;
131912
132112
  }
@@ -132249,7 +132449,7 @@ function bundledManifestLockPath(tarPath) {
132249
132449
  return index === parts.length ? directory2 : void 0;
132250
132450
  }
132251
132451
  async function extractArtifactSnapshot(artifact, extractionDir, filter) {
132252
- await pipeline3(Readable2.from([artifact]), So({ cwd: extractionDir, strip: 1, strict: true, filter }));
132452
+ await pipeline4(Readable3.from([artifact]), So({ cwd: extractionDir, strip: 1, strict: true, filter }));
132253
132453
  }
132254
132454
  async function verifyLockedArtifact(artifact, extractionDir, release2) {
132255
132455
  mkdirSync19(extractionDir, { recursive: true, mode: 448 });
@@ -132269,15 +132469,15 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
132269
132469
  seen2.add(path3);
132270
132470
  return true;
132271
132471
  });
132272
- const manifestPath = join43(extractionDir, "package.json");
132273
- const lockPath = join43(extractionDir, "npm-shrinkwrap.json");
132472
+ const manifestPath = join44(extractionDir, "package.json");
132473
+ const lockPath = join44(extractionDir, "npm-shrinkwrap.json");
132274
132474
  let manifest;
132275
132475
  let lock;
132276
132476
  try {
132277
132477
  if (statSync7(lockPath).size > MAX_LOCKFILE_BYTES)
132278
132478
  throw new Error("lockfile too large");
132279
- manifest = JSON.parse(readFileSync39(manifestPath, "utf8"));
132280
- lock = JSON.parse(readFileSync39(lockPath, "utf8"));
132479
+ manifest = JSON.parse(readFileSync40(manifestPath, "utf8"));
132480
+ lock = JSON.parse(readFileSync40(lockPath, "utf8"));
132281
132481
  } catch (cause) {
132282
132482
  throw new Error(`the verified artifact has no readable npm-shrinkwrap dependency lock: ${message(cause)}`);
132283
132483
  }
@@ -132314,8 +132514,8 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
132314
132514
  }
132315
132515
  let bundledManifest;
132316
132516
  try {
132317
- const bundledPath = join43(extractionDir, ...lockPath2.split("/"), "package.json");
132318
- bundledManifest = JSON.parse(readFileSync39(bundledPath, "utf8"));
132517
+ const bundledPath = join44(extractionDir, ...lockPath2.split("/"), "package.json");
132518
+ bundledManifest = JSON.parse(readFileSync40(bundledPath, "utf8"));
132319
132519
  } catch (cause) {
132320
132520
  throw new Error(`the verified artifact has an unreadable bundled dependency ${lockPath2}: ${message(cause)}`);
132321
132521
  }
@@ -132385,10 +132585,10 @@ ${GITHUB_REPOSITORY_ID}`,
132385
132585
  // dist/commands/update.js
132386
132586
  import { spawn as spawn6 } from "node:child_process";
132387
132587
  import { randomBytes as randomBytes8 } from "node:crypto";
132388
- 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";
132588
+ import { closeSync as closeSync5, constants as constants2, fstatSync, mkdtempSync as mkdtempSync4, openSync as openSync5, readFileSync as readFileSync41, readSync, rmSync as rmSync15, unlinkSync as unlinkSync5, writeFileSync as writeFileSync25 } from "node:fs";
132389
132589
  import { createServer } from "node:http";
132390
132590
  import { tmpdir as tmpdir2 } from "node:os";
132391
- import { join as join44 } from "node:path";
132591
+ import { join as join45 } from "node:path";
132392
132592
  function refuse2(cause) {
132393
132593
  error(`Update refused: ${message2(cause)}.`);
132394
132594
  info(`To install the latest release with npm instead, run: ${teal(NPM_UPDATE_COMMAND)}`);
@@ -132396,7 +132596,7 @@ function refuse2(cause) {
132396
132596
  }
132397
132597
  function currentVersion2() {
132398
132598
  try {
132399
- const pkg = JSON.parse(readFileSync40(join44(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
132599
+ const pkg = JSON.parse(readFileSync41(join45(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
132400
132600
  return pkg.version;
132401
132601
  } catch {
132402
132602
  return "0.0.0";
@@ -132535,10 +132735,10 @@ async function serveArtifactSnapshot(artifact) {
132535
132735
  }
132536
132736
  async function installVerifiedTarball(tarballPath, tempDir, release2) {
132537
132737
  const ambientEnvironment = { ...process.env };
132538
- const packageDir = join44(tempDir, "authenticated-package");
132539
- const cacheDir = join44(tempDir, "empty-cache");
132540
- const userConfigPath = join44(tempDir, "user-npmrc");
132541
- const globalConfigPath = join44(tempDir, "global-npmrc");
132738
+ const packageDir = join45(tempDir, "authenticated-package");
132739
+ const cacheDir = join45(tempDir, "empty-cache");
132740
+ const userConfigPath = join45(tempDir, "user-npmrc");
132741
+ const globalConfigPath = join45(tempDir, "global-npmrc");
132542
132742
  writeFileSync25(userConfigPath, "", { mode: 384 });
132543
132743
  writeFileSync25(globalConfigPath, "", { mode: 384 });
132544
132744
  const artifact = snapshotAuthenticatedArtifact(tarballPath);
@@ -132610,8 +132810,8 @@ async function runUpdate(opts, dependencies = {}) {
132610
132810
  const provenance = await fetchJson(fetchImpl, release2.attestationUrl, "the official npm provenance endpoint");
132611
132811
  await (dependencies.verifyProvenance ?? verifyPublishedProvenance)(provenance, release2);
132612
132812
  const tarball = await downloadTarball(fetchImpl, release2);
132613
- tempDir = mkdtempSync4(join44(tmpdir2(), "somewhere-update-"));
132614
- const tarballPath = join44(tempDir, `cli-${release2.version}.tgz`);
132813
+ tempDir = mkdtempSync4(join45(tmpdir2(), "somewhere-update-"));
132814
+ const tarballPath = join45(tempDir, `cli-${release2.version}.tgz`);
132615
132815
  writeFileSync25(tarballPath, tarball, { mode: 384 });
132616
132816
  info(`Cryptographically verified provenance and integrity for ${CLI_PACKAGE}@${release2.version}.`);
132617
132817
  info(`Updating ${CLI_PACKAGE} from its authenticated dependency lock \u2026`);
@@ -132743,7 +132943,7 @@ var init_upgrade = __esm({
132743
132943
  });
132744
132944
 
132745
132945
  // dist/commands/call.js
132746
- import { readFileSync as readFileSync41 } from "node:fs";
132946
+ import { readFileSync as readFileSync42 } from "node:fs";
132747
132947
  function parseArguments(value, file) {
132748
132948
  if (value === void 0)
132749
132949
  return {};
@@ -132767,7 +132967,7 @@ function readCallArguments(jsonArgs, file) {
132767
132967
  }
132768
132968
  let text;
132769
132969
  try {
132770
- text = readFileSync41(file, "utf8");
132970
+ text = readFileSync42(file, "utf8");
132771
132971
  } catch (err) {
132772
132972
  const code = err?.code;
132773
132973
  throw new Error(`Could not read --file ${file}${code ? ` (${code})` : ""}. The requested tool was not called.`);
@@ -135043,9 +135243,9 @@ var init_form_auth = __esm({
135043
135243
  });
135044
135244
 
135045
135245
  // dist/lib/test-response-capture.js
135046
- import { randomUUID as randomUUID10 } from "node:crypto";
135246
+ import { randomUUID as randomUUID11 } from "node:crypto";
135047
135247
  function privateMarker() {
135048
- return "sw-test-" + randomUUID10();
135248
+ return "sw-test-" + randomUUID11();
135049
135249
  }
135050
135250
  function captureResponses(page) {
135051
135251
  const pending = [];
@@ -135092,11 +135292,11 @@ var init_test_response_capture = __esm({
135092
135292
  });
135093
135293
 
135094
135294
  // dist/lib/app-test.js
135095
- import { randomUUID as randomUUID11 } from "node:crypto";
135295
+ import { randomUUID as randomUUID12 } from "node:crypto";
135096
135296
  import { setDefaultResultOrder } from "node:dns";
135097
135297
  import { lookup } from "node:dns/promises";
135098
- import { existsSync as existsSync38, mkdirSync as mkdirSync20, readFileSync as readFileSync42, writeFileSync as writeFileSync26 } from "node:fs";
135099
- import { basename as basename9, dirname as dirname14, join as join45, relative as relative12, resolve as resolve24 } from "node:path";
135298
+ import { existsSync as existsSync38, mkdirSync as mkdirSync20, readFileSync as readFileSync43, writeFileSync as writeFileSync26 } from "node:fs";
135299
+ import { basename as basename10, dirname as dirname15, join as join46, relative as relative12, resolve as resolve24 } from "node:path";
135100
135300
  function launchOptions(extra = {}) {
135101
135301
  return { ...extra, args: ["--disable-features=AsyncDns", ...extra.args ?? []] };
135102
135302
  }
@@ -135146,10 +135346,10 @@ function undeployedChanges(root, projectId, preview = false) {
135146
135346
  return null;
135147
135347
  base = { project_id: record3.project_id, release_id: record3.preview_id, files: record3.files };
135148
135348
  } else {
135149
- const path3 = join45(root, ".somewhere", "base-files.json");
135349
+ const path3 = join46(root, ".somewhere", "base-files.json");
135150
135350
  if (!existsSync38(path3))
135151
135351
  return null;
135152
- base = JSON.parse(readFileSync42(path3, "utf8"));
135352
+ base = JSON.parse(readFileSync43(path3, "utf8"));
135153
135353
  }
135154
135354
  if (base.project_id !== projectId || !base.files)
135155
135355
  return null;
@@ -135314,12 +135514,12 @@ var init_app_test = __esm({
135314
135514
  const [ipv4First] = await Promise.all([testAddressOrder(target.origin), lookup(new URL(target.origin).hostname).catch(() => null)]);
135315
135515
  if (ipv4First)
135316
135516
  setDefaultResultOrder("ipv4first");
135317
- process.env.SW_TEST_RUN ??= randomUUID11();
135517
+ process.env.SW_TEST_RUN ??= randomUUID12();
135318
135518
  process.env.SW_TEST_ORIGIN = target.origin;
135319
135519
  for (const line of describeSweep(await sweepAccounts(control, root), "Before this script"))
135320
135520
  process.stderr.write(line + "\n");
135321
- const scriptName = process.argv[1] ? basename9(process.argv[1]).replace(/\.[cm]?[jt]s$/, "") : "app-check";
135322
- const app = new _AppTest(root, control, resolve24(root, options2.results ?? join45(".somewhere", `${scriptName}${preview ? "-preview" : ""}.json`)));
135521
+ const scriptName = process.argv[1] ? basename10(process.argv[1]).replace(/\.[cm]?[jt]s$/, "") : "app-check";
135522
+ const app = new _AppTest(root, control, resolve24(root, options2.results ?? join46(".somewhere", `${scriptName}${preview ? "-preview" : ""}.json`)));
135323
135523
  return app;
135324
135524
  }
135325
135525
  /** What this run tests: the project, environment, preview, origin and script. */
@@ -135501,7 +135701,7 @@ page ${i + 1}: ${state}`).join("");
135501
135701
  }
135502
135702
  const passed = this.checks.filter((check) => check.ok).length;
135503
135703
  const failed = this.checks.filter((check) => !check.ok && !check.skipped).length;
135504
- mkdirSync20(dirname14(this.resultsPath), { recursive: true });
135704
+ mkdirSync20(dirname15(this.resultsPath), { recursive: true });
135505
135705
  writeFileSync26(this.resultsPath, JSON.stringify({
135506
135706
  identity: this.identity(),
135507
135707
  origin: this.origin,
@@ -136092,8 +136292,8 @@ var init_reference_check_note = __esm({
136092
136292
 
136093
136293
  // dist/lib/test-scripts.js
136094
136294
  import { createRequire as createRequire10 } from "node:module";
136095
- 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";
136096
- import { dirname as dirname15, join as join46, relative as relative13, resolve as resolve25 } from "node:path";
136295
+ import { existsSync as existsSync39, mkdirSync as mkdirSync21, readFileSync as readFileSync44, readdirSync as readdirSync8, rmSync as rmSync17, statSync as statSync8, writeFileSync as writeFileSync27 } from "node:fs";
136296
+ import { dirname as dirname16, join as join47, relative as relative13, resolve as resolve25 } from "node:path";
136097
136297
  import { spawn as spawn7, spawnSync as spawnSync5 } from "node:child_process";
136098
136298
  function hasSpecFiles(root) {
136099
136299
  const walk2 = /* @__PURE__ */ __name((dir) => {
@@ -136102,24 +136302,24 @@ function hasSpecFiles(root) {
136102
136302
  for (const entry of readdirSync8(dir, { withFileTypes: true })) {
136103
136303
  if (entry.name === "node_modules" || entry.name.startsWith("."))
136104
136304
  continue;
136105
- const path3 = join46(dir, entry.name);
136305
+ const path3 = join47(dir, entry.name);
136106
136306
  if (entry.isDirectory() ? walk2(path3) : /\.spec\.ts$/.test(entry.name))
136107
136307
  return true;
136108
136308
  }
136109
136309
  return false;
136110
136310
  }, "walk");
136111
- return walk2(join46(root, "tests"));
136311
+ return walk2(join47(root, "tests"));
136112
136312
  }
136113
136313
  function listScripts(root, files) {
136114
136314
  if (files.length)
136115
136315
  return files.map((file) => relative13(root, resolve25(root, file)));
136116
- const dir = join46(root, "tests");
136316
+ const dir = join47(root, "tests");
136117
136317
  if (!existsSync39(dir))
136118
136318
  return [];
136119
- return readdirSync8(dir).filter((name) => isScript(name) && statSync8(join46(dir, name)).isFile()).sort().map((name) => join46("tests", name));
136319
+ return readdirSync8(dir).filter((name) => isScript(name) && statSync8(join47(dir, name)).isFile()).sort().map((name) => join47("tests", name));
136120
136320
  }
136121
136321
  function scriptBrowserEnv(root) {
136122
- const require6 = createRequire10(join46(root, "package.json"));
136322
+ const require6 = createRequire10(join47(root, "package.json"));
136123
136323
  let cli;
136124
136324
  try {
136125
136325
  cli = require6.resolve("@playwright/test/cli");
@@ -136130,7 +136330,7 @@ function scriptBrowserEnv(root) {
136130
136330
  const probe = spawnSync5(process.execPath, ["-e", "require(process.argv[1]).chromium.launch().then(b => b.close()).then(() => process.exit(0), () => process.exit(3))", require6.resolve("@playwright/test")], { env, stdio: "ignore" });
136131
136331
  if (probe.status === 0)
136132
136332
  return env;
136133
- env.PLAYWRIGHT_BROWSERS_PATH ??= join46(cliConfigDir(), "cache", "playwright");
136333
+ env.PLAYWRIGHT_BROWSERS_PATH ??= join47(cliConfigDir(), "cache", "playwright");
136134
136334
  process.stderr.write("Installing Playwright Chromium in the CLI cache (once).\n");
136135
136335
  const install = spawnSync5(process.execPath, [cli, "install", "chromium"], { stdio: "inherit", env });
136136
136336
  if (install.status !== 0)
@@ -136153,7 +136353,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
136153
136353
  env = testImportEnv(root, env);
136154
136354
  const results = [];
136155
136355
  for (const script of scripts) {
136156
- if (!existsSync39(join46(root, script))) {
136356
+ if (!existsSync39(join47(root, script))) {
136157
136357
  results.push({ script, ok: false, exitCode: 1, ms: 0, reason: "no such file" });
136158
136358
  continue;
136159
136359
  }
@@ -136162,8 +136362,8 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
136162
136362
  `);
136163
136363
  const started = performance.now();
136164
136364
  let output = "";
136165
- const handOver = join46(root, ".somewhere", "tests", `report-${results.length}.json`);
136166
- mkdirSync21(dirname15(handOver), { recursive: true });
136365
+ const handOver = join47(root, ".somewhere", "tests", `report-${results.length}.json`);
136366
+ mkdirSync21(dirname16(handOver), { recursive: true });
136167
136367
  rmSync17(handOver, { force: true });
136168
136368
  const askedForBrowserLog = /(^|,)\s*(pw:browser|pw:\*|\*)\s*(,|$)/.test(env.DEBUG ?? "");
136169
136369
  const childEnv = { ...env, SW_TEST_REPORT: handOver, DEBUG: askedForBrowserLog ? env.DEBUG : [env.DEBUG, "pw:browser"].filter(Boolean).join(",") };
@@ -136192,7 +136392,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
136192
136392
  stderrLines("", true);
136193
136393
  let report2 = null;
136194
136394
  try {
136195
- report2 = existsSync39(handOver) ? JSON.parse(readFileSync43(handOver, "utf8")) : null;
136395
+ report2 = existsSync39(handOver) ? JSON.parse(readFileSync44(handOver, "utf8")) : null;
136196
136396
  } catch {
136197
136397
  report2 = null;
136198
136398
  }
@@ -136225,20 +136425,20 @@ function describeScriptResults(results, options2 = {}) {
136225
136425
  return results.some((result) => result.browserCrashed) ? lines.map((line) => line.startsWith("Next: ") ? `Next: give the browser access as the FAIL line says, then run ${TEST_COMMAND} again.` : line) : lines;
136226
136426
  }
136227
136427
  function lastFailedScripts(root) {
136228
- const path3 = join46(root, LAST);
136428
+ const path3 = join47(root, LAST);
136229
136429
  if (!existsSync39(path3))
136230
136430
  return [];
136231
136431
  try {
136232
- return (JSON.parse(readFileSync43(path3, "utf8")).results ?? []).filter((r) => !r.ok).map((r) => r.script);
136432
+ return (JSON.parse(readFileSync44(path3, "utf8")).results ?? []).filter((r) => !r.ok).map((r) => r.script);
136233
136433
  } catch {
136234
136434
  return [];
136235
136435
  }
136236
136436
  }
136237
136437
  function recordScriptResults(root, results, rerunOnly) {
136238
- const previous = rerunOnly && existsSync39(join46(root, LAST)) ? JSON.parse(readFileSync43(join46(root, LAST), "utf8")).results ?? [] : [];
136438
+ const previous = rerunOnly && existsSync39(join47(root, LAST)) ? JSON.parse(readFileSync44(join47(root, LAST), "utf8")).results ?? [] : [];
136239
136439
  const merged = [...previous.filter((p2) => !results.some((r) => r.script === p2.script)), ...results];
136240
- mkdirSync21(join46(root, ".somewhere", "tests"), { recursive: true });
136241
- writeFileSync27(join46(root, LAST), JSON.stringify({ finished: (/* @__PURE__ */ new Date()).toISOString(), results: merged }, null, 2) + "\n");
136440
+ mkdirSync21(join47(root, ".somewhere", "tests"), { recursive: true });
136441
+ writeFileSync27(join47(root, LAST), JSON.stringify({ finished: (/* @__PURE__ */ new Date()).toISOString(), results: merged }, null, 2) + "\n");
136242
136442
  }
136243
136443
  var BROWSER_CRASH, BROWSER_CRASH_REASON, isScript, LAST;
136244
136444
  var init_test_scripts = __esm({
@@ -136256,7 +136456,7 @@ var init_test_scripts = __esm({
136256
136456
  __name(failureReason, "failureReason");
136257
136457
  __name(runScripts, "runScripts");
136258
136458
  __name(describeScriptResults, "describeScriptResults");
136259
- LAST = join46(".somewhere", "tests", "scripts-last.json");
136459
+ LAST = join47(".somewhere", "tests", "scripts-last.json");
136260
136460
  __name(lastFailedScripts, "lastFailedScripts");
136261
136461
  __name(recordScriptResults, "recordScriptResults");
136262
136462
  }
@@ -136264,7 +136464,7 @@ var init_test_scripts = __esm({
136264
136464
 
136265
136465
  // dist/commands/test.js
136266
136466
  function registerTest(program2) {
136267
- program2.command("test [files...]").description("Read the deployed app's smoke check. It checks the built-in data path, pages and saved browser flows, and reports function errors with evidence. Use @somewhere-cloud/cli/testing for your own app tests. A named file runs that script.").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("--only <check>", "Run just access, crawl, or one saved check, e.g. checks/add-note.json").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) => {
136467
+ program2.command("test [files...]").description("Run the deployed app's checks: your check lists in checks/*.json (requests as named test users the platform makes), saved browser flows, and the platform's own access and page checks. Prints PASS or FAIL per step with the request ID. A named file runs that script.").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("--only <check>", "Run just access, crawl, or one saved check, e.g. checks/add-note.json").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", '\nWrite what to prove as a check list in checks/<name>.json: {"users": ["alice", "bob"], "steps": [{"as": "bob", "delete": "/api/tasks/{task}", "expect": 403}]}. The platform runs every checks/*.json after each deploy and `somewhere test` reads the latest result; --again starts a fresh run and --only checks/<name>.json runs one. See somewhere docs test. The last line of a platform run is JSON with outcome and counts.\n').action(async (files, opts) => {
136268
136468
  markProcessStart("cli");
136269
136469
  mark("cli:action");
136270
136470
  if (opts.url)
@@ -136351,8 +136551,8 @@ var init_test = __esm({
136351
136551
  });
136352
136552
 
136353
136553
  // dist/commands/test-users.js
136354
- import { existsSync as existsSync40, readFileSync as readFileSync44, rmSync as rmSync18 } from "node:fs";
136355
- import { basename as basename10, join as join47 } from "node:path";
136554
+ import { existsSync as existsSync40, readFileSync as readFileSync45, rmSync as rmSync18 } from "node:fs";
136555
+ import { basename as basename11, join as join48 } from "node:path";
136356
136556
  import { randomBytes as randomBytes9 } from "node:crypto";
136357
136557
  async function resolveTarget(projectOpt, originOpt) {
136358
136558
  const root = process.cwd();
@@ -136453,7 +136653,7 @@ function registerTestUsers(program2) {
136453
136653
  const record3 = /* @__PURE__ */ __name((spec, issued, receivedAt) => {
136454
136654
  const times = expiryOf(issued, receivedAt);
136455
136655
  const file = `${spec.name}.state.json`;
136456
- writePrivateFile(join47(dir, file), JSON.stringify(buildStorageState(target.origin, target.host, issued, times), null, 2) + "\n");
136656
+ writePrivateFile(join48(dir, file), JSON.stringify(buildStorageState(target.origin, target.host, issued, times), null, 2) + "\n");
136457
136657
  const actor = {
136458
136658
  name: spec.name,
136459
136659
  user_id: issued.user.id,
@@ -136551,11 +136751,11 @@ function registerTestUsers(program2) {
136551
136751
  if (opts.linkOut) {
136552
136752
  if (!newest.magic_link)
136553
136753
  throw Object.assign(new Error("The newest message has no magic link."), { code: "NO_MAGIC_LINK" });
136554
- const name = basename10(opts.linkOut);
136754
+ const name = basename11(opts.linkOut);
136555
136755
  if (name !== opts.linkOut || !/^[A-Za-z0-9._-]{1,64}$/.test(name))
136556
136756
  throw new Error(`--link-out takes a file name; it is written under ${TEST_STATE_DIR}/.`);
136557
136757
  ensurePrivateDir(stateDir(target.root));
136558
- writePrivateFile(join47(stateDir(target.root), name), newest.magic_link + "\n");
136758
+ writePrivateFile(join48(stateDir(target.root), name), newest.magic_link + "\n");
136559
136759
  linkFile = `${TEST_STATE_DIR}/${name}`;
136560
136760
  }
136561
136761
  const message3 = {
@@ -136626,12 +136826,12 @@ function registerTestUsers(program2) {
136626
136826
  local_state: { removed: localRemoved, kept: manifest.actors.map((actor) => actor.state_file).filter((file) => !localRemoved.includes(file)) },
136627
136827
  actors: manifest.actors.map(({ name, user_id, email: email2, role, created_at }) => ({ name, user_id, email: email2, role, created_at }))
136628
136828
  };
136629
- writePrivateFile(join47(stateDir(target.root), CLEANUP_RECEIPT_FILE), JSON.stringify(receipt, null, 2) + "\n");
136829
+ writePrivateFile(join48(stateDir(target.root), CLEANUP_RECEIPT_FILE), JSON.stringify(receipt, null, 2) + "\n");
136630
136830
  const left = manifest.actors.filter((actor) => !removed.includes(actor.user_id));
136631
136831
  if (left.length)
136632
136832
  writeManifest(target.root, { ...manifest, actors: left, status: "partial" });
136633
136833
  else
136634
- rmSync18(join47(stateDir(target.root), MANIFEST_FILE), { force: true });
136834
+ rmSync18(join48(stateDir(target.root), MANIFEST_FILE), { force: true });
136635
136835
  if (opts.json) {
136636
136836
  printJson(receipt);
136637
136837
  if (left.length)
@@ -136671,7 +136871,7 @@ var init_test_users = __esm({
136671
136871
  });
136672
136872
 
136673
136873
  // dist/commands/support.js
136674
- import { join as join48 } from "node:path";
136874
+ import { join as join49 } from "node:path";
136675
136875
  function commandPaths(program2) {
136676
136876
  const paths = /* @__PURE__ */ new Set();
136677
136877
  const walk2 = /* @__PURE__ */ __name((command, prefix) => {
@@ -136756,7 +136956,7 @@ function emitPacket(packet, opts) {
136756
136956
  if (opts.out) {
136757
136957
  if (!/^[A-Za-z0-9._-]{1,64}$/.test(opts.out))
136758
136958
  throw new Error("--out takes a plain file name in the current folder.");
136759
- writePrivateFile(join48(process.cwd(), opts.out), JSON.stringify(packet, null, 2) + "\n");
136959
+ writePrivateFile(join49(process.cwd(), opts.out), JSON.stringify(packet, null, 2) + "\n");
136760
136960
  }
136761
136961
  if (opts.json) {
136762
136962
  printJson(packet);
@@ -136878,7 +137078,7 @@ var init_skills = __esm({
136878
137078
  });
136879
137079
 
136880
137080
  // dist/commands/ai.js
136881
- import { readFileSync as readFileSync45 } from "node:fs";
137081
+ import { readFileSync as readFileSync46 } from "node:fs";
136882
137082
  function fail4(message3) {
136883
137083
  error(message3);
136884
137084
  process.exit(1);
@@ -136899,7 +137099,7 @@ async function readKey(stdin) {
136899
137099
  if (stdin) {
136900
137100
  if (process.stdin.isTTY)
136901
137101
  fail4("Pipe the key into --stdin, or leave out --stdin to type it into a hidden prompt.");
136902
- raw = readFileSync45(0, "utf8");
137102
+ raw = readFileSync46(0, "utf8");
136903
137103
  } else {
136904
137104
  if (!process.stdin.isTTY)
136905
137105
  fail4("Pass --stdin to read the key from a pipe. Nothing was sent.");
@@ -137047,10 +137247,10 @@ var init_startup_notice = __esm({
137047
137247
 
137048
137248
  // dist/lib/last-run.js
137049
137249
  import { lstatSync as lstatSync6, mkdirSync as mkdirSync22, renameSync as renameSync7, unlinkSync as unlinkSync6, writeFileSync as writeFileSync28 } from "node:fs";
137050
- import { join as join49 } from "node:path";
137250
+ import { join as join50 } from "node:path";
137051
137251
  function removeStaleRunRecord(dir = cliConfigDir()) {
137052
137252
  for (const name of RUN_RECORD_FILES) {
137053
- const path3 = join49(dir, name);
137253
+ const path3 = join50(dir, name);
137054
137254
  try {
137055
137255
  if (lstatSync6(path3).isDirectory()) {
137056
137256
  process.stderr.write(`Could not remove ${path3}: it is a directory, not this CLI's run record. Check it yourself.
@@ -137090,8 +137290,8 @@ function recordLastRun(cliVersion) {
137090
137290
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
137091
137291
  cli_version: cliVersion
137092
137292
  };
137093
- const path3 = join49(dir, "last-run.json");
137094
- const temporary = join49(dir, "last-run.json.tmp");
137293
+ const path3 = join50(dir, "last-run.json");
137294
+ const temporary = join50(dir, "last-run.json.tmp");
137095
137295
  writeFileSync28(temporary, JSON.stringify(record3) + "\n", { mode: 384 });
137096
137296
  renameSync7(temporary, path3);
137097
137297
  } catch {
@@ -137129,8 +137329,8 @@ __export(dist_exports, {
137129
137329
  runCli: () => runCli
137130
137330
  });
137131
137331
  import { spawnSync as spawnSync6 } from "node:child_process";
137132
- import { readFileSync as readFileSync46 } from "node:fs";
137133
- import { join as join50 } from "node:path";
137332
+ import { readFileSync as readFileSync47 } from "node:fs";
137333
+ import { join as join51 } from "node:path";
137134
137334
  async function runCli() {
137135
137335
  const pinned = decidePin(process.cwd(), CLI_VERSION2, process.argv, process.env);
137136
137336
  if (pinned.notice)
@@ -137158,7 +137358,7 @@ async function runCli() {
137158
137358
  process.exit(child.status ?? 1);
137159
137359
  }
137160
137360
  removeStaleRunRecord();
137161
- const pkg = JSON.parse(readFileSync46(join50(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
137361
+ const pkg = JSON.parse(readFileSync47(join51(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
137162
137362
  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);
137163
137363
  recordLastRun(pkg.version);
137164
137364
  const jsonOutputRequested = process.argv.includes("--json");
@@ -137576,7 +137776,7 @@ var init_screenshot_guard = __esm({
137576
137776
 
137577
137777
  // dist/lib/playwright-fixtures.js
137578
137778
  import { createRequire as createRequire11 } from "node:module";
137579
- import { join as join51 } from "node:path";
137779
+ import { join as join52 } from "node:path";
137580
137780
  function waitOnNavigation(page) {
137581
137781
  async function wait(options2) {
137582
137782
  if (options2?.waitUntil === "commit")
@@ -137628,7 +137828,7 @@ async function previewControlForWorker() {
137628
137828
  function runner() {
137629
137829
  if (loaded)
137630
137830
  return loaded;
137631
- const require6 = createRequire11(join51(process.cwd(), "package.json"));
137831
+ const require6 = createRequire11(join52(process.cwd(), "package.json"));
137632
137832
  let pw;
137633
137833
  try {
137634
137834
  pw = require6("@playwright/test");