@somewhere-cloud/cli 0.38.127 → 0.38.129
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 +11 -0
- package/dist/lib/bundle.js +367 -348
- package/dist/lib/bundle.js.map +3 -3
- package/dist/types/lib/app-test.d.ts +6 -1
- package/dist/types/lib/form-auth.d.ts +1 -1
- package/dist/types/lib/test-control.d.ts +0 -3
- package/dist/types/lib/test-report.d.ts +1 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
package/dist/lib/bundle.js
CHANGED
|
@@ -36599,6 +36599,9 @@ var init_client = __esm({
|
|
|
36599
36599
|
* API_KEY_EXPIRED. */
|
|
36600
36600
|
async refreshAccessKey(timeoutMs) {
|
|
36601
36601
|
const config2 = loadConfig();
|
|
36602
|
+
if (config2?.claim_access && config2.token === this.token) {
|
|
36603
|
+
throw new CliApiError("SESSION_EXPIRED", `This app connection expired. Run \`${cliInvocation()} login\` and ask the account owner to approve it.`, 401);
|
|
36604
|
+
}
|
|
36602
36605
|
const refreshToken = config2?.refresh_token;
|
|
36603
36606
|
if (!refreshToken) {
|
|
36604
36607
|
throw new CliApiError("SESSION_EXPIRED", `Your somewhere session expired and there is no refresh token saved (old login format). Run \`${cliInvocation()} login\` to sign in again \u2014 that upgrades your config so sessions refresh automatically from now on.`, 401);
|
|
@@ -36692,7 +36695,9 @@ var init_client = __esm({
|
|
|
36692
36695
|
if (typeof retry_after_ms === "number" && Number.isFinite(retry_after_ms)) {
|
|
36693
36696
|
meta3.retryAfterMs = retry_after_ms;
|
|
36694
36697
|
}
|
|
36695
|
-
|
|
36698
|
+
const agentSignIn = `Run \`${cliInvocation()} login\` and ask the account owner to approve it.`;
|
|
36699
|
+
const agentMessage = error3 === "PROJECT_AGENT_OPERATION_FORBIDDEN" ? `This app connection cannot use that feature. ${agentSignIn}` : error3 === "PROJECT_AGENT_PROJECT_FORBIDDEN" ? `This app is outside this connection or no longer available. ${agentSignIn}` : void 0;
|
|
36700
|
+
throw new CliApiError(error3 ?? "UNKNOWN", agentMessage ?? (error3 === void 0 && message3 === void 0 ? unclassifiedResponseMessage(res.status, text) : message3 ?? "Unknown error"), res.status, data2 ?? extraData, hint, meta3);
|
|
36696
36701
|
}
|
|
36697
36702
|
/** Like call(), but returns the raw response TEXT instead of JSON-parsing it
|
|
36698
36703
|
* — for endpoints that legitimately return non-JSON (e.g. a SQL db dump). A
|
|
@@ -38362,7 +38367,6 @@ After every deploy, somewhere verify checks the page loads and looks right at de
|
|
|
38362
38367
|
test to write. Journeys, several users and access rules go in tests/*.mjs with somewhere test.
|
|
38363
38368
|
${FIRST_CLI_PERMISSION}
|
|
38364
38369
|
Run somewhere test after a successful deploy: npx @somewhere-cloud/cli deploy && npx @somewhere-cloud/cli test
|
|
38365
|
-
Tests that need the email inbox work after you claim the app.
|
|
38366
38370
|
It runs every tests/*.mjs and tests/*.cjs Playwright script and prints failures first. Start from
|
|
38367
38371
|
tests/app-check.mjs: change its checks to the journeys you changed and your access boundaries.
|
|
38368
38372
|
Keep each run short:
|
|
@@ -38775,8 +38779,8 @@ var init_skills_pack_generated = __esm({
|
|
|
38775
38779
|
BUNDLED_SKILLS_PACK = {
|
|
38776
38780
|
"schema": 1,
|
|
38777
38781
|
"name": "somewhere-skills",
|
|
38778
|
-
"version": "1+
|
|
38779
|
-
"sha256": "
|
|
38782
|
+
"version": "1+8aec0eae1728",
|
|
38783
|
+
"sha256": "8aec0eae1728bbe4d51fb8de104d1547e79c45a47800de7f4d9750d81f9e72c6",
|
|
38780
38784
|
"files": [
|
|
38781
38785
|
{
|
|
38782
38786
|
"path": "adopt/SKILL.md",
|
|
@@ -38785,8 +38789,8 @@ var init_skills_pack_generated = __esm({
|
|
|
38785
38789
|
},
|
|
38786
38790
|
{
|
|
38787
38791
|
"path": "deploy-verify-loop/SKILL.md",
|
|
38788
|
-
"sha256": "
|
|
38789
|
-
"content": '---\nname: deploy-verify-loop\ndescription: After edits, typecheck and run focused tests; verify the final deployed journey and rerun after relevant fixes.\n---\n\n# Deploy, verify, read the failure\n\n## The loop\n\n```bash\nsomewhere typecheck\nsomewhere deploy\n```\n\nDon\'t bundle the source yourself; the platform runs the frontend build.\n\nRun `somewhere claim` and open its link to keep a temporary app
|
|
38792
|
+
"sha256": "b394c2944cd64a48517dff6c80917b0e9332758f429e96600587ca91e4e951f8",
|
|
38793
|
+
"content": '---\nname: deploy-verify-loop\ndescription: After edits, typecheck and run focused tests; verify the final deployed journey and rerun after relevant fixes.\n---\n\n# Deploy, verify, read the failure\n\n## The loop\n\nBefore your first Somewhere command for a user, ask their permission and say where it will run, either as an npm package in your own cloud workspace (nothing installs on their computer) or as an npm package on their machine. Approval in their first message covers this.\n\n```bash\nsomewhere typecheck\nsomewhere deploy\n```\n\nDon\'t bundle the source yourself; the platform runs the frontend build.\n\nRun `somewhere claim` and open its link to keep a temporary app.\n\n```bash\nsomewhere deploy-check --run /api/hello -X POST -d \'{"name":"Ada"}\'\n```\n\n| Step | Command | What it tells you |\n|---|---|---|\n| Verify | `somewhere verify [--flow flow.json]` | Runs the live app at desktop and phone sizes: named steps, console/network health, both screenshots. |\n| Inspect | `somewhere browser [target]` | One page: screenshot, snapshot, DOM, network, or an evaluated expression. |\n| Diagnose | `somewhere logs --tail 10`, `somewhere errors` | Recent function output, then failures split into refused and exception. `errors` also works on a temporary project. |\n\n## A flow for verify --flow\n\n```json\n{ "actions": [{ "fill": "#title", "value": "Verify entry" }, { "fill": "#from_email", "value": "v@example.com" },\n { "click": "#send" }, { "expect": { "selector": "#status", "text": "Received" } }], "viewports": ["desktop"] }\n```\n\n`passed` requires successful steps and request expectations, no page errors, and no unexpected failed requests. It can be false even when every step succeeded.\n\n## Failure 1: the live site still shows the old version\n\nBrowser or CDN cache. Hard-reload (Cmd-Shift-R), or check with `curl -sI https://{subdomain}.somewhere.site`.\n\n## Failure 2: a route fails\n\nShow recent failures with a `kind` column: **refused** for a 4xx your own handler returned on purpose, **exception** for an uncaught throw or a 5xx.\n\nThe `stack` field is the single most useful field for debugging \u2014 it tells you the exact file + line in your code where the throw originated.\n\n| `somewhere rollback [project]` | `-y, --yes`, `--json` | Select the previous retained production release. By default this changes code without restoring data. |\n\nSources (`somewhere docs <topic>`): browser, cli, common-mistakes, deploy, getting-started, recipe-signed-in-app, troubleshooting.\n'
|
|
38790
38794
|
},
|
|
38791
38795
|
{
|
|
38792
38796
|
"path": "schema-changes/SKILL.md",
|
|
@@ -38810,8 +38814,8 @@ var init_skills_pack_generated = __esm({
|
|
|
38810
38814
|
},
|
|
38811
38815
|
{
|
|
38812
38816
|
"path": "email-and-test-inbox/SKILL.md",
|
|
38813
|
-
"sha256": "
|
|
38814
|
-
"content": "---\nname: email-and-test-inbox\ndescription: When the app sends email, or you need to test sign-up, magic-link, or reset mail without a real mailbox.\n---\n\n# Send email and read the test inbox\n\n## Notification after a save\n\nSave first, await durable job admission, then respond. Queued is not sent; the signed handler records the email outcome.\n\n## Send\n\n```ts\n// api/_lib/order-email.ts \u2014 call it from a handler that already checked who\n// receives this; the address comes from your saved order, never the request.\nexport function sendOrderShipped(\n sw: SomewhereRuntimeContext,\n order: { id: string; email: string; trackingNumber: string },\n): Promise<SomewhereEmailSendResult> {\n return sw.email.send({\n to: order.email,\n subject: 'Your order shipped',\n text: `Tracking: ${order.trackingNumber}`, // or html, or both\n idempotency_key: `order-shipped:${order.id}`,\n });\n}\n```\n\nIt can only email the project's owner and users who have verified their email address with this project; a pending sign-in or an unverified sign-up does not count
|
|
38817
|
+
"sha256": "9406a949a35f929f6b90616d757670f81eb85333f13c7d5b83cf44aed2b8174a",
|
|
38818
|
+
"content": "---\nname: email-and-test-inbox\ndescription: When the app sends email, or you need to test sign-up, magic-link, or reset mail without a real mailbox.\n---\n\n# Send email and read the test inbox\n\n## Notification after a save\n\nSave first, await durable job admission, then respond. Queued is not sent; the signed handler records the email outcome.\n\n## Send\n\n```ts\n// api/_lib/order-email.ts \u2014 call it from a handler that already checked who\n// receives this; the address comes from your saved order, never the request.\nexport function sendOrderShipped(\n sw: SomewhereRuntimeContext,\n order: { id: string; email: string; trackingNumber: string },\n): Promise<SomewhereEmailSendResult> {\n return sw.email.send({\n to: order.email,\n subject: 'Your order shipped',\n text: `Tracking: ${order.trackingNumber}`, // or html, or both\n idempotency_key: `order-shipped:${order.id}`,\n });\n}\n```\n\nIt can only email the project's owner and app users who have verified their email address with this project and signed in at least once; a pending sign-in or an unverified sign-up does not count. The platform adds a one-line unsubscribe footer and one-click unsubscribe headers; after a user unsubscribes, sends to them return `RECIPIENT_UNSUBSCRIBED`. Replies to the app's address are recorded in your project mailbox; read them with `sw.mail.project.list()`.\n\n## Test inbox\n\nAddresses `<anything>@<project-subdomain>.test.somewhere.site` never reach a real mailbox. Read it with `somewhere email test-inbox <address>` (or `sw.email.inbox(address)`) \u2192 `{ address, messages: [{ id, to, subject, text, html, magic_link, verification_code, created_at }] }`. `verification_code` is the code an auth message carries (the 6-digit email verification or sign-in code), or `null`.\n\n## Failure 1: MANAGED_SENDER_RECIPIENT_NOT_A_USER\n\nOther recipients return `MANAGED_SENDER_RECIPIENT_NOT_A_USER`; verify your own sender domain for outreach.\n\n## Failure 2: gating on status 'sent'\n\nDo not gate follow-up work on `status === 'sent'` alone: a captured test send and a replay of a delivered message are both successful sends.\n\nSources (`somewhere docs <topic>`): sw.email.\n"
|
|
38815
38819
|
},
|
|
38816
38820
|
{
|
|
38817
38821
|
"path": "design/SKILL.md",
|
|
@@ -42909,7 +42913,6 @@ function createFeatureTemplate(selection, options2) {
|
|
|
42909
42913
|
{ path: "AGENTS.md", content: INIT_AGENTS_MD.replace(/## Getting started[^]*?After edits:/, `## Testing
|
|
42910
42914
|
${FIRST_CLI_PERMISSION}
|
|
42911
42915
|
Run somewhere test after a successful deploy: npx @somewhere-cloud/cli deploy && npx @somewhere-cloud/cli test
|
|
42912
|
-
Tests that need the email inbox work after you claim the app.
|
|
42913
42916
|
It runs every tests/*.mjs and tests/*.cjs Playwright script and prints failures first.
|
|
42914
42917
|
Start from tests/app-check.mjs: change its checks to the journeys you changed and your access boundaries.
|
|
42915
42918
|
Helpers from @somewhere-cloud/cli/script (import or require): signUp/signIn/signOut through your form,
|
|
@@ -46551,6 +46554,200 @@ var init_link = __esm({
|
|
|
46551
46554
|
}
|
|
46552
46555
|
});
|
|
46553
46556
|
|
|
46557
|
+
// dist/lib/claim-handoff.js
|
|
46558
|
+
import { createDecipheriv, createHash as createHash3, randomBytes as randomBytes2 } from "node:crypto";
|
|
46559
|
+
function readClaimConnection(client) {
|
|
46560
|
+
return client.call("GET", "/auth/temp-claim/status", void 0, void 0, { refresh: false });
|
|
46561
|
+
}
|
|
46562
|
+
function verifierHash(verifier) {
|
|
46563
|
+
return createHash3("sha256").update(verifier, "utf8").digest("hex");
|
|
46564
|
+
}
|
|
46565
|
+
function newVerifier() {
|
|
46566
|
+
return randomBytes2(32).toString("base64url");
|
|
46567
|
+
}
|
|
46568
|
+
function decodeCredentials(state, response) {
|
|
46569
|
+
if (!state.handoff_id || response.project_id !== state.project_id) {
|
|
46570
|
+
throw new Error("Claim continuation returned a different project. No credential was installed.");
|
|
46571
|
+
}
|
|
46572
|
+
const key = createHash3("sha256").update(`claim-cli-handoff:v1:${state.verifier}`, "utf8").digest();
|
|
46573
|
+
const combined = Buffer.from(response.ciphertext, "base64");
|
|
46574
|
+
if (combined.length <= 16)
|
|
46575
|
+
throw new Error("Claim continuation returned an invalid credential payload.");
|
|
46576
|
+
const encrypted = combined.subarray(0, -16);
|
|
46577
|
+
const tag = combined.subarray(-16);
|
|
46578
|
+
const decipher = createDecipheriv("aes-256-gcm", key, Buffer.from(response.iv, "base64"));
|
|
46579
|
+
decipher.setAAD(Buffer.from(`${state.handoff_id}:${state.project_id}`, "utf8"));
|
|
46580
|
+
decipher.setAuthTag(tag);
|
|
46581
|
+
const plaintext = Buffer.concat([decipher.update(encrypted), decipher.final()]).toString("utf8");
|
|
46582
|
+
const parsed = JSON.parse(plaintext);
|
|
46583
|
+
const projects = parsed.scope?.projects;
|
|
46584
|
+
const agent = parsed.credential_kind === "project_agent";
|
|
46585
|
+
if (typeof parsed.token !== "string" || !parsed.token || typeof parsed.expires_at !== "string" || typeof parsed.email !== "string" || parsed.project_id !== state.project_id || parsed.approved_scope !== void 0 && parsed.approved_scope !== "project" || !Array.isArray(projects) || !projects.includes(state.project_id) || projects.some((project) => typeof project !== "string" || !project) || (agent ? parsed.refresh_token !== null || parsed.claim_access !== "new_projects" && parsed.claim_access !== "all_projects" : parsed.credential_kind !== void 0 || parsed.claim_access !== void 0 || typeof parsed.refresh_token !== "string" || projects.length !== 1)) {
|
|
46586
|
+
throw new Error("Claim continuation credential did not match the approved project. Nothing was installed.");
|
|
46587
|
+
}
|
|
46588
|
+
return parsed;
|
|
46589
|
+
}
|
|
46590
|
+
async function post(path3, body, token) {
|
|
46591
|
+
const response = await fetchWithProxy(`${API_BASE_URL}${path3}`, {
|
|
46592
|
+
method: "POST",
|
|
46593
|
+
headers: {
|
|
46594
|
+
"Content-Type": "application/json",
|
|
46595
|
+
...token ? { Authorization: `Bearer ${token}` } : {}
|
|
46596
|
+
},
|
|
46597
|
+
body: JSON.stringify(body),
|
|
46598
|
+
signal: AbortSignal.timeout(15e3)
|
|
46599
|
+
}, 15e3);
|
|
46600
|
+
const envelope = await response.json();
|
|
46601
|
+
return { response, envelope };
|
|
46602
|
+
}
|
|
46603
|
+
async function ensureClaimHandoff(projectId) {
|
|
46604
|
+
const config2 = loadConfig();
|
|
46605
|
+
if (!config2?.temporary || !config2.token)
|
|
46606
|
+
return null;
|
|
46607
|
+
let state = config2.claim_handoff;
|
|
46608
|
+
if (!state || state.project_id !== projectId) {
|
|
46609
|
+
state = { project_id: projectId, verifier: newVerifier() };
|
|
46610
|
+
saveConfig({ ...config2, claim_handoff: state });
|
|
46611
|
+
}
|
|
46612
|
+
if (state.handoff_id)
|
|
46613
|
+
return state;
|
|
46614
|
+
const { response, envelope } = await post("/auth/temp-handoff/register", {
|
|
46615
|
+
project_id: projectId,
|
|
46616
|
+
verifier_hash: verifierHash(state.verifier),
|
|
46617
|
+
device_name: getDeviceKeyName(),
|
|
46618
|
+
client: { hostname: describeThisDevice().hostname },
|
|
46619
|
+
capabilities: ["claim_project_agent_v1"]
|
|
46620
|
+
}, config2.token);
|
|
46621
|
+
if (!response.ok || !envelope.ok || !envelope.data) {
|
|
46622
|
+
throw new Error(envelope.message || envelope.error || `CLI continuation registration failed (HTTP ${response.status}).`);
|
|
46623
|
+
}
|
|
46624
|
+
const registered = { ...state, handoff_id: envelope.data.handoff_id, expires_at: envelope.data.expires_at };
|
|
46625
|
+
const current = loadConfig();
|
|
46626
|
+
if (!current?.temporary || current.claim_handoff?.verifier !== state.verifier)
|
|
46627
|
+
return null;
|
|
46628
|
+
saveConfig({ ...current, claim_handoff: registered });
|
|
46629
|
+
return registered;
|
|
46630
|
+
}
|
|
46631
|
+
async function acknowledge(handoffId, verifier) {
|
|
46632
|
+
try {
|
|
46633
|
+
const { response, envelope } = await post("/auth/temp-handoff/ack", {
|
|
46634
|
+
handoff_id: handoffId,
|
|
46635
|
+
verifier
|
|
46636
|
+
});
|
|
46637
|
+
return response.ok && envelope.ok && envelope.data?.acknowledged === true;
|
|
46638
|
+
} catch {
|
|
46639
|
+
return false;
|
|
46640
|
+
}
|
|
46641
|
+
}
|
|
46642
|
+
function clearCurrentAcknowledgement(expected) {
|
|
46643
|
+
const current = loadConfig();
|
|
46644
|
+
if (!current)
|
|
46645
|
+
return null;
|
|
46646
|
+
if (current.claim_handoff_ack?.handoff_id !== expected.handoff_id || current.claim_handoff_ack.verifier !== expected.verifier)
|
|
46647
|
+
return current;
|
|
46648
|
+
const { claim_handoff_ack: _removed, ...clean } = current;
|
|
46649
|
+
saveConfig(clean);
|
|
46650
|
+
return clean;
|
|
46651
|
+
}
|
|
46652
|
+
function dropExpiredHandoff(token, state) {
|
|
46653
|
+
const current = loadConfig();
|
|
46654
|
+
if (!current?.temporary || current.token !== token || current.claim_handoff?.handoff_id !== state.handoff_id || current.claim_handoff?.verifier !== state.verifier)
|
|
46655
|
+
return;
|
|
46656
|
+
const { claim_handoff: _expired, ...rest } = current;
|
|
46657
|
+
saveConfig(rest);
|
|
46658
|
+
}
|
|
46659
|
+
async function recoverClaimHandoff() {
|
|
46660
|
+
let config2 = loadConfig();
|
|
46661
|
+
if (!config2)
|
|
46662
|
+
return { kind: "none" };
|
|
46663
|
+
if (config2.claim_handoff_ack) {
|
|
46664
|
+
const ack = config2.claim_handoff_ack;
|
|
46665
|
+
if (await acknowledge(ack.handoff_id, ack.verifier)) {
|
|
46666
|
+
config2 = clearCurrentAcknowledgement(ack);
|
|
46667
|
+
if (!config2)
|
|
46668
|
+
return { kind: "none" };
|
|
46669
|
+
}
|
|
46670
|
+
}
|
|
46671
|
+
const state = config2.temporary ? config2.claim_handoff : void 0;
|
|
46672
|
+
if (!state?.handoff_id)
|
|
46673
|
+
return { kind: "none" };
|
|
46674
|
+
let response;
|
|
46675
|
+
let envelope;
|
|
46676
|
+
try {
|
|
46677
|
+
({ response, envelope } = await post("/auth/temp-handoff/exchange", {
|
|
46678
|
+
handoff_id: state.handoff_id,
|
|
46679
|
+
verifier: state.verifier
|
|
46680
|
+
}));
|
|
46681
|
+
} catch {
|
|
46682
|
+
return { kind: "none" };
|
|
46683
|
+
}
|
|
46684
|
+
if (envelope.error === "CLAIM_CLI_ACCOUNT_SCOPE_FORBIDDEN" || envelope.data?.approved_scope !== void 0 && envelope.data.approved_scope !== "project") {
|
|
46685
|
+
return {
|
|
46686
|
+
kind: "manual",
|
|
46687
|
+
message: `This claim approval cannot be used to sign in. Run \`${cliInvocation()} login\` and ask the account owner to approve it.`
|
|
46688
|
+
};
|
|
46689
|
+
}
|
|
46690
|
+
if (!response.ok || !envelope.ok || !envelope.data) {
|
|
46691
|
+
if (["CLAIM_CLI_HANDOFF_PENDING", "CLAIM_CLI_HANDOFF_IN_PROGRESS"].includes(envelope.error || "")) {
|
|
46692
|
+
return { kind: "none" };
|
|
46693
|
+
}
|
|
46694
|
+
if (envelope.error === "CLAIM_CLI_HANDOFF_EXPIRED" && temporaryConfigExpired(config2)) {
|
|
46695
|
+
dropExpiredHandoff(config2.token, state);
|
|
46696
|
+
return {
|
|
46697
|
+
kind: "stale",
|
|
46698
|
+
message: `The temporary workspace on this machine expired at ${config2.temp_expires_at}. If you claimed it in the browser, \`${cliInvocation()} login\` signs in to it.`
|
|
46699
|
+
};
|
|
46700
|
+
}
|
|
46701
|
+
if (["CLAIM_CLI_HANDOFF_DENIED", "CLAIM_CLI_HANDOFF_EXPIRED", "CLAIM_CLI_HANDOFF_CONSUMED", "CLAIM_CLI_HANDOFF_OWNERSHIP_MISMATCH"].includes(envelope.error || "")) {
|
|
46702
|
+
return {
|
|
46703
|
+
kind: "manual",
|
|
46704
|
+
message: envelope.message || `Run \`${cliInvocation()} login\` in this directory. Keep the existing project link; do not unlink or redeploy.`
|
|
46705
|
+
};
|
|
46706
|
+
}
|
|
46707
|
+
return { kind: "none" };
|
|
46708
|
+
}
|
|
46709
|
+
const delivered = decodeCredentials(state, envelope.data);
|
|
46710
|
+
const current = loadConfig();
|
|
46711
|
+
if (!current?.temporary || current.token !== config2.token || current.claim_handoff?.project_id !== state.project_id || current.claim_handoff.verifier !== state.verifier || current.claim_handoff.handoff_id !== state.handoff_id) {
|
|
46712
|
+
return { kind: "none" };
|
|
46713
|
+
}
|
|
46714
|
+
const next = {
|
|
46715
|
+
token: delivered.token,
|
|
46716
|
+
...delivered.credential_kind === "project_agent" ? { claim_access: delivered.claim_access } : { refresh_token: delivered.refresh_token, access_expires_at: delivered.expires_at },
|
|
46717
|
+
user: { email: delivered.email, username: "" },
|
|
46718
|
+
claim_handoff_ack: { handoff_id: state.handoff_id, verifier: state.verifier }
|
|
46719
|
+
};
|
|
46720
|
+
saveConfig(next);
|
|
46721
|
+
if (await acknowledge(state.handoff_id, state.verifier)) {
|
|
46722
|
+
clearCurrentAcknowledgement(next.claim_handoff_ack);
|
|
46723
|
+
}
|
|
46724
|
+
return {
|
|
46725
|
+
kind: "recovered",
|
|
46726
|
+
message: delivered.claim_access === "new_projects" ? "Connected. You can work on the saved apps and create new apps in this account." : delivered.claim_access === "all_projects" ? "Connected. You can work on the apps already in this account and create new ones." : `Connected. You can work on the saved app. Run \`${cliInvocation()} login\` for account access.`
|
|
46727
|
+
};
|
|
46728
|
+
}
|
|
46729
|
+
var init_claim_handoff = __esm({
|
|
46730
|
+
"dist/lib/claim-handoff.js"() {
|
|
46731
|
+
"use strict";
|
|
46732
|
+
init_cli_invocation();
|
|
46733
|
+
init_config();
|
|
46734
|
+
init_device();
|
|
46735
|
+
init_device_login();
|
|
46736
|
+
init_client();
|
|
46737
|
+
init_http();
|
|
46738
|
+
__name(readClaimConnection, "readClaimConnection");
|
|
46739
|
+
__name(verifierHash, "verifierHash");
|
|
46740
|
+
__name(newVerifier, "newVerifier");
|
|
46741
|
+
__name(decodeCredentials, "decodeCredentials");
|
|
46742
|
+
__name(post, "post");
|
|
46743
|
+
__name(ensureClaimHandoff, "ensureClaimHandoff");
|
|
46744
|
+
__name(acknowledge, "acknowledge");
|
|
46745
|
+
__name(clearCurrentAcknowledgement, "clearCurrentAcknowledgement");
|
|
46746
|
+
__name(dropExpiredHandoff, "dropExpiredHandoff");
|
|
46747
|
+
__name(recoverClaimHandoff, "recoverClaimHandoff");
|
|
46748
|
+
}
|
|
46749
|
+
});
|
|
46750
|
+
|
|
46554
46751
|
// dist/lib/allowed-origins.js
|
|
46555
46752
|
function isExactOrigin(value) {
|
|
46556
46753
|
const trimmed = value.trim();
|
|
@@ -46825,6 +47022,30 @@ async function listProjects(opts = {}) {
|
|
|
46825
47022
|
const client = new ApiClient(getToken());
|
|
46826
47023
|
const spinner = opts.json ? null : ora("Fetching projects...").start();
|
|
46827
47024
|
try {
|
|
47025
|
+
if (loadConfig()?.claim_access) {
|
|
47026
|
+
const connection = await readClaimConnection(client);
|
|
47027
|
+
spinner?.stop();
|
|
47028
|
+
if (connection.state !== "claimed_connected") {
|
|
47029
|
+
throw new Error(`This app connection is closed. Run \`${cliInvocation()} login\` and ask the account owner to approve it.`);
|
|
47030
|
+
}
|
|
47031
|
+
if (opts.json)
|
|
47032
|
+
printJson(connection);
|
|
47033
|
+
else {
|
|
47034
|
+
const apps = connection.projects ?? [];
|
|
47035
|
+
if (apps.length)
|
|
47036
|
+
table(["App", "ID", "URL", "Deploy"], apps.map((app) => [
|
|
47037
|
+
app.name,
|
|
47038
|
+
app.project_id,
|
|
47039
|
+
app.url,
|
|
47040
|
+
app.can_deploy ? "Available" : app.reason === "private_configuration" ? "Paused for private configuration" : "Unavailable"
|
|
47041
|
+
]));
|
|
47042
|
+
else
|
|
47043
|
+
info("This connection has no apps yet.");
|
|
47044
|
+
if (connection.can_create_projects)
|
|
47045
|
+
info(`Create an app with \`${cliInvocation()} init --name <name>\`.`);
|
|
47046
|
+
}
|
|
47047
|
+
return;
|
|
47048
|
+
}
|
|
46828
47049
|
const result = await client.call("GET", "/projects");
|
|
46829
47050
|
spinner?.stop();
|
|
46830
47051
|
if (opts.json) {
|
|
@@ -46873,6 +47094,7 @@ var init_project = __esm({
|
|
|
46873
47094
|
init_spinner();
|
|
46874
47095
|
init_client();
|
|
46875
47096
|
init_config();
|
|
47097
|
+
init_claim_handoff();
|
|
46876
47098
|
init_output();
|
|
46877
47099
|
init_project_urls();
|
|
46878
47100
|
init_platform_command();
|
|
@@ -76028,11 +76250,11 @@ var init_typecheck2 = __esm({
|
|
|
76028
76250
|
});
|
|
76029
76251
|
|
|
76030
76252
|
// dist/lib/base-files.js
|
|
76031
|
-
import { createHash as
|
|
76253
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
76032
76254
|
import { existsSync as existsSync17, mkdirSync as mkdirSync10, readFileSync as readFileSync18, rmSync as rmSync5, writeFileSync as writeFileSync13 } from "node:fs";
|
|
76033
76255
|
import { join as join20 } from "node:path";
|
|
76034
76256
|
function sha2562(content) {
|
|
76035
|
-
return
|
|
76257
|
+
return createHash4("sha256").update(content).digest("hex");
|
|
76036
76258
|
}
|
|
76037
76259
|
function hashFiles(dir, paths) {
|
|
76038
76260
|
const out = {};
|
|
@@ -76308,7 +76530,7 @@ var init_build_errors = __esm({
|
|
|
76308
76530
|
});
|
|
76309
76531
|
|
|
76310
76532
|
// dist/lib/temp-auth.js
|
|
76311
|
-
import { createHash as
|
|
76533
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
76312
76534
|
function leadingZeroBits(buf) {
|
|
76313
76535
|
let bits = 0;
|
|
76314
76536
|
for (const byte of buf) {
|
|
@@ -76329,7 +76551,7 @@ function solvePow(nonce, difficulty) {
|
|
|
76329
76551
|
let i = 0;
|
|
76330
76552
|
for (; ; ) {
|
|
76331
76553
|
const suffix = (i++).toString(36);
|
|
76332
|
-
const hash2 =
|
|
76554
|
+
const hash2 = createHash5("sha256").update(`${nonce}:${suffix}`, "utf8").digest();
|
|
76333
76555
|
if (leadingZeroBits(hash2) >= difficulty) {
|
|
76334
76556
|
return { suffix, hash: hash2.toString("hex") };
|
|
76335
76557
|
}
|
|
@@ -76374,194 +76596,6 @@ var init_temp_auth = __esm({
|
|
|
76374
76596
|
}
|
|
76375
76597
|
});
|
|
76376
76598
|
|
|
76377
|
-
// dist/lib/claim-handoff.js
|
|
76378
|
-
import { createDecipheriv, createHash as createHash5, randomBytes as randomBytes2 } from "node:crypto";
|
|
76379
|
-
function verifierHash(verifier) {
|
|
76380
|
-
return createHash5("sha256").update(verifier, "utf8").digest("hex");
|
|
76381
|
-
}
|
|
76382
|
-
function newVerifier() {
|
|
76383
|
-
return randomBytes2(32).toString("base64url");
|
|
76384
|
-
}
|
|
76385
|
-
function decodeCredentials(state, response) {
|
|
76386
|
-
if (!state.handoff_id || response.project_id !== state.project_id) {
|
|
76387
|
-
throw new Error("Claim continuation returned a different project. No credential was installed.");
|
|
76388
|
-
}
|
|
76389
|
-
const key = createHash5("sha256").update(`claim-cli-handoff:v1:${state.verifier}`, "utf8").digest();
|
|
76390
|
-
const combined = Buffer.from(response.ciphertext, "base64");
|
|
76391
|
-
if (combined.length <= 16)
|
|
76392
|
-
throw new Error("Claim continuation returned an invalid credential payload.");
|
|
76393
|
-
const encrypted = combined.subarray(0, -16);
|
|
76394
|
-
const tag = combined.subarray(-16);
|
|
76395
|
-
const decipher = createDecipheriv("aes-256-gcm", key, Buffer.from(response.iv, "base64"));
|
|
76396
|
-
decipher.setAAD(Buffer.from(`${state.handoff_id}:${state.project_id}`, "utf8"));
|
|
76397
|
-
decipher.setAuthTag(tag);
|
|
76398
|
-
const plaintext = Buffer.concat([decipher.update(encrypted), decipher.final()]).toString("utf8");
|
|
76399
|
-
const parsed = JSON.parse(plaintext);
|
|
76400
|
-
if (typeof parsed.token !== "string" || typeof parsed.refresh_token !== "string" || typeof parsed.expires_at !== "string" || typeof parsed.email !== "string" || parsed.project_id !== state.project_id || parsed.approved_scope !== void 0 && parsed.approved_scope !== "project" || parsed.scope?.projects?.length !== 1 || parsed.scope.projects[0] !== state.project_id) {
|
|
76401
|
-
throw new Error("Claim continuation credential did not match the approved project. Nothing was installed.");
|
|
76402
|
-
}
|
|
76403
|
-
return parsed;
|
|
76404
|
-
}
|
|
76405
|
-
async function post(path3, body, token) {
|
|
76406
|
-
const response = await fetchWithProxy(`${API_BASE_URL}${path3}`, {
|
|
76407
|
-
method: "POST",
|
|
76408
|
-
headers: {
|
|
76409
|
-
"Content-Type": "application/json",
|
|
76410
|
-
...token ? { Authorization: `Bearer ${token}` } : {}
|
|
76411
|
-
},
|
|
76412
|
-
body: JSON.stringify(body),
|
|
76413
|
-
signal: AbortSignal.timeout(15e3)
|
|
76414
|
-
}, 15e3);
|
|
76415
|
-
const envelope = await response.json();
|
|
76416
|
-
return { response, envelope };
|
|
76417
|
-
}
|
|
76418
|
-
async function ensureClaimHandoff(projectId) {
|
|
76419
|
-
const config2 = loadConfig();
|
|
76420
|
-
if (!config2?.temporary || !config2.token)
|
|
76421
|
-
return null;
|
|
76422
|
-
let state = config2.claim_handoff;
|
|
76423
|
-
if (!state || state.project_id !== projectId) {
|
|
76424
|
-
state = { project_id: projectId, verifier: newVerifier() };
|
|
76425
|
-
saveConfig({ ...config2, claim_handoff: state });
|
|
76426
|
-
}
|
|
76427
|
-
if (state.handoff_id)
|
|
76428
|
-
return state;
|
|
76429
|
-
const { response, envelope } = await post("/auth/temp-handoff/register", {
|
|
76430
|
-
project_id: projectId,
|
|
76431
|
-
verifier_hash: verifierHash(state.verifier),
|
|
76432
|
-
device_name: getDeviceKeyName(),
|
|
76433
|
-
client: describeThisDevice()
|
|
76434
|
-
}, config2.token);
|
|
76435
|
-
if (!response.ok || !envelope.ok || !envelope.data) {
|
|
76436
|
-
throw new Error(envelope.message || envelope.error || `CLI continuation registration failed (HTTP ${response.status}).`);
|
|
76437
|
-
}
|
|
76438
|
-
const registered = { ...state, handoff_id: envelope.data.handoff_id, expires_at: envelope.data.expires_at };
|
|
76439
|
-
const current = loadConfig();
|
|
76440
|
-
if (!current?.temporary || current.claim_handoff?.verifier !== state.verifier)
|
|
76441
|
-
return null;
|
|
76442
|
-
saveConfig({ ...current, claim_handoff: registered });
|
|
76443
|
-
return registered;
|
|
76444
|
-
}
|
|
76445
|
-
async function acknowledge(handoffId, verifier) {
|
|
76446
|
-
try {
|
|
76447
|
-
const { response, envelope } = await post("/auth/temp-handoff/ack", {
|
|
76448
|
-
handoff_id: handoffId,
|
|
76449
|
-
verifier
|
|
76450
|
-
});
|
|
76451
|
-
return response.ok && envelope.ok && envelope.data?.acknowledged === true;
|
|
76452
|
-
} catch {
|
|
76453
|
-
return false;
|
|
76454
|
-
}
|
|
76455
|
-
}
|
|
76456
|
-
function clearCurrentAcknowledgement(expected) {
|
|
76457
|
-
const current = loadConfig();
|
|
76458
|
-
if (!current)
|
|
76459
|
-
return null;
|
|
76460
|
-
if (current.claim_handoff_ack?.handoff_id !== expected.handoff_id || current.claim_handoff_ack.verifier !== expected.verifier)
|
|
76461
|
-
return current;
|
|
76462
|
-
const { claim_handoff_ack: _removed, ...clean } = current;
|
|
76463
|
-
saveConfig(clean);
|
|
76464
|
-
return clean;
|
|
76465
|
-
}
|
|
76466
|
-
function dropExpiredHandoff(token, state) {
|
|
76467
|
-
const current = loadConfig();
|
|
76468
|
-
if (!current?.temporary || current.token !== token || current.claim_handoff?.handoff_id !== state.handoff_id || current.claim_handoff?.verifier !== state.verifier)
|
|
76469
|
-
return;
|
|
76470
|
-
const { claim_handoff: _expired, ...rest } = current;
|
|
76471
|
-
saveConfig(rest);
|
|
76472
|
-
}
|
|
76473
|
-
async function recoverClaimHandoff() {
|
|
76474
|
-
let config2 = loadConfig();
|
|
76475
|
-
if (!config2)
|
|
76476
|
-
return { kind: "none" };
|
|
76477
|
-
if (config2.claim_handoff_ack) {
|
|
76478
|
-
const ack = config2.claim_handoff_ack;
|
|
76479
|
-
if (await acknowledge(ack.handoff_id, ack.verifier)) {
|
|
76480
|
-
config2 = clearCurrentAcknowledgement(ack);
|
|
76481
|
-
if (!config2)
|
|
76482
|
-
return { kind: "none" };
|
|
76483
|
-
}
|
|
76484
|
-
}
|
|
76485
|
-
const state = config2.temporary ? config2.claim_handoff : void 0;
|
|
76486
|
-
if (!state?.handoff_id)
|
|
76487
|
-
return { kind: "none" };
|
|
76488
|
-
let response;
|
|
76489
|
-
let envelope;
|
|
76490
|
-
try {
|
|
76491
|
-
({ response, envelope } = await post("/auth/temp-handoff/exchange", {
|
|
76492
|
-
handoff_id: state.handoff_id,
|
|
76493
|
-
verifier: state.verifier
|
|
76494
|
-
}));
|
|
76495
|
-
} catch {
|
|
76496
|
-
return { kind: "none" };
|
|
76497
|
-
}
|
|
76498
|
-
if (envelope.error === "CLAIM_CLI_ACCOUNT_SCOPE_FORBIDDEN" || envelope.data?.approved_scope !== void 0 && envelope.data.approved_scope !== "project") {
|
|
76499
|
-
return {
|
|
76500
|
-
kind: "manual",
|
|
76501
|
-
message: `A claim link connects this CLI only to the claimed project. Run \`${cliInvocation()} login\` for account access.`
|
|
76502
|
-
};
|
|
76503
|
-
}
|
|
76504
|
-
if (!response.ok || !envelope.ok || !envelope.data) {
|
|
76505
|
-
if (["CLAIM_CLI_HANDOFF_PENDING", "CLAIM_CLI_HANDOFF_IN_PROGRESS"].includes(envelope.error || "")) {
|
|
76506
|
-
return { kind: "none" };
|
|
76507
|
-
}
|
|
76508
|
-
if (envelope.error === "CLAIM_CLI_HANDOFF_EXPIRED" && temporaryConfigExpired(config2)) {
|
|
76509
|
-
dropExpiredHandoff(config2.token, state);
|
|
76510
|
-
return {
|
|
76511
|
-
kind: "stale",
|
|
76512
|
-
message: `The temporary workspace on this machine expired at ${config2.temp_expires_at}. If you claimed it in the browser, \`${cliInvocation()} login\` signs in to it.`
|
|
76513
|
-
};
|
|
76514
|
-
}
|
|
76515
|
-
if (["CLAIM_CLI_HANDOFF_DENIED", "CLAIM_CLI_HANDOFF_EXPIRED", "CLAIM_CLI_HANDOFF_CONSUMED", "CLAIM_CLI_HANDOFF_OWNERSHIP_MISMATCH"].includes(envelope.error || "")) {
|
|
76516
|
-
return {
|
|
76517
|
-
kind: "manual",
|
|
76518
|
-
message: envelope.message || `Run \`${cliInvocation()} login\` in this directory. Keep the existing project link; do not unlink or redeploy.`
|
|
76519
|
-
};
|
|
76520
|
-
}
|
|
76521
|
-
return { kind: "none" };
|
|
76522
|
-
}
|
|
76523
|
-
const delivered = decodeCredentials(state, envelope.data);
|
|
76524
|
-
const current = loadConfig();
|
|
76525
|
-
if (!current?.temporary || current.token !== config2.token || current.claim_handoff?.project_id !== state.project_id || current.claim_handoff.verifier !== state.verifier || current.claim_handoff.handoff_id !== state.handoff_id) {
|
|
76526
|
-
return { kind: "none" };
|
|
76527
|
-
}
|
|
76528
|
-
const next = {
|
|
76529
|
-
token: delivered.token,
|
|
76530
|
-
refresh_token: delivered.refresh_token,
|
|
76531
|
-
access_expires_at: delivered.expires_at,
|
|
76532
|
-
user: { email: delivered.email, username: "" },
|
|
76533
|
-
claim_handoff_ack: { handoff_id: state.handoff_id, verifier: state.verifier }
|
|
76534
|
-
};
|
|
76535
|
-
saveConfig(next);
|
|
76536
|
-
if (await acknowledge(state.handoff_id, state.verifier)) {
|
|
76537
|
-
clearCurrentAcknowledgement(next.claim_handoff_ack);
|
|
76538
|
-
}
|
|
76539
|
-
return {
|
|
76540
|
-
kind: "recovered",
|
|
76541
|
-
message: `Connected to ${delivered.email} for this project only. The existing project link was kept. Run \`${cliInvocation()} login\` for account access.`
|
|
76542
|
-
};
|
|
76543
|
-
}
|
|
76544
|
-
var init_claim_handoff = __esm({
|
|
76545
|
-
"dist/lib/claim-handoff.js"() {
|
|
76546
|
-
"use strict";
|
|
76547
|
-
init_cli_invocation();
|
|
76548
|
-
init_config();
|
|
76549
|
-
init_device();
|
|
76550
|
-
init_device_login();
|
|
76551
|
-
init_client();
|
|
76552
|
-
init_http();
|
|
76553
|
-
__name(verifierHash, "verifierHash");
|
|
76554
|
-
__name(newVerifier, "newVerifier");
|
|
76555
|
-
__name(decodeCredentials, "decodeCredentials");
|
|
76556
|
-
__name(post, "post");
|
|
76557
|
-
__name(ensureClaimHandoff, "ensureClaimHandoff");
|
|
76558
|
-
__name(acknowledge, "acknowledge");
|
|
76559
|
-
__name(clearCurrentAcknowledgement, "clearCurrentAcknowledgement");
|
|
76560
|
-
__name(dropExpiredHandoff, "dropExpiredHandoff");
|
|
76561
|
-
__name(recoverClaimHandoff, "recoverClaimHandoff");
|
|
76562
|
-
}
|
|
76563
|
-
});
|
|
76564
|
-
|
|
76565
76599
|
// dist/lib/project-notices.js
|
|
76566
76600
|
import { existsSync as existsSync19, mkdirSync as mkdirSync11, readFileSync as readFileSync20, writeFileSync as writeFileSync14 } from "node:fs";
|
|
76567
76601
|
import { dirname as dirname8, join as join22 } from "node:path";
|
|
@@ -77325,70 +77359,6 @@ var init_preview_record = __esm({
|
|
|
77325
77359
|
}
|
|
77326
77360
|
});
|
|
77327
77361
|
|
|
77328
|
-
// dist/lib/test-report.js
|
|
77329
|
-
function describeReport(groups, options2 = {}) {
|
|
77330
|
-
const many = groups.length > 1;
|
|
77331
|
-
const checks = groups.flatMap((group) => group.checks.map((check2) => ({ ...check2, script: many && check2.name !== group.script ? group.script : null })));
|
|
77332
|
-
const note = /* @__PURE__ */ __name((script, extra) => {
|
|
77333
|
-
const parts = [script, extra].filter(Boolean);
|
|
77334
|
-
return parts.length ? ` (${parts.join(", ")})` : "";
|
|
77335
|
-
}, "note");
|
|
77336
|
-
const failed = checks.filter((check2) => !check2.ok && !check2.skipped);
|
|
77337
|
-
const notRun = checks.filter((check2) => check2.skipped === "after-failure");
|
|
77338
|
-
const skipped = checks.filter((check2) => check2.skipped && check2.skipped !== "after-failure");
|
|
77339
|
-
const lines = [
|
|
77340
|
-
...failed.flatMap((check2) => {
|
|
77341
|
-
const name = `FAIL ${check2.name}${note(check2.script)}`;
|
|
77342
|
-
const failure = check2.failure;
|
|
77343
|
-
if (!failure)
|
|
77344
|
-
return [`${name}: ${firstLine(check2.error) || "failed"}`];
|
|
77345
|
-
return [
|
|
77346
|
-
name,
|
|
77347
|
-
` Expected: ${failure.expected}`,
|
|
77348
|
-
` Happened: ${failure.happened}`,
|
|
77349
|
-
` Step: ${failure.step}`,
|
|
77350
|
-
...failure.evidence ? [` Evidence: ${failure.evidence}`] : []
|
|
77351
|
-
];
|
|
77352
|
-
}),
|
|
77353
|
-
...checks.filter((check2) => check2.ok).map((check2) => `PASS ${check2.name}${note(check2.script)}`),
|
|
77354
|
-
...skipped.map((check2) => `SKIPPED ${check2.name}${note(check2.script)}: ${firstLine(check2.error)}`),
|
|
77355
|
-
...notRun.map((check2) => `NOT RUN ${check2.name}${note(check2.script, "after the first failure")}`)
|
|
77356
|
-
];
|
|
77357
|
-
const scripts = plural(groups.length, "script");
|
|
77358
|
-
if (!checks.length)
|
|
77359
|
-
lines.push(`FAILED: no check ran in ${scripts}: it stopped before its first check (its error is in the script's output).`);
|
|
77360
|
-
else if (failed.length) {
|
|
77361
|
-
const omitted = [skipped.length && `${skipped.length} skipped`, notRun.length && `${notRun.length} not run`].filter(Boolean);
|
|
77362
|
-
lines.push(`FAILED: ${failed.length} of ${plural(checks.length, "check")} in ${scripts}${omitted.length ? ` (${omitted.join(", ")})` : ""}`);
|
|
77363
|
-
} else if (skipped.length)
|
|
77364
|
-
lines.push(`${checks.length - skipped.length} passed, ${skipped.length} skipped in ${scripts}`);
|
|
77365
|
-
else
|
|
77366
|
-
lines.push(`PASSED: ${plural(checks.length, "check")} in ${scripts}`);
|
|
77367
|
-
if (!checks.length)
|
|
77368
|
-
lines.push(`Next: fix the error in the script's output, then run ${TEST_COMMAND} again.`);
|
|
77369
|
-
else if (failed.length)
|
|
77370
|
-
lines.push(`Next: fix what each FAIL line names, run ${DEPLOY_COMMAND}, then ${TEST_COMMAND} --failed to rerun each script that failed.`);
|
|
77371
|
-
if (skipped.some((check2) => check2.skipped === "needs-claim"))
|
|
77372
|
-
lines.push(TEST_INBOX_CLAIM_NEXT);
|
|
77373
|
-
const files = [...new Set(groups.map((group) => group.resultFile).filter((file2) => Boolean(file2)))];
|
|
77374
|
-
if (files.length && (failed.length || !checks.length || options2.verbose))
|
|
77375
|
-
lines.push(`Full result: ${files.join(", ")}`);
|
|
77376
|
-
return lines;
|
|
77377
|
-
}
|
|
77378
|
-
var DEPLOY_COMMAND, TEST_COMMAND, TEST_INBOX_CLAIM_REASON, TEST_INBOX_CLAIM_NEXT, firstLine, plural;
|
|
77379
|
-
var init_test_report = __esm({
|
|
77380
|
-
"dist/lib/test-report.js"() {
|
|
77381
|
-
"use strict";
|
|
77382
|
-
DEPLOY_COMMAND = "npx @somewhere-cloud/cli deploy";
|
|
77383
|
-
TEST_COMMAND = "npx @somewhere-cloud/cli test";
|
|
77384
|
-
TEST_INBOX_CLAIM_REASON = "needs a claimed app: run somewhere claim";
|
|
77385
|
-
TEST_INBOX_CLAIM_NEXT = "Next: run somewhere claim, open its link, then run somewhere test again.";
|
|
77386
|
-
firstLine = /* @__PURE__ */ __name((text) => (text ?? "").split("\n").map((line) => line.trim()).find((line) => line && !/^(?:hint:|Usage details:|Platform bug reports:)/i.test(line)) ?? "", "firstLine");
|
|
77387
|
-
plural = /* @__PURE__ */ __name((n, word) => `${n} ${word}${n === 1 ? "" : "s"}`, "plural");
|
|
77388
|
-
__name(describeReport, "describeReport");
|
|
77389
|
-
}
|
|
77390
|
-
});
|
|
77391
|
-
|
|
77392
77362
|
// dist/lib/test-diagnostics.js
|
|
77393
77363
|
function rememberSecrets(...values) {
|
|
77394
77364
|
for (const value of values)
|
|
@@ -77500,8 +77470,6 @@ function productionControl(client, target) {
|
|
|
77500
77470
|
projectId,
|
|
77501
77471
|
target,
|
|
77502
77472
|
async inbox(address, wait) {
|
|
77503
|
-
if (loadConfig()?.temporary)
|
|
77504
|
-
throw new TestInboxNeedsClaim();
|
|
77505
77473
|
const body = await client.call("GET", "/email/test-inbox", void 0, { project_id: projectId, address, limit: 20, ...wait ? { wait_ms: wait.ms ?? 1e4, since: wait.since } : {} });
|
|
77506
77474
|
return messagesAfter(body.messages, address, 0);
|
|
77507
77475
|
},
|
|
@@ -77652,7 +77620,7 @@ async function deletePreviewManagedUser(tool, id) {
|
|
|
77652
77620
|
return isDeadPreviewCredential(error3) ? "the preview is closed, promoted or expired, or its credential was revoked" : String(error3 instanceof Error ? error3.message : error3).slice(0, 200);
|
|
77653
77621
|
}
|
|
77654
77622
|
}
|
|
77655
|
-
var
|
|
77623
|
+
var PREVIEW_CLOSED_MESSAGE, PreviewRunError;
|
|
77656
77624
|
var init_test_control = __esm({
|
|
77657
77625
|
"dist/lib/test-control.js"() {
|
|
77658
77626
|
"use strict";
|
|
@@ -77663,16 +77631,7 @@ var init_test_control = __esm({
|
|
|
77663
77631
|
init_test_target();
|
|
77664
77632
|
init_test_identities();
|
|
77665
77633
|
init_form_accounts();
|
|
77666
|
-
init_test_report();
|
|
77667
77634
|
init_test_diagnostics();
|
|
77668
|
-
TestInboxNeedsClaim = class extends Error {
|
|
77669
|
-
static {
|
|
77670
|
-
__name(this, "TestInboxNeedsClaim");
|
|
77671
|
-
}
|
|
77672
|
-
constructor() {
|
|
77673
|
-
super(TEST_INBOX_CLAIM_REASON);
|
|
77674
|
-
}
|
|
77675
|
-
};
|
|
77676
77635
|
__name(productionControl, "productionControl");
|
|
77677
77636
|
__name(openProductionControl, "openProductionControl");
|
|
77678
77637
|
PREVIEW_CLOSED_MESSAGE = "The preview is closed, promoted or expired, or its credential was revoked. Open or continue one with `somewhere preview`, then run the tests again.";
|
|
@@ -77892,8 +77851,6 @@ function prepareDeployTests(start) {
|
|
|
77892
77851
|
async function runDeployTests(input) {
|
|
77893
77852
|
const release2 = input.release ?? null;
|
|
77894
77853
|
const notRun = /* @__PURE__ */ __name((reason) => ({ status: "not_run", release: release2, reason }), "notRun");
|
|
77895
|
-
if (input.temporary)
|
|
77896
|
-
return notRun("a temporary project cannot run tests; claim it, link this folder and run somewhere test");
|
|
77897
77854
|
if (!input.projectId || !input.release)
|
|
77898
77855
|
return notRun("the deploy did not name its project and release");
|
|
77899
77856
|
if (input.renderPending) {
|
|
@@ -77930,6 +77887,8 @@ function formatDeployTestsLine(tests) {
|
|
|
77930
77887
|
const skipped = r?.skipped ? `, ${r.skipped} skipped (a skipped test proves nothing)` : "";
|
|
77931
77888
|
if (tests.status === "passed")
|
|
77932
77889
|
return `The deploy is live and its tests passed: ${r?.passed ?? 0} passed${skipped} on ${tests.release}.`;
|
|
77890
|
+
if (tests.status === "failed" && !r?.failed && r?.skipped && !r?.setupErrors && !tests.reason)
|
|
77891
|
+
return `The deploy is live. Its tests did NOT all run: ${r.skipped} skipped (a skipped test proves nothing), ${r.passed ?? 0} passed on ${tests.release}. Each SKIPPED line above says why.`;
|
|
77933
77892
|
if (tests.status === "failed")
|
|
77934
77893
|
return `The deploy is live. Its tests FAILED: ${r?.failed ?? 0} failed, ${r?.passed ?? 0} passed${skipped}${r?.setupErrors ? `, ${r.setupErrors} setup errors` : ""}${tests.reason ? ` (${tests.reason})` : ""} on ${tests.release}. After fixing a test: somewhere test --failed. After fixing the app: somewhere deploy --test.`;
|
|
77935
77894
|
return `The deploy is live. Its tests did NOT run: ${tests.reason}.`;
|
|
@@ -77948,19 +77907,19 @@ var init_deploy_tests = __esm({
|
|
|
77948
77907
|
});
|
|
77949
77908
|
|
|
77950
77909
|
// dist/lib/surface-counts.js
|
|
77951
|
-
function
|
|
77910
|
+
function plural(count2, one, many) {
|
|
77952
77911
|
return `${count2} ${count2 === 1 ? one : many}`;
|
|
77953
77912
|
}
|
|
77954
77913
|
function formatPublishSurface(counts) {
|
|
77955
77914
|
const parts = [];
|
|
77956
77915
|
if (counts.staticFiles !== null) {
|
|
77957
|
-
parts.push(
|
|
77916
|
+
parts.push(plural(counts.staticFiles, "static file", "static files"));
|
|
77958
77917
|
}
|
|
77959
77918
|
if (counts.functions === "some") {
|
|
77960
77919
|
parts.push("functions");
|
|
77961
77920
|
} else if (typeof counts.functions === "number") {
|
|
77962
77921
|
if (counts.functions > 0 || parts.length === 0) {
|
|
77963
|
-
parts.push(
|
|
77922
|
+
parts.push(plural(counts.functions, "function", "functions"));
|
|
77964
77923
|
}
|
|
77965
77924
|
}
|
|
77966
77925
|
if (parts.length === 0)
|
|
@@ -78003,7 +77962,7 @@ var init_surface_counts = __esm({
|
|
|
78003
77962
|
"dist/lib/surface-counts.js"() {
|
|
78004
77963
|
"use strict";
|
|
78005
77964
|
init_cli_invocation();
|
|
78006
|
-
__name(
|
|
77965
|
+
__name(plural, "plural");
|
|
78007
77966
|
__name(formatPublishSurface, "formatPublishSurface");
|
|
78008
77967
|
__name(countPublishSurface, "countPublishSurface");
|
|
78009
77968
|
__name(countFunctionRoutes, "countFunctionRoutes");
|
|
@@ -81958,10 +81917,10 @@ function formatTempExpiry(expiresAt, ttlSeconds, nowMs = Date.now()) {
|
|
|
81958
81917
|
if (remainingMs <= 0)
|
|
81959
81918
|
return "Temporary app. It has expired.";
|
|
81960
81919
|
const minutes = Math.ceil(remainingMs / 6e4);
|
|
81961
|
-
const remaining = minutes >= 60 ?
|
|
81920
|
+
const remaining = minutes >= 60 ? plural2(Math.round(minutes / 60), "hour") : plural2(minutes < 5 ? minutes : Math.min(55, Math.round(minutes / 5) * 5), "minute");
|
|
81962
81921
|
return `Temporary app. Expires in about ${remaining}.`;
|
|
81963
81922
|
}
|
|
81964
|
-
function
|
|
81923
|
+
function plural2(count2, singular, pluralWord = `${singular}s`) {
|
|
81965
81924
|
return `${count2} ${count2 === 1 ? singular : pluralWord}`;
|
|
81966
81925
|
}
|
|
81967
81926
|
function formatElapsed(at2, nowMs = Date.now()) {
|
|
@@ -81974,15 +81933,15 @@ function formatElapsed(at2, nowMs = Date.now()) {
|
|
|
81974
81933
|
if (minutes < 1)
|
|
81975
81934
|
return " just now";
|
|
81976
81935
|
if (minutes < 60)
|
|
81977
|
-
return ` ${
|
|
81936
|
+
return ` ${plural2(minutes, "minute")} ago`;
|
|
81978
81937
|
const hours = Math.floor(minutes / 60);
|
|
81979
81938
|
if (hours < 24)
|
|
81980
|
-
return ` ${
|
|
81939
|
+
return ` ${plural2(hours, "hour")} ago`;
|
|
81981
81940
|
const days = Math.floor(hours / 24);
|
|
81982
81941
|
if (days < 30)
|
|
81983
|
-
return ` ${
|
|
81942
|
+
return ` ${plural2(days, "day")} ago`;
|
|
81984
81943
|
const months = Math.floor(days / 30);
|
|
81985
|
-
return ` ${
|
|
81944
|
+
return ` ${plural2(months, "month")} ago`;
|
|
81986
81945
|
}
|
|
81987
81946
|
function formatChangeSource(source) {
|
|
81988
81947
|
const normalized = source?.trim().toLowerCase();
|
|
@@ -82025,7 +81984,7 @@ function formatStaleBaseExplanation(details, nowMs = Date.now()) {
|
|
|
82025
81984
|
const elapsed = formatElapsed(details.last_change_at, nowMs);
|
|
82026
81985
|
const fileList = files.slice(0, 10).join(", ");
|
|
82027
81986
|
const more = files.length > 10 ? `, and ${files.length - 10} more` : "";
|
|
82028
|
-
const changeSummary = files.length > 0 ? `${
|
|
81987
|
+
const changeSummary = files.length > 0 ? `${plural2(files.length, "file")} edited${source}${elapsed}: ${fileList}${more}` : `remote edits${source}${elapsed}`;
|
|
82029
81988
|
const versionSummary = details.current_version !== void 0 && details.base_version !== void 0 ? `Remote is now v${details.current_version}; this machine last deployed v${details.base_version}.` : null;
|
|
82030
81989
|
return [
|
|
82031
81990
|
`This project changed since your last deploy from this machine \u2014 ${changeSummary}. Your deploy was NOT applied.`,
|
|
@@ -82478,7 +82437,7 @@ Existing project: \`${cliInvocation()} init --link --project <ref>\` (see \`${cl
|
|
|
82478
82437
|
} else if (linkedProjectEntry && projectConfigMatchesRef(linkedProjectEntry.config, projectId)) {
|
|
82479
82438
|
deployStateEntry = linkedProjectEntry;
|
|
82480
82439
|
}
|
|
82481
|
-
const stopPrestart = projectId && !tempSession && !opts.dryRun ? startDeployPrestart(client, projectId) : () => void 0;
|
|
82440
|
+
const stopPrestart = projectId && !tempSession && !opts.dryRun && !storedConfig?.claim_access ? startDeployPrestart(client, projectId) : () => void 0;
|
|
82482
82441
|
let explicitProjectId = null;
|
|
82483
82442
|
const earlyLiveBase = opts.project && projectId && !tempSession && !opts.force && CANONICAL_PROJECT_ID.test(projectId) && !readSourceBase(targetProjectConfig, projectId) ? { projectId, read: readExplicitProjectLiveBase(client, projectId) } : null;
|
|
82484
82443
|
if (opts.project && projectId && !tempSession) {
|
|
@@ -82774,7 +82733,7 @@ Existing project: \`${cliInvocation()} init --link --project <ref>\` (see \`${cl
|
|
|
82774
82733
|
return { status: "not_run", release: release2, reason: "functions failed to deploy" };
|
|
82775
82734
|
if (verificationFailed)
|
|
82776
82735
|
return { status: "not_run", release: release2, reason: "the deploy verification did not pass" };
|
|
82777
|
-
return runDeployTests({ client, root: deployStateEntry?.dir ?? targetDir, projectId: result.project_id ?? projectId ?? void 0,
|
|
82736
|
+
return runDeployTests({ client, root: deployStateEntry?.dir ?? targetDir, projectId: result.project_id ?? projectId ?? void 0, json: Boolean(opts.json), release: release2 ?? void 0, renderPending: postLive.kind === "timeout", prepared: prepareDeployTests(() => prepareRunner(deployStateEntry?.dir ?? targetDir)) });
|
|
82778
82737
|
}, "runReleaseTests");
|
|
82779
82738
|
const verificationNextSteps = besideRealLogin ? [
|
|
82780
82739
|
"Inspect the live URL; keep this project and its claim URL.",
|
|
@@ -82937,11 +82896,11 @@ ${dim("Build")}`);
|
|
|
82937
82896
|
info(formatTempExpiry(tempSession.expiresAt, tempSession.ttlSeconds));
|
|
82938
82897
|
const link = teal(tempSession.claimUrl);
|
|
82939
82898
|
if (tempSession.handoffReady) {
|
|
82940
|
-
info(`Open ${link} and select "Save and connect agent" to
|
|
82899
|
+
info(`Open ${link} and select "Save and connect agent" to work on the saved apps and create new ones. You can choose to include your other apps.`);
|
|
82941
82900
|
} else if (besideRealLogin) {
|
|
82942
|
-
info(`Open ${link} to save the
|
|
82901
|
+
info(`Open ${link} to save the app to your account, then run \`${cliInvocation()} init --link --project ${projectId}\` in an unlinked folder to work on it.`);
|
|
82943
82902
|
} else {
|
|
82944
|
-
info(`Open ${link} to save the
|
|
82903
|
+
info(`Open ${link} to save the app to your account, then run \`${cliInvocation()} login\` to connect this terminal.`);
|
|
82945
82904
|
}
|
|
82946
82905
|
}
|
|
82947
82906
|
if (hasFunctionErrors) {
|
|
@@ -83413,7 +83372,7 @@ var init_deploy = __esm({
|
|
|
83413
83372
|
__name(randomSuffix, "randomSuffix");
|
|
83414
83373
|
__name(deriveNewProjectName, "deriveNewProjectName");
|
|
83415
83374
|
__name(formatTempExpiry, "formatTempExpiry");
|
|
83416
|
-
__name(
|
|
83375
|
+
__name(plural2, "plural");
|
|
83417
83376
|
__name(formatElapsed, "formatElapsed");
|
|
83418
83377
|
__name(formatChangeSource, "formatChangeSource");
|
|
83419
83378
|
__name(readString, "readString");
|
|
@@ -87144,6 +87103,7 @@ function registerStatus(program2) {
|
|
|
87144
87103
|
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) => {
|
|
87145
87104
|
const token = getToken();
|
|
87146
87105
|
const client = new ApiClient(token);
|
|
87106
|
+
const claimConnection = Boolean(loadConfig()?.claim_access);
|
|
87147
87107
|
const chosen = chooseProjectRef(projectArg, opts.project);
|
|
87148
87108
|
if (chosen.kind === "conflict") {
|
|
87149
87109
|
error(projectRefConflictMessage(chosen));
|
|
@@ -87167,7 +87127,7 @@ function registerStatus(program2) {
|
|
|
87167
87127
|
try {
|
|
87168
87128
|
const p2 = await client.call("GET", `/projects/${encodeURIComponent(projectId)}`);
|
|
87169
87129
|
projectStatus = p2;
|
|
87170
|
-
const servingUrl = await getProjectServingUrl(client, projectId).catch(() => fallbackProjectServingUrl(p2));
|
|
87130
|
+
const servingUrl = claimConnection ? fallbackProjectServingUrl(p2) : await getProjectServingUrl(client, projectId).catch(() => fallbackProjectServingUrl(p2));
|
|
87171
87131
|
if (!opts.json) {
|
|
87172
87132
|
console.log(`
|
|
87173
87133
|
Project: ${teal(p2.name)} (${statusDot(p2.status)})`);
|
|
@@ -87184,7 +87144,7 @@ function registerStatus(program2) {
|
|
|
87184
87144
|
process.exitCode = 1;
|
|
87185
87145
|
}
|
|
87186
87146
|
try {
|
|
87187
|
-
const deployment = unwrapPlatformData(await callPlatformTool("deploy_status", { project_id: projectId }, { allTools: true }));
|
|
87147
|
+
const deployment = claimConnection ? await client.call("GET", "/deploy/status", void 0, { project_id: projectId }) : unwrapPlatformData(await callPlatformTool("deploy_status", { project_id: projectId }, { allTools: true }));
|
|
87188
87148
|
if (!isRecord(deployment))
|
|
87189
87149
|
throw new Error("deploy_status returned an unexpected response.");
|
|
87190
87150
|
deploymentStatus = deployment;
|
|
@@ -87234,24 +87194,25 @@ function registerStatus(program2) {
|
|
|
87234
87194
|
process.exitCode = 1;
|
|
87235
87195
|
}
|
|
87236
87196
|
}
|
|
87237
|
-
|
|
87238
|
-
|
|
87239
|
-
|
|
87240
|
-
|
|
87241
|
-
|
|
87242
|
-
|
|
87243
|
-
|
|
87244
|
-
|
|
87245
|
-
|
|
87197
|
+
if (!claimConnection)
|
|
87198
|
+
try {
|
|
87199
|
+
const ws2 = await client.call("GET", "/hosted/status");
|
|
87200
|
+
workspaceStatus = ws2;
|
|
87201
|
+
if (!opts.json) {
|
|
87202
|
+
console.log("");
|
|
87203
|
+
const wsStatus = ws2.status === "ready" ? "running" : `${ws2.status} (starting)`;
|
|
87204
|
+
info(`Dev workspace: ${wsStatus} ${dim("\u2014 optional code workspace; your deployed app serves regardless")}`);
|
|
87205
|
+
if (ws2.terminal_url) {
|
|
87206
|
+
info(`Terminal: ${dim(ws2.terminal_url)}`);
|
|
87207
|
+
}
|
|
87246
87208
|
}
|
|
87209
|
+
} catch {
|
|
87247
87210
|
}
|
|
87248
|
-
} catch {
|
|
87249
|
-
}
|
|
87250
87211
|
if (opts.json) {
|
|
87251
87212
|
let appUrl = null;
|
|
87252
87213
|
let appUrlError = null;
|
|
87253
87214
|
try {
|
|
87254
|
-
appUrl = await getAuthoritativeAppUrl(client, projectId);
|
|
87215
|
+
appUrl = claimConnection ? projectStatus && fallbackProjectServingUrl(projectStatus) : await getAuthoritativeAppUrl(client, projectId);
|
|
87255
87216
|
if (!appUrl)
|
|
87256
87217
|
appUrlError = { code: "APP_URL_NOT_REPORTED", message: "The platform reported no https app URL for this project. Deploy it, then run this again." };
|
|
87257
87218
|
} catch (err) {
|
|
@@ -87358,10 +87319,10 @@ var init_open2 = __esm({
|
|
|
87358
87319
|
|
|
87359
87320
|
// dist/commands/claim.js
|
|
87360
87321
|
function registerClaim(program2) {
|
|
87361
|
-
program2.command("claim").description("Print the claim URL
|
|
87322
|
+
program2.command("claim").description("Print the claim URL for this computer's temporary apps").option("--json", "Print { claim_url, expires_at } as JSON").action((opts) => {
|
|
87362
87323
|
const config2 = loadConfig();
|
|
87363
87324
|
if (!config2?.temporary || !config2.claim_url) {
|
|
87364
|
-
const message3 = config2?.token ? `This terminal has no temporary workspace to claim. Run \`${cliInvocation()} projects\` to see the
|
|
87325
|
+
const message3 = config2?.token ? `This terminal has no temporary workspace to claim. Run \`${cliInvocation()} projects\` to see the apps it can access.` : `This terminal has no temporary workspace. If you deployed signed out from another terminal, run \`${cliInvocation()} claim\` there. Run \`${cliInvocation()} deploy\` here to start one.`;
|
|
87365
87326
|
if (opts.json)
|
|
87366
87327
|
printJson({ ok: false, error: config2?.token ? "NOT_TEMPORARY" : "NO_TEMPORARY_WORKSPACE", message: message3 });
|
|
87367
87328
|
else
|
|
@@ -87376,17 +87337,18 @@ function registerClaim(program2) {
|
|
|
87376
87337
|
return;
|
|
87377
87338
|
}
|
|
87378
87339
|
if (expired) {
|
|
87379
|
-
error(`This computer's temporary workspace expired at ${config2.temp_expires_at}
|
|
87340
|
+
error(`This computer's temporary workspace expired at ${config2.temp_expires_at}. Unclaimed apps are gone. Run \`${cliInvocation()} deploy\` to start a new one.`);
|
|
87380
87341
|
process.exit(1);
|
|
87381
87342
|
}
|
|
87382
87343
|
info(`Claim URL: ${teal(config2.claim_url)}`);
|
|
87383
87344
|
if (config2.temp_expires_at)
|
|
87384
87345
|
info(`Expires at: ${config2.temp_expires_at} (UTC)`);
|
|
87385
|
-
info("Open it in a browser and sign in or create an account to keep these
|
|
87346
|
+
info("Open it in a browser and sign in or create an account to keep these apps.");
|
|
87386
87347
|
if (config2.claim_handoff?.handoff_id) {
|
|
87387
|
-
info('Choose "Save and connect agent" to
|
|
87348
|
+
info('Choose "Save and connect agent" to work on the saved apps and create new ones. You can choose to include your other apps.');
|
|
87349
|
+
} else {
|
|
87350
|
+
info(`Run \`${cliInvocation()} login\` to connect this terminal after saving.`);
|
|
87388
87351
|
}
|
|
87389
|
-
info(`Run \`${cliInvocation()} login\` for account access.`);
|
|
87390
87352
|
});
|
|
87391
87353
|
}
|
|
87392
87354
|
var init_claim = __esm({
|
|
@@ -131188,6 +131150,66 @@ var init_reference_check_note = __esm({
|
|
|
131188
131150
|
}
|
|
131189
131151
|
});
|
|
131190
131152
|
|
|
131153
|
+
// dist/lib/test-report.js
|
|
131154
|
+
function describeReport(groups, options2 = {}) {
|
|
131155
|
+
const many = groups.length > 1;
|
|
131156
|
+
const checks = groups.flatMap((group) => group.checks.map((check2) => ({ ...check2, script: many && check2.name !== group.script ? group.script : null })));
|
|
131157
|
+
const note = /* @__PURE__ */ __name((script, extra) => {
|
|
131158
|
+
const parts = [script, extra].filter(Boolean);
|
|
131159
|
+
return parts.length ? ` (${parts.join(", ")})` : "";
|
|
131160
|
+
}, "note");
|
|
131161
|
+
const failed = checks.filter((check2) => !check2.ok && !check2.skipped);
|
|
131162
|
+
const notRun = checks.filter((check2) => check2.skipped === "after-failure");
|
|
131163
|
+
const skipped = checks.filter((check2) => check2.skipped && check2.skipped !== "after-failure");
|
|
131164
|
+
const lines = [
|
|
131165
|
+
...failed.flatMap((check2) => {
|
|
131166
|
+
const name = `FAIL ${check2.name}${note(check2.script)}`;
|
|
131167
|
+
const failure = check2.failure;
|
|
131168
|
+
if (!failure)
|
|
131169
|
+
return [`${name}: ${firstLine(check2.error) || "failed"}`];
|
|
131170
|
+
return [
|
|
131171
|
+
name,
|
|
131172
|
+
` Expected: ${failure.expected}`,
|
|
131173
|
+
` Happened: ${failure.happened}`,
|
|
131174
|
+
` Step: ${failure.step}`,
|
|
131175
|
+
...failure.evidence ? [` Evidence: ${failure.evidence}`] : []
|
|
131176
|
+
];
|
|
131177
|
+
}),
|
|
131178
|
+
...checks.filter((check2) => check2.ok).map((check2) => `PASS ${check2.name}${note(check2.script)}`),
|
|
131179
|
+
...skipped.map((check2) => `SKIPPED ${check2.name}${note(check2.script)}: ${firstLine(check2.error)}`),
|
|
131180
|
+
...notRun.map((check2) => `NOT RUN ${check2.name}${note(check2.script, "after the first failure")}`)
|
|
131181
|
+
];
|
|
131182
|
+
const scripts = plural3(groups.length, "script");
|
|
131183
|
+
if (!checks.length)
|
|
131184
|
+
lines.push(`FAILED: no check ran in ${scripts}: it stopped before its first check (its error is in the script's output).`);
|
|
131185
|
+
else if (failed.length) {
|
|
131186
|
+
const omitted = [skipped.length && `${skipped.length} skipped`, notRun.length && `${notRun.length} not run`].filter(Boolean);
|
|
131187
|
+
lines.push(`FAILED: ${failed.length} of ${plural3(checks.length, "check")} in ${scripts}${omitted.length ? ` (${omitted.join(", ")})` : ""}`);
|
|
131188
|
+
} else if (skipped.length)
|
|
131189
|
+
lines.push(`NOT ALL CHECKED: ${checks.length - skipped.length} passed, ${skipped.length} skipped in ${scripts}. A skipped check proves nothing: ${skipped.map((check2) => `\u201C${check2.name}\u201D (${firstLine(check2.error).replace(/\.$/, "") || "skipped"})`).join("; ")}.`);
|
|
131190
|
+
else
|
|
131191
|
+
lines.push(`PASSED: ${plural3(checks.length, "check")} in ${scripts}`);
|
|
131192
|
+
if (!checks.length)
|
|
131193
|
+
lines.push(`Next: fix the error in the script's output, then run ${TEST_COMMAND} again.`);
|
|
131194
|
+
else if (failed.length)
|
|
131195
|
+
lines.push(`Next: fix what each FAIL line names, run ${DEPLOY_COMMAND}, then ${TEST_COMMAND} --failed to rerun each script that failed.`);
|
|
131196
|
+
const files = [...new Set(groups.map((group) => group.resultFile).filter((file2) => Boolean(file2)))];
|
|
131197
|
+
if (files.length && (failed.length || !checks.length || options2.verbose))
|
|
131198
|
+
lines.push(`Full result: ${files.join(", ")}`);
|
|
131199
|
+
return lines;
|
|
131200
|
+
}
|
|
131201
|
+
var DEPLOY_COMMAND, TEST_COMMAND, firstLine, plural3;
|
|
131202
|
+
var init_test_report = __esm({
|
|
131203
|
+
"dist/lib/test-report.js"() {
|
|
131204
|
+
"use strict";
|
|
131205
|
+
DEPLOY_COMMAND = "npx @somewhere-cloud/cli deploy";
|
|
131206
|
+
TEST_COMMAND = "npx @somewhere-cloud/cli test";
|
|
131207
|
+
firstLine = /* @__PURE__ */ __name((text) => (text ?? "").split("\n").map((line) => line.trim()).find((line) => line && !/^(?:hint:|Usage details:|Platform bug reports:)/i.test(line)) ?? "", "firstLine");
|
|
131208
|
+
plural3 = /* @__PURE__ */ __name((n, word) => `${n} ${word}${n === 1 ? "" : "s"}`, "plural");
|
|
131209
|
+
__name(describeReport, "describeReport");
|
|
131210
|
+
}
|
|
131211
|
+
});
|
|
131212
|
+
|
|
131191
131213
|
// dist/lib/test-scripts.js
|
|
131192
131214
|
import { createRequire as createRequire8 } from "node:module";
|
|
131193
131215
|
import { existsSync as existsSync36, mkdirSync as mkdirSync18, readFileSync as readFileSync40, readdirSync as readdirSync8, rmSync as rmSync14, statSync as statSync8, writeFileSync as writeFileSync24 } from "node:fs";
|
|
@@ -132318,8 +132340,12 @@ Run ${cliInvocation()} <command> --help for full command details.`);
|
|
|
132318
132340
|
program2.enablePositionalOptions();
|
|
132319
132341
|
const skipRecovery = ["lint", "upgrade", "update", "login", "signup", "logout", "docs", "help", "--help", "-h", "--version", "-V"].includes(command);
|
|
132320
132342
|
const recovery = skipRecovery ? { kind: "none" } : await recoverClaimHandoff();
|
|
132321
|
-
if (recovery.kind === "recovered" && recovery.message
|
|
132322
|
-
|
|
132343
|
+
if (recovery.kind === "recovered" && recovery.message) {
|
|
132344
|
+
if (jsonOutputRequested || command === "file")
|
|
132345
|
+
console.error(recovery.message);
|
|
132346
|
+
else
|
|
132347
|
+
info(recovery.message);
|
|
132348
|
+
}
|
|
132323
132349
|
if (recovery.kind === "stale" && recovery.message) {
|
|
132324
132350
|
if (jsonOutputRequested || command === "file")
|
|
132325
132351
|
console.error(recovery.message);
|
|
@@ -132437,7 +132463,6 @@ var init_test_reporter = __esm({
|
|
|
132437
132463
|
init_test_control();
|
|
132438
132464
|
init_test_identities();
|
|
132439
132465
|
init_test_diagnostics();
|
|
132440
|
-
init_test_report();
|
|
132441
132466
|
init_test_timeline();
|
|
132442
132467
|
markProcessStart("playwright");
|
|
132443
132468
|
firstLine2 = /* @__PURE__ */ __name((message3) => message3.replace(/^[^:\n]+:\d+: /, "").split("\n").find((line) => line.trim())?.trim().slice(0, 240) ?? "", "firstLine");
|
|
@@ -132474,11 +132499,11 @@ var init_test_reporter = __esm({
|
|
|
132474
132499
|
return location2 ? describeError({ message: "", location: location2 }).replace(/: $/, "") + ": " + message3 : message3;
|
|
132475
132500
|
}) : result.errors.map((error3) => describeError(error3));
|
|
132476
132501
|
const file2 = relative13(process.cwd(), test2.location.file);
|
|
132477
|
-
const
|
|
132478
|
-
const entry = { ...details, ...
|
|
132502
|
+
const skipReason = result.status === "skipped" ? scrub(result.annotations.find(({ type, description }) => type === "skip" && description)?.description ?? "no reason given").slice(0, 200) : void 0;
|
|
132503
|
+
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: file2, line: test2.location.line };
|
|
132479
132504
|
this.entries.push(entry);
|
|
132480
132505
|
if (process.env.SW_TEST_JSON !== "true") {
|
|
132481
|
-
console.log(
|
|
132506
|
+
console.log(skipReason ? `SKIPPED ${entry.title}: ${skipReason}` : `${result.status}: ${entry.title}`);
|
|
132482
132507
|
for (const note of entry.notes ?? [])
|
|
132483
132508
|
console.log(` note: ${scrub(note)}`);
|
|
132484
132509
|
if (result.status !== "passed" && result.status !== "skipped")
|
|
@@ -132497,7 +132522,6 @@ ${entry.errors.map((error3) => " " + error3.replaceAll("\n", "\n ")).join("\n"
|
|
|
132497
132522
|
async onEnd(result) {
|
|
132498
132523
|
const passed = this.entries.filter((entry) => entry.status === "passed" && entry.outcome === "expected").length;
|
|
132499
132524
|
const skipped = this.entries.filter((entry) => entry.status === "skipped").length;
|
|
132500
|
-
const needsClaim = this.entries.some((entry) => entry.skipReason === TEST_INBOX_CLAIM_REASON);
|
|
132501
132525
|
const expectedFailures = this.entries.filter((entry) => entry.status === "failed" && entry.outcome === "expected").length;
|
|
132502
132526
|
const failed = this.entries.filter((entry) => entry.outcome === "unexpected").length;
|
|
132503
132527
|
const startRelease = process.env.SW_TEST_RELEASE;
|
|
@@ -132565,12 +132589,10 @@ ${entry.errors.map((error3) => " " + error3.replaceAll("\n", "\n ")).join("\n"
|
|
|
132565
132589
|
if (versionLost) {
|
|
132566
132590
|
console.log(preview ? "The preview changed or closed during this run. Save it again with `somewhere preview` (or open a new one if it closed), then run all the tests again: somewhere test --preview" : "The live release changed during this run. Run all the tests again: somewhere test");
|
|
132567
132591
|
}
|
|
132568
|
-
if (needsClaim)
|
|
132569
|
-
console.log(TEST_INBOX_CLAIM_NEXT);
|
|
132570
132592
|
if (skipped)
|
|
132571
|
-
console.log(
|
|
132593
|
+
console.log(`NOT ALL RAN: ${skipped} skipped (each SKIPPED line above says why). A skipped test proves nothing until it runs.`);
|
|
132572
132594
|
}
|
|
132573
|
-
const status = result.status === "passed" && failed === 0 && this.errors === 0 &&
|
|
132595
|
+
const status = result.status === "passed" && failed === 0 && this.errors === 0 && skipped === 0 && passed > 0 ? "passed" : "failed";
|
|
132574
132596
|
if (status === "passed" && passed > 0 && process.env.SW_TEST_JSON !== "true")
|
|
132575
132597
|
console.log("The checks you wrote passed; say which requirements they do not cover.");
|
|
132576
132598
|
return { status };
|
|
@@ -132677,7 +132699,7 @@ async function step(page, name, work, beforeReport) {
|
|
|
132677
132699
|
} catch (error3) {
|
|
132678
132700
|
await beforeReport?.().catch(() => {
|
|
132679
132701
|
});
|
|
132680
|
-
if (error3 instanceof StepError
|
|
132702
|
+
if (error3 instanceof StepError)
|
|
132681
132703
|
throw error3;
|
|
132682
132704
|
const stopped = browserStoppedMessage(page, error3);
|
|
132683
132705
|
if (stopped)
|
|
@@ -132946,7 +132968,6 @@ var secretScreens, FIND_MS, DEFAULT_FORM, pick2, describe3, marks, lastSignInCod
|
|
|
132946
132968
|
var init_form_auth = __esm({
|
|
132947
132969
|
"dist/lib/form-auth.js"() {
|
|
132948
132970
|
"use strict";
|
|
132949
|
-
init_test_control();
|
|
132950
132971
|
init_test_diagnostics();
|
|
132951
132972
|
init_test_timeline();
|
|
132952
132973
|
init_form_accounts();
|
|
@@ -133045,6 +133066,9 @@ function clientOf(who) {
|
|
|
133045
133066
|
return who.request;
|
|
133046
133067
|
return who;
|
|
133047
133068
|
}
|
|
133069
|
+
function splitManifests(changed) {
|
|
133070
|
+
return { app: changed.filter((file2) => !PACKAGE_MANIFESTS.has(file2)), manifests: changed.filter((file2) => PACKAGE_MANIFESTS.has(file2)) };
|
|
133071
|
+
}
|
|
133048
133072
|
function undeployedChanges(root, projectId, preview = false) {
|
|
133049
133073
|
let base;
|
|
133050
133074
|
if (preview) {
|
|
@@ -133117,7 +133141,7 @@ async function dataReady(scope, timeout = 5e3) {
|
|
|
133117
133141
|
});
|
|
133118
133142
|
return await root.locator('[data-sw-data="error"]').count() ? "error" : "ready";
|
|
133119
133143
|
}
|
|
133120
|
-
var AppTest;
|
|
133144
|
+
var PACKAGE_MANIFESTS, AppTest;
|
|
133121
133145
|
var init_app_test = __esm({
|
|
133122
133146
|
"dist/lib/app-test.js"() {
|
|
133123
133147
|
"use strict";
|
|
@@ -133136,6 +133160,8 @@ var init_app_test = __esm({
|
|
|
133136
133160
|
__name(describeCheckFailure, "describeCheckFailure");
|
|
133137
133161
|
__name(pageState, "pageState");
|
|
133138
133162
|
__name(clientOf, "clientOf");
|
|
133163
|
+
PACKAGE_MANIFESTS = /* @__PURE__ */ new Set(["package.json", "package-lock.json", "npm-shrinkwrap.json", "yarn.lock", "pnpm-lock.yaml", "bun.lock", "bun.lockb"]);
|
|
133164
|
+
__name(splitManifests, "splitManifests");
|
|
133139
133165
|
__name(undeployedChanges, "undeployedChanges");
|
|
133140
133166
|
__name(classifyData, "classifyData");
|
|
133141
133167
|
AppTest = class _AppTest {
|
|
@@ -133200,6 +133226,12 @@ var init_app_test = __esm({
|
|
|
133200
133226
|
const target = control.target;
|
|
133201
133227
|
if ((options2.undeployed ?? "refuse") === "refuse") {
|
|
133202
133228
|
const local = undeployedChanges(root, projectId, preview);
|
|
133229
|
+
const { app: changedApp, manifests } = splitManifests(local?.changed ?? []);
|
|
133230
|
+
if (local && manifests.length) {
|
|
133231
|
+
local.changed = changedApp;
|
|
133232
|
+
process.stderr.write(`Note: ${manifests.join(", ")} changed since the last ${preview ? "preview save" : "deploy"}. Installing test tools changes only these, so the tests run; if you changed the app's dependencies, ${preview ? "save the preview" : "deploy"} first.
|
|
133233
|
+
`);
|
|
133234
|
+
}
|
|
133203
133235
|
if (local?.changed.length) {
|
|
133204
133236
|
throw new Error(preview ? `This folder has changes its preview does not have (${local.changed.slice(0, 8).join(", ")}${local.changed.length > 8 ? ", \u2026" : ""}). Save them with \`somewhere preview\`, then run this script.` : `This folder has changes the live release does not have (${local.changed.slice(0, 8).join(", ")}${local.changed.length > 8 ? ", \u2026" : ""}). The last deploy did not publish them (it failed, was refused, or has not run), so testing now would test an old release. Deploy, check that it succeeded, then run this script.`);
|
|
133205
133237
|
}
|
|
@@ -133330,10 +133362,6 @@ var init_app_test = __esm({
|
|
|
133330
133362
|
this.checks.push({ name, ok: true, ms: Math.round(performance.now() - start) });
|
|
133331
133363
|
return true;
|
|
133332
133364
|
} catch (error3) {
|
|
133333
|
-
if (error3 instanceof TestInboxNeedsClaim) {
|
|
133334
|
-
this.checks.push({ name, ok: false, ms: 0, skipped: "needs-claim", error: error3.message });
|
|
133335
|
-
return false;
|
|
133336
|
-
}
|
|
133337
133365
|
await this.rememberPageSecrets();
|
|
133338
133366
|
const pages = await Promise.all([...this.host.pages].map(pageState));
|
|
133339
133367
|
const stopped = [...this.host.pages].map((page) => browserStoppedMessage(page, error3)).find(Boolean);
|
|
@@ -133347,7 +133375,7 @@ page ${i + 1}: ${state}`).join("");
|
|
|
133347
133375
|
}
|
|
133348
133376
|
}
|
|
133349
133377
|
/** Confirm the release did not change, delete this script's sign-up accounts by exact id, write
|
|
133350
|
-
* the result once, print one summary, and set a non-zero exit code if anything failed. */
|
|
133378
|
+
* the result once, print one summary, and set a non-zero exit code if anything failed or was skipped. */
|
|
133351
133379
|
async finish() {
|
|
133352
133380
|
if (this.finished)
|
|
133353
133381
|
throw new Error("finish() already ran");
|
|
@@ -133430,7 +133458,7 @@ page ${i + 1}: ${state}`).join("");
|
|
|
133430
133458
|
if (live !== this.release) {
|
|
133431
133459
|
process.stdout.write(preview ? "The preview changed or closed during this script. Save it again with `somewhere preview` (or open a new one if it closed), then run the whole script again.\n" : "The live release changed during this script. Run the whole script again.\n");
|
|
133432
133460
|
}
|
|
133433
|
-
if (failed || !this.checks.length)
|
|
133461
|
+
if (failed || !this.checks.length || this.checks.some((check2) => check2.skipped))
|
|
133434
133462
|
process.exitCode = 1;
|
|
133435
133463
|
return { passed, failed, file: this.resultsPath };
|
|
133436
133464
|
}
|
|
@@ -133522,15 +133550,6 @@ function runner() {
|
|
|
133522
133550
|
} catch {
|
|
133523
133551
|
throw new Error("Install project test dependencies: npm install -D @playwright/test @somewhere-cloud/cli");
|
|
133524
133552
|
}
|
|
133525
|
-
const withInboxSkip = /* @__PURE__ */ __name(async (work) => {
|
|
133526
|
-
try {
|
|
133527
|
-
return await work();
|
|
133528
|
-
} catch (error3) {
|
|
133529
|
-
if (error3 instanceof TestInboxNeedsClaim)
|
|
133530
|
-
pw.test.skip(true, error3.message);
|
|
133531
|
-
throw error3;
|
|
133532
|
-
}
|
|
133533
|
-
}, "withInboxSkip");
|
|
133534
133553
|
const test2 = pw.test.extend({
|
|
133535
133554
|
_preview: [async ({}, use) => {
|
|
133536
133555
|
const control = await previewControlForWorker();
|
|
@@ -133712,13 +133731,13 @@ function runner() {
|
|
|
133712
133731
|
}
|
|
133713
133732
|
}, "_forms"),
|
|
133714
133733
|
signUp: /* @__PURE__ */ __name(async ({ _forms }, use, info2) => {
|
|
133715
|
-
await use((page, options2) => span("signUp", { test: titled(info2.project.name, info2.title) }, () =>
|
|
133734
|
+
await use((page, options2) => span("signUp", { test: titled(info2.project.name, info2.title) }, () => signUp(_forms, page, options2 ?? {})));
|
|
133716
133735
|
}, "signUp"),
|
|
133717
133736
|
verify: /* @__PURE__ */ __name(async ({ _forms }, use, info2) => {
|
|
133718
|
-
await use((page, person) => span("verify", { test: titled(info2.project.name, info2.title) }, () =>
|
|
133737
|
+
await use((page, person) => span("verify", { test: titled(info2.project.name, info2.title) }, () => verify(_forms, page, person)));
|
|
133719
133738
|
}, "verify"),
|
|
133720
133739
|
signIn: /* @__PURE__ */ __name(async ({ _forms }, use, info2) => {
|
|
133721
|
-
await use((page, person, options2) => span("signIn", { test: titled(info2.project.name, info2.title) }, () =>
|
|
133740
|
+
await use((page, person, options2) => span("signIn", { test: titled(info2.project.name, info2.title) }, () => signIn(_forms, page, person, options2 ?? {})));
|
|
133722
133741
|
}, "signIn"),
|
|
133723
133742
|
signOut: /* @__PURE__ */ __name(async ({ _forms }, use, info2) => {
|
|
133724
133743
|
await use((page, options2) => span("signOut", { test: titled(info2.project.name, info2.title) }, () => signOut(_forms, page, options2 ?? {})));
|