@somewhere-cloud/cli 0.38.174 → 0.38.175
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 +4 -0
- package/dist/lib/bundle.js +292 -171
- package/dist/lib/bundle.js.map +3 -3
- package/dist/lib/files.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
package/dist/lib/bundle.js
CHANGED
|
@@ -76977,7 +76977,9 @@ var files_exports = {};
|
|
|
76977
76977
|
__export(files_exports, {
|
|
76978
76978
|
BINARY_EXTS: () => BINARY_EXTS,
|
|
76979
76979
|
IGNORE: () => IGNORE,
|
|
76980
|
+
MAX_DEPLOY_BLOB_BYTES: () => MAX_DEPLOY_BLOB_BYTES,
|
|
76980
76981
|
MAX_FILE_SIZE: () => MAX_FILE_SIZE,
|
|
76982
|
+
MAX_INLINE_DEPLOY_BYTES: () => MAX_INLINE_DEPLOY_BYTES,
|
|
76981
76983
|
SENSITIVE_FILE_REASON: () => SENSITIVE_FILE_REASON,
|
|
76982
76984
|
TEST_FOLDERS: () => TEST_FOLDERS,
|
|
76983
76985
|
classifyInto: () => classifyInto,
|
|
@@ -76996,7 +76998,7 @@ __export(files_exports, {
|
|
|
76996
76998
|
});
|
|
76997
76999
|
import { isUtf8 } from "node:buffer";
|
|
76998
77000
|
import { existsSync as existsSync13, readdirSync as readdirSync3, readFileSync as readFileSync15, statSync as statSync2 } from "node:fs";
|
|
76999
|
-
import { extname as extname3, isAbsolute as isAbsolute2, join as join16, relative as relative6 } from "node:path";
|
|
77001
|
+
import { extname as extname3, isAbsolute as isAbsolute2, join as join16, posix as posix2, relative as relative6 } from "node:path";
|
|
77000
77002
|
function isTestSourcePath(relPath) {
|
|
77001
77003
|
return TEST_SOURCE_NAME.test(relPath.slice(relPath.lastIndexOf("/") + 1));
|
|
77002
77004
|
}
|
|
@@ -77035,6 +77037,31 @@ function isFunctionPath(p2) {
|
|
|
77035
77037
|
function isBinaryPath2(p2) {
|
|
77036
77038
|
return BINARY_EXTS.has(extname3(p2).toLowerCase());
|
|
77037
77039
|
}
|
|
77040
|
+
function compilerAssetMatcher(sources) {
|
|
77041
|
+
const resolved = /* @__PURE__ */ new Set();
|
|
77042
|
+
const aliasedNames = /* @__PURE__ */ new Set();
|
|
77043
|
+
const scriptImports = /\b(?:import\s*(?:\(\s*|(?=['"])|[^;"'`]*?\bfrom\s*)|export\s+[^;"'`]*?\bfrom\s*|require\s*\(\s*|new\s+URL\s*\(\s*)(['"])([^'"\r\n]+)\1/g;
|
|
77044
|
+
const cssImports = /url\(\s*(?:"([^"]+)"|'([^']+)'|([^\s)]+))|@import\s+["']([^"']+)["']/g;
|
|
77045
|
+
for (const [file, source] of sources) {
|
|
77046
|
+
const stylesheet = /\.(?:css|scss|sass|less)$/i.test(file);
|
|
77047
|
+
const imports = stylesheet ? Array.from(source.matchAll(cssImports), (match) => match[1] ?? match[2] ?? match[3] ?? match[4]) : Array.from(source.matchAll(scriptImports), (match) => match[2]);
|
|
77048
|
+
for (const specifier of imports) {
|
|
77049
|
+
const path3 = specifier.split(/[?#]/, 1)[0];
|
|
77050
|
+
if (!path3 || path3.startsWith("//") || /^[a-z][a-z0-9+.-]*:/i.test(path3))
|
|
77051
|
+
continue;
|
|
77052
|
+
if (path3.startsWith("/"))
|
|
77053
|
+
resolved.add(posix2.normalize(path3).slice(1));
|
|
77054
|
+
else if (stylesheet || path3.startsWith("."))
|
|
77055
|
+
resolved.add(posix2.normalize(posix2.join(posix2.dirname(file), path3)));
|
|
77056
|
+
else
|
|
77057
|
+
aliasedNames.add(posix2.basename(path3));
|
|
77058
|
+
}
|
|
77059
|
+
}
|
|
77060
|
+
return (path3) => {
|
|
77061
|
+
const stem = path3.slice(0, path3.length - posix2.extname(path3).length);
|
|
77062
|
+
return resolved.has(path3) || resolved.has(stem) || aliasedNames.has(posix2.basename(path3)) || aliasedNames.has(posix2.basename(stem));
|
|
77063
|
+
};
|
|
77064
|
+
}
|
|
77038
77065
|
function collectFiles(baseDir, options2 = {}) {
|
|
77039
77066
|
const out = { dotfilesLeftOut: false, files: {}, binaryFiles: {}, functions: {}, skipped: [], oversize: [], notes: [], excluded: [], sensitive: [], published: [] };
|
|
77040
77067
|
const ignore = loadDeployIgnore(baseDir);
|
|
@@ -77102,8 +77129,24 @@ function collectFiles(baseDir, options2 = {}) {
|
|
|
77102
77129
|
}
|
|
77103
77130
|
out.sensitive.sort((a, b2) => a.path.localeCompare(b2.path));
|
|
77104
77131
|
}
|
|
77132
|
+
if (options2.deployBlobs && (publish.reduce((total, path3) => total + (sizes.get(path3) ?? 0), 0) > MAX_INLINE_DEPLOY_BYTES || publish.some((path3) => (sizes.get(path3) ?? 0) > MAX_FILE_SIZE))) {
|
|
77133
|
+
const compilerSources = corpusFiles(publish.filter((path3) => /\.(?:[cm]?[jt]sx?|css|scss|sass|less)$/i.test(path3)));
|
|
77134
|
+
const isCompilerAsset = compilerAssetMatcher(compilerSources);
|
|
77135
|
+
out.blobs = /* @__PURE__ */ new Map();
|
|
77136
|
+
for (const path3 of publish) {
|
|
77137
|
+
const size = sizes.get(path3) ?? 0;
|
|
77138
|
+
const served = path3.replace(/^public\//, "");
|
|
77139
|
+
if (classifyKey(path3).kind === "function" || /^(?:api|db|_lib|_compiled|_internal|_source)\//i.test(served) || /(?:^|\/)(?:package(?:-lock)?\.json|npm-shrinkwrap\.json|tsconfig[^/]*\.json)$/i.test(path3) || /\.(?:[cm]?[jt]sx?|css|scss|sass|less|html?|wasm)$/i.test(path3) || !(/^(?:public|static)\//.test(path3) || BINARY_EXTS.has(extname3(path3).toLowerCase()) || /\.(?:svg|json|csv)$/i.test(path3)) || isCompilerAsset(path3))
|
|
77140
|
+
continue;
|
|
77141
|
+
out.blobs.set(path3, size);
|
|
77142
|
+
}
|
|
77143
|
+
}
|
|
77105
77144
|
for (const relPath of publish) {
|
|
77106
77145
|
const bytes = sizes.get(relPath) ?? 0;
|
|
77146
|
+
if (out.blobs?.has(relPath) && bytes <= MAX_DEPLOY_BLOB_BYTES) {
|
|
77147
|
+
out.published.push(relPath);
|
|
77148
|
+
continue;
|
|
77149
|
+
}
|
|
77107
77150
|
if (bytes > MAX_FILE_SIZE) {
|
|
77108
77151
|
out.oversize.push({ path: relPath, bytes });
|
|
77109
77152
|
out.skipped.push({ path: relPath, reason: `${formatBytes(bytes)} exceeds the ${formatBytes(MAX_FILE_SIZE)} per-file limit` });
|
|
@@ -77357,7 +77400,7 @@ function sensitiveReferenceRefusal(collected) {
|
|
|
77357
77400
|
"If nothing loads it (for example, only a comment mentions it), add it to .somewhereignore or move it out of this folder, then run the command again."
|
|
77358
77401
|
].join("\n");
|
|
77359
77402
|
}
|
|
77360
|
-
var IGNORE, MAX_FILE_SIZE, BINARY_EXTS, TEST_SOURCE_NAME, TEST_FOLDERS, SENSITIVE_FILE_REASON, DeployIgnoreMatcher;
|
|
77403
|
+
var IGNORE, MAX_FILE_SIZE, MAX_DEPLOY_BLOB_BYTES, MAX_INLINE_DEPLOY_BYTES, BINARY_EXTS, TEST_SOURCE_NAME, TEST_FOLDERS, SENSITIVE_FILE_REASON, DeployIgnoreMatcher;
|
|
77361
77404
|
var init_files = __esm({
|
|
77362
77405
|
"dist/lib/files.js"() {
|
|
77363
77406
|
"use strict";
|
|
@@ -77379,6 +77422,8 @@ var init_files = __esm({
|
|
|
77379
77422
|
".vercel"
|
|
77380
77423
|
]);
|
|
77381
77424
|
MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
77425
|
+
MAX_DEPLOY_BLOB_BYTES = 25 * 1024 * 1024;
|
|
77426
|
+
MAX_INLINE_DEPLOY_BYTES = 20 * 1024 * 1024;
|
|
77382
77427
|
BINARY_EXTS = /* @__PURE__ */ new Set([
|
|
77383
77428
|
".png",
|
|
77384
77429
|
".jpg",
|
|
@@ -77416,6 +77461,7 @@ var init_files = __esm({
|
|
|
77416
77461
|
__name(isFunctionPath, "isFunctionPath");
|
|
77417
77462
|
__name(isBinaryPath2, "isBinaryPath");
|
|
77418
77463
|
SENSITIVE_FILE_REASON = "blocked by the sensitive-path policy \u2014 never uploaded";
|
|
77464
|
+
__name(compilerAssetMatcher, "compilerAssetMatcher");
|
|
77419
77465
|
__name(collectFiles, "collectFiles");
|
|
77420
77466
|
__name(walk, "walk");
|
|
77421
77467
|
__name(classifyKey, "classifyKey");
|
|
@@ -78856,6 +78902,60 @@ var init_build_errors = __esm({
|
|
|
78856
78902
|
}
|
|
78857
78903
|
});
|
|
78858
78904
|
|
|
78905
|
+
// dist/lib/deploy-blobs.js
|
|
78906
|
+
import { createReadStream } from "node:fs";
|
|
78907
|
+
import { join as join23 } from "node:path";
|
|
78908
|
+
async function uploadDeployBlobs(client, dir, projectId, paths, hashes) {
|
|
78909
|
+
const files = /* @__PURE__ */ new Map();
|
|
78910
|
+
for (const [path3, size] of paths) {
|
|
78911
|
+
const sha2563 = hashes[path3];
|
|
78912
|
+
files.set(sha2563, { sha256: sha2563, size, path: path3 });
|
|
78913
|
+
}
|
|
78914
|
+
process.stderr.write(`Checking ${paths.size} static files...
|
|
78915
|
+
`);
|
|
78916
|
+
const { missing } = await client.call("POST", "/deploy/blobs/check", {
|
|
78917
|
+
project_id: projectId,
|
|
78918
|
+
files: [...files.values()].map(({ sha256: sha2563, size }) => ({ sha256: sha2563, size }))
|
|
78919
|
+
}, void 0, { timeoutMs: LONG_CALL_TIMEOUT_MS });
|
|
78920
|
+
process.stderr.write(`Uploading ${missing.length} of ${files.size} distinct static files.
|
|
78921
|
+
`);
|
|
78922
|
+
let next = 0;
|
|
78923
|
+
let failure2;
|
|
78924
|
+
const query = new URLSearchParams({ project_id: projectId });
|
|
78925
|
+
await Promise.all(Array.from({ length: Math.min(missing.length, PARALLEL_UPLOADS) }, async () => {
|
|
78926
|
+
while (next < missing.length && !failure2) {
|
|
78927
|
+
const file = files.get(missing[next++]);
|
|
78928
|
+
if (!file)
|
|
78929
|
+
throw new Error("The deploy returned an unknown file hash.");
|
|
78930
|
+
try {
|
|
78931
|
+
const response = await client.callStream("PUT", `/deploy/blobs/${file.sha256}?${query}`, () => createReadStream(join23(dir, file.path)), {
|
|
78932
|
+
headers: { "Content-Type": "application/octet-stream", "Content-Length": String(file.size) },
|
|
78933
|
+
replayableBody: true,
|
|
78934
|
+
timeoutMs: LONG_CALL_TIMEOUT_MS
|
|
78935
|
+
});
|
|
78936
|
+
const answer = await response.json().catch(() => null);
|
|
78937
|
+
if (!response.ok || answer?.ok !== true) {
|
|
78938
|
+
throw new CliApiError(answer?.error ?? "BLOB_UPLOAD_FAILED", answer?.message ?? `Upload returned HTTP ${response.status}.`, response.status);
|
|
78939
|
+
}
|
|
78940
|
+
} catch (cause) {
|
|
78941
|
+
failure2 ??= new CliApiError(cause instanceof CliApiError ? cause.code : "BLOB_UPLOAD_FAILED", `Could not upload "${file.path}". ${cause instanceof Error ? cause.message : String(cause)}`, cause instanceof CliApiError ? cause.statusCode : 0);
|
|
78942
|
+
}
|
|
78943
|
+
}
|
|
78944
|
+
}));
|
|
78945
|
+
if (failure2)
|
|
78946
|
+
throw failure2;
|
|
78947
|
+
return Object.fromEntries([...paths.keys()].map((path3) => [path3, `sha256:${hashes[path3]}`]));
|
|
78948
|
+
}
|
|
78949
|
+
var PARALLEL_UPLOADS;
|
|
78950
|
+
var init_deploy_blobs = __esm({
|
|
78951
|
+
"dist/lib/deploy-blobs.js"() {
|
|
78952
|
+
"use strict";
|
|
78953
|
+
init_client();
|
|
78954
|
+
PARALLEL_UPLOADS = 8;
|
|
78955
|
+
__name(uploadDeployBlobs, "uploadDeployBlobs");
|
|
78956
|
+
}
|
|
78957
|
+
});
|
|
78958
|
+
|
|
78859
78959
|
// dist/lib/temp-auth.js
|
|
78860
78960
|
import { createHash as createHash5 } from "node:crypto";
|
|
78861
78961
|
function leadingZeroBits(buf) {
|
|
@@ -78925,7 +79025,7 @@ var init_temp_auth = __esm({
|
|
|
78925
79025
|
|
|
78926
79026
|
// dist/lib/project-notices.js
|
|
78927
79027
|
import { existsSync as existsSync20, mkdirSync as mkdirSync11, readFileSync as readFileSync20, writeFileSync as writeFileSync14 } from "node:fs";
|
|
78928
|
-
import { dirname as dirname8, join as
|
|
79028
|
+
import { dirname as dirname8, join as join24 } from "node:path";
|
|
78929
79029
|
function localDay(now2) {
|
|
78930
79030
|
const date4 = new Date(now2);
|
|
78931
79031
|
return [date4.getFullYear(), date4.getMonth() + 1, date4.getDate()].map((part) => String(part).padStart(2, "0")).join("-");
|
|
@@ -78950,7 +79050,7 @@ function formatProjectNotice(notice) {
|
|
|
78950
79050
|
async function showProjectNotices(client, projectRef3, options2 = {}) {
|
|
78951
79051
|
const now2 = options2.now ?? Date.now();
|
|
78952
79052
|
const day = localDay(now2);
|
|
78953
|
-
const statePath = options2.statePath ??
|
|
79053
|
+
const statePath = options2.statePath ?? join24(cliConfigDir(), "project-notices.json");
|
|
78954
79054
|
const write = options2.write ?? ((line) => process.stderr.write(`${line}
|
|
78955
79055
|
`));
|
|
78956
79056
|
try {
|
|
@@ -78987,7 +79087,7 @@ var init_project_notices = __esm({
|
|
|
78987
79087
|
|
|
78988
79088
|
// dist/lib/test-identities.js
|
|
78989
79089
|
import { chmodSync as chmodSync2, existsSync as existsSync21, mkdirSync as mkdirSync12, readFileSync as readFileSync21, renameSync as renameSync3, rmSync as rmSync6, writeFileSync as writeFileSync15 } from "node:fs";
|
|
78990
|
-
import { join as
|
|
79090
|
+
import { join as join25 } from "node:path";
|
|
78991
79091
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
78992
79092
|
function parseActorSpecs(values) {
|
|
78993
79093
|
if (!values.length)
|
|
@@ -79023,7 +79123,7 @@ function productionOrigin(prodFallback, requested) {
|
|
|
79023
79123
|
return { origin, host };
|
|
79024
79124
|
}
|
|
79025
79125
|
function stateDir(root) {
|
|
79026
|
-
return
|
|
79126
|
+
return join25(root, TEST_STATE_DIR);
|
|
79027
79127
|
}
|
|
79028
79128
|
function ensurePrivateDir(dir) {
|
|
79029
79129
|
mkdirSync12(dir, { recursive: true, mode: 448 });
|
|
@@ -79036,7 +79136,7 @@ function writePrivateFile(path3, content) {
|
|
|
79036
79136
|
renameSync3(tmp, path3);
|
|
79037
79137
|
}
|
|
79038
79138
|
function ensureGitignored(root) {
|
|
79039
|
-
const path3 =
|
|
79139
|
+
const path3 = join25(root, ".gitignore");
|
|
79040
79140
|
if (!existsSync21(path3)) {
|
|
79041
79141
|
writeFileSync15(path3, `# somewhere test-users: private signed-in test state
|
|
79042
79142
|
${TEST_STATE_GITIGNORE_LINE}
|
|
@@ -79054,7 +79154,7 @@ ${TEST_STATE_GITIGNORE_LINE}
|
|
|
79054
79154
|
return "added";
|
|
79055
79155
|
}
|
|
79056
79156
|
function readManifest(root) {
|
|
79057
|
-
const path3 =
|
|
79157
|
+
const path3 = join25(stateDir(root), MANIFEST_FILE);
|
|
79058
79158
|
if (!existsSync21(path3))
|
|
79059
79159
|
return null;
|
|
79060
79160
|
const invalid = /* @__PURE__ */ __name((why) => Object.assign(new Error(`${path3} is not a valid test-users manifest (${why}); nothing was changed.`), { code: "MANIFEST_INVALID" }), "invalid");
|
|
@@ -79084,7 +79184,7 @@ function preparedActorState(root, target, name) {
|
|
|
79084
79184
|
if (!actor || manifest?.project_id !== target.projectId || manifest.origin !== target.origin) {
|
|
79085
79185
|
throw new Error("No prepared actor for this app. Run somewhere test-users prepare with the actor name.");
|
|
79086
79186
|
}
|
|
79087
|
-
const path3 =
|
|
79187
|
+
const path3 = join25(stateDir(root), actor.state_file);
|
|
79088
79188
|
const domain = new URL(target.origin).hostname;
|
|
79089
79189
|
let state;
|
|
79090
79190
|
try {
|
|
@@ -79098,7 +79198,7 @@ function preparedActorState(root, target, name) {
|
|
|
79098
79198
|
return { path: path3, state: { cookies: state.cookies, origins: state.origins ?? [] }, access: token };
|
|
79099
79199
|
}
|
|
79100
79200
|
function writeManifest(root, manifest) {
|
|
79101
|
-
writePrivateFile(
|
|
79201
|
+
writePrivateFile(join25(stateDir(root), MANIFEST_FILE), JSON.stringify(manifest, null, 2) + "\n");
|
|
79102
79202
|
}
|
|
79103
79203
|
function tokenTimes(accessToken) {
|
|
79104
79204
|
const part = accessToken.split(".")[1];
|
|
@@ -79213,7 +79313,7 @@ function removeStateFiles(root, actors) {
|
|
|
79213
79313
|
for (const actor of actors) {
|
|
79214
79314
|
if (!ACTOR.test(actor.name) || actor.state_file !== `${actor.name}.state.json`)
|
|
79215
79315
|
continue;
|
|
79216
|
-
const path3 =
|
|
79316
|
+
const path3 = join25(stateDir(root), actor.state_file);
|
|
79217
79317
|
if (existsSync21(path3)) {
|
|
79218
79318
|
rmSync6(path3, { force: true });
|
|
79219
79319
|
removed.push(actor.state_file);
|
|
@@ -79225,7 +79325,7 @@ var TEST_STATE_DIR, TEST_STATE_GITIGNORE_LINE, MANIFEST_FILE, CLEANUP_RECEIPT_FI
|
|
|
79225
79325
|
var init_test_identities = __esm({
|
|
79226
79326
|
"dist/lib/test-identities.js"() {
|
|
79227
79327
|
"use strict";
|
|
79228
|
-
TEST_STATE_DIR =
|
|
79328
|
+
TEST_STATE_DIR = join25(".somewhere", "test");
|
|
79229
79329
|
TEST_STATE_GITIGNORE_LINE = ".somewhere/test/";
|
|
79230
79330
|
MANIFEST_FILE = "manifest.json";
|
|
79231
79331
|
CLEANUP_RECEIPT_FILE = "cleanup-receipt.json";
|
|
@@ -79258,7 +79358,7 @@ var init_test_identities = __esm({
|
|
|
79258
79358
|
|
|
79259
79359
|
// dist/lib/form-accounts.js
|
|
79260
79360
|
import { existsSync as existsSync22, readdirSync as readdirSync4, readFileSync as readFileSync22, rmSync as rmSync7 } from "node:fs";
|
|
79261
|
-
import { join as
|
|
79361
|
+
import { join as join26 } from "node:path";
|
|
79262
79362
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
79263
79363
|
function readDeletionAnswer(ids, answer) {
|
|
79264
79364
|
const out = { done: [], kept: /* @__PURE__ */ new Map(), dropped: /* @__PURE__ */ new Map(), teamsDeleted: answer.groups_deleted ?? [] };
|
|
@@ -79334,12 +79434,12 @@ function generatedPassword() {
|
|
|
79334
79434
|
function accountsDir(root, projectId) {
|
|
79335
79435
|
if (!/^[A-Za-z0-9-]{1,64}$/.test(projectId))
|
|
79336
79436
|
throw new Error("Unexpected project id in the test run record.");
|
|
79337
|
-
return
|
|
79437
|
+
return join26(root, ".somewhere", "tests", "accounts", projectId);
|
|
79338
79438
|
}
|
|
79339
79439
|
function recordAttempt(control, root, email2) {
|
|
79340
79440
|
const dir = control.journalDir(root);
|
|
79341
79441
|
ensurePrivateDir(dir);
|
|
79342
|
-
const path3 =
|
|
79442
|
+
const path3 = join26(dir, `${Date.now()}-${randomBytes4(4).toString("hex")}.json`);
|
|
79343
79443
|
const record3 = {
|
|
79344
79444
|
project_id: control.projectId,
|
|
79345
79445
|
email: email2,
|
|
@@ -79387,7 +79487,7 @@ async function sweepAccounts(control, root) {
|
|
|
79387
79487
|
return result;
|
|
79388
79488
|
const pending = [];
|
|
79389
79489
|
for (const name of readdirSync4(dir).filter((entry) => /^\d+-[0-9a-f]{8}\.json$/.test(entry))) {
|
|
79390
|
-
const path3 =
|
|
79490
|
+
const path3 = join26(dir, name);
|
|
79391
79491
|
let record3;
|
|
79392
79492
|
try {
|
|
79393
79493
|
record3 = JSON.parse(readFileSync22(path3, "utf8"));
|
|
@@ -79578,9 +79678,9 @@ var init_test_target = __esm({
|
|
|
79578
79678
|
|
|
79579
79679
|
// dist/lib/preview-credential.js
|
|
79580
79680
|
import { existsSync as existsSync23, readFileSync as readFileSync23, unlinkSync as unlinkSync4 } from "node:fs";
|
|
79581
|
-
import { join as
|
|
79681
|
+
import { join as join27 } from "node:path";
|
|
79582
79682
|
function loadPreviewCredential(projectId, previewSessionId) {
|
|
79583
|
-
const path3 =
|
|
79683
|
+
const path3 = join27(cliConfigDir(), SUBDIR, fileName(projectId, previewSessionId));
|
|
79584
79684
|
if (!existsSync23(path3))
|
|
79585
79685
|
return null;
|
|
79586
79686
|
try {
|
|
@@ -79591,7 +79691,7 @@ function loadPreviewCredential(projectId, previewSessionId) {
|
|
|
79591
79691
|
}
|
|
79592
79692
|
}
|
|
79593
79693
|
function forgetPreviewCredential(projectId, previewSessionId) {
|
|
79594
|
-
const path3 =
|
|
79694
|
+
const path3 = join27(cliConfigDir(), SUBDIR, fileName(projectId, previewSessionId));
|
|
79595
79695
|
if (existsSync23(path3))
|
|
79596
79696
|
unlinkSync4(path3);
|
|
79597
79697
|
}
|
|
@@ -79629,9 +79729,9 @@ var init_preview_credential = __esm({
|
|
|
79629
79729
|
|
|
79630
79730
|
// dist/lib/preview-record.js
|
|
79631
79731
|
import { existsSync as existsSync24, mkdirSync as mkdirSync13, readFileSync as readFileSync24, rmSync as rmSync8, writeFileSync as writeFileSync16 } from "node:fs";
|
|
79632
|
-
import { join as
|
|
79732
|
+
import { join as join28 } from "node:path";
|
|
79633
79733
|
function loadPreviewRecord(dir, projectId) {
|
|
79634
|
-
const path3 =
|
|
79734
|
+
const path3 = join28(dir, PREVIEW_RECORD);
|
|
79635
79735
|
if (!existsSync24(path3))
|
|
79636
79736
|
return null;
|
|
79637
79737
|
try {
|
|
@@ -79644,11 +79744,11 @@ function loadPreviewRecord(dir, projectId) {
|
|
|
79644
79744
|
}
|
|
79645
79745
|
}
|
|
79646
79746
|
function savePreviewRecord(dir, record3) {
|
|
79647
|
-
mkdirSync13(
|
|
79648
|
-
writeFileSync16(
|
|
79747
|
+
mkdirSync13(join28(dir, ".somewhere"), { recursive: true });
|
|
79748
|
+
writeFileSync16(join28(dir, PREVIEW_RECORD), JSON.stringify({ ...record3, saved_at: (/* @__PURE__ */ new Date()).toISOString() }) + "\n");
|
|
79649
79749
|
}
|
|
79650
79750
|
function clearPreviewRecord(dir) {
|
|
79651
|
-
rmSync8(
|
|
79751
|
+
rmSync8(join28(dir, PREVIEW_RECORD), { force: true });
|
|
79652
79752
|
}
|
|
79653
79753
|
function openPreviewsFromStatus(status) {
|
|
79654
79754
|
const data2 = unwrapPlatformData(status);
|
|
@@ -79702,7 +79802,7 @@ var init_preview_record = __esm({
|
|
|
79702
79802
|
"dist/lib/preview-record.js"() {
|
|
79703
79803
|
"use strict";
|
|
79704
79804
|
init_platform_command();
|
|
79705
|
-
PREVIEW_RECORD =
|
|
79805
|
+
PREVIEW_RECORD = join28(".somewhere", "preview.json");
|
|
79706
79806
|
__name(loadPreviewRecord, "loadPreviewRecord");
|
|
79707
79807
|
__name(savePreviewRecord, "savePreviewRecord");
|
|
79708
79808
|
__name(clearPreviewRecord, "clearPreviewRecord");
|
|
@@ -79816,7 +79916,7 @@ var init_test_diagnostics = __esm({
|
|
|
79816
79916
|
});
|
|
79817
79917
|
|
|
79818
79918
|
// dist/lib/test-control.js
|
|
79819
|
-
import { join as
|
|
79919
|
+
import { join as join29 } from "node:path";
|
|
79820
79920
|
function productionControl(client, target, options2 = {}) {
|
|
79821
79921
|
const projectId = target.projectId;
|
|
79822
79922
|
return {
|
|
@@ -79956,7 +80056,7 @@ function previewControl(tool, target, _root) {
|
|
|
79956
80056
|
function previewAccountsDir(root, projectId, previewSessionId) {
|
|
79957
80057
|
if (!/^[A-Za-z0-9-]{1,64}$/.test(projectId) || !/^draft_[A-Za-z0-9-]{1,80}$/.test(previewSessionId))
|
|
79958
80058
|
throw new Error("Unexpected project or preview id in the test run record.");
|
|
79959
|
-
return
|
|
80059
|
+
return join29(root, ".somewhere", "tests", "preview-accounts", projectId, previewSessionId);
|
|
79960
80060
|
}
|
|
79961
80061
|
async function createPreviewManagedUser(tool) {
|
|
79962
80062
|
let created;
|
|
@@ -80037,14 +80137,14 @@ var init_test_connectivity = __esm({
|
|
|
80037
80137
|
// dist/lib/test-run.js
|
|
80038
80138
|
import { createRequire as createRequire7 } from "node:module";
|
|
80039
80139
|
import { pathToFileURL } from "node:url";
|
|
80040
|
-
import { join as
|
|
80140
|
+
import { join as join30, dirname as dirname9 } from "node:path";
|
|
80041
80141
|
import { spawn as spawn4, spawnSync as spawnSync3 } from "node:child_process";
|
|
80042
80142
|
import { appendFileSync as appendFileSync2, existsSync as existsSync25, readFileSync as readFileSync25, readdirSync as readdirSync5, rmSync as rmSync9 } from "node:fs";
|
|
80043
80143
|
import { createHash as createHash6, randomUUID as randomUUID6 } from "node:crypto";
|
|
80044
80144
|
function testImportEnv(root, env) {
|
|
80045
80145
|
if (!readProjectPin(root)?.versionOnly)
|
|
80046
80146
|
return env;
|
|
80047
|
-
const hook2 = pathToFileURL(
|
|
80147
|
+
const hook2 = pathToFileURL(join30(CLI_PACKAGE_ROOT, "bin", "starter-test-imports.mjs"));
|
|
80048
80148
|
return { ...env, NODE_OPTIONS: [env.NODE_OPTIONS, "--import=" + hook2.href].filter(Boolean).join(" ") };
|
|
80049
80149
|
}
|
|
80050
80150
|
function testDependencyError(root) {
|
|
@@ -80054,7 +80154,7 @@ function testDependencyError(root) {
|
|
|
80054
80154
|
return new Error(missingProjectDependencies(root).includes("@playwright/test") ? INSTALL_PROJECT_DEPENDENCIES : "Install project test dependencies: npm install -D @playwright/test @somewhere-cloud/cli");
|
|
80055
80155
|
}
|
|
80056
80156
|
async function prepareRunner(root) {
|
|
80057
|
-
const require6 = createRequire7(
|
|
80157
|
+
const require6 = createRequire7(join30(root, "package.json"));
|
|
80058
80158
|
let cli;
|
|
80059
80159
|
let pw;
|
|
80060
80160
|
try {
|
|
@@ -80074,7 +80174,7 @@ async function prepareRunner(root) {
|
|
|
80074
80174
|
throw error3;
|
|
80075
80175
|
channel = void 0;
|
|
80076
80176
|
process.stderr.write("Chrome is not installed; installing Playwright Chromium in the CLI cache.\n");
|
|
80077
|
-
process.env.PLAYWRIGHT_BROWSERS_PATH ??=
|
|
80177
|
+
process.env.PLAYWRIGHT_BROWSERS_PATH ??= join30(cliConfigDir(), "cache", "playwright");
|
|
80078
80178
|
const install = spawnSync3(process.execPath, [cli, "install", "chromium"], { stdio: "inherit", env: process.env });
|
|
80079
80179
|
if (install.status !== 0)
|
|
80080
80180
|
throw new Error("Playwright Chromium installation failed");
|
|
@@ -80086,7 +80186,7 @@ async function prepareRunner(root) {
|
|
|
80086
80186
|
mark("browser-probe:end");
|
|
80087
80187
|
let playwright = "unknown";
|
|
80088
80188
|
try {
|
|
80089
|
-
playwright = JSON.parse(readFileSync25(
|
|
80189
|
+
playwright = JSON.parse(readFileSync25(join30(dirname9(cli), "package.json"), "utf8")).version ?? "unknown";
|
|
80090
80190
|
} catch {
|
|
80091
80191
|
}
|
|
80092
80192
|
return { cli, channel, version: version2, browserLaunchMs, playwright };
|
|
@@ -80115,9 +80215,9 @@ async function runTests(input) {
|
|
|
80115
80215
|
throw new Error(`The live release is ${target.releaseId}, not ${input.expectRelease} from this deploy (another deploy or rollback happened), so the tests were not run.`);
|
|
80116
80216
|
}
|
|
80117
80217
|
const { origin } = target;
|
|
80118
|
-
const dir =
|
|
80218
|
+
const dir = join30(root, ".somewhere", "tests");
|
|
80119
80219
|
ensurePrivateDir(dir);
|
|
80120
|
-
const ignorePath =
|
|
80220
|
+
const ignorePath = join30(root, ".gitignore");
|
|
80121
80221
|
const ignored = existsSync25(ignorePath) ? readFileSync25(ignorePath, "utf8") : "";
|
|
80122
80222
|
for (const line of [".somewhere/", "playwright-report/", "test-results/"])
|
|
80123
80223
|
if (!ignored.split(/\r?\n/).includes(line))
|
|
@@ -80129,9 +80229,9 @@ ${line}
|
|
|
80129
80229
|
const files = options2.files ?? [];
|
|
80130
80230
|
const failed = Boolean(options2.failed);
|
|
80131
80231
|
const browser = `${prepared.channel ?? "chromium"} ${prepared.version}`;
|
|
80132
|
-
const artifacts =
|
|
80232
|
+
const artifacts = join30(dir, createHash6("sha256").update(projectId + origin + (target.environment === "preview" ? `${target.previewSessionId}:${target.releaseId}` : "")).digest("hex").slice(0, 16));
|
|
80133
80233
|
if (failed) {
|
|
80134
|
-
const lastRun =
|
|
80234
|
+
const lastRun = join30(artifacts, ".last-run.json");
|
|
80135
80235
|
if (!existsSync25(lastRun) || !JSON.parse(readFileSync25(lastRun, "utf8")).failedTests?.length) {
|
|
80136
80236
|
throw new Error("No failed tests are recorded from the last run here; run somewhere test.");
|
|
80137
80237
|
}
|
|
@@ -80140,9 +80240,9 @@ ${line}
|
|
|
80140
80240
|
process.env.SW_TEST_RUN = randomUUID6();
|
|
80141
80241
|
for (const line of describeSweep(await span("sweep:before", {}, () => sweepAccounts(control, root)), "Before this run"))
|
|
80142
80242
|
process.stderr.write(line + "\n");
|
|
80143
|
-
const config2 =
|
|
80243
|
+
const config2 = join30(dir, "runner.config.cjs");
|
|
80144
80244
|
const use = { baseURL: origin, channel: prepared.channel, trace: "off", video: "off", screenshot: "off", launchOptions: { args: ["--disable-features=AsyncDns"] } };
|
|
80145
|
-
writePrivateFile(config2, `module.exports = ${JSON.stringify({ testDir:
|
|
80245
|
+
writePrivateFile(config2, `module.exports = ${JSON.stringify({ testDir: join30(root, "tests"), testMatch: "**/*.spec.ts", fullyParallel: true, forbidOnly: !subset, retries: 0, workers: Number(options2.workers), outputDir: artifacts, reporter: [[join30(CLI_PACKAGE_ROOT, "dist", "lib", "test-reporter.js")]], use, ...options2.phone ? { projects: [{ name: "desktop" }, { name: "phone", use: { viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true } }] } : {} })};
|
|
80146
80246
|
`);
|
|
80147
80247
|
const args = [prepared.cli, "test", "--config", config2, ...files];
|
|
80148
80248
|
if (options2.grep)
|
|
@@ -80150,7 +80250,7 @@ ${line}
|
|
|
80150
80250
|
if (failed)
|
|
80151
80251
|
args.push("--last-failed");
|
|
80152
80252
|
const rerunFlags = `${options2.preview ? " --preview" : ""}${options2.phone ? " --phone" : ""}${options2.workers !== "5" ? ` --workers ${options2.workers}` : ""}`;
|
|
80153
|
-
const resultsPath =
|
|
80253
|
+
const resultsPath = join30(dir, "results.json");
|
|
80154
80254
|
rmSync9(resultsPath, { force: true });
|
|
80155
80255
|
mark("runner:spawn");
|
|
80156
80256
|
const child = spawn4(process.execPath, args, { cwd: root, stdio: ["inherit", input.toStderr ? "pipe" : "inherit", "inherit"], env: { ...runnerEnv, SW_TEST_TARGET: JSON.stringify(target), SW_TEST_RELEASE: target.releaseId, PLAYWRIGHT_NO_COPY_PROMPT: "1", SW_TEST_ORIGIN: origin, SW_TEST_BROWSER_LAUNCH_MS: String(prepared.browserLaunchMs), SW_TEST_BROWSER: browser, SW_TEST_SUBSET: String(subset), SW_TEST_JSON: String(Boolean(options2.json)), SW_TEST_RESULTS: resultsPath, SW_TEST_RUN: process.env.SW_TEST_RUN, SW_TEST_RUN_PID: String(process.pid), SW_TEST_RERUN_FLAGS: rerunFlags } });
|
|
@@ -80170,7 +80270,7 @@ ${line}
|
|
|
80170
80270
|
if (!existsSync25(path3))
|
|
80171
80271
|
return;
|
|
80172
80272
|
for (const entry of readdirSync5(path3, { withFileTypes: true })) {
|
|
80173
|
-
const file =
|
|
80273
|
+
const file = join30(path3, entry.name);
|
|
80174
80274
|
if (entry.isDirectory())
|
|
80175
80275
|
cleanArtifacts(file);
|
|
80176
80276
|
else if (entry.name !== ".last-run.json" && !entry.name.endsWith(".png"))
|
|
@@ -80855,26 +80955,26 @@ var init_browser_actions = __esm({
|
|
|
80855
80955
|
import { spawn as spawn5 } from "node:child_process";
|
|
80856
80956
|
import { existsSync as existsSync26, mkdtempSync, rmSync as rmSync10 } from "node:fs";
|
|
80857
80957
|
import { homedir as homedir3, tmpdir, userInfo } from "node:os";
|
|
80858
|
-
import { join as
|
|
80958
|
+
import { join as join31 } from "node:path";
|
|
80859
80959
|
import { readdirSync as readdirSync6 } from "node:fs";
|
|
80860
80960
|
function candidatePaths() {
|
|
80861
80961
|
const home = homedir3();
|
|
80862
80962
|
const out = [];
|
|
80863
80963
|
if (process.platform === "darwin") {
|
|
80864
|
-
out.push("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary", "/Applications/Chromium.app/Contents/MacOS/Chromium", "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge", "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser",
|
|
80964
|
+
out.push("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary", "/Applications/Chromium.app/Contents/MacOS/Chromium", "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge", "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser", join31(home, "Applications/Google Chrome.app/Contents/MacOS/Google Chrome"));
|
|
80865
80965
|
} else if (process.platform === "win32") {
|
|
80866
80966
|
const programFiles = [
|
|
80867
80967
|
process.env["PROGRAMFILES"] ?? "C:\\Program Files",
|
|
80868
80968
|
process.env["PROGRAMFILES(X86)"] ?? "C:\\Program Files (x86)",
|
|
80869
|
-
process.env["LOCALAPPDATA"] ??
|
|
80969
|
+
process.env["LOCALAPPDATA"] ?? join31(home, "AppData", "Local")
|
|
80870
80970
|
];
|
|
80871
80971
|
for (const base of programFiles) {
|
|
80872
|
-
out.push(
|
|
80972
|
+
out.push(join31(base, "Google\\Chrome\\Application\\chrome.exe"), join31(base, "Microsoft\\Edge\\Application\\msedge.exe"), join31(base, "Chromium\\Application\\chrome.exe"));
|
|
80873
80973
|
}
|
|
80874
80974
|
} else {
|
|
80875
80975
|
out.push("/usr/bin/google-chrome", "/usr/bin/google-chrome-stable", "/usr/bin/chromium", "/usr/bin/chromium-browser", "/usr/bin/microsoft-edge", "/snap/bin/chromium");
|
|
80876
80976
|
}
|
|
80877
|
-
out.push(...puppeteerCachePaths(
|
|
80977
|
+
out.push(...puppeteerCachePaths(join31(home, ".cache", "puppeteer")));
|
|
80878
80978
|
return out;
|
|
80879
80979
|
}
|
|
80880
80980
|
function puppeteerCachePaths(cacheDir) {
|
|
@@ -80890,13 +80990,13 @@ function puppeteerCachePaths(cacheDir) {
|
|
|
80890
80990
|
continue;
|
|
80891
80991
|
let builds;
|
|
80892
80992
|
try {
|
|
80893
|
-
builds = readdirSync6(
|
|
80993
|
+
builds = readdirSync6(join31(cacheDir, product)).sort().reverse();
|
|
80894
80994
|
} catch {
|
|
80895
80995
|
continue;
|
|
80896
80996
|
}
|
|
80897
80997
|
for (const build of builds) {
|
|
80898
|
-
const base =
|
|
80899
|
-
out.push(
|
|
80998
|
+
const base = join31(cacheDir, product, build);
|
|
80999
|
+
out.push(join31(base, "chrome-mac-arm64", "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"), join31(base, "chrome-mac-x64", "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"), join31(base, "chrome-linux64", "chrome"), join31(base, "chrome-win64", "chrome.exe"), join31(base, "chrome-headless-shell-mac-arm64", "chrome-headless-shell"), join31(base, "chrome-headless-shell-mac-x64", "chrome-headless-shell"), join31(base, "chrome-headless-shell-linux64", "chrome-headless-shell"), join31(base, "chrome-headless-shell-win64", "chrome-headless-shell.exe"));
|
|
80900
81000
|
}
|
|
80901
81001
|
}
|
|
80902
81002
|
return out;
|
|
@@ -80943,7 +81043,7 @@ function readEndpoint(child, timeoutMs) {
|
|
|
80943
81043
|
});
|
|
80944
81044
|
}
|
|
80945
81045
|
async function launchLocalBrowser(opts) {
|
|
80946
|
-
const profileDir = mkdtempSync(
|
|
81046
|
+
const profileDir = mkdtempSync(join31(tmpdir(), "somewhere-browser-"));
|
|
80947
81047
|
const browserEnv = process.platform === "darwin" ? { ...process.env, HOME: userInfo().homedir } : process.env;
|
|
80948
81048
|
const child = spawn5(opts.executablePath, [
|
|
80949
81049
|
"--headless=new",
|
|
@@ -81133,7 +81233,7 @@ var init_chrome = __esm({
|
|
|
81133
81233
|
|
|
81134
81234
|
// dist/lib/browser-run.js
|
|
81135
81235
|
import { writeFileSync as writeFileSync17 } from "node:fs";
|
|
81136
|
-
import { join as
|
|
81236
|
+
import { join as join32, resolve as resolve13 } from "node:path";
|
|
81137
81237
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
81138
81238
|
function isLoopbackUrl(raw) {
|
|
81139
81239
|
let url3;
|
|
@@ -81150,7 +81250,7 @@ function isLoopbackUrl(raw) {
|
|
|
81150
81250
|
return /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(host);
|
|
81151
81251
|
}
|
|
81152
81252
|
async function domOutlineScript() {
|
|
81153
|
-
const path3 =
|
|
81253
|
+
const path3 = join32(CLI_PACKAGE_ROOT, "runtime", "browser-probes.mjs");
|
|
81154
81254
|
const probes = await import(pathToFileURL2(path3).href);
|
|
81155
81255
|
return probes.DOM_OUTLINE_SCRIPT;
|
|
81156
81256
|
}
|
|
@@ -81677,15 +81777,15 @@ var init_browser_run = __esm({
|
|
|
81677
81777
|
|
|
81678
81778
|
// dist/lib/verify-report.js
|
|
81679
81779
|
import { chmodSync as chmodSync3, mkdirSync as mkdirSync14, mkdtempSync as mkdtempSync2, renameSync as renameSync4, writeFileSync as writeFileSync18 } from "node:fs";
|
|
81680
|
-
import { join as
|
|
81780
|
+
import { join as join33 } from "node:path";
|
|
81681
81781
|
function saveVerifyReport(report2) {
|
|
81682
|
-
const root =
|
|
81782
|
+
const root = join33(cliConfigDir(), "verify-reports");
|
|
81683
81783
|
mkdirSync14(root, { recursive: true, mode: 448 });
|
|
81684
81784
|
chmodSync3(root, 448);
|
|
81685
|
-
const directory2 = mkdtempSync2(
|
|
81785
|
+
const directory2 = mkdtempSync2(join33(root, "run-"));
|
|
81686
81786
|
chmodSync3(directory2, 448);
|
|
81687
|
-
const pending =
|
|
81688
|
-
const destination =
|
|
81787
|
+
const pending = join33(directory2, "report.pending");
|
|
81788
|
+
const destination = join33(directory2, "report.json");
|
|
81689
81789
|
writeFileSync18(pending, JSON.stringify(report2, null, 2) + "\n", { mode: 384, flag: "wx" });
|
|
81690
81790
|
renameSync4(pending, destination);
|
|
81691
81791
|
return destination;
|
|
@@ -82228,9 +82328,9 @@ var init_browser = __esm({
|
|
|
82228
82328
|
// dist/lib/verify-keep.js
|
|
82229
82329
|
import { createHash as createHash7, randomBytes as randomBytes5 } from "node:crypto";
|
|
82230
82330
|
import { closeSync as closeSync4, existsSync as existsSync27, openSync as openSync4, readFileSync as readFileSync28, rmSync as rmSync11, statSync as statSync5, writeSync } from "node:fs";
|
|
82231
|
-
import { join as
|
|
82331
|
+
import { join as join34 } from "node:path";
|
|
82232
82332
|
function path(root) {
|
|
82233
|
-
return
|
|
82333
|
+
return join34(stateDir(root), KEEP_FILE);
|
|
82234
82334
|
}
|
|
82235
82335
|
function readFile(root) {
|
|
82236
82336
|
if (!existsSync27(path(root)))
|
|
@@ -82291,7 +82391,7 @@ function reusableIdentities(entry, now2) {
|
|
|
82291
82391
|
}
|
|
82292
82392
|
function lockKeep(root, key, now2 = Date.now()) {
|
|
82293
82393
|
ensurePrivateDir(stateDir(root));
|
|
82294
|
-
const lock =
|
|
82394
|
+
const lock = join34(stateDir(root), `verify-actors-${key}.lock`);
|
|
82295
82395
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
82296
82396
|
try {
|
|
82297
82397
|
const fd = openSync4(lock, "wx", 384);
|
|
@@ -84251,7 +84351,7 @@ var init_verify = __esm({
|
|
|
84251
84351
|
|
|
84252
84352
|
// dist/commands/deploy.js
|
|
84253
84353
|
import { existsSync as existsSync29, readFileSync as readFileSync30 } from "node:fs";
|
|
84254
|
-
import { join as
|
|
84354
|
+
import { join as join35 } from "node:path";
|
|
84255
84355
|
import { basename as basename5, resolve as resolve16 } from "node:path";
|
|
84256
84356
|
function resolveTargetDir(dir, cwd = process.cwd()) {
|
|
84257
84357
|
return dir ? resolve16(cwd, dir) : cwd;
|
|
@@ -84627,7 +84727,8 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
84627
84727
|
const verifyFlow = opts.verify && !opts.dryRun ? loadVerifyFlow(typeof opts.verify === "string" ? opts.verify : void 0, targetDir) : void 0;
|
|
84628
84728
|
const collectionStartedAt = performance.now();
|
|
84629
84729
|
const collected = collectFiles(targetDir, {
|
|
84630
|
-
include: opts.include ?? []
|
|
84730
|
+
include: opts.include ?? [],
|
|
84731
|
+
deployBlobs: process.env.SOMEWHERE_DEPLOY_BLOBS === "1" && !opts.dryRun && opts.scope !== "functions"
|
|
84631
84732
|
});
|
|
84632
84733
|
const publishedHashes = hashFiles(targetDir, collected.published);
|
|
84633
84734
|
const collectionEndedAt = performance.now();
|
|
@@ -84643,7 +84744,8 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
84643
84744
|
error(sensitiveRefusal);
|
|
84644
84745
|
process.exit(1);
|
|
84645
84746
|
}
|
|
84646
|
-
const
|
|
84747
|
+
const tooLargeBlob = [...collected.blobs ?? []].find(([, size]) => size > MAX_DEPLOY_BLOB_BYTES);
|
|
84748
|
+
const sizeRefusal = tooLargeBlob ? `"${tooLargeBlob[0]}" exceeds the 25 MiB static file limit. Reduce its size or serve it from file storage.` : oversizeRefusal(collected);
|
|
84647
84749
|
if (sizeRefusal) {
|
|
84648
84750
|
if (opts.json)
|
|
84649
84751
|
printJsonError("FILE_TOO_LARGE", sizeRefusal);
|
|
@@ -84663,16 +84765,24 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
84663
84765
|
for (const [path3, content] of Object.entries(submittedFunctions))
|
|
84664
84766
|
sizes.set(path3, Buffer.byteLength(content));
|
|
84665
84767
|
const payloadBytes = [...sizes.values()].reduce((total, bytes) => total + bytes, 0);
|
|
84666
|
-
const limitBytes =
|
|
84768
|
+
const limitBytes = MAX_INLINE_DEPLOY_BYTES;
|
|
84667
84769
|
if (payloadBytes > limitBytes) {
|
|
84668
|
-
const message3 = `This deploy contains ${(payloadBytes / 1024 ** 2).toFixed(1)} MiB of files. The limit is 20 MiB per deploy. Move large assets to file storage before deploying.`;
|
|
84770
|
+
const message3 = `This deploy contains ${(payloadBytes / 1024 ** 2).toFixed(1)} MiB of files. The inline limit is 20 MiB per deploy. Move large assets to file storage before deploying.`;
|
|
84669
84771
|
if (opts.json)
|
|
84670
84772
|
printJsonError("DEPLOY_TOO_LARGE", message3, { payload_bytes: payloadBytes, limit_bytes: limitBytes });
|
|
84671
84773
|
else
|
|
84672
84774
|
error(message3);
|
|
84673
84775
|
process.exit(1);
|
|
84674
84776
|
}
|
|
84675
|
-
if (
|
|
84777
|
+
if (collected.blobs?.size && collected.published.length > 2e4) {
|
|
84778
|
+
const message3 = "A site can contain up to 20,000 files.";
|
|
84779
|
+
if (opts.json)
|
|
84780
|
+
printJsonError("DEPLOY_TOO_MANY_FILES", message3);
|
|
84781
|
+
else
|
|
84782
|
+
error(message3);
|
|
84783
|
+
process.exit(1);
|
|
84784
|
+
}
|
|
84785
|
+
if (!collected.blobs?.size && Object.keys(files).length === 0 && Object.keys(binaryFiles).length === 0 && Object.keys(functions).length === 0) {
|
|
84676
84786
|
const message3 = `No deployable source found. Create an index.html or add raw app source files, or add API handlers under api/, then run \`${cliInvocation()} deploy\` again.`;
|
|
84677
84787
|
if (opts.json)
|
|
84678
84788
|
printJsonError("NO_DEPLOYABLE_SOURCE", message3);
|
|
@@ -84687,7 +84797,7 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
84687
84797
|
const sourceUnchanged = !opts.project && !opts.temporary && unchangedSinceLastPublish(foundProjectEntry, targetDir, publishedHashes);
|
|
84688
84798
|
if (sourceUnchanged)
|
|
84689
84799
|
process.stderr.write("No file changed since this folder's last deploy; types were not checked again.\n");
|
|
84690
|
-
const hasTsconfig = !sourceUnchanged && existsSync29(
|
|
84800
|
+
const hasTsconfig = !sourceUnchanged && existsSync29(join35(targetDir, "tsconfig.json"));
|
|
84691
84801
|
const missingDependencies = hasTsconfig && missingProjectDependencies(targetDir).length > 0;
|
|
84692
84802
|
const checkingTypes = hasTsconfig && !missingDependencies;
|
|
84693
84803
|
if (checkingTypes && typecheckCompilerSource(targetDir) === "npx") {
|
|
@@ -84993,8 +85103,12 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
84993
85103
|
if (process.stderr.isTTY)
|
|
84994
85104
|
spinner?.start();
|
|
84995
85105
|
}
|
|
84996
|
-
const totalFiles = Object.keys(files).length + Object.keys(binaryFiles).length + Object.keys(functions).length;
|
|
85106
|
+
const totalFiles = Object.keys(files).length + Object.keys(binaryFiles).length + (collected.blobs?.size ?? 0) + Object.keys(functions).length;
|
|
84997
85107
|
const inventory = uploadInventory(files, binaryFiles, functions, scope);
|
|
85108
|
+
if (collected.blobs?.size) {
|
|
85109
|
+
inventory.static_files.push(...collected.blobs.keys());
|
|
85110
|
+
inventory.static_files.sort((a, b2) => a.localeCompare(b2));
|
|
85111
|
+
}
|
|
84998
85112
|
if (opts.dryRun && !opts.json) {
|
|
84999
85113
|
spinner?.stop();
|
|
85000
85114
|
info(dim(`Dry run: sending ${totalFiles} files to Somewhere to check what would change. Nothing is published.`));
|
|
@@ -85109,6 +85223,12 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
85109
85223
|
}
|
|
85110
85224
|
return;
|
|
85111
85225
|
}
|
|
85226
|
+
if (collected.blobs?.size) {
|
|
85227
|
+
spinner?.stop();
|
|
85228
|
+
body.blob_files = await uploadDeployBlobs(client, targetDir, projectId, collected.blobs, publishedHashes);
|
|
85229
|
+
if (process.stderr.isTTY)
|
|
85230
|
+
spinner?.start();
|
|
85231
|
+
}
|
|
85112
85232
|
const requestStartedAt = performance.now();
|
|
85113
85233
|
deployRequestStartedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
85114
85234
|
const preparationMs = requestStartedAt - collectionEndedAt;
|
|
@@ -85573,7 +85693,7 @@ function withLocalEnvHint(warning, dir) {
|
|
|
85573
85693
|
if (!key)
|
|
85574
85694
|
return warning;
|
|
85575
85695
|
try {
|
|
85576
|
-
const source = readFileSync30(
|
|
85696
|
+
const source = readFileSync30(join35(dir, ".env"), "utf8");
|
|
85577
85697
|
if (new RegExp(`^\\s*(?:export\\s+)?${key}\\s*=`, "m").test(source)) {
|
|
85578
85698
|
return `${warning} Copy ${key} from your local .env file.`;
|
|
85579
85699
|
}
|
|
@@ -85890,6 +86010,7 @@ var init_deploy = __esm({
|
|
|
85890
86010
|
init_build_errors();
|
|
85891
86011
|
init_config();
|
|
85892
86012
|
init_project_urls();
|
|
86013
|
+
init_deploy_blobs();
|
|
85893
86014
|
init_files();
|
|
85894
86015
|
init_version();
|
|
85895
86016
|
init_temp_auth();
|
|
@@ -86087,7 +86208,7 @@ var init_deploys = __esm({
|
|
|
86087
86208
|
|
|
86088
86209
|
// dist/commands/pull.js
|
|
86089
86210
|
import { existsSync as existsSync30, lstatSync as lstatSync4, mkdirSync as mkdirSync15, readFileSync as readFileSync31, readdirSync as readdirSync7, rmSync as rmSync12, writeFileSync as writeFileSync19 } from "node:fs";
|
|
86090
|
-
import { basename as basename6, dirname as dirname12, join as
|
|
86211
|
+
import { basename as basename6, dirname as dirname12, join as join36, relative as relative10, resolve as resolve17 } from "node:path";
|
|
86091
86212
|
function registerPull(program2) {
|
|
86092
86213
|
program2.command("pull [project]").description(`Download a project's deployed source files to the current directory. Scaffolds a tsconfig.json + package.json (only if absent) so \`${cliInvocation()} typecheck\` can catch undefined symbols locally before you deploy. In a linked folder, plain pull is the safe update when live is newer: files you have not edited move to the live version, your local edits and local-only files (AGENTS.md, notes, tests) are kept, and it stops without writing anything if a file changed both here and live.`).option("--env <env>", "Environment to pull from (dev or prod)", "prod").option("--out <dir>", "Output directory", ".").option("--force", "Also replace files you edited here with live, and delete published files you edited that live no longer has. Never deletes a file a deploy would not upload (AGENTS.md, CLAUDE.md, README.md, tests, dotfiles, .somewhereignore matches)").option("--json", "Print the raw source response as JSON").action(async (projectArg, opts) => {
|
|
86093
86214
|
const token = getToken();
|
|
@@ -86124,7 +86245,7 @@ function registerPull(program2) {
|
|
|
86124
86245
|
}
|
|
86125
86246
|
spinner?.stop();
|
|
86126
86247
|
const deployStateEntry = loadProjectConfigEntry(outDir);
|
|
86127
|
-
const configStat = lstatSync4(
|
|
86248
|
+
const configStat = lstatSync4(join36(outDir, ".somewhere.json"), { throwIfNoEntry: false });
|
|
86128
86249
|
if (configStat && (configStat.isSymbolicLink() || !configStat.isFile() || !deployStateEntry)) {
|
|
86129
86250
|
error("Cannot read the destination .somewhere.json. Pull into a fresh folder or repair the link first.");
|
|
86130
86251
|
process.exit(1);
|
|
@@ -86160,7 +86281,7 @@ function registerPull(program2) {
|
|
|
86160
86281
|
if (i < parts.length && source.has(parts.slice(0, i).join("/"))) {
|
|
86161
86282
|
throw new Error(`Conflicting exported source path: ${path3}`);
|
|
86162
86283
|
}
|
|
86163
|
-
const target2 =
|
|
86284
|
+
const target2 = join36(outDir, ...parts.slice(0, i));
|
|
86164
86285
|
const stat7 = lstatSync4(target2, { throwIfNoEntry: false });
|
|
86165
86286
|
if (!stat7)
|
|
86166
86287
|
continue;
|
|
@@ -86168,7 +86289,7 @@ function registerPull(program2) {
|
|
|
86168
86289
|
throw new Error(`Pull would conflict with local path ${path3}. Pull into a fresh folder.`);
|
|
86169
86290
|
}
|
|
86170
86291
|
}
|
|
86171
|
-
const target =
|
|
86292
|
+
const target = join36(outDir, path3);
|
|
86172
86293
|
if (!existsSync30(target))
|
|
86173
86294
|
continue;
|
|
86174
86295
|
const local = readFileSync31(target);
|
|
@@ -86196,7 +86317,7 @@ function registerPull(program2) {
|
|
|
86196
86317
|
}
|
|
86197
86318
|
const written = [];
|
|
86198
86319
|
const writeOne = /* @__PURE__ */ __name((relPath, contents) => {
|
|
86199
|
-
const target =
|
|
86320
|
+
const target = join36(outDir, relPath);
|
|
86200
86321
|
if (existsSync30(target) && !overwrite.has(relPath)) {
|
|
86201
86322
|
return;
|
|
86202
86323
|
}
|
|
@@ -86259,18 +86380,18 @@ function registerPull(program2) {
|
|
|
86259
86380
|
}
|
|
86260
86381
|
function scaffoldTypecheckFiles(outDir, staticFiles) {
|
|
86261
86382
|
const added = [];
|
|
86262
|
-
const tsconfigPath =
|
|
86383
|
+
const tsconfigPath = join36(outDir, SCAFFOLD_TSCONFIG_FILENAME);
|
|
86263
86384
|
if (!existsSync30(tsconfigPath)) {
|
|
86264
86385
|
writeFileSync19(tsconfigPath, buildScaffoldTsconfig());
|
|
86265
86386
|
added.push(SCAFFOLD_TSCONFIG_FILENAME);
|
|
86266
86387
|
}
|
|
86267
|
-
const packagePath =
|
|
86388
|
+
const packagePath = join36(outDir, SCAFFOLD_PACKAGE_FILENAME);
|
|
86268
86389
|
if (!existsSync30(packagePath)) {
|
|
86269
86390
|
const deps = extractDeps(staticFiles["package.json"]);
|
|
86270
86391
|
writeFileSync19(packagePath, buildScaffoldPackageJson(basename6(outDir), deps));
|
|
86271
86392
|
added.push(SCAFFOLD_PACKAGE_FILENAME);
|
|
86272
86393
|
}
|
|
86273
|
-
const gitignorePath =
|
|
86394
|
+
const gitignorePath = join36(outDir, SCAFFOLD_GITIGNORE_FILENAME);
|
|
86274
86395
|
if (!existsSync30(gitignorePath)) {
|
|
86275
86396
|
writeFileSync19(gitignorePath, buildScaffoldGitignore());
|
|
86276
86397
|
added.push(SCAFFOLD_GITIGNORE_FILENAME);
|
|
@@ -86292,7 +86413,7 @@ function reconcileRemovedFiles(outDir, expected, force, base = null) {
|
|
|
86292
86413
|
for (const entry of readdirSync7(dir, { withFileTypes: true })) {
|
|
86293
86414
|
if (IGNORE.has(entry.name) || entry.name.startsWith(".") && entry.name !== ".well-known")
|
|
86294
86415
|
continue;
|
|
86295
|
-
const fullPath =
|
|
86416
|
+
const fullPath = join36(dir, entry.name);
|
|
86296
86417
|
if (entry.isDirectory()) {
|
|
86297
86418
|
walk2(fullPath);
|
|
86298
86419
|
continue;
|
|
@@ -87176,7 +87297,7 @@ var init_db_rows = __esm({
|
|
|
87176
87297
|
import { createWriteStream as createWriteStream2, writeFileSync as writeFileSync20 } from "node:fs";
|
|
87177
87298
|
import { rename, unlink } from "node:fs/promises";
|
|
87178
87299
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
87179
|
-
import { basename as basename7, dirname as dirname13, join as
|
|
87300
|
+
import { basename as basename7, dirname as dirname13, join as join37 } from "node:path";
|
|
87180
87301
|
import { Readable as Readable2 } from "node:stream";
|
|
87181
87302
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
87182
87303
|
async function backgroundExport(client, projectId, plane, output, json, spinner) {
|
|
@@ -87208,7 +87329,7 @@ async function backgroundExport(client, projectId, plane, output, json, spinner)
|
|
|
87208
87329
|
throw new Error(`Downloading the export failed (HTTP ${response.status}).`);
|
|
87209
87330
|
const body = Readable2.fromWeb(response.body);
|
|
87210
87331
|
if (output) {
|
|
87211
|
-
const temp =
|
|
87332
|
+
const temp = join37(dirname13(output), `.${basename7(output)}.${randomUUID7()}.tmp`);
|
|
87212
87333
|
try {
|
|
87213
87334
|
await pipeline2(body, createWriteStream2(temp, { flags: "wx", mode: 384 }));
|
|
87214
87335
|
await rename(temp, output);
|
|
@@ -87888,16 +88009,16 @@ var init_postgres = __esm({
|
|
|
87888
88009
|
|
|
87889
88010
|
// dist/lib/local-docs.js
|
|
87890
88011
|
import { appendFileSync as appendFileSync3, existsSync as existsSync31, lstatSync as lstatSync5, mkdirSync as mkdirSync16, mkdtempSync as mkdtempSync3, readFileSync as readFileSync33, renameSync as renameSync5, rmSync as rmSync13, writeFileSync as writeFileSync21 } from "node:fs";
|
|
87891
|
-
import { join as
|
|
88012
|
+
import { join as join38 } from "node:path";
|
|
87892
88013
|
function localDocsVersion(root = process.cwd()) {
|
|
87893
|
-
const path3 =
|
|
88014
|
+
const path3 = join38(root, FOLDER, DOCS, STAMP);
|
|
87894
88015
|
if (!existsSync31(path3))
|
|
87895
88016
|
return void 0;
|
|
87896
88017
|
const stamp2 = JSON.parse(readFileSync33(path3, "utf8"));
|
|
87897
88018
|
return typeof stamp2.version === "string" && /^[a-f0-9]{16}$/.test(stamp2.version) ? stamp2.version : void 0;
|
|
87898
88019
|
}
|
|
87899
88020
|
function ensureGitIgnore(root) {
|
|
87900
|
-
const path3 =
|
|
88021
|
+
const path3 = join38(root, ".gitignore");
|
|
87901
88022
|
const text = existsSync31(path3) ? readFileSync33(path3, "utf8") : "";
|
|
87902
88023
|
if (text.split(/\r?\n/).some((line) => line === ".somewhere/" || line === "/.somewhere/"))
|
|
87903
88024
|
return;
|
|
@@ -87905,8 +88026,8 @@ function ensureGitIgnore(root) {
|
|
|
87905
88026
|
`);
|
|
87906
88027
|
}
|
|
87907
88028
|
function saveLocalDocs(version2, files, root = process.cwd()) {
|
|
87908
|
-
const state =
|
|
87909
|
-
const target =
|
|
88029
|
+
const state = join38(root, FOLDER);
|
|
88030
|
+
const target = join38(state, DOCS);
|
|
87910
88031
|
if (existsSync31(state) && !lstatSync5(state).isDirectory())
|
|
87911
88032
|
throw new Error(`${state} must be a directory.`);
|
|
87912
88033
|
if (existsSync31(target) && (!lstatSync5(target).isDirectory() || !localDocsVersion(root))) {
|
|
@@ -87914,17 +88035,17 @@ function saveLocalDocs(version2, files, root = process.cwd()) {
|
|
|
87914
88035
|
}
|
|
87915
88036
|
ensureGitIgnore(root);
|
|
87916
88037
|
mkdirSync16(state, { recursive: true });
|
|
87917
|
-
const staging = mkdtempSync3(
|
|
87918
|
-
const next =
|
|
87919
|
-
const previous =
|
|
88038
|
+
const staging = mkdtempSync3(join38(state, "docs-pull-"));
|
|
88039
|
+
const next = join38(staging, "next");
|
|
88040
|
+
const previous = join38(staging, "previous");
|
|
87920
88041
|
let installed = false;
|
|
87921
88042
|
try {
|
|
87922
88043
|
mkdirSync16(next);
|
|
87923
88044
|
for (const [name, content] of files)
|
|
87924
|
-
writeFileSync21(
|
|
88045
|
+
writeFileSync21(join38(next, name), content, { flag: "wx" });
|
|
87925
88046
|
const pulledAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
87926
|
-
writeFileSync21(
|
|
87927
|
-
writeFileSync21(
|
|
88047
|
+
writeFileSync21(join38(next, STAMP), JSON.stringify({ version: version2, pulledAt }) + "\n");
|
|
88048
|
+
writeFileSync21(join38(next, "README.md"), `# Somewhere docs
|
|
87928
88049
|
|
|
87929
88050
|
Pulled platform docs version ${version2} on ${pulledAt}. Run \`${cliInvocation()} docs\` to check whether this copy is older than the current docs and \`${cliInvocation()} docs pull\` to refresh it.
|
|
87930
88051
|
`, { flag: "wx" });
|
|
@@ -88004,11 +88125,11 @@ var init_advisor_context = __esm({
|
|
|
88004
88125
|
// dist/lib/advisor-runs.js
|
|
88005
88126
|
import { randomBytes as randomBytes7, randomUUID as randomUUID8 } from "node:crypto";
|
|
88006
88127
|
import { chmodSync as chmodSync4, existsSync as existsSync32, mkdirSync as mkdirSync17, readFileSync as readFileSync35, renameSync as renameSync6, writeFileSync as writeFileSync22 } from "node:fs";
|
|
88007
|
-
import { join as
|
|
88128
|
+
import { join as join39 } from "node:path";
|
|
88008
88129
|
function path2(id) {
|
|
88009
88130
|
if (!/^[a-f0-9-]{36}$/i.test(id))
|
|
88010
88131
|
throw Error("Invalid Advisor request ID.");
|
|
88011
|
-
return
|
|
88132
|
+
return join39(directory(), id + ".json");
|
|
88012
88133
|
}
|
|
88013
88134
|
function save(record3) {
|
|
88014
88135
|
mkdirSync17(directory(), { recursive: true, mode: 448 });
|
|
@@ -88146,7 +88267,7 @@ var init_advisor_runs = __esm({
|
|
|
88146
88267
|
init_config();
|
|
88147
88268
|
init_http();
|
|
88148
88269
|
init_advisor_context();
|
|
88149
|
-
directory = /* @__PURE__ */ __name(() =>
|
|
88270
|
+
directory = /* @__PURE__ */ __name(() => join39(cliConfigDir(), "advisor-runs"), "directory");
|
|
88150
88271
|
__name(path2, "path");
|
|
88151
88272
|
__name(save, "save");
|
|
88152
88273
|
PAYLOAD_RETENTION_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -88165,7 +88286,7 @@ var init_advisor_runs = __esm({
|
|
|
88165
88286
|
// dist/lib/advisor-app.js
|
|
88166
88287
|
import { createHash as createHash8 } from "node:crypto";
|
|
88167
88288
|
import { existsSync as existsSync33, mkdirSync as mkdirSync18, readFileSync as readFileSync36, rmSync as rmSync14, writeFileSync as writeFileSync23 } from "node:fs";
|
|
88168
|
-
import { join as
|
|
88289
|
+
import { join as join40 } from "node:path";
|
|
88169
88290
|
async function gatherAdvisorApp(client, ref) {
|
|
88170
88291
|
const project = await client.call("GET", `/projects/${encodeURIComponent(ref)}`);
|
|
88171
88292
|
if (typeof project.id !== "string" || project.deleted === true)
|
|
@@ -88199,7 +88320,7 @@ async function gatherAdvisorApp(client, ref) {
|
|
|
88199
88320
|
}
|
|
88200
88321
|
function loadAdvisorTurns(dir, projectId, account, now2 = Date.now()) {
|
|
88201
88322
|
try {
|
|
88202
|
-
const saved = JSON.parse(readFileSync36(
|
|
88323
|
+
const saved = JSON.parse(readFileSync36(join40(dir, FILE), "utf8"));
|
|
88203
88324
|
if (saved.project_id !== projectId || saved.owner !== ownerOf(account) || !Array.isArray(saved.turns))
|
|
88204
88325
|
return [];
|
|
88205
88326
|
const last = saved.turns.at(-1);
|
|
@@ -88209,16 +88330,16 @@ function loadAdvisorTurns(dir, projectId, account, now2 = Date.now()) {
|
|
|
88209
88330
|
}
|
|
88210
88331
|
}
|
|
88211
88332
|
function saveAdvisorTurn(dir, projectId, account, earlier, turn) {
|
|
88212
|
-
mkdirSync18(
|
|
88213
|
-
writeFileSync23(
|
|
88333
|
+
mkdirSync18(join40(dir, DIR), { recursive: true, mode: 448 });
|
|
88334
|
+
writeFileSync23(join40(dir, FILE), JSON.stringify({ project_id: projectId, owner: ownerOf(account), turns: [...earlier, { question: turn.question.slice(0, 2e3), answer: turn.answer.slice(0, 3e3), at: turn.at }].slice(-3) }) + "\n", { mode: 384 });
|
|
88214
88335
|
ensureAdvisorStateIgnored(dir);
|
|
88215
88336
|
}
|
|
88216
88337
|
function clearAdvisorTurns(dir) {
|
|
88217
|
-
if (existsSync33(
|
|
88218
|
-
rmSync14(
|
|
88338
|
+
if (existsSync33(join40(dir, FILE)))
|
|
88339
|
+
rmSync14(join40(dir, FILE), { force: true });
|
|
88219
88340
|
}
|
|
88220
88341
|
function ensureAdvisorStateIgnored(dir) {
|
|
88221
|
-
const path3 =
|
|
88342
|
+
const path3 = join40(dir, ".gitignore");
|
|
88222
88343
|
const covered = [".somewhere/", ".somewhere", "/.somewhere/", "/.somewhere", ".somewhere/advisor-conversation.json"];
|
|
88223
88344
|
if (!existsSync33(path3)) {
|
|
88224
88345
|
writeFileSync23(path3, "# somewhere: local CLI state (Advisor follow-ups, test users)\n.somewhere/\n");
|
|
@@ -88238,7 +88359,7 @@ var init_advisor_app = __esm({
|
|
|
88238
88359
|
"use strict";
|
|
88239
88360
|
__name(gatherAdvisorApp, "gatherAdvisorApp");
|
|
88240
88361
|
DIR = ".somewhere";
|
|
88241
|
-
FILE =
|
|
88362
|
+
FILE = join40(DIR, "advisor-conversation.json");
|
|
88242
88363
|
IDLE_MS = 30 * 6e4;
|
|
88243
88364
|
ownerOf = /* @__PURE__ */ __name((account) => createHash8("sha256").update(`advisor:${account}`).digest("hex"), "ownerOf");
|
|
88244
88365
|
__name(loadAdvisorTurns, "loadAdvisorTurns");
|
|
@@ -90366,7 +90487,7 @@ var init_claim = __esm({
|
|
|
90366
90487
|
import { createRequire as createRequire9 } from "node:module";
|
|
90367
90488
|
import { realpathSync as realpathSync4 } from "node:fs";
|
|
90368
90489
|
import { createConnection, createServer as createNetServer } from "node:net";
|
|
90369
|
-
import { join as
|
|
90490
|
+
import { join as join41 } from "node:path";
|
|
90370
90491
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
90371
90492
|
function deployedOrigin(value) {
|
|
90372
90493
|
const url3 = new URL(value);
|
|
@@ -90464,7 +90585,7 @@ async function startFrontendDev(cwd, target, port = 8787, open4 = false) {
|
|
|
90464
90585
|
throw new Error(INSTALL_PROJECT_DEPENDENCIES);
|
|
90465
90586
|
let vitePath;
|
|
90466
90587
|
try {
|
|
90467
|
-
vitePath = createRequire9(
|
|
90588
|
+
vitePath = createRequire9(join41(cwd, "package.json")).resolve("vite");
|
|
90468
90589
|
} catch {
|
|
90469
90590
|
if (readProjectPin(cwd)?.versionOnly) {
|
|
90470
90591
|
throw new Error("Install the local frontend tools: npm install -D --save-exact vite@7.2.2");
|
|
@@ -90608,7 +90729,7 @@ var init_preview_jobs = __esm({
|
|
|
90608
90729
|
// dist/commands/dev.js
|
|
90609
90730
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
90610
90731
|
import { existsSync as existsSync36 } from "node:fs";
|
|
90611
|
-
import { join as
|
|
90732
|
+
import { join as join42, relative as relative11 } from "node:path";
|
|
90612
90733
|
function previewFinishedReason(err) {
|
|
90613
90734
|
if (!(err instanceof CliApiError) || err.code !== "DRAFT_SESSION_TERMINAL")
|
|
90614
90735
|
return null;
|
|
@@ -91596,7 +91717,7 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
|
|
|
91596
91717
|
const updateBinary = {};
|
|
91597
91718
|
const deleteKeys = [];
|
|
91598
91719
|
for (const rel of changed) {
|
|
91599
|
-
const abs =
|
|
91720
|
+
const abs = join42(cwd, rel);
|
|
91600
91721
|
if (!existsSync36(abs))
|
|
91601
91722
|
continue;
|
|
91602
91723
|
classifyInto({ files: updateFiles, functions: updateFunctions, binaryFiles: updateBinary }, cwd, rel);
|
|
@@ -91662,7 +91783,7 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
|
|
|
91662
91783
|
for (const rel of deleted)
|
|
91663
91784
|
delete nextFiles[rel];
|
|
91664
91785
|
for (const rel of changed)
|
|
91665
|
-
if (existsSync36(
|
|
91786
|
+
if (existsSync36(join42(cwd, rel)))
|
|
91666
91787
|
Object.assign(nextFiles, hashFiles(cwd, [rel]));
|
|
91667
91788
|
savePreviewRecord(cwd, { ...record3, preview_id: nextCandidate, files: nextFiles });
|
|
91668
91789
|
}
|
|
@@ -91858,7 +91979,7 @@ var init_dev = __esm({
|
|
|
91858
91979
|
|
|
91859
91980
|
// dist/commands/check.js
|
|
91860
91981
|
import { existsSync as existsSync37 } from "node:fs";
|
|
91861
|
-
import { join as
|
|
91982
|
+
import { join as join43, resolve as resolve21 } from "node:path";
|
|
91862
91983
|
function buildCheckBody(collected, projectId) {
|
|
91863
91984
|
const body = { project_id: projectId, files: collected.files };
|
|
91864
91985
|
if (Object.keys(collected.functions).length > 0)
|
|
@@ -91963,7 +92084,7 @@ async function runLocalPreflight(targetDir, collected, typecheck = async (dir) =
|
|
|
91963
92084
|
if (collected.excluded.length)
|
|
91964
92085
|
source.not_published = collected.excluded;
|
|
91965
92086
|
let typecheckStep;
|
|
91966
|
-
if (!existsSync37(
|
|
92087
|
+
if (!existsSync37(join43(targetDir, "tsconfig.json"))) {
|
|
91967
92088
|
typecheckStep = { name: "typecheck", status: "skipped", reason: MISSING_TSCONFIG_GUIDANCE };
|
|
91968
92089
|
} else if (missingProjectDependencies(targetDir).length) {
|
|
91969
92090
|
typecheckStep = { name: "typecheck", status: "skipped", reason: missingTypecheckDependenciesMessage() };
|
|
@@ -92156,7 +92277,7 @@ var init_check = __esm({
|
|
|
92156
92277
|
});
|
|
92157
92278
|
|
|
92158
92279
|
// dist/commands/api.js
|
|
92159
|
-
import { createReadStream } from "node:fs";
|
|
92280
|
+
import { createReadStream as createReadStream2 } from "node:fs";
|
|
92160
92281
|
import { stat as stat5 } from "node:fs/promises";
|
|
92161
92282
|
import { extname as extname5, resolve as resolve22 } from "node:path";
|
|
92162
92283
|
function registerApi(program2) {
|
|
@@ -92218,7 +92339,7 @@ function registerApi(program2) {
|
|
|
92218
92339
|
};
|
|
92219
92340
|
if (file)
|
|
92220
92341
|
headers["Content-Length"] = String(file.size);
|
|
92221
|
-
const response = await client.callStream(method.toUpperCase(), apiPath, () => source ?
|
|
92342
|
+
const response = await client.callStream(method.toUpperCase(), apiPath, () => source ? createReadStream2(source) : process.stdin, {
|
|
92222
92343
|
headers,
|
|
92223
92344
|
timeoutMs: LONG_CALL_TIMEOUT_MS,
|
|
92224
92345
|
replayableBody: Boolean(source)
|
|
@@ -92377,10 +92498,10 @@ var init_api2 = __esm({
|
|
|
92377
92498
|
});
|
|
92378
92499
|
|
|
92379
92500
|
// dist/commands/fs.js
|
|
92380
|
-
import { createReadStream as
|
|
92501
|
+
import { createReadStream as createReadStream3, createWriteStream as createWriteStream3 } from "node:fs";
|
|
92381
92502
|
import { stat as stat6, rename as rename2, unlink as unlink2 } from "node:fs/promises";
|
|
92382
92503
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
92383
|
-
import { basename as basename9, dirname as dirname14, extname as extname6, join as
|
|
92504
|
+
import { basename as basename9, dirname as dirname14, extname as extname6, join as join44, resolve as resolve23 } from "node:path";
|
|
92384
92505
|
import { pipeline as pipeline3 } from "node:stream/promises";
|
|
92385
92506
|
function registerFs(program2) {
|
|
92386
92507
|
const fs2 = program2.command("fs").description("Manage project file storage");
|
|
@@ -92395,7 +92516,7 @@ function registerFs(program2) {
|
|
|
92395
92516
|
throw new Error(`${local} is not a file.`);
|
|
92396
92517
|
const project = resolveProject(opts.project);
|
|
92397
92518
|
const client = new ApiClient(getToken());
|
|
92398
|
-
const result = await readEnvelope(await client.callStream("PUT", fsPath(project, remote), () =>
|
|
92519
|
+
const result = await readEnvelope(await client.callStream("PUT", fsPath(project, remote), () => createReadStream3(source), {
|
|
92399
92520
|
replayableBody: true,
|
|
92400
92521
|
timeoutMs: LONG_CALL_TIMEOUT_MS,
|
|
92401
92522
|
headers: {
|
|
@@ -92424,7 +92545,7 @@ function registerFs(program2) {
|
|
|
92424
92545
|
if (!response.body)
|
|
92425
92546
|
throw new Error("The server returned an empty file response.");
|
|
92426
92547
|
const destination = resolve23(local);
|
|
92427
|
-
tempPath =
|
|
92548
|
+
tempPath = join44(dirname14(destination), `.${basename9(destination)}.${randomUUID10()}.tmp`);
|
|
92428
92549
|
await pipeline3(response.body, createWriteStream3(tempPath, { flags: "wx" }));
|
|
92429
92550
|
await rename2(tempPath, destination);
|
|
92430
92551
|
tempPath = void 0;
|
|
@@ -110234,7 +110355,7 @@ var require_polyfill = __commonJS({
|
|
|
110234
110355
|
var {
|
|
110235
110356
|
dirname: dirname17,
|
|
110236
110357
|
isAbsolute: isAbsolute7,
|
|
110237
|
-
join:
|
|
110358
|
+
join: join54,
|
|
110238
110359
|
parse: parse3,
|
|
110239
110360
|
resolve: resolve27,
|
|
110240
110361
|
sep: sep2,
|
|
@@ -110515,8 +110636,8 @@ var require_polyfill = __commonJS({
|
|
|
110515
110636
|
const dir = await readdir3(src);
|
|
110516
110637
|
for (let i = 0; i < dir.length; i++) {
|
|
110517
110638
|
const item = dir[i];
|
|
110518
|
-
const srcItem =
|
|
110519
|
-
const destItem =
|
|
110639
|
+
const srcItem = join54(src, item);
|
|
110640
|
+
const destItem = join54(dest, item);
|
|
110520
110641
|
const { destStat } = await checkPaths(srcItem, destItem, opts);
|
|
110521
110642
|
await startCopy(destStat, srcItem, destItem, opts);
|
|
110522
110643
|
}
|
|
@@ -110592,7 +110713,7 @@ var require_cp = __commonJS({
|
|
|
110592
110713
|
// node_modules/@npmcli/fs/lib/with-temp-dir.js
|
|
110593
110714
|
var require_with_temp_dir = __commonJS({
|
|
110594
110715
|
"node_modules/@npmcli/fs/lib/with-temp-dir.js"(exports, module) {
|
|
110595
|
-
var { join:
|
|
110716
|
+
var { join: join54, sep: sep2 } = __require("path");
|
|
110596
110717
|
var getOptions = require_get_options();
|
|
110597
110718
|
var { mkdir, mkdtemp, rm } = __require("fs/promises");
|
|
110598
110719
|
var withTempDir = /* @__PURE__ */ __name(async (root, fn, opts) => {
|
|
@@ -110600,7 +110721,7 @@ var require_with_temp_dir = __commonJS({
|
|
|
110600
110721
|
copy: ["tmpPrefix"]
|
|
110601
110722
|
});
|
|
110602
110723
|
await mkdir(root, { recursive: true });
|
|
110603
|
-
const target = await mkdtemp(
|
|
110724
|
+
const target = await mkdtemp(join54(`${root}${sep2}`, options2.tmpPrefix || ""));
|
|
110604
110725
|
let err;
|
|
110605
110726
|
let result;
|
|
110606
110727
|
try {
|
|
@@ -110625,13 +110746,13 @@ var require_with_temp_dir = __commonJS({
|
|
|
110625
110746
|
var require_readdir_scoped = __commonJS({
|
|
110626
110747
|
"node_modules/@npmcli/fs/lib/readdir-scoped.js"(exports, module) {
|
|
110627
110748
|
var { readdir: readdir3 } = __require("fs/promises");
|
|
110628
|
-
var { join:
|
|
110749
|
+
var { join: join54 } = __require("path");
|
|
110629
110750
|
var readdirScoped = /* @__PURE__ */ __name(async (dir) => {
|
|
110630
110751
|
const results = [];
|
|
110631
110752
|
for (const item of await readdir3(dir)) {
|
|
110632
110753
|
if (item.startsWith("@")) {
|
|
110633
|
-
for (const scopedItem of await readdir3(
|
|
110634
|
-
results.push(
|
|
110754
|
+
for (const scopedItem of await readdir3(join54(dir, item))) {
|
|
110755
|
+
results.push(join54(item, scopedItem));
|
|
110635
110756
|
}
|
|
110636
110757
|
} else {
|
|
110637
110758
|
results.push(item);
|
|
@@ -110646,7 +110767,7 @@ var require_readdir_scoped = __commonJS({
|
|
|
110646
110767
|
// node_modules/@npmcli/fs/lib/move-file.js
|
|
110647
110768
|
var require_move_file = __commonJS({
|
|
110648
110769
|
"node_modules/@npmcli/fs/lib/move-file.js"(exports, module) {
|
|
110649
|
-
var { dirname: dirname17, join:
|
|
110770
|
+
var { dirname: dirname17, join: join54, resolve: resolve27, relative: relative15, isAbsolute: isAbsolute7 } = __require("path");
|
|
110650
110771
|
var fs2 = __require("fs/promises");
|
|
110651
110772
|
var pathExists = /* @__PURE__ */ __name(async (path3) => {
|
|
110652
110773
|
try {
|
|
@@ -110676,7 +110797,7 @@ var require_move_file = __commonJS({
|
|
|
110676
110797
|
if (sourceStat.isDirectory()) {
|
|
110677
110798
|
const files = await fs2.readdir(source);
|
|
110678
110799
|
await Promise.all(files.map(
|
|
110679
|
-
(file) => moveFile(
|
|
110800
|
+
(file) => moveFile(join54(source, file), join54(destination, file), options2, false, symlinks)
|
|
110680
110801
|
));
|
|
110681
110802
|
} else if (sourceStat.isSymbolicLink()) {
|
|
110682
110803
|
symlinks.push({ source, destination });
|
|
@@ -130044,12 +130165,12 @@ var require_url = __commonJS({
|
|
|
130044
130165
|
"node_modules/tuf-js/dist/utils/url.js"(exports) {
|
|
130045
130166
|
"use strict";
|
|
130046
130167
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
130047
|
-
exports.join =
|
|
130168
|
+
exports.join = join54;
|
|
130048
130169
|
var url_1 = __require("url");
|
|
130049
|
-
function
|
|
130170
|
+
function join54(base, path3) {
|
|
130050
130171
|
return new url_1.URL(ensureTrailingSlash(base) + removeLeadingSlash(path3)).toString();
|
|
130051
130172
|
}
|
|
130052
|
-
__name(
|
|
130173
|
+
__name(join54, "join");
|
|
130053
130174
|
function ensureTrailingSlash(path3) {
|
|
130054
130175
|
return path3.endsWith("/") ? path3 : path3 + "/";
|
|
130055
130176
|
}
|
|
@@ -132386,7 +132507,7 @@ var require_dist15 = __commonJS({
|
|
|
132386
132507
|
// dist/lib/update-security.js
|
|
132387
132508
|
import { createHash as createHash9, timingSafeEqual } from "node:crypto";
|
|
132388
132509
|
import { mkdirSync as mkdirSync19, readFileSync as readFileSync39, statSync as statSync7 } from "node:fs";
|
|
132389
|
-
import { join as
|
|
132510
|
+
import { join as join45 } from "node:path";
|
|
132390
132511
|
import { Readable as Readable3 } from "node:stream";
|
|
132391
132512
|
import { pipeline as pipeline4 } from "node:stream/promises";
|
|
132392
132513
|
function expectedTarballUrl(version2) {
|
|
@@ -132751,8 +132872,8 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
|
132751
132872
|
seen2.add(path3);
|
|
132752
132873
|
return true;
|
|
132753
132874
|
});
|
|
132754
|
-
const manifestPath =
|
|
132755
|
-
const lockPath =
|
|
132875
|
+
const manifestPath = join45(extractionDir, "package.json");
|
|
132876
|
+
const lockPath = join45(extractionDir, "npm-shrinkwrap.json");
|
|
132756
132877
|
let manifest;
|
|
132757
132878
|
let lock;
|
|
132758
132879
|
try {
|
|
@@ -132796,7 +132917,7 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
|
|
|
132796
132917
|
}
|
|
132797
132918
|
let bundledManifest;
|
|
132798
132919
|
try {
|
|
132799
|
-
const bundledPath =
|
|
132920
|
+
const bundledPath = join45(extractionDir, ...lockPath2.split("/"), "package.json");
|
|
132800
132921
|
bundledManifest = JSON.parse(readFileSync39(bundledPath, "utf8"));
|
|
132801
132922
|
} catch (cause) {
|
|
132802
132923
|
throw new Error(`the verified artifact has an unreadable bundled dependency ${lockPath2}: ${message(cause)}`);
|
|
@@ -132870,7 +132991,7 @@ import { randomBytes as randomBytes8 } from "node:crypto";
|
|
|
132870
132991
|
import { closeSync as closeSync5, constants as constants2, fstatSync, mkdtempSync as mkdtempSync4, openSync as openSync5, readFileSync as readFileSync40, readSync, rmSync as rmSync15, unlinkSync as unlinkSync5, writeFileSync as writeFileSync25 } from "node:fs";
|
|
132871
132992
|
import { createServer } from "node:http";
|
|
132872
132993
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
132873
|
-
import { join as
|
|
132994
|
+
import { join as join46 } from "node:path";
|
|
132874
132995
|
function refuse2(cause) {
|
|
132875
132996
|
error(`Update refused: ${message2(cause)}.`);
|
|
132876
132997
|
info(`To install the latest release with npm instead, run: ${teal(NPM_UPDATE_COMMAND)}`);
|
|
@@ -132878,7 +132999,7 @@ function refuse2(cause) {
|
|
|
132878
132999
|
}
|
|
132879
133000
|
function currentVersion2() {
|
|
132880
133001
|
try {
|
|
132881
|
-
const pkg = JSON.parse(readFileSync40(
|
|
133002
|
+
const pkg = JSON.parse(readFileSync40(join46(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
132882
133003
|
return pkg.version;
|
|
132883
133004
|
} catch {
|
|
132884
133005
|
return "0.0.0";
|
|
@@ -133017,10 +133138,10 @@ async function serveArtifactSnapshot(artifact) {
|
|
|
133017
133138
|
}
|
|
133018
133139
|
async function installVerifiedTarball(tarballPath, tempDir, release2) {
|
|
133019
133140
|
const ambientEnvironment = { ...process.env };
|
|
133020
|
-
const packageDir =
|
|
133021
|
-
const cacheDir =
|
|
133022
|
-
const userConfigPath =
|
|
133023
|
-
const globalConfigPath =
|
|
133141
|
+
const packageDir = join46(tempDir, "authenticated-package");
|
|
133142
|
+
const cacheDir = join46(tempDir, "empty-cache");
|
|
133143
|
+
const userConfigPath = join46(tempDir, "user-npmrc");
|
|
133144
|
+
const globalConfigPath = join46(tempDir, "global-npmrc");
|
|
133024
133145
|
writeFileSync25(userConfigPath, "", { mode: 384 });
|
|
133025
133146
|
writeFileSync25(globalConfigPath, "", { mode: 384 });
|
|
133026
133147
|
const artifact = snapshotAuthenticatedArtifact(tarballPath);
|
|
@@ -133092,8 +133213,8 @@ async function runUpdate(opts, dependencies = {}) {
|
|
|
133092
133213
|
const provenance = await fetchJson(fetchImpl, release2.attestationUrl, "the official npm provenance endpoint");
|
|
133093
133214
|
await (dependencies.verifyProvenance ?? verifyPublishedProvenance)(provenance, release2);
|
|
133094
133215
|
const tarball = await downloadTarball(fetchImpl, release2);
|
|
133095
|
-
tempDir = mkdtempSync4(
|
|
133096
|
-
const tarballPath =
|
|
133216
|
+
tempDir = mkdtempSync4(join46(tmpdir2(), "somewhere-update-"));
|
|
133217
|
+
const tarballPath = join46(tempDir, `cli-${release2.version}.tgz`);
|
|
133097
133218
|
writeFileSync25(tarballPath, tarball, { mode: 384 });
|
|
133098
133219
|
info(`Cryptographically verified provenance and integrity for ${CLI_PACKAGE}@${release2.version}.`);
|
|
133099
133220
|
info(`Updating ${CLI_PACKAGE} from its authenticated dependency lock \u2026`);
|
|
@@ -135578,7 +135699,7 @@ import { randomUUID as randomUUID12 } from "node:crypto";
|
|
|
135578
135699
|
import { setDefaultResultOrder } from "node:dns";
|
|
135579
135700
|
import { lookup } from "node:dns/promises";
|
|
135580
135701
|
import { existsSync as existsSync38, mkdirSync as mkdirSync20, readFileSync as readFileSync42, writeFileSync as writeFileSync26 } from "node:fs";
|
|
135581
|
-
import { basename as basename10, dirname as dirname15, join as
|
|
135702
|
+
import { basename as basename10, dirname as dirname15, join as join47, relative as relative12, resolve as resolve24 } from "node:path";
|
|
135582
135703
|
function launchOptions(extra = {}) {
|
|
135583
135704
|
return { ...extra, args: ["--disable-features=AsyncDns", ...extra.args ?? []] };
|
|
135584
135705
|
}
|
|
@@ -135628,7 +135749,7 @@ function undeployedChanges(root, projectId, preview = false) {
|
|
|
135628
135749
|
return null;
|
|
135629
135750
|
base = { project_id: record3.project_id, release_id: record3.preview_id, files: record3.files };
|
|
135630
135751
|
} else {
|
|
135631
|
-
const path3 =
|
|
135752
|
+
const path3 = join47(root, ".somewhere", "base-files.json");
|
|
135632
135753
|
if (!existsSync38(path3))
|
|
135633
135754
|
return null;
|
|
135634
135755
|
base = JSON.parse(readFileSync42(path3, "utf8"));
|
|
@@ -135801,7 +135922,7 @@ var init_app_test = __esm({
|
|
|
135801
135922
|
for (const line of describeSweep(await sweepAccounts(control, root), "Before this script"))
|
|
135802
135923
|
process.stderr.write(line + "\n");
|
|
135803
135924
|
const scriptName = process.argv[1] ? basename10(process.argv[1]).replace(/\.[cm]?[jt]s$/, "") : "app-check";
|
|
135804
|
-
const app = new _AppTest(root, control, resolve24(root, options2.results ??
|
|
135925
|
+
const app = new _AppTest(root, control, resolve24(root, options2.results ?? join47(".somewhere", `${scriptName}${preview ? "-preview" : ""}.json`)));
|
|
135805
135926
|
return app;
|
|
135806
135927
|
}
|
|
135807
135928
|
/** What this run tests: the project, environment, preview, origin and script. */
|
|
@@ -136575,7 +136696,7 @@ var init_reference_check_note = __esm({
|
|
|
136575
136696
|
// dist/lib/test-scripts.js
|
|
136576
136697
|
import { createRequire as createRequire10 } from "node:module";
|
|
136577
136698
|
import { existsSync as existsSync39, mkdirSync as mkdirSync21, readFileSync as readFileSync43, readdirSync as readdirSync8, rmSync as rmSync17, statSync as statSync8, writeFileSync as writeFileSync27 } from "node:fs";
|
|
136578
|
-
import { dirname as dirname16, join as
|
|
136699
|
+
import { dirname as dirname16, join as join48, relative as relative13, resolve as resolve25 } from "node:path";
|
|
136579
136700
|
import { spawn as spawn7, spawnSync as spawnSync5 } from "node:child_process";
|
|
136580
136701
|
function hasSpecFiles(root) {
|
|
136581
136702
|
const walk2 = /* @__PURE__ */ __name((dir) => {
|
|
@@ -136584,24 +136705,24 @@ function hasSpecFiles(root) {
|
|
|
136584
136705
|
for (const entry of readdirSync8(dir, { withFileTypes: true })) {
|
|
136585
136706
|
if (entry.name === "node_modules" || entry.name.startsWith("."))
|
|
136586
136707
|
continue;
|
|
136587
|
-
const path3 =
|
|
136708
|
+
const path3 = join48(dir, entry.name);
|
|
136588
136709
|
if (entry.isDirectory() ? walk2(path3) : /\.spec\.ts$/.test(entry.name))
|
|
136589
136710
|
return true;
|
|
136590
136711
|
}
|
|
136591
136712
|
return false;
|
|
136592
136713
|
}, "walk");
|
|
136593
|
-
return walk2(
|
|
136714
|
+
return walk2(join48(root, "tests"));
|
|
136594
136715
|
}
|
|
136595
136716
|
function listScripts(root, files) {
|
|
136596
136717
|
if (files.length)
|
|
136597
136718
|
return files.map((file) => relative13(root, resolve25(root, file)));
|
|
136598
|
-
const dir =
|
|
136719
|
+
const dir = join48(root, "tests");
|
|
136599
136720
|
if (!existsSync39(dir))
|
|
136600
136721
|
return [];
|
|
136601
|
-
return readdirSync8(dir).filter((name) => isScript(name) && statSync8(
|
|
136722
|
+
return readdirSync8(dir).filter((name) => isScript(name) && statSync8(join48(dir, name)).isFile()).sort().map((name) => join48("tests", name));
|
|
136602
136723
|
}
|
|
136603
136724
|
function scriptBrowserEnv(root) {
|
|
136604
|
-
const require6 = createRequire10(
|
|
136725
|
+
const require6 = createRequire10(join48(root, "package.json"));
|
|
136605
136726
|
let cli;
|
|
136606
136727
|
try {
|
|
136607
136728
|
cli = require6.resolve("@playwright/test/cli");
|
|
@@ -136612,7 +136733,7 @@ function scriptBrowserEnv(root) {
|
|
|
136612
136733
|
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" });
|
|
136613
136734
|
if (probe.status === 0)
|
|
136614
136735
|
return env;
|
|
136615
|
-
env.PLAYWRIGHT_BROWSERS_PATH ??=
|
|
136736
|
+
env.PLAYWRIGHT_BROWSERS_PATH ??= join48(cliConfigDir(), "cache", "playwright");
|
|
136616
136737
|
process.stderr.write("Installing Playwright Chromium in the CLI cache (once).\n");
|
|
136617
136738
|
const install = spawnSync5(process.execPath, [cli, "install", "chromium"], { stdio: "inherit", env });
|
|
136618
136739
|
if (install.status !== 0)
|
|
@@ -136635,7 +136756,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
136635
136756
|
env = testImportEnv(root, env);
|
|
136636
136757
|
const results = [];
|
|
136637
136758
|
for (const script of scripts) {
|
|
136638
|
-
if (!existsSync39(
|
|
136759
|
+
if (!existsSync39(join48(root, script))) {
|
|
136639
136760
|
results.push({ script, ok: false, exitCode: 1, ms: 0, reason: "no such file" });
|
|
136640
136761
|
continue;
|
|
136641
136762
|
}
|
|
@@ -136644,7 +136765,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
136644
136765
|
`);
|
|
136645
136766
|
const started = performance.now();
|
|
136646
136767
|
let output = "";
|
|
136647
|
-
const handOver =
|
|
136768
|
+
const handOver = join48(root, ".somewhere", "tests", `report-${results.length}.json`);
|
|
136648
136769
|
mkdirSync21(dirname16(handOver), { recursive: true });
|
|
136649
136770
|
rmSync17(handOver, { force: true });
|
|
136650
136771
|
const askedForBrowserLog = /(^|,)\s*(pw:browser|pw:\*|\*)\s*(,|$)/.test(env.DEBUG ?? "");
|
|
@@ -136707,7 +136828,7 @@ function describeScriptResults(results, options2 = {}) {
|
|
|
136707
136828
|
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;
|
|
136708
136829
|
}
|
|
136709
136830
|
function lastFailedScripts(root) {
|
|
136710
|
-
const path3 =
|
|
136831
|
+
const path3 = join48(root, LAST);
|
|
136711
136832
|
if (!existsSync39(path3))
|
|
136712
136833
|
return [];
|
|
136713
136834
|
try {
|
|
@@ -136717,10 +136838,10 @@ function lastFailedScripts(root) {
|
|
|
136717
136838
|
}
|
|
136718
136839
|
}
|
|
136719
136840
|
function recordScriptResults(root, results, rerunOnly) {
|
|
136720
|
-
const previous = rerunOnly && existsSync39(
|
|
136841
|
+
const previous = rerunOnly && existsSync39(join48(root, LAST)) ? JSON.parse(readFileSync43(join48(root, LAST), "utf8")).results ?? [] : [];
|
|
136721
136842
|
const merged = [...previous.filter((p2) => !results.some((r) => r.script === p2.script)), ...results];
|
|
136722
|
-
mkdirSync21(
|
|
136723
|
-
writeFileSync27(
|
|
136843
|
+
mkdirSync21(join48(root, ".somewhere", "tests"), { recursive: true });
|
|
136844
|
+
writeFileSync27(join48(root, LAST), JSON.stringify({ finished: (/* @__PURE__ */ new Date()).toISOString(), results: merged }, null, 2) + "\n");
|
|
136724
136845
|
}
|
|
136725
136846
|
var BROWSER_CRASH, BROWSER_CRASH_REASON, isScript, LAST;
|
|
136726
136847
|
var init_test_scripts = __esm({
|
|
@@ -136738,7 +136859,7 @@ var init_test_scripts = __esm({
|
|
|
136738
136859
|
__name(failureReason, "failureReason");
|
|
136739
136860
|
__name(runScripts, "runScripts");
|
|
136740
136861
|
__name(describeScriptResults, "describeScriptResults");
|
|
136741
|
-
LAST =
|
|
136862
|
+
LAST = join48(".somewhere", "tests", "scripts-last.json");
|
|
136742
136863
|
__name(lastFailedScripts, "lastFailedScripts");
|
|
136743
136864
|
__name(recordScriptResults, "recordScriptResults");
|
|
136744
136865
|
}
|
|
@@ -136834,7 +136955,7 @@ var init_test = __esm({
|
|
|
136834
136955
|
|
|
136835
136956
|
// dist/commands/test-users.js
|
|
136836
136957
|
import { existsSync as existsSync40, readFileSync as readFileSync44, rmSync as rmSync18 } from "node:fs";
|
|
136837
|
-
import { basename as basename11, join as
|
|
136958
|
+
import { basename as basename11, join as join49 } from "node:path";
|
|
136838
136959
|
import { randomBytes as randomBytes9 } from "node:crypto";
|
|
136839
136960
|
async function resolveTarget(projectOpt, originOpt) {
|
|
136840
136961
|
const root = process.cwd();
|
|
@@ -136935,7 +137056,7 @@ function registerTestUsers(program2) {
|
|
|
136935
137056
|
const record3 = /* @__PURE__ */ __name((spec, issued, receivedAt) => {
|
|
136936
137057
|
const times = expiryOf(issued, receivedAt);
|
|
136937
137058
|
const file = `${spec.name}.state.json`;
|
|
136938
|
-
writePrivateFile(
|
|
137059
|
+
writePrivateFile(join49(dir, file), JSON.stringify(buildStorageState(target.origin, target.host, issued, times), null, 2) + "\n");
|
|
136939
137060
|
const actor = {
|
|
136940
137061
|
name: spec.name,
|
|
136941
137062
|
user_id: issued.user.id,
|
|
@@ -137037,7 +137158,7 @@ function registerTestUsers(program2) {
|
|
|
137037
137158
|
if (name !== opts.linkOut || !/^[A-Za-z0-9._-]{1,64}$/.test(name))
|
|
137038
137159
|
throw new Error(`--link-out takes a file name; it is written under ${TEST_STATE_DIR}/.`);
|
|
137039
137160
|
ensurePrivateDir(stateDir(target.root));
|
|
137040
|
-
writePrivateFile(
|
|
137161
|
+
writePrivateFile(join49(stateDir(target.root), name), newest.magic_link + "\n");
|
|
137041
137162
|
linkFile = `${TEST_STATE_DIR}/${name}`;
|
|
137042
137163
|
}
|
|
137043
137164
|
const message3 = {
|
|
@@ -137108,12 +137229,12 @@ function registerTestUsers(program2) {
|
|
|
137108
137229
|
local_state: { removed: localRemoved, kept: manifest.actors.map((actor) => actor.state_file).filter((file) => !localRemoved.includes(file)) },
|
|
137109
137230
|
actors: manifest.actors.map(({ name, user_id, email: email2, role, created_at }) => ({ name, user_id, email: email2, role, created_at }))
|
|
137110
137231
|
};
|
|
137111
|
-
writePrivateFile(
|
|
137232
|
+
writePrivateFile(join49(stateDir(target.root), CLEANUP_RECEIPT_FILE), JSON.stringify(receipt, null, 2) + "\n");
|
|
137112
137233
|
const left = manifest.actors.filter((actor) => !removed.includes(actor.user_id));
|
|
137113
137234
|
if (left.length)
|
|
137114
137235
|
writeManifest(target.root, { ...manifest, actors: left, status: "partial" });
|
|
137115
137236
|
else
|
|
137116
|
-
rmSync18(
|
|
137237
|
+
rmSync18(join49(stateDir(target.root), MANIFEST_FILE), { force: true });
|
|
137117
137238
|
if (opts.json) {
|
|
137118
137239
|
printJson(receipt);
|
|
137119
137240
|
if (left.length)
|
|
@@ -137153,7 +137274,7 @@ var init_test_users = __esm({
|
|
|
137153
137274
|
});
|
|
137154
137275
|
|
|
137155
137276
|
// dist/commands/support.js
|
|
137156
|
-
import { join as
|
|
137277
|
+
import { join as join50 } from "node:path";
|
|
137157
137278
|
function commandPaths(program2) {
|
|
137158
137279
|
const paths = /* @__PURE__ */ new Set();
|
|
137159
137280
|
const walk2 = /* @__PURE__ */ __name((command, prefix) => {
|
|
@@ -137238,7 +137359,7 @@ function emitPacket(packet, opts) {
|
|
|
137238
137359
|
if (opts.out) {
|
|
137239
137360
|
if (!/^[A-Za-z0-9._-]{1,64}$/.test(opts.out))
|
|
137240
137361
|
throw new Error("--out takes a plain file name in the current folder.");
|
|
137241
|
-
writePrivateFile(
|
|
137362
|
+
writePrivateFile(join50(process.cwd(), opts.out), JSON.stringify(packet, null, 2) + "\n");
|
|
137242
137363
|
}
|
|
137243
137364
|
if (opts.json) {
|
|
137244
137365
|
printJson(packet);
|
|
@@ -137529,10 +137650,10 @@ var init_startup_notice = __esm({
|
|
|
137529
137650
|
|
|
137530
137651
|
// dist/lib/last-run.js
|
|
137531
137652
|
import { lstatSync as lstatSync6, mkdirSync as mkdirSync22, renameSync as renameSync7, unlinkSync as unlinkSync6, writeFileSync as writeFileSync28 } from "node:fs";
|
|
137532
|
-
import { join as
|
|
137653
|
+
import { join as join51 } from "node:path";
|
|
137533
137654
|
function removeStaleRunRecord(dir = cliConfigDir()) {
|
|
137534
137655
|
for (const name of RUN_RECORD_FILES) {
|
|
137535
|
-
const path3 =
|
|
137656
|
+
const path3 = join51(dir, name);
|
|
137536
137657
|
try {
|
|
137537
137658
|
if (lstatSync6(path3).isDirectory()) {
|
|
137538
137659
|
process.stderr.write(`Could not remove ${path3}: it is a directory, not this CLI's run record. Check it yourself.
|
|
@@ -137572,8 +137693,8 @@ function recordLastRun(cliVersion) {
|
|
|
137572
137693
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
137573
137694
|
cli_version: cliVersion
|
|
137574
137695
|
};
|
|
137575
|
-
const path3 =
|
|
137576
|
-
const temporary =
|
|
137696
|
+
const path3 = join51(dir, "last-run.json");
|
|
137697
|
+
const temporary = join51(dir, "last-run.json.tmp");
|
|
137577
137698
|
writeFileSync28(temporary, JSON.stringify(record3) + "\n", { mode: 384 });
|
|
137578
137699
|
renameSync7(temporary, path3);
|
|
137579
137700
|
} catch {
|
|
@@ -137612,7 +137733,7 @@ __export(dist_exports, {
|
|
|
137612
137733
|
});
|
|
137613
137734
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
137614
137735
|
import { readFileSync as readFileSync46 } from "node:fs";
|
|
137615
|
-
import { join as
|
|
137736
|
+
import { join as join52 } from "node:path";
|
|
137616
137737
|
async function runCli() {
|
|
137617
137738
|
const pinned = decidePin(process.cwd(), CLI_VERSION2, process.argv, process.env);
|
|
137618
137739
|
if (pinned.notice)
|
|
@@ -137640,7 +137761,7 @@ async function runCli() {
|
|
|
137640
137761
|
process.exit(child.status ?? 1);
|
|
137641
137762
|
}
|
|
137642
137763
|
removeStaleRunRecord();
|
|
137643
|
-
const pkg = JSON.parse(readFileSync46(
|
|
137764
|
+
const pkg = JSON.parse(readFileSync46(join52(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
|
|
137644
137765
|
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);
|
|
137645
137766
|
recordLastRun(pkg.version);
|
|
137646
137767
|
const jsonOutputRequested = process.argv.includes("--json");
|
|
@@ -138058,7 +138179,7 @@ var init_screenshot_guard = __esm({
|
|
|
138058
138179
|
|
|
138059
138180
|
// dist/lib/playwright-fixtures.js
|
|
138060
138181
|
import { createRequire as createRequire11 } from "node:module";
|
|
138061
|
-
import { join as
|
|
138182
|
+
import { join as join53 } from "node:path";
|
|
138062
138183
|
function waitOnNavigation(page) {
|
|
138063
138184
|
async function wait(options2) {
|
|
138064
138185
|
if (options2?.waitUntil === "commit")
|
|
@@ -138110,7 +138231,7 @@ async function previewControlForWorker() {
|
|
|
138110
138231
|
function runner() {
|
|
138111
138232
|
if (loaded)
|
|
138112
138233
|
return loaded;
|
|
138113
|
-
const require6 = createRequire11(
|
|
138234
|
+
const require6 = createRequire11(join53(process.cwd(), "package.json"));
|
|
138114
138235
|
let pw;
|
|
138115
138236
|
try {
|
|
138116
138237
|
pw = require6("@playwright/test");
|