@somewhere-cloud/cli 0.38.181 → 0.38.183
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 +12 -0
- package/dist/commands/init.js +1 -1
- package/dist/lib/bundle.js +190 -146
- package/dist/lib/bundle.js.map +2 -2
- package/dist/types/lib/client.d.ts +6 -1
- package/dist/types/lib/test-control.d.ts +1 -1
- package/dist/types/lib/test-session.d.ts +3 -1
- package/dist/types/lib/testing-app.d.ts +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
- package/runtime/DECLARED-DATA-VENDOR.json +8 -8
- package/runtime/PLATFORM-SOURCE.json +1 -1
- package/runtime/declared-data.cjs +10 -4
package/dist/lib/bundle.js
CHANGED
|
@@ -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: readFile3, mkdir } = __require("node:fs/promises");
|
|
20318
|
-
var { dirname:
|
|
20318
|
+
var { dirname: dirname18, 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(
|
|
20574
|
+
await mkdir(dirname18(resolvedPath), { recursive: true });
|
|
20575
20575
|
const data2 = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
20576
20576
|
hash,
|
|
20577
20577
|
snapshot
|
|
@@ -34013,13 +34013,15 @@ var init_client = __esm({
|
|
|
34013
34013
|
static {
|
|
34014
34014
|
__name(this, "ApiClient");
|
|
34015
34015
|
}
|
|
34016
|
+
linkedProjectId;
|
|
34016
34017
|
/** Mutable: the refresh-on-401 path swaps in a fresh access key in place so
|
|
34017
34018
|
* the retry (and every later call on this instance) uses the new token. */
|
|
34018
34019
|
/** null: an unauthenticated client (no Authorization header, never a
|
|
34019
34020
|
* stored-login refresh), for the public anonymous-deploy routes. */
|
|
34020
34021
|
token;
|
|
34021
34022
|
temporaryConfig;
|
|
34022
|
-
constructor(token) {
|
|
34023
|
+
constructor(token, linkedProjectId) {
|
|
34024
|
+
this.linkedProjectId = linkedProjectId;
|
|
34023
34025
|
this.token = token;
|
|
34024
34026
|
const saved = token === null ? null : loadConfig();
|
|
34025
34027
|
this.temporaryConfig = saved?.temporary && saved.token === token ? saved : null;
|
|
@@ -34033,6 +34035,25 @@ var init_client = __esm({
|
|
|
34033
34035
|
this.checkTemporaryExpiry();
|
|
34034
34036
|
return this.token === null ? {} : { Authorization: `Bearer ${this.token}` };
|
|
34035
34037
|
}
|
|
34038
|
+
/** A refusal for a target selected from .somewhere.json may identify only
|
|
34039
|
+
* the caller. Its status and code cannot distinguish a missing project
|
|
34040
|
+
* from one the caller cannot access. Explicit project refs omit this context. */
|
|
34041
|
+
async linkedProjectError(error3, path3, body, query) {
|
|
34042
|
+
const id = this.linkedProjectId;
|
|
34043
|
+
if (!id || this.token === null || !(error3 instanceof CliApiError) || error3.statusCode !== 404 || error3.code !== "PROJECT_NOT_FOUND")
|
|
34044
|
+
return error3;
|
|
34045
|
+
const target = `/projects/${encodeURIComponent(id)}`;
|
|
34046
|
+
if (path3 !== target && !path3.startsWith(target + "/") && query?.project_id !== id && !(body && typeof body === "object" && "project_id" in body && body.project_id === id))
|
|
34047
|
+
return error3;
|
|
34048
|
+
const identity = await this.call("GET", "/auth/whoami", void 0, void 0, { timeoutMs: 3e3, refresh: false }).then((answer) => {
|
|
34049
|
+
if (typeof answer?.user?.email !== "string")
|
|
34050
|
+
return "";
|
|
34051
|
+
const match = /^([a-z0-9])[^@\s]*@([a-z0-9])[^@\s]*$/i.exec(answer.user.email);
|
|
34052
|
+
return match ? ` Signed in as ${match[1]}\u2026@${match[2]}\u2026.` : "";
|
|
34053
|
+
}).catch(() => "");
|
|
34054
|
+
error3.message = `This sign-in cannot open the project in this folder's .somewhere.json.${identity} Check whether the folder was linked with a different account or CLI configuration.`;
|
|
34055
|
+
return error3;
|
|
34056
|
+
}
|
|
34036
34057
|
/** Run a one-off script against the project's live DEV bindings via the
|
|
34037
34058
|
* dedicated runner worker. Same auth + `{ ok, data }` envelope as call(), but
|
|
34038
34059
|
* rooted at RUNNER_BASE_URL instead of the /v1 API (see that constant for the
|
|
@@ -34067,11 +34088,13 @@ var init_client = __esm({
|
|
|
34067
34088
|
if (err instanceof CliApiError && err.statusCode === 401)
|
|
34068
34089
|
this.checkTemporaryExpiry();
|
|
34069
34090
|
if (!(err instanceof CliApiError) || err.code !== "API_KEY_EXPIRED" || opts?.refresh === false || this.token === null)
|
|
34070
|
-
throw err;
|
|
34091
|
+
throw await this.linkedProjectError(err, path3, body, query);
|
|
34071
34092
|
const refreshed = await this.refreshAccessKey(opts?.timeoutMs);
|
|
34072
34093
|
if (!refreshed)
|
|
34073
34094
|
throw err;
|
|
34074
|
-
return await this.request(method, path3, body, query, opts)
|
|
34095
|
+
return await this.request(method, path3, body, query, opts).catch(async (retryError) => {
|
|
34096
|
+
throw await this.linkedProjectError(retryError, path3, body, query);
|
|
34097
|
+
});
|
|
34075
34098
|
}
|
|
34076
34099
|
}
|
|
34077
34100
|
/** Authenticated request whose body and response remain streams. The body is
|
|
@@ -44255,7 +44278,7 @@ Existing integer IDs stay integers. Declare composite uniqueness with \`unique:
|
|
|
44255
44278
|
|
|
44256
44279
|
- Browser reads and writes use generated \`somewhere:data\`. \`client\` sets allowed operations and fields. Include the key in explicit read lists. Browser calls throw errors, and list pages use the returned \`next\` as \`after\` (at most 100 rows per page).
|
|
44257
44280
|
- \`anyOf()\` grants access through either branch. \`allOf()\` requires both the membership gate and the action rule. \`parent()\` inherits the parent row's access. Declare \`parent({ author, update, delete })\` on the child table's first deploy. If you display the author's email, use a signed-in creation endpoint that takes the address from the session and leave browser create disabled. For staff replies through \`parent()\`, grant staff create permission on the ticket's rule. See \`somewhere docs declared-data --section comments-that-their-author-may-edit\`.
|
|
44258
|
-
- \`sw.db.from/insert/update/remove\` apply the caller's scope and return \`{ data, count, changes }\`. Use \`where\`, \`columns\`, \`order\`, \`limit\` and \`offset\` for server reads. \`sw.db.tx\` takes an array of write intents. Supply related IDs up front.
|
|
44281
|
+
- \`sw.db.from/insert/update/remove\` apply the caller's scope and return \`{ data, count, changes }\`. An insert puts the new row in \`data[0]\`. Use \`where\`, \`columns\`, \`order\`, \`limit\` and \`offset\` for server reads. \`sw.db.tx\` takes an array of write intents. Supply related IDs up front.
|
|
44259
44282
|
- Authorize before \`sw.db.server\` calls, which bypass the caller's scope. Keep declared scopes on records users work with, even when an exceptional write needs server authority. Use \`serverOnly()\` for protected ledgers and job state. Raw SQL uses a separate raw database.
|
|
44260
44283
|
- For booking and help desk schemas, see \`somewhere docs sw.db --section provider-or-booker-and-owner-or-staff-recipes\`. For browser paging, server paging and transactions, see \`somewhere docs sw.db\`.
|
|
44261
44284
|
|
|
@@ -44268,7 +44291,7 @@ Use \`client.intake\` for public submissions to a private parent row. See
|
|
|
44268
44291
|
- 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\`.
|
|
44269
44292
|
- 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\`.
|
|
44270
44293
|
- 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.
|
|
44271
|
-
- 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.
|
|
44294
|
+
- 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 } })\`.
|
|
44272
44295
|
|
|
44273
44296
|
### Run and verify
|
|
44274
44297
|
|
|
@@ -44283,7 +44306,7 @@ Prove the brief in \`tests/starter.mjs\` (\`npm test\`, from the app folder, aft
|
|
|
44283
44306
|
|
|
44284
44307
|
If the folder already has Playwright tests, keep running them; put new checks in \`tests/starter.mjs\`. Tests that write change rows in the live app: for an app with real customers, test on a preview (\`somewhere preview\`, then \`openTestApp({ preview: true })\`). After every deploy the platform runs its own smoke check, plus any check lists saved in \`checks/\`; \`somewhere test\` shows the result.
|
|
44285
44308
|
|
|
44286
|
-
|
|
44309
|
+
Deploy with \`somewhere deploy\`; there is no build step, and a routine edit needs no separate check first. A deploy type-checks locally when dependencies are installed and runs the platform's compile, schema and secret checks; a refusal from those checks changes nothing, so fix what it names and deploy again. If a later step fails, the answer says which version is live and whether the database changed; act on that. Run \`somewhere deploy --dry-run\` first when a change removes a table, column, file or handler, or widens who can read existing rows: it lists those effects before they happen. When testing changes with real users or data, use \`somewhere preview\`, test with \`somewhere test --preview\`, then promote. See \`somewhere docs dev-environments\`. Inspect failures with \`somewhere errors\` and \`somewhere logs\`. Keep test IDs when restyling. See \`somewhere docs test\`.
|
|
44287
44310
|
|
|
44288
44311
|
Use \`somewhere docs <topic> --section <id>\` for one section or \`--full\` for all examples. Ask before destructive or paid actions unless the user already authorized them.
|
|
44289
44312
|
`;
|
|
@@ -44586,16 +44609,12 @@ function createGreenTemplate(appName = "somewhere-starter") {
|
|
|
44586
44609
|
},
|
|
44587
44610
|
{ path: "src/App.tsx", content: APP },
|
|
44588
44611
|
{ path: "src/main.tsx", content: MAIN },
|
|
44589
|
-
{ path: "src/services/greeting.ts", content: SERVICE },
|
|
44590
44612
|
{ path: "src/styles.css", content: STYLES },
|
|
44591
|
-
{ path: "api/greeting.ts", content: API },
|
|
44592
44613
|
{ path: "api/auth/[...path].ts", content: "export { somewhereAuth as default } from '@somewhere-cloud/sdk/server';\n" },
|
|
44593
|
-
{ path: "db/schema.ts", content: SCHEMA },
|
|
44594
|
-
{ path: "types/app.ts", content: APP_TYPES },
|
|
44595
44614
|
ASSET_TYPES_FILE
|
|
44596
44615
|
];
|
|
44597
44616
|
}
|
|
44598
|
-
var packageJson, TSCONFIG,
|
|
44617
|
+
var packageJson, TSCONFIG, APP, MAIN, STYLES, README;
|
|
44599
44618
|
var init_init_green_template = __esm({
|
|
44600
44619
|
"dist/lib/init-green-template.js"() {
|
|
44601
44620
|
"use strict";
|
|
@@ -44648,67 +44667,11 @@ var init_init_green_template = __esm({
|
|
|
44648
44667
|
"include": ["src", "api", "db", "types", "*.ts"]
|
|
44649
44668
|
}
|
|
44650
44669
|
`;
|
|
44651
|
-
|
|
44652
|
-
message: string;
|
|
44653
|
-
}
|
|
44654
|
-
`;
|
|
44655
|
-
SCHEMA = `// Starter table. To replace the greeting with your app, declare your own tables here
|
|
44656
|
-
// (a schema needs at least one) and delete the greeting files: api/greeting.ts,
|
|
44657
|
-
// src/services/greeting.ts, types/app.ts and the greeting code in src/App.tsx. Then:
|
|
44658
|
-
// - Never deployed: delete the greetings table below.
|
|
44659
|
-
// - Already deployed: replace it with \`greetings: removedTable()\` (import removedTable
|
|
44660
|
-
// from 'somewhere/db'). The deploy retires it and keeps its rows for 30 days;
|
|
44661
|
-
// declaring it again within 30 days restores them. Leave it declared to keep it.
|
|
44662
|
-
// - Unsure: delete it and run \`somewhere deploy-check .\`. A deployed table is refused
|
|
44663
|
-
// with SCHEMA_DEPLOY_REFUSED naming it and nothing changes; then use removedTable().
|
|
44664
|
-
import { id, schema, serverOnly, table, text } from 'somewhere/db';
|
|
44665
|
-
|
|
44666
|
-
export default schema({
|
|
44667
|
-
greetings: table({
|
|
44668
|
-
id: id(),
|
|
44669
|
-
message: text({ default: 'Your full-stack app is ready.' }),
|
|
44670
|
-
}, {
|
|
44671
|
-
scope: serverOnly(),
|
|
44672
|
-
}),
|
|
44673
|
-
});
|
|
44674
|
-
`;
|
|
44675
|
-
API = `// Starter endpoint. To remove the greeting, follow the steps at the top of db/schema.ts.
|
|
44676
|
-
export default sw.endpoint({
|
|
44677
|
-
auth: 'none', // deliberate: public and read-only; anyone can fetch the greeting
|
|
44678
|
-
handler: async (_input, sw) => {
|
|
44679
|
-
const result = await sw.db.from('greetings', { limit: 1 });
|
|
44680
|
-
const message = result.data[0]?.message;
|
|
44681
|
-
return { message: typeof message === 'string' ? message : 'Your full-stack app is ready.' };
|
|
44682
|
-
},
|
|
44683
|
-
});
|
|
44684
|
-
`;
|
|
44685
|
-
SERVICE = `import type { GreetingResponse } from '../../types/app';
|
|
44686
|
-
|
|
44687
|
-
export async function loadGreeting(): Promise<GreetingResponse> {
|
|
44688
|
-
const response = await fetch('/api/greeting');
|
|
44689
|
-
if (!response.ok) throw new Error(\`Request failed (\${response.status})\`);
|
|
44690
|
-
return response.json() as Promise<GreetingResponse>;
|
|
44691
|
-
}
|
|
44692
|
-
`;
|
|
44693
|
-
APP = `import { useEffect, useState } from 'react';
|
|
44694
|
-
import { loadGreeting } from './services/greeting';
|
|
44695
|
-
|
|
44696
|
-
export function App() {
|
|
44697
|
-
const [message, setMessage] = useState('Connecting frontend, function, and database\u2026');
|
|
44698
|
-
|
|
44699
|
-
useEffect(() => {
|
|
44700
|
-
void loadGreeting()
|
|
44701
|
-
.then((result) => setMessage(result.message))
|
|
44702
|
-
.catch((error: unknown) => {
|
|
44703
|
-
setMessage(error instanceof Error ? error.message : 'Could not load the greeting.');
|
|
44704
|
-
});
|
|
44705
|
-
}, []);
|
|
44706
|
-
|
|
44670
|
+
APP = `export function App() {
|
|
44707
44671
|
return (
|
|
44708
44672
|
<main>
|
|
44709
44673
|
<p className="eyebrow">somewhere.cloud starter</p>
|
|
44710
|
-
<h1>Start
|
|
44711
|
-
<p className="message">{message}</p>
|
|
44674
|
+
<h1>Start building your app.</h1>
|
|
44712
44675
|
<p className="hint">Edit <code>src/App.tsx</code>, then deploy the raw source.</p>
|
|
44713
44676
|
</main>
|
|
44714
44677
|
);
|
|
@@ -44736,7 +44699,6 @@ body { margin: 0; min-width: 320px; }
|
|
|
44736
44699
|
main { width: min(720px, calc(100% - 32px)); margin: 14vh auto; }
|
|
44737
44700
|
h1 { max-width: 660px; margin: 12px 0 24px; font-size: clamp(2.7rem, 8vw, 5.5rem); line-height: .94; letter-spacing: -.06em; }
|
|
44738
44701
|
.eyebrow { color: #14734c; font-weight: 750; text-transform: uppercase; letter-spacing: .12em; }
|
|
44739
|
-
.message { padding: 20px 22px; border: 1px solid #c6d8ce; border-radius: 16px; background: rgba(255, 255, 255, .82); }
|
|
44740
44702
|
.hint { color: #4f665b; }
|
|
44741
44703
|
code { color: #0e6542; }
|
|
44742
44704
|
`;
|
|
@@ -44744,19 +44706,11 @@ code { color: #0e6542; }
|
|
|
44744
44706
|
|
|
44745
44707
|
${PROJECT_LINK_README}
|
|
44746
44708
|
|
|
44747
|
-
|
|
44748
|
-
|
|
44749
|
-
|
|
44750
|
-
the greeting message; add caller authorization before serving private data.
|
|
44751
|
-
The SDK and \`api/auth/[...path].ts\` are included; add your sign-in UI or use
|
|
44752
|
-
\`somewhere init --template auth\` for the complete sign-in screens.
|
|
44753
|
-
|
|
44754
|
-
To replace the greeting, follow the steps at the top of \`db/schema.ts\`;
|
|
44755
|
-
they cover a table that was never deployed, one that was, and not knowing
|
|
44756
|
-
which. A missing optional include directory is harmless.
|
|
44709
|
+
Start with a React page and the SDK auth route at \`api/auth/[...path].ts\`.
|
|
44710
|
+
Edit \`src/App.tsx\` to build your UI, or choose \`somewhere init --template auth\`
|
|
44711
|
+
when you want generated sign-in screens.
|
|
44757
44712
|
|
|
44758
|
-
|
|
44759
|
-
it is not the default for your app's data. Choose fitting declared access
|
|
44713
|
+
Choose fitting declared access
|
|
44760
44714
|
before the first deploy: \`owner()\` for personal rows, \`group()\` for teams,
|
|
44761
44715
|
and \`anyOf()\` for combined access. For booking and help-desk rules, read:
|
|
44762
44716
|
\`somewhere docs sw.db --section provider-or-booker-and-owner-or-staff-recipes\`
|
|
@@ -44765,7 +44719,6 @@ To share your own rows with specific people, read:
|
|
|
44765
44719
|
|
|
44766
44720
|
\`\`\`sh
|
|
44767
44721
|
somewhere typecheck
|
|
44768
|
-
somewhere deploy-check .
|
|
44769
44722
|
somewhere deploy
|
|
44770
44723
|
somewhere browser
|
|
44771
44724
|
\`\`\`
|
|
@@ -48641,13 +48594,13 @@ export const SHOW_EMAIL_VERIFICATION = false;
|
|
|
48641
48594
|
}
|
|
48642
48595
|
function schemaTs(privateData, agent) {
|
|
48643
48596
|
if (!agent)
|
|
48644
|
-
return
|
|
48597
|
+
return SCHEMA;
|
|
48645
48598
|
const imports = `import { id, owner, schema, table, text, timestamp } from 'somewhere/db';
|
|
48646
48599
|
|
|
48647
48600
|
`;
|
|
48648
48601
|
if (!privateData)
|
|
48649
48602
|
return imports + AGENT_SCHEMA_NOTE + "export default schema({\n" + AGENT_TABLES + "});\n";
|
|
48650
|
-
const notes =
|
|
48603
|
+
const notes = SCHEMA.slice(SCHEMA.indexOf("// notes:"));
|
|
48651
48604
|
return imports + AGENT_SCHEMA_NOTE + notes.replace(/\n\}\);\n$/, "\n" + AGENT_TABLES + "});\n");
|
|
48652
48605
|
}
|
|
48653
48606
|
function homePage(privateData, agent) {
|
|
@@ -48877,7 +48830,7 @@ function createFeatureTemplate(selection, options2) {
|
|
|
48877
48830
|
}
|
|
48878
48831
|
return files;
|
|
48879
48832
|
}
|
|
48880
|
-
var packageJson2, TSCONFIG2, AUTH_API, AUTH_TYPES, PROVIDER_SIGN_IN_HOOK, AUTH_CALLBACK_PAGE, AUTH_SERVICE, AUTH_HOOKS, ROUTES, APP2,
|
|
48833
|
+
var packageJson2, TSCONFIG2, AUTH_API, AUTH_TYPES, PROVIDER_SIGN_IN_HOOK, AUTH_CALLBACK_PAGE, AUTH_SERVICE, AUTH_HOOKS, ROUTES, APP2, SCHEMA, NOTES_TYPES, NOTES_SERVICE, USE_NOTES, AGENT_TABLES, AGENT_SCHEMA_NOTE, CHAT_API, PROPOSALS_API, ASSISTANT_TYPES, ASSISTANT_SERVICE, USE_ASSISTANT, ASSISTANT_FIXTURES, ASSISTANT_FIXTURES_PAGE, ASSISTANT_FIXTURES_FLOW, STYLED_ASSISTANT_PANEL, PLAIN_ASSISTANT_PANEL, MFA_HOOK, MFA_VIEW, SIGN_IN_PAGE, SIGNED_IN_LAYOUT, NOTE_DETAIL_PAGE, DETAIL_PAGE, NOT_FOUND_PAGE, STYLED_FEEDBACK, STYLED_APP_SHELL, STYLED_NOTES_BOARD, PLAIN_FEEDBACK, PLAIN_APP_SHELL, PLAIN_NOTES_BOARD, NOTES_CSS, ASSISTANT_CSS, MAGIC_LINK_TYPES, MAGIC_LINK_HOOKS, CONNECTION_RETURN, MAGIC_LINK_PAGE, MAGIC_SIGN_IN_PAGE, STYLED_MAGIC_LINK, PLAIN_MAGIC_LINK, FORGOT_PASSWORD_API, RESET_PASSWORD_API, PASSWORD_RESET_PAGE, VERIFY_EMAIL_HOOK, PLAIN_VERIFY_EMAIL;
|
|
48881
48834
|
var init_init_feature_template = __esm({
|
|
48882
48835
|
"dist/lib/init-feature-template.js"() {
|
|
48883
48836
|
"use strict";
|
|
@@ -49380,7 +49333,7 @@ function PrivateRoutes({ user }: { user: User }) {
|
|
|
49380
49333
|
__name(mainTsx, "mainTsx");
|
|
49381
49334
|
__name(mainTsxWithFixtures, "mainTsxWithFixtures");
|
|
49382
49335
|
__name(configTs, "configTs");
|
|
49383
|
-
|
|
49336
|
+
SCHEMA = `import { id, owner, schema, table, text } from 'somewhere/db';
|
|
49384
49337
|
|
|
49385
49338
|
// notes: owner() gives each signed-in user their own rows through the
|
|
49386
49339
|
// generated somewhere:data client, so the browser code sends no user filter.
|
|
@@ -51980,7 +51933,7 @@ the SDK client in src/services/auth.ts, hooks in src/auth/, pages in src/pages/,
|
|
|
51980
51933
|
replaceable views in src/ui/ and styles in src/styles/, plus an AGENTS.md workflow
|
|
51981
51934
|
(deploy, then test). Sign-in and invitation links (sw.auth.invite) open
|
|
51982
51935
|
/auth/magic, which the starter routes before the sign-in gate.
|
|
51983
|
-
\`--template minimal\` includes the SDK and auth route without sign-in screens.
|
|
51936
|
+
\`--template minimal\` includes the SDK and auth route without sign-in screens. Add the notes example with --features auth,private-data.
|
|
51984
51937
|
Init installs React, the SDK and editor types. The platform builds your source when you deploy.
|
|
51985
51938
|
TypeScript is fetched when first needed. Vite and Playwright are installed only if you choose to use them.
|
|
51986
51939
|
New starters and --bare also install agent skills in .agents/skills, pinned by skills-lock.json.
|
|
@@ -52446,7 +52399,7 @@ var init_init = __esm({
|
|
|
52446
52399
|
init_output();
|
|
52447
52400
|
INSTALL_STARTER_MESSAGE = "Installing the starter's pinned dependencies with `npm install` (downloads from npm and runs package install scripts)\u2026";
|
|
52448
52401
|
INIT_TEMPLATES = ["auth", "minimal", "bare"];
|
|
52449
|
-
DEFAULT_AUTH_SELECTION = { requested: ["auth"
|
|
52402
|
+
DEFAULT_AUTH_SELECTION = { requested: ["auth"], added: [], modules: ["auth"], ui: "styled" };
|
|
52450
52403
|
__name(registerInit, "registerInit");
|
|
52451
52404
|
__name(runInit, "runInit");
|
|
52452
52405
|
__name(planFeatures, "planFeatures");
|
|
@@ -52811,7 +52764,7 @@ function registerProject(program2) {
|
|
|
52811
52764
|
process.exit(1);
|
|
52812
52765
|
}
|
|
52813
52766
|
});
|
|
52814
|
-
proj.command("delete <name-or-id>").description("
|
|
52767
|
+
proj.command("delete <name-or-id>").description("Delete a project: it goes offline now and its data is erased after 30 days. --undo restores it within those 30 days.").option("--confirm-code <code>", "Confirm deletion using the confirm_code returned by the first call").option("--undo", "Restore a project you deleted within the last 30 days. It comes back offline; deploy it again to put it online.").option("--json", "Print the deletion result as JSON").addOption(new Option("--yes").hideHelp()).addOption(new Option("--force").hideHelp()).action(async (nameOrId, opts) => {
|
|
52815
52768
|
const unsupported = opts.yes ? "--yes" : opts.force ? "--force" : void 0;
|
|
52816
52769
|
if (unsupported) {
|
|
52817
52770
|
const message3 = `Unknown option '${unsupported}'. Run ${cliInvocation()} project delete <name-or-id> to get a code, then repeat with --confirm-code <code>.`;
|
|
@@ -52821,7 +52774,38 @@ function registerProject(program2) {
|
|
|
52821
52774
|
error(message3);
|
|
52822
52775
|
process.exit(1);
|
|
52823
52776
|
}
|
|
52777
|
+
if (opts.undo && opts.confirmCode) {
|
|
52778
|
+
const message3 = "--undo restores a deleted project and takes no confirmation code. Run it without --confirm-code.";
|
|
52779
|
+
if (opts.json)
|
|
52780
|
+
printJsonError("UNKNOWN_OPTION", message3);
|
|
52781
|
+
else
|
|
52782
|
+
error(message3);
|
|
52783
|
+
process.exit(1);
|
|
52784
|
+
}
|
|
52824
52785
|
const client = new ApiClient(getToken());
|
|
52786
|
+
if (opts.undo) {
|
|
52787
|
+
const spinner2 = opts.json ? null : ora("Restoring...").start();
|
|
52788
|
+
try {
|
|
52789
|
+
const restored = await client.call("POST", `/projects/${encodeURIComponent(nameOrId)}/restore`, {});
|
|
52790
|
+
spinner2?.stop();
|
|
52791
|
+
if (opts.json) {
|
|
52792
|
+
printJson(restored);
|
|
52793
|
+
return;
|
|
52794
|
+
}
|
|
52795
|
+
if (restored?.restored === true) {
|
|
52796
|
+
success("Restored. It is offline until you deploy it again.");
|
|
52797
|
+
if (restored.note)
|
|
52798
|
+
info(restored.note);
|
|
52799
|
+
} else {
|
|
52800
|
+
info(restored?.note ?? "This project is not deleted. Nothing changed.");
|
|
52801
|
+
}
|
|
52802
|
+
} catch (err) {
|
|
52803
|
+
spinner2?.stop();
|
|
52804
|
+
renderDeleteError(err, opts.json);
|
|
52805
|
+
process.exit(1);
|
|
52806
|
+
}
|
|
52807
|
+
return;
|
|
52808
|
+
}
|
|
52825
52809
|
const promptStdout = opts.json ? process.stderr : void 0;
|
|
52826
52810
|
let project;
|
|
52827
52811
|
try {
|
|
@@ -52842,6 +52826,7 @@ function registerProject(program2) {
|
|
|
52842
52826
|
return;
|
|
52843
52827
|
}
|
|
52844
52828
|
success("Deleted.");
|
|
52829
|
+
printDeleteNote(deleted2);
|
|
52845
52830
|
return;
|
|
52846
52831
|
}
|
|
52847
52832
|
const code = await requestDeleteConfirmationCode(client, project.id);
|
|
@@ -52863,7 +52848,7 @@ function registerProject(program2) {
|
|
|
52863
52848
|
const { confirm: confirm2 } = await (0, import_prompts3.default)({
|
|
52864
52849
|
type: "text",
|
|
52865
52850
|
name: "confirm",
|
|
52866
|
-
message: `This will
|
|
52851
|
+
message: `This will delete "${projectName}": it goes offline now, and its data is erased for good after 30 days.
|
|
52867
52852
|
Type the project name to confirm`,
|
|
52868
52853
|
stdout: promptStdout
|
|
52869
52854
|
});
|
|
@@ -52884,6 +52869,7 @@ function registerProject(program2) {
|
|
|
52884
52869
|
return;
|
|
52885
52870
|
}
|
|
52886
52871
|
success("Deleted.");
|
|
52872
|
+
printDeleteNote(deleted);
|
|
52887
52873
|
} catch (err) {
|
|
52888
52874
|
spinner?.stop();
|
|
52889
52875
|
renderDeleteError(err, opts.json);
|
|
@@ -52928,6 +52914,11 @@ async function requestDeleteConfirmationCode(client, projectId) {
|
|
|
52928
52914
|
}
|
|
52929
52915
|
throw new CliApiError("DELETE_CONFIRMATION_MISSING", "The server did not require a delete confirmation code, so the CLI refused to continue.", 500);
|
|
52930
52916
|
}
|
|
52917
|
+
function printDeleteNote(deleted) {
|
|
52918
|
+
const note = deleted && typeof deleted === "object" ? deleted.note : void 0;
|
|
52919
|
+
if (typeof note === "string" && note.trim())
|
|
52920
|
+
info(note);
|
|
52921
|
+
}
|
|
52931
52922
|
function confirmProjectDelete(client, projectId, code) {
|
|
52932
52923
|
return client.call("DELETE", `/projects/${encodeURIComponent(projectId)}`, { code });
|
|
52933
52924
|
}
|
|
@@ -53032,6 +53023,7 @@ var init_project = __esm({
|
|
|
53032
53023
|
__name(registerProject, "registerProject");
|
|
53033
53024
|
__name(resolveDeleteTarget, "resolveDeleteTarget");
|
|
53034
53025
|
__name(requestDeleteConfirmationCode, "requestDeleteConfirmationCode");
|
|
53026
|
+
__name(printDeleteNote, "printDeleteNote");
|
|
53035
53027
|
__name(confirmProjectDelete, "confirmProjectDelete");
|
|
53036
53028
|
__name(renderDeleteError, "renderDeleteError");
|
|
53037
53029
|
__name(listProjects, "listProjects");
|
|
@@ -75204,7 +75196,7 @@ var init_typecheck = __esm({
|
|
|
75204
75196
|
PAGE_LIMIT_EXPLANATION = "A data list call reads at most 100 rows: limit must be a number from 1 to 100. Read further pages with { after: page.next } while page.has_more is true.";
|
|
75205
75197
|
__name(explainPageLimit, "explainPageLimit");
|
|
75206
75198
|
DIAGNOSTIC_HINTS = [
|
|
75207
|
-
{ matches: /SomewhereDb(?:Caller)?WriteIntent|__SomewhereDbIntentFor|readonly.*WriteIntent/, hint: `Pass write intents as an array, e.g. sw.db.tx([{ op: "insert", table: "notes", values: { title } }]). For a separately declared array, use satisfies Parameters<typeof sw.db.tx>[0] to check the operation, table and columns where you declare it. Use the type of sw.db.server.tx for server writes. ${cliInvocation()} docs sw.db --section swdbtxintents-all-or-nothing-composed-writes` },
|
|
75199
|
+
{ matches: /SomewhereDb(?:Caller)?WriteIntent|__SomewhereDbIntentFor|readonly.*WriteIntent/, hint: `Pass write intents as an array, e.g. sw.db.tx([{ op: "insert", table: "notes", values: { title } }]). For a separately declared array, use satisfies Parameters<typeof sw.db.tx>[0] to check the operation, table and columns where you declare it. An inline array or an explicit as const also preserves literal operation and table names. Use the type of sw.db.server.tx for server writes. ${cliInvocation()} docs sw.db --section swdbtxintents-all-or-nothing-composed-writes` },
|
|
75208
75200
|
{ matches: /Expected 2 arguments, but got 3/, hint: `Database update shape: sw.db.update(table, { where: { id }, set: { title } }). ${cliInvocation()} docs sw.db --section builder-verbs-and-where-shapes` },
|
|
75209
75201
|
{ matches: /\border\b.*does not exist|limit\?: undefined|A data list call reads at most 100/, hint: "Browser list: limit 1\u2013100; paginate with after. Sort in the client or use a server endpoint." },
|
|
75210
75202
|
{ matches: /`\$\{number\}\/second`/, hint: "rateLimit is text: rateLimit: '30/minute' (per second, minute, hour or day), not an object." },
|
|
@@ -75958,9 +75950,9 @@ var init_handler = __esm({
|
|
|
75958
75950
|
if (this.fsw.closed) {
|
|
75959
75951
|
return;
|
|
75960
75952
|
}
|
|
75961
|
-
const
|
|
75953
|
+
const dirname18 = sysPath.dirname(file);
|
|
75962
75954
|
const basename13 = sysPath.basename(file);
|
|
75963
|
-
const parent = this.fsw._getWatchedDir(
|
|
75955
|
+
const parent = this.fsw._getWatchedDir(dirname18);
|
|
75964
75956
|
let prevStats = stats;
|
|
75965
75957
|
if (parent.has(basename13))
|
|
75966
75958
|
return;
|
|
@@ -75987,7 +75979,7 @@ var init_handler = __esm({
|
|
|
75987
75979
|
prevStats = newStats2;
|
|
75988
75980
|
}
|
|
75989
75981
|
} catch (error3) {
|
|
75990
|
-
this.fsw._remove(
|
|
75982
|
+
this.fsw._remove(dirname18, basename13);
|
|
75991
75983
|
}
|
|
75992
75984
|
} else if (parent.has(basename13)) {
|
|
75993
75985
|
const at2 = newStats.atimeMs;
|
|
@@ -78758,8 +78750,8 @@ function formatChecksReport(check) {
|
|
|
78758
78750
|
}
|
|
78759
78751
|
const coverage = check?.not_checked ?? null;
|
|
78760
78752
|
if (coverage) {
|
|
78761
|
-
if (typeof check?.routes_discovered === "number")
|
|
78762
|
-
lines.push(
|
|
78753
|
+
if (typeof check?.routes_discovered === "number" && check.routes_checked)
|
|
78754
|
+
lines.push(`${check.routes_checked} of ${check.routes_discovered} app routes had a completed read check.`);
|
|
78763
78755
|
const { routes_without_read_check: reads, routes_without_write_check: writes, schedules_not_run: schedules, other } = coverage;
|
|
78764
78756
|
if (reads === null || writes === null)
|
|
78765
78757
|
lines.push("App route coverage could not be listed.");
|
|
@@ -78773,15 +78765,16 @@ function formatChecksReport(check) {
|
|
|
78773
78765
|
lines.push(`This check skips scheduled tasks (${schedules.join(", ")}). To verify one on your preview, use ${cliInvocation()} cron run <name> --preview --wait.`);
|
|
78774
78766
|
if (other.length)
|
|
78775
78767
|
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.");
|
|
78776
78770
|
} else {
|
|
78777
78771
|
lines.push("Coverage details are unavailable for this run.");
|
|
78778
78772
|
}
|
|
78779
|
-
lines.push("Prove the brief with a check list in checks/<name>.json (users and steps). See somewhere docs test.");
|
|
78780
78773
|
return [...lines, JSON.stringify({
|
|
78781
78774
|
...summary,
|
|
78782
78775
|
not_checked: coverage,
|
|
78783
78776
|
...check?.scope === "partial" ? { scope: check.scope, selection: check.selection, checked_parts: check.checked_parts } : {},
|
|
78784
|
-
...coverage ? { routes_checked: check
|
|
78777
|
+
...coverage && check?.routes_checked ? { routes_checked: check.routes_checked, routes_discovered: check.routes_discovered } : {}
|
|
78785
78778
|
})];
|
|
78786
78779
|
}
|
|
78787
78780
|
var DEPLOY_CHECKS_RUNNING, TEST_CHECKS_WAIT_MS, selectionLabel, cleanupFindings, functionWarnings;
|
|
@@ -80118,8 +80111,8 @@ function productionControl(client, target, options2 = {}) {
|
|
|
80118
80111
|
}
|
|
80119
80112
|
};
|
|
80120
80113
|
}
|
|
80121
|
-
async function openProductionControl(projectId, target) {
|
|
80122
|
-
const client = new ApiClient(getToken());
|
|
80114
|
+
async function openProductionControl(projectId, target, fromProjectFile = false) {
|
|
80115
|
+
const client = new ApiClient(getToken(), fromProjectFile ? projectId : void 0);
|
|
80123
80116
|
return productionControl(client, target ?? await loadTestTarget(client, projectId));
|
|
80124
80117
|
}
|
|
80125
80118
|
function previewFailure(error3, what) {
|
|
@@ -80589,12 +80582,14 @@ function uploadInventory(files, binaryFiles, functions, scope) {
|
|
|
80589
80582
|
functions: scope === "static" ? [] : sorted(Object.keys(functions).filter((path3) => !path3.split("/").some((segment) => segment.startsWith("_"))))
|
|
80590
80583
|
};
|
|
80591
80584
|
}
|
|
80592
|
-
function formatUploadInventory(inventory) {
|
|
80585
|
+
function formatUploadInventory(inventory, dryRun = false) {
|
|
80593
80586
|
const paths = [...inventory.static_files, ...inventory.functions];
|
|
80594
80587
|
if (paths.length === 0)
|
|
80595
80588
|
return "Uploaded: nothing";
|
|
80596
80589
|
if (paths.length <= INLINE_UPLOAD_LIST_MAX)
|
|
80597
80590
|
return `Uploaded: ${paths.join(", ")}`;
|
|
80591
|
+
if (!dryRun)
|
|
80592
|
+
return `Uploaded ${paths.length} paths.`;
|
|
80598
80593
|
return `Uploaded ${paths.length} paths; the full list is "uploaded" in the output of ${cliInvocation()} deploy --dry-run --json`;
|
|
80599
80594
|
}
|
|
80600
80595
|
var INLINE_UPLOAD_LIST_MAX;
|
|
@@ -85124,7 +85119,7 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
85124
85119
|
} else {
|
|
85125
85120
|
token = getToken();
|
|
85126
85121
|
}
|
|
85127
|
-
const client = new ApiClient(token);
|
|
85122
|
+
const client = new ApiClient(token, !opts.project && !besideRealLogin ? foundProjectEntry?.config.project_id : void 0);
|
|
85128
85123
|
let scope;
|
|
85129
85124
|
if (opts.scope !== void 0) {
|
|
85130
85125
|
if (opts.scope !== "functions" && opts.scope !== "static") {
|
|
@@ -85414,7 +85409,7 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
85414
85409
|
printJson({ ...plan, uploaded: inventory });
|
|
85415
85410
|
} else {
|
|
85416
85411
|
printDryRun(plan, scope);
|
|
85417
|
-
info(dim(formatUploadInventory(inventory)));
|
|
85412
|
+
info(dim(formatUploadInventory(inventory, true)));
|
|
85418
85413
|
}
|
|
85419
85414
|
return;
|
|
85420
85415
|
}
|
|
@@ -85764,7 +85759,7 @@ ${dim("Build")}`);
|
|
|
85764
85759
|
process.exit(1);
|
|
85765
85760
|
}
|
|
85766
85761
|
if (err instanceof CliApiError && targetFromLink && !deployAnswered && (err.code === "PROJECT_NOT_FOUND" || err.code === "FORBIDDEN" && err.statusCode === 403)) {
|
|
85767
|
-
const message3 = formatLinkedProjectAccessRefusal(!tempSession, dir);
|
|
85762
|
+
const message3 = err.statusCode === 404 ? `${err.message} To publish a new project instead and update .somewhere.json, run \`${newProjectCommand(dir)}\`.` : formatLinkedProjectAccessRefusal(!tempSession, dir);
|
|
85768
85763
|
if (opts.json) {
|
|
85769
85764
|
printJsonError(err.code, message3, {
|
|
85770
85765
|
...platformErrorEnvelope(err)?.extra ?? {},
|
|
@@ -86352,7 +86347,7 @@ function registerDeploys(program2) {
|
|
|
86352
86347
|
const deploys = program2.command("deploys").description("List recent deploys with their time, note and restore command.").option("--project <ref>", "Project ID or subdomain (defaults to the linked project)").option("--json", "Print deploy history as JSON").action(async (options2) => {
|
|
86353
86348
|
try {
|
|
86354
86349
|
const project = projectRef(options2.project);
|
|
86355
|
-
const result = await new ApiClient(getToken()).call("GET", `/projects/${encodeURIComponent(project)}/deploys`);
|
|
86350
|
+
const result = await new ApiClient(getToken(), options2.project ? void 0 : project).call("GET", `/projects/${encodeURIComponent(project)}/deploys`);
|
|
86356
86351
|
if (options2.json)
|
|
86357
86352
|
return printJson(result);
|
|
86358
86353
|
if (result.deploys.length === 0)
|
|
@@ -86374,8 +86369,9 @@ function registerDeploys(program2) {
|
|
|
86374
86369
|
const options2 = command.optsWithGlobals();
|
|
86375
86370
|
try {
|
|
86376
86371
|
const version2 = deployVersion(versionArg);
|
|
86377
|
-
const
|
|
86378
|
-
|
|
86372
|
+
const project = projectRef(options2.project);
|
|
86373
|
+
const result = await new ApiClient(getToken(), options2.project ? void 0 : project).call("PATCH", "/deploy/note", {
|
|
86374
|
+
project_id: project,
|
|
86379
86375
|
version: version2,
|
|
86380
86376
|
message: message3
|
|
86381
86377
|
});
|
|
@@ -86389,7 +86385,7 @@ function registerDeploys(program2) {
|
|
|
86389
86385
|
program2.command("file <path>").description("Print one deployed source file. Redirect stdout to save it.").requiredOption("--version <number>", "Retained production version to read (required)").option("--project <ref>", "Project ID or subdomain (defaults to the linked project)").action(async (path3, options2) => {
|
|
86390
86386
|
const project = projectRef(options2.project);
|
|
86391
86387
|
const version2 = deployVersion(options2.version);
|
|
86392
|
-
const file = await new ApiClient(getToken()).call("GET", "/deploy/file", void 0, { project_id: project, path: path3, version: version2 });
|
|
86388
|
+
const file = await new ApiClient(getToken(), options2.project ? void 0 : project).call("GET", "/deploy/file", void 0, { project_id: project, path: path3, version: version2 });
|
|
86393
86389
|
process.stdout.write(Buffer.from(file.content, file.encoding));
|
|
86394
86390
|
});
|
|
86395
86391
|
}
|
|
@@ -89649,7 +89645,6 @@ function registerLogs(program2) {
|
|
|
89649
89645
|
process.exit(1);
|
|
89650
89646
|
}
|
|
89651
89647
|
const token = getToken();
|
|
89652
|
-
const client = new ApiClient(token);
|
|
89653
89648
|
const chosen = chooseProjectRef(project, opts.project);
|
|
89654
89649
|
if (chosen.kind === "conflict") {
|
|
89655
89650
|
error(projectRefConflictMessage(chosen));
|
|
@@ -89664,6 +89659,7 @@ function registerLogs(program2) {
|
|
|
89664
89659
|
}
|
|
89665
89660
|
projectId = config2.project_id;
|
|
89666
89661
|
}
|
|
89662
|
+
const client = new ApiClient(token, chosen.kind === "none" ? projectId : void 0);
|
|
89667
89663
|
if (opts.function && opts.endpoint && opts.function !== opts.endpoint) {
|
|
89668
89664
|
error("--function and --endpoint cannot specify different paths.");
|
|
89669
89665
|
process.exit(1);
|
|
@@ -89869,7 +89865,7 @@ var init_logs = __esm({
|
|
|
89869
89865
|
// dist/commands/errors.js
|
|
89870
89866
|
function registerErrors(program2) {
|
|
89871
89867
|
program2.command("errors [project]").description("Show what recently went wrong in a project \u2014 the curated 24h view (endpoint, status, error, time). The fastest way to see what is breaking in production without digging through raw logs. Rows are split into EXCEPTIONS (nobody chose it \u2014 an uncaught throw or a 5xx) and REFUSALS (your handler answered 4xx on purpose, e.g. a 401 from your own auth gate). Platform-generated diagnostics are labeled separately. Use --exceptions to hide your handler's deliberate refusals.").option("--project <ref>", "Project ID, name, slug, or subdomain \u2014 the same flag every other command takes. The positional form still works.").option("--limit <n>", "Max rows to show (default 20, max 100)", "20").option("--exceptions", "Hide the 4xx your own handlers returned on purpose; keep exceptions and platform diagnostics.").option("--json", "Print rows as JSON; platform-generated diagnostics include diagnostic_origin.").action(async (projectArg, opts) => {
|
|
89872
|
-
const
|
|
89868
|
+
const token = getToken();
|
|
89873
89869
|
const chosen = chooseProjectRef(projectArg, opts.project);
|
|
89874
89870
|
if (chosen.kind === "conflict") {
|
|
89875
89871
|
error(projectRefConflictMessage(chosen));
|
|
@@ -89884,6 +89880,7 @@ function registerErrors(program2) {
|
|
|
89884
89880
|
}
|
|
89885
89881
|
projectId = config2.project_id;
|
|
89886
89882
|
}
|
|
89883
|
+
const client = new ApiClient(token, chosen.kind === "none" ? projectId : void 0);
|
|
89887
89884
|
const limit = Math.min(parseInt(String(opts.limit), 10) || 20, 100);
|
|
89888
89885
|
let rows;
|
|
89889
89886
|
try {
|
|
@@ -90293,7 +90290,7 @@ function registerRun(program2) {
|
|
|
90293
90290
|
error("This command sends one script. Inline local helpers or bundle them into a single ES module, then run that file.");
|
|
90294
90291
|
process.exit(1);
|
|
90295
90292
|
}
|
|
90296
|
-
const client = new ApiClient(getToken());
|
|
90293
|
+
const client = new ApiClient(getToken(), opts.project ? void 0 : projectId);
|
|
90297
90294
|
let timeoutMs;
|
|
90298
90295
|
if (opts.timeout !== void 0) {
|
|
90299
90296
|
timeoutMs = parseInt(String(opts.timeout), 10);
|
|
@@ -90459,7 +90456,6 @@ function printProductionDeployment(deployment) {
|
|
|
90459
90456
|
function registerStatus(program2) {
|
|
90460
90457
|
program2.command("status [project]").description("Show project and workspace status").option("--project <ref>", "Project ID, name, slug, or subdomain \u2014 the same flag every other command takes. The positional form still works.").option("--json", "Print the raw status responses as JSON").action(async (projectArg, opts) => {
|
|
90461
90458
|
const token = getToken();
|
|
90462
|
-
const client = new ApiClient(token);
|
|
90463
90459
|
const claimConnection = Boolean(loadConfig()?.claim_access);
|
|
90464
90460
|
const chosen = chooseProjectRef(projectArg, opts.project);
|
|
90465
90461
|
if (chosen.kind === "conflict") {
|
|
@@ -90475,6 +90471,7 @@ function registerStatus(program2) {
|
|
|
90475
90471
|
}
|
|
90476
90472
|
projectId = config2.project_id;
|
|
90477
90473
|
}
|
|
90474
|
+
const client = new ApiClient(token, chosen.kind === "none" ? projectId : void 0);
|
|
90478
90475
|
let projectStatus = null;
|
|
90479
90476
|
let projectError = null;
|
|
90480
90477
|
let deploymentStatus = null;
|
|
@@ -90633,7 +90630,6 @@ function registerOpen(program2) {
|
|
|
90633
90630
|
return;
|
|
90634
90631
|
}
|
|
90635
90632
|
const token = getToken();
|
|
90636
|
-
const client = new ApiClient(token);
|
|
90637
90633
|
const chosen = chooseProjectRef(project, opts.project);
|
|
90638
90634
|
if (chosen.kind === "conflict") {
|
|
90639
90635
|
error(projectRefConflictMessage(chosen));
|
|
@@ -90648,6 +90644,7 @@ function registerOpen(program2) {
|
|
|
90648
90644
|
error("No project linked. Pass a project name (positionally or with --project) or run from a linked directory." + unlinkedFolderHint());
|
|
90649
90645
|
process.exit(1);
|
|
90650
90646
|
}
|
|
90647
|
+
const client = new ApiClient(token, chosen.kind === "none" ? projectRef3 : void 0);
|
|
90651
90648
|
try {
|
|
90652
90649
|
const servingUrl = await getProjectServingUrl(client, projectRef3);
|
|
90653
90650
|
if (!servingUrl)
|
|
@@ -92391,7 +92388,7 @@ function registerCheck(program2) {
|
|
|
92391
92388
|
}
|
|
92392
92389
|
projectId = config2.project_id;
|
|
92393
92390
|
}
|
|
92394
|
-
const client = new ApiClient(getToken());
|
|
92391
|
+
const client = new ApiClient(getToken(), opts.project ? void 0 : projectId);
|
|
92395
92392
|
const collected = collectFiles(targetDir);
|
|
92396
92393
|
const sensitiveRefusal = sensitiveReferenceRefusal(collected);
|
|
92397
92394
|
if (sensitiveRefusal) {
|
|
@@ -110588,7 +110585,7 @@ var require_polyfill = __commonJS({
|
|
|
110588
110585
|
utimes
|
|
110589
110586
|
} = __require("fs/promises");
|
|
110590
110587
|
var {
|
|
110591
|
-
dirname:
|
|
110588
|
+
dirname: dirname18,
|
|
110592
110589
|
isAbsolute: isAbsolute7,
|
|
110593
110590
|
join: join57,
|
|
110594
110591
|
parse: parse3,
|
|
@@ -110692,7 +110689,7 @@ var require_polyfill = __commonJS({
|
|
|
110692
110689
|
}
|
|
110693
110690
|
__name(getStats, "getStats");
|
|
110694
110691
|
async function checkParentDir(destStat, src, dest, opts) {
|
|
110695
|
-
const destParent =
|
|
110692
|
+
const destParent = dirname18(dest);
|
|
110696
110693
|
const dirExists = await pathExists(destParent);
|
|
110697
110694
|
if (dirExists) {
|
|
110698
110695
|
return getStatsForCopy(destStat, src, dest, opts);
|
|
@@ -110710,8 +110707,8 @@ var require_polyfill = __commonJS({
|
|
|
110710
110707
|
}
|
|
110711
110708
|
__name(pathExists, "pathExists");
|
|
110712
110709
|
async function checkParentPaths(src, srcStat, dest) {
|
|
110713
|
-
const srcParent = resolve27(
|
|
110714
|
-
const destParent = resolve27(
|
|
110710
|
+
const srcParent = resolve27(dirname18(src));
|
|
110711
|
+
const destParent = resolve27(dirname18(dest));
|
|
110715
110712
|
if (destParent === srcParent || destParent === parse3(destParent).root) {
|
|
110716
110713
|
return;
|
|
110717
110714
|
}
|
|
@@ -110881,7 +110878,7 @@ var require_polyfill = __commonJS({
|
|
|
110881
110878
|
async function onLink(destStat, src, dest) {
|
|
110882
110879
|
let resolvedSrc = await readlink(src);
|
|
110883
110880
|
if (!isAbsolute7(resolvedSrc)) {
|
|
110884
|
-
resolvedSrc = resolve27(
|
|
110881
|
+
resolvedSrc = resolve27(dirname18(src), resolvedSrc);
|
|
110885
110882
|
}
|
|
110886
110883
|
if (!destStat) {
|
|
110887
110884
|
return symlink(resolvedSrc, dest);
|
|
@@ -110896,7 +110893,7 @@ var require_polyfill = __commonJS({
|
|
|
110896
110893
|
throw err;
|
|
110897
110894
|
}
|
|
110898
110895
|
if (!isAbsolute7(resolvedDest)) {
|
|
110899
|
-
resolvedDest = resolve27(
|
|
110896
|
+
resolvedDest = resolve27(dirname18(dest), resolvedDest);
|
|
110900
110897
|
}
|
|
110901
110898
|
if (isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
110902
110899
|
throw new ERR_FS_CP_EINVAL({
|
|
@@ -111002,7 +110999,7 @@ var require_readdir_scoped = __commonJS({
|
|
|
111002
110999
|
// node_modules/@npmcli/fs/lib/move-file.js
|
|
111003
111000
|
var require_move_file = __commonJS({
|
|
111004
111001
|
"node_modules/@npmcli/fs/lib/move-file.js"(exports, module) {
|
|
111005
|
-
var { dirname:
|
|
111002
|
+
var { dirname: dirname18, join: join57, resolve: resolve27, relative: relative15, isAbsolute: isAbsolute7 } = __require("path");
|
|
111006
111003
|
var fs2 = __require("fs/promises");
|
|
111007
111004
|
var pathExists = /* @__PURE__ */ __name(async (path3) => {
|
|
111008
111005
|
try {
|
|
@@ -111023,7 +111020,7 @@ var require_move_file = __commonJS({
|
|
|
111023
111020
|
if (!options2.overwrite && await pathExists(destination)) {
|
|
111024
111021
|
throw new Error(`The destination file exists: ${destination}`);
|
|
111025
111022
|
}
|
|
111026
|
-
await fs2.mkdir(
|
|
111023
|
+
await fs2.mkdir(dirname18(destination), { recursive: true });
|
|
111027
111024
|
try {
|
|
111028
111025
|
await fs2.rename(source, destination);
|
|
111029
111026
|
} catch (error3) {
|
|
@@ -111051,7 +111048,7 @@ var require_move_file = __commonJS({
|
|
|
111051
111048
|
}
|
|
111052
111049
|
let targetStat = "file";
|
|
111053
111050
|
try {
|
|
111054
|
-
targetStat = await fs2.stat(resolve27(
|
|
111051
|
+
targetStat = await fs2.stat(resolve27(dirname18(symSource), target));
|
|
111055
111052
|
if (targetStat.isDirectory()) {
|
|
111056
111053
|
targetStat = "junction";
|
|
111057
111054
|
}
|
|
@@ -136146,7 +136143,7 @@ var init_app_test = __esm({
|
|
|
136146
136143
|
if (!projectId)
|
|
136147
136144
|
throw new Error(`${root} is not a linked Somewhere project (no .somewhere.json with a project_id).`);
|
|
136148
136145
|
const preview = options2.preview !== void 0 && options2.preview !== false;
|
|
136149
|
-
const control = preview ? await openPreviewControl({ root, projectId, ...typeof options2.preview === "string" ? { previewSessionId: options2.preview } : {} }) : await openProductionControl(projectId);
|
|
136146
|
+
const control = preview ? await openPreviewControl({ root, projectId, ...typeof options2.preview === "string" ? { previewSessionId: options2.preview } : {} }) : await openProductionControl(projectId, void 0, true);
|
|
136150
136147
|
const target = control.target;
|
|
136151
136148
|
if ((options2.undeployed ?? "refuse") === "refuse") {
|
|
136152
136149
|
const local = undeployedChanges(root, projectId, preview);
|
|
@@ -137139,7 +137136,7 @@ function registerTest(program2) {
|
|
|
137139
137136
|
throw new Error(`${unsupported.join(", ")} apply to Playwright specs and scripts; the platform runs checks/*.json as saved.`);
|
|
137140
137137
|
let check;
|
|
137141
137138
|
try {
|
|
137142
|
-
check = await runChecksNow(new ApiClient(getToken()), projectId, { again: opts.again === true, only: opts.only });
|
|
137139
|
+
check = await runChecksNow(new ApiClient(getToken(), projectId), projectId, { again: opts.again === true, only: opts.only });
|
|
137143
137140
|
} catch (cause) {
|
|
137144
137141
|
const sentence = cause instanceof Error ? cause.message : "The platform could not start the checks.";
|
|
137145
137142
|
check = opts.only ? partialCheckUnavailable(opts.only, sentence) : { status: "unavailable", sentence };
|
|
@@ -137181,7 +137178,7 @@ function registerTest(program2) {
|
|
|
137181
137178
|
}
|
|
137182
137179
|
if (opts.failFast)
|
|
137183
137180
|
throw new Error("--fail-fast applies to app-check scripts (tests/*.mjs or *.cjs).");
|
|
137184
|
-
const outcome2 = await runTests({ root, ...opts.preview ? {} : { client: new ApiClient(getToken()) }, projectId, prepared: prepareRunner(root), options: { ...opts, files } });
|
|
137181
|
+
const outcome2 = await runTests({ root, ...opts.preview ? {} : { client: new ApiClient(getToken(), projectId) }, projectId, prepared: prepareRunner(root), options: { ...opts, files } });
|
|
137185
137182
|
await note;
|
|
137186
137183
|
mark("cli:exit");
|
|
137187
137184
|
process.exitCode = outcome2.exitCode;
|
|
@@ -138960,7 +138957,7 @@ var init_playwright_fixtures = __esm({
|
|
|
138960
138957
|
return this.loading ??= (async () => {
|
|
138961
138958
|
const control = this.preview ?? await timed(this.info, "target snapshot", async () => {
|
|
138962
138959
|
const projectId = linkedProject();
|
|
138963
|
-
return openProductionControl(projectId, runTarget(projectId) ?? void 0);
|
|
138960
|
+
return openProductionControl(projectId, runTarget(projectId) ?? void 0, true);
|
|
138964
138961
|
});
|
|
138965
138962
|
diagnostics(this.info).release = control.target.releaseId;
|
|
138966
138963
|
return { control };
|
|
@@ -139152,7 +139149,9 @@ var init_testing_jobs = __esm({
|
|
|
139152
139149
|
// dist/lib/testing-app.js
|
|
139153
139150
|
import { resolve as resolve26 } from "node:path";
|
|
139154
139151
|
import { createRequire as createRequire12 } from "node:module";
|
|
139155
|
-
import {
|
|
139152
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
139153
|
+
import { readdirSync as readdirSync10 } from "node:fs";
|
|
139154
|
+
import { dirname as dirname17, join as join56 } from "node:path";
|
|
139156
139155
|
async function openTestApp(options2 = {}) {
|
|
139157
139156
|
const root = resolve26(options2.projectDir ?? process.cwd());
|
|
139158
139157
|
const projectId = loadProjectConfig(root)?.project_id;
|
|
@@ -139160,7 +139159,7 @@ async function openTestApp(options2 = {}) {
|
|
|
139160
139159
|
throw new Error("Run the test from a linked Somewhere app folder.");
|
|
139161
139160
|
const setup = options2.preview ? previewCredentialFor(root, projectId) : void 0;
|
|
139162
139161
|
const tool = setup && previewToolClient(setup.credential);
|
|
139163
|
-
const client = tool ? void 0 : new ApiClient(testingDeveloperToken());
|
|
139162
|
+
const client = tool ? void 0 : new ApiClient(testingDeveloperToken(), projectId);
|
|
139164
139163
|
const target = tool && setup ? await readPreviewTarget(tool, projectId, setup.previewSessionId) : await loadTestTarget(client, projectId);
|
|
139165
139164
|
const control = tool ? previewControl(tool, target) : void 0;
|
|
139166
139165
|
const inbox2 = control ?? productionControl(client, target, { liveInboxOnly: true });
|
|
@@ -139202,6 +139201,17 @@ async function openTestApp(options2 = {}) {
|
|
|
139202
139201
|
const actor = { name, id, email: email2, roles, session, ...callerOf(session, () => {
|
|
139203
139202
|
routeWrites++;
|
|
139204
139203
|
}) };
|
|
139204
|
+
const refusedAs2 = session.expectRefused.bind(session);
|
|
139205
|
+
session.expectRefused = async (...args) => {
|
|
139206
|
+
const what = typeof args[0] === "string" ? args[0] : "";
|
|
139207
|
+
const op = args[1] && typeof args[1] === "object" && "operation" in args[1] ? ` ${args[1].operation}` : "";
|
|
139208
|
+
try {
|
|
139209
|
+
await refusedAs2(...args);
|
|
139210
|
+
results.check(`refused: ${name} ${what}${op}`, true);
|
|
139211
|
+
} catch (error3) {
|
|
139212
|
+
results.check(`refused: ${name} ${what}${op}`, false, error3);
|
|
139213
|
+
}
|
|
139214
|
+
};
|
|
139205
139215
|
actors.add(actor);
|
|
139206
139216
|
managedFileSession(session, root, id);
|
|
139207
139217
|
return actor;
|
|
@@ -139411,7 +139421,7 @@ async function openTestApp(options2 = {}) {
|
|
|
139411
139421
|
}
|
|
139412
139422
|
const reply = settled.value;
|
|
139413
139423
|
const leaked = lacks.findIndex((text) => text && reply.text.includes(text));
|
|
139414
|
-
const refused = allowed.includes(reply.status) || request2[0] === "DATA" && options3.status === void 0 && empty(reply);
|
|
139424
|
+
const refused = allowed.includes(reply.status) || request2[0] === "DATA" && options3.status === void 0 && empty(reply) || lacks.length > 0 && reply.ok && leaked < 0;
|
|
139415
139425
|
if (!refused) {
|
|
139416
139426
|
results.expect(reply, allowed, line);
|
|
139417
139427
|
all = false;
|
|
@@ -139591,6 +139601,47 @@ function replySummary(reply) {
|
|
|
139591
139601
|
const message3 = typeof body.message === "string" ? body.message : void 0;
|
|
139592
139602
|
return `${reply.status}${reply.requestId ? ` (request ${reply.requestId})` : ""}${code ? ` ${code}` : ""}${message3 ? `: ${cut(message3, 200)}` : ""}`;
|
|
139593
139603
|
}
|
|
139604
|
+
function findPlaywright(root, given) {
|
|
139605
|
+
if (given && typeof given === "object")
|
|
139606
|
+
return given;
|
|
139607
|
+
const require6 = createRequire12(join56(root, "package.json"));
|
|
139608
|
+
const load2 = /* @__PURE__ */ __name((name) => {
|
|
139609
|
+
try {
|
|
139610
|
+
const pw = require6(name);
|
|
139611
|
+
return pw?.chromium ? pw : void 0;
|
|
139612
|
+
} catch {
|
|
139613
|
+
return void 0;
|
|
139614
|
+
}
|
|
139615
|
+
}, "load");
|
|
139616
|
+
for (const name of [given, process.env.PLAYWRIGHT_MODULE, process.env.PW_PATH, "playwright", "@playwright/test"]) {
|
|
139617
|
+
const pw = name ? load2(name) : void 0;
|
|
139618
|
+
if (pw)
|
|
139619
|
+
return pw;
|
|
139620
|
+
}
|
|
139621
|
+
const dirs = [];
|
|
139622
|
+
const browsers = process.env.PLAYWRIGHT_BROWSERS_PATH;
|
|
139623
|
+
if (browsers) {
|
|
139624
|
+
const parent = dirname17(resolve26(browsers));
|
|
139625
|
+
dirs.push(join56(parent, "node_modules"), ...readdirSafe(parent).map((entry) => join56(parent, entry, "node_modules")));
|
|
139626
|
+
}
|
|
139627
|
+
try {
|
|
139628
|
+
dirs.push(execFileSync2("npm", ["root", "-g"], { encoding: "utf8", timeout: 5e3 }).trim());
|
|
139629
|
+
} catch {
|
|
139630
|
+
}
|
|
139631
|
+
for (const dir of dirs) {
|
|
139632
|
+
const pw = load2(join56(dir, "playwright"));
|
|
139633
|
+
if (pw)
|
|
139634
|
+
return pw;
|
|
139635
|
+
}
|
|
139636
|
+
throw new Error("app.page() needs Playwright and could not find it here, in NODE_PATH, globally or next to PLAYWRIGHT_BROWSERS_PATH. Pass its path: openTestApp({ playwright: '/path/to/node_modules/playwright' }) or set PLAYWRIGHT_MODULE. Or install it: npm install -D playwright && npx playwright install chromium");
|
|
139637
|
+
}
|
|
139638
|
+
function readdirSafe(dir) {
|
|
139639
|
+
try {
|
|
139640
|
+
return readdirSync10(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).slice(0, 50);
|
|
139641
|
+
} catch {
|
|
139642
|
+
return [];
|
|
139643
|
+
}
|
|
139644
|
+
}
|
|
139594
139645
|
var SECRET_KEY, cut, Results, Pages;
|
|
139595
139646
|
var init_testing_app = __esm({
|
|
139596
139647
|
"dist/lib/testing-app.js"() {
|
|
@@ -139670,21 +139721,12 @@ var init_testing_app = __esm({
|
|
|
139670
139721
|
}
|
|
139671
139722
|
async open(state, path3) {
|
|
139672
139723
|
this.browser ??= (() => {
|
|
139673
|
-
const
|
|
139674
|
-
|
|
139675
|
-
|
|
139676
|
-
try {
|
|
139677
|
-
pw = require6(name);
|
|
139678
|
-
break;
|
|
139679
|
-
} catch {
|
|
139680
|
-
}
|
|
139681
|
-
}
|
|
139682
|
-
if (!pw?.chromium) {
|
|
139683
|
-
throw new Error("app.page() needs Playwright. If it is installed outside this folder, pass its path: openTestApp({ playwright: '/path/to/node_modules/playwright' }). Otherwise: npm install -D playwright && npx playwright install chromium");
|
|
139684
|
-
}
|
|
139685
|
-
return pw.chromium.launch();
|
|
139724
|
+
const pw = findPlaywright(this.root, this.playwright);
|
|
139725
|
+
const { chromium } = pw;
|
|
139726
|
+
return process.platform === "darwin" ? chromium.launch({ channel: "chrome" }).catch(() => chromium.launch()) : chromium.launch();
|
|
139686
139727
|
})();
|
|
139687
139728
|
const context = await (await this.browser).newContext({ baseURL: this.origin, storageState: state });
|
|
139729
|
+
context.setDefaultTimeout(1e4);
|
|
139688
139730
|
const page = await context.newPage();
|
|
139689
139731
|
await page.goto(path3);
|
|
139690
139732
|
if (await page.locator("html[data-sw-auth]").count()) {
|
|
@@ -139699,6 +139741,8 @@ var init_testing_app = __esm({
|
|
|
139699
139741
|
await (await browser).close();
|
|
139700
139742
|
}
|
|
139701
139743
|
};
|
|
139744
|
+
__name(findPlaywright, "findPlaywright");
|
|
139745
|
+
__name(readdirSafe, "readdirSafe");
|
|
139702
139746
|
}
|
|
139703
139747
|
});
|
|
139704
139748
|
|