@somewhere-cloud/cli 0.38.183 → 0.38.184
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/lib/bundle.js +225 -146
- package/dist/lib/bundle.js.map +3 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
- package/runtime/DECLARED-DATA-VENDOR.json +5 -5
- package/runtime/PLATFORM-SOURCE.json +1 -1
- package/runtime/VENDOR.json +1 -1
- package/runtime/browser-probes.mjs +1 -1
- package/runtime/declared-data.cjs +27 -2
package/dist/lib/bundle.js
CHANGED
|
@@ -33775,10 +33775,31 @@ var init_package_root = __esm({
|
|
|
33775
33775
|
}
|
|
33776
33776
|
});
|
|
33777
33777
|
|
|
33778
|
+
// dist/lib/version.js
|
|
33779
|
+
import { readFileSync as readFileSync3 } from "node:fs";
|
|
33780
|
+
import { join as join3 } from "node:path";
|
|
33781
|
+
function readVersion() {
|
|
33782
|
+
try {
|
|
33783
|
+
const pkg = JSON.parse(readFileSync3(join3(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
33784
|
+
return typeof pkg.version === "string" ? pkg.version : "unknown";
|
|
33785
|
+
} catch {
|
|
33786
|
+
return "unknown";
|
|
33787
|
+
}
|
|
33788
|
+
}
|
|
33789
|
+
var CLI_VERSION2;
|
|
33790
|
+
var init_version = __esm({
|
|
33791
|
+
"dist/lib/version.js"() {
|
|
33792
|
+
"use strict";
|
|
33793
|
+
init_package_root();
|
|
33794
|
+
__name(readVersion, "readVersion");
|
|
33795
|
+
CLI_VERSION2 = readVersion();
|
|
33796
|
+
}
|
|
33797
|
+
});
|
|
33798
|
+
|
|
33778
33799
|
// dist/lib/platform-contract.js
|
|
33779
|
-
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as
|
|
33800
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
33780
33801
|
import { createRequire } from "node:module";
|
|
33781
|
-
import { join as
|
|
33802
|
+
import { join as join4 } from "node:path";
|
|
33782
33803
|
import { debuglog } from "node:util";
|
|
33783
33804
|
function cliConsumerContract() {
|
|
33784
33805
|
return vendor().CONSUMER_CONTRACT ?? null;
|
|
@@ -33787,8 +33808,10 @@ function readSeenFile() {
|
|
|
33787
33808
|
if (!existsSync3(seenPath()))
|
|
33788
33809
|
return { origins: {} };
|
|
33789
33810
|
try {
|
|
33790
|
-
const value = JSON.parse(
|
|
33791
|
-
|
|
33811
|
+
const value = JSON.parse(readFileSync4(seenPath(), "utf8"));
|
|
33812
|
+
if (!value || typeof value !== "object" || !value.origins || typeof value.origins !== "object")
|
|
33813
|
+
return { origins: {} };
|
|
33814
|
+
return { origins: value.origins, warned: value.warned && typeof value.warned === "object" ? value.warned : {} };
|
|
33792
33815
|
} catch {
|
|
33793
33816
|
return { origins: {} };
|
|
33794
33817
|
}
|
|
@@ -33806,10 +33829,13 @@ function recordPlatformContract(headers, url3, now2 = Date.now()) {
|
|
|
33806
33829
|
const file = readSeenFile();
|
|
33807
33830
|
const seen2 = { ...announced, seen_at: now2, origin };
|
|
33808
33831
|
file.origins[origin] = seen2;
|
|
33832
|
+
writeSeenFile(file);
|
|
33833
|
+
observeContract(contractVerdict(seen2, now2), now2);
|
|
33834
|
+
return seen2;
|
|
33835
|
+
}
|
|
33836
|
+
function writeSeenFile(file) {
|
|
33809
33837
|
mkdirSync3(cliConfigDir(), { recursive: true, mode: 448 });
|
|
33810
33838
|
writeFileSync3(seenPath(), JSON.stringify(file, null, 2) + "\n", { mode: 384 });
|
|
33811
|
-
observeContract(contractVerdict(seen2, now2));
|
|
33812
|
-
return seen2;
|
|
33813
33839
|
}
|
|
33814
33840
|
function seenPlatformContract(apiBase) {
|
|
33815
33841
|
let origin;
|
|
@@ -33827,7 +33853,7 @@ function contractVerdict(platform2, now2) {
|
|
|
33827
33853
|
}
|
|
33828
33854
|
function platformContractVerdict(apiBase, now2 = Date.now()) {
|
|
33829
33855
|
const verdict = contractVerdict(seenPlatformContract(apiBase), now2);
|
|
33830
|
-
observeContract(verdict);
|
|
33856
|
+
observeContract(verdict, now2);
|
|
33831
33857
|
return verdict;
|
|
33832
33858
|
}
|
|
33833
33859
|
function describePlatformContract(verdict) {
|
|
@@ -33846,26 +33872,34 @@ function configureContractWarning(command, apiBase) {
|
|
|
33846
33872
|
} catch {
|
|
33847
33873
|
}
|
|
33848
33874
|
}
|
|
33849
|
-
function observeContract(verdict) {
|
|
33875
|
+
function observeContract(verdict, now2) {
|
|
33850
33876
|
debug("%s", describePlatformContract(verdict));
|
|
33851
33877
|
if (warned || !warningOrigin || verdict.platform?.origin !== warningOrigin || verdict.status !== "outdated")
|
|
33852
33878
|
return;
|
|
33853
33879
|
warned = true;
|
|
33854
|
-
|
|
33880
|
+
const file = readSeenFile();
|
|
33881
|
+
const last = file.warned?.[warningOrigin];
|
|
33882
|
+
if (typeof last === "number" && now2 - last < CONTRACT_WARNING_INTERVAL_MS)
|
|
33883
|
+
return;
|
|
33884
|
+
file.warned = { ...file.warned, [warningOrigin]: now2 };
|
|
33885
|
+
writeSeenFile(file);
|
|
33886
|
+
console.error(CONTRACT_WARNING);
|
|
33855
33887
|
}
|
|
33856
|
-
var require2, CONTRACT_HEADER, vendor, seenPath, debug, warningOrigin, warned;
|
|
33888
|
+
var require2, CONTRACT_HEADER, vendor, seenPath, debug, warningOrigin, warned, CONTRACT_WARNING_INTERVAL_MS, CONTRACT_WARNING;
|
|
33857
33889
|
var init_platform_contract = __esm({
|
|
33858
33890
|
"dist/lib/platform-contract.js"() {
|
|
33859
33891
|
"use strict";
|
|
33860
33892
|
init_package_root();
|
|
33861
33893
|
init_config();
|
|
33894
|
+
init_version();
|
|
33862
33895
|
require2 = createRequire(CLI_PACKAGE_ROOT);
|
|
33863
33896
|
CONTRACT_HEADER = "x-sw-consumer-contract";
|
|
33864
33897
|
vendor = /* @__PURE__ */ __name(() => require2("./runtime/declared-data.cjs"), "vendor");
|
|
33865
|
-
seenPath = /* @__PURE__ */ __name(() =>
|
|
33898
|
+
seenPath = /* @__PURE__ */ __name(() => join4(cliConfigDir(), "platform-contract.json"), "seenPath");
|
|
33866
33899
|
__name(cliConsumerContract, "cliConsumerContract");
|
|
33867
33900
|
__name(readSeenFile, "readSeenFile");
|
|
33868
33901
|
__name(recordPlatformContract, "recordPlatformContract");
|
|
33902
|
+
__name(writeSeenFile, "writeSeenFile");
|
|
33869
33903
|
__name(seenPlatformContract, "seenPlatformContract");
|
|
33870
33904
|
__name(contractVerdict, "contractVerdict");
|
|
33871
33905
|
__name(platformContractVerdict, "platformContractVerdict");
|
|
@@ -33874,6 +33908,8 @@ var init_platform_contract = __esm({
|
|
|
33874
33908
|
debug = debuglog("somewhere-contract");
|
|
33875
33909
|
warned = false;
|
|
33876
33910
|
__name(configureContractWarning, "configureContractWarning");
|
|
33911
|
+
CONTRACT_WARNING_INTERVAL_MS = 12 * 60 * 60 * 1e3;
|
|
33912
|
+
CONTRACT_WARNING = `This Somewhere CLI (${CLI_VERSION2}) is older than the platform, so its local checks may miss newer rules. To update this project, run npx -y @somewhere-cloud/cli@latest upgrade here. Shown once every 12 hours.`;
|
|
33877
33913
|
__name(observeContract, "observeContract");
|
|
33878
33914
|
}
|
|
33879
33915
|
});
|
|
@@ -39936,9 +39972,9 @@ var require_prompts = __commonJS({
|
|
|
39936
39972
|
$2.date = (args) => toPrompt("DatePrompt", args);
|
|
39937
39973
|
$2.confirm = (args) => toPrompt("ConfirmPrompt", args);
|
|
39938
39974
|
$2.list = (args) => {
|
|
39939
|
-
const
|
|
39975
|
+
const sep3 = args.separator || ",";
|
|
39940
39976
|
return toPrompt("TextPrompt", args, {
|
|
39941
|
-
onSubmit: /* @__PURE__ */ __name((str2) => str2.split(
|
|
39977
|
+
onSubmit: /* @__PURE__ */ __name((str2) => str2.split(sep3).map((s3) => s3.trim()), "onSubmit")
|
|
39942
39978
|
});
|
|
39943
39979
|
};
|
|
39944
39980
|
$2.toggle = (args) => toPrompt("TogglePrompt", args);
|
|
@@ -42299,9 +42335,9 @@ var require_prompts2 = __commonJS({
|
|
|
42299
42335
|
$2.date = (args) => toPrompt("DatePrompt", args);
|
|
42300
42336
|
$2.confirm = (args) => toPrompt("ConfirmPrompt", args);
|
|
42301
42337
|
$2.list = (args) => {
|
|
42302
|
-
const
|
|
42338
|
+
const sep3 = args.separator || ",";
|
|
42303
42339
|
return toPrompt("TextPrompt", args, {
|
|
42304
|
-
onSubmit: /* @__PURE__ */ __name((str2) => str2.split(
|
|
42340
|
+
onSubmit: /* @__PURE__ */ __name((str2) => str2.split(sep3).map((s3) => s3.trim()), "onSubmit")
|
|
42305
42341
|
});
|
|
42306
42342
|
};
|
|
42307
42343
|
$2.toggle = (args) => toPrompt("TogglePrompt", args);
|
|
@@ -42548,10 +42584,10 @@ var init_spinner = __esm({
|
|
|
42548
42584
|
});
|
|
42549
42585
|
|
|
42550
42586
|
// dist/lib/device.js
|
|
42551
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as
|
|
42587
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "node:fs";
|
|
42552
42588
|
import { hostname } from "node:os";
|
|
42553
42589
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
42554
|
-
import { join as
|
|
42590
|
+
import { join as join5 } from "node:path";
|
|
42555
42591
|
function ensureDir2() {
|
|
42556
42592
|
if (!existsSync4(CONFIG_DIR2))
|
|
42557
42593
|
mkdirSync4(CONFIG_DIR2, { recursive: true });
|
|
@@ -42560,7 +42596,7 @@ function loadDevice() {
|
|
|
42560
42596
|
if (!existsSync4(DEVICE_PATH))
|
|
42561
42597
|
return null;
|
|
42562
42598
|
try {
|
|
42563
|
-
const parsed = JSON.parse(
|
|
42599
|
+
const parsed = JSON.parse(readFileSync5(DEVICE_PATH, "utf-8"));
|
|
42564
42600
|
if (typeof parsed.id !== "string" || parsed.id.length < 8)
|
|
42565
42601
|
return null;
|
|
42566
42602
|
return parsed;
|
|
@@ -42595,7 +42631,7 @@ var init_device = __esm({
|
|
|
42595
42631
|
"use strict";
|
|
42596
42632
|
init_config();
|
|
42597
42633
|
CONFIG_DIR2 = cliConfigDir();
|
|
42598
|
-
DEVICE_PATH =
|
|
42634
|
+
DEVICE_PATH = join5(CONFIG_DIR2, "device.json");
|
|
42599
42635
|
__name(ensureDir2, "ensureDir");
|
|
42600
42636
|
__name(loadDevice, "loadDevice");
|
|
42601
42637
|
__name(saveDevice, "saveDevice");
|
|
@@ -42761,27 +42797,6 @@ var init_auth = __esm({
|
|
|
42761
42797
|
}
|
|
42762
42798
|
});
|
|
42763
42799
|
|
|
42764
|
-
// dist/lib/version.js
|
|
42765
|
-
import { readFileSync as readFileSync5 } from "node:fs";
|
|
42766
|
-
import { join as join5 } from "node:path";
|
|
42767
|
-
function readVersion() {
|
|
42768
|
-
try {
|
|
42769
|
-
const pkg = JSON.parse(readFileSync5(join5(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
42770
|
-
return typeof pkg.version === "string" ? pkg.version : "unknown";
|
|
42771
|
-
} catch {
|
|
42772
|
-
return "unknown";
|
|
42773
|
-
}
|
|
42774
|
-
}
|
|
42775
|
-
var CLI_VERSION2;
|
|
42776
|
-
var init_version = __esm({
|
|
42777
|
-
"dist/lib/version.js"() {
|
|
42778
|
-
"use strict";
|
|
42779
|
-
init_package_root();
|
|
42780
|
-
__name(readVersion, "readVersion");
|
|
42781
|
-
CLI_VERSION2 = readVersion();
|
|
42782
|
-
}
|
|
42783
|
-
});
|
|
42784
|
-
|
|
42785
42800
|
// dist/lib/device-login.js
|
|
42786
42801
|
import { createHash, randomBytes, randomInt } from "node:crypto";
|
|
42787
42802
|
import { arch, hostname as hostname2, platform, release } from "node:os";
|
|
@@ -44290,6 +44305,8 @@ Use \`client.intake\` for public submissions to a private parent row. See
|
|
|
44290
44305
|
- Add React pages where your app handles navigation. To serve a dynamic endpoint such as \`/api/notes/:id\`, create \`api/notes/[id].ts\`. A root \`[...path].ts\` handles document routes, including \`/\`. Underscore-prefixed files are import-only helpers.
|
|
44291
44306
|
- JSON routes use \`sw.endpoint({ auth, body, rateLimit, handler })\`. Set \`auth\` to \`'required'\`, \`'optional'\` or \`'none'\`. Use a limit like \`'30/minute'\`. Read route parameters from the handler's \`params\`. Use a default handler or named HTTP method exports. For streaming, webhooks or custom responses, use a bare \`(req, sw)\` handler and \`sw.params\`. See \`somewhere docs functions\`.
|
|
44292
44307
|
- Keep the SDK auth handler at \`api/auth/[...path].ts\` when your app uses sign-in. Gate private UI on auth state. Password sign-up starts unverified, and signed-in unverified users pass \`auth: 'required'\`. See \`somewhere docs auth-client\`.
|
|
44308
|
+
- Mail from the app's built-in address reaches only the owner and app users who verified their email and signed in. Password sign-up starts unverified: if the app emails its users (confirmations, reminders), keep the starter's "Verify your email" step, or verify your own sender domain. See \`somewhere docs sw.email\`.
|
|
44309
|
+
- When users must see each other's changes without reloading (a queue, chat or status board), do not poll. Return the list through \`sw.rooms.live\` and follow it in the page with \`watchLive\`. See \`somewhere docs live --section realtime-live-updates-two-users-see-the-same-change\`.
|
|
44293
44310
|
- Render a view when the reads it depends on finish. Keep inputs disabled until their initial data and identity are ready, and preserve edits when a late response arrives.
|
|
44294
44311
|
- Browser requests use same-origin cookies. For scripted writes with a cookie session, send the app's origin in the \`Origin\` header. Use the CLI test helper to send data endpoint calls with the deployed contract digest. For an update, use \`data(table, { operation: 'update', id, values: { title } })\`.
|
|
44295
44312
|
|
|
@@ -44742,8 +44759,8 @@ var init_skills_pack_generated = __esm({
|
|
|
44742
44759
|
BUNDLED_SKILLS_PACK = {
|
|
44743
44760
|
"schema": 1,
|
|
44744
44761
|
"name": "somewhere-skills",
|
|
44745
|
-
"version": "1+
|
|
44746
|
-
"sha256": "
|
|
44762
|
+
"version": "1+7afa5a8a338d",
|
|
44763
|
+
"sha256": "7afa5a8a338d554b0f90630eb85dccad9ff8e0e170e550b73650bee538d1e927",
|
|
44747
44764
|
"files": [
|
|
44748
44765
|
{
|
|
44749
44766
|
"path": "adopt/SKILL.md",
|
|
@@ -44757,8 +44774,8 @@ var init_skills_pack_generated = __esm({
|
|
|
44757
44774
|
},
|
|
44758
44775
|
{
|
|
44759
44776
|
"path": "schema-changes/SKILL.md",
|
|
44760
|
-
"sha256": "
|
|
44761
|
-
"content": "---\nname: schema-changes\ndescription: Before adding, changing, or removing a table or column in db/schema.ts.\n---\n\n# Change the database schema safely\n\n## The file is the contract\n\nThe default `somewhere init` starter has no `db/schema.ts`: create it at the project root, or run `somewhere init --name my-app --features private-data` to start with a schema.\n\n```ts\n// db/schema.ts\nimport { id, owner, schema, table, text, timestamp } from 'somewhere/db';\n\nexport default schema({\n notes: table(\n {\n id: id(),\n title: text(),\n body: text({ default: '' }),\n created_at: timestamp({ default: 'now' }),\n },\n {\n scope: owner(),\n client: {\n read: ['id', 'title', 'body', 'created_at'],\n create: ['title', 'body'],\n update: ['title', 'body'],\n delete: true,\n },\n },\n ),\n});\n```\n\nA table without a `client` block can't be reached from the browser at all.\n\nChoose the `parent({ author })` column and its author permissions in the table's first deploy. To change them on a deployed table, declare a new table with the desired rule and move the rows from server code.\n\nDelete a never-deployed starter table's declaration and references. A `removedTable()` marker for it is a no-op. **Removing a table** is `old_table: removedTable()`. The deploy keeps the table while your previous version is still serving; once the new version is live it retires the table and keeps its data for 30 days.\n\nRun `somewhere typecheck` before deploying schema changes.\n\n## What a deploy does with it\n\n- **Additive changes apply**: a new table, a new nullable-or-defaulted column, a new index, a new unique group. Unchanged schema is a no-op.\n- **Unmarked removals and shape changes refuse** with `409 SCHEMA_DEPLOY_REFUSED` and a message naming the change.\n- **Supported table scope changes apply in place.** See Two worlds for the supported transitions, including role-list edits on an existing `group()` or `appRole()` rule.\n- **Column rules and child author rules are set on a new table.** A deploy refuses additions, edits or removals of `columns` rules (`write` and `memberOf`) or `parent({ author })` rules on a deployed table. Keep its current declaration and handle the operation in an authorized server endpoint, closing any direct browser write path that could bypass the endpoint. To change the declared rule, create a new table with the desired rule and migrate the rows from server code.\n- a production deploy or a promotion that would remove or rename a column is refused before anything changes, so a running release never loses a column it uses. Keep the column declared and leave its data in place.\n\n## Failure: raw SQL refused after the schema file deploys\n\
|
|
44777
|
+
"sha256": "05fa17d25e504a44b3e8f6b88710dffc85a367a7bed289e81bca65c5cc6bb492",
|
|
44778
|
+
"content": "---\nname: schema-changes\ndescription: Before adding, changing, or removing a table or column in db/schema.ts.\n---\n\n# Change the database schema safely\n\n## The file is the contract\n\nThe default `somewhere init` starter has no `db/schema.ts`: create it at the project root, or run `somewhere init --name my-app --features private-data` to start with a schema.\n\n```ts\n// db/schema.ts\nimport { id, owner, schema, table, text, timestamp } from 'somewhere/db';\n\nexport default schema({\n notes: table(\n {\n id: id(),\n title: text(),\n body: text({ default: '' }),\n created_at: timestamp({ default: 'now' }),\n },\n {\n scope: owner(),\n client: {\n read: ['id', 'title', 'body', 'created_at'],\n create: ['title', 'body'],\n update: ['title', 'body'],\n delete: true,\n },\n },\n ),\n});\n```\n\nA table without a `client` block can't be reached from the browser at all.\n\nChoose the `parent({ author })` column and its author permissions in the table's first deploy. To change them on a deployed table, declare a new table with the desired rule and move the rows from server code.\n\nDelete a never-deployed starter table's declaration and references. A `removedTable()` marker for it is a no-op. **Removing a table** is `old_table: removedTable()`. The deploy keeps the table while your previous version is still serving; once the new version is live it retires the table and keeps its data for 30 days.\n\nRun `somewhere typecheck` before deploying schema changes.\n\n## What a deploy does with it\n\n- **Additive changes apply**: a new table, a new nullable-or-defaulted column, a new index, a new unique group. Unchanged schema is a no-op.\n- **Unmarked removals and shape changes refuse** with `409 SCHEMA_DEPLOY_REFUSED` and a message naming the change.\n- **Supported table scope changes apply in place.** See Two worlds for the supported transitions, including role-list edits on an existing `group()` or `appRole()` rule.\n- **Column rules and child author rules are set on a new table.** A deploy refuses additions, edits or removals of `columns` rules (`write` and `memberOf`) or `parent({ author })` rules on a deployed table. Keep its current declaration and handle the operation in an authorized server endpoint, closing any direct browser write path that could bypass the endpoint. To change the declared rule, create a new table with the desired rule and migrate the rows from server code.\n- a production deploy or a promotion that would remove or rename a column is refused before anything changes, so a running release never loses a column it uses. Keep the column declared and leave its data in place.\n\n## Failure: raw SQL refused after the schema file deploys\n\nRaw SQL (`sw.db.query`, `sw.db.server.query` and their batch forms) never reads or writes declared tables, including in job, queue, and cron handlers: Fix: read with `sw.db.from` / `sw.db.count` / `sw.db.aggregate` and write with `sw.db.insert` / `sw.db.update` / `sw.db.remove` (the table needs a declared intent)\n\nSources (`somewhere docs <topic>`): declared-data, getting-started, sw.db, troubleshooting.\n"
|
|
44762
44779
|
},
|
|
44763
44780
|
{
|
|
44764
44781
|
"path": "sign-in-setup/SKILL.md",
|
|
@@ -44772,8 +44789,8 @@ var init_skills_pack_generated = __esm({
|
|
|
44772
44789
|
},
|
|
44773
44790
|
{
|
|
44774
44791
|
"path": "realtime-and-background/SKILL.md",
|
|
44775
|
-
"sha256": "
|
|
44776
|
-
"content": "---\nname: realtime-and-background\ndescription: When the page must update without a reload, or work must run outside one request.\n---\n\n# Live lists, jobs, cron\n\n## Live list: the page updates when rows change\n\nDeclare the list in a function with `sw.rooms.live(name, sw.db.from(...))` and follow it with `watchLive` from `/__sw/rooms/client.js`.\n\n```ts\n// api/open-notes.ts\nexport default async function (_req: Request, sw: SomewhereRuntimeContext) {\n return Response.json(await sw.rooms.live('notes.open', sw.db.from('notes', {\n where: { done: false },\n columns: ['id', 'title', 'done', 'created_at'],\n order: [['created_at', 'desc'], ['id', 'asc']],\n limit: 20,\n })))\n}\n```\n\n```js\n// browser\nimport { watchLive } from '/__sw/rooms/client.js'\
|
|
44792
|
+
"sha256": "b67dd797fd09f655584ad779605ec2d5526e329aba9ea18069e12db0f41deaf3",
|
|
44793
|
+
"content": "---\nname: realtime-and-background\ndescription: When the page must update without a reload, or work must run outside one request.\n---\n\n# Live lists, jobs, cron\n\n## Live list: the page updates when rows change\n\nDeclare the list in a function with `sw.rooms.live(name, sw.db.from(...))` and follow it with `watchLive` from `/__sw/rooms/client.js`.\n\n```ts\n// api/open-notes.ts\nexport default async function (_req: Request, sw: SomewhereRuntimeContext) {\n return Response.json(await sw.rooms.live('notes.open', sw.db.from('notes', {\n where: { done: false },\n columns: ['id', 'title', 'done', 'created_at'],\n order: [['created_at', 'desc'], ['id', 'asc']],\n limit: 20,\n })))\n}\n```\n\n```js\n// browser\nimport { watchLive } from '/__sw/rooms/client.js'\nconst stop = watchLive(\n () => fetch('/api/tickets', { credentials: 'include' }).then((r) => r.json()),\n (rows) => render(rows),\n)\n```\n\n## Job: slow work with a status\n\nRun work that shouldn't block a user request in a job. Make handlers idempotent \u2014 they may run more than once.\n\n```ts\nconst job = await sw.jobs.create({\n handler: '/api/jobs/summarize-notes',\n idempotency_key: `summary:${user.id}:${operationId}`,\n // user_id comes from the verified session, so the handler can trust it.\n payload: { summary_id: `${user.id}:${operationId}`, user_id: user.id },\n});\n```\n\n```ts\nif (!(await sw.jobs.verifyInvocation(request))) {\n return Response.json({ error: 'forbidden' }, { status: 403 });\n}\n```\n\n## Cron: on a schedule\n\nThe finest granularity is one minute: a 5-field expression has no seconds field.\n\n```js\ncron_create({\n project_id: \"my-app\",\n schedule: \"0 9 * * *\", // 5-field cron expression\n timezone: \"America/Los_Angeles\", // optional; defaults to UTC\n handler: \"/api/jobs/daily-digest\",\n payload: { segment: \"daily\" } // optional\n})\n```\n\n## Failure 1: CRON_SCHEDULE_TOO_FREQUENT\n\nA schedule tighter than `min_interval_minutes` is refused when you create or edit it, with `CRON_SCHEDULE_TOO_FREQUENT` naming both intervals.\n\nSources (`somewhere docs <topic>`): cron, live, sw.jobs.\n"
|
|
44777
44794
|
},
|
|
44778
44795
|
{
|
|
44779
44796
|
"path": "email-and-test-inbox/SKILL.md",
|
|
@@ -46861,7 +46878,7 @@ function pinNotice(pin, running, delegatedTo) {
|
|
|
46861
46878
|
const newer = import_semver.default.valid(running) !== null && import_semver.default.gtr(running, pin.spec, { includePrerelease: true });
|
|
46862
46879
|
const move = `Run \`${cliInvocation()} upgrade\` to move the project to ${running}.`;
|
|
46863
46880
|
if (delegatedTo) {
|
|
46864
|
-
return `${head}; running its installed ${delegatedTo}
|
|
46881
|
+
return newer ? `${head}; running its installed ${delegatedTo}, not ${running}. ${move}` : null;
|
|
46865
46882
|
}
|
|
46866
46883
|
if (newer)
|
|
46867
46884
|
return `${head}; you are running ${running}. ${move}`;
|
|
@@ -52883,6 +52900,8 @@ async function resolveDeleteTarget(client, ref) {
|
|
|
52883
52900
|
} catch (err) {
|
|
52884
52901
|
if (!(err instanceof CliApiError) || err.statusCode !== 404)
|
|
52885
52902
|
throw err;
|
|
52903
|
+
if (PROJECT_ID_RE.test(ref))
|
|
52904
|
+
throw err;
|
|
52886
52905
|
}
|
|
52887
52906
|
const listed = await client.call("GET", "/projects", void 0, { q: ref, fields: "compact" });
|
|
52888
52907
|
const refLower = ref.toLowerCase();
|
|
@@ -53004,7 +53023,7 @@ function printAllowedOrigins(result) {
|
|
|
53004
53023
|
info(` ${teal(origin)}`);
|
|
53005
53024
|
info(dim(" The project's own address and any verified custom domain are always trusted and are not listed here."));
|
|
53006
53025
|
}
|
|
53007
|
-
var import_prompts3;
|
|
53026
|
+
var import_prompts3, PROJECT_ID_RE;
|
|
53008
53027
|
var init_project = __esm({
|
|
53009
53028
|
"dist/commands/project.js"() {
|
|
53010
53029
|
"use strict";
|
|
@@ -53021,6 +53040,7 @@ var init_project = __esm({
|
|
|
53021
53040
|
init_platform_command();
|
|
53022
53041
|
init_allowed_origins();
|
|
53023
53042
|
__name(registerProject, "registerProject");
|
|
53043
|
+
PROJECT_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
53024
53044
|
__name(resolveDeleteTarget, "resolveDeleteTarget");
|
|
53025
53045
|
__name(requestDeleteConfirmationCode, "requestDeleteConfirmationCode");
|
|
53026
53046
|
__name(printDeleteNote, "printDeleteNote");
|
|
@@ -69552,50 +69572,50 @@ var require_fast_uri = __commonJS({
|
|
|
69552
69572
|
return serialize(resolved, schemelessOptions);
|
|
69553
69573
|
}
|
|
69554
69574
|
__name(resolve27, "resolve");
|
|
69555
|
-
function resolveComponent(base,
|
|
69575
|
+
function resolveComponent(base, relative16, options2, skipNormalization) {
|
|
69556
69576
|
const target = {};
|
|
69557
69577
|
if (!skipNormalization) {
|
|
69558
69578
|
base = parse3(serialize(base, options2), options2);
|
|
69559
|
-
|
|
69579
|
+
relative16 = parse3(serialize(relative16, options2), options2);
|
|
69560
69580
|
}
|
|
69561
69581
|
options2 = options2 || {};
|
|
69562
|
-
if (!options2.tolerant &&
|
|
69563
|
-
target.scheme =
|
|
69564
|
-
target.userinfo =
|
|
69565
|
-
target.host =
|
|
69566
|
-
target.port =
|
|
69567
|
-
target.path = removeDotSegments(
|
|
69568
|
-
target.query =
|
|
69582
|
+
if (!options2.tolerant && relative16.scheme) {
|
|
69583
|
+
target.scheme = relative16.scheme;
|
|
69584
|
+
target.userinfo = relative16.userinfo;
|
|
69585
|
+
target.host = relative16.host;
|
|
69586
|
+
target.port = relative16.port;
|
|
69587
|
+
target.path = removeDotSegments(relative16.path || "");
|
|
69588
|
+
target.query = relative16.query;
|
|
69569
69589
|
} else {
|
|
69570
|
-
if (
|
|
69571
|
-
target.userinfo =
|
|
69572
|
-
target.host =
|
|
69573
|
-
target.port =
|
|
69574
|
-
target.path = removeDotSegments(
|
|
69575
|
-
target.query =
|
|
69590
|
+
if (relative16.userinfo !== void 0 || relative16.host !== void 0 || relative16.port !== void 0) {
|
|
69591
|
+
target.userinfo = relative16.userinfo;
|
|
69592
|
+
target.host = relative16.host;
|
|
69593
|
+
target.port = relative16.port;
|
|
69594
|
+
target.path = removeDotSegments(relative16.path || "");
|
|
69595
|
+
target.query = relative16.query;
|
|
69576
69596
|
} else {
|
|
69577
|
-
if (!
|
|
69597
|
+
if (!relative16.path) {
|
|
69578
69598
|
target.path = base.path;
|
|
69579
|
-
if (
|
|
69580
|
-
target.query =
|
|
69599
|
+
if (relative16.query !== void 0) {
|
|
69600
|
+
target.query = relative16.query;
|
|
69581
69601
|
} else {
|
|
69582
69602
|
target.query = base.query;
|
|
69583
69603
|
}
|
|
69584
69604
|
} else {
|
|
69585
|
-
if (
|
|
69586
|
-
target.path = removeDotSegments(
|
|
69605
|
+
if (relative16.path[0] === "/") {
|
|
69606
|
+
target.path = removeDotSegments(relative16.path);
|
|
69587
69607
|
} else {
|
|
69588
69608
|
const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
|
|
69589
69609
|
if (baseHasAuthority && !base.path) {
|
|
69590
|
-
target.path = "/" +
|
|
69610
|
+
target.path = "/" + relative16.path;
|
|
69591
69611
|
} else if (!base.path) {
|
|
69592
|
-
target.path =
|
|
69612
|
+
target.path = relative16.path;
|
|
69593
69613
|
} else {
|
|
69594
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
69614
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative16.path;
|
|
69595
69615
|
}
|
|
69596
69616
|
target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
|
|
69597
69617
|
}
|
|
69598
|
-
target.query =
|
|
69618
|
+
target.query = relative16.query;
|
|
69599
69619
|
}
|
|
69600
69620
|
target.userinfo = base.userinfo;
|
|
69601
69621
|
target.host = base.host;
|
|
@@ -69603,7 +69623,7 @@ var require_fast_uri = __commonJS({
|
|
|
69603
69623
|
}
|
|
69604
69624
|
target.scheme = base.scheme;
|
|
69605
69625
|
}
|
|
69606
|
-
target.fragment =
|
|
69626
|
+
target.fragment = relative16.fragment;
|
|
69607
69627
|
return target;
|
|
69608
69628
|
}
|
|
69609
69629
|
__name(resolveComponent, "resolveComponent");
|
|
@@ -76224,11 +76244,11 @@ function createPattern(matcher) {
|
|
|
76224
76244
|
if (matcher.path === string4)
|
|
76225
76245
|
return true;
|
|
76226
76246
|
if (matcher.recursive) {
|
|
76227
|
-
const
|
|
76228
|
-
if (!
|
|
76247
|
+
const relative16 = sysPath2.relative(matcher.path, string4);
|
|
76248
|
+
if (!relative16) {
|
|
76229
76249
|
return false;
|
|
76230
76250
|
}
|
|
76231
|
-
return !
|
|
76251
|
+
return !relative16.startsWith("..") && !sysPath2.isAbsolute(relative16);
|
|
76232
76252
|
}
|
|
76233
76253
|
return false;
|
|
76234
76254
|
};
|
|
@@ -77056,7 +77076,7 @@ __export(files_exports, {
|
|
|
77056
77076
|
testFolderOf: () => testFolderOf
|
|
77057
77077
|
});
|
|
77058
77078
|
import { isUtf8 } from "node:buffer";
|
|
77059
|
-
import { existsSync as existsSync14, readdirSync as readdirSync3, readFileSync as readFileSync17, statSync as statSync2 } from "node:fs";
|
|
77079
|
+
import { closeSync as closeSync4, existsSync as existsSync14, openSync as openSync4, readdirSync as readdirSync3, readFileSync as readFileSync17, readSync, statSync as statSync2 } from "node:fs";
|
|
77060
77080
|
import { extname as extname3, isAbsolute as isAbsolute2, join as join18, posix as posix2, relative as relative6 } from "node:path";
|
|
77061
77081
|
function isTestSourcePath(relPath) {
|
|
77062
77082
|
return TEST_SOURCE_NAME.test(relPath.slice(relPath.lastIndexOf("/") + 1));
|
|
@@ -77122,11 +77142,11 @@ function compilerAssetMatcher(sources) {
|
|
|
77122
77142
|
};
|
|
77123
77143
|
}
|
|
77124
77144
|
function collectFiles(baseDir, options2 = {}) {
|
|
77125
|
-
const out = { dotfilesLeftOut: false, files: {}, binaryFiles: {}, functions: {}, skipped: [], oversize: [], notes: [], excluded: [], sensitive: [], published: [] };
|
|
77145
|
+
const out = { dotfilesLeftOut: false, cliCredentialFiles: [], files: {}, binaryFiles: {}, functions: {}, skipped: [], oversize: [], notes: [], excluded: [], sensitive: [], published: [] };
|
|
77126
77146
|
const ignore = loadDeployIgnore(baseDir);
|
|
77127
77147
|
const candidates = [];
|
|
77128
77148
|
const sizes = /* @__PURE__ */ new Map();
|
|
77129
|
-
walk(baseDir, baseDir, out, ignore, candidates, sizes);
|
|
77149
|
+
walk(baseDir, baseDir, out, ignore, candidates, sizes, options2.checkCliCredentials ? Buffer.alloc(512) : null);
|
|
77130
77150
|
const optIn = new Set((options2.include ?? []).map((p2) => toDeployPath(p2.trim()).replace(/^\.\//, "").replace(/\/+$/, "")).filter(Boolean));
|
|
77131
77151
|
const publish = [];
|
|
77132
77152
|
const deferred = [];
|
|
@@ -77151,7 +77171,8 @@ function collectFiles(baseDir, options2 = {}) {
|
|
|
77151
77171
|
deferred.push(relPath);
|
|
77152
77172
|
}
|
|
77153
77173
|
}
|
|
77154
|
-
const
|
|
77174
|
+
const inlineFileLimit = options2.inlineFileLimitBytes ?? MAX_FILE_SIZE;
|
|
77175
|
+
const corpusFiles = /* @__PURE__ */ __name((paths) => paths.filter((relPath) => isReferenceCorpusPath(relPath) && (sizes.get(relPath) ?? 0) <= inlineFileLimit).map((relPath) => {
|
|
77155
77176
|
try {
|
|
77156
77177
|
return [relPath, readFileSync17(join18(baseDir, relPath), "utf-8")];
|
|
77157
77178
|
} catch {
|
|
@@ -77208,9 +77229,9 @@ function collectFiles(baseDir, options2 = {}) {
|
|
|
77208
77229
|
out.published.push(relPath);
|
|
77209
77230
|
continue;
|
|
77210
77231
|
}
|
|
77211
|
-
if (bytes >
|
|
77232
|
+
if (bytes > inlineFileLimit) {
|
|
77212
77233
|
out.oversize.push({ path: relPath, bytes });
|
|
77213
|
-
out.skipped.push({ path: relPath, reason: `${formatBytes(bytes)} exceeds the ${formatBytes(
|
|
77234
|
+
out.skipped.push({ path: relPath, reason: `${formatBytes(bytes)} exceeds the ${formatBytes(inlineFileLimit)} per-file limit` });
|
|
77214
77235
|
continue;
|
|
77215
77236
|
}
|
|
77216
77237
|
classifyInto(out, baseDir, relPath, options2.readBinary !== false);
|
|
@@ -77227,7 +77248,34 @@ function collectFiles(baseDir, options2 = {}) {
|
|
|
77227
77248
|
}
|
|
77228
77249
|
return out;
|
|
77229
77250
|
}
|
|
77230
|
-
function
|
|
77251
|
+
function looksLikeCliCredential(path3, bytes, header) {
|
|
77252
|
+
if (bytes === 0 || bytes > MAX_DEPLOY_BLOB_BYTES)
|
|
77253
|
+
return false;
|
|
77254
|
+
const fd = openSync4(path3, "r");
|
|
77255
|
+
try {
|
|
77256
|
+
const size = readSync(fd, header, 0, header.length, 0);
|
|
77257
|
+
const prefix = header.toString("utf8", 0, size).trimStart();
|
|
77258
|
+
if (!prefix.startsWith("{") && !/^(?:smt|smtr)_/i.test(prefix))
|
|
77259
|
+
return false;
|
|
77260
|
+
} finally {
|
|
77261
|
+
closeSync4(fd);
|
|
77262
|
+
}
|
|
77263
|
+
const text = readFileSync17(path3, "utf8").trim();
|
|
77264
|
+
const cliKey = /^(?:smt|smtr)_[a-z0-9_-]+$/i;
|
|
77265
|
+
if (cliKey.test(text))
|
|
77266
|
+
return true;
|
|
77267
|
+
if (!text.startsWith("{"))
|
|
77268
|
+
return false;
|
|
77269
|
+
try {
|
|
77270
|
+
const value = JSON.parse(text);
|
|
77271
|
+
if (typeof value !== "object" || value === null)
|
|
77272
|
+
return false;
|
|
77273
|
+
return "token" in value && typeof value.token === "string" && cliKey.test(value.token) || "refresh_token" in value && typeof value.refresh_token === "string" && cliKey.test(value.refresh_token);
|
|
77274
|
+
} catch {
|
|
77275
|
+
return false;
|
|
77276
|
+
}
|
|
77277
|
+
}
|
|
77278
|
+
function walk(baseDir, currentDir, out, ignore, candidates, sizes, credentialHeader) {
|
|
77231
77279
|
for (const entry of readdirSync3(currentDir, { withFileTypes: true })) {
|
|
77232
77280
|
const fullPath = join18(currentDir, entry.name);
|
|
77233
77281
|
const relPath = toDeployPath(relative6(baseDir, fullPath));
|
|
@@ -77241,7 +77289,7 @@ function walk(baseDir, currentDir, out, ignore, candidates, sizes) {
|
|
|
77241
77289
|
continue;
|
|
77242
77290
|
}
|
|
77243
77291
|
if (entry.isDirectory()) {
|
|
77244
|
-
walk(baseDir, fullPath, out, ignore, candidates, sizes);
|
|
77292
|
+
walk(baseDir, fullPath, out, ignore, candidates, sizes, credentialHeader);
|
|
77245
77293
|
continue;
|
|
77246
77294
|
}
|
|
77247
77295
|
if (!entry.isFile())
|
|
@@ -77252,7 +77300,12 @@ function walk(baseDir, currentDir, out, ignore, candidates, sizes) {
|
|
|
77252
77300
|
}
|
|
77253
77301
|
if ((entry.name === DATA_DECLARATION_FILE || entry.name === FILES_DECLARATION_FILE) && readFileSync17(fullPath, "utf8").startsWith(GENERATED_DATA_HEADER))
|
|
77254
77302
|
continue;
|
|
77255
|
-
|
|
77303
|
+
const bytes = statSync2(fullPath).size;
|
|
77304
|
+
if (credentialHeader && looksLikeCliCredential(fullPath, bytes, credentialHeader)) {
|
|
77305
|
+
out.cliCredentialFiles.push(relPath);
|
|
77306
|
+
continue;
|
|
77307
|
+
}
|
|
77308
|
+
sizes.set(relPath, bytes);
|
|
77256
77309
|
candidates.push(relPath);
|
|
77257
77310
|
}
|
|
77258
77311
|
}
|
|
@@ -77385,11 +77438,12 @@ function globToRegExp(pattern) {
|
|
|
77385
77438
|
function escapeRegExp(ch) {
|
|
77386
77439
|
return /[\\^$+?.()|[\]{}]/.test(ch) ? `\\${ch}` : ch;
|
|
77387
77440
|
}
|
|
77388
|
-
function oversizeRefusal(collected) {
|
|
77441
|
+
function oversizeRefusal(collected, limitBytes = MAX_FILE_SIZE) {
|
|
77389
77442
|
if (collected.oversize.length === 0)
|
|
77390
77443
|
return null;
|
|
77444
|
+
const limit = limitBytes === MAX_INLINE_DEPLOY_BYTES ? "20 MiB inline deploy" : `${formatBytes(limitBytes)} per-file`;
|
|
77391
77445
|
return [
|
|
77392
|
-
`Nothing was sent. ${collected.oversize.length === 1 ? "This file is" : "These files are"} over the ${
|
|
77446
|
+
`Nothing was sent. ${collected.oversize.length === 1 ? "This file is" : "These files are"} over the ${limit} limit and would be left out, which removes any copy already live:`,
|
|
77393
77447
|
...collected.oversize.map((entry) => ` ${entry.path} (${formatBytes(entry.bytes)})`),
|
|
77394
77448
|
...fileStorageRecovery(collected.oversize)
|
|
77395
77449
|
].join("\n");
|
|
@@ -77524,6 +77578,7 @@ var init_files = __esm({
|
|
|
77524
77578
|
SENSITIVE_FILE_REASON = "blocked by the sensitive-path policy \u2014 never uploaded";
|
|
77525
77579
|
__name(compilerAssetMatcher, "compilerAssetMatcher");
|
|
77526
77580
|
__name(collectFiles, "collectFiles");
|
|
77581
|
+
__name(looksLikeCliCredential, "looksLikeCliCredential");
|
|
77527
77582
|
__name(walk, "walk");
|
|
77528
77583
|
__name(classifyKey, "classifyKey");
|
|
77529
77584
|
__name(classifyInto, "classifyInto");
|
|
@@ -78750,8 +78805,8 @@ function formatChecksReport(check) {
|
|
|
78750
78805
|
}
|
|
78751
78806
|
const coverage = check?.not_checked ?? null;
|
|
78752
78807
|
if (coverage) {
|
|
78753
|
-
if (typeof check?.routes_discovered === "number"
|
|
78754
|
-
lines.push(`${check.routes_checked} of ${check.routes_discovered} app routes had a completed read check.`);
|
|
78808
|
+
if (typeof check?.routes_discovered === "number")
|
|
78809
|
+
lines.push(check.routes_checked ? `${check.routes_checked} of ${check.routes_discovered} app routes had a completed read check.` : `This check called none of your ${check.routes_discovered} app routes: it covers your tables, pages and saved checks/ lists. Check the routes in tests/starter.mjs (npm test).`);
|
|
78755
78810
|
const { routes_without_read_check: reads, routes_without_write_check: writes, schedules_not_run: schedules, other } = coverage;
|
|
78756
78811
|
if (reads === null || writes === null)
|
|
78757
78812
|
lines.push("App route coverage could not be listed.");
|
|
@@ -78765,11 +78820,10 @@ function formatChecksReport(check) {
|
|
|
78765
78820
|
lines.push(`This check skips scheduled tasks (${schedules.join(", ")}). To verify one on your preview, use ${cliInvocation()} cron run <name> --preview --wait.`);
|
|
78766
78821
|
if (other.length)
|
|
78767
78822
|
lines.push(`Other checks skipped or out of scope: ${other.join(", ")}.`);
|
|
78768
|
-
if (!check?.routes_checked)
|
|
78769
|
-
lines.push("Your app's own routes, screens and rules are proven by your own tests (npm test), not by this check.");
|
|
78770
78823
|
} else {
|
|
78771
78824
|
lines.push("Coverage details are unavailable for this run.");
|
|
78772
78825
|
}
|
|
78826
|
+
lines.push("Prove the brief in tests/starter.mjs (npm test). To rerun a check after every deploy, save it as checks/<name>.json (users and steps). See somewhere docs test.");
|
|
78773
78827
|
return [...lines, JSON.stringify({
|
|
78774
78828
|
...summary,
|
|
78775
78829
|
not_checked: coverage,
|
|
@@ -82504,7 +82558,7 @@ var init_browser = __esm({
|
|
|
82504
82558
|
|
|
82505
82559
|
// dist/lib/verify-keep.js
|
|
82506
82560
|
import { createHash as createHash7, randomBytes as randomBytes5 } from "node:crypto";
|
|
82507
|
-
import { closeSync as
|
|
82561
|
+
import { closeSync as closeSync5, existsSync as existsSync27, openSync as openSync5, readFileSync as readFileSync30, rmSync as rmSync11, statSync as statSync6, writeSync } from "node:fs";
|
|
82508
82562
|
import { join as join36 } from "node:path";
|
|
82509
82563
|
function path(root) {
|
|
82510
82564
|
return join36(stateDir(root), KEEP_FILE);
|
|
@@ -82571,9 +82625,9 @@ function lockKeep(root, key, now2 = Date.now()) {
|
|
|
82571
82625
|
const lock = join36(stateDir(root), `verify-actors-${key}.lock`);
|
|
82572
82626
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
82573
82627
|
try {
|
|
82574
|
-
const fd =
|
|
82628
|
+
const fd = openSync5(lock, "wx", 384);
|
|
82575
82629
|
writeSync(fd, JSON.stringify({ pid: process.pid, at: now2 }));
|
|
82576
|
-
|
|
82630
|
+
closeSync5(fd);
|
|
82577
82631
|
return () => {
|
|
82578
82632
|
try {
|
|
82579
82633
|
rmSync11(lock, { force: true });
|
|
@@ -84527,8 +84581,8 @@ var init_verify = __esm({
|
|
|
84527
84581
|
});
|
|
84528
84582
|
|
|
84529
84583
|
// dist/commands/deploy.js
|
|
84530
|
-
import { existsSync as existsSync29, readFileSync as readFileSync32 } from "node:fs";
|
|
84531
|
-
import { join as join37 } from "node:path";
|
|
84584
|
+
import { existsSync as existsSync29, readFileSync as readFileSync32, realpathSync as realpathSync4 } from "node:fs";
|
|
84585
|
+
import { isAbsolute as isAbsolute6, join as join37, relative as relative10, sep as sep2 } from "node:path";
|
|
84532
84586
|
import { basename as basename6, resolve as resolve16 } from "node:path";
|
|
84533
84587
|
function resolveTargetDir(dir, cwd = process.cwd()) {
|
|
84534
84588
|
return dir ? resolve16(cwd, dir) : cwd;
|
|
@@ -84886,8 +84940,29 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
84886
84940
|
error(message3);
|
|
84887
84941
|
process.exit(1);
|
|
84888
84942
|
}
|
|
84943
|
+
const refuseCredential = /* @__PURE__ */ __name((path3) => {
|
|
84944
|
+
const message3 = `Nothing was sent. ${JSON.stringify(path3)} is a CLI login or key location. Move it outside the deploy folder and try again.`;
|
|
84945
|
+
if (opts.json)
|
|
84946
|
+
printJsonError("CLI_CREDENTIAL_IN_DEPLOY", message3);
|
|
84947
|
+
else
|
|
84948
|
+
error(message3);
|
|
84949
|
+
process.exit(1);
|
|
84950
|
+
}, "refuseCredential");
|
|
84951
|
+
const configDir = cliConfigDir();
|
|
84952
|
+
if (existsSync29(configDir) && existsSync29(targetDir)) {
|
|
84953
|
+
const config2 = realpathSync4(configDir);
|
|
84954
|
+
const target = realpathSync4(targetDir);
|
|
84955
|
+
const inside = /* @__PURE__ */ __name((path3) => !isAbsolute6(path3) && path3 !== ".." && !path3.startsWith(".." + sep2), "inside");
|
|
84956
|
+
const configInTarget = relative10(target, config2);
|
|
84957
|
+
if (inside(configInTarget))
|
|
84958
|
+
refuseCredential(join37(configInTarget, "config.json"));
|
|
84959
|
+
if (inside(relative10(config2, target)))
|
|
84960
|
+
refuseCredential(join37(configDir, "config.json"));
|
|
84961
|
+
}
|
|
84889
84962
|
if (opts.listUnpublished) {
|
|
84890
|
-
const { excluded: excluded2, sensitive: sensitive2, skipped: skipped2, dotfilesLeftOut } = collectFiles(targetDir, { include: opts.include ?? [] });
|
|
84963
|
+
const { excluded: excluded2, sensitive: sensitive2, skipped: skipped2, dotfilesLeftOut, cliCredentialFiles } = collectFiles(targetDir, { include: opts.include ?? [], checkCliCredentials: true });
|
|
84964
|
+
if (cliCredentialFiles.length)
|
|
84965
|
+
refuseCredential(cliCredentialFiles.sort()[0]);
|
|
84891
84966
|
if (dotfilesLeftOut)
|
|
84892
84967
|
console.error(DOTFILE_NOTICE);
|
|
84893
84968
|
if (opts.json)
|
|
@@ -84916,9 +84991,13 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
84916
84991
|
const localScaffolds = unchangedPullScaffolds(targetDir, localBase);
|
|
84917
84992
|
const collected = collectFiles(targetDir, {
|
|
84918
84993
|
localScaffolds: new Set(Object.keys(localScaffolds)),
|
|
84994
|
+
checkCliCredentials: true,
|
|
84919
84995
|
include: opts.include ?? [],
|
|
84920
|
-
deployBlobs:
|
|
84996
|
+
deployBlobs: !opts.dryRun && opts.scope !== "functions",
|
|
84997
|
+
inlineFileLimitBytes: MAX_INLINE_DEPLOY_BYTES
|
|
84921
84998
|
});
|
|
84999
|
+
if (collected.cliCredentialFiles.length)
|
|
85000
|
+
refuseCredential(collected.cliCredentialFiles.sort()[0]);
|
|
84922
85001
|
const hashStartedAt = collected.blobs?.size && opts.timing ? performance.now() : void 0;
|
|
84923
85002
|
const publishedHashes = hashFiles(targetDir, collected.published);
|
|
84924
85003
|
const collectionEndedAt = performance.now();
|
|
@@ -84935,7 +85014,7 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
84935
85014
|
process.exit(1);
|
|
84936
85015
|
}
|
|
84937
85016
|
const tooLargeBlob = [...collected.blobs ?? []].find(([, size]) => size > MAX_DEPLOY_BLOB_BYTES);
|
|
84938
|
-
const sizeRefusal = tooLargeBlob ? `"${tooLargeBlob[0]}" exceeds the 25 MiB static file limit. Reduce its size or serve it from file storage.` : oversizeRefusal(collected);
|
|
85017
|
+
const sizeRefusal = tooLargeBlob ? `"${tooLargeBlob[0]}" exceeds the 25 MiB static file limit. Reduce its size or serve it from file storage.` : oversizeRefusal(collected, MAX_INLINE_DEPLOY_BYTES);
|
|
84939
85018
|
if (sizeRefusal) {
|
|
84940
85019
|
if (opts.json)
|
|
84941
85020
|
printJsonError("FILE_TOO_LARGE", sizeRefusal);
|
|
@@ -84965,7 +85044,7 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
84965
85044
|
process.exit(1);
|
|
84966
85045
|
}
|
|
84967
85046
|
if (collected.blobs?.size && collected.published.length > 2e4) {
|
|
84968
|
-
const message3 = "A site can contain up to 20,000 files.";
|
|
85047
|
+
const message3 = "A site can contain up to 20,000 files. Move extra assets to file storage.";
|
|
84969
85048
|
if (opts.json)
|
|
84970
85049
|
printJsonError("DEPLOY_TOO_MANY_FILES", message3);
|
|
84971
85050
|
else
|
|
@@ -86407,7 +86486,7 @@ var init_deploys = __esm({
|
|
|
86407
86486
|
|
|
86408
86487
|
// dist/commands/pull.js
|
|
86409
86488
|
import { existsSync as existsSync30, lstatSync as lstatSync5, mkdirSync as mkdirSync15, readFileSync as readFileSync33, readdirSync as readdirSync8, rmSync as rmSync12, writeFileSync as writeFileSync19 } from "node:fs";
|
|
86410
|
-
import { basename as basename7, dirname as dirname12, join as join38, relative as
|
|
86489
|
+
import { basename as basename7, dirname as dirname12, join as join38, relative as relative11, resolve as resolve17 } from "node:path";
|
|
86411
86490
|
function registerPull(program2) {
|
|
86412
86491
|
program2.command("pull [project]").description(`Download a project's deployed source files to the current directory. Scaffolds a tsconfig.json + package.json (only if absent) so \`${cliInvocation()} typecheck\` can catch undefined symbols locally before you deploy. In a linked folder, plain pull is the safe update when live is newer: files you have not edited move to the live version, your local edits and local-only files (AGENTS.md, notes, tests) are kept, and it stops without writing anything if a file changed both here and live.`).option("--env <env>", "Environment to pull from (dev or prod)", "prod").option("--out <dir>", "Output directory", ".").option("--force", "Also replace files you edited here with live, and delete published files you edited that live no longer has. Never deletes a file a deploy would not upload (AGENTS.md, CLAUDE.md, README.md, tests, dotfiles, .somewhereignore matches)").option("--json", "Print the raw source response as JSON").action(async (projectArg, opts) => {
|
|
86413
86492
|
const token = getToken();
|
|
@@ -86655,7 +86734,7 @@ function planRemovedFiles(outDir, expected, force, base = null) {
|
|
|
86655
86734
|
}
|
|
86656
86735
|
if (!entry.isFile())
|
|
86657
86736
|
continue;
|
|
86658
|
-
const relPath = normalizeRelPath(
|
|
86737
|
+
const relPath = normalizeRelPath(relative11(outDir, fullPath));
|
|
86659
86738
|
if (expected.has(relPath) || !publishable.has(relPath))
|
|
86660
86739
|
continue;
|
|
86661
86740
|
const was = base?.files[relPath];
|
|
@@ -90211,7 +90290,7 @@ var init_env = __esm({
|
|
|
90211
90290
|
|
|
90212
90291
|
// dist/commands/run.js
|
|
90213
90292
|
import { existsSync as existsSync35, readFileSync as readFileSync40 } from "node:fs";
|
|
90214
|
-
import { isAbsolute as
|
|
90293
|
+
import { isAbsolute as isAbsolute7, resolve as resolve20 } from "node:path";
|
|
90215
90294
|
import { createRequire as createRequire8 } from "node:module";
|
|
90216
90295
|
function parseArgs(values) {
|
|
90217
90296
|
if (!values.length)
|
|
@@ -90245,14 +90324,14 @@ function hasRelativeRuntimeImport(fileName2, code) {
|
|
|
90245
90324
|
return false;
|
|
90246
90325
|
}
|
|
90247
90326
|
const source = ts2.createSourceFile(fileName2, code, ts2.ScriptTarget.Latest, true);
|
|
90248
|
-
const
|
|
90327
|
+
const relative16 = /* @__PURE__ */ __name((node2) => node2 !== void 0 && ts2.isStringLiteralLike(node2) && /^\.\.?\//.test(node2.text), "relative");
|
|
90249
90328
|
const scan = /* @__PURE__ */ __name((node2) => {
|
|
90250
90329
|
if (ts2.isImportDeclaration(node2))
|
|
90251
|
-
return !node2.importClause?.isTypeOnly &&
|
|
90330
|
+
return !node2.importClause?.isTypeOnly && relative16(node2.moduleSpecifier);
|
|
90252
90331
|
if (ts2.isExportDeclaration(node2))
|
|
90253
|
-
return !node2.isTypeOnly &&
|
|
90332
|
+
return !node2.isTypeOnly && relative16(node2.moduleSpecifier);
|
|
90254
90333
|
if (ts2.isCallExpression(node2) && node2.expression.kind === ts2.SyntaxKind.ImportKeyword) {
|
|
90255
|
-
return
|
|
90334
|
+
return relative16(node2.arguments[0]);
|
|
90256
90335
|
}
|
|
90257
90336
|
return ts2.forEachChild(node2, (child) => scan(child) || void 0) === true;
|
|
90258
90337
|
}, "scan");
|
|
@@ -90276,7 +90355,7 @@ function registerRun(program2) {
|
|
|
90276
90355
|
}
|
|
90277
90356
|
projectId = config2.project_id;
|
|
90278
90357
|
}
|
|
90279
|
-
const absPath =
|
|
90358
|
+
const absPath = isAbsolute7(script) ? script : resolve20(process.cwd(), script);
|
|
90280
90359
|
if (!existsSync35(absPath)) {
|
|
90281
90360
|
error(`File not found: ${script}`);
|
|
90282
90361
|
process.exit(1);
|
|
@@ -90717,7 +90796,7 @@ var init_claim = __esm({
|
|
|
90717
90796
|
|
|
90718
90797
|
// dist/lib/frontend-dev.js
|
|
90719
90798
|
import { createRequire as createRequire9 } from "node:module";
|
|
90720
|
-
import { realpathSync as
|
|
90799
|
+
import { realpathSync as realpathSync5 } from "node:fs";
|
|
90721
90800
|
import { createConnection, createServer as createNetServer } from "node:net";
|
|
90722
90801
|
import { join as join43 } from "node:path";
|
|
90723
90802
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
@@ -90811,7 +90890,7 @@ async function relayIpv6Loopback(port) {
|
|
|
90811
90890
|
async function startFrontendDev(cwd, target, port = 8787, open4 = false) {
|
|
90812
90891
|
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
90813
90892
|
throw new Error("Port must be an integer from 1 through 65535.");
|
|
90814
|
-
cwd =
|
|
90893
|
+
cwd = realpathSync5(cwd);
|
|
90815
90894
|
const origin = deployedOrigin(target);
|
|
90816
90895
|
if (missingProjectDependencies(cwd).length)
|
|
90817
90896
|
throw new Error(INSTALL_PROJECT_DEPENDENCIES);
|
|
@@ -90961,7 +91040,7 @@ var init_preview_jobs = __esm({
|
|
|
90961
91040
|
// dist/commands/dev.js
|
|
90962
91041
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
90963
91042
|
import { existsSync as existsSync36 } from "node:fs";
|
|
90964
|
-
import { join as join44, relative as
|
|
91043
|
+
import { join as join44, relative as relative12 } from "node:path";
|
|
90965
91044
|
function previewFinishedReason(err) {
|
|
90966
91045
|
if (!(err instanceof CliApiError) || err.code !== "DRAFT_SESSION_TERMINAL")
|
|
90967
91046
|
return null;
|
|
@@ -91799,7 +91878,7 @@ async function runHotDeploy(opts) {
|
|
|
91799
91878
|
const watcher = esm_default.watch(cwd, {
|
|
91800
91879
|
ignoreInitial: true,
|
|
91801
91880
|
ignored: /* @__PURE__ */ __name((p2) => {
|
|
91802
|
-
const rel =
|
|
91881
|
+
const rel = relative12(cwd, p2);
|
|
91803
91882
|
if (!rel || rel.startsWith(".."))
|
|
91804
91883
|
return false;
|
|
91805
91884
|
const segments = rel.split(/[\\/]/);
|
|
@@ -91874,7 +91953,7 @@ async function runHotDeploy(opts) {
|
|
|
91874
91953
|
}
|
|
91875
91954
|
}, "flush");
|
|
91876
91955
|
const onChange = /* @__PURE__ */ __name((abs) => {
|
|
91877
|
-
const rel =
|
|
91956
|
+
const rel = relative12(cwd, abs);
|
|
91878
91957
|
if (!WATCH_EXTS.test(rel))
|
|
91879
91958
|
return;
|
|
91880
91959
|
pendingChanged.add(rel);
|
|
@@ -91882,7 +91961,7 @@ async function runHotDeploy(opts) {
|
|
|
91882
91961
|
schedule();
|
|
91883
91962
|
}, "onChange");
|
|
91884
91963
|
const onUnlink = /* @__PURE__ */ __name((abs) => {
|
|
91885
|
-
const rel =
|
|
91964
|
+
const rel = relative12(cwd, abs);
|
|
91886
91965
|
if (!WATCH_EXTS.test(rel))
|
|
91887
91966
|
return;
|
|
91888
91967
|
pendingDeleted.add(rel);
|
|
@@ -108651,7 +108730,7 @@ var require_lib5 = __commonJS({
|
|
|
108651
108730
|
return `${this.algorithm}-${this.digest}${getOptString(this.options)}`;
|
|
108652
108731
|
}
|
|
108653
108732
|
};
|
|
108654
|
-
function integrityHashToString(toString,
|
|
108733
|
+
function integrityHashToString(toString, sep3, opts, hashes) {
|
|
108655
108734
|
const toStringIsNotEmpty = toString !== "";
|
|
108656
108735
|
let shouldAddFirstSep = false;
|
|
108657
108736
|
let complement = "";
|
|
@@ -108661,7 +108740,7 @@ var require_lib5 = __commonJS({
|
|
|
108661
108740
|
if (hashString) {
|
|
108662
108741
|
shouldAddFirstSep = true;
|
|
108663
108742
|
complement += hashString;
|
|
108664
|
-
complement +=
|
|
108743
|
+
complement += sep3;
|
|
108665
108744
|
}
|
|
108666
108745
|
}
|
|
108667
108746
|
const finalHashString = Hash.prototype.toString.call(hashes[lastIndex], opts);
|
|
@@ -108670,7 +108749,7 @@ var require_lib5 = __commonJS({
|
|
|
108670
108749
|
complement += finalHashString;
|
|
108671
108750
|
}
|
|
108672
108751
|
if (toStringIsNotEmpty && shouldAddFirstSep) {
|
|
108673
|
-
return toString +
|
|
108752
|
+
return toString + sep3 + complement;
|
|
108674
108753
|
}
|
|
108675
108754
|
return toString + complement;
|
|
108676
108755
|
}
|
|
@@ -108689,18 +108768,18 @@ var require_lib5 = __commonJS({
|
|
|
108689
108768
|
return Object.keys(this).length === 0;
|
|
108690
108769
|
}
|
|
108691
108770
|
toString(opts) {
|
|
108692
|
-
let
|
|
108771
|
+
let sep3 = opts?.sep || " ";
|
|
108693
108772
|
let toString = "";
|
|
108694
108773
|
if (opts?.strict) {
|
|
108695
|
-
|
|
108774
|
+
sep3 = sep3.replace(/\S+/g, " ");
|
|
108696
108775
|
for (const hash of SPEC_ALGORITHMS) {
|
|
108697
108776
|
if (this[hash]) {
|
|
108698
|
-
toString = integrityHashToString(toString,
|
|
108777
|
+
toString = integrityHashToString(toString, sep3, opts, this[hash]);
|
|
108699
108778
|
}
|
|
108700
108779
|
}
|
|
108701
108780
|
} else {
|
|
108702
108781
|
for (const hash of Object.keys(this)) {
|
|
108703
|
-
toString = integrityHashToString(toString,
|
|
108782
|
+
toString = integrityHashToString(toString, sep3, opts, this[hash]);
|
|
108704
108783
|
}
|
|
108705
108784
|
}
|
|
108706
108785
|
return toString;
|
|
@@ -110586,11 +110665,11 @@ var require_polyfill = __commonJS({
|
|
|
110586
110665
|
} = __require("fs/promises");
|
|
110587
110666
|
var {
|
|
110588
110667
|
dirname: dirname18,
|
|
110589
|
-
isAbsolute:
|
|
110668
|
+
isAbsolute: isAbsolute8,
|
|
110590
110669
|
join: join57,
|
|
110591
110670
|
parse: parse3,
|
|
110592
110671
|
resolve: resolve27,
|
|
110593
|
-
sep:
|
|
110672
|
+
sep: sep3,
|
|
110594
110673
|
toNamespacedPath
|
|
110595
110674
|
} = __require("path");
|
|
110596
110675
|
var { fileURLToPath: fileURLToPath2 } = __require("url");
|
|
@@ -110732,7 +110811,7 @@ var require_polyfill = __commonJS({
|
|
|
110732
110811
|
return checkParentPaths(src, srcStat, destParent);
|
|
110733
110812
|
}
|
|
110734
110813
|
__name(checkParentPaths, "checkParentPaths");
|
|
110735
|
-
var normalizePathToArray = /* @__PURE__ */ __name((path3) => resolve27(path3).split(
|
|
110814
|
+
var normalizePathToArray = /* @__PURE__ */ __name((path3) => resolve27(path3).split(sep3).filter(Boolean), "normalizePathToArray");
|
|
110736
110815
|
function isSrcSubdir(src, dest) {
|
|
110737
110816
|
const srcArr = normalizePathToArray(src);
|
|
110738
110817
|
const destArr = normalizePathToArray(dest);
|
|
@@ -110877,7 +110956,7 @@ var require_polyfill = __commonJS({
|
|
|
110877
110956
|
__name(copyDir, "copyDir");
|
|
110878
110957
|
async function onLink(destStat, src, dest) {
|
|
110879
110958
|
let resolvedSrc = await readlink(src);
|
|
110880
|
-
if (!
|
|
110959
|
+
if (!isAbsolute8(resolvedSrc)) {
|
|
110881
110960
|
resolvedSrc = resolve27(dirname18(src), resolvedSrc);
|
|
110882
110961
|
}
|
|
110883
110962
|
if (!destStat) {
|
|
@@ -110892,7 +110971,7 @@ var require_polyfill = __commonJS({
|
|
|
110892
110971
|
}
|
|
110893
110972
|
throw err;
|
|
110894
110973
|
}
|
|
110895
|
-
if (!
|
|
110974
|
+
if (!isAbsolute8(resolvedDest)) {
|
|
110896
110975
|
resolvedDest = resolve27(dirname18(dest), resolvedDest);
|
|
110897
110976
|
}
|
|
110898
110977
|
if (isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
@@ -110945,7 +111024,7 @@ var require_cp = __commonJS({
|
|
|
110945
111024
|
// node_modules/@npmcli/fs/lib/with-temp-dir.js
|
|
110946
111025
|
var require_with_temp_dir = __commonJS({
|
|
110947
111026
|
"node_modules/@npmcli/fs/lib/with-temp-dir.js"(exports, module) {
|
|
110948
|
-
var { join: join57, sep:
|
|
111027
|
+
var { join: join57, sep: sep3 } = __require("path");
|
|
110949
111028
|
var getOptions = require_get_options();
|
|
110950
111029
|
var { mkdir, mkdtemp, rm } = __require("fs/promises");
|
|
110951
111030
|
var withTempDir = /* @__PURE__ */ __name(async (root, fn, opts) => {
|
|
@@ -110953,7 +111032,7 @@ var require_with_temp_dir = __commonJS({
|
|
|
110953
111032
|
copy: ["tmpPrefix"]
|
|
110954
111033
|
});
|
|
110955
111034
|
await mkdir(root, { recursive: true });
|
|
110956
|
-
const target = await mkdtemp(join57(`${root}${
|
|
111035
|
+
const target = await mkdtemp(join57(`${root}${sep3}`, options2.tmpPrefix || ""));
|
|
110957
111036
|
let err;
|
|
110958
111037
|
let result;
|
|
110959
111038
|
try {
|
|
@@ -110999,7 +111078,7 @@ var require_readdir_scoped = __commonJS({
|
|
|
110999
111078
|
// node_modules/@npmcli/fs/lib/move-file.js
|
|
111000
111079
|
var require_move_file = __commonJS({
|
|
111001
111080
|
"node_modules/@npmcli/fs/lib/move-file.js"(exports, module) {
|
|
111002
|
-
var { dirname: dirname18, join: join57, resolve: resolve27, relative:
|
|
111081
|
+
var { dirname: dirname18, join: join57, resolve: resolve27, relative: relative16, isAbsolute: isAbsolute8 } = __require("path");
|
|
111003
111082
|
var fs2 = __require("fs/promises");
|
|
111004
111083
|
var pathExists = /* @__PURE__ */ __name(async (path3) => {
|
|
111005
111084
|
try {
|
|
@@ -111043,8 +111122,8 @@ var require_move_file = __commonJS({
|
|
|
111043
111122
|
if (root) {
|
|
111044
111123
|
await Promise.all(symlinks.map(async ({ source: symSource, destination: symDestination }) => {
|
|
111045
111124
|
let target = await fs2.readlink(symSource);
|
|
111046
|
-
if (
|
|
111047
|
-
target = resolve27(symDestination,
|
|
111125
|
+
if (isAbsolute8(target)) {
|
|
111126
|
+
target = resolve27(symDestination, relative16(symSource, target));
|
|
111048
111127
|
}
|
|
111049
111128
|
let targetStat = "file";
|
|
111050
111129
|
try {
|
|
@@ -133220,7 +133299,7 @@ ${GITHUB_REPOSITORY_ID}`,
|
|
|
133220
133299
|
// dist/commands/update.js
|
|
133221
133300
|
import { spawn as spawn6 } from "node:child_process";
|
|
133222
133301
|
import { randomBytes as randomBytes8 } from "node:crypto";
|
|
133223
|
-
import { closeSync as
|
|
133302
|
+
import { closeSync as closeSync6, constants as constants2, fstatSync, mkdtempSync as mkdtempSync4, openSync as openSync6, readFileSync as readFileSync42, readSync as readSync2, rmSync as rmSync15, unlinkSync as unlinkSync5, writeFileSync as writeFileSync25 } from "node:fs";
|
|
133224
133303
|
import { createServer } from "node:http";
|
|
133225
133304
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
133226
133305
|
import { join as join48 } from "node:path";
|
|
@@ -133295,7 +133374,7 @@ async function runPinnedNpm(args, cwd, ambientEnvironment, userConfigPath, globa
|
|
|
133295
133374
|
});
|
|
133296
133375
|
}
|
|
133297
133376
|
function snapshotAuthenticatedArtifact(tarballPath) {
|
|
133298
|
-
const fd =
|
|
133377
|
+
const fd = openSync6(tarballPath, constants2.O_RDONLY | (constants2.O_NOFOLLOW ?? 0));
|
|
133299
133378
|
try {
|
|
133300
133379
|
const stat7 = fstatSync(fd);
|
|
133301
133380
|
if (!stat7.isFile() || stat7.size <= 0 || stat7.size > MAX_UPDATE_BYTES) {
|
|
@@ -133304,14 +133383,14 @@ function snapshotAuthenticatedArtifact(tarballPath) {
|
|
|
133304
133383
|
unlinkSync5(tarballPath);
|
|
133305
133384
|
return readOpenArtifact(fd, stat7.size);
|
|
133306
133385
|
} finally {
|
|
133307
|
-
|
|
133386
|
+
closeSync6(fd);
|
|
133308
133387
|
}
|
|
133309
133388
|
}
|
|
133310
133389
|
function readOpenArtifact(fd, size) {
|
|
133311
133390
|
const bytes = Buffer.allocUnsafe(size);
|
|
133312
133391
|
let offset = 0;
|
|
133313
133392
|
while (offset < size) {
|
|
133314
|
-
const count2 =
|
|
133393
|
+
const count2 = readSync2(fd, bytes, offset, size - offset, offset);
|
|
133315
133394
|
if (count2 === 0)
|
|
133316
133395
|
throw new Error("the downloaded update artifact ended while being verified");
|
|
133317
133396
|
offset += count2;
|
|
@@ -135945,7 +136024,7 @@ import { randomUUID as randomUUID12 } from "node:crypto";
|
|
|
135945
136024
|
import { setDefaultResultOrder } from "node:dns";
|
|
135946
136025
|
import { lookup } from "node:dns/promises";
|
|
135947
136026
|
import { existsSync as existsSync38, mkdirSync as mkdirSync20, readFileSync as readFileSync44, writeFileSync as writeFileSync26 } from "node:fs";
|
|
135948
|
-
import { basename as basename11, dirname as dirname15, join as join49, relative as
|
|
136027
|
+
import { basename as basename11, dirname as dirname15, join as join49, relative as relative13, resolve as resolve24 } from "node:path";
|
|
135949
136028
|
function launchOptions(extra = {}) {
|
|
135950
136029
|
return { ...extra, args: ["--disable-features=AsyncDns", ...extra.args ?? []] };
|
|
135951
136030
|
}
|
|
@@ -136173,7 +136252,7 @@ var init_app_test = __esm({
|
|
|
136173
136252
|
}
|
|
136174
136253
|
/** What this run tests: the project, environment, preview, origin and script. */
|
|
136175
136254
|
identity() {
|
|
136176
|
-
const script = process.argv[1] ?
|
|
136255
|
+
const script = process.argv[1] ? relative13(this.root, resolve24(process.argv[1])) : null;
|
|
136177
136256
|
return {
|
|
136178
136257
|
project_id: this.control.projectId,
|
|
136179
136258
|
environment: this.control.environment,
|
|
@@ -136367,13 +136446,13 @@ page ${i + 1}: ${state}`).join("");
|
|
|
136367
136446
|
...check,
|
|
136368
136447
|
...check.error ? { error: scrub(check.error) } : {}
|
|
136369
136448
|
}));
|
|
136370
|
-
const resultFile =
|
|
136449
|
+
const resultFile = relative13(this.root, this.resultsPath);
|
|
136371
136450
|
const handOver = process.env.SW_TEST_REPORT;
|
|
136372
136451
|
if (handOver)
|
|
136373
136452
|
writeFileSync26(handOver, JSON.stringify({ checks: reported, resultFile }) + "\n");
|
|
136374
136453
|
else {
|
|
136375
136454
|
const verbose = process.argv.includes("--verbose") || process.env.SW_TEST_VERBOSE === "1";
|
|
136376
|
-
const script = process.argv[1] ?
|
|
136455
|
+
const script = process.argv[1] ? relative13(this.root, resolve24(process.argv[1])) : "this script";
|
|
136377
136456
|
process.stdout.write(describeReport([{ script, checks: reported, resultFile }], { verbose }).join("\n") + "\n");
|
|
136378
136457
|
}
|
|
136379
136458
|
if (live !== this.release) {
|
|
@@ -136798,7 +136877,7 @@ var init_test_session = __esm({
|
|
|
136798
136877
|
|
|
136799
136878
|
// dist/lib/prepared-actor-session.js
|
|
136800
136879
|
import { createHash as createHash10 } from "node:crypto";
|
|
136801
|
-
import { closeSync as
|
|
136880
|
+
import { closeSync as closeSync7, openSync as openSync7, rmSync as rmSync16 } from "node:fs";
|
|
136802
136881
|
import { setTimeout as delay2 } from "node:timers/promises";
|
|
136803
136882
|
async function preparedActorSession(root, target, name) {
|
|
136804
136883
|
const read = /* @__PURE__ */ __name(() => preparedActorState(root, target, name), "read");
|
|
@@ -136811,7 +136890,7 @@ async function preparedActorSession(root, target, name) {
|
|
|
136811
136890
|
while (Date.now() < deadline) {
|
|
136812
136891
|
let fd;
|
|
136813
136892
|
try {
|
|
136814
|
-
fd =
|
|
136893
|
+
fd = openSync7(lock, "wx", 384);
|
|
136815
136894
|
} catch (error3) {
|
|
136816
136895
|
if (error3.code !== "EEXIST")
|
|
136817
136896
|
throw error3;
|
|
@@ -136833,7 +136912,7 @@ async function preparedActorSession(root, target, name) {
|
|
|
136833
136912
|
writePrivateFile(latest.path, JSON.stringify(renewed, null, 2) + "\n");
|
|
136834
136913
|
return token;
|
|
136835
136914
|
} finally {
|
|
136836
|
-
|
|
136915
|
+
closeSync7(fd);
|
|
136837
136916
|
rmSync16(lock, { force: true });
|
|
136838
136917
|
}
|
|
136839
136918
|
}
|
|
@@ -136942,7 +137021,7 @@ var init_reference_check_note = __esm({
|
|
|
136942
137021
|
// dist/lib/test-scripts.js
|
|
136943
137022
|
import { createRequire as createRequire10 } from "node:module";
|
|
136944
137023
|
import { existsSync as existsSync39, mkdirSync as mkdirSync21, readFileSync as readFileSync45, readdirSync as readdirSync9, rmSync as rmSync17, statSync as statSync9, writeFileSync as writeFileSync27 } from "node:fs";
|
|
136945
|
-
import { dirname as dirname16, join as join50, relative as
|
|
137024
|
+
import { dirname as dirname16, join as join50, relative as relative14, resolve as resolve25 } from "node:path";
|
|
136946
137025
|
import { spawn as spawn7, spawnSync as spawnSync5 } from "node:child_process";
|
|
136947
137026
|
function hasSpecFiles(root) {
|
|
136948
137027
|
const walk2 = /* @__PURE__ */ __name((dir) => {
|
|
@@ -136961,7 +137040,7 @@ function hasSpecFiles(root) {
|
|
|
136961
137040
|
}
|
|
136962
137041
|
function listScripts(root, files) {
|
|
136963
137042
|
if (files.length)
|
|
136964
|
-
return files.map((file) =>
|
|
137043
|
+
return files.map((file) => relative14(root, resolve25(root, file)));
|
|
136965
137044
|
const dir = join50(root, "tests");
|
|
136966
137045
|
if (!existsSync39(dir))
|
|
136967
137046
|
return [];
|
|
@@ -138221,7 +138300,7 @@ __export(test_reporter_exports, {
|
|
|
138221
138300
|
confirmedRelease: () => confirmedRelease,
|
|
138222
138301
|
default: () => TestReporter
|
|
138223
138302
|
});
|
|
138224
|
-
import { relative as
|
|
138303
|
+
import { relative as relative15 } from "node:path";
|
|
138225
138304
|
function confirmedRelease(start, seen2, live) {
|
|
138226
138305
|
if (!start || !live)
|
|
138227
138306
|
return null;
|
|
@@ -138273,7 +138352,7 @@ var init_test_reporter = __esm({
|
|
|
138273
138352
|
const location2 = result.errors[i]?.location;
|
|
138274
138353
|
return location2 ? describeError({ message: "", location: location2 }).replace(/: $/, "") + ": " + message3 : message3;
|
|
138275
138354
|
}) : result.errors.map((error3) => describeError(error3));
|
|
138276
|
-
const file =
|
|
138355
|
+
const file = relative15(process.cwd(), test2.location.file);
|
|
138277
138356
|
const skipReason = result.status === "skipped" ? scrub(result.annotations.find(({ type, description }) => type === "skip" && description)?.description ?? "no reason given").slice(0, 200) : void 0;
|
|
138278
138357
|
const entry = { ...details, ...skipReason ? { skipReason } : {}, status: result.status, outcome: test2.outcome(), title: scrub(details.title).slice(0, 200), errors, step: result.steps.find((step2) => step2.error)?.category ?? "test body", file, line: test2.location.line };
|
|
138279
138358
|
this.entries.push(entry);
|