@somewhere-cloud/cli 0.38.182 → 0.38.183
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/lib/bundle.js +127 -39
- package/dist/lib/bundle.js.map +2 -2
- package/dist/types/lib/testing-app.d.ts +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
- package/runtime/DECLARED-DATA-VENDOR.json +6 -6
- package/runtime/PLATFORM-SOURCE.json +1 -1
- package/runtime/declared-data.cjs +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.38.183
|
|
4
|
+
|
|
5
|
+
- Restore a recently deleted app with `somewhere project delete --undo`.
|
|
6
|
+
- The testing kit finds Playwright automatically and prefers installed Chrome on macOS.
|
|
7
|
+
- Test that a response leaves out protected text, and see a pass or fail when you expect a refusal.
|
|
8
|
+
- The starter guide explains when a dry run is worth doing before a deploy.
|
|
9
|
+
|
|
3
10
|
## 0.38.182
|
|
4
11
|
|
|
5
12
|
- Start a new app without the sample notes table or screen.
|
package/dist/lib/bundle.js
CHANGED
|
@@ -20315,7 +20315,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
20315
20315
|
"node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
20316
20316
|
"use strict";
|
|
20317
20317
|
var { writeFile: writeFile2, readFile: readFile3, mkdir } = __require("node:fs/promises");
|
|
20318
|
-
var { dirname:
|
|
20318
|
+
var { dirname: dirname18, resolve: resolve27 } = __require("node:path");
|
|
20319
20319
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
|
|
20320
20320
|
var { InvalidArgumentError: InvalidArgumentError2, UndiciError } = require_errors();
|
|
20321
20321
|
var { setHeader } = require_util();
|
|
@@ -20571,7 +20571,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
20571
20571
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
20572
20572
|
}
|
|
20573
20573
|
const resolvedPath = resolve27(path3);
|
|
20574
|
-
await mkdir(
|
|
20574
|
+
await mkdir(dirname18(resolvedPath), { recursive: true });
|
|
20575
20575
|
const data2 = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
20576
20576
|
hash,
|
|
20577
20577
|
snapshot
|
|
@@ -44306,7 +44306,7 @@ Prove the brief in \`tests/starter.mjs\` (\`npm test\`, from the app folder, aft
|
|
|
44306
44306
|
|
|
44307
44307
|
If the folder already has Playwright tests, keep running them; put new checks in \`tests/starter.mjs\`. Tests that write change rows in the live app: for an app with real customers, test on a preview (\`somewhere preview\`, then \`openTestApp({ preview: true })\`). After every deploy the platform runs its own smoke check, plus any check lists saved in \`checks/\`; \`somewhere test\` shows the result.
|
|
44308
44308
|
|
|
44309
|
-
|
|
44309
|
+
Deploy with \`somewhere deploy\`; there is no build step, and a routine edit needs no separate check first. A deploy type-checks locally when dependencies are installed and runs the platform's compile, schema and secret checks; a refusal from those checks changes nothing, so fix what it names and deploy again. If a later step fails, the answer says which version is live and whether the database changed; act on that. Run \`somewhere deploy --dry-run\` first when a change removes a table, column, file or handler, or widens who can read existing rows: it lists those effects before they happen. When testing changes with real users or data, use \`somewhere preview\`, test with \`somewhere test --preview\`, then promote. See \`somewhere docs dev-environments\`. Inspect failures with \`somewhere errors\` and \`somewhere logs\`. Keep test IDs when restyling. See \`somewhere docs test\`.
|
|
44310
44310
|
|
|
44311
44311
|
Use \`somewhere docs <topic> --section <id>\` for one section or \`--full\` for all examples. Ask before destructive or paid actions unless the user already authorized them.
|
|
44312
44312
|
`;
|
|
@@ -44719,7 +44719,6 @@ To share your own rows with specific people, read:
|
|
|
44719
44719
|
|
|
44720
44720
|
\`\`\`sh
|
|
44721
44721
|
somewhere typecheck
|
|
44722
|
-
somewhere deploy-check .
|
|
44723
44722
|
somewhere deploy
|
|
44724
44723
|
somewhere browser
|
|
44725
44724
|
\`\`\`
|
|
@@ -52765,7 +52764,7 @@ function registerProject(program2) {
|
|
|
52765
52764
|
process.exit(1);
|
|
52766
52765
|
}
|
|
52767
52766
|
});
|
|
52768
|
-
proj.command("delete <name-or-id>").description("
|
|
52767
|
+
proj.command("delete <name-or-id>").description("Delete a project: it goes offline now and its data is erased after 30 days. --undo restores it within those 30 days.").option("--confirm-code <code>", "Confirm deletion using the confirm_code returned by the first call").option("--undo", "Restore a project you deleted within the last 30 days. It comes back offline; deploy it again to put it online.").option("--json", "Print the deletion result as JSON").addOption(new Option("--yes").hideHelp()).addOption(new Option("--force").hideHelp()).action(async (nameOrId, opts) => {
|
|
52769
52768
|
const unsupported = opts.yes ? "--yes" : opts.force ? "--force" : void 0;
|
|
52770
52769
|
if (unsupported) {
|
|
52771
52770
|
const message3 = `Unknown option '${unsupported}'. Run ${cliInvocation()} project delete <name-or-id> to get a code, then repeat with --confirm-code <code>.`;
|
|
@@ -52775,7 +52774,38 @@ function registerProject(program2) {
|
|
|
52775
52774
|
error(message3);
|
|
52776
52775
|
process.exit(1);
|
|
52777
52776
|
}
|
|
52777
|
+
if (opts.undo && opts.confirmCode) {
|
|
52778
|
+
const message3 = "--undo restores a deleted project and takes no confirmation code. Run it without --confirm-code.";
|
|
52779
|
+
if (opts.json)
|
|
52780
|
+
printJsonError("UNKNOWN_OPTION", message3);
|
|
52781
|
+
else
|
|
52782
|
+
error(message3);
|
|
52783
|
+
process.exit(1);
|
|
52784
|
+
}
|
|
52778
52785
|
const client = new ApiClient(getToken());
|
|
52786
|
+
if (opts.undo) {
|
|
52787
|
+
const spinner2 = opts.json ? null : ora("Restoring...").start();
|
|
52788
|
+
try {
|
|
52789
|
+
const restored = await client.call("POST", `/projects/${encodeURIComponent(nameOrId)}/restore`, {});
|
|
52790
|
+
spinner2?.stop();
|
|
52791
|
+
if (opts.json) {
|
|
52792
|
+
printJson(restored);
|
|
52793
|
+
return;
|
|
52794
|
+
}
|
|
52795
|
+
if (restored?.restored === true) {
|
|
52796
|
+
success("Restored. It is offline until you deploy it again.");
|
|
52797
|
+
if (restored.note)
|
|
52798
|
+
info(restored.note);
|
|
52799
|
+
} else {
|
|
52800
|
+
info(restored?.note ?? "This project is not deleted. Nothing changed.");
|
|
52801
|
+
}
|
|
52802
|
+
} catch (err) {
|
|
52803
|
+
spinner2?.stop();
|
|
52804
|
+
renderDeleteError(err, opts.json);
|
|
52805
|
+
process.exit(1);
|
|
52806
|
+
}
|
|
52807
|
+
return;
|
|
52808
|
+
}
|
|
52779
52809
|
const promptStdout = opts.json ? process.stderr : void 0;
|
|
52780
52810
|
let project;
|
|
52781
52811
|
try {
|
|
@@ -52796,6 +52826,7 @@ function registerProject(program2) {
|
|
|
52796
52826
|
return;
|
|
52797
52827
|
}
|
|
52798
52828
|
success("Deleted.");
|
|
52829
|
+
printDeleteNote(deleted2);
|
|
52799
52830
|
return;
|
|
52800
52831
|
}
|
|
52801
52832
|
const code = await requestDeleteConfirmationCode(client, project.id);
|
|
@@ -52817,7 +52848,7 @@ function registerProject(program2) {
|
|
|
52817
52848
|
const { confirm: confirm2 } = await (0, import_prompts3.default)({
|
|
52818
52849
|
type: "text",
|
|
52819
52850
|
name: "confirm",
|
|
52820
|
-
message: `This will
|
|
52851
|
+
message: `This will delete "${projectName}": it goes offline now, and its data is erased for good after 30 days.
|
|
52821
52852
|
Type the project name to confirm`,
|
|
52822
52853
|
stdout: promptStdout
|
|
52823
52854
|
});
|
|
@@ -52838,6 +52869,7 @@ function registerProject(program2) {
|
|
|
52838
52869
|
return;
|
|
52839
52870
|
}
|
|
52840
52871
|
success("Deleted.");
|
|
52872
|
+
printDeleteNote(deleted);
|
|
52841
52873
|
} catch (err) {
|
|
52842
52874
|
spinner?.stop();
|
|
52843
52875
|
renderDeleteError(err, opts.json);
|
|
@@ -52882,6 +52914,11 @@ async function requestDeleteConfirmationCode(client, projectId) {
|
|
|
52882
52914
|
}
|
|
52883
52915
|
throw new CliApiError("DELETE_CONFIRMATION_MISSING", "The server did not require a delete confirmation code, so the CLI refused to continue.", 500);
|
|
52884
52916
|
}
|
|
52917
|
+
function printDeleteNote(deleted) {
|
|
52918
|
+
const note = deleted && typeof deleted === "object" ? deleted.note : void 0;
|
|
52919
|
+
if (typeof note === "string" && note.trim())
|
|
52920
|
+
info(note);
|
|
52921
|
+
}
|
|
52885
52922
|
function confirmProjectDelete(client, projectId, code) {
|
|
52886
52923
|
return client.call("DELETE", `/projects/${encodeURIComponent(projectId)}`, { code });
|
|
52887
52924
|
}
|
|
@@ -52986,6 +53023,7 @@ var init_project = __esm({
|
|
|
52986
53023
|
__name(registerProject, "registerProject");
|
|
52987
53024
|
__name(resolveDeleteTarget, "resolveDeleteTarget");
|
|
52988
53025
|
__name(requestDeleteConfirmationCode, "requestDeleteConfirmationCode");
|
|
53026
|
+
__name(printDeleteNote, "printDeleteNote");
|
|
52989
53027
|
__name(confirmProjectDelete, "confirmProjectDelete");
|
|
52990
53028
|
__name(renderDeleteError, "renderDeleteError");
|
|
52991
53029
|
__name(listProjects, "listProjects");
|
|
@@ -75912,9 +75950,9 @@ var init_handler = __esm({
|
|
|
75912
75950
|
if (this.fsw.closed) {
|
|
75913
75951
|
return;
|
|
75914
75952
|
}
|
|
75915
|
-
const
|
|
75953
|
+
const dirname18 = sysPath.dirname(file);
|
|
75916
75954
|
const basename13 = sysPath.basename(file);
|
|
75917
|
-
const parent = this.fsw._getWatchedDir(
|
|
75955
|
+
const parent = this.fsw._getWatchedDir(dirname18);
|
|
75918
75956
|
let prevStats = stats;
|
|
75919
75957
|
if (parent.has(basename13))
|
|
75920
75958
|
return;
|
|
@@ -75941,7 +75979,7 @@ var init_handler = __esm({
|
|
|
75941
75979
|
prevStats = newStats2;
|
|
75942
75980
|
}
|
|
75943
75981
|
} catch (error3) {
|
|
75944
|
-
this.fsw._remove(
|
|
75982
|
+
this.fsw._remove(dirname18, basename13);
|
|
75945
75983
|
}
|
|
75946
75984
|
} else if (parent.has(basename13)) {
|
|
75947
75985
|
const at2 = newStats.atimeMs;
|
|
@@ -78712,8 +78750,8 @@ function formatChecksReport(check) {
|
|
|
78712
78750
|
}
|
|
78713
78751
|
const coverage = check?.not_checked ?? null;
|
|
78714
78752
|
if (coverage) {
|
|
78715
|
-
if (typeof check?.routes_discovered === "number")
|
|
78716
|
-
lines.push(
|
|
78753
|
+
if (typeof check?.routes_discovered === "number" && check.routes_checked)
|
|
78754
|
+
lines.push(`${check.routes_checked} of ${check.routes_discovered} app routes had a completed read check.`);
|
|
78717
78755
|
const { routes_without_read_check: reads, routes_without_write_check: writes, schedules_not_run: schedules, other } = coverage;
|
|
78718
78756
|
if (reads === null || writes === null)
|
|
78719
78757
|
lines.push("App route coverage could not be listed.");
|
|
@@ -78727,15 +78765,16 @@ function formatChecksReport(check) {
|
|
|
78727
78765
|
lines.push(`This check skips scheduled tasks (${schedules.join(", ")}). To verify one on your preview, use ${cliInvocation()} cron run <name> --preview --wait.`);
|
|
78728
78766
|
if (other.length)
|
|
78729
78767
|
lines.push(`Other checks skipped or out of scope: ${other.join(", ")}.`);
|
|
78768
|
+
if (!check?.routes_checked)
|
|
78769
|
+
lines.push("Your app's own routes, screens and rules are proven by your own tests (npm test), not by this check.");
|
|
78730
78770
|
} else {
|
|
78731
78771
|
lines.push("Coverage details are unavailable for this run.");
|
|
78732
78772
|
}
|
|
78733
|
-
lines.push("Prove the brief with a check list in checks/<name>.json (users and steps). See somewhere docs test.");
|
|
78734
78773
|
return [...lines, JSON.stringify({
|
|
78735
78774
|
...summary,
|
|
78736
78775
|
not_checked: coverage,
|
|
78737
78776
|
...check?.scope === "partial" ? { scope: check.scope, selection: check.selection, checked_parts: check.checked_parts } : {},
|
|
78738
|
-
...coverage ? { routes_checked: check
|
|
78777
|
+
...coverage && check?.routes_checked ? { routes_checked: check.routes_checked, routes_discovered: check.routes_discovered } : {}
|
|
78739
78778
|
})];
|
|
78740
78779
|
}
|
|
78741
78780
|
var DEPLOY_CHECKS_RUNNING, TEST_CHECKS_WAIT_MS, selectionLabel, cleanupFindings, functionWarnings;
|
|
@@ -80543,12 +80582,14 @@ function uploadInventory(files, binaryFiles, functions, scope) {
|
|
|
80543
80582
|
functions: scope === "static" ? [] : sorted(Object.keys(functions).filter((path3) => !path3.split("/").some((segment) => segment.startsWith("_"))))
|
|
80544
80583
|
};
|
|
80545
80584
|
}
|
|
80546
|
-
function formatUploadInventory(inventory) {
|
|
80585
|
+
function formatUploadInventory(inventory, dryRun = false) {
|
|
80547
80586
|
const paths = [...inventory.static_files, ...inventory.functions];
|
|
80548
80587
|
if (paths.length === 0)
|
|
80549
80588
|
return "Uploaded: nothing";
|
|
80550
80589
|
if (paths.length <= INLINE_UPLOAD_LIST_MAX)
|
|
80551
80590
|
return `Uploaded: ${paths.join(", ")}`;
|
|
80591
|
+
if (!dryRun)
|
|
80592
|
+
return `Uploaded ${paths.length} paths.`;
|
|
80552
80593
|
return `Uploaded ${paths.length} paths; the full list is "uploaded" in the output of ${cliInvocation()} deploy --dry-run --json`;
|
|
80553
80594
|
}
|
|
80554
80595
|
var INLINE_UPLOAD_LIST_MAX;
|
|
@@ -85368,7 +85409,7 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
85368
85409
|
printJson({ ...plan, uploaded: inventory });
|
|
85369
85410
|
} else {
|
|
85370
85411
|
printDryRun(plan, scope);
|
|
85371
|
-
info(dim(formatUploadInventory(inventory)));
|
|
85412
|
+
info(dim(formatUploadInventory(inventory, true)));
|
|
85372
85413
|
}
|
|
85373
85414
|
return;
|
|
85374
85415
|
}
|
|
@@ -110544,7 +110585,7 @@ var require_polyfill = __commonJS({
|
|
|
110544
110585
|
utimes
|
|
110545
110586
|
} = __require("fs/promises");
|
|
110546
110587
|
var {
|
|
110547
|
-
dirname:
|
|
110588
|
+
dirname: dirname18,
|
|
110548
110589
|
isAbsolute: isAbsolute7,
|
|
110549
110590
|
join: join57,
|
|
110550
110591
|
parse: parse3,
|
|
@@ -110648,7 +110689,7 @@ var require_polyfill = __commonJS({
|
|
|
110648
110689
|
}
|
|
110649
110690
|
__name(getStats, "getStats");
|
|
110650
110691
|
async function checkParentDir(destStat, src, dest, opts) {
|
|
110651
|
-
const destParent =
|
|
110692
|
+
const destParent = dirname18(dest);
|
|
110652
110693
|
const dirExists = await pathExists(destParent);
|
|
110653
110694
|
if (dirExists) {
|
|
110654
110695
|
return getStatsForCopy(destStat, src, dest, opts);
|
|
@@ -110666,8 +110707,8 @@ var require_polyfill = __commonJS({
|
|
|
110666
110707
|
}
|
|
110667
110708
|
__name(pathExists, "pathExists");
|
|
110668
110709
|
async function checkParentPaths(src, srcStat, dest) {
|
|
110669
|
-
const srcParent = resolve27(
|
|
110670
|
-
const destParent = resolve27(
|
|
110710
|
+
const srcParent = resolve27(dirname18(src));
|
|
110711
|
+
const destParent = resolve27(dirname18(dest));
|
|
110671
110712
|
if (destParent === srcParent || destParent === parse3(destParent).root) {
|
|
110672
110713
|
return;
|
|
110673
110714
|
}
|
|
@@ -110837,7 +110878,7 @@ var require_polyfill = __commonJS({
|
|
|
110837
110878
|
async function onLink(destStat, src, dest) {
|
|
110838
110879
|
let resolvedSrc = await readlink(src);
|
|
110839
110880
|
if (!isAbsolute7(resolvedSrc)) {
|
|
110840
|
-
resolvedSrc = resolve27(
|
|
110881
|
+
resolvedSrc = resolve27(dirname18(src), resolvedSrc);
|
|
110841
110882
|
}
|
|
110842
110883
|
if (!destStat) {
|
|
110843
110884
|
return symlink(resolvedSrc, dest);
|
|
@@ -110852,7 +110893,7 @@ var require_polyfill = __commonJS({
|
|
|
110852
110893
|
throw err;
|
|
110853
110894
|
}
|
|
110854
110895
|
if (!isAbsolute7(resolvedDest)) {
|
|
110855
|
-
resolvedDest = resolve27(
|
|
110896
|
+
resolvedDest = resolve27(dirname18(dest), resolvedDest);
|
|
110856
110897
|
}
|
|
110857
110898
|
if (isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
110858
110899
|
throw new ERR_FS_CP_EINVAL({
|
|
@@ -110958,7 +110999,7 @@ var require_readdir_scoped = __commonJS({
|
|
|
110958
110999
|
// node_modules/@npmcli/fs/lib/move-file.js
|
|
110959
111000
|
var require_move_file = __commonJS({
|
|
110960
111001
|
"node_modules/@npmcli/fs/lib/move-file.js"(exports, module) {
|
|
110961
|
-
var { dirname:
|
|
111002
|
+
var { dirname: dirname18, join: join57, resolve: resolve27, relative: relative15, isAbsolute: isAbsolute7 } = __require("path");
|
|
110962
111003
|
var fs2 = __require("fs/promises");
|
|
110963
111004
|
var pathExists = /* @__PURE__ */ __name(async (path3) => {
|
|
110964
111005
|
try {
|
|
@@ -110979,7 +111020,7 @@ var require_move_file = __commonJS({
|
|
|
110979
111020
|
if (!options2.overwrite && await pathExists(destination)) {
|
|
110980
111021
|
throw new Error(`The destination file exists: ${destination}`);
|
|
110981
111022
|
}
|
|
110982
|
-
await fs2.mkdir(
|
|
111023
|
+
await fs2.mkdir(dirname18(destination), { recursive: true });
|
|
110983
111024
|
try {
|
|
110984
111025
|
await fs2.rename(source, destination);
|
|
110985
111026
|
} catch (error3) {
|
|
@@ -111007,7 +111048,7 @@ var require_move_file = __commonJS({
|
|
|
111007
111048
|
}
|
|
111008
111049
|
let targetStat = "file";
|
|
111009
111050
|
try {
|
|
111010
|
-
targetStat = await fs2.stat(resolve27(
|
|
111051
|
+
targetStat = await fs2.stat(resolve27(dirname18(symSource), target));
|
|
111011
111052
|
if (targetStat.isDirectory()) {
|
|
111012
111053
|
targetStat = "junction";
|
|
111013
111054
|
}
|
|
@@ -139108,7 +139149,9 @@ var init_testing_jobs = __esm({
|
|
|
139108
139149
|
// dist/lib/testing-app.js
|
|
139109
139150
|
import { resolve as resolve26 } from "node:path";
|
|
139110
139151
|
import { createRequire as createRequire12 } from "node:module";
|
|
139111
|
-
import {
|
|
139152
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
139153
|
+
import { readdirSync as readdirSync10 } from "node:fs";
|
|
139154
|
+
import { dirname as dirname17, join as join56 } from "node:path";
|
|
139112
139155
|
async function openTestApp(options2 = {}) {
|
|
139113
139156
|
const root = resolve26(options2.projectDir ?? process.cwd());
|
|
139114
139157
|
const projectId = loadProjectConfig(root)?.project_id;
|
|
@@ -139158,6 +139201,17 @@ async function openTestApp(options2 = {}) {
|
|
|
139158
139201
|
const actor = { name, id, email: email2, roles, session, ...callerOf(session, () => {
|
|
139159
139202
|
routeWrites++;
|
|
139160
139203
|
}) };
|
|
139204
|
+
const refusedAs2 = session.expectRefused.bind(session);
|
|
139205
|
+
session.expectRefused = async (...args) => {
|
|
139206
|
+
const what = typeof args[0] === "string" ? args[0] : "";
|
|
139207
|
+
const op = args[1] && typeof args[1] === "object" && "operation" in args[1] ? ` ${args[1].operation}` : "";
|
|
139208
|
+
try {
|
|
139209
|
+
await refusedAs2(...args);
|
|
139210
|
+
results.check(`refused: ${name} ${what}${op}`, true);
|
|
139211
|
+
} catch (error3) {
|
|
139212
|
+
results.check(`refused: ${name} ${what}${op}`, false, error3);
|
|
139213
|
+
}
|
|
139214
|
+
};
|
|
139161
139215
|
actors.add(actor);
|
|
139162
139216
|
managedFileSession(session, root, id);
|
|
139163
139217
|
return actor;
|
|
@@ -139367,7 +139421,7 @@ async function openTestApp(options2 = {}) {
|
|
|
139367
139421
|
}
|
|
139368
139422
|
const reply = settled.value;
|
|
139369
139423
|
const leaked = lacks.findIndex((text) => text && reply.text.includes(text));
|
|
139370
|
-
const refused = allowed.includes(reply.status) || request2[0] === "DATA" && options3.status === void 0 && empty(reply);
|
|
139424
|
+
const refused = allowed.includes(reply.status) || request2[0] === "DATA" && options3.status === void 0 && empty(reply) || lacks.length > 0 && reply.ok && leaked < 0;
|
|
139371
139425
|
if (!refused) {
|
|
139372
139426
|
results.expect(reply, allowed, line);
|
|
139373
139427
|
all = false;
|
|
@@ -139547,6 +139601,47 @@ function replySummary(reply) {
|
|
|
139547
139601
|
const message3 = typeof body.message === "string" ? body.message : void 0;
|
|
139548
139602
|
return `${reply.status}${reply.requestId ? ` (request ${reply.requestId})` : ""}${code ? ` ${code}` : ""}${message3 ? `: ${cut(message3, 200)}` : ""}`;
|
|
139549
139603
|
}
|
|
139604
|
+
function findPlaywright(root, given) {
|
|
139605
|
+
if (given && typeof given === "object")
|
|
139606
|
+
return given;
|
|
139607
|
+
const require6 = createRequire12(join56(root, "package.json"));
|
|
139608
|
+
const load2 = /* @__PURE__ */ __name((name) => {
|
|
139609
|
+
try {
|
|
139610
|
+
const pw = require6(name);
|
|
139611
|
+
return pw?.chromium ? pw : void 0;
|
|
139612
|
+
} catch {
|
|
139613
|
+
return void 0;
|
|
139614
|
+
}
|
|
139615
|
+
}, "load");
|
|
139616
|
+
for (const name of [given, process.env.PLAYWRIGHT_MODULE, process.env.PW_PATH, "playwright", "@playwright/test"]) {
|
|
139617
|
+
const pw = name ? load2(name) : void 0;
|
|
139618
|
+
if (pw)
|
|
139619
|
+
return pw;
|
|
139620
|
+
}
|
|
139621
|
+
const dirs = [];
|
|
139622
|
+
const browsers = process.env.PLAYWRIGHT_BROWSERS_PATH;
|
|
139623
|
+
if (browsers) {
|
|
139624
|
+
const parent = dirname17(resolve26(browsers));
|
|
139625
|
+
dirs.push(join56(parent, "node_modules"), ...readdirSafe(parent).map((entry) => join56(parent, entry, "node_modules")));
|
|
139626
|
+
}
|
|
139627
|
+
try {
|
|
139628
|
+
dirs.push(execFileSync2("npm", ["root", "-g"], { encoding: "utf8", timeout: 5e3 }).trim());
|
|
139629
|
+
} catch {
|
|
139630
|
+
}
|
|
139631
|
+
for (const dir of dirs) {
|
|
139632
|
+
const pw = load2(join56(dir, "playwright"));
|
|
139633
|
+
if (pw)
|
|
139634
|
+
return pw;
|
|
139635
|
+
}
|
|
139636
|
+
throw new Error("app.page() needs Playwright and could not find it here, in NODE_PATH, globally or next to PLAYWRIGHT_BROWSERS_PATH. Pass its path: openTestApp({ playwright: '/path/to/node_modules/playwright' }) or set PLAYWRIGHT_MODULE. Or install it: npm install -D playwright && npx playwright install chromium");
|
|
139637
|
+
}
|
|
139638
|
+
function readdirSafe(dir) {
|
|
139639
|
+
try {
|
|
139640
|
+
return readdirSync10(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).slice(0, 50);
|
|
139641
|
+
} catch {
|
|
139642
|
+
return [];
|
|
139643
|
+
}
|
|
139644
|
+
}
|
|
139550
139645
|
var SECRET_KEY, cut, Results, Pages;
|
|
139551
139646
|
var init_testing_app = __esm({
|
|
139552
139647
|
"dist/lib/testing-app.js"() {
|
|
@@ -139626,21 +139721,12 @@ var init_testing_app = __esm({
|
|
|
139626
139721
|
}
|
|
139627
139722
|
async open(state, path3) {
|
|
139628
139723
|
this.browser ??= (() => {
|
|
139629
|
-
const
|
|
139630
|
-
|
|
139631
|
-
|
|
139632
|
-
try {
|
|
139633
|
-
pw = require6(name);
|
|
139634
|
-
break;
|
|
139635
|
-
} catch {
|
|
139636
|
-
}
|
|
139637
|
-
}
|
|
139638
|
-
if (!pw?.chromium) {
|
|
139639
|
-
throw new Error("app.page() needs Playwright. If it is installed outside this folder, pass its path: openTestApp({ playwright: '/path/to/node_modules/playwright' }). Otherwise: npm install -D playwright && npx playwright install chromium");
|
|
139640
|
-
}
|
|
139641
|
-
return pw.chromium.launch();
|
|
139724
|
+
const pw = findPlaywright(this.root, this.playwright);
|
|
139725
|
+
const { chromium } = pw;
|
|
139726
|
+
return process.platform === "darwin" ? chromium.launch({ channel: "chrome" }).catch(() => chromium.launch()) : chromium.launch();
|
|
139642
139727
|
})();
|
|
139643
139728
|
const context = await (await this.browser).newContext({ baseURL: this.origin, storageState: state });
|
|
139729
|
+
context.setDefaultTimeout(1e4);
|
|
139644
139730
|
const page = await context.newPage();
|
|
139645
139731
|
await page.goto(path3);
|
|
139646
139732
|
if (await page.locator("html[data-sw-auth]").count()) {
|
|
@@ -139655,6 +139741,8 @@ var init_testing_app = __esm({
|
|
|
139655
139741
|
await (await browser).close();
|
|
139656
139742
|
}
|
|
139657
139743
|
};
|
|
139744
|
+
__name(findPlaywright, "findPlaywright");
|
|
139745
|
+
__name(readdirSafe, "readdirSafe");
|
|
139658
139746
|
}
|
|
139659
139747
|
});
|
|
139660
139748
|
|