@somewhere-cloud/cli 0.38.154 → 0.38.155
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/docs/adopt.md +39 -0
- package/dist/docs/analytics.md +161 -0
- package/dist/docs/api-reference.md +339 -0
- package/dist/docs/api-surface.md +2067 -0
- package/dist/docs/app-mcp.md +162 -0
- package/dist/docs/architecture-patterns.md +334 -0
- package/dist/docs/auth-client.md +531 -0
- package/dist/docs/billing.md +76 -0
- package/dist/docs/browser.md +639 -0
- package/dist/docs/calendar.md +298 -0
- package/dist/docs/changes.md +323 -0
- package/dist/docs/cli.md +407 -0
- package/dist/docs/common-mistakes.md +199 -0
- package/dist/docs/connect-agent.md +72 -0
- package/dist/docs/cors.md +114 -0
- package/dist/docs/cron.md +167 -0
- package/dist/docs/database-engine.md +167 -0
- package/dist/docs/declared-data.md +1656 -0
- package/dist/docs/declared-files.md +475 -0
- package/dist/docs/deploy-intelligence.md +188 -0
- package/dist/docs/deploy.md +733 -0
- package/dist/docs/design-system.md +273 -0
- package/dist/docs/dev-environments.md +496 -0
- package/dist/docs/domain-ownership.md +31 -0
- package/dist/docs/domains.md +370 -0
- package/dist/docs/feedback.md +88 -0
- package/dist/docs/file-tools.md +116 -0
- package/dist/docs/functions.md +489 -0
- package/dist/docs/getting-started.md +238 -0
- package/dist/docs/github.md +95 -0
- package/dist/docs/google-calendar.md +212 -0
- package/dist/docs/groups.md +836 -0
- package/dist/docs/guarantees.md +58 -0
- package/dist/docs/handled-for-you.md +224 -0
- package/dist/docs/inspect.md +171 -0
- package/dist/docs/limits.md +68 -0
- package/dist/docs/live-data.md +197 -0
- package/dist/docs/live.md +92 -0
- package/dist/docs/local-dev.md +30 -0
- package/dist/docs/migration-supabase.md +58 -0
- package/dist/docs/payments.md +1102 -0
- package/dist/docs/portability.md +194 -0
- package/dist/docs/postgres.md +301 -0
- package/dist/docs/pricing-comparison.md +42 -0
- package/dist/docs/pricing.md +39 -0
- package/dist/docs/project-groups.md +107 -0
- package/dist/docs/projects.md +380 -0
- package/dist/docs/recipe-ai-agent.md +112 -0
- package/dist/docs/recipe-ai-features.md +227 -0
- package/dist/docs/recipe-ai-receipts.md +783 -0
- package/dist/docs/recipe-background-jobs.md +369 -0
- package/dist/docs/recipe-booking.md +348 -0
- package/dist/docs/recipe-csv-import.md +390 -0
- package/dist/docs/recipe-ecommerce.md +127 -0
- package/dist/docs/recipe-email.md +282 -0
- package/dist/docs/recipe-escalation.md +133 -0
- package/dist/docs/recipe-file-uploads.md +159 -0
- package/dist/docs/recipe-import-app.md +110 -0
- package/dist/docs/recipe-login.md +457 -0
- package/dist/docs/recipe-multi-chat.md +198 -0
- package/dist/docs/recipe-paid-api.md +161 -0
- package/dist/docs/recipe-pdfs.md +205 -0
- package/dist/docs/recipe-push-notifications.md +107 -0
- package/dist/docs/recipe-seo.md +200 -0
- package/dist/docs/recipe-signed-in-app.md +330 -0
- package/dist/docs/render.md +99 -0
- package/dist/docs/rooms.md +554 -0
- package/dist/docs/sdk.md +287 -0
- package/dist/docs/sdks.md +24 -0
- package/dist/docs/search.md +199 -0
- package/dist/docs/security-model.md +168 -0
- package/dist/docs/setup.md +212 -0
- package/dist/docs/smoke.md +102 -0
- package/dist/docs/speed.md +298 -0
- package/dist/docs/sql-compatibility.md +96 -0
- package/dist/docs/sw.agent.md +248 -0
- package/dist/docs/sw.ai.md +1291 -0
- package/dist/docs/sw.auth.md +1811 -0
- package/dist/docs/sw.billing.md +171 -0
- package/dist/docs/sw.db.md +2128 -0
- package/dist/docs/sw.email.md +661 -0
- package/dist/docs/sw.endpoint.md +187 -0
- package/dist/docs/sw.env.md +303 -0
- package/dist/docs/sw.fetch.md +115 -0
- package/dist/docs/sw.fs.md +424 -0
- package/dist/docs/sw.groups.md +836 -0
- package/dist/docs/sw.image.md +69 -0
- package/dist/docs/sw.jobs.md +520 -0
- package/dist/docs/sw.logs.md +61 -0
- package/dist/docs/sw.mail.md +106 -0
- package/dist/docs/sw.notifications.md +78 -0
- package/dist/docs/sw.push.md +161 -0
- package/dist/docs/sw.rateLimit.md +67 -0
- package/dist/docs/sw.web.md +128 -0
- package/dist/docs/tasks.md +269 -0
- package/dist/docs/test.md +220 -0
- package/dist/docs/tool-reference-account.md +7 -0
- package/dist/docs/tool-reference-ai.md +121 -0
- package/dist/docs/tool-reference-analytics.md +37 -0
- package/dist/docs/tool-reference-api.md +19 -0
- package/dist/docs/tool-reference-artifacts.md +35 -0
- package/dist/docs/tool-reference-auth.md +163 -0
- package/dist/docs/tool-reference-browser.md +114 -0
- package/dist/docs/tool-reference-code.md +26 -0
- package/dist/docs/tool-reference-connect.md +21 -0
- package/dist/docs/tool-reference-cron.md +48 -0
- package/dist/docs/tool-reference-db.md +282 -0
- package/dist/docs/tool-reference-domains.md +107 -0
- package/dist/docs/tool-reference-email.md +55 -0
- package/dist/docs/tool-reference-env.md +19 -0
- package/dist/docs/tool-reference-feedback.md +56 -0
- package/dist/docs/tool-reference-fs.md +265 -0
- package/dist/docs/tool-reference-github.md +57 -0
- package/dist/docs/tool-reference-groups.md +85 -0
- package/dist/docs/tool-reference-help.md +29 -0
- package/dist/docs/tool-reference-jobs.md +39 -0
- package/dist/docs/tool-reference-live.md +48 -0
- package/dist/docs/tool-reference-logs.md +16 -0
- package/dist/docs/tool-reference-payments.md +44 -0
- package/dist/docs/tool-reference-project.md +706 -0
- package/dist/docs/tool-reference-push.md +78 -0
- package/dist/docs/tool-reference-rate-limit.md +18 -0
- package/dist/docs/tool-reference-search.md +68 -0
- package/dist/docs/tool-reference-security.md +42 -0
- package/dist/docs/tool-reference-smoke.md +17 -0
- package/dist/docs/tool-reference-stock-photos.md +20 -0
- package/dist/docs/tool-reference-tasks.md +73 -0
- package/dist/docs/tool-reference-telegram.md +32 -0
- package/dist/docs/tool-reference-usage.md +9 -0
- package/dist/docs/tool-reference-web.md +71 -0
- package/dist/docs/tool-reference-webhooks.md +9 -0
- package/dist/docs/troubleshooting.md +411 -0
- package/dist/docs/typed-functions.md +94 -0
- package/dist/docs/verify-before-deploy.md +67 -0
- package/dist/docs/vs-supabase.md +75 -0
- package/dist/docs/vs-vercel.md +103 -0
- package/dist/lib/bundle.js +303 -221
- package/dist/lib/bundle.js.map +3 -3
- package/dist/types/lib/test-session.d.ts +8 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +3 -2
package/dist/lib/bundle.js
CHANGED
|
@@ -44184,6 +44184,7 @@ Use \`somewhere docs <topic> --section <id>\` for one section or \`--full\` for
|
|
|
44184
44184
|
INIT_AGENTS_MD = `# somewhere.cloud project contract
|
|
44185
44185
|
${AGENT_WORKFLOW}
|
|
44186
44186
|
${SKILLS_POINTER}
|
|
44187
|
+
Search the installed topic Markdown in \`node_modules/@somewhere-cloud/cli/dist/docs/\`.
|
|
44187
44188
|
Without a global CLI, use \`npx @somewhere-cloud/cli deploy\` and \`npx @somewhere-cloud/cli test\`.
|
|
44188
44189
|
|
|
44189
44190
|
For Node or Playwright tests, see [Testing your app](https://somewhere.cloud/docs/test).
|
|
@@ -44236,11 +44237,15 @@ try {
|
|
|
44236
44237
|
});
|
|
44237
44238
|
|
|
44238
44239
|
// dist/lib/typecheck-version.js
|
|
44239
|
-
|
|
44240
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
44241
|
+
var require3, checkerContract, TYPECHECK_TYPESCRIPT_VERSION;
|
|
44240
44242
|
var init_typecheck_version = __esm({
|
|
44241
44243
|
"dist/lib/typecheck-version.js"() {
|
|
44242
44244
|
"use strict";
|
|
44243
|
-
|
|
44245
|
+
init_package_root();
|
|
44246
|
+
require3 = createRequire2(CLI_PACKAGE_ROOT);
|
|
44247
|
+
({ checkerContract } = require3("./runtime/declared-data.cjs"));
|
|
44248
|
+
TYPECHECK_TYPESCRIPT_VERSION = checkerContract.TYPESCRIPT_VERSION;
|
|
44244
44249
|
}
|
|
44245
44250
|
});
|
|
44246
44251
|
|
|
@@ -52595,7 +52600,16 @@ function registerProject(program2) {
|
|
|
52595
52600
|
process.exit(1);
|
|
52596
52601
|
}
|
|
52597
52602
|
});
|
|
52598
|
-
proj.command("delete <name-or-id>").description("Permanently delete a project and all its data").option("--confirm-code <code>", "Confirm deletion
|
|
52603
|
+
proj.command("delete <name-or-id>").description("Permanently delete a project and all its data").option("--confirm-code <code>", "Confirm deletion using the confirm_code returned by the first call").option("--json", "Print the deletion result as JSON").addOption(new Option("--yes").hideHelp()).addOption(new Option("--force").hideHelp()).action(async (nameOrId, opts) => {
|
|
52604
|
+
const unsupported = opts.yes ? "--yes" : opts.force ? "--force" : void 0;
|
|
52605
|
+
if (unsupported) {
|
|
52606
|
+
const message3 = `Unknown option '${unsupported}'. Run ${cliInvocation()} project delete <name-or-id> to get a code, then repeat with --confirm-code <code>.`;
|
|
52607
|
+
if (opts.json)
|
|
52608
|
+
printJsonError("UNKNOWN_OPTION", message3);
|
|
52609
|
+
else
|
|
52610
|
+
error(message3);
|
|
52611
|
+
process.exit(1);
|
|
52612
|
+
}
|
|
52599
52613
|
const client = new ApiClient(getToken());
|
|
52600
52614
|
const promptStdout = opts.json ? process.stderr : void 0;
|
|
52601
52615
|
let project;
|
|
@@ -52626,7 +52640,7 @@ function registerProject(program2) {
|
|
|
52626
52640
|
if (opts.json) {
|
|
52627
52641
|
printJson({
|
|
52628
52642
|
status: "needs_confirmation",
|
|
52629
|
-
|
|
52643
|
+
confirm_code: code,
|
|
52630
52644
|
confirm_command: confirmCommand
|
|
52631
52645
|
});
|
|
52632
52646
|
} else {
|
|
@@ -73980,7 +73994,7 @@ var init_privacy = __esm({
|
|
|
73980
73994
|
|
|
73981
73995
|
// dist/lib/role-method-hints.js
|
|
73982
73996
|
import { existsSync as existsSync9, readdirSync as readdirSync2, readFileSync as readFileSync10 } from "node:fs";
|
|
73983
|
-
import { createRequire as
|
|
73997
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
73984
73998
|
import { join as join9, relative as relative2, resolve as resolve4 } from "node:path";
|
|
73985
73999
|
function roleMethodHints(projectDir, { removedOnly = false } = {}) {
|
|
73986
74000
|
const api = join9(projectDir, "api");
|
|
@@ -73989,7 +74003,7 @@ function roleMethodHints(projectDir, { removedOnly = false } = {}) {
|
|
|
73989
74003
|
const skipped = ["Role-method hints skipped: TypeScript is unavailable in this project."];
|
|
73990
74004
|
let ts2;
|
|
73991
74005
|
try {
|
|
73992
|
-
const projectRequire =
|
|
74006
|
+
const projectRequire = createRequire3(resolve4(projectDir, "package.json"));
|
|
73993
74007
|
ts2 = projectRequire("typescript");
|
|
73994
74008
|
} catch {
|
|
73995
74009
|
return skipped;
|
|
@@ -74305,7 +74319,7 @@ __export(declared_data_exports, {
|
|
|
74305
74319
|
prepareDeclaredData: () => prepareDeclaredData
|
|
74306
74320
|
});
|
|
74307
74321
|
import { existsSync as existsSync11, readFileSync as readFileSync13, rmSync as rmSync2, writeFileSync as writeFileSync9 } from "node:fs";
|
|
74308
|
-
import { createRequire as
|
|
74322
|
+
import { createRequire as createRequire4 } from "node:module";
|
|
74309
74323
|
import { join as join12, resolve as resolve5 } from "node:path";
|
|
74310
74324
|
function generatedContents(path3) {
|
|
74311
74325
|
const previous = existsSync11(path3) ? readFileSync13(path3, "utf8") : void 0;
|
|
@@ -74326,7 +74340,7 @@ function prepareDeclaredData(projectDir) {
|
|
|
74326
74340
|
rmSync2(filesPath);
|
|
74327
74341
|
if (previous !== void 0 && !previous.startsWith(GENERATED_DATA_HEADER))
|
|
74328
74342
|
return void 0;
|
|
74329
|
-
const generator2 =
|
|
74343
|
+
const generator2 = require4("./runtime/declared-data.cjs");
|
|
74330
74344
|
const declaration2 = GENERATED_DATA_HEADER + NO_SCHEMA_NOTE + generator2.RUNTIME_CONTEXT_DECLARATION + generator2.ENDPOINT_DECLARATION + SW_ENDPOINT_GLOBAL;
|
|
74331
74345
|
if (declaration2 !== previous)
|
|
74332
74346
|
writeFileSync9(declarationPath, declaration2);
|
|
@@ -74339,7 +74353,7 @@ function prepareDeclaredData(projectDir) {
|
|
|
74339
74353
|
let tables;
|
|
74340
74354
|
let runtimeDeclaration;
|
|
74341
74355
|
let filesDeclaration;
|
|
74342
|
-
const generator =
|
|
74356
|
+
const generator = require4("./runtime/declared-data.cjs");
|
|
74343
74357
|
try {
|
|
74344
74358
|
const files = { "db/schema.ts": readFileSync13(schemaPath, "utf8") };
|
|
74345
74359
|
client = generator.generateFromFiles(files);
|
|
@@ -74418,7 +74432,7 @@ function declaredDataPlugin(projectDir) {
|
|
|
74418
74432
|
}
|
|
74419
74433
|
};
|
|
74420
74434
|
}
|
|
74421
|
-
var DATA_MODULE, DATA_VIRTUAL_ID, DATA_DECLARATION_FILE, GENERATED_DATA_HEADER, NO_SCHEMA_NOTE, SW_ENDPOINT_GLOBAL,
|
|
74435
|
+
var DATA_MODULE, DATA_VIRTUAL_ID, DATA_DECLARATION_FILE, GENERATED_DATA_HEADER, NO_SCHEMA_NOTE, SW_ENDPOINT_GLOBAL, require4, FILES_DECLARATION_FILE;
|
|
74422
74436
|
var init_declared_data = __esm({
|
|
74423
74437
|
"dist/lib/declared-data.js"() {
|
|
74424
74438
|
"use strict";
|
|
@@ -74439,8 +74453,8 @@ var init_declared_data = __esm({
|
|
|
74439
74453
|
): (req: Request, sw: SomewhereRuntimeContext) => Promise<Response>;
|
|
74440
74454
|
};
|
|
74441
74455
|
`;
|
|
74442
|
-
|
|
74443
|
-
FILES_DECLARATION_FILE =
|
|
74456
|
+
require4 = createRequire4(CLI_PACKAGE_ROOT);
|
|
74457
|
+
FILES_DECLARATION_FILE = require4("./runtime/declared-data.cjs").FILES_DECLARATION_FILE;
|
|
74444
74458
|
__name(generatedContents, "generatedContents");
|
|
74445
74459
|
__name(prepareDeclaredData, "prepareDeclaredData");
|
|
74446
74460
|
__name(declaredDataPlugin, "declaredDataPlugin");
|
|
@@ -77183,7 +77197,7 @@ var init_files = __esm({
|
|
|
77183
77197
|
// dist/lib/deploy-check.js
|
|
77184
77198
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
77185
77199
|
import { existsSync as existsSync14, mkdirSync as mkdirSync8, readFileSync as readFileSync16, realpathSync as realpathSync2, rmSync as rmSync4, writeFileSync as writeFileSync11 } from "node:fs";
|
|
77186
|
-
import { createRequire as
|
|
77200
|
+
import { createRequire as createRequire5 } from "node:module";
|
|
77187
77201
|
import { isAbsolute as isAbsolute3, join as join17, relative as relative7, resolve as resolve8 } from "node:path";
|
|
77188
77202
|
function projectTypeScriptVersion(projectDir) {
|
|
77189
77203
|
try {
|
|
@@ -77349,17 +77363,18 @@ async function startDeployCheck(projectDir, onFetch) {
|
|
|
77349
77363
|
}
|
|
77350
77364
|
return { ok: findings.length === 0, findings, typescript, checkedFiles: checked.length };
|
|
77351
77365
|
}
|
|
77352
|
-
var
|
|
77366
|
+
var require5, vendor2, contract, DEPLOY_CHECK_TYPESCRIPT_VERSION, DIAGNOSTIC, GLOBAL_ERROR, pendingCleanups;
|
|
77353
77367
|
var init_deploy_check = __esm({
|
|
77354
77368
|
"dist/lib/deploy-check.js"() {
|
|
77355
77369
|
"use strict";
|
|
77356
77370
|
init_package_root();
|
|
77371
|
+
init_typecheck_version();
|
|
77357
77372
|
init_files();
|
|
77358
77373
|
init_typecheck();
|
|
77359
|
-
|
|
77360
|
-
vendor2 =
|
|
77374
|
+
require5 = createRequire5(CLI_PACKAGE_ROOT);
|
|
77375
|
+
vendor2 = require5("./runtime/declared-data.cjs");
|
|
77361
77376
|
contract = vendor2.checkerContract;
|
|
77362
|
-
DEPLOY_CHECK_TYPESCRIPT_VERSION =
|
|
77377
|
+
DEPLOY_CHECK_TYPESCRIPT_VERSION = TYPECHECK_TYPESCRIPT_VERSION;
|
|
77363
77378
|
__name(projectTypeScriptVersion, "projectTypeScriptVersion");
|
|
77364
77379
|
__name(announceDeployCheckFetch, "announceDeployCheckFetch");
|
|
77365
77380
|
__name(deployCheckTsc, "deployCheckTsc");
|
|
@@ -77754,14 +77769,14 @@ var source_lint_exports = {};
|
|
|
77754
77769
|
__export(source_lint_exports, {
|
|
77755
77770
|
lintProject: () => lintProject
|
|
77756
77771
|
});
|
|
77757
|
-
import { createRequire as
|
|
77772
|
+
import { createRequire as createRequire6 } from "node:module";
|
|
77758
77773
|
import { performance as performance2 } from "node:perf_hooks";
|
|
77759
77774
|
async function lintProject(directory2, options2 = {}) {
|
|
77760
77775
|
const started = performance2.now();
|
|
77761
77776
|
const contract2 = platformContractVerdict(options2.apiBase ?? API_BASE_URL);
|
|
77762
77777
|
const collected = collectFiles(directory2, { readBinary: false });
|
|
77763
|
-
const
|
|
77764
|
-
const vendor3 =
|
|
77778
|
+
const require6 = createRequire6(CLI_PACKAGE_ROOT);
|
|
77779
|
+
const vendor3 = require6("./runtime/source-lint.cjs");
|
|
77765
77780
|
const report2 = await vendor3.lintSourceSnapshot(collected.files, collected.functions);
|
|
77766
77781
|
const generic = options2.generic ? genericLint(directory2) : { status: "not-requested", findings: [] };
|
|
77767
77782
|
return {
|
|
@@ -79750,7 +79765,7 @@ var init_test_connectivity = __esm({
|
|
|
79750
79765
|
});
|
|
79751
79766
|
|
|
79752
79767
|
// dist/lib/test-run.js
|
|
79753
|
-
import { createRequire as
|
|
79768
|
+
import { createRequire as createRequire7 } from "node:module";
|
|
79754
79769
|
import { pathToFileURL } from "node:url";
|
|
79755
79770
|
import { join as join29, dirname as dirname9 } from "node:path";
|
|
79756
79771
|
import { spawn as spawn4, spawnSync as spawnSync3 } from "node:child_process";
|
|
@@ -79769,12 +79784,12 @@ function testDependencyError(root) {
|
|
|
79769
79784
|
return new Error(missingProjectDependencies(root).includes("@playwright/test") ? INSTALL_PROJECT_DEPENDENCIES : "Install project test dependencies: npm install -D @playwright/test @somewhere-cloud/cli");
|
|
79770
79785
|
}
|
|
79771
79786
|
async function prepareRunner(root) {
|
|
79772
|
-
const
|
|
79787
|
+
const require6 = createRequire7(join29(root, "package.json"));
|
|
79773
79788
|
let cli;
|
|
79774
79789
|
let pw;
|
|
79775
79790
|
try {
|
|
79776
|
-
cli =
|
|
79777
|
-
pw =
|
|
79791
|
+
cli = require6.resolve("@playwright/test/cli");
|
|
79792
|
+
pw = require6("@playwright/test");
|
|
79778
79793
|
} catch {
|
|
79779
79794
|
throw testDependencyError(root);
|
|
79780
79795
|
}
|
|
@@ -87705,6 +87720,8 @@ __export(docs_exports, {
|
|
|
87705
87720
|
searchPublicDocs: () => searchPublicDocs,
|
|
87706
87721
|
writeResponseBodyToStdout: () => writeResponseBodyToStdout
|
|
87707
87722
|
});
|
|
87723
|
+
import { existsSync as existsSync33 } from "node:fs";
|
|
87724
|
+
import { join as join38 } from "node:path";
|
|
87708
87725
|
import { once } from "node:events";
|
|
87709
87726
|
function closestMatches(wanted, candidates) {
|
|
87710
87727
|
const query = wanted.trim().toLowerCase();
|
|
@@ -88018,6 +88035,21 @@ async function writeResponseBodyToStdout(res) {
|
|
|
88018
88035
|
reader.releaseLock();
|
|
88019
88036
|
}
|
|
88020
88037
|
}
|
|
88038
|
+
function bundledDocsPath(topic) {
|
|
88039
|
+
if (topic !== void 0 && !/^[a-z0-9][a-z0-9.-]*$/i.test(topic))
|
|
88040
|
+
return void 0;
|
|
88041
|
+
const path3 = topic === void 0 ? BUNDLED_DOCS_DIR : join38(BUNDLED_DOCS_DIR, topic + ".md");
|
|
88042
|
+
return existsSync33(path3) ? path3 : void 0;
|
|
88043
|
+
}
|
|
88044
|
+
function printDocsHint(topic, view, complete) {
|
|
88045
|
+
const path3 = bundledDocsPath(topic) ?? bundledDocsPath();
|
|
88046
|
+
if (view === "summary" && complete === false) {
|
|
88047
|
+
const read = `Run ${cliInvocation()} docs ${commandArg(topic)} --full for the whole topic or --section <id> for one section.`;
|
|
88048
|
+
console.error(path3 ? `${read} Search installed Markdown in ${path3}.` : read);
|
|
88049
|
+
} else if (path3) {
|
|
88050
|
+
console.error(`Search installed Markdown in ${path3}.`);
|
|
88051
|
+
}
|
|
88052
|
+
}
|
|
88021
88053
|
function registerDocs(program2) {
|
|
88022
88054
|
program2.command("docs [topic] [terms...]").description(`Read platform docs. No login needed \u2014 every topic is public. With no topic, prints the topic index. Search with \`${cliInvocation()} docs <topic> <term>\` or \`${cliInvocation()} docs search <term>\`. Quick topics: ` + Object.keys(TOPICS).join(", ") + `. Example manual topic: \`${cliInvocation()} docs sw.db\`.`).option("--list", `List available topics (the same index bare \`${cliInvocation()} docs\` prints)`).option("--full", "Print the complete topic instead of its summary; with no topic, the full manual").option("--section <id>", "Print one section of a topic (ids are listed in the summary)").option("--json", "Print the selected document in a JSON envelope").addHelpText("after", `
|
|
88023
88055
|
Examples:
|
|
@@ -88097,6 +88129,9 @@ Examples:
|
|
|
88097
88129
|
return;
|
|
88098
88130
|
}
|
|
88099
88131
|
process.stdout.write(renderDocsIndex(pages, groups));
|
|
88132
|
+
const docs = bundledDocsPath();
|
|
88133
|
+
if (docs)
|
|
88134
|
+
console.log("\nSearch installed Markdown in " + docs + ".");
|
|
88100
88135
|
console.log(`
|
|
88101
88136
|
${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
|
|
88102
88137
|
} catch (e) {
|
|
@@ -88134,8 +88169,11 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
|
|
|
88134
88169
|
}
|
|
88135
88170
|
if (opts.json)
|
|
88136
88171
|
printJson({ topic: requestedTopic, ...status, content });
|
|
88137
|
-
else
|
|
88172
|
+
else {
|
|
88138
88173
|
process.stdout.write(withNewline(content));
|
|
88174
|
+
if (view.kind === "default")
|
|
88175
|
+
printDocsHint(resolvedTopic, status.view, status.complete);
|
|
88176
|
+
}
|
|
88139
88177
|
return;
|
|
88140
88178
|
} catch (e) {
|
|
88141
88179
|
authenticatedFailure = e instanceof Error ? e.message : String(e);
|
|
@@ -88160,6 +88198,8 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
|
|
|
88160
88198
|
});
|
|
88161
88199
|
} else {
|
|
88162
88200
|
process.stdout.write(rendered.content);
|
|
88201
|
+
if (view.kind === "default")
|
|
88202
|
+
printDocsHint(page.id, rendered.view, rendered.complete);
|
|
88163
88203
|
}
|
|
88164
88204
|
return;
|
|
88165
88205
|
}
|
|
@@ -88194,16 +88234,19 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
|
|
|
88194
88234
|
return;
|
|
88195
88235
|
}
|
|
88196
88236
|
await writeResponseBodyToStdout(res);
|
|
88237
|
+
if (view.kind === "default")
|
|
88238
|
+
printDocsHint(key ?? requestedTopic);
|
|
88197
88239
|
} catch (e) {
|
|
88198
88240
|
error(`Could not reach ${DOCS_BASE2} \u2014 check your connection. (${e instanceof Error ? e.message : String(e)})`, e);
|
|
88199
88241
|
process.exit(1);
|
|
88200
88242
|
}
|
|
88201
88243
|
});
|
|
88202
88244
|
}
|
|
88203
|
-
var DOCS_BASE2, TOPICS, ALIASES, PUBLIC_MANIFEST_PATH, DOCS_SECTION_MAX_CHARS, DOCS_SEARCH_LIMIT, SNIPPET_RADIUS;
|
|
88245
|
+
var DOCS_BASE2, TOPICS, ALIASES, PUBLIC_MANIFEST_PATH, DOCS_SECTION_MAX_CHARS, DOCS_SEARCH_LIMIT, SNIPPET_RADIUS, BUNDLED_DOCS_DIR;
|
|
88204
88246
|
var init_docs = __esm({
|
|
88205
88247
|
"dist/commands/docs.js"() {
|
|
88206
88248
|
"use strict";
|
|
88249
|
+
init_package_root();
|
|
88207
88250
|
init_cli_invocation();
|
|
88208
88251
|
init_http();
|
|
88209
88252
|
init_config();
|
|
@@ -88271,6 +88314,9 @@ var init_docs = __esm({
|
|
|
88271
88314
|
__name(warnIfDocsNewerThanCli, "warnIfDocsNewerThanCli");
|
|
88272
88315
|
__name(renderPublicPage, "renderPublicPage");
|
|
88273
88316
|
__name(writeResponseBodyToStdout, "writeResponseBodyToStdout");
|
|
88317
|
+
BUNDLED_DOCS_DIR = join38(CLI_PACKAGE_ROOT, "dist", "docs");
|
|
88318
|
+
__name(bundledDocsPath, "bundledDocsPath");
|
|
88319
|
+
__name(printDocsHint, "printDocsHint");
|
|
88274
88320
|
__name(registerDocs, "registerDocs");
|
|
88275
88321
|
}
|
|
88276
88322
|
});
|
|
@@ -88827,7 +88873,7 @@ var init_envfile_write = __esm({
|
|
|
88827
88873
|
});
|
|
88828
88874
|
|
|
88829
88875
|
// dist/commands/env.js
|
|
88830
|
-
import { existsSync as
|
|
88876
|
+
import { existsSync as existsSync34, readFileSync as readFileSync35, writeFileSync as writeFileSync23 } from "node:fs";
|
|
88831
88877
|
import { resolve as resolve19 } from "node:path";
|
|
88832
88878
|
function resolveProjectId(explicit) {
|
|
88833
88879
|
if (explicit)
|
|
@@ -88892,11 +88938,11 @@ function registerEnv(program2) {
|
|
|
88892
88938
|
return;
|
|
88893
88939
|
}
|
|
88894
88940
|
const outPath = resolve19(process.cwd(), String(opts.out));
|
|
88895
|
-
if (
|
|
88941
|
+
if (existsSync34(outPath) && !opts.force && opts.json) {
|
|
88896
88942
|
error(`${opts.out} exists. Pass --force to overwrite in --json mode.`);
|
|
88897
88943
|
process.exit(1);
|
|
88898
88944
|
}
|
|
88899
|
-
if (
|
|
88945
|
+
if (existsSync34(outPath) && !opts.force) {
|
|
88900
88946
|
const existing = readFileSync35(outPath, "utf-8");
|
|
88901
88947
|
const hasValues = existing.split("\n").some((l) => /^[^#=]+=.+/.test(l.trim()));
|
|
88902
88948
|
const { ok } = await (0, import_prompts9.default)({
|
|
@@ -89019,9 +89065,9 @@ var init_env = __esm({
|
|
|
89019
89065
|
});
|
|
89020
89066
|
|
|
89021
89067
|
// dist/commands/run.js
|
|
89022
|
-
import { existsSync as
|
|
89068
|
+
import { existsSync as existsSync35, readFileSync as readFileSync36 } from "node:fs";
|
|
89023
89069
|
import { isAbsolute as isAbsolute6, resolve as resolve20 } from "node:path";
|
|
89024
|
-
import { createRequire as
|
|
89070
|
+
import { createRequire as createRequire8 } from "node:module";
|
|
89025
89071
|
function parseArgs(values) {
|
|
89026
89072
|
if (!values.length)
|
|
89027
89073
|
return void 0;
|
|
@@ -89049,7 +89095,7 @@ function parseArgs(values) {
|
|
|
89049
89095
|
function hasRelativeRuntimeImport(fileName2, code) {
|
|
89050
89096
|
let ts2;
|
|
89051
89097
|
try {
|
|
89052
|
-
ts2 =
|
|
89098
|
+
ts2 = createRequire8(resolve20(fileName2))("typescript");
|
|
89053
89099
|
} catch {
|
|
89054
89100
|
return false;
|
|
89055
89101
|
}
|
|
@@ -89086,7 +89132,7 @@ function registerRun(program2) {
|
|
|
89086
89132
|
projectId = config2.project_id;
|
|
89087
89133
|
}
|
|
89088
89134
|
const absPath = isAbsolute6(script) ? script : resolve20(process.cwd(), script);
|
|
89089
|
-
if (!
|
|
89135
|
+
if (!existsSync35(absPath)) {
|
|
89090
89136
|
error(`File not found: ${script}`);
|
|
89091
89137
|
process.exit(1);
|
|
89092
89138
|
}
|
|
@@ -89525,10 +89571,10 @@ var init_claim = __esm({
|
|
|
89525
89571
|
});
|
|
89526
89572
|
|
|
89527
89573
|
// dist/lib/frontend-dev.js
|
|
89528
|
-
import { createRequire as
|
|
89574
|
+
import { createRequire as createRequire9 } from "node:module";
|
|
89529
89575
|
import { realpathSync as realpathSync4 } from "node:fs";
|
|
89530
89576
|
import { createConnection, createServer as createNetServer } from "node:net";
|
|
89531
|
-
import { join as
|
|
89577
|
+
import { join as join39 } from "node:path";
|
|
89532
89578
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
89533
89579
|
function deployedOrigin(value) {
|
|
89534
89580
|
const url3 = new URL(value);
|
|
@@ -89626,7 +89672,7 @@ async function startFrontendDev(cwd, target, port = 8787, open4 = false) {
|
|
|
89626
89672
|
throw new Error(INSTALL_PROJECT_DEPENDENCIES);
|
|
89627
89673
|
let vitePath;
|
|
89628
89674
|
try {
|
|
89629
|
-
vitePath =
|
|
89675
|
+
vitePath = createRequire9(join39(cwd, "package.json")).resolve("vite");
|
|
89630
89676
|
} catch {
|
|
89631
89677
|
if (readProjectPin(cwd)?.versionOnly) {
|
|
89632
89678
|
throw new Error("Install the local frontend tools: npm install -D --save-exact vite@7.2.2");
|
|
@@ -89769,8 +89815,8 @@ var init_preview_jobs = __esm({
|
|
|
89769
89815
|
|
|
89770
89816
|
// dist/commands/dev.js
|
|
89771
89817
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
89772
|
-
import { existsSync as
|
|
89773
|
-
import { join as
|
|
89818
|
+
import { existsSync as existsSync36, readFileSync as readFileSync37 } from "node:fs";
|
|
89819
|
+
import { join as join40, relative as relative11 } from "node:path";
|
|
89774
89820
|
function previewFinishedReason(err) {
|
|
89775
89821
|
if (!(err instanceof CliApiError) || err.code !== "DRAFT_SESSION_TERMINAL")
|
|
89776
89822
|
return null;
|
|
@@ -90753,8 +90799,8 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
|
|
|
90753
90799
|
const updateBinary = {};
|
|
90754
90800
|
const deleteKeys = [];
|
|
90755
90801
|
for (const rel of changed) {
|
|
90756
|
-
const abs =
|
|
90757
|
-
if (!
|
|
90802
|
+
const abs = join40(cwd, rel);
|
|
90803
|
+
if (!existsSync36(abs))
|
|
90758
90804
|
continue;
|
|
90759
90805
|
const { kind, key } = classifyKey(rel);
|
|
90760
90806
|
if (kind === "function")
|
|
@@ -90825,7 +90871,7 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
|
|
|
90825
90871
|
for (const rel of deleted)
|
|
90826
90872
|
delete nextFiles[rel];
|
|
90827
90873
|
for (const rel of changed)
|
|
90828
|
-
if (
|
|
90874
|
+
if (existsSync36(join40(cwd, rel)))
|
|
90829
90875
|
Object.assign(nextFiles, hashFiles(cwd, [rel]));
|
|
90830
90876
|
savePreviewRecord(cwd, { ...record3, preview_id: nextCandidate, files: nextFiles });
|
|
90831
90877
|
}
|
|
@@ -91020,8 +91066,8 @@ var init_dev = __esm({
|
|
|
91020
91066
|
});
|
|
91021
91067
|
|
|
91022
91068
|
// dist/commands/check.js
|
|
91023
|
-
import { existsSync as
|
|
91024
|
-
import { join as
|
|
91069
|
+
import { existsSync as existsSync37 } from "node:fs";
|
|
91070
|
+
import { join as join41, resolve as resolve21 } from "node:path";
|
|
91025
91071
|
function buildCheckBody(collected, projectId) {
|
|
91026
91072
|
const body = { project_id: projectId, files: collected.files };
|
|
91027
91073
|
if (Object.keys(collected.functions).length > 0)
|
|
@@ -91126,7 +91172,7 @@ async function runLocalPreflight(targetDir, collected, typecheck = async (dir) =
|
|
|
91126
91172
|
if (collected.excluded.length)
|
|
91127
91173
|
source.not_published = collected.excluded;
|
|
91128
91174
|
let typecheckStep;
|
|
91129
|
-
if (!
|
|
91175
|
+
if (!existsSync37(join41(targetDir, "tsconfig.json"))) {
|
|
91130
91176
|
typecheckStep = { name: "typecheck", status: "skipped", reason: MISSING_TSCONFIG_GUIDANCE };
|
|
91131
91177
|
} else if (missingProjectDependencies(targetDir).length) {
|
|
91132
91178
|
typecheckStep = { name: "typecheck", status: "skipped", reason: missingTypecheckDependenciesMessage() };
|
|
@@ -91543,7 +91589,7 @@ var init_api2 = __esm({
|
|
|
91543
91589
|
import { createReadStream as createReadStream2, createWriteStream as createWriteStream2 } from "node:fs";
|
|
91544
91590
|
import { stat as stat5, rename, unlink } from "node:fs/promises";
|
|
91545
91591
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
91546
|
-
import { basename as basename8, dirname as dirname13, extname as extname6, join as
|
|
91592
|
+
import { basename as basename8, dirname as dirname13, extname as extname6, join as join42, resolve as resolve23 } from "node:path";
|
|
91547
91593
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
91548
91594
|
function registerFs(program2) {
|
|
91549
91595
|
const fs2 = program2.command("fs").description("Manage project file storage");
|
|
@@ -91587,7 +91633,7 @@ function registerFs(program2) {
|
|
|
91587
91633
|
if (!response.body)
|
|
91588
91634
|
throw new Error("The server returned an empty file response.");
|
|
91589
91635
|
const destination = resolve23(local);
|
|
91590
|
-
tempPath =
|
|
91636
|
+
tempPath = join42(dirname13(destination), `.${basename8(destination)}.${randomUUID9()}.tmp`);
|
|
91591
91637
|
await pipeline2(response.body, createWriteStream2(tempPath, { flags: "wx" }));
|
|
91592
91638
|
await rename(tempPath, destination);
|
|
91593
91639
|
tempPath = void 0;
|
|
@@ -109377,7 +109423,7 @@ var require_polyfill = __commonJS({
|
|
|
109377
109423
|
var {
|
|
109378
109424
|
dirname: dirname16,
|
|
109379
109425
|
isAbsolute: isAbsolute7,
|
|
109380
|
-
join:
|
|
109426
|
+
join: join52,
|
|
109381
109427
|
parse: parse3,
|
|
109382
109428
|
resolve: resolve27,
|
|
109383
109429
|
sep: sep2,
|
|
@@ -109658,8 +109704,8 @@ var require_polyfill = __commonJS({
|
|
|
109658
109704
|
const dir = await readdir3(src);
|
|
109659
109705
|
for (let i = 0; i < dir.length; i++) {
|
|
109660
109706
|
const item = dir[i];
|
|
109661
|
-
const srcItem =
|
|
109662
|
-
const destItem =
|
|
109707
|
+
const srcItem = join52(src, item);
|
|
109708
|
+
const destItem = join52(dest, item);
|
|
109663
109709
|
const { destStat } = await checkPaths(srcItem, destItem, opts);
|
|
109664
109710
|
await startCopy(destStat, srcItem, destItem, opts);
|
|
109665
109711
|
}
|
|
@@ -109735,7 +109781,7 @@ var require_cp = __commonJS({
|
|
|
109735
109781
|
// node_modules/@npmcli/fs/lib/with-temp-dir.js
|
|
109736
109782
|
var require_with_temp_dir = __commonJS({
|
|
109737
109783
|
"node_modules/@npmcli/fs/lib/with-temp-dir.js"(exports, module) {
|
|
109738
|
-
var { join:
|
|
109784
|
+
var { join: join52, sep: sep2 } = __require("path");
|
|
109739
109785
|
var getOptions = require_get_options();
|
|
109740
109786
|
var { mkdir, mkdtemp, rm } = __require("fs/promises");
|
|
109741
109787
|
var withTempDir = /* @__PURE__ */ __name(async (root, fn, opts) => {
|
|
@@ -109743,7 +109789,7 @@ var require_with_temp_dir = __commonJS({
|
|
|
109743
109789
|
copy: ["tmpPrefix"]
|
|
109744
109790
|
});
|
|
109745
109791
|
await mkdir(root, { recursive: true });
|
|
109746
|
-
const target = await mkdtemp(
|
|
109792
|
+
const target = await mkdtemp(join52(`${root}${sep2}`, options2.tmpPrefix || ""));
|
|
109747
109793
|
let err;
|
|
109748
109794
|
let result;
|
|
109749
109795
|
try {
|
|
@@ -109768,13 +109814,13 @@ var require_with_temp_dir = __commonJS({
|
|
|
109768
109814
|
var require_readdir_scoped = __commonJS({
|
|
109769
109815
|
"node_modules/@npmcli/fs/lib/readdir-scoped.js"(exports, module) {
|
|
109770
109816
|
var { readdir: readdir3 } = __require("fs/promises");
|
|
109771
|
-
var { join:
|
|
109817
|
+
var { join: join52 } = __require("path");
|
|
109772
109818
|
var readdirScoped = /* @__PURE__ */ __name(async (dir) => {
|
|
109773
109819
|
const results = [];
|
|
109774
109820
|
for (const item of await readdir3(dir)) {
|
|
109775
109821
|
if (item.startsWith("@")) {
|
|
109776
|
-
for (const scopedItem of await readdir3(
|
|
109777
|
-
results.push(
|
|
109822
|
+
for (const scopedItem of await readdir3(join52(dir, item))) {
|
|
109823
|
+
results.push(join52(item, scopedItem));
|
|
109778
109824
|
}
|
|
109779
109825
|
} else {
|
|
109780
109826
|
results.push(item);
|
|
@@ -109789,7 +109835,7 @@ var require_readdir_scoped = __commonJS({
|
|
|
109789
109835
|
// node_modules/@npmcli/fs/lib/move-file.js
|
|
109790
109836
|
var require_move_file = __commonJS({
|
|
109791
109837
|
"node_modules/@npmcli/fs/lib/move-file.js"(exports, module) {
|
|
109792
|
-
var { dirname: dirname16, join:
|
|
109838
|
+
var { dirname: dirname16, join: join52, resolve: resolve27, relative: relative15, isAbsolute: isAbsolute7 } = __require("path");
|
|
109793
109839
|
var fs2 = __require("fs/promises");
|
|
109794
109840
|
var pathExists = /* @__PURE__ */ __name(async (path3) => {
|
|
109795
109841
|
try {
|
|
@@ -109819,7 +109865,7 @@ var require_move_file = __commonJS({
|
|
|
109819
109865
|
if (sourceStat.isDirectory()) {
|
|
109820
109866
|
const files = await fs2.readdir(source);
|
|
109821
109867
|
await Promise.all(files.map(
|
|
109822
|
-
(file) => moveFile(
|
|
109868
|
+
(file) => moveFile(join52(source, file), join52(destination, file), options2, false, symlinks)
|
|
109823
109869
|
));
|
|
109824
109870
|
} else if (sourceStat.isSymbolicLink()) {
|
|
109825
109871
|
symlinks.push({ source, destination });
|
|
@@ -129187,12 +129233,12 @@ var require_url = __commonJS({
|
|
|
129187
129233
|
"node_modules/tuf-js/dist/utils/url.js"(exports) {
|
|
129188
129234
|
"use strict";
|
|
129189
129235
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
129190
|
-
exports.join =
|
|
129236
|
+
exports.join = join52;
|
|
129191
129237
|
var url_1 = __require("url");
|
|
129192
|
-
function
|
|
129238
|
+
function join52(base, path3) {
|
|
129193
129239
|
return new url_1.URL(ensureTrailingSlash(base) + removeLeadingSlash(path3)).toString();
|
|
129194
129240
|
}
|
|
129195
|
-
__name(
|
|
129241
|
+
__name(join52, "join");
|
|
129196
129242
|
function ensureTrailingSlash(path3) {
|
|
129197
129243
|
return path3.endsWith("/") ? path3 : path3 + "/";
|
|
129198
129244
|
}
|
|
@@ -131529,7 +131575,7 @@ var require_dist15 = __commonJS({
|
|
|
131529
131575
|
// dist/lib/update-security.js
|
|
131530
131576
|
import { createHash as createHash9, timingSafeEqual } from "node:crypto";
|
|
131531
131577
|
import { mkdirSync as mkdirSync18, readFileSync as readFileSync38, statSync as statSync7 } from "node:fs";
|
|
131532
|
-
import { join as
|
|
131578
|
+
import { join as join43 } from "node:path";
|
|
131533
131579
|
import { Readable as Readable2 } from "node:stream";
|
|
131534
131580
|
import { pipeline as pipeline3 } from "node:stream/promises";
|
|
131535
131581
|
function expectedTarballUrl(version2) {
|
|
@@ -131894,8 +131940,8 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
|
131894
131940
|
seen2.add(path3);
|
|
131895
131941
|
return true;
|
|
131896
131942
|
});
|
|
131897
|
-
const manifestPath =
|
|
131898
|
-
const lockPath =
|
|
131943
|
+
const manifestPath = join43(extractionDir, "package.json");
|
|
131944
|
+
const lockPath = join43(extractionDir, "npm-shrinkwrap.json");
|
|
131899
131945
|
let manifest;
|
|
131900
131946
|
let lock;
|
|
131901
131947
|
try {
|
|
@@ -131939,7 +131985,7 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
|
131939
131985
|
}
|
|
131940
131986
|
let bundledManifest;
|
|
131941
131987
|
try {
|
|
131942
|
-
const bundledPath =
|
|
131988
|
+
const bundledPath = join43(extractionDir, ...lockPath2.split("/"), "package.json");
|
|
131943
131989
|
bundledManifest = JSON.parse(readFileSync38(bundledPath, "utf8"));
|
|
131944
131990
|
} catch (cause) {
|
|
131945
131991
|
throw new Error(`the verified artifact has an unreadable bundled dependency ${lockPath2}: ${message(cause)}`);
|
|
@@ -132013,7 +132059,7 @@ import { randomBytes as randomBytes8 } from "node:crypto";
|
|
|
132013
132059
|
import { closeSync as closeSync5, constants as constants2, fstatSync, mkdtempSync as mkdtempSync3, openSync as openSync5, readFileSync as readFileSync39, readSync, rmSync as rmSync14, unlinkSync as unlinkSync5, writeFileSync as writeFileSync24 } from "node:fs";
|
|
132014
132060
|
import { createServer } from "node:http";
|
|
132015
132061
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
132016
|
-
import { join as
|
|
132062
|
+
import { join as join44 } from "node:path";
|
|
132017
132063
|
function refuse2(cause) {
|
|
132018
132064
|
error(`Update refused: ${message2(cause)}.`);
|
|
132019
132065
|
info(`To install the latest release with npm instead, run: ${teal(NPM_UPDATE_COMMAND)}`);
|
|
@@ -132021,7 +132067,7 @@ function refuse2(cause) {
|
|
|
132021
132067
|
}
|
|
132022
132068
|
function currentVersion2() {
|
|
132023
132069
|
try {
|
|
132024
|
-
const pkg = JSON.parse(readFileSync39(
|
|
132070
|
+
const pkg = JSON.parse(readFileSync39(join44(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
132025
132071
|
return pkg.version;
|
|
132026
132072
|
} catch {
|
|
132027
132073
|
return "0.0.0";
|
|
@@ -132160,10 +132206,10 @@ async function serveArtifactSnapshot(artifact) {
|
|
|
132160
132206
|
}
|
|
132161
132207
|
async function installVerifiedTarball(tarballPath, tempDir, release2) {
|
|
132162
132208
|
const ambientEnvironment = { ...process.env };
|
|
132163
|
-
const packageDir =
|
|
132164
|
-
const cacheDir =
|
|
132165
|
-
const userConfigPath =
|
|
132166
|
-
const globalConfigPath =
|
|
132209
|
+
const packageDir = join44(tempDir, "authenticated-package");
|
|
132210
|
+
const cacheDir = join44(tempDir, "empty-cache");
|
|
132211
|
+
const userConfigPath = join44(tempDir, "user-npmrc");
|
|
132212
|
+
const globalConfigPath = join44(tempDir, "global-npmrc");
|
|
132167
132213
|
writeFileSync24(userConfigPath, "", { mode: 384 });
|
|
132168
132214
|
writeFileSync24(globalConfigPath, "", { mode: 384 });
|
|
132169
132215
|
const artifact = snapshotAuthenticatedArtifact(tarballPath);
|
|
@@ -132235,8 +132281,8 @@ async function runUpdate(opts, dependencies = {}) {
|
|
|
132235
132281
|
const provenance = await fetchJson(fetchImpl, release2.attestationUrl, "the official npm provenance endpoint");
|
|
132236
132282
|
await (dependencies.verifyProvenance ?? verifyPublishedProvenance)(provenance, release2);
|
|
132237
132283
|
const tarball = await downloadTarball(fetchImpl, release2);
|
|
132238
|
-
tempDir = mkdtempSync3(
|
|
132239
|
-
const tarballPath =
|
|
132284
|
+
tempDir = mkdtempSync3(join44(tmpdir2(), "somewhere-update-"));
|
|
132285
|
+
const tarballPath = join44(tempDir, `cli-${release2.version}.tgz`);
|
|
132240
132286
|
writeFileSync24(tarballPath, tarball, { mode: 384 });
|
|
132241
132287
|
info(`Cryptographically verified provenance and integrity for ${CLI_PACKAGE}@${release2.version}.`);
|
|
132242
132288
|
info(`Updating ${CLI_PACKAGE} from its authenticated dependency lock \u2026`);
|
|
@@ -134710,8 +134756,8 @@ var init_test_response_capture = __esm({
|
|
|
134710
134756
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
134711
134757
|
import { setDefaultResultOrder } from "node:dns";
|
|
134712
134758
|
import { lookup } from "node:dns/promises";
|
|
134713
|
-
import { existsSync as
|
|
134714
|
-
import { basename as basename9, dirname as dirname14, join as
|
|
134759
|
+
import { existsSync as existsSync38, mkdirSync as mkdirSync19, readFileSync as readFileSync41, writeFileSync as writeFileSync25 } from "node:fs";
|
|
134760
|
+
import { basename as basename9, dirname as dirname14, join as join45, relative as relative12, resolve as resolve24 } from "node:path";
|
|
134715
134761
|
function launchOptions(extra = {}) {
|
|
134716
134762
|
return { ...extra, args: ["--disable-features=AsyncDns", ...extra.args ?? []] };
|
|
134717
134763
|
}
|
|
@@ -134761,8 +134807,8 @@ function undeployedChanges(root, projectId, preview = false) {
|
|
|
134761
134807
|
return null;
|
|
134762
134808
|
base = { project_id: record3.project_id, release_id: record3.preview_id, files: record3.files };
|
|
134763
134809
|
} else {
|
|
134764
|
-
const path3 =
|
|
134765
|
-
if (!
|
|
134810
|
+
const path3 = join45(root, ".somewhere", "base-files.json");
|
|
134811
|
+
if (!existsSync38(path3))
|
|
134766
134812
|
return null;
|
|
134767
134813
|
base = JSON.parse(readFileSync41(path3, "utf8"));
|
|
134768
134814
|
}
|
|
@@ -134934,7 +134980,7 @@ var init_app_test = __esm({
|
|
|
134934
134980
|
for (const line of describeSweep(await sweepAccounts(control, root), "Before this script"))
|
|
134935
134981
|
process.stderr.write(line + "\n");
|
|
134936
134982
|
const scriptName = process.argv[1] ? basename9(process.argv[1]).replace(/\.[cm]?[jt]s$/, "") : "app-check";
|
|
134937
|
-
const app = new _AppTest(root, control, resolve24(root, options2.results ??
|
|
134983
|
+
const app = new _AppTest(root, control, resolve24(root, options2.results ?? join45(".somewhere", `${scriptName}${preview ? "-preview" : ""}.json`)));
|
|
134938
134984
|
return app;
|
|
134939
134985
|
}
|
|
134940
134986
|
/** What this run tests: the project, environment, preview, origin and script. */
|
|
@@ -135155,6 +135201,117 @@ page ${i + 1}: ${state}`).join("");
|
|
|
135155
135201
|
}
|
|
135156
135202
|
});
|
|
135157
135203
|
|
|
135204
|
+
// dist/lib/test-refusal.js
|
|
135205
|
+
async function bodyOf(response) {
|
|
135206
|
+
let json = null;
|
|
135207
|
+
try {
|
|
135208
|
+
json = await response.json();
|
|
135209
|
+
} catch {
|
|
135210
|
+
}
|
|
135211
|
+
const raw = typeof json?.error === "string" ? json.error : "";
|
|
135212
|
+
return { code: /^[A-Z_]+$/.test(raw) ? raw : "none", message: typeof json?.message === "string" ? scrub(json.message).slice(0, 300) : "", json };
|
|
135213
|
+
}
|
|
135214
|
+
function seen(status, code, message3) {
|
|
135215
|
+
const kind = status === 400 ? "a malformed request" : status === 409 ? "a stale data contract" : `HTTP ${status}`;
|
|
135216
|
+
return `${kind} (${status} ${code}${message3 ? `: ${message3}` : ""})`;
|
|
135217
|
+
}
|
|
135218
|
+
async function assertRefused(client, target, request2, allowed) {
|
|
135219
|
+
const endpoint = ENDPOINT.exec(target);
|
|
135220
|
+
if (endpoint) {
|
|
135221
|
+
const [, method, path3] = endpoint;
|
|
135222
|
+
const payload = method === "GET" ? void 0 : request2;
|
|
135223
|
+
const response2 = await client.endpoint(method, path3, payload);
|
|
135224
|
+
const status2 = response2.status;
|
|
135225
|
+
const { code: code2, message: message4 } = await bodyOf(response2);
|
|
135226
|
+
const said2 = `${target} answered ${seen(status2, code2, message4)}`;
|
|
135227
|
+
if (status2 < 400)
|
|
135228
|
+
throw new Error(`expectRefused: ${said2}: this person could call the endpoint.`);
|
|
135229
|
+
if (status2 === 400 || status2 === 422)
|
|
135230
|
+
throw new Error(`expectRefused: ${said2}: the endpoint rejected the input, which says nothing about who is asking. Send a body it accepts from someone who may.`);
|
|
135231
|
+
if (![401, 403, 404].includes(status2))
|
|
135232
|
+
throw new Error(`expectRefused: ${said2}: a refusal is 401, 403 or 404.`);
|
|
135233
|
+
if (status2 === 404 && !allowed)
|
|
135234
|
+
throw new Error(`expectRefused: ${said2}: a 404 ${INCONCLUSIVE}`);
|
|
135235
|
+
if (allowed) {
|
|
135236
|
+
const control = await allowed.endpoint(method, path3, payload);
|
|
135237
|
+
const c = await bodyOf(control);
|
|
135238
|
+
if (control.status >= 300)
|
|
135239
|
+
throw new Error(`expectRefused: ${said2}, but the allowed person got ${seen(control.status, c.code, c.message)} too, so the route or input is wrong and the refusal is not proven.`);
|
|
135240
|
+
}
|
|
135241
|
+
return;
|
|
135242
|
+
}
|
|
135243
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(target))
|
|
135244
|
+
throw new Error(`expectRefused: "${target}" is neither a table name nor 'METHOD /path'.`);
|
|
135245
|
+
if (!request2 || typeof request2 !== "object" || typeof request2.operation !== "string") {
|
|
135246
|
+
throw new Error(`expectRefused: pass a data request for table ${target}, for example { operation: 'get', id }.`);
|
|
135247
|
+
}
|
|
135248
|
+
const operation = request2.operation;
|
|
135249
|
+
const reading = operation === "get" || operation === "list" || operation === "relation_list";
|
|
135250
|
+
const writing = operation === "update" || operation === "delete";
|
|
135251
|
+
const id = request2.id;
|
|
135252
|
+
const rowOf = /* @__PURE__ */ __name(async (as2) => {
|
|
135253
|
+
const response2 = await as2.data(target, { operation: "get", id });
|
|
135254
|
+
const body = await bodyOf(response2);
|
|
135255
|
+
if (response2.status !== 200)
|
|
135256
|
+
throw new Error(`expectRefused: the allowed person could not read ${target} ${String(id)} (${seen(response2.status, body.code, body.message)}), so choose a control that can read this row.`);
|
|
135257
|
+
return body.json?.data ?? null;
|
|
135258
|
+
}, "rowOf");
|
|
135259
|
+
let before = "";
|
|
135260
|
+
if (writing && allowed) {
|
|
135261
|
+
const row = await rowOf(allowed);
|
|
135262
|
+
before = JSON.stringify(row);
|
|
135263
|
+
if (row === null)
|
|
135264
|
+
throw new Error(`expectRefused: ${target} ${String(id)} does not exist for the allowed person, so there is nothing to refuse. Create the row first.`);
|
|
135265
|
+
}
|
|
135266
|
+
const response = await client.data(target, request2);
|
|
135267
|
+
const status = response.status;
|
|
135268
|
+
const { code, message: message3, json } = await bodyOf(response);
|
|
135269
|
+
const said = `${operation} on ${target} answered ${seen(status, code, message3)}`;
|
|
135270
|
+
const { kind } = classifyData(status, json, operation);
|
|
135271
|
+
if (kind === "missing-contract" || kind === "stale-contract" || kind === "malformed") {
|
|
135272
|
+
throw new Error(`expectRefused: ${said}. Nothing ran, so this proves nothing about access.`);
|
|
135273
|
+
}
|
|
135274
|
+
const rows = json?.data;
|
|
135275
|
+
const empty = status === 200 && (operation === "get" && rows === null || (operation === "list" || operation === "relation_list") && Array.isArray(rows) && rows.length === 0);
|
|
135276
|
+
const missing = kind === "missing-or-refused";
|
|
135277
|
+
if (status === 200 && !empty) {
|
|
135278
|
+
if (reading)
|
|
135279
|
+
throw new Error(`expectRefused: ${said}: this person read ${Array.isArray(rows) ? `${rows.length} row(s)` : "the row"}.`);
|
|
135280
|
+
throw new Error(`expectRefused: ${said}: the ${operation} was allowed.`);
|
|
135281
|
+
}
|
|
135282
|
+
if (kind !== "refused" && !empty && !missing)
|
|
135283
|
+
throw new Error(`expectRefused: ${said}: expected an access refusal.`);
|
|
135284
|
+
if ((empty || missing) && !allowed)
|
|
135285
|
+
throw new Error(`expectRefused: ${said}: ${empty ? "an empty answer" : "a 404"} ${INCONCLUSIVE}`);
|
|
135286
|
+
if (!allowed)
|
|
135287
|
+
return;
|
|
135288
|
+
if (reading) {
|
|
135289
|
+
const control = await allowed.data(target, request2);
|
|
135290
|
+
const c = await bodyOf(control);
|
|
135291
|
+
const got = c.json?.data;
|
|
135292
|
+
const found = control.status === 200 && (operation === "get" ? got !== null && got !== void 0 : Array.isArray(got) && got.length > 0);
|
|
135293
|
+
if (!found)
|
|
135294
|
+
throw new Error(`expectRefused: ${said}, but the allowed person got ${control.status === 200 ? "nothing" : seen(control.status, c.code, c.message)} for the same request, so there was nothing to refuse.`);
|
|
135295
|
+
} else if (writing) {
|
|
135296
|
+
const after = await rowOf(allowed);
|
|
135297
|
+
if (JSON.stringify(after) !== before)
|
|
135298
|
+
throw new Error(`expectRefused: ${said}, but ${target} ${String(id)} ${after === null ? "is gone" : "changed"} for the allowed person afterwards.`);
|
|
135299
|
+
}
|
|
135300
|
+
}
|
|
135301
|
+
var ENDPOINT, INCONCLUSIVE;
|
|
135302
|
+
var init_test_refusal = __esm({
|
|
135303
|
+
"dist/lib/test-refusal.js"() {
|
|
135304
|
+
"use strict";
|
|
135305
|
+
init_app_test();
|
|
135306
|
+
init_test_diagnostics();
|
|
135307
|
+
ENDPOINT = /^(GET|POST|PUT|PATCH|DELETE) (\/\S*)$/;
|
|
135308
|
+
__name(bodyOf, "bodyOf");
|
|
135309
|
+
INCONCLUSIVE = "looks the same as an empty table, a missing row or a missing route, so it proves nothing on its own. Pass { allowed: <someone the same request succeeds for> } as the positive control.";
|
|
135310
|
+
__name(seen, "seen");
|
|
135311
|
+
__name(assertRefused, "assertRefused");
|
|
135312
|
+
}
|
|
135313
|
+
});
|
|
135314
|
+
|
|
135158
135315
|
// dist/lib/test-session.js
|
|
135159
135316
|
async function expectStatus(response, expected) {
|
|
135160
135317
|
if (response.status !== expected)
|
|
@@ -135191,6 +135348,7 @@ var UserSession;
|
|
|
135191
135348
|
var init_test_session = __esm({
|
|
135192
135349
|
"dist/lib/test-session.js"() {
|
|
135193
135350
|
"use strict";
|
|
135351
|
+
init_test_refusal();
|
|
135194
135352
|
init_client();
|
|
135195
135353
|
init_config();
|
|
135196
135354
|
init_test_target();
|
|
@@ -135299,6 +135457,21 @@ var init_test_session = __esm({
|
|
|
135299
135457
|
post(path3, body) {
|
|
135300
135458
|
return this.request(path3, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
|
|
135301
135459
|
}
|
|
135460
|
+
async expectRefused(target, request2, { allowed } = {}) {
|
|
135461
|
+
if (allowed && allowed.origin !== this.origin)
|
|
135462
|
+
throw new Error("Choose a control session from the same app.");
|
|
135463
|
+
const adapt = /* @__PURE__ */ __name((session) => ({
|
|
135464
|
+
endpoint(method, path3, body) {
|
|
135465
|
+
return session.request(path3, body === void 0 ? { method } : {
|
|
135466
|
+
method,
|
|
135467
|
+
headers: { "Content-Type": "application/json" },
|
|
135468
|
+
body: JSON.stringify(body)
|
|
135469
|
+
});
|
|
135470
|
+
},
|
|
135471
|
+
data: /* @__PURE__ */ __name((table2, request3) => session.data(table2, request3), "data")
|
|
135472
|
+
}), "adapt");
|
|
135473
|
+
await assertRefused(adapt(this), target, request2, allowed && adapt(allowed));
|
|
135474
|
+
}
|
|
135302
135475
|
async data(table2, requestOrContract, request2) {
|
|
135303
135476
|
if (typeof requestOrContract === "string") {
|
|
135304
135477
|
return this.post("/__sw/data", { ...request2, table: table2, contract: requestOrContract });
|
|
@@ -135466,46 +135639,46 @@ var init_reference_check_note = __esm({
|
|
|
135466
135639
|
});
|
|
135467
135640
|
|
|
135468
135641
|
// dist/lib/test-scripts.js
|
|
135469
|
-
import { createRequire as
|
|
135470
|
-
import { existsSync as
|
|
135471
|
-
import { dirname as dirname15, join as
|
|
135642
|
+
import { createRequire as createRequire10 } from "node:module";
|
|
135643
|
+
import { existsSync as existsSync39, mkdirSync as mkdirSync20, readFileSync as readFileSync42, readdirSync as readdirSync8, rmSync as rmSync16, statSync as statSync8, writeFileSync as writeFileSync26 } from "node:fs";
|
|
135644
|
+
import { dirname as dirname15, join as join46, relative as relative13, resolve as resolve25 } from "node:path";
|
|
135472
135645
|
import { spawn as spawn7, spawnSync as spawnSync5 } from "node:child_process";
|
|
135473
135646
|
function hasSpecFiles(root) {
|
|
135474
135647
|
const walk2 = /* @__PURE__ */ __name((dir) => {
|
|
135475
|
-
if (!
|
|
135648
|
+
if (!existsSync39(dir))
|
|
135476
135649
|
return false;
|
|
135477
135650
|
for (const entry of readdirSync8(dir, { withFileTypes: true })) {
|
|
135478
135651
|
if (entry.name === "node_modules" || entry.name.startsWith("."))
|
|
135479
135652
|
continue;
|
|
135480
|
-
const path3 =
|
|
135653
|
+
const path3 = join46(dir, entry.name);
|
|
135481
135654
|
if (entry.isDirectory() ? walk2(path3) : /\.spec\.ts$/.test(entry.name))
|
|
135482
135655
|
return true;
|
|
135483
135656
|
}
|
|
135484
135657
|
return false;
|
|
135485
135658
|
}, "walk");
|
|
135486
|
-
return walk2(
|
|
135659
|
+
return walk2(join46(root, "tests"));
|
|
135487
135660
|
}
|
|
135488
135661
|
function listScripts(root, files) {
|
|
135489
135662
|
if (files.length)
|
|
135490
135663
|
return files.map((file) => relative13(root, resolve25(root, file)));
|
|
135491
|
-
const dir =
|
|
135492
|
-
if (!
|
|
135664
|
+
const dir = join46(root, "tests");
|
|
135665
|
+
if (!existsSync39(dir))
|
|
135493
135666
|
return [];
|
|
135494
|
-
return readdirSync8(dir).filter((name) => isScript(name) && statSync8(
|
|
135667
|
+
return readdirSync8(dir).filter((name) => isScript(name) && statSync8(join46(dir, name)).isFile()).sort().map((name) => join46("tests", name));
|
|
135495
135668
|
}
|
|
135496
135669
|
function scriptBrowserEnv(root) {
|
|
135497
|
-
const
|
|
135670
|
+
const require6 = createRequire10(join46(root, "package.json"));
|
|
135498
135671
|
let cli;
|
|
135499
135672
|
try {
|
|
135500
|
-
cli =
|
|
135673
|
+
cli = require6.resolve("@playwright/test/cli");
|
|
135501
135674
|
} catch {
|
|
135502
135675
|
throw testDependencyError(root);
|
|
135503
135676
|
}
|
|
135504
135677
|
const env = { ...process.env, PLAYWRIGHT_NO_COPY_PROMPT: "1" };
|
|
135505
|
-
const probe = spawnSync5(process.execPath, ["-e", "require(process.argv[1]).chromium.launch().then(b => b.close()).then(() => process.exit(0), () => process.exit(3))",
|
|
135678
|
+
const probe = spawnSync5(process.execPath, ["-e", "require(process.argv[1]).chromium.launch().then(b => b.close()).then(() => process.exit(0), () => process.exit(3))", require6.resolve("@playwright/test")], { env, stdio: "ignore" });
|
|
135506
135679
|
if (probe.status === 0)
|
|
135507
135680
|
return env;
|
|
135508
|
-
env.PLAYWRIGHT_BROWSERS_PATH ??=
|
|
135681
|
+
env.PLAYWRIGHT_BROWSERS_PATH ??= join46(cliConfigDir(), "cache", "playwright");
|
|
135509
135682
|
process.stderr.write("Installing Playwright Chromium in the CLI cache (once).\n");
|
|
135510
135683
|
const install = spawnSync5(process.execPath, [cli, "install", "chromium"], { stdio: "inherit", env });
|
|
135511
135684
|
if (install.status !== 0)
|
|
@@ -135528,7 +135701,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
135528
135701
|
env = testImportEnv(root, env);
|
|
135529
135702
|
const results = [];
|
|
135530
135703
|
for (const script of scripts) {
|
|
135531
|
-
if (!
|
|
135704
|
+
if (!existsSync39(join46(root, script))) {
|
|
135532
135705
|
results.push({ script, ok: false, exitCode: 1, ms: 0, reason: "no such file" });
|
|
135533
135706
|
continue;
|
|
135534
135707
|
}
|
|
@@ -135537,7 +135710,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
135537
135710
|
`);
|
|
135538
135711
|
const started = performance.now();
|
|
135539
135712
|
let output = "";
|
|
135540
|
-
const handOver =
|
|
135713
|
+
const handOver = join46(root, ".somewhere", "tests", `report-${results.length}.json`);
|
|
135541
135714
|
mkdirSync20(dirname15(handOver), { recursive: true });
|
|
135542
135715
|
rmSync16(handOver, { force: true });
|
|
135543
135716
|
const askedForBrowserLog = /(^|,)\s*(pw:browser|pw:\*|\*)\s*(,|$)/.test(env.DEBUG ?? "");
|
|
@@ -135567,7 +135740,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
135567
135740
|
stderrLines("", true);
|
|
135568
135741
|
let report2 = null;
|
|
135569
135742
|
try {
|
|
135570
|
-
report2 =
|
|
135743
|
+
report2 = existsSync39(handOver) ? JSON.parse(readFileSync42(handOver, "utf8")) : null;
|
|
135571
135744
|
} catch {
|
|
135572
135745
|
report2 = null;
|
|
135573
135746
|
}
|
|
@@ -135600,8 +135773,8 @@ function describeScriptResults(results, options2 = {}) {
|
|
|
135600
135773
|
return results.some((result) => result.browserCrashed) ? lines.map((line) => line.startsWith("Next: ") ? `Next: give the browser access as the FAIL line says, then run ${TEST_COMMAND} again.` : line) : lines;
|
|
135601
135774
|
}
|
|
135602
135775
|
function lastFailedScripts(root) {
|
|
135603
|
-
const path3 =
|
|
135604
|
-
if (!
|
|
135776
|
+
const path3 = join46(root, LAST);
|
|
135777
|
+
if (!existsSync39(path3))
|
|
135605
135778
|
return [];
|
|
135606
135779
|
try {
|
|
135607
135780
|
return (JSON.parse(readFileSync42(path3, "utf8")).results ?? []).filter((r) => !r.ok).map((r) => r.script);
|
|
@@ -135610,10 +135783,10 @@ function lastFailedScripts(root) {
|
|
|
135610
135783
|
}
|
|
135611
135784
|
}
|
|
135612
135785
|
function recordScriptResults(root, results, rerunOnly) {
|
|
135613
|
-
const previous = rerunOnly &&
|
|
135786
|
+
const previous = rerunOnly && existsSync39(join46(root, LAST)) ? JSON.parse(readFileSync42(join46(root, LAST), "utf8")).results ?? [] : [];
|
|
135614
135787
|
const merged = [...previous.filter((p2) => !results.some((r) => r.script === p2.script)), ...results];
|
|
135615
|
-
mkdirSync20(
|
|
135616
|
-
writeFileSync26(
|
|
135788
|
+
mkdirSync20(join46(root, ".somewhere", "tests"), { recursive: true });
|
|
135789
|
+
writeFileSync26(join46(root, LAST), JSON.stringify({ finished: (/* @__PURE__ */ new Date()).toISOString(), results: merged }, null, 2) + "\n");
|
|
135617
135790
|
}
|
|
135618
135791
|
var BROWSER_CRASH, BROWSER_CRASH_REASON, isScript, LAST;
|
|
135619
135792
|
var init_test_scripts = __esm({
|
|
@@ -135631,7 +135804,7 @@ var init_test_scripts = __esm({
|
|
|
135631
135804
|
__name(failureReason, "failureReason");
|
|
135632
135805
|
__name(runScripts, "runScripts");
|
|
135633
135806
|
__name(describeScriptResults, "describeScriptResults");
|
|
135634
|
-
LAST =
|
|
135807
|
+
LAST = join46(".somewhere", "tests", "scripts-last.json");
|
|
135635
135808
|
__name(lastFailedScripts, "lastFailedScripts");
|
|
135636
135809
|
__name(recordScriptResults, "recordScriptResults");
|
|
135637
135810
|
}
|
|
@@ -135726,8 +135899,8 @@ var init_test = __esm({
|
|
|
135726
135899
|
});
|
|
135727
135900
|
|
|
135728
135901
|
// dist/commands/test-users.js
|
|
135729
|
-
import { existsSync as
|
|
135730
|
-
import { basename as basename10, join as
|
|
135902
|
+
import { existsSync as existsSync40, readFileSync as readFileSync43, rmSync as rmSync17 } from "node:fs";
|
|
135903
|
+
import { basename as basename10, join as join47 } from "node:path";
|
|
135731
135904
|
import { randomBytes as randomBytes9 } from "node:crypto";
|
|
135732
135905
|
async function resolveTarget(projectOpt, originOpt) {
|
|
135733
135906
|
const root = process.cwd();
|
|
@@ -135818,7 +135991,7 @@ function registerTestUsers(program2) {
|
|
|
135818
135991
|
const record3 = /* @__PURE__ */ __name((spec, issued, receivedAt) => {
|
|
135819
135992
|
const times = expiryOf(issued, receivedAt);
|
|
135820
135993
|
const file = `${spec.name}.state.json`;
|
|
135821
|
-
writePrivateFile(
|
|
135994
|
+
writePrivateFile(join47(dir, file), JSON.stringify(buildStorageState(target.origin, target.host, issued, times), null, 2) + "\n");
|
|
135822
135995
|
const actor = {
|
|
135823
135996
|
name: spec.name,
|
|
135824
135997
|
user_id: issued.user.id,
|
|
@@ -135919,7 +136092,7 @@ function registerTestUsers(program2) {
|
|
|
135919
136092
|
if (name !== opts.linkOut || !/^[A-Za-z0-9._-]{1,64}$/.test(name))
|
|
135920
136093
|
throw new Error(`--link-out takes a file name; it is written under ${TEST_STATE_DIR}/.`);
|
|
135921
136094
|
ensurePrivateDir(stateDir(target.root));
|
|
135922
|
-
writePrivateFile(
|
|
136095
|
+
writePrivateFile(join47(stateDir(target.root), name), newest.magic_link + "\n");
|
|
135923
136096
|
linkFile = `${TEST_STATE_DIR}/${name}`;
|
|
135924
136097
|
}
|
|
135925
136098
|
const message3 = {
|
|
@@ -135990,12 +136163,12 @@ function registerTestUsers(program2) {
|
|
|
135990
136163
|
local_state: { removed: localRemoved, kept: manifest.actors.map((actor) => actor.state_file).filter((file) => !localRemoved.includes(file)) },
|
|
135991
136164
|
actors: manifest.actors.map(({ name, user_id, email: email2, role, created_at }) => ({ name, user_id, email: email2, role, created_at }))
|
|
135992
136165
|
};
|
|
135993
|
-
writePrivateFile(
|
|
136166
|
+
writePrivateFile(join47(stateDir(target.root), CLEANUP_RECEIPT_FILE), JSON.stringify(receipt, null, 2) + "\n");
|
|
135994
136167
|
const left = manifest.actors.filter((actor) => !removed.includes(actor.user_id));
|
|
135995
136168
|
if (left.length)
|
|
135996
136169
|
writeManifest(target.root, { ...manifest, actors: left, status: "partial" });
|
|
135997
136170
|
else
|
|
135998
|
-
rmSync17(
|
|
136171
|
+
rmSync17(join47(stateDir(target.root), MANIFEST_FILE), { force: true });
|
|
135999
136172
|
if (opts.json) {
|
|
136000
136173
|
printJson(receipt);
|
|
136001
136174
|
if (left.length)
|
|
@@ -136035,7 +136208,7 @@ var init_test_users = __esm({
|
|
|
136035
136208
|
});
|
|
136036
136209
|
|
|
136037
136210
|
// dist/commands/support.js
|
|
136038
|
-
import { join as
|
|
136211
|
+
import { join as join48 } from "node:path";
|
|
136039
136212
|
function commandPaths(program2) {
|
|
136040
136213
|
const paths = /* @__PURE__ */ new Set();
|
|
136041
136214
|
const walk2 = /* @__PURE__ */ __name((command, prefix) => {
|
|
@@ -136120,7 +136293,7 @@ function emitPacket(packet, opts) {
|
|
|
136120
136293
|
if (opts.out) {
|
|
136121
136294
|
if (!/^[A-Za-z0-9._-]{1,64}$/.test(opts.out))
|
|
136122
136295
|
throw new Error("--out takes a plain file name in the current folder.");
|
|
136123
|
-
writePrivateFile(
|
|
136296
|
+
writePrivateFile(join48(process.cwd(), opts.out), JSON.stringify(packet, null, 2) + "\n");
|
|
136124
136297
|
}
|
|
136125
136298
|
if (opts.json) {
|
|
136126
136299
|
printJson(packet);
|
|
@@ -136411,10 +136584,10 @@ var init_startup_notice = __esm({
|
|
|
136411
136584
|
|
|
136412
136585
|
// dist/lib/last-run.js
|
|
136413
136586
|
import { lstatSync as lstatSync5, mkdirSync as mkdirSync21, renameSync as renameSync6, unlinkSync as unlinkSync6, writeFileSync as writeFileSync27 } from "node:fs";
|
|
136414
|
-
import { join as
|
|
136587
|
+
import { join as join49 } from "node:path";
|
|
136415
136588
|
function removeStaleRunRecord(dir = cliConfigDir()) {
|
|
136416
136589
|
for (const name of RUN_RECORD_FILES) {
|
|
136417
|
-
const path3 =
|
|
136590
|
+
const path3 = join49(dir, name);
|
|
136418
136591
|
try {
|
|
136419
136592
|
if (lstatSync5(path3).isDirectory()) {
|
|
136420
136593
|
process.stderr.write(`Could not remove ${path3}: it is a directory, not this CLI's run record. Check it yourself.
|
|
@@ -136454,8 +136627,8 @@ function recordLastRun(cliVersion) {
|
|
|
136454
136627
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
136455
136628
|
cli_version: cliVersion
|
|
136456
136629
|
};
|
|
136457
|
-
const path3 =
|
|
136458
|
-
const temporary =
|
|
136630
|
+
const path3 = join49(dir, "last-run.json");
|
|
136631
|
+
const temporary = join49(dir, "last-run.json.tmp");
|
|
136459
136632
|
writeFileSync27(temporary, JSON.stringify(record3) + "\n", { mode: 384 });
|
|
136460
136633
|
renameSync6(temporary, path3);
|
|
136461
136634
|
} catch {
|
|
@@ -136494,7 +136667,7 @@ __export(dist_exports, {
|
|
|
136494
136667
|
});
|
|
136495
136668
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
136496
136669
|
import { readFileSync as readFileSync45 } from "node:fs";
|
|
136497
|
-
import { join as
|
|
136670
|
+
import { join as join50 } from "node:path";
|
|
136498
136671
|
async function runCli() {
|
|
136499
136672
|
const pinned = decidePin(process.cwd(), CLI_VERSION, process.argv, process.env);
|
|
136500
136673
|
if (pinned.notice)
|
|
@@ -136522,7 +136695,7 @@ async function runCli() {
|
|
|
136522
136695
|
process.exit(child.status ?? 1);
|
|
136523
136696
|
}
|
|
136524
136697
|
removeStaleRunRecord();
|
|
136525
|
-
const pkg = JSON.parse(readFileSync45(
|
|
136698
|
+
const pkg = JSON.parse(readFileSync45(join50(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
136526
136699
|
const program2 = new Command().name(cliInvocation()).description(`CLI for somewhere.cloud. Run ${cliInvocation()} init first, then read generated AGENTS.md: call shapes and access patterns for a typical app; docs are for exceptions.`).version(pkg.version);
|
|
136527
136700
|
recordLastRun(pkg.version);
|
|
136528
136701
|
const jsonOutputRequested = process.argv.includes("--json");
|
|
@@ -136935,8 +137108,8 @@ var init_screenshot_guard = __esm({
|
|
|
136935
137108
|
});
|
|
136936
137109
|
|
|
136937
137110
|
// dist/lib/playwright-fixtures.js
|
|
136938
|
-
import { createRequire as
|
|
136939
|
-
import { join as
|
|
137111
|
+
import { createRequire as createRequire11 } from "node:module";
|
|
137112
|
+
import { join as join51 } from "node:path";
|
|
136940
137113
|
function waitOnNavigation(page) {
|
|
136941
137114
|
async function wait(options2) {
|
|
136942
137115
|
if (options2?.waitUntil === "commit")
|
|
@@ -136988,10 +137161,10 @@ async function previewControlForWorker() {
|
|
|
136988
137161
|
function runner() {
|
|
136989
137162
|
if (loaded)
|
|
136990
137163
|
return loaded;
|
|
136991
|
-
const
|
|
137164
|
+
const require6 = createRequire11(join51(process.cwd(), "package.json"));
|
|
136992
137165
|
let pw;
|
|
136993
137166
|
try {
|
|
136994
|
-
pw =
|
|
137167
|
+
pw = require6("@playwright/test");
|
|
136995
137168
|
} catch {
|
|
136996
137169
|
throw new Error("Install project test dependencies: npm install -D @playwright/test @somewhere-cloud/cli");
|
|
136997
137170
|
}
|
|
@@ -137320,107 +137493,20 @@ function clientOf2(person) {
|
|
|
137320
137493
|
return person.request;
|
|
137321
137494
|
return person;
|
|
137322
137495
|
}
|
|
137323
|
-
async function bodyOf(response) {
|
|
137324
|
-
let json = null;
|
|
137325
|
-
try {
|
|
137326
|
-
json = await response.json();
|
|
137327
|
-
} catch {
|
|
137328
|
-
}
|
|
137329
|
-
const raw = typeof json?.error === "string" ? json.error : "";
|
|
137330
|
-
return { code: /^[A-Z_]+$/.test(raw) ? raw : "none", message: typeof json?.message === "string" ? scrub(json.message).slice(0, 300) : "", json };
|
|
137331
|
-
}
|
|
137332
|
-
function seen(status, code, message3) {
|
|
137333
|
-
const kind = status === 400 ? "a malformed request" : status === 409 ? "a stale data contract" : `HTTP ${status}`;
|
|
137334
|
-
return `${kind} (${status} ${code}${message3 ? `: ${message3}` : ""})`;
|
|
137335
|
-
}
|
|
137336
137496
|
async function refusedAs(person, target, request2, options2) {
|
|
137337
|
-
const
|
|
137338
|
-
|
|
137339
|
-
|
|
137340
|
-
|
|
137341
|
-
|
|
137342
|
-
|
|
137343
|
-
|
|
137344
|
-
|
|
137345
|
-
|
|
137346
|
-
|
|
137347
|
-
if (status2 < 400)
|
|
137348
|
-
throw new Error(`expectRefused: ${said2}: it was allowed, not refused.`);
|
|
137349
|
-
if (status2 === 400 || status2 === 422)
|
|
137350
|
-
throw new Error(`expectRefused: ${said2}: the endpoint rejected the input, which says nothing about who is asking. Send a body it accepts from someone who may.`);
|
|
137351
|
-
if (![401, 403, 404].includes(status2))
|
|
137352
|
-
throw new Error(`expectRefused: ${said2}: a refusal is 401, 403 or 404.`);
|
|
137353
|
-
if (status2 === 404 && !allowed)
|
|
137354
|
-
throw new Error(`expectRefused: ${said2}: a 404 ${INCONCLUSIVE}`);
|
|
137355
|
-
if (allowed) {
|
|
137356
|
-
const control = await send(allowed);
|
|
137357
|
-
const c = await bodyOf(control);
|
|
137358
|
-
if (control.status() >= 300)
|
|
137359
|
-
throw new Error(`expectRefused: ${said2}, but the allowed person got ${seen(control.status(), c.code, c.message)} too, so the route or input is wrong and the refusal is not proven.`);
|
|
137497
|
+
const adapt = /* @__PURE__ */ __name((client) => ({
|
|
137498
|
+
async endpoint(method, path3, body) {
|
|
137499
|
+
const response = await client.fetch(path3, { method, ...body === void 0 ? {} : { data: body } });
|
|
137500
|
+
return { status: response.status(), json: /* @__PURE__ */ __name(() => response.json(), "json") };
|
|
137501
|
+
},
|
|
137502
|
+
async data(table2, request3) {
|
|
137503
|
+
if (!digests.has(client))
|
|
137504
|
+
throw new Error("expectRefused: act as (and pass allowed as) a page that signed up or signed in (signUp/signIn), a newUser() user, or anonymous.");
|
|
137505
|
+
const response = await data(client, table2, request3);
|
|
137506
|
+
return { status: response.status(), json: /* @__PURE__ */ __name(() => response.json(), "json") };
|
|
137360
137507
|
}
|
|
137361
|
-
|
|
137362
|
-
|
|
137363
|
-
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(target))
|
|
137364
|
-
throw new Error(`expectRefused: "${target}" is neither a table name nor 'METHOD /path'.`);
|
|
137365
|
-
if (!request2 || typeof request2 !== "object" || typeof request2.operation !== "string") {
|
|
137366
|
-
throw new Error(`expectRefused: pass a data request for table ${target}, for example { operation: 'get', id }.`);
|
|
137367
|
-
}
|
|
137368
|
-
for (const as2 of [client, ...allowed ? [allowed] : []]) {
|
|
137369
|
-
if (!digests.has(as2))
|
|
137370
|
-
throw new Error("expectRefused: act as (and pass allowed as) a page that signed up or signed in (signUp/signIn), a newUser() user, or anonymous.");
|
|
137371
|
-
}
|
|
137372
|
-
const operation = request2.operation;
|
|
137373
|
-
const reading = operation === "get" || operation === "list" || operation === "relation_list";
|
|
137374
|
-
const writing = operation === "update" || operation === "delete";
|
|
137375
|
-
const id = request2.id;
|
|
137376
|
-
const rowOf = /* @__PURE__ */ __name(async (as2) => {
|
|
137377
|
-
const response2 = await data(as2, target, { operation: "get", id });
|
|
137378
|
-
const body = await bodyOf(response2);
|
|
137379
|
-
if (response2.status() !== 200)
|
|
137380
|
-
throw new Error(`expectRefused: the allowed person could not read ${target} ${String(id)} (${seen(response2.status(), body.code, body.message)}), so it is not a control for this row.`);
|
|
137381
|
-
return body.json?.data ?? null;
|
|
137382
|
-
}, "rowOf");
|
|
137383
|
-
let before = "";
|
|
137384
|
-
if (writing && allowed) {
|
|
137385
|
-
const row = await rowOf(allowed);
|
|
137386
|
-
before = JSON.stringify(row);
|
|
137387
|
-
if (row === null)
|
|
137388
|
-
throw new Error(`expectRefused: ${target} ${String(id)} does not exist for the allowed person, so there is nothing to refuse. Create the row first.`);
|
|
137389
|
-
}
|
|
137390
|
-
const response = await data(client, target, request2);
|
|
137391
|
-
const status = response.status();
|
|
137392
|
-
const { code, message: message3, json } = await bodyOf(response);
|
|
137393
|
-
const said = `${operation} on ${target} answered ${seen(status, code, message3)}`;
|
|
137394
|
-
const { kind } = classifyData(status, json, operation);
|
|
137395
|
-
if (kind === "missing-contract" || kind === "stale-contract" || kind === "malformed") {
|
|
137396
|
-
throw new Error(`expectRefused: ${said}. Nothing ran, so this proves nothing about access.`);
|
|
137397
|
-
}
|
|
137398
|
-
const rows = json?.data;
|
|
137399
|
-
const empty = status === 200 && (operation === "get" && rows === null || (operation === "list" || operation === "relation_list") && Array.isArray(rows) && rows.length === 0);
|
|
137400
|
-
const missing = kind === "missing-or-refused";
|
|
137401
|
-
if (status === 200 && !empty) {
|
|
137402
|
-
if (reading)
|
|
137403
|
-
throw new Error(`expectRefused: ${said}: this person read ${Array.isArray(rows) ? `${rows.length} row(s)` : "the row"}.`);
|
|
137404
|
-
throw new Error(`expectRefused: ${said}: the ${operation} was allowed.`);
|
|
137405
|
-
}
|
|
137406
|
-
if (kind !== "refused" && !empty && !missing)
|
|
137407
|
-
throw new Error(`expectRefused: ${said}: not a refusal.`);
|
|
137408
|
-
if ((empty || missing) && !allowed)
|
|
137409
|
-
throw new Error(`expectRefused: ${said}: ${empty ? "an empty answer" : "a 404"} ${INCONCLUSIVE}`);
|
|
137410
|
-
if (!allowed)
|
|
137411
|
-
return;
|
|
137412
|
-
if (reading) {
|
|
137413
|
-
const control = await data(allowed, target, request2);
|
|
137414
|
-
const c = await bodyOf(control);
|
|
137415
|
-
const got = c.json?.data;
|
|
137416
|
-
const found = control.status() === 200 && (operation === "get" ? got !== null && got !== void 0 : Array.isArray(got) && got.length > 0);
|
|
137417
|
-
if (!found)
|
|
137418
|
-
throw new Error(`expectRefused: ${said}, but the allowed person got ${control.status() === 200 ? "nothing" : seen(control.status(), c.code, c.message)} for the same request, so there was nothing to refuse.`);
|
|
137419
|
-
} else if (writing) {
|
|
137420
|
-
const after = await rowOf(allowed);
|
|
137421
|
-
if (JSON.stringify(after) !== before)
|
|
137422
|
-
throw new Error(`expectRefused: ${said}, but ${target} ${String(id)} ${after === null ? "is gone" : "changed"} for the allowed person afterwards.`);
|
|
137423
|
-
}
|
|
137508
|
+
}), "adapt");
|
|
137509
|
+
await assertRefused(adapt(clientOf2(person)), target, request2, options2.allowed === void 0 ? void 0 : adapt(clientOf2(options2.allowed)));
|
|
137424
137510
|
}
|
|
137425
137511
|
async function refreshTestContext(client, origin) {
|
|
137426
137512
|
const ongoing = contextRefreshes.get(client);
|
|
@@ -137479,13 +137565,13 @@ async function data(client, table2, request2) {
|
|
|
137479
137565
|
data: { ...request2, table: table2, contract: contractDigest ?? "" }
|
|
137480
137566
|
});
|
|
137481
137567
|
}
|
|
137482
|
-
var loaded, digests, eager, test, expect,
|
|
137568
|
+
var loaded, digests, eager, test, expect, contextRefreshes, contextTargets, constrained, FormRun;
|
|
137483
137569
|
var init_playwright_fixtures = __esm({
|
|
137484
137570
|
"dist/lib/playwright-fixtures.js"() {
|
|
137485
137571
|
"use strict";
|
|
137486
137572
|
init_test_target();
|
|
137487
137573
|
init_client();
|
|
137488
|
-
|
|
137574
|
+
init_test_refusal();
|
|
137489
137575
|
init_config();
|
|
137490
137576
|
init_test_identities();
|
|
137491
137577
|
init_test_diagnostics();
|
|
@@ -137527,10 +137613,6 @@ var init_playwright_fixtures = __esm({
|
|
|
137527
137613
|
});
|
|
137528
137614
|
__name(expectRefused, "expectRefused");
|
|
137529
137615
|
__name(clientOf2, "clientOf");
|
|
137530
|
-
ENDPOINT = /^(GET|POST|PUT|PATCH|DELETE) (\/\S*)$/;
|
|
137531
|
-
__name(bodyOf, "bodyOf");
|
|
137532
|
-
INCONCLUSIVE = "looks the same as an empty table, a missing row or a missing route, so it proves nothing on its own. Pass { allowed: <someone the same request succeeds for> } as the positive control.";
|
|
137533
|
-
__name(seen, "seen");
|
|
137534
137616
|
__name(refusedAs, "refusedAs");
|
|
137535
137617
|
contextRefreshes = /* @__PURE__ */ new WeakMap();
|
|
137536
137618
|
__name(refreshTestContext, "refreshTestContext");
|