@somewhere-cloud/cli 0.38.163 → 0.38.165

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) => {
@@ -43339,7 +43339,7 @@ function registerAuth(program2) {
43339
43339
  if (!config2.temporary)
43340
43340
  info(`Token: ${config2.token.slice(0, 8)}\u2026${config2.token.slice(-4)}`);
43341
43341
  });
43342
- auth2.command("export [project]").description("Export portable end-user password credentials after verified-owner email approval").option("--project <ref>", "Project ID, name, slug, or subdomain (defaults to the linked project)").requiredOption("--output <path>", "New local JSON file to create (existing paths are never overwritten)").allowExcessArguments(false).showHelpAfterError("The approval code is read from a hidden prompt or stdin; never pass it as an argument.").action(async (project, opts) => {
43342
+ auth2.command("export [project]").description(PASSWORD_EXPORT_REQUEST).option("--project <ref>", "Project ID, name, slug, or subdomain (defaults to the linked project)").requiredOption("--output <path>", "New local JSON file to create (existing paths are never overwritten)").allowExcessArguments(false).action(async (project, opts) => {
43343
43343
  let outputFd = null;
43344
43344
  let outputCreated = false;
43345
43345
  let wroteOutput = false;
@@ -43404,7 +43404,11 @@ function registerAuth(program2) {
43404
43404
  } catch {
43405
43405
  }
43406
43406
  }
43407
- error(err instanceof Error ? err.message : String(err), err);
43407
+ if (err instanceof CliApiError && err.statusCode === 501 && err.code === "AUTH_FEATURE_UNAVAILABLE") {
43408
+ error(PASSWORD_EXPORT_REQUEST, void 0, err);
43409
+ } else {
43410
+ error(err instanceof Error ? err.message : String(err), err);
43411
+ }
43408
43412
  process.exitCode = 1;
43409
43413
  }
43410
43414
  });
@@ -43595,7 +43599,7 @@ async function runBrowserCallbackLogin() {
43595
43599
  process.exit(1);
43596
43600
  }
43597
43601
  }
43598
- var import_prompts, SIGNUP_URL, SIGNUP_HINT;
43602
+ var import_prompts, PASSWORD_EXPORT_REQUEST, SIGNUP_URL, SIGNUP_HINT;
43599
43603
  var init_auth2 = __esm({
43600
43604
  "dist/commands/auth.js"() {
43601
43605
  "use strict";
@@ -43611,6 +43615,7 @@ var init_auth2 = __esm({
43611
43615
  init_next_actions();
43612
43616
  init_output();
43613
43617
  init_platform_command();
43618
+ PASSWORD_EXPORT_REQUEST = "The app's owner can request password hashes at migration@somewhere.cloud.";
43614
43619
  __name(readAuthToken, "readAuthToken");
43615
43620
  __name(readPasswordExportCode, "readPasswordExportCode");
43616
43621
  __name(createProtectedOutput, "createProtectedOutput");
@@ -44234,7 +44239,7 @@ var init_init_agent_guide = __esm({
44234
44239
  | Does your app verify emails? | Choose the declared access rule |
44235
44240
  | --- | --- |
44236
44241
  | Yes, invited teams | Use \`group()\` and \`sw.groups\` for invitations, membership and owner/admin permissions. See \`somewhere docs sw.groups --section team-example\`. |
44237
- | No, app-managed teams | Use \`member()\` over a server-only roster. Declare author-or-team-owner delete with \`anyOf()\` and a role-filtered branch. See \`somewhere docs declared-data --section teams-without-email-verification\`. |
44242
+ | No, app-managed teams | Use \`member()\` over a server-only roster. Add \`deleteWhere: { role: 'owner' }\` to reserve deletion for team owners on a standalone \`member()\` rule. For author-or-team-owner deletion, check either permission in a server endpoint before deleting. See \`somewhere docs declared-data --section teams-without-email-verification\`. |
44238
44243
  | Yes, staff by domain | Use \`appRole()\` and \`appRoles: { staff: { emailDomain: 'staff.example' } }\`. The address must be verified. |
44239
44244
  | No, staff by invitation | Use \`appRole()\` and \`assignedBy: 'server'\`. Redeem an app-issued invitation and call \`sw.auth.server.setRoles\` inside the sign-up route. See \`somewhere docs sw.auth --section server-assigned-app-roles-setroles\`. |
44240
44245
  | Either, personal rows | Use \`owner()\`. The platform stamps the owner from the signed-in user. |
@@ -44266,6 +44271,15 @@ Use \`client.intake\` for public submissions to a private parent row. See
44266
44271
 
44267
44272
  ### Run and verify
44268
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\`.
44282
+
44269
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\`.
44270
44284
 
44271
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\`.
@@ -75176,10 +75190,10 @@ var init_esm3 = __esm({
75176
75190
  }
75177
75191
  async _formatEntry(dirent, path3) {
75178
75192
  let entry;
75179
- const basename11 = this._isDirent ? dirent.name : dirent;
75193
+ const basename12 = this._isDirent ? dirent.name : dirent;
75180
75194
  try {
75181
- const fullPath = presolve(pjoin(path3, basename11));
75182
- entry = { path: prelative(this._root, fullPath), fullPath, basename: basename11 };
75195
+ const fullPath = presolve(pjoin(path3, basename12));
75196
+ entry = { path: prelative(this._root, fullPath), fullPath, basename: basename12 };
75183
75197
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
75184
75198
  } catch (err) {
75185
75199
  this._onError(err);
@@ -75712,9 +75726,9 @@ var init_handler = __esm({
75712
75726
  _watchWithNodeFs(path3, listener) {
75713
75727
  const opts = this.fsw.options;
75714
75728
  const directory2 = sysPath.dirname(path3);
75715
- const basename11 = sysPath.basename(path3);
75729
+ const basename12 = sysPath.basename(path3);
75716
75730
  const parent = this.fsw._getWatchedDir(directory2);
75717
- parent.add(basename11);
75731
+ parent.add(basename12);
75718
75732
  const absolutePath = sysPath.resolve(path3);
75719
75733
  const options2 = {
75720
75734
  persistent: opts.persistent
@@ -75724,7 +75738,7 @@ var init_handler = __esm({
75724
75738
  let closer;
75725
75739
  if (opts.usePolling) {
75726
75740
  const enableBin = opts.interval !== opts.binaryInterval;
75727
- options2.interval = enableBin && isBinaryPath(basename11) ? opts.binaryInterval : opts.interval;
75741
+ options2.interval = enableBin && isBinaryPath(basename12) ? opts.binaryInterval : opts.interval;
75728
75742
  closer = setFsWatchFileListener(path3, absolutePath, options2, {
75729
75743
  listener,
75730
75744
  rawEmitter: this.fsw._emitRaw
@@ -75746,11 +75760,11 @@ var init_handler = __esm({
75746
75760
  if (this.fsw.closed) {
75747
75761
  return;
75748
75762
  }
75749
- const dirname16 = sysPath.dirname(file);
75750
- const basename11 = sysPath.basename(file);
75751
- const parent = this.fsw._getWatchedDir(dirname16);
75763
+ const dirname17 = sysPath.dirname(file);
75764
+ const basename12 = sysPath.basename(file);
75765
+ const parent = this.fsw._getWatchedDir(dirname17);
75752
75766
  let prevStats = stats;
75753
- if (parent.has(basename11))
75767
+ if (parent.has(basename12))
75754
75768
  return;
75755
75769
  const listener = /* @__PURE__ */ __name(async (path3, newStats) => {
75756
75770
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
@@ -75775,9 +75789,9 @@ var init_handler = __esm({
75775
75789
  prevStats = newStats2;
75776
75790
  }
75777
75791
  } catch (error3) {
75778
- this.fsw._remove(dirname16, basename11);
75792
+ this.fsw._remove(dirname17, basename12);
75779
75793
  }
75780
- } else if (parent.has(basename11)) {
75794
+ } else if (parent.has(basename12)) {
75781
75795
  const at2 = newStats.atimeMs;
75782
75796
  const mt2 = newStats.mtimeMs;
75783
75797
  if (!at2 || at2 <= mt2 || mt2 !== prevStats.mtimeMs) {
@@ -84337,16 +84351,16 @@ function formatLinkedProjectMismatchExplanation(linkedProjectId, ref, resolvedPr
84337
84351
  "Next steps:",
84338
84352
  ` Deploy this folder to its linked project: run \`${cliInvocation()} deploy\` (no --project).`,
84339
84353
  ` Work on ${ref}: run \`${cliInvocation()} pull ${shellQuote(ref)} --out <fresh-folder>\`, re-apply your changes there, then run \`${cliInvocation()} deploy\`.`,
84340
- ` Deploy a copy elsewhere: copy the files into an unlinked folder and run \`${cliInvocation()} deploy --project ${ref}\` there.`
84354
+ ` Replace ${ref} with these files on purpose: copy them into an unlinked folder and run \`${cliInvocation()} deploy --project ${ref} --force --yes\` there.`
84341
84355
  ].join("\n");
84342
84356
  }
84343
84357
  function formatExplicitProjectBaseRequiredExplanation(ref) {
84344
84358
  return [
84345
- `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.`,
84359
+ `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.`,
84346
84360
  "",
84347
84361
  "Next steps:",
84348
- ` Start with \`${cliInvocation()} pull ${shellQuote(ref)} --out <fresh-folder>\`, re-apply your changes there, then run \`${cliInvocation()} deploy\`.`,
84349
- ` Or replace the live release deliberately: \`${cliInvocation()} deploy --project ${ref} --force --yes\`.`
84362
+ ` 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\`.`,
84363
+ ` To replace the live app with this folder's files on purpose: \`${cliInvocation()} deploy --project ${ref} --force --yes\`.`
84350
84364
  ].join("\n");
84351
84365
  }
84352
84366
  function startDeployPrestart(client, projectId) {
@@ -84854,8 +84868,10 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
84854
84868
  // Sending the on-disk static under scope:functions is what bricked
84855
84869
  // compiled SPAs; the worker now ignores it too, but
84856
84870
  // the CLI shouldn't send it in the first place. --scope static is the
84857
- // inverse: no functions.
84858
- files: scope === "functions" ? {} : files
84871
+ // inverse: no functions. The dependency manifest is the functions'
84872
+ // too: a backend change that adds a package sends package.json (and
84873
+ // its lockfile), so the platform builds against the new dependencies.
84874
+ files: scope === "functions" ? functionDependencyManifest(files) : files
84859
84875
  };
84860
84876
  if (scope !== "functions" && Object.keys(binaryFiles).length > 0) {
84861
84877
  body.binary_files = binaryFiles;
@@ -84883,8 +84899,8 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
84883
84899
  body.base_release_id = sourceBase.releaseId;
84884
84900
  } else if (!opts.force && explicitProjectId) {
84885
84901
  const liveBase = earlyLiveBase?.projectId === explicitProjectId ? await earlyLiveBase.read : await readExplicitProjectLiveBase(client, explicitProjectId);
84886
- if (liveBase !== void 0)
84887
- body.base_release_id = liveBase;
84902
+ if (liveBase === null)
84903
+ body.base_release_id = null;
84888
84904
  }
84889
84905
  body.source = "cli";
84890
84906
  if (opts.force)
@@ -85565,6 +85581,9 @@ function formatDryRunNeedsProjectExplanation() {
85565
85581
  `To deploy for real (signed out, this starts a temporary workspace): \`${cliInvocation()} deploy\`.`
85566
85582
  ].join("\n");
85567
85583
  }
85584
+ function functionDependencyManifest(files) {
85585
+ return Object.fromEntries(["package.json", "package-lock.json", "npm-shrinkwrap.json"].filter((path3) => typeof files[path3] === "string").map((path3) => [path3, files[path3]]));
85586
+ }
85568
85587
  function printDryRun(plan, scope) {
85569
85588
  const scopeNote = scope === "functions" ? " (scope: functions \u2014 static unchanged)" : scope === "static" ? " (scope: static \u2014 functions unchanged)" : "";
85570
85589
  console.log(`
@@ -85740,6 +85759,7 @@ var init_deploy = __esm({
85740
85759
  __name(printLocalOmissionsToStderr, "printLocalOmissionsToStderr");
85741
85760
  __name(printSensitiveFiles, "printSensitiveFiles");
85742
85761
  __name(formatDryRunNeedsProjectExplanation, "formatDryRunNeedsProjectExplanation");
85762
+ __name(functionDependencyManifest, "functionDependencyManifest");
85743
85763
  __name(printDryRun, "printDryRun");
85744
85764
  }
85745
85765
  });
@@ -86847,7 +86867,62 @@ var init_db_rows = __esm({
86847
86867
  });
86848
86868
 
86849
86869
  // dist/commands/db.js
86850
- import { writeFileSync as writeFileSync20 } from "node:fs";
86870
+ import { createWriteStream as createWriteStream2, writeFileSync as writeFileSync20 } from "node:fs";
86871
+ import { rename, unlink } from "node:fs/promises";
86872
+ import { randomUUID as randomUUID7 } from "node:crypto";
86873
+ import { basename as basename7, dirname as dirname13, join as join36 } from "node:path";
86874
+ import { Readable as Readable2 } from "node:stream";
86875
+ import { pipeline as pipeline2 } from "node:stream/promises";
86876
+ async function backgroundExport(client, projectId, plane, output, json, spinner) {
86877
+ if (json && !output)
86878
+ throw new Error("This database is exported in the background as a file: pass --output <file> with --json.");
86879
+ const wanted = plane ?? "raw";
86880
+ if (spinner)
86881
+ spinner.text = "The database is larger than one dump response; exporting it in the background\u2026";
86882
+ let current;
86883
+ try {
86884
+ current = (await client.call("POST", "/db/exports", { project_id: projectId, ...plane ? { plane } : {} })).export;
86885
+ } catch (err) {
86886
+ if (err instanceof CliApiError && err.statusCode === 404 && err.code === "NOT_FOUND")
86887
+ return false;
86888
+ throw err;
86889
+ }
86890
+ while (current.state === "running") {
86891
+ await new Promise((resolve27) => setTimeout(resolve27, 3e3));
86892
+ current = (await client.call("GET", `/db/exports/${encodeURIComponent(current.id)}`, void 0, { project_id: projectId })).export;
86893
+ if (spinner)
86894
+ spinner.text = `Exporting in the background: ${current.rows.toLocaleString()} rows, ${sizeText(current.size_bytes)} so far\u2026`;
86895
+ }
86896
+ if (current.state !== "ready")
86897
+ throw new Error(current.detail ?? `The export ended ${current.state}.`);
86898
+ if ((current.plane ?? "raw") !== wanted)
86899
+ throw new Error(`The platform returned an export of the ${current.plane} tables, not the ${wanted} ones. Nothing was written.`);
86900
+ const response = await client.callStream("GET", `/db/exports/${encodeURIComponent(current.id)}/sql?project_id=${encodeURIComponent(projectId)}`, void 0, { timeoutMs: 4 * 60 * 6e4 });
86901
+ if (!response.ok || !response.body)
86902
+ throw new Error(`Downloading the export failed (HTTP ${response.status}).`);
86903
+ const body = Readable2.fromWeb(response.body);
86904
+ if (output) {
86905
+ const temp = join36(dirname13(output), `.${basename7(output)}.${randomUUID7()}.tmp`);
86906
+ try {
86907
+ await pipeline2(body, createWriteStream2(temp, { flags: "wx", mode: 384 }));
86908
+ await rename(temp, output);
86909
+ } catch (err) {
86910
+ await unlink(temp).catch(() => void 0);
86911
+ throw err;
86912
+ }
86913
+ } else {
86914
+ spinner?.stop();
86915
+ await pipeline2(body, process.stdout, { end: false });
86916
+ }
86917
+ const summary = `${current.tables} tables, ${current.rows} rows, ${sizeText(current.size_bytes)}${current.consistency ? `. ${current.consistency}` : ""}`;
86918
+ if (json)
86919
+ printJson({ export: current, output });
86920
+ else if (output)
86921
+ spinner?.succeed(`Wrote ${output} (${summary})`);
86922
+ else
86923
+ process.stderr.write(dim(summary) + "\n");
86924
+ return true;
86925
+ }
86851
86926
  function registerDb(program2) {
86852
86927
  const db = program2.command("db").description("Inspect managed production rows or run SQL against your raw database");
86853
86928
  registerDbRows(db);
@@ -86938,6 +87013,16 @@ function registerDb(program2) {
86938
87013
  ...opts.plane ? { plane: opts.plane } : {}
86939
87014
  });
86940
87015
  if (!res.ok) {
87016
+ let refused = null;
87017
+ try {
87018
+ refused = JSON.parse(res.body);
87019
+ } catch {
87020
+ refused = null;
87021
+ }
87022
+ 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 ?? "")) {
87023
+ if (await backgroundExport(client, projectId, opts.plane, opts.output, Boolean(opts.json), spinner))
87024
+ return;
87025
+ }
86941
87026
  spinner?.fail("Dump failed");
86942
87027
  try {
86943
87028
  const json = JSON.parse(res.body);
@@ -86959,7 +87044,7 @@ function registerDb(program2) {
86959
87044
  process.exit(1);
86960
87045
  }
86961
87046
  if (opts.output)
86962
- writeFileSync20(opts.output, res.body);
87047
+ writeFileSync20(opts.output, res.body, { mode: 384 });
86963
87048
  else
86964
87049
  process.stdout.write(res.body + "\n");
86965
87050
  return;
@@ -86980,7 +87065,7 @@ function registerDb(program2) {
86980
87065
  truncated_tables: truncated ?? null
86981
87066
  };
86982
87067
  if (opts.output) {
86983
- writeFileSync20(opts.output, sql);
87068
+ writeFileSync20(opts.output, sql, { mode: 384 });
86984
87069
  if (opts.json) {
86985
87070
  printJson(dumpResult);
86986
87071
  } else {
@@ -87004,6 +87089,81 @@ function registerDb(program2) {
87004
87089
  process.exit(1);
87005
87090
  }
87006
87091
  });
87092
+ 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) => {
87093
+ if (opts.take && opts.delete) {
87094
+ error("Use --take or --delete, not both.");
87095
+ process.exit(1);
87096
+ }
87097
+ let projectId = opts.project;
87098
+ if (!projectId) {
87099
+ const config2 = loadProjectConfig();
87100
+ if (!config2) {
87101
+ error("No project specified and no .somewhere.json found. Pass --project <id>." + unlinkedFolderHint());
87102
+ process.exit(1);
87103
+ }
87104
+ projectId = config2.project_id;
87105
+ }
87106
+ const size = /* @__PURE__ */ __name((n) => n >= 1e6 ? `${(n / 1e6).toFixed(1)} MB` : `${Math.max(1, Math.round(n / 1e3))} KB`, "size");
87107
+ const client = new ApiClient(getToken());
87108
+ try {
87109
+ if (opts.take) {
87110
+ const spinner = opts.json ? null : ora("Taking a restore point\u2026").start();
87111
+ let point = (await client.call("POST", "/db/restore-points", { project_id: projectId })).restore_point;
87112
+ for (let waited = 0; point.state === "running" && waited < 30 * 6e4; waited += 3e3) {
87113
+ await new Promise((resolve27) => setTimeout(resolve27, 3e3));
87114
+ const listed = await client.call("GET", "/db/restore-points", void 0, { project_id: projectId });
87115
+ point = listed.restore_points.find((p2) => p2.id === point.id) ?? { ...point, state: "failed", detail: "It is no longer listed." };
87116
+ if (spinner)
87117
+ spinner.text = `Taking a restore point\u2026 ${point.rows.toLocaleString()} rows so far`;
87118
+ }
87119
+ if (opts.json) {
87120
+ printJson({ restore_point: point });
87121
+ if (point.state !== "ready")
87122
+ process.exitCode = 1;
87123
+ return;
87124
+ }
87125
+ if (point.state === "running") {
87126
+ spinner?.succeed(`Restore point ${point.id} is still being taken; \`${cliInvocation()} db restore-points\` shows when it is ready.`);
87127
+ return;
87128
+ }
87129
+ if (point.state !== "ready") {
87130
+ spinner?.fail(`No restore point was taken: ${point.detail ?? point.state}`);
87131
+ process.exitCode = 1;
87132
+ return;
87133
+ }
87134
+ spinner?.succeed(`Restore point ${point.id} taken (${size(point.size_bytes)}, ${point.tables} tables, ${point.rows} rows); kept until ${point.expires_at}.`);
87135
+ for (const line of [point.consistency, point.validation])
87136
+ if (line)
87137
+ info(dim(line));
87138
+ return;
87139
+ }
87140
+ if (opts.delete) {
87141
+ const r2 = await client.call("DELETE", `/db/restore-points/${encodeURIComponent(opts.delete)}`, void 0, { project_id: projectId });
87142
+ if (opts.json) {
87143
+ printJson(r2);
87144
+ return;
87145
+ }
87146
+ success(`Deleted restore point ${r2.deleted}.`);
87147
+ return;
87148
+ }
87149
+ const r = await client.call("GET", "/db/restore-points", void 0, { project_id: projectId });
87150
+ if (opts.json) {
87151
+ printJson(r);
87152
+ return;
87153
+ }
87154
+ if (!r.restore_points.length) {
87155
+ 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.`));
87156
+ return;
87157
+ }
87158
+ 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]));
87159
+ for (const p2 of r.restore_points)
87160
+ if (p2.state === "ready" && p2.consistency && p2.consistency !== "Read in one moment: an exact copy.")
87161
+ info(dim(`${p2.id}: ${p2.consistency}`));
87162
+ } catch (err) {
87163
+ error(err instanceof Error ? err.message : String(err), err);
87164
+ process.exit(1);
87165
+ }
87166
+ });
87007
87167
  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) => {
87008
87168
  const client = new ApiClient(getToken());
87009
87169
  let projectId = opts.project;
@@ -87033,6 +87193,7 @@ function registerDb(program2) {
87033
87193
  }
87034
87194
  });
87035
87195
  }
87196
+ var sizeText;
87036
87197
  var init_db = __esm({
87037
87198
  "dist/commands/db.js"() {
87038
87199
  "use strict";
@@ -87043,6 +87204,8 @@ var init_db = __esm({
87043
87204
  init_config();
87044
87205
  init_output();
87045
87206
  init_link_hint();
87207
+ sizeText = /* @__PURE__ */ __name((n) => n >= 1e6 ? `${(n / 1e6).toFixed(1)} MB` : `${Math.max(1, Math.round(n / 1e3))} KB`, "sizeText");
87208
+ __name(backgroundExport, "backgroundExport");
87046
87209
  __name(registerDb, "registerDb");
87047
87210
  }
87048
87211
  });
@@ -87387,16 +87550,16 @@ var init_postgres = __esm({
87387
87550
 
87388
87551
  // dist/lib/local-docs.js
87389
87552
  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";
87390
- import { join as join36 } from "node:path";
87553
+ import { join as join37 } from "node:path";
87391
87554
  function localDocsVersion(root = process.cwd()) {
87392
- const path3 = join36(root, FOLDER, DOCS, STAMP);
87555
+ const path3 = join37(root, FOLDER, DOCS, STAMP);
87393
87556
  if (!existsSync31(path3))
87394
87557
  return void 0;
87395
87558
  const stamp2 = JSON.parse(readFileSync32(path3, "utf8"));
87396
87559
  return typeof stamp2.version === "string" && /^[a-f0-9]{16}$/.test(stamp2.version) ? stamp2.version : void 0;
87397
87560
  }
87398
87561
  function ensureGitIgnore(root) {
87399
- const path3 = join36(root, ".gitignore");
87562
+ const path3 = join37(root, ".gitignore");
87400
87563
  const text = existsSync31(path3) ? readFileSync32(path3, "utf8") : "";
87401
87564
  if (text.split(/\r?\n/).some((line) => line === ".somewhere/" || line === "/.somewhere/"))
87402
87565
  return;
@@ -87404,8 +87567,8 @@ function ensureGitIgnore(root) {
87404
87567
  `);
87405
87568
  }
87406
87569
  function saveLocalDocs(version2, files, root = process.cwd()) {
87407
- const state = join36(root, FOLDER);
87408
- const target = join36(state, DOCS);
87570
+ const state = join37(root, FOLDER);
87571
+ const target = join37(state, DOCS);
87409
87572
  if (existsSync31(state) && !lstatSync5(state).isDirectory())
87410
87573
  throw new Error(`${state} must be a directory.`);
87411
87574
  if (existsSync31(target) && (!lstatSync5(target).isDirectory() || !localDocsVersion(root))) {
@@ -87413,17 +87576,17 @@ function saveLocalDocs(version2, files, root = process.cwd()) {
87413
87576
  }
87414
87577
  ensureGitIgnore(root);
87415
87578
  mkdirSync16(state, { recursive: true });
87416
- const staging = mkdtempSync3(join36(state, "docs-pull-"));
87417
- const next = join36(staging, "next");
87418
- const previous = join36(staging, "previous");
87579
+ const staging = mkdtempSync3(join37(state, "docs-pull-"));
87580
+ const next = join37(staging, "next");
87581
+ const previous = join37(staging, "previous");
87419
87582
  let installed = false;
87420
87583
  try {
87421
87584
  mkdirSync16(next);
87422
87585
  for (const [name, content] of files)
87423
- writeFileSync21(join36(next, name), content, { flag: "wx" });
87586
+ writeFileSync21(join37(next, name), content, { flag: "wx" });
87424
87587
  const pulledAt = (/* @__PURE__ */ new Date()).toISOString();
87425
- writeFileSync21(join36(next, STAMP), JSON.stringify({ version: version2, pulledAt }) + "\n");
87426
- writeFileSync21(join36(next, "README.md"), `# Somewhere docs
87588
+ writeFileSync21(join37(next, STAMP), JSON.stringify({ version: version2, pulledAt }) + "\n");
87589
+ writeFileSync21(join37(next, "README.md"), `# Somewhere docs
87427
87590
 
87428
87591
  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.
87429
87592
  `, { flag: "wx" });
@@ -87455,7 +87618,7 @@ var init_local_docs = __esm({
87455
87618
 
87456
87619
  // dist/lib/advisor-context.js
87457
87620
  import { readFileSync as readFileSync33, statSync as statSync6 } from "node:fs";
87458
- import { basename as basename7 } from "node:path";
87621
+ import { basename as basename8 } from "node:path";
87459
87622
  function tail(value, limit) {
87460
87623
  return value.length <= limit ? value : `\u2026${value.slice(-limit)}`;
87461
87624
  }
@@ -87467,7 +87630,7 @@ function redactAdvisorText(value, redactDotenvValues = false) {
87467
87630
  return redacted;
87468
87631
  }
87469
87632
  function isDotenvPath(path3) {
87470
- const name = basename7(path3);
87633
+ const name = basename8(path3);
87471
87634
  return name === ".env" || name.startsWith(".env.") || name.endsWith(".env");
87472
87635
  }
87473
87636
  function buildAdvisorContext(filePath) {
@@ -87501,18 +87664,18 @@ var init_advisor_context = __esm({
87501
87664
  });
87502
87665
 
87503
87666
  // dist/lib/advisor-runs.js
87504
- import { randomBytes as randomBytes7, randomUUID as randomUUID7 } from "node:crypto";
87667
+ import { randomBytes as randomBytes7, randomUUID as randomUUID8 } from "node:crypto";
87505
87668
  import { chmodSync as chmodSync4, existsSync as existsSync32, mkdirSync as mkdirSync17, readFileSync as readFileSync34, renameSync as renameSync6, writeFileSync as writeFileSync22 } from "node:fs";
87506
- import { join as join37 } from "node:path";
87669
+ import { join as join38 } from "node:path";
87507
87670
  function path2(id) {
87508
87671
  if (!/^[a-f0-9-]{36}$/i.test(id))
87509
87672
  throw Error("Invalid Advisor request ID.");
87510
- return join37(directory(), id + ".json");
87673
+ return join38(directory(), id + ".json");
87511
87674
  }
87512
87675
  function save(record3) {
87513
87676
  mkdirSync17(directory(), { recursive: true, mode: 448 });
87514
87677
  chmodSync4(directory(), 448);
87515
- const target = path2(record3.request_id), temporary = target + "." + randomUUID7() + ".tmp";
87678
+ const target = path2(record3.request_id), temporary = target + "." + randomUUID8() + ".tmp";
87516
87679
  writeFileSync22(temporary, JSON.stringify(record3), { mode: 384, flag: "wx" });
87517
87680
  renameSync6(temporary, target);
87518
87681
  chmodSync4(target, 384);
@@ -87589,7 +87752,7 @@ async function callAdvisorRun(args) {
87589
87752
  else {
87590
87753
  if (!args.question)
87591
87754
  throw Error("Supply a question or --resume <request-id>.");
87592
- const id = randomUUID7(), created = Date.now(), context = args.context ? { ...args.context } : void 0;
87755
+ const id = randomUUID8(), created = Date.now(), context = args.context ? { ...args.context } : void 0;
87593
87756
  if (context?.file)
87594
87757
  delete context.file;
87595
87758
  const config2 = loadConfig();
@@ -87630,7 +87793,7 @@ async function consumeAdvisorRun(text, progress) {
87630
87793
  }
87631
87794
  if (typeof parsed.run_id !== "string" || typeof parsed.status !== "string")
87632
87795
  return null;
87633
- const config2 = loadConfig(), anonymous = typeof parsed.anonymous_capability === "string", id = randomUUID7();
87796
+ const config2 = loadConfig(), anonymous = typeof parsed.anonymous_capability === "string", id = randomUUID8();
87634
87797
  if (!anonymous && (!config2?.token || config2.temporary === true))
87635
87798
  throw Error("Sign in to the account that owns this Advisor run.");
87636
87799
  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) } : {} };
@@ -87645,7 +87808,7 @@ var init_advisor_runs = __esm({
87645
87808
  init_config();
87646
87809
  init_http();
87647
87810
  init_advisor_context();
87648
- directory = /* @__PURE__ */ __name(() => join37(cliConfigDir(), "advisor-runs"), "directory");
87811
+ directory = /* @__PURE__ */ __name(() => join38(cliConfigDir(), "advisor-runs"), "directory");
87649
87812
  __name(path2, "path");
87650
87813
  __name(save, "save");
87651
87814
  PAYLOAD_RETENTION_MS = 24 * 60 * 60 * 1e3;
@@ -87664,7 +87827,7 @@ var init_advisor_runs = __esm({
87664
87827
  // dist/lib/advisor-app.js
87665
87828
  import { createHash as createHash8 } from "node:crypto";
87666
87829
  import { existsSync as existsSync33, mkdirSync as mkdirSync18, readFileSync as readFileSync35, rmSync as rmSync14, writeFileSync as writeFileSync23 } from "node:fs";
87667
- import { join as join38 } from "node:path";
87830
+ import { join as join39 } from "node:path";
87668
87831
  async function gatherAdvisorApp(client, ref) {
87669
87832
  const project = await client.call("GET", `/projects/${encodeURIComponent(ref)}`);
87670
87833
  if (typeof project.id !== "string" || project.deleted === true)
@@ -87698,7 +87861,7 @@ async function gatherAdvisorApp(client, ref) {
87698
87861
  }
87699
87862
  function loadAdvisorTurns(dir, projectId, account, now2 = Date.now()) {
87700
87863
  try {
87701
- const saved = JSON.parse(readFileSync35(join38(dir, FILE), "utf8"));
87864
+ const saved = JSON.parse(readFileSync35(join39(dir, FILE), "utf8"));
87702
87865
  if (saved.project_id !== projectId || saved.owner !== ownerOf(account) || !Array.isArray(saved.turns))
87703
87866
  return [];
87704
87867
  const last = saved.turns.at(-1);
@@ -87708,16 +87871,16 @@ function loadAdvisorTurns(dir, projectId, account, now2 = Date.now()) {
87708
87871
  }
87709
87872
  }
87710
87873
  function saveAdvisorTurn(dir, projectId, account, earlier, turn) {
87711
- mkdirSync18(join38(dir, DIR), { recursive: true, mode: 448 });
87712
- 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 });
87874
+ mkdirSync18(join39(dir, DIR), { recursive: true, mode: 448 });
87875
+ 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 });
87713
87876
  ensureAdvisorStateIgnored(dir);
87714
87877
  }
87715
87878
  function clearAdvisorTurns(dir) {
87716
- if (existsSync33(join38(dir, FILE)))
87717
- rmSync14(join38(dir, FILE), { force: true });
87879
+ if (existsSync33(join39(dir, FILE)))
87880
+ rmSync14(join39(dir, FILE), { force: true });
87718
87881
  }
87719
87882
  function ensureAdvisorStateIgnored(dir) {
87720
- const path3 = join38(dir, ".gitignore");
87883
+ const path3 = join39(dir, ".gitignore");
87721
87884
  const covered = [".somewhere/", ".somewhere", "/.somewhere/", "/.somewhere", ".somewhere/advisor-conversation.json"];
87722
87885
  if (!existsSync33(path3)) {
87723
87886
  writeFileSync23(path3, "# somewhere: local CLI state (Advisor follow-ups, test users)\n.somewhere/\n");
@@ -87737,7 +87900,7 @@ var init_advisor_app = __esm({
87737
87900
  "use strict";
87738
87901
  __name(gatherAdvisorApp, "gatherAdvisorApp");
87739
87902
  DIR = ".somewhere";
87740
- FILE = join38(DIR, "advisor-conversation.json");
87903
+ FILE = join39(DIR, "advisor-conversation.json");
87741
87904
  IDLE_MS = 30 * 6e4;
87742
87905
  ownerOf = /* @__PURE__ */ __name((account) => createHash8("sha256").update(`advisor:${account}`).digest("hex"), "ownerOf");
87743
87906
  __name(loadAdvisorTurns, "loadAdvisorTurns");
@@ -88093,6 +88256,11 @@ function findPublicDocsPage(pages, aliases, requested) {
88093
88256
  const target = own2(lower) ?? own2(normalized);
88094
88257
  return byId(requested) ?? (target ? byId(target) : void 0);
88095
88258
  }
88259
+ function docsConnectionError(cause) {
88260
+ const inner = cause?.cause;
88261
+ const reason = inner?.code ?? inner?.message ?? (cause instanceof Error ? cause.message : String(cause));
88262
+ return new Error(`Could not reach ${DOCS_BASE2} (${reason}) \u2014 check your connection. The docs are public and need no login.`, { cause });
88263
+ }
88096
88264
  async function fetchPublicManifestWithGroups() {
88097
88265
  let res;
88098
88266
  try {
@@ -88100,9 +88268,7 @@ async function fetchPublicManifestWithGroups() {
88100
88268
  headers: { "User-Agent": "somewhere-cli" }
88101
88269
  });
88102
88270
  } catch (cause) {
88103
- const inner = cause?.cause;
88104
- const reason = inner?.code ?? inner?.message ?? (cause instanceof Error ? cause.message : String(cause));
88105
- throw new Error(`Could not reach ${DOCS_BASE2} (${reason}) \u2014 check your connection. The docs are public and need no login.`);
88271
+ throw docsConnectionError(cause);
88106
88272
  }
88107
88273
  if (!res.ok) {
88108
88274
  throw new Error(`Could not fetch ${DOCS_BASE2}${PUBLIC_MANIFEST_PATH} (HTTP ${res.status}).`);
@@ -88165,7 +88331,7 @@ async function fetchDocsSearch(query, topic, includeApi) {
88165
88331
  });
88166
88332
  if (!res.ok) {
88167
88333
  if (topic && res.status === 404)
88168
- throw new Error(`Unknown docs topic "${topic}". Run ${cliInvocation()} docs for the topic index.`);
88334
+ throw new Error(`Unknown docs topic "${topic}". Run ${cliInvocation()} docs --list for the topic index.`);
88169
88335
  throw new Error(`Could not search docs at ${DOCS_BASE2} (HTTP ${res.status}).`);
88170
88336
  }
88171
88337
  const { results, total, version: version2 } = await res.json();
@@ -88248,9 +88414,9 @@ function displayDocs(content) {
88248
88414
  return withNewline(hasViewNotice(content) ? content.replace(/^\[docs\][^\n]*\n/, "") : content);
88249
88415
  }
88250
88416
  function registerDocs(program2) {
88251
- program2.command("docs [topic] [terms...]").description(`Read platform docs. No login needed \u2014 every topic is public. With no topic, prints the topic index. Search with \`${cliInvocation()} docs --search "<words>"\`. Quick topics: ` + Object.keys(TOPICS).join(", ") + `. Example manual topic: \`${cliInvocation()} docs sw.db\`.`).option("--list", `List available topics (the same index bare \`${cliInvocation()} docs\` prints)`).option("--full", "Print the complete topic; with no topic, print the full manual").option("--search <words>", "Find matching builder docs and read the top section whole").option("--include-api", "Include the HTTP API catalog and developer tool reference in search").option("--section <id>", "Print one section of a topic (ids are listed in the summary)").option("--json", "Print the selected document in a JSON envelope").addHelpText("after", `
88417
+ program2.command("docs [topic] [terms...]").description(`Read platform docs. No login needed \u2014 every topic is public. With no topic, opens the platform overview. Search with \`${cliInvocation()} docs --search "<words>"\`. Quick topics: ` + Object.keys(TOPICS).join(", ") + `. Example manual topic: \`${cliInvocation()} docs sw.db\`.`).option("--list", "List available topics").option("--full", "Print the complete topic; with no topic, print the full manual").option("--search <words>", "Find matching builder docs, optionally within the given topic").option("--include-api", "Include the HTTP API catalog and developer tool reference in search").option("--section <id>", "Print one section of a topic (ids are listed in the summary)").option("--json", "Print the selected document in a JSON envelope").addHelpText("after", `
88252
88418
  Examples:
88253
- ${cliInvocation()} docs # topic index
88419
+ ${cliInvocation()} docs # platform overview
88254
88420
  ${cliInvocation()} docs --search "magic link" # matching builder docs
88255
88421
  ${cliInvocation()} docs pull # download Markdown into .somewhere/docs/
88256
88422
  ${cliInvocation()} docs sw.auth # topic summary when the whole topic is long
@@ -88333,8 +88499,8 @@ Examples:
88333
88499
  return;
88334
88500
  }
88335
88501
  if (searching) {
88336
- if (opts.full || opts.section !== void 0 || opts.list || opts.search !== void 0 && topic !== void 0) {
88337
- error('Use docs --search "<words>" with optional --include-api and --json.');
88502
+ if (opts.full || opts.section !== void 0 || opts.list) {
88503
+ error('Use docs [topic] --search "<words>" with optional --include-api and --json.');
88338
88504
  process.exitCode = 1;
88339
88505
  return;
88340
88506
  }
@@ -88372,7 +88538,7 @@ ${results[0].snippet}`);
88372
88538
  return;
88373
88539
  }
88374
88540
  const view = opts.section !== void 0 ? { kind: "section", id: opts.section } : opts.full ? { kind: "full" } : { kind: "default" };
88375
- if (opts.list || topic === void 0 && view.kind === "default") {
88541
+ if (opts.list) {
88376
88542
  try {
88377
88543
  const { pages, groups, version: version2 } = await fetchPublicManifestWithGroups();
88378
88544
  await warnIfLocalDocsOlder(version2);
@@ -88407,7 +88573,7 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
88407
88573
  const lowerTopic = requestedTopic.toLowerCase();
88408
88574
  const key = ownKey(TOPICS, requestedTopic) ? requestedTopic : ownKey(ALIASES, lowerTopic) ? ALIASES[lowerTopic] : void 0;
88409
88575
  const resolvedTopic = key ?? requestedTopic;
88410
- const entry = key ? TOPICS[key] : void 0;
88576
+ const entry = key === "docs" && view.kind === "full" ? { path: "/manual.txt" } : key ? TOPICS[key] : void 0;
88411
88577
  if (entry && view.kind === "section") {
88412
88578
  reportDocsFailure({
88413
88579
  error: "DOCS_SECTION_INDEX_UNAVAILABLE",
@@ -88511,7 +88677,7 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
88511
88677
  }
88512
88678
  await writeResponseBodyToStdout(res);
88513
88679
  } catch (e) {
88514
- error(`Could not reach ${DOCS_BASE2} \u2014 check your connection. (${e instanceof Error ? e.message : String(e)})`, e);
88680
+ error(docsConnectionError(e).message, e);
88515
88681
  process.exit(1);
88516
88682
  }
88517
88683
  });
@@ -88536,7 +88702,7 @@ var init_docs = __esm({
88536
88702
  },
88537
88703
  docs: {
88538
88704
  path: "/docs.txt",
88539
- blurb: "Full platform reference for agents (large)"
88705
+ blurb: "Platform overview, plans and topic links"
88540
88706
  },
88541
88707
  guides: {
88542
88708
  path: "/guides.txt",
@@ -88581,6 +88747,7 @@ var init_docs = __esm({
88581
88747
  __name(parsePublicDocsGroups, "parsePublicDocsGroups");
88582
88748
  __name(parsePublicDocsAliases, "parsePublicDocsAliases");
88583
88749
  __name(findPublicDocsPage, "findPublicDocsPage");
88750
+ __name(docsConnectionError, "docsConnectionError");
88584
88751
  __name(fetchPublicManifestWithGroups, "fetchPublicManifestWithGroups");
88585
88752
  __name(renderDocsIndex, "renderDocsIndex");
88586
88753
  __name(fetchDocsSearch, "fetchDocsSearch");
@@ -89861,7 +90028,7 @@ var init_claim = __esm({
89861
90028
  import { createRequire as createRequire9 } from "node:module";
89862
90029
  import { realpathSync as realpathSync4 } from "node:fs";
89863
90030
  import { createConnection, createServer as createNetServer } from "node:net";
89864
- import { join as join39 } from "node:path";
90031
+ import { join as join40 } from "node:path";
89865
90032
  import { pathToFileURL as pathToFileURL3 } from "node:url";
89866
90033
  function deployedOrigin(value) {
89867
90034
  const url3 = new URL(value);
@@ -89959,7 +90126,7 @@ async function startFrontendDev(cwd, target, port = 8787, open4 = false) {
89959
90126
  throw new Error(INSTALL_PROJECT_DEPENDENCIES);
89960
90127
  let vitePath;
89961
90128
  try {
89962
- vitePath = createRequire9(join39(cwd, "package.json")).resolve("vite");
90129
+ vitePath = createRequire9(join40(cwd, "package.json")).resolve("vite");
89963
90130
  } catch {
89964
90131
  if (readProjectPin(cwd)?.versionOnly) {
89965
90132
  throw new Error("Install the local frontend tools: npm install -D --save-exact vite@7.2.2");
@@ -90101,9 +90268,9 @@ var init_preview_jobs = __esm({
90101
90268
  });
90102
90269
 
90103
90270
  // dist/commands/dev.js
90104
- import { randomUUID as randomUUID8 } from "node:crypto";
90271
+ import { randomUUID as randomUUID9 } from "node:crypto";
90105
90272
  import { existsSync as existsSync36, readFileSync as readFileSync38 } from "node:fs";
90106
- import { join as join40, relative as relative11 } from "node:path";
90273
+ import { join as join41, relative as relative11 } from "node:path";
90107
90274
  function previewFinishedReason(err) {
90108
90275
  if (!(err instanceof CliApiError) || err.code !== "DRAFT_SESSION_TERMINAL")
90109
90276
  return null;
@@ -90729,7 +90896,7 @@ async function runHotDeploy(opts) {
90729
90896
  }
90730
90897
  await showProjectNotices(client, projectId);
90731
90898
  const { files, binaryFiles, functions } = collected;
90732
- const firstOperationId = `previewop_${randomUUID8()}`;
90899
+ const firstOperationId = `previewop_${randomUUID9()}`;
90733
90900
  const showPublishProgress = opts.publishFirst === true && opts.json !== true;
90734
90901
  const phase = /* @__PURE__ */ __name((label, operation) => showPublishProgress ? runPreviewPhase(label, operation) : operation(), "phase");
90735
90902
  const say = opts.json ? () => {
@@ -90761,7 +90928,7 @@ async function runHotDeploy(opts) {
90761
90928
  say(`Continuing this folder's preview ${draftId}${when.length ? ` (${when.join(", ")})` : ""}.`);
90762
90929
  say("Pass --new to open a fresh preview with a new copy of production data instead.");
90763
90930
  } else {
90764
- draftId = `draft_${randomUUID8()}`;
90931
+ draftId = `draft_${randomUUID9()}`;
90765
90932
  expectedPreviewId = null;
90766
90933
  if (decision.reason === "stale") {
90767
90934
  if (!opts.json) {
@@ -91090,7 +91257,7 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
91090
91257
  const updateBinary = {};
91091
91258
  const deleteKeys = [];
91092
91259
  for (const rel of changed) {
91093
- const abs = join40(cwd, rel);
91260
+ const abs = join41(cwd, rel);
91094
91261
  if (!existsSync36(abs))
91095
91262
  continue;
91096
91263
  const { kind, key } = classifyKey(rel);
@@ -91103,7 +91270,7 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
91103
91270
  }
91104
91271
  for (const rel of deleted)
91105
91272
  deleteKeys.push(classifyKey(rel).key);
91106
- const operationId = `previewop_${randomUUID8()}`;
91273
+ const operationId = `previewop_${randomUUID9()}`;
91107
91274
  const body = {
91108
91275
  project_id: projectId,
91109
91276
  preview: true,
@@ -91162,7 +91329,7 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
91162
91329
  for (const rel of deleted)
91163
91330
  delete nextFiles[rel];
91164
91331
  for (const rel of changed)
91165
- if (existsSync36(join40(cwd, rel)))
91332
+ if (existsSync36(join41(cwd, rel)))
91166
91333
  Object.assign(nextFiles, hashFiles(cwd, [rel]));
91167
91334
  savePreviewRecord(cwd, { ...record3, preview_id: nextCandidate, files: nextFiles });
91168
91335
  }
@@ -91358,7 +91525,7 @@ var init_dev = __esm({
91358
91525
 
91359
91526
  // dist/commands/check.js
91360
91527
  import { existsSync as existsSync37 } from "node:fs";
91361
- import { join as join41, resolve as resolve21 } from "node:path";
91528
+ import { join as join42, resolve as resolve21 } from "node:path";
91362
91529
  function buildCheckBody(collected, projectId) {
91363
91530
  const body = { project_id: projectId, files: collected.files };
91364
91531
  if (Object.keys(collected.functions).length > 0)
@@ -91463,7 +91630,7 @@ async function runLocalPreflight(targetDir, collected, typecheck = async (dir) =
91463
91630
  if (collected.excluded.length)
91464
91631
  source.not_published = collected.excluded;
91465
91632
  let typecheckStep;
91466
- if (!existsSync37(join41(targetDir, "tsconfig.json"))) {
91633
+ if (!existsSync37(join42(targetDir, "tsconfig.json"))) {
91467
91634
  typecheckStep = { name: "typecheck", status: "skipped", reason: MISSING_TSCONFIG_GUIDANCE };
91468
91635
  } else if (missingProjectDependencies(targetDir).length) {
91469
91636
  typecheckStep = { name: "typecheck", status: "skipped", reason: missingTypecheckDependenciesMessage() };
@@ -91877,11 +92044,11 @@ var init_api2 = __esm({
91877
92044
  });
91878
92045
 
91879
92046
  // dist/commands/fs.js
91880
- import { createReadStream as createReadStream2, createWriteStream as createWriteStream2 } from "node:fs";
91881
- import { stat as stat5, rename, unlink } from "node:fs/promises";
91882
- import { randomUUID as randomUUID9 } from "node:crypto";
91883
- import { basename as basename8, dirname as dirname13, extname as extname6, join as join42, resolve as resolve23 } from "node:path";
91884
- import { pipeline as pipeline2 } from "node:stream/promises";
92047
+ import { createReadStream as createReadStream2, createWriteStream as createWriteStream3 } from "node:fs";
92048
+ import { stat as stat5, rename as rename2, unlink as unlink2 } from "node:fs/promises";
92049
+ import { randomUUID as randomUUID10 } from "node:crypto";
92050
+ import { basename as basename9, dirname as dirname14, extname as extname6, join as join43, resolve as resolve23 } from "node:path";
92051
+ import { pipeline as pipeline3 } from "node:stream/promises";
91885
92052
  function registerFs(program2) {
91886
92053
  const fs2 = program2.command("fs").description("Manage project file storage");
91887
92054
  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) => {
@@ -91924,9 +92091,9 @@ function registerFs(program2) {
91924
92091
  if (!response.body)
91925
92092
  throw new Error("The server returned an empty file response.");
91926
92093
  const destination = resolve23(local);
91927
- tempPath = join42(dirname13(destination), `.${basename8(destination)}.${randomUUID9()}.tmp`);
91928
- await pipeline2(response.body, createWriteStream2(tempPath, { flags: "wx" }));
91929
- await rename(tempPath, destination);
92094
+ tempPath = join43(dirname14(destination), `.${basename9(destination)}.${randomUUID10()}.tmp`);
92095
+ await pipeline3(response.body, createWriteStream3(tempPath, { flags: "wx" }));
92096
+ await rename2(tempPath, destination);
91930
92097
  tempPath = void 0;
91931
92098
  const size = Number(response.headers.get("content-length"));
91932
92099
  const result = {
@@ -91941,7 +92108,7 @@ function registerFs(program2) {
91941
92108
  success(`Downloaded ${remote} \u2192 ${local}`);
91942
92109
  } catch (err) {
91943
92110
  if (tempPath)
91944
- await unlink(tempPath).catch(() => {
92111
+ await unlink2(tempPath).catch(() => {
91945
92112
  });
91946
92113
  fail(err, opts.json);
91947
92114
  }
@@ -109728,13 +109895,13 @@ var require_polyfill = __commonJS({
109728
109895
  readlink,
109729
109896
  stat: stat6,
109730
109897
  symlink,
109731
- unlink: unlink2,
109898
+ unlink: unlink3,
109732
109899
  utimes
109733
109900
  } = __require("fs/promises");
109734
109901
  var {
109735
- dirname: dirname16,
109902
+ dirname: dirname17,
109736
109903
  isAbsolute: isAbsolute7,
109737
- join: join52,
109904
+ join: join53,
109738
109905
  parse: parse3,
109739
109906
  resolve: resolve27,
109740
109907
  sep: sep2,
@@ -109836,7 +110003,7 @@ var require_polyfill = __commonJS({
109836
110003
  }
109837
110004
  __name(getStats, "getStats");
109838
110005
  async function checkParentDir(destStat, src, dest, opts) {
109839
- const destParent = dirname16(dest);
110006
+ const destParent = dirname17(dest);
109840
110007
  const dirExists = await pathExists(destParent);
109841
110008
  if (dirExists) {
109842
110009
  return getStatsForCopy(destStat, src, dest, opts);
@@ -109854,8 +110021,8 @@ var require_polyfill = __commonJS({
109854
110021
  }
109855
110022
  __name(pathExists, "pathExists");
109856
110023
  async function checkParentPaths(src, srcStat, dest) {
109857
- const srcParent = resolve27(dirname16(src));
109858
- const destParent = resolve27(dirname16(dest));
110024
+ const srcParent = resolve27(dirname17(src));
110025
+ const destParent = resolve27(dirname17(dest));
109859
110026
  if (destParent === srcParent || destParent === parse3(destParent).root) {
109860
110027
  return;
109861
110028
  }
@@ -109948,7 +110115,7 @@ var require_polyfill = __commonJS({
109948
110115
  __name(onFile, "onFile");
109949
110116
  async function mayCopyFile(srcStat, src, dest, opts) {
109950
110117
  if (opts.force) {
109951
- await unlink2(dest);
110118
+ await unlink3(dest);
109952
110119
  return _copyFile(srcStat, src, dest, opts);
109953
110120
  } else if (opts.errorOnExist) {
109954
110121
  throw new ERR_FS_CP_EEXIST({
@@ -110015,8 +110182,8 @@ var require_polyfill = __commonJS({
110015
110182
  const dir = await readdir3(src);
110016
110183
  for (let i = 0; i < dir.length; i++) {
110017
110184
  const item = dir[i];
110018
- const srcItem = join52(src, item);
110019
- const destItem = join52(dest, item);
110185
+ const srcItem = join53(src, item);
110186
+ const destItem = join53(dest, item);
110020
110187
  const { destStat } = await checkPaths(srcItem, destItem, opts);
110021
110188
  await startCopy(destStat, srcItem, destItem, opts);
110022
110189
  }
@@ -110025,7 +110192,7 @@ var require_polyfill = __commonJS({
110025
110192
  async function onLink(destStat, src, dest) {
110026
110193
  let resolvedSrc = await readlink(src);
110027
110194
  if (!isAbsolute7(resolvedSrc)) {
110028
- resolvedSrc = resolve27(dirname16(src), resolvedSrc);
110195
+ resolvedSrc = resolve27(dirname17(src), resolvedSrc);
110029
110196
  }
110030
110197
  if (!destStat) {
110031
110198
  return symlink(resolvedSrc, dest);
@@ -110040,7 +110207,7 @@ var require_polyfill = __commonJS({
110040
110207
  throw err;
110041
110208
  }
110042
110209
  if (!isAbsolute7(resolvedDest)) {
110043
- resolvedDest = resolve27(dirname16(dest), resolvedDest);
110210
+ resolvedDest = resolve27(dirname17(dest), resolvedDest);
110044
110211
  }
110045
110212
  if (isSrcSubdir(resolvedSrc, resolvedDest)) {
110046
110213
  throw new ERR_FS_CP_EINVAL({
@@ -110063,7 +110230,7 @@ var require_polyfill = __commonJS({
110063
110230
  }
110064
110231
  __name(onLink, "onLink");
110065
110232
  async function copyLink(resolvedSrc, dest) {
110066
- await unlink2(dest);
110233
+ await unlink3(dest);
110067
110234
  return symlink(resolvedSrc, dest);
110068
110235
  }
110069
110236
  __name(copyLink, "copyLink");
@@ -110092,7 +110259,7 @@ var require_cp = __commonJS({
110092
110259
  // node_modules/@npmcli/fs/lib/with-temp-dir.js
110093
110260
  var require_with_temp_dir = __commonJS({
110094
110261
  "node_modules/@npmcli/fs/lib/with-temp-dir.js"(exports, module) {
110095
- var { join: join52, sep: sep2 } = __require("path");
110262
+ var { join: join53, sep: sep2 } = __require("path");
110096
110263
  var getOptions = require_get_options();
110097
110264
  var { mkdir, mkdtemp, rm } = __require("fs/promises");
110098
110265
  var withTempDir = /* @__PURE__ */ __name(async (root, fn, opts) => {
@@ -110100,7 +110267,7 @@ var require_with_temp_dir = __commonJS({
110100
110267
  copy: ["tmpPrefix"]
110101
110268
  });
110102
110269
  await mkdir(root, { recursive: true });
110103
- const target = await mkdtemp(join52(`${root}${sep2}`, options2.tmpPrefix || ""));
110270
+ const target = await mkdtemp(join53(`${root}${sep2}`, options2.tmpPrefix || ""));
110104
110271
  let err;
110105
110272
  let result;
110106
110273
  try {
@@ -110125,13 +110292,13 @@ var require_with_temp_dir = __commonJS({
110125
110292
  var require_readdir_scoped = __commonJS({
110126
110293
  "node_modules/@npmcli/fs/lib/readdir-scoped.js"(exports, module) {
110127
110294
  var { readdir: readdir3 } = __require("fs/promises");
110128
- var { join: join52 } = __require("path");
110295
+ var { join: join53 } = __require("path");
110129
110296
  var readdirScoped = /* @__PURE__ */ __name(async (dir) => {
110130
110297
  const results = [];
110131
110298
  for (const item of await readdir3(dir)) {
110132
110299
  if (item.startsWith("@")) {
110133
- for (const scopedItem of await readdir3(join52(dir, item))) {
110134
- results.push(join52(item, scopedItem));
110300
+ for (const scopedItem of await readdir3(join53(dir, item))) {
110301
+ results.push(join53(item, scopedItem));
110135
110302
  }
110136
110303
  } else {
110137
110304
  results.push(item);
@@ -110146,7 +110313,7 @@ var require_readdir_scoped = __commonJS({
110146
110313
  // node_modules/@npmcli/fs/lib/move-file.js
110147
110314
  var require_move_file = __commonJS({
110148
110315
  "node_modules/@npmcli/fs/lib/move-file.js"(exports, module) {
110149
- var { dirname: dirname16, join: join52, resolve: resolve27, relative: relative15, isAbsolute: isAbsolute7 } = __require("path");
110316
+ var { dirname: dirname17, join: join53, resolve: resolve27, relative: relative15, isAbsolute: isAbsolute7 } = __require("path");
110150
110317
  var fs2 = __require("fs/promises");
110151
110318
  var pathExists = /* @__PURE__ */ __name(async (path3) => {
110152
110319
  try {
@@ -110167,7 +110334,7 @@ var require_move_file = __commonJS({
110167
110334
  if (!options2.overwrite && await pathExists(destination)) {
110168
110335
  throw new Error(`The destination file exists: ${destination}`);
110169
110336
  }
110170
- await fs2.mkdir(dirname16(destination), { recursive: true });
110337
+ await fs2.mkdir(dirname17(destination), { recursive: true });
110171
110338
  try {
110172
110339
  await fs2.rename(source, destination);
110173
110340
  } catch (error3) {
@@ -110176,7 +110343,7 @@ var require_move_file = __commonJS({
110176
110343
  if (sourceStat.isDirectory()) {
110177
110344
  const files = await fs2.readdir(source);
110178
110345
  await Promise.all(files.map(
110179
- (file) => moveFile(join52(source, file), join52(destination, file), options2, false, symlinks)
110346
+ (file) => moveFile(join53(source, file), join53(destination, file), options2, false, symlinks)
110180
110347
  ));
110181
110348
  } else if (sourceStat.isSymbolicLink()) {
110182
110349
  symlinks.push({ source, destination });
@@ -110195,7 +110362,7 @@ var require_move_file = __commonJS({
110195
110362
  }
110196
110363
  let targetStat = "file";
110197
110364
  try {
110198
- targetStat = await fs2.stat(resolve27(dirname16(symSource), target));
110365
+ targetStat = await fs2.stat(resolve27(dirname17(symSource), target));
110199
110366
  if (targetStat.isDirectory()) {
110200
110367
  targetStat = "junction";
110201
110368
  }
@@ -112397,8 +112564,8 @@ var require_write = __commonJS({
112397
112564
  hashStream.on("size", (s3) => {
112398
112565
  size = s3;
112399
112566
  });
112400
- const pipeline4 = new Pipeline(inputStream, hashStream, outStream);
112401
- await pipeline4.promise();
112567
+ const pipeline5 = new Pipeline(inputStream, hashStream, outStream);
112568
+ await pipeline5.promise();
112402
112569
  return { integrity, size };
112403
112570
  }
112404
112571
  __name(pipeToTmp, "pipeToTmp");
@@ -112489,12 +112656,12 @@ var require_put = __commonJS({
112489
112656
  let size;
112490
112657
  let error3;
112491
112658
  let memoData;
112492
- const pipeline4 = new Pipeline();
112659
+ const pipeline5 = new Pipeline();
112493
112660
  if (memoize) {
112494
112661
  const memoizer2 = new PassThrough().on("collect", (data2) => {
112495
112662
  memoData = data2;
112496
112663
  });
112497
- pipeline4.push(memoizer2);
112664
+ pipeline5.push(memoizer2);
112498
112665
  }
112499
112666
  const contentStream = write.stream(cache, opts).on("integrity", (int2) => {
112500
112667
  integrity = int2;
@@ -112503,20 +112670,20 @@ var require_put = __commonJS({
112503
112670
  }).on("error", (err) => {
112504
112671
  error3 = err;
112505
112672
  });
112506
- pipeline4.push(contentStream);
112507
- pipeline4.push(new Flush({
112673
+ pipeline5.push(contentStream);
112674
+ pipeline5.push(new Flush({
112508
112675
  async flush() {
112509
112676
  if (!error3) {
112510
112677
  const entry = await index.insert(cache, key, integrity, { ...opts, size });
112511
112678
  if (memoize && memoData) {
112512
112679
  memo2.put(cache, entry, memoData, opts);
112513
112680
  }
112514
- pipeline4.emit("integrity", integrity);
112515
- pipeline4.emit("size", size);
112681
+ pipeline5.emit("integrity", integrity);
112682
+ pipeline5.emit("size", size);
112516
112683
  }
112517
112684
  }
112518
112685
  }));
112519
- return pipeline4;
112686
+ return pipeline5;
112520
112687
  }
112521
112688
  __name(putStream, "putStream");
112522
112689
  }
@@ -123294,12 +123461,12 @@ var require_remote = __commonJS({
123294
123461
  integrity: _opts.integrity,
123295
123462
  size: _opts.size
123296
123463
  });
123297
- const pipeline4 = new CachingMinipassPipeline({
123464
+ const pipeline5 = new CachingMinipassPipeline({
123298
123465
  events: ["integrity", "size"]
123299
123466
  }, res.body, integrityStream);
123300
- integrityStream.on("integrity", (i) => pipeline4.emit("integrity", i));
123301
- integrityStream.on("size", (s3) => pipeline4.emit("size", s3));
123302
- res = new fetch2.Response(pipeline4, res);
123467
+ integrityStream.on("integrity", (i) => pipeline5.emit("integrity", i));
123468
+ integrityStream.on("size", (s3) => pipeline5.emit("size", s3));
123469
+ res = new fetch2.Response(pipeline5, res);
123303
123470
  res.body.hasIntegrityEmitter = true;
123304
123471
  }
123305
123472
  res.headers.set("x-fetch-attempts", attemptNum);
@@ -129544,12 +129711,12 @@ var require_url = __commonJS({
129544
129711
  "node_modules/tuf-js/dist/utils/url.js"(exports) {
129545
129712
  "use strict";
129546
129713
  Object.defineProperty(exports, "__esModule", { value: true });
129547
- exports.join = join52;
129714
+ exports.join = join53;
129548
129715
  var url_1 = __require("url");
129549
- function join52(base, path3) {
129716
+ function join53(base, path3) {
129550
129717
  return new url_1.URL(ensureTrailingSlash(base) + removeLeadingSlash(path3)).toString();
129551
129718
  }
129552
- __name(join52, "join");
129719
+ __name(join53, "join");
129553
129720
  function ensureTrailingSlash(path3) {
129554
129721
  return path3.endsWith("/") ? path3 : path3 + "/";
129555
129722
  }
@@ -131886,9 +132053,9 @@ var require_dist15 = __commonJS({
131886
132053
  // dist/lib/update-security.js
131887
132054
  import { createHash as createHash9, timingSafeEqual } from "node:crypto";
131888
132055
  import { mkdirSync as mkdirSync19, readFileSync as readFileSync39, statSync as statSync7 } from "node:fs";
131889
- import { join as join43 } from "node:path";
131890
- import { Readable as Readable2 } from "node:stream";
131891
- import { pipeline as pipeline3 } from "node:stream/promises";
132056
+ import { join as join44 } from "node:path";
132057
+ import { Readable as Readable3 } from "node:stream";
132058
+ import { pipeline as pipeline4 } from "node:stream/promises";
131892
132059
  function expectedTarballUrl(version2) {
131893
132060
  return `${OFFICIAL_NPM_REGISTRY}/@somewhere-cloud/cli/-/cli-${encodeURIComponent(version2)}.tgz`;
131894
132061
  }
@@ -132231,7 +132398,7 @@ function bundledManifestLockPath(tarPath) {
132231
132398
  return index === parts.length ? directory2 : void 0;
132232
132399
  }
132233
132400
  async function extractArtifactSnapshot(artifact, extractionDir, filter) {
132234
- await pipeline3(Readable2.from([artifact]), So({ cwd: extractionDir, strip: 1, strict: true, filter }));
132401
+ await pipeline4(Readable3.from([artifact]), So({ cwd: extractionDir, strip: 1, strict: true, filter }));
132235
132402
  }
132236
132403
  async function verifyLockedArtifact(artifact, extractionDir, release2) {
132237
132404
  mkdirSync19(extractionDir, { recursive: true, mode: 448 });
@@ -132251,8 +132418,8 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
132251
132418
  seen2.add(path3);
132252
132419
  return true;
132253
132420
  });
132254
- const manifestPath = join43(extractionDir, "package.json");
132255
- const lockPath = join43(extractionDir, "npm-shrinkwrap.json");
132421
+ const manifestPath = join44(extractionDir, "package.json");
132422
+ const lockPath = join44(extractionDir, "npm-shrinkwrap.json");
132256
132423
  let manifest;
132257
132424
  let lock;
132258
132425
  try {
@@ -132296,7 +132463,7 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
132296
132463
  }
132297
132464
  let bundledManifest;
132298
132465
  try {
132299
- const bundledPath = join43(extractionDir, ...lockPath2.split("/"), "package.json");
132466
+ const bundledPath = join44(extractionDir, ...lockPath2.split("/"), "package.json");
132300
132467
  bundledManifest = JSON.parse(readFileSync39(bundledPath, "utf8"));
132301
132468
  } catch (cause) {
132302
132469
  throw new Error(`the verified artifact has an unreadable bundled dependency ${lockPath2}: ${message(cause)}`);
@@ -132370,7 +132537,7 @@ import { randomBytes as randomBytes8 } from "node:crypto";
132370
132537
  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";
132371
132538
  import { createServer } from "node:http";
132372
132539
  import { tmpdir as tmpdir2 } from "node:os";
132373
- import { join as join44 } from "node:path";
132540
+ import { join as join45 } from "node:path";
132374
132541
  function refuse2(cause) {
132375
132542
  error(`Update refused: ${message2(cause)}.`);
132376
132543
  info(`To install the latest release with npm instead, run: ${teal(NPM_UPDATE_COMMAND)}`);
@@ -132378,7 +132545,7 @@ function refuse2(cause) {
132378
132545
  }
132379
132546
  function currentVersion2() {
132380
132547
  try {
132381
- const pkg = JSON.parse(readFileSync40(join44(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
132548
+ const pkg = JSON.parse(readFileSync40(join45(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
132382
132549
  return pkg.version;
132383
132550
  } catch {
132384
132551
  return "0.0.0";
@@ -132517,10 +132684,10 @@ async function serveArtifactSnapshot(artifact) {
132517
132684
  }
132518
132685
  async function installVerifiedTarball(tarballPath, tempDir, release2) {
132519
132686
  const ambientEnvironment = { ...process.env };
132520
- const packageDir = join44(tempDir, "authenticated-package");
132521
- const cacheDir = join44(tempDir, "empty-cache");
132522
- const userConfigPath = join44(tempDir, "user-npmrc");
132523
- const globalConfigPath = join44(tempDir, "global-npmrc");
132687
+ const packageDir = join45(tempDir, "authenticated-package");
132688
+ const cacheDir = join45(tempDir, "empty-cache");
132689
+ const userConfigPath = join45(tempDir, "user-npmrc");
132690
+ const globalConfigPath = join45(tempDir, "global-npmrc");
132524
132691
  writeFileSync25(userConfigPath, "", { mode: 384 });
132525
132692
  writeFileSync25(globalConfigPath, "", { mode: 384 });
132526
132693
  const artifact = snapshotAuthenticatedArtifact(tarballPath);
@@ -132592,8 +132759,8 @@ async function runUpdate(opts, dependencies = {}) {
132592
132759
  const provenance = await fetchJson(fetchImpl, release2.attestationUrl, "the official npm provenance endpoint");
132593
132760
  await (dependencies.verifyProvenance ?? verifyPublishedProvenance)(provenance, release2);
132594
132761
  const tarball = await downloadTarball(fetchImpl, release2);
132595
- tempDir = mkdtempSync4(join44(tmpdir2(), "somewhere-update-"));
132596
- const tarballPath = join44(tempDir, `cli-${release2.version}.tgz`);
132762
+ tempDir = mkdtempSync4(join45(tmpdir2(), "somewhere-update-"));
132763
+ const tarballPath = join45(tempDir, `cli-${release2.version}.tgz`);
132597
132764
  writeFileSync25(tarballPath, tarball, { mode: 384 });
132598
132765
  info(`Cryptographically verified provenance and integrity for ${CLI_PACKAGE}@${release2.version}.`);
132599
132766
  info(`Updating ${CLI_PACKAGE} from its authenticated dependency lock \u2026`);
@@ -135025,9 +135192,9 @@ var init_form_auth = __esm({
135025
135192
  });
135026
135193
 
135027
135194
  // dist/lib/test-response-capture.js
135028
- import { randomUUID as randomUUID10 } from "node:crypto";
135195
+ import { randomUUID as randomUUID11 } from "node:crypto";
135029
135196
  function privateMarker() {
135030
- return "sw-test-" + randomUUID10();
135197
+ return "sw-test-" + randomUUID11();
135031
135198
  }
135032
135199
  function captureResponses(page) {
135033
135200
  const pending = [];
@@ -135074,11 +135241,11 @@ var init_test_response_capture = __esm({
135074
135241
  });
135075
135242
 
135076
135243
  // dist/lib/app-test.js
135077
- import { randomUUID as randomUUID11 } from "node:crypto";
135244
+ import { randomUUID as randomUUID12 } from "node:crypto";
135078
135245
  import { setDefaultResultOrder } from "node:dns";
135079
135246
  import { lookup } from "node:dns/promises";
135080
135247
  import { existsSync as existsSync38, mkdirSync as mkdirSync20, readFileSync as readFileSync42, writeFileSync as writeFileSync26 } from "node:fs";
135081
- import { basename as basename9, dirname as dirname14, join as join45, relative as relative12, resolve as resolve24 } from "node:path";
135248
+ import { basename as basename10, dirname as dirname15, join as join46, relative as relative12, resolve as resolve24 } from "node:path";
135082
135249
  function launchOptions(extra = {}) {
135083
135250
  return { ...extra, args: ["--disable-features=AsyncDns", ...extra.args ?? []] };
135084
135251
  }
@@ -135128,7 +135295,7 @@ function undeployedChanges(root, projectId, preview = false) {
135128
135295
  return null;
135129
135296
  base = { project_id: record3.project_id, release_id: record3.preview_id, files: record3.files };
135130
135297
  } else {
135131
- const path3 = join45(root, ".somewhere", "base-files.json");
135298
+ const path3 = join46(root, ".somewhere", "base-files.json");
135132
135299
  if (!existsSync38(path3))
135133
135300
  return null;
135134
135301
  base = JSON.parse(readFileSync42(path3, "utf8"));
@@ -135296,12 +135463,12 @@ var init_app_test = __esm({
135296
135463
  const [ipv4First] = await Promise.all([testAddressOrder(target.origin), lookup(new URL(target.origin).hostname).catch(() => null)]);
135297
135464
  if (ipv4First)
135298
135465
  setDefaultResultOrder("ipv4first");
135299
- process.env.SW_TEST_RUN ??= randomUUID11();
135466
+ process.env.SW_TEST_RUN ??= randomUUID12();
135300
135467
  process.env.SW_TEST_ORIGIN = target.origin;
135301
135468
  for (const line of describeSweep(await sweepAccounts(control, root), "Before this script"))
135302
135469
  process.stderr.write(line + "\n");
135303
- const scriptName = process.argv[1] ? basename9(process.argv[1]).replace(/\.[cm]?[jt]s$/, "") : "app-check";
135304
- const app = new _AppTest(root, control, resolve24(root, options2.results ?? join45(".somewhere", `${scriptName}${preview ? "-preview" : ""}.json`)));
135470
+ const scriptName = process.argv[1] ? basename10(process.argv[1]).replace(/\.[cm]?[jt]s$/, "") : "app-check";
135471
+ const app = new _AppTest(root, control, resolve24(root, options2.results ?? join46(".somewhere", `${scriptName}${preview ? "-preview" : ""}.json`)));
135305
135472
  return app;
135306
135473
  }
135307
135474
  /** What this run tests: the project, environment, preview, origin and script. */
@@ -135483,7 +135650,7 @@ page ${i + 1}: ${state}`).join("");
135483
135650
  }
135484
135651
  const passed = this.checks.filter((check) => check.ok).length;
135485
135652
  const failed = this.checks.filter((check) => !check.ok && !check.skipped).length;
135486
- mkdirSync20(dirname14(this.resultsPath), { recursive: true });
135653
+ mkdirSync20(dirname15(this.resultsPath), { recursive: true });
135487
135654
  writeFileSync26(this.resultsPath, JSON.stringify({
135488
135655
  identity: this.identity(),
135489
135656
  origin: this.origin,
@@ -136075,7 +136242,7 @@ var init_reference_check_note = __esm({
136075
136242
  // dist/lib/test-scripts.js
136076
136243
  import { createRequire as createRequire10 } from "node:module";
136077
136244
  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";
136078
- import { dirname as dirname15, join as join46, relative as relative13, resolve as resolve25 } from "node:path";
136245
+ import { dirname as dirname16, join as join47, relative as relative13, resolve as resolve25 } from "node:path";
136079
136246
  import { spawn as spawn7, spawnSync as spawnSync5 } from "node:child_process";
136080
136247
  function hasSpecFiles(root) {
136081
136248
  const walk2 = /* @__PURE__ */ __name((dir) => {
@@ -136084,24 +136251,24 @@ function hasSpecFiles(root) {
136084
136251
  for (const entry of readdirSync8(dir, { withFileTypes: true })) {
136085
136252
  if (entry.name === "node_modules" || entry.name.startsWith("."))
136086
136253
  continue;
136087
- const path3 = join46(dir, entry.name);
136254
+ const path3 = join47(dir, entry.name);
136088
136255
  if (entry.isDirectory() ? walk2(path3) : /\.spec\.ts$/.test(entry.name))
136089
136256
  return true;
136090
136257
  }
136091
136258
  return false;
136092
136259
  }, "walk");
136093
- return walk2(join46(root, "tests"));
136260
+ return walk2(join47(root, "tests"));
136094
136261
  }
136095
136262
  function listScripts(root, files) {
136096
136263
  if (files.length)
136097
136264
  return files.map((file) => relative13(root, resolve25(root, file)));
136098
- const dir = join46(root, "tests");
136265
+ const dir = join47(root, "tests");
136099
136266
  if (!existsSync39(dir))
136100
136267
  return [];
136101
- return readdirSync8(dir).filter((name) => isScript(name) && statSync8(join46(dir, name)).isFile()).sort().map((name) => join46("tests", name));
136268
+ return readdirSync8(dir).filter((name) => isScript(name) && statSync8(join47(dir, name)).isFile()).sort().map((name) => join47("tests", name));
136102
136269
  }
136103
136270
  function scriptBrowserEnv(root) {
136104
- const require6 = createRequire10(join46(root, "package.json"));
136271
+ const require6 = createRequire10(join47(root, "package.json"));
136105
136272
  let cli;
136106
136273
  try {
136107
136274
  cli = require6.resolve("@playwright/test/cli");
@@ -136112,7 +136279,7 @@ function scriptBrowserEnv(root) {
136112
136279
  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" });
136113
136280
  if (probe.status === 0)
136114
136281
  return env;
136115
- env.PLAYWRIGHT_BROWSERS_PATH ??= join46(cliConfigDir(), "cache", "playwright");
136282
+ env.PLAYWRIGHT_BROWSERS_PATH ??= join47(cliConfigDir(), "cache", "playwright");
136116
136283
  process.stderr.write("Installing Playwright Chromium in the CLI cache (once).\n");
136117
136284
  const install = spawnSync5(process.execPath, [cli, "install", "chromium"], { stdio: "inherit", env });
136118
136285
  if (install.status !== 0)
@@ -136135,7 +136302,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
136135
136302
  env = testImportEnv(root, env);
136136
136303
  const results = [];
136137
136304
  for (const script of scripts) {
136138
- if (!existsSync39(join46(root, script))) {
136305
+ if (!existsSync39(join47(root, script))) {
136139
136306
  results.push({ script, ok: false, exitCode: 1, ms: 0, reason: "no such file" });
136140
136307
  continue;
136141
136308
  }
@@ -136144,8 +136311,8 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
136144
136311
  `);
136145
136312
  const started = performance.now();
136146
136313
  let output = "";
136147
- const handOver = join46(root, ".somewhere", "tests", `report-${results.length}.json`);
136148
- mkdirSync21(dirname15(handOver), { recursive: true });
136314
+ const handOver = join47(root, ".somewhere", "tests", `report-${results.length}.json`);
136315
+ mkdirSync21(dirname16(handOver), { recursive: true });
136149
136316
  rmSync17(handOver, { force: true });
136150
136317
  const askedForBrowserLog = /(^|,)\s*(pw:browser|pw:\*|\*)\s*(,|$)/.test(env.DEBUG ?? "");
136151
136318
  const childEnv = { ...env, SW_TEST_REPORT: handOver, DEBUG: askedForBrowserLog ? env.DEBUG : [env.DEBUG, "pw:browser"].filter(Boolean).join(",") };
@@ -136207,7 +136374,7 @@ function describeScriptResults(results, options2 = {}) {
136207
136374
  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;
136208
136375
  }
136209
136376
  function lastFailedScripts(root) {
136210
- const path3 = join46(root, LAST);
136377
+ const path3 = join47(root, LAST);
136211
136378
  if (!existsSync39(path3))
136212
136379
  return [];
136213
136380
  try {
@@ -136217,10 +136384,10 @@ function lastFailedScripts(root) {
136217
136384
  }
136218
136385
  }
136219
136386
  function recordScriptResults(root, results, rerunOnly) {
136220
- const previous = rerunOnly && existsSync39(join46(root, LAST)) ? JSON.parse(readFileSync43(join46(root, LAST), "utf8")).results ?? [] : [];
136387
+ const previous = rerunOnly && existsSync39(join47(root, LAST)) ? JSON.parse(readFileSync43(join47(root, LAST), "utf8")).results ?? [] : [];
136221
136388
  const merged = [...previous.filter((p2) => !results.some((r) => r.script === p2.script)), ...results];
136222
- mkdirSync21(join46(root, ".somewhere", "tests"), { recursive: true });
136223
- writeFileSync27(join46(root, LAST), JSON.stringify({ finished: (/* @__PURE__ */ new Date()).toISOString(), results: merged }, null, 2) + "\n");
136389
+ mkdirSync21(join47(root, ".somewhere", "tests"), { recursive: true });
136390
+ writeFileSync27(join47(root, LAST), JSON.stringify({ finished: (/* @__PURE__ */ new Date()).toISOString(), results: merged }, null, 2) + "\n");
136224
136391
  }
136225
136392
  var BROWSER_CRASH, BROWSER_CRASH_REASON, isScript, LAST;
136226
136393
  var init_test_scripts = __esm({
@@ -136238,7 +136405,7 @@ var init_test_scripts = __esm({
136238
136405
  __name(failureReason, "failureReason");
136239
136406
  __name(runScripts, "runScripts");
136240
136407
  __name(describeScriptResults, "describeScriptResults");
136241
- LAST = join46(".somewhere", "tests", "scripts-last.json");
136408
+ LAST = join47(".somewhere", "tests", "scripts-last.json");
136242
136409
  __name(lastFailedScripts, "lastFailedScripts");
136243
136410
  __name(recordScriptResults, "recordScriptResults");
136244
136411
  }
@@ -136334,7 +136501,7 @@ var init_test = __esm({
136334
136501
 
136335
136502
  // dist/commands/test-users.js
136336
136503
  import { existsSync as existsSync40, readFileSync as readFileSync44, rmSync as rmSync18 } from "node:fs";
136337
- import { basename as basename10, join as join47 } from "node:path";
136504
+ import { basename as basename11, join as join48 } from "node:path";
136338
136505
  import { randomBytes as randomBytes9 } from "node:crypto";
136339
136506
  async function resolveTarget(projectOpt, originOpt) {
136340
136507
  const root = process.cwd();
@@ -136371,7 +136538,7 @@ function registerTestUsers(program2) {
136371
136538
  "that signup or email verification works. Use `address` + `inbox` for real signup tests.",
136372
136539
  `${RETAINED_NOTE}`
136373
136540
  ].join("\n"));
136374
- group.command("prepare <actors...>").description("Create preverified test users and write one Playwright storageState file per actor (e.g. alice bob:admin)").option("-p, --project <project>", "Project slug or ID; defaults to the linked project").option("--origin <url>", "Only the project's production origin is supported; anything else is refused").option("--json", "Print the manifest (no tokens) as JSON").addHelpText("after", [
136541
+ group.command("prepare <actors...>").description("Create preverified test users and write one Playwright storageState file per actor (e.g. alice bob:admin)").option("-p, --project <project>", "Project slug or ID; defaults to the linked project").option("--origin <url>", "Only the project's production origin is supported; anything else is refused").option("--json", "Print the manifest and browser data contract digest as JSON").addHelpText("after", [
136375
136542
  "",
136376
136543
  "From the linked project folder, run somewhere test-users prepare alice. It writes .somewhere/test/<actor>.state.json (a standard Playwright storageState) and manifest.json.",
136377
136544
  'Playwright: const alice = await browser.newContext({ storageState: ".somewhere/test/alice.state.json" })',
@@ -136409,6 +136576,16 @@ function registerTestUsers(program2) {
136409
136576
  fail2(opts, Object.assign(new Error(`${TEST_STATE_DIR}/${MANIFEST_FILE} still records ${existing.actors.length} test user(s) from run ${existing.run_id}. Reuse the saved state if it still signs in, or run \`somewhere browser --auth-user <user-id>\` with the ID in the manifest to start a fresh hosted session. To replace the identities, run \`somewhere test-users cleanup\` and then prepare again.`), { code: "TEST_USERS_NOT_CLEANED" }));
136410
136577
  return;
136411
136578
  }
136579
+ let contractDigest = null;
136580
+ try {
136581
+ const map = await target.client.call("GET", "/db/access-map", void 0, { project_id: target.projectId });
136582
+ contractDigest = map.browser_data.contract_digest;
136583
+ } catch (cause) {
136584
+ if (!(cause instanceof CliApiError && cause.code === "NOT_FOUND")) {
136585
+ fail2(opts, cause);
136586
+ return;
136587
+ }
136588
+ }
136412
136589
  ensurePrivateDir(dir);
136413
136590
  const gitignore = ensureGitignored(target.root);
136414
136591
  const manifest = {
@@ -136425,7 +136602,7 @@ function registerTestUsers(program2) {
136425
136602
  const record3 = /* @__PURE__ */ __name((spec, issued, receivedAt) => {
136426
136603
  const times = expiryOf(issued, receivedAt);
136427
136604
  const file = `${spec.name}.state.json`;
136428
- writePrivateFile(join47(dir, file), JSON.stringify(buildStorageState(target.origin, target.host, issued, times), null, 2) + "\n");
136605
+ writePrivateFile(join48(dir, file), JSON.stringify(buildStorageState(target.origin, target.host, issued, times), null, 2) + "\n");
136429
136606
  const actor = {
136430
136607
  name: spec.name,
136431
136608
  user_id: issued.user.id,
@@ -136463,7 +136640,7 @@ function registerTestUsers(program2) {
136463
136640
  if (failure2)
136464
136641
  fail2(opts, failure2, { manifest, state_dir: TEST_STATE_DIR, created: manifest.actors.length, requested: specs.length });
136465
136642
  else
136466
- printJson({ manifest, state_dir: TEST_STATE_DIR, gitignore });
136643
+ printJson({ manifest, state_dir: TEST_STATE_DIR, gitignore, contract_digest: contractDigest });
136467
136644
  return;
136468
136645
  }
136469
136646
  for (const actor of manifest.actors) {
@@ -136472,6 +136649,7 @@ function registerTestUsers(program2) {
136472
136649
  }
136473
136650
  if (gitignore !== "present")
136474
136651
  info(`${gitignore === "created" ? "Created" : "Updated"} .gitignore to ignore ${TEST_STATE_DIR}/.`);
136652
+ info(contractDigest ? `Data contract digest: ${contractDigest}` : "No browser data contract is deployed.");
136475
136653
  info(RETAINED_NOTE);
136476
136654
  if (failure2) {
136477
136655
  fail2(opts, failure2);
@@ -136522,11 +136700,11 @@ function registerTestUsers(program2) {
136522
136700
  if (opts.linkOut) {
136523
136701
  if (!newest.magic_link)
136524
136702
  throw Object.assign(new Error("The newest message has no magic link."), { code: "NO_MAGIC_LINK" });
136525
- const name = basename10(opts.linkOut);
136703
+ const name = basename11(opts.linkOut);
136526
136704
  if (name !== opts.linkOut || !/^[A-Za-z0-9._-]{1,64}$/.test(name))
136527
136705
  throw new Error(`--link-out takes a file name; it is written under ${TEST_STATE_DIR}/.`);
136528
136706
  ensurePrivateDir(stateDir(target.root));
136529
- writePrivateFile(join47(stateDir(target.root), name), newest.magic_link + "\n");
136707
+ writePrivateFile(join48(stateDir(target.root), name), newest.magic_link + "\n");
136530
136708
  linkFile = `${TEST_STATE_DIR}/${name}`;
136531
136709
  }
136532
136710
  const message3 = {
@@ -136597,12 +136775,12 @@ function registerTestUsers(program2) {
136597
136775
  local_state: { removed: localRemoved, kept: manifest.actors.map((actor) => actor.state_file).filter((file) => !localRemoved.includes(file)) },
136598
136776
  actors: manifest.actors.map(({ name, user_id, email: email2, role, created_at }) => ({ name, user_id, email: email2, role, created_at }))
136599
136777
  };
136600
- writePrivateFile(join47(stateDir(target.root), CLEANUP_RECEIPT_FILE), JSON.stringify(receipt, null, 2) + "\n");
136778
+ writePrivateFile(join48(stateDir(target.root), CLEANUP_RECEIPT_FILE), JSON.stringify(receipt, null, 2) + "\n");
136601
136779
  const left = manifest.actors.filter((actor) => !removed.includes(actor.user_id));
136602
136780
  if (left.length)
136603
136781
  writeManifest(target.root, { ...manifest, actors: left, status: "partial" });
136604
136782
  else
136605
- rmSync18(join47(stateDir(target.root), MANIFEST_FILE), { force: true });
136783
+ rmSync18(join48(stateDir(target.root), MANIFEST_FILE), { force: true });
136606
136784
  if (opts.json) {
136607
136785
  printJson(receipt);
136608
136786
  if (left.length)
@@ -136642,7 +136820,7 @@ var init_test_users = __esm({
136642
136820
  });
136643
136821
 
136644
136822
  // dist/commands/support.js
136645
- import { join as join48 } from "node:path";
136823
+ import { join as join49 } from "node:path";
136646
136824
  function commandPaths(program2) {
136647
136825
  const paths = /* @__PURE__ */ new Set();
136648
136826
  const walk2 = /* @__PURE__ */ __name((command, prefix) => {
@@ -136727,7 +136905,7 @@ function emitPacket(packet, opts) {
136727
136905
  if (opts.out) {
136728
136906
  if (!/^[A-Za-z0-9._-]{1,64}$/.test(opts.out))
136729
136907
  throw new Error("--out takes a plain file name in the current folder.");
136730
- writePrivateFile(join48(process.cwd(), opts.out), JSON.stringify(packet, null, 2) + "\n");
136908
+ writePrivateFile(join49(process.cwd(), opts.out), JSON.stringify(packet, null, 2) + "\n");
136731
136909
  }
136732
136910
  if (opts.json) {
136733
136911
  printJson(packet);
@@ -137018,10 +137196,10 @@ var init_startup_notice = __esm({
137018
137196
 
137019
137197
  // dist/lib/last-run.js
137020
137198
  import { lstatSync as lstatSync6, mkdirSync as mkdirSync22, renameSync as renameSync7, unlinkSync as unlinkSync6, writeFileSync as writeFileSync28 } from "node:fs";
137021
- import { join as join49 } from "node:path";
137199
+ import { join as join50 } from "node:path";
137022
137200
  function removeStaleRunRecord(dir = cliConfigDir()) {
137023
137201
  for (const name of RUN_RECORD_FILES) {
137024
- const path3 = join49(dir, name);
137202
+ const path3 = join50(dir, name);
137025
137203
  try {
137026
137204
  if (lstatSync6(path3).isDirectory()) {
137027
137205
  process.stderr.write(`Could not remove ${path3}: it is a directory, not this CLI's run record. Check it yourself.
@@ -137061,8 +137239,8 @@ function recordLastRun(cliVersion) {
137061
137239
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
137062
137240
  cli_version: cliVersion
137063
137241
  };
137064
- const path3 = join49(dir, "last-run.json");
137065
- const temporary = join49(dir, "last-run.json.tmp");
137242
+ const path3 = join50(dir, "last-run.json");
137243
+ const temporary = join50(dir, "last-run.json.tmp");
137066
137244
  writeFileSync28(temporary, JSON.stringify(record3) + "\n", { mode: 384 });
137067
137245
  renameSync7(temporary, path3);
137068
137246
  } catch {
@@ -137101,7 +137279,7 @@ __export(dist_exports, {
137101
137279
  });
137102
137280
  import { spawnSync as spawnSync6 } from "node:child_process";
137103
137281
  import { readFileSync as readFileSync46 } from "node:fs";
137104
- import { join as join50 } from "node:path";
137282
+ import { join as join51 } from "node:path";
137105
137283
  async function runCli() {
137106
137284
  const pinned = decidePin(process.cwd(), CLI_VERSION2, process.argv, process.env);
137107
137285
  if (pinned.notice)
@@ -137129,7 +137307,7 @@ async function runCli() {
137129
137307
  process.exit(child.status ?? 1);
137130
137308
  }
137131
137309
  removeStaleRunRecord();
137132
- const pkg = JSON.parse(readFileSync46(join50(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
137310
+ const pkg = JSON.parse(readFileSync46(join51(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
137133
137311
  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);
137134
137312
  recordLastRun(pkg.version);
137135
137313
  const jsonOutputRequested = process.argv.includes("--json");
@@ -137547,7 +137725,7 @@ var init_screenshot_guard = __esm({
137547
137725
 
137548
137726
  // dist/lib/playwright-fixtures.js
137549
137727
  import { createRequire as createRequire11 } from "node:module";
137550
- import { join as join51 } from "node:path";
137728
+ import { join as join52 } from "node:path";
137551
137729
  function waitOnNavigation(page) {
137552
137730
  async function wait(options2) {
137553
137731
  if (options2?.waitUntil === "commit")
@@ -137599,7 +137777,7 @@ async function previewControlForWorker() {
137599
137777
  function runner() {
137600
137778
  if (loaded)
137601
137779
  return loaded;
137602
- const require6 = createRequire11(join51(process.cwd(), "package.json"));
137780
+ const require6 = createRequire11(join52(process.cwd(), "package.json"));
137603
137781
  let pw;
137604
137782
  try {
137605
137783
  pw = require6("@playwright/test");