deployai 0.1.0-beta.47 → 0.1.0-beta.49
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/dist/index.js +91 -43
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var __export = (target, all) => {
|
|
|
7
7
|
|
|
8
8
|
// src/cli.ts
|
|
9
9
|
import { existsSync as existsSync22 } from "fs";
|
|
10
|
-
import { join as join25, resolve as
|
|
10
|
+
import { join as join25, resolve as resolve10 } from "path";
|
|
11
11
|
import { Command, CommanderError } from "commander";
|
|
12
12
|
|
|
13
13
|
// ../shared/src/plans.ts
|
|
@@ -6516,7 +6516,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
6516
6516
|
var NONE = 0;
|
|
6517
6517
|
var ASSUMED = 1;
|
|
6518
6518
|
var PROVEN = 2;
|
|
6519
|
-
function isRecursive(inst, stack,
|
|
6519
|
+
function isRecursive(inst, stack, resolve11) {
|
|
6520
6520
|
const cached2 = recursive.get(inst);
|
|
6521
6521
|
if (cached2 !== void 0)
|
|
6522
6522
|
return cached2 ? PROVEN : NONE;
|
|
@@ -6526,7 +6526,7 @@ function isRecursive(inst, stack, resolve10) {
|
|
|
6526
6526
|
let result = NONE;
|
|
6527
6527
|
const check2 = (child) => {
|
|
6528
6528
|
if (result !== PROVEN && child?._zod) {
|
|
6529
|
-
const answer = isRecursive(child, stack,
|
|
6529
|
+
const answer = isRecursive(child, stack, resolve11);
|
|
6530
6530
|
if (answer > result)
|
|
6531
6531
|
result = answer;
|
|
6532
6532
|
}
|
|
@@ -6537,7 +6537,7 @@ function isRecursive(inst, stack, resolve10) {
|
|
|
6537
6537
|
const desc = Object.getOwnPropertyDescriptor(sh, key2);
|
|
6538
6538
|
if (spread && !desc.enumerable)
|
|
6539
6539
|
continue;
|
|
6540
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
6540
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve11) : NONE;
|
|
6541
6541
|
if (child > answer)
|
|
6542
6542
|
answer = child;
|
|
6543
6543
|
}
|
|
@@ -6601,7 +6601,7 @@ function isRecursive(inst, stack, resolve10) {
|
|
|
6601
6601
|
break;
|
|
6602
6602
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
6603
6603
|
case "lazy": {
|
|
6604
|
-
const inner = def._cachedInner ?? (
|
|
6604
|
+
const inner = def._cachedInner ?? (resolve11 ? inst._zod.innerType : void 0);
|
|
6605
6605
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
6606
6606
|
break;
|
|
6607
6607
|
}
|
|
@@ -21199,12 +21199,12 @@ function findSecretLine(text2, re) {
|
|
|
21199
21199
|
return null;
|
|
21200
21200
|
}
|
|
21201
21201
|
var PRIVATE_DIRS = /* @__PURE__ */ new Set([".deployai", ".claude", ".cursor", ".vscode", ".idea", ".git", ".github", ".husky"]);
|
|
21202
|
-
var PRIVATE_FILES = /* @__PURE__ */ new Set(["
|
|
21202
|
+
var PRIVATE_FILES = /* @__PURE__ */ new Set(["deployai.md", "claude.md", "agents.md", ".cursorrules", ".windsurfrules"]);
|
|
21203
21203
|
var SERVED_DOT_DIR = ".well-known";
|
|
21204
21204
|
var BUILD_DOTFILES = /* @__PURE__ */ new Set([".babelrc", ".babelrc.json", ".browserslistrc", ".postcssrc", ".postcssrc.json", ".postcssrc.js", ".postcssrc.cjs", ".postcssrc.mjs", ".swcrc", ".nvmrc", ".node-version", ".assetsignore"]);
|
|
21205
21205
|
var segments = (path) => path.replace(/^\/+/, "").split("/").filter(Boolean);
|
|
21206
21206
|
function privateProjectFile(path) {
|
|
21207
|
-
const parts2 = segments(path);
|
|
21207
|
+
const parts2 = segments(path).map((p) => p.toLowerCase());
|
|
21208
21208
|
const base = parts2[parts2.length - 1] ?? "";
|
|
21209
21209
|
return PRIVATE_FILES.has(base) || parts2.slice(0, -1).some((p) => PRIVATE_DIRS.has(p)) || PRIVATE_DIRS.has(base);
|
|
21210
21210
|
}
|
|
@@ -21324,6 +21324,10 @@ var AgentFeedback = external_exports.object({
|
|
|
21324
21324
|
tried: external_exports.string().trim().max(FEEDBACK_TEXT_MAX).nullable(),
|
|
21325
21325
|
suggest: external_exports.string().trim().max(FEEDBACK_TEXT_MAX).nullable()
|
|
21326
21326
|
});
|
|
21327
|
+
var UPLOAD_PART_BYTES = 4 * 1024 * 1024;
|
|
21328
|
+
var MAX_DEPLOY_BYTES = 50 * 1024 * 1024;
|
|
21329
|
+
var MAX_UPLOAD_PARTS = Math.ceil(MAX_DEPLOY_BYTES / UPLOAD_PART_BYTES);
|
|
21330
|
+
var UploadPartResponse = external_exports.object({ ok: external_exports.literal(true) });
|
|
21327
21331
|
var DeployResponse = external_exports.object({
|
|
21328
21332
|
versionId: external_exports.string(),
|
|
21329
21333
|
number: external_exports.number(),
|
|
@@ -24917,6 +24921,7 @@ var M = {
|
|
|
24917
24921
|
deployTitle: "DeployAI deploy",
|
|
24918
24922
|
guestTitle: "DeployAI deploy (no account)",
|
|
24919
24923
|
uploading: "Uploading...",
|
|
24924
|
+
uploadingPart: "Uploading part {n} of {total}...",
|
|
24920
24925
|
project: "Project",
|
|
24921
24926
|
message: "Message",
|
|
24922
24927
|
version: "Version",
|
|
@@ -25218,6 +25223,7 @@ var M = {
|
|
|
25218
25223
|
deployTitle: "DeployAI deploy",
|
|
25219
25224
|
guestTitle: "DeployAI deploy (\u05D1\u05DC\u05D9 \u05D7\u05E9\u05D1\u05D5\u05DF)",
|
|
25220
25225
|
uploading: "\u05DE\u05E2\u05DC\u05D9\u05DD...",
|
|
25226
|
+
uploadingPart: "\u05DE\u05E2\u05DC\u05D9\u05DD \u05D7\u05DC\u05E7 {n} \u05DE\u05EA\u05D5\u05DA {total}...",
|
|
25221
25227
|
project: "\u05D0\u05EA\u05E8",
|
|
25222
25228
|
message: "\u05D4\u05D5\u05D3\u05E2\u05D4",
|
|
25223
25229
|
version: "\u05D2\u05E8\u05E1\u05D4",
|
|
@@ -25513,7 +25519,7 @@ function formatBytes(n2) {
|
|
|
25513
25519
|
}
|
|
25514
25520
|
|
|
25515
25521
|
// src/version.ts
|
|
25516
|
-
var CLI_VERSION = "0.1.0-beta.
|
|
25522
|
+
var CLI_VERSION = "0.1.0-beta.49";
|
|
25517
25523
|
|
|
25518
25524
|
// src/api.ts
|
|
25519
25525
|
function apiContext(apiFlag, root) {
|
|
@@ -25546,9 +25552,10 @@ function errorCode(e3) {
|
|
|
25546
25552
|
const cause = e3?.cause;
|
|
25547
25553
|
return cause?.code ?? e3?.code;
|
|
25548
25554
|
}
|
|
25549
|
-
|
|
25550
|
-
|
|
25551
|
-
|
|
25555
|
+
var EDGE_TIMEOUT = /* @__PURE__ */ new Set([520, 521, 522, 523, 524]);
|
|
25556
|
+
function shouldRetry(method, failure2, idempotent = false) {
|
|
25557
|
+
const get2 = method === "GET" || idempotent;
|
|
25558
|
+
if (typeof failure2 === "number") return get2 && (failure2 === 502 || failure2 === 503 || failure2 === 504 || EDGE_TIMEOUT.has(failure2));
|
|
25552
25559
|
const code = errorCode(failure2);
|
|
25553
25560
|
if (code && NEVER_SENT.has(code)) return true;
|
|
25554
25561
|
if (!get2) return false;
|
|
@@ -25586,7 +25593,7 @@ async function apiRequest(ctx, path, schema, opts = {}) {
|
|
|
25586
25593
|
} catch (e3) {
|
|
25587
25594
|
failure2 = e3;
|
|
25588
25595
|
}
|
|
25589
|
-
const again = attempt < waits.length && shouldRetry(method, res ? res.status : failure2);
|
|
25596
|
+
const again = attempt < waits.length && shouldRetry(method, res ? res.status : failure2, opts.idempotent);
|
|
25590
25597
|
if (!again) {
|
|
25591
25598
|
if (!res) throw await networkError(failure2, ctx.apiUrl);
|
|
25592
25599
|
break;
|
|
@@ -25603,6 +25610,7 @@ async function apiRequest(ctx, path, schema, opts = {}) {
|
|
|
25603
25610
|
}
|
|
25604
25611
|
const t = messages(process.cwd());
|
|
25605
25612
|
if (res.status === 401) throw new CliError(t("sessionExpired"), 1, "auth");
|
|
25613
|
+
if (EDGE_TIMEOUT.has(res.status)) throw new CliError(t("timeout", { url: ctx.apiUrl }), 1, "network");
|
|
25606
25614
|
if (!res.ok) {
|
|
25607
25615
|
const parsed2 = ApiError.safeParse(data);
|
|
25608
25616
|
if (parsed2.success && parsed2.data.error === "site_deleted") {
|
|
@@ -25767,6 +25775,8 @@ function buildTelemetryEvent(installId, command, result, errorCategory, extra =
|
|
|
25767
25775
|
if ((result === "error" || result === "blocked") && extra.errorLine) ev.errorLine = scrubText(extra.errorLine, ERROR_LINE_MAX);
|
|
25768
25776
|
return ev;
|
|
25769
25777
|
}
|
|
25778
|
+
var TELEMETRY_WAIT_MS = 2e3;
|
|
25779
|
+
var TELEMETRY_ERROR_WAIT_MS = 8e3;
|
|
25770
25780
|
async function sendTelemetryEvent(ctx, event) {
|
|
25771
25781
|
if (!telemetryEnabled(ctx.config)) return;
|
|
25772
25782
|
try {
|
|
@@ -25777,7 +25787,7 @@ async function sendTelemetryEvent(ctx, event) {
|
|
|
25777
25787
|
method: "POST",
|
|
25778
25788
|
headers,
|
|
25779
25789
|
body: JSON.stringify(event),
|
|
25780
|
-
signal: AbortSignal.timeout(
|
|
25790
|
+
signal: AbortSignal.timeout(event.result === "error" ? TELEMETRY_ERROR_WAIT_MS : TELEMETRY_WAIT_MS)
|
|
25781
25791
|
});
|
|
25782
25792
|
await res.body?.cancel().catch(() => {
|
|
25783
25793
|
});
|
|
@@ -28484,6 +28494,9 @@ async function linkCommand(root, ctx, target, opts) {
|
|
|
28484
28494
|
out(t("runLinkPick"));
|
|
28485
28495
|
}
|
|
28486
28496
|
|
|
28497
|
+
// src/commands/deploy.ts
|
|
28498
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
28499
|
+
|
|
28487
28500
|
// src/ask.ts
|
|
28488
28501
|
import { createInterface as createInterface2 } from "readline/promises";
|
|
28489
28502
|
var isInteractive = () => Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
@@ -28529,7 +28542,7 @@ function changedUnderSameName(root, files) {
|
|
|
28529
28542
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
28530
28543
|
import { existsSync as existsSync15, mkdirSync as mkdirSync9, mkdtempSync, readFileSync as readFileSync13, rmSync as rmSync3, unlinkSync, writeFileSync as writeFileSync13 } from "fs";
|
|
28531
28544
|
import { tmpdir } from "os";
|
|
28532
|
-
import { dirname as dirname5, join as join17 } from "path";
|
|
28545
|
+
import { dirname as dirname5, join as join17, resolve as resolve4, sep as sep3 } from "path";
|
|
28533
28546
|
import { gunzipSync as gunzipSync2 } from "zlib";
|
|
28534
28547
|
|
|
28535
28548
|
// src/tar.ts
|
|
@@ -28636,13 +28649,16 @@ function readTar(tar) {
|
|
|
28636
28649
|
const h = tar.subarray(offset, offset + BLOCK);
|
|
28637
28650
|
if (h.every((b) => b === 0)) break;
|
|
28638
28651
|
const name = readString(h, 0, 100);
|
|
28639
|
-
const
|
|
28652
|
+
const sizeField = readString(h, 124, 12).trim() || "0";
|
|
28653
|
+
if (!/^[0-7]{1,12}$/.test(sizeField)) throw new Error("Archive header is damaged");
|
|
28654
|
+
const size = parseInt(sizeField, 8);
|
|
28655
|
+
if (offset + BLOCK + size > tar.length) throw new Error("Archive header is damaged");
|
|
28640
28656
|
const type = String.fromCharCode(h[156] || 48);
|
|
28641
28657
|
const prefix = readString(h, 345, 155);
|
|
28642
28658
|
const data = tar.subarray(offset + BLOCK, offset + BLOCK + size);
|
|
28643
28659
|
offset += BLOCK + Math.ceil(size / BLOCK) * BLOCK;
|
|
28644
28660
|
if (type === "x") {
|
|
28645
|
-
const m =
|
|
28661
|
+
const m = /(?:^|\n)\d+ path=([^\n]*)\n/.exec(data.toString("utf8"));
|
|
28646
28662
|
paxPath = m ? m[1] : null;
|
|
28647
28663
|
continue;
|
|
28648
28664
|
}
|
|
@@ -28899,11 +28915,20 @@ var git2 = (cwd, args) => spawnSync3("git", args, { cwd, encoding: "utf8" });
|
|
|
28899
28915
|
function filesOf(gz) {
|
|
28900
28916
|
const map2 = /* @__PURE__ */ new Map();
|
|
28901
28917
|
for (const e3 of readTar(gunzipSync2(gz, { maxOutputLength: 200 * 1024 * 1024 }))) {
|
|
28902
|
-
|
|
28903
|
-
|
|
28918
|
+
if (e3.type !== "0" && e3.type !== "" && e3.type !== "\0") continue;
|
|
28919
|
+
const name = safeSourceName(e3.name);
|
|
28920
|
+
if (name) map2.set(name, e3.data);
|
|
28904
28921
|
}
|
|
28905
28922
|
return map2;
|
|
28906
28923
|
}
|
|
28924
|
+
function safeSourceName(raw) {
|
|
28925
|
+
const name = raw.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
|
|
28926
|
+
if (!name || name.startsWith("/") || /^[a-zA-Z]:/.test(name) || name.includes("\0")) return null;
|
|
28927
|
+
if (name.split("/").some((p) => p === ".." || p === ".")) return null;
|
|
28928
|
+
if (privateProjectFile(name)) return null;
|
|
28929
|
+
if (name.split("/").some((p) => /^[^.]{1,8}~\d+(\.[^.]{0,3})?$/.test(p) || /[. ]$/.test(p))) return null;
|
|
28930
|
+
return name;
|
|
28931
|
+
}
|
|
28907
28932
|
var same2 = (a, b) => a === void 0 && b === void 0 || a !== void 0 && b !== void 0 && a.equals(b);
|
|
28908
28933
|
var isBinary = (b) => !!b && b.subarray(0, 8e3).includes(0);
|
|
28909
28934
|
function migrationNumber(path) {
|
|
@@ -28949,8 +28974,10 @@ async function bringIn(root, ctx, projectId, behind) {
|
|
|
28949
28974
|
const state = { live, base: behind.base, conflicts: [], clashes: migrationClashes(baseFiles, liveFiles, ourFiles) };
|
|
28950
28975
|
let taken = 0;
|
|
28951
28976
|
let merged = 0;
|
|
28977
|
+
const folder = resolve4(root);
|
|
28952
28978
|
const write = (path, data) => {
|
|
28953
|
-
const abs =
|
|
28979
|
+
const abs = resolve4(folder, path);
|
|
28980
|
+
if (!abs.startsWith(folder + sep3)) return;
|
|
28954
28981
|
if (data === void 0) {
|
|
28955
28982
|
if (existsSync15(abs)) unlinkSync(abs);
|
|
28956
28983
|
return;
|
|
@@ -29445,6 +29472,27 @@ function addTool(form, ctx, model) {
|
|
|
29445
29472
|
const m = toDeployModel(model) ?? deployModelFromEnv(process.env);
|
|
29446
29473
|
if (m) form.append("model", m);
|
|
29447
29474
|
}
|
|
29475
|
+
async function attachArchive(ctx, form, projectId, archive, root) {
|
|
29476
|
+
if (archive.length <= UPLOAD_PART_BYTES) {
|
|
29477
|
+
form.append("archive", new Blob([new Uint8Array(archive)], { type: "application/gzip" }), "source.tar.gz");
|
|
29478
|
+
return;
|
|
29479
|
+
}
|
|
29480
|
+
const t = messages(root);
|
|
29481
|
+
const uploadId = randomUUID2();
|
|
29482
|
+
const parts2 = Math.ceil(archive.length / UPLOAD_PART_BYTES);
|
|
29483
|
+
for (let n2 = 0; n2 < parts2; n2++) {
|
|
29484
|
+
out(t("uploadingPart", { n: n2 + 1, total: parts2 }));
|
|
29485
|
+
const part = new FormData();
|
|
29486
|
+
part.append("projectId", projectId);
|
|
29487
|
+
part.append("uploadId", uploadId);
|
|
29488
|
+
part.append("part", String(n2));
|
|
29489
|
+
part.append("parts", String(parts2));
|
|
29490
|
+
part.append("data", new Blob([new Uint8Array(archive.subarray(n2 * UPLOAD_PART_BYTES, (n2 + 1) * UPLOAD_PART_BYTES))], { type: "application/octet-stream" }), `part-${n2}`);
|
|
29491
|
+
await apiRequest(ctx, "/api/cli/deploy/parts", UploadPartResponse, { method: "POST", form: part, idempotent: true, timeoutMs: 2 * 6e4 });
|
|
29492
|
+
}
|
|
29493
|
+
form.append("uploadId", uploadId);
|
|
29494
|
+
form.append("parts", String(parts2));
|
|
29495
|
+
}
|
|
29448
29496
|
async function catchUp(root, ctx, projectId, builtOn) {
|
|
29449
29497
|
const t = messages(root);
|
|
29450
29498
|
const work = await checkWork(ctx, root, projectId, builtOn);
|
|
@@ -29492,7 +29540,7 @@ async function deployVersion(root, ctx, opts, guest) {
|
|
|
29492
29540
|
addTool(form, ctx, opts.model);
|
|
29493
29541
|
if (wait && soundWanted(ctx.config)) form.append("soundHere", live ? "live" : "preview");
|
|
29494
29542
|
if (hold) form.append("hold", "1");
|
|
29495
|
-
|
|
29543
|
+
await attachArchive(ctx, form, project.projectId, archive, root);
|
|
29496
29544
|
const res = await apiRequest(ctx, "/api/cli/deploy", DeployResponse, { method: "POST", form, timeoutMs: 5 * 6e4 });
|
|
29497
29545
|
if (!guest) {
|
|
29498
29546
|
updateProject(root, { builtOn: res.number });
|
|
@@ -29875,7 +29923,7 @@ async function requestsOpenCommand(root, ctx, path, open2) {
|
|
|
29875
29923
|
// src/commands/start.ts
|
|
29876
29924
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
29877
29925
|
import { existsSync as existsSync16, writeFileSync as writeFileSync15 } from "fs";
|
|
29878
|
-
import { join as join19, relative as relative3, resolve as
|
|
29926
|
+
import { join as join19, relative as relative3, resolve as resolve5 } from "path";
|
|
29879
29927
|
|
|
29880
29928
|
// src/commands/starter.ts
|
|
29881
29929
|
import { writeFileSync as writeFileSync14 } from "fs";
|
|
@@ -29999,7 +30047,7 @@ async function startCommand(cwd, ctx, id, opts = {}) {
|
|
|
29999
30047
|
out(START_WAIT_LINE);
|
|
30000
30048
|
out();
|
|
30001
30049
|
const fresh = kind === "new" || kind === "migrate" || kind === "guest" && sample;
|
|
30002
|
-
const here =
|
|
30050
|
+
const here = resolve5(cwd);
|
|
30003
30051
|
const sameSite = Boolean(choices.projectId && readProject(here)?.projectId === choices.projectId);
|
|
30004
30052
|
const update = kind === "update" && Boolean(choices.projectId);
|
|
30005
30053
|
const root = (fresh || update) && filesIn(here).length && !opts.here && !sameSite ? freeFolder(here, choices.slug ?? sample?.key ?? "site") : here;
|
|
@@ -30125,7 +30173,7 @@ ${choices.brief}
|
|
|
30125
30173
|
}
|
|
30126
30174
|
|
|
30127
30175
|
// src/commands/addon.ts
|
|
30128
|
-
import { dirname as dirname6, join as join20, resolve as
|
|
30176
|
+
import { dirname as dirname6, join as join20, resolve as resolve6 } from "path";
|
|
30129
30177
|
import { mkdirSync as mkdirSync10, existsSync as existsSync17, writeFileSync as writeFileSync16 } from "fs";
|
|
30130
30178
|
function linkedProjectId2(root) {
|
|
30131
30179
|
const id = readProject(root)?.projectId;
|
|
@@ -30282,7 +30330,7 @@ async function addonDoneCommand(root, ctx, runId, opts) {
|
|
|
30282
30330
|
let report2;
|
|
30283
30331
|
if (opts.report) {
|
|
30284
30332
|
try {
|
|
30285
|
-
report2 = readJson(
|
|
30333
|
+
report2 = readJson(resolve6(root, opts.report));
|
|
30286
30334
|
} catch {
|
|
30287
30335
|
throw new CliError(`Cannot read the report file ${opts.report} as JSON.`, 1, "usage");
|
|
30288
30336
|
}
|
|
@@ -30454,7 +30502,7 @@ async function local(page3, strategy, deps, dir, now) {
|
|
|
30454
30502
|
import { spawn as spawn4 } from "child_process";
|
|
30455
30503
|
import { existsSync as existsSync18, mkdirSync as mkdirSync12, readFileSync as readFileSync15, rmSync as rmSync5, writeFileSync as writeFileSync18 } from "fs";
|
|
30456
30504
|
import { tmpdir as tmpdir3 } from "os";
|
|
30457
|
-
import { join as join22, resolve as
|
|
30505
|
+
import { join as join22, resolve as resolve7 } from "path";
|
|
30458
30506
|
var SHOT_SIZES = [{ name: "phone", size: "390,844" }, { name: "desktop", size: "1440,900" }];
|
|
30459
30507
|
var PLAYWRIGHT = "playwright@1.56";
|
|
30460
30508
|
var WAIT_MS3 = 18e4;
|
|
@@ -30518,7 +30566,7 @@ async function shotCommand(root, address, opts = {}, run = runNpx) {
|
|
|
30518
30566
|
const browser = opts.webkit ? null : findBrowser();
|
|
30519
30567
|
if (!opts.webkit && !browser) throw new CliError("No Chrome or Edge was found on this computer. Install Chrome, set CHROME_PATH to its path, or run shot again with --webkit (it downloads Safari's engine first).", 1, "no_browser");
|
|
30520
30568
|
if (opts.webkit && await run(["--yes", PLAYWRIGHT, "install", "webkit"]) !== 0) throw new CliError("Safari's engine could not be installed. Run shot without --webkit to use Chrome or Edge.", 1, "shot_failed");
|
|
30521
|
-
const dir =
|
|
30569
|
+
const dir = resolve7(root, opts.out ?? join22(".deployai", "shots"));
|
|
30522
30570
|
mkdirSync12(dir, { recursive: true });
|
|
30523
30571
|
const taker = join22(tmpdir3(), "deployai-shot.cjs");
|
|
30524
30572
|
writeFileSync18(taker, TAKER);
|
|
@@ -30545,7 +30593,7 @@ import { spawnSync as spawnSync5 } from "child_process";
|
|
|
30545
30593
|
import { existsSync as existsSync19, mkdirSync as mkdirSync13, readdirSync as readdirSync6, statSync as statSync3, writeFileSync as writeFileSync19 } from "fs";
|
|
30546
30594
|
import { createRequire } from "module";
|
|
30547
30595
|
import { homedir as homedir3 } from "os";
|
|
30548
|
-
import { extname, join as join23, relative as relative4, resolve as
|
|
30596
|
+
import { extname, join as join23, relative as relative4, resolve as resolve8 } from "path";
|
|
30549
30597
|
var PHONE_WIDTH = 640;
|
|
30550
30598
|
var SHARP = "sharp@0.34";
|
|
30551
30599
|
var SKIP_DIRS2 = /* @__PURE__ */ new Set(["node_modules", ".git", ".deployai", "dist", ".astro", ".next"]);
|
|
@@ -30581,7 +30629,7 @@ function loadSharp() {
|
|
|
30581
30629
|
return createRequire(join23(dir, "package.json"))("sharp");
|
|
30582
30630
|
}
|
|
30583
30631
|
async function imagesCommand(root, folder, sharp = loadSharp) {
|
|
30584
|
-
const dir =
|
|
30632
|
+
const dir = resolve8(root, folder ?? "public");
|
|
30585
30633
|
const files = imagesIn(dir);
|
|
30586
30634
|
if (!files.length) {
|
|
30587
30635
|
out(`No JPG or PNG images under ${relative4(root, dir) || "."}.`);
|
|
@@ -30616,7 +30664,7 @@ async function imagesCommand(root, folder, sharp = loadSharp) {
|
|
|
30616
30664
|
// src/commands/blocks.ts
|
|
30617
30665
|
import { createHash as createHash5 } from "crypto";
|
|
30618
30666
|
import { existsSync as existsSync20, mkdirSync as mkdirSync14, readFileSync as readFileSync16, writeFileSync as writeFileSync20 } from "fs";
|
|
30619
|
-
import { dirname as dirname7, resolve as
|
|
30667
|
+
import { dirname as dirname7, resolve as resolve9, sep as sep4 } from "path";
|
|
30620
30668
|
import { gunzipSync as gunzipSync3 } from "zlib";
|
|
30621
30669
|
var BLOCKS = [
|
|
30622
30670
|
{ key: "dashboard", title: "The site's own dashboard: messages, pages, blog, shop, images, accessibility, documents. Add --update to get a newer version" },
|
|
@@ -30626,7 +30674,7 @@ var BLOCKS = [
|
|
|
30626
30674
|
];
|
|
30627
30675
|
var MAX_BYTES3 = 5 * 1024 * 1024;
|
|
30628
30676
|
var sha = (data) => createHash5("sha256").update(data).digest("hex");
|
|
30629
|
-
var lockPath = (base, key2) =>
|
|
30677
|
+
var lockPath = (base, key2) => resolve9(base, ".deployai", "blocks", `${key2}.lock.json`);
|
|
30630
30678
|
function readLock(base, key2) {
|
|
30631
30679
|
try {
|
|
30632
30680
|
return readJson(lockPath(base, key2));
|
|
@@ -30660,15 +30708,15 @@ async function blocksCommand(root, ctx, name, opts = {}) {
|
|
|
30660
30708
|
} catch {
|
|
30661
30709
|
throw new CliError("The block download is damaged. Try again.", 1, "api");
|
|
30662
30710
|
}
|
|
30663
|
-
const base =
|
|
30711
|
+
const base = resolve9(root);
|
|
30664
30712
|
const written = [];
|
|
30665
30713
|
const kept = [];
|
|
30666
30714
|
const updated = [];
|
|
30667
30715
|
const lock = readLock(base, block.key);
|
|
30668
30716
|
for (const e3 of entries) {
|
|
30669
30717
|
if (e3.type !== "0" && e3.type !== "\0") continue;
|
|
30670
|
-
const target =
|
|
30671
|
-
if (target === base || !target.startsWith(base +
|
|
30718
|
+
const target = resolve9(base, e3.name);
|
|
30719
|
+
if (target === base || !target.startsWith(base + sep4)) continue;
|
|
30672
30720
|
if (existsSync20(target)) {
|
|
30673
30721
|
const now = sha(readFileSync16(target));
|
|
30674
30722
|
if (now === sha(e3.data)) {
|
|
@@ -30678,8 +30726,8 @@ async function blocksCommand(root, ctx, name, opts = {}) {
|
|
|
30678
30726
|
lock[e3.name] = sha(e3.data);
|
|
30679
30727
|
updated.push(e3.name);
|
|
30680
30728
|
} else {
|
|
30681
|
-
const upstream =
|
|
30682
|
-
if (upstream.startsWith(base +
|
|
30729
|
+
const upstream = resolve9(base, ".deployai", "blocks", `${block.key}-upstream`, e3.name);
|
|
30730
|
+
if (upstream.startsWith(base + sep4)) {
|
|
30683
30731
|
mkdirSync14(dirname7(upstream), { recursive: true });
|
|
30684
30732
|
writeFileSync20(upstream, e3.data);
|
|
30685
30733
|
}
|
|
@@ -30758,7 +30806,7 @@ import { spawn as spawn5 } from "child_process";
|
|
|
30758
30806
|
import { copyFileSync, existsSync as existsSync21, mkdirSync as mkdirSync15, mkdtempSync as mkdtempSync3, readdirSync as readdirSync7, readFileSync as readFileSync17, rmSync as rmSync6, statSync as statSync4, writeFileSync as writeFileSync21 } from "fs";
|
|
30759
30807
|
import { createServer } from "http";
|
|
30760
30808
|
import { tmpdir as tmpdir4 } from "os";
|
|
30761
|
-
import { basename as basename2, dirname as dirname8, extname as extname2, join as join24, relative as relative5, sep as
|
|
30809
|
+
import { basename as basename2, dirname as dirname8, extname as extname2, join as join24, relative as relative5, sep as sep5 } from "path";
|
|
30762
30810
|
import { randomBytes } from "crypto";
|
|
30763
30811
|
|
|
30764
30812
|
// src/commands/brand-page.ts
|
|
@@ -30877,14 +30925,14 @@ function walk(dir, found = []) {
|
|
|
30877
30925
|
}
|
|
30878
30926
|
function existingFavicon(root) {
|
|
30879
30927
|
const web = webRoot(root);
|
|
30880
|
-
for (const f of ["favicon.ico", "favicon.svg", "favicon.png", "icon.svg", "icon.png"]) if (existsSync21(join24(web, f))) return relative5(root, join24(web, f)).split(
|
|
30928
|
+
for (const f of ["favicon.ico", "favicon.svg", "favicon.png", "icon.svg", "icon.png"]) if (existsSync21(join24(web, f))) return relative5(root, join24(web, f)).split(sep5).join("/");
|
|
30881
30929
|
for (const d of ["app", "src/app"]) for (const f of ["favicon.ico", "icon.svg", "icon.png", "icon.tsx", "icon.jpg"]) if (existsSync21(join24(root, d, f))) return `${d}/${f}`;
|
|
30882
30930
|
for (const f of walk(root).filter((p) => /\.(html|astro|tsx|jsx|vue|svelte)$/.test(p)).slice(0, 400)) {
|
|
30883
30931
|
try {
|
|
30884
30932
|
const m = readFileSync17(f, "utf8").match(/<link\b[^>]*\brel=["'](?:shortcut )?icon["'][^>]*>/i);
|
|
30885
30933
|
if (!m) continue;
|
|
30886
30934
|
const href = m[0].match(/\shref=["']([^"']+)/i)?.[1] ?? "";
|
|
30887
|
-
if (href.startsWith("data:") || /^https?:/.test(href) || existsSync21(join24(web, href.split("?")[0]))) return relative5(root, f).split(
|
|
30935
|
+
if (href.startsWith("data:") || /^https?:/.test(href) || existsSync21(join24(web, href.split("?")[0]))) return relative5(root, f).split(sep5).join("/");
|
|
30888
30936
|
} catch {
|
|
30889
30937
|
}
|
|
30890
30938
|
}
|
|
@@ -30914,7 +30962,7 @@ function findSource(root) {
|
|
|
30914
30962
|
const sharp = icons.find((i) => i.kind === "icon" && i.big);
|
|
30915
30963
|
if (sharp) return { path: sharp.path, from: "old-icon" };
|
|
30916
30964
|
const dirs = ["public", "static", "src/assets", "assets", "images", "img"].map((d) => join24(root, d));
|
|
30917
|
-
const logos = dirs.flatMap((d) => walk(d)).filter((p) => looksLikeLogo(relative5(root, p).split(
|
|
30965
|
+
const logos = dirs.flatMap((d) => walk(d)).filter((p) => looksLikeLogo(relative5(root, p).split(sep5).join("/")));
|
|
30918
30966
|
const logo = logos.find((p) => /\.svg$/i.test(p)) ?? logos[0];
|
|
30919
30967
|
if (logo) return { path: logo, from: "logo" };
|
|
30920
30968
|
const oldLogo = icons.find((i) => i.kind === "logo");
|
|
@@ -31115,7 +31163,7 @@ function sourceBytes(path) {
|
|
|
31115
31163
|
return { bytes: readFileSync17(path), type: TYPES[extname2(path).toLowerCase()] ?? "application/octet-stream" };
|
|
31116
31164
|
}
|
|
31117
31165
|
function report(root, r) {
|
|
31118
|
-
const where = relative5(root, webRoot(root)).split(
|
|
31166
|
+
const where = relative5(root, webRoot(root)).split(sep5).join("/") || "the site root";
|
|
31119
31167
|
out(`Written in ${where}: ${r.written.join(", ")}`);
|
|
31120
31168
|
if (r.skipped.length) out(`Left out, the picture is too small to stay sharp: ${r.skipped.join(", ")}. A larger logo makes them.`);
|
|
31121
31169
|
const tags2 = brandHeadTags(r.written);
|
|
@@ -31254,7 +31302,7 @@ function imageFiles(root) {
|
|
|
31254
31302
|
const dirs = [webRoot(root) === root ? null : webRoot(root), join24(root, "src"), join24(root, MIGRATION_DIR)].filter((d) => !!d);
|
|
31255
31303
|
const files = dirs.flatMap((d) => walkAll(d));
|
|
31256
31304
|
if (webRoot(root) === root) files.push(...walk(root));
|
|
31257
|
-
return [...new Set(files)].filter((p) => IMAGE_EXT.test(p) && !p.split(
|
|
31305
|
+
return [...new Set(files)].filter((p) => IMAGE_EXT.test(p) && !p.split(sep5).includes("icons") && !BRAND_FILES.includes(basename2(p)));
|
|
31258
31306
|
}
|
|
31259
31307
|
function walkAll(dir) {
|
|
31260
31308
|
const found = [];
|
|
@@ -31294,7 +31342,7 @@ function judgeFiles(root) {
|
|
|
31294
31342
|
if (!size) continue;
|
|
31295
31343
|
total++;
|
|
31296
31344
|
const verdict = judgeImage({ width: size.width, height: size.height, bytes: bytes.length, format: size.format });
|
|
31297
|
-
if (verdict !== "ok") findings.push({ where: relative5(root, f).split(
|
|
31345
|
+
if (verdict !== "ok") findings.push({ where: relative5(root, f).split(sep5).join("/"), width: size.width, height: size.height, verdict });
|
|
31298
31346
|
}
|
|
31299
31347
|
return { findings, total };
|
|
31300
31348
|
}
|
|
@@ -31402,7 +31450,7 @@ function buildProgram() {
|
|
|
31402
31450
|
if (lang === "he" || lang === "en") process.env.DEPLOYAI_LANG = lang;
|
|
31403
31451
|
}).showHelpAfterError();
|
|
31404
31452
|
const g = (cmd) => cmd.optsWithGlobals();
|
|
31405
|
-
const root = (cmd) =>
|
|
31453
|
+
const root = (cmd) => resolve10(g(cmd).dir ?? process.cwd());
|
|
31406
31454
|
const ctx = (cmd) => apiContext(g(cmd).api, root(cmd));
|
|
31407
31455
|
program.hook("preAction", async (_p, action) => {
|
|
31408
31456
|
if (["init", "start", "rules"].includes(action.name()) || !existsSync22(join25(root(action), "DEPLOYAI.md"))) return;
|