deployai 0.1.0-beta.33 → 0.1.0-beta.34
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 +318 -251
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,8 @@ var __export = (target, all) => {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
// src/cli.ts
|
|
9
|
-
import {
|
|
9
|
+
import { existsSync as existsSync21 } from "fs";
|
|
10
|
+
import { join as join24, resolve as resolve8 } from "path";
|
|
10
11
|
import { Command, CommanderError } from "commander";
|
|
11
12
|
|
|
12
13
|
// ../shared/src/plans.ts
|
|
@@ -21149,16 +21150,11 @@ function privateProjectFile(path) {
|
|
|
21149
21150
|
const base = parts2[parts2.length - 1] ?? "";
|
|
21150
21151
|
return PRIVATE_FILES.has(base) || parts2.slice(0, -1).some((p) => PRIVATE_DIRS.has(p)) || PRIVATE_DIRS.has(base);
|
|
21151
21152
|
}
|
|
21152
|
-
function dotPath(path) {
|
|
21153
|
-
const parts2 = segments(path);
|
|
21154
|
-
if (parts2[0] === SERVED_DOT_DIR) parts2.shift();
|
|
21155
|
-
return parts2.some((p) => p.startsWith("."));
|
|
21156
|
-
}
|
|
21157
21153
|
function neverUploadedFile(rel) {
|
|
21158
21154
|
if (privateProjectFile(rel)) return true;
|
|
21159
21155
|
const parts2 = segments(rel);
|
|
21160
21156
|
if (parts2.length === 1 && BUILD_DOTFILES.has(parts2[0])) return false;
|
|
21161
|
-
return
|
|
21157
|
+
return parts2.some((p) => p.startsWith(".") && p !== SERVED_DOT_DIR);
|
|
21162
21158
|
}
|
|
21163
21159
|
|
|
21164
21160
|
// ../shared/src/agent-feedback.ts
|
|
@@ -22484,6 +22480,7 @@ var CLI_MAP_NODES = [
|
|
|
22484
22480
|
n("cmd-shot", "cli", "shot <url>", "\u05EA\u05DE\u05D5\u05E0\u05D5\u05EA \u05D8\u05DC\u05E4\u05D5\u05DF \u05D5\u05DE\u05D7\u05E9\u05D1 \u05E9\u05DC \u05E2\u05DE\u05D5\u05D3, \u05D1\u05D3\u05E4\u05D3\u05E4\u05DF \u05E9\u05DB\u05D1\u05E8 \u05D1\u05DE\u05D7\u05E9\u05D1.", "Phone and desktop pictures of a page, with the browser already on the computer."),
|
|
22485
22481
|
n("cmd-optimize", "cli", "optimize [folder]", "AVIF \u05D5\u05BEWebP \u05DC\u05D9\u05D3 \u05DB\u05DC \u05EA\u05DE\u05D5\u05E0\u05D4, \u05D1\u05DC\u05D9 \u05DC\u05D2\u05E2\u05EA \u05D1\u05DE\u05E7\u05D5\u05E8.", "AVIF and WebP next to each image, originals untouched."),
|
|
22486
22482
|
n("cmd-allow", "cli", "allow [tool]", "\u05D0\u05D7\u05E8\u05D9 \u05E9\u05D4\u05D1\u05E2\u05DC\u05D9\u05DD \u05D0\u05D9\u05E9\u05E8: \u05DB\u05DC\u05D9 \u05D4\u05E7\u05D5\u05D3 \u05DE\u05E4\u05E1\u05D9\u05E7 \u05DC\u05E9\u05D0\u05D5\u05DC \u05DC\u05E4\u05E0\u05D9 \u05DB\u05DC \u05E4\u05E7\u05D5\u05D3\u05EA DeployAI, \u05E8\u05E7 \u05D1\u05EA\u05D9\u05E7\u05D9\u05D9\u05D4 \u05D4\u05D6\u05D5.", "After the owner says yes: the coding tool stops asking before every DeployAI command, in this folder only."),
|
|
22483
|
+
n("cmd-rules", "cli", "rules", "\u05DE\u05D3\u05E4\u05D9\u05E1 \u05D0\u05EA \u05D4\u05DB\u05DC\u05DC\u05D9\u05DD \u05D4\u05E2\u05D3\u05DB\u05E0\u05D9\u05D9\u05DD \u05DC\u05E1\u05D5\u05DB\u05DF \u05DE\u05D4\u05E9\u05E8\u05EA \u05D5\u05DE\u05E2\u05D3\u05DB\u05DF \u05D0\u05DC\u05D9\u05D4\u05DD \u05D0\u05EA DEPLOYAI.md. \u05DB\u05DC \u05E4\u05E7\u05D5\u05D3\u05D4 \u05D0\u05D7\u05E8\u05EA \u05DE\u05E2\u05D3\u05DB\u05E0\u05EA \u05D0\u05EA DEPLOYAI.md \u05D1\u05E2\u05E6\u05DE\u05D4, \u05D0\u05DD \u05DC\u05D0 \u05E0\u05E2\u05E8\u05DA.", "Prints the current agent rules from the server and brings DEPLOYAI.md up to them. Every other command updates DEPLOYAI.md too, unless it was edited."),
|
|
22487
22484
|
n("cmd-sound", "cli", "sound", "\u05E6\u05DC\u05D9\u05DC \u05D1\u05DE\u05D7\u05E9\u05D1 \u05DB\u05E9\u05D4\u05D0\u05EA\u05E8 \u05DE\u05D5\u05DB\u05DF, \u05D0\u05D7\u05E8\u05D9 \u05E9\u05D4\u05D1\u05E2\u05DC\u05D9\u05DD \u05D0\u05D9\u05E9\u05E8. \u05D1-Claude Code \u05D4\u05D0\u05D9\u05E9\u05D5\u05E8 \u05D4\u05D6\u05D4 \u05DE\u05D5\u05E1\u05D9\u05E3 \u05D2\u05DD \u05E6\u05DC\u05D9\u05DC \u05D5\u05E0\u05E7\u05D5\u05D3\u05D4 \u05D1\u05DC\u05E9\u05D5\u05E0\u05D9\u05EA \u05E9\u05DC \u05D4\u05D8\u05E8\u05DE\u05D9\u05E0\u05DC.", "A sound on this computer when the site is ready, after the owner says yes. In Claude Code that yes also adds a sound and a tab dot in the terminal."),
|
|
22488
22485
|
n("cmd-telemetry", "cli", "telemetry", "\u05D4\u05E4\u05E2\u05DC\u05D4 \u05D0\u05D5 \u05DB\u05D9\u05D1\u05D5\u05D9 \u05E9\u05DC \u05E0\u05EA\u05D5\u05E0\u05D9 \u05E9\u05D9\u05DE\u05D5\u05E9 \u05D0\u05E0\u05D5\u05E0\u05D9\u05DE\u05D9\u05D9\u05DD.", "Turns anonymous usage data on or off."),
|
|
22489
22486
|
n("cmd-feedback", "cli", "feedback", "\u05D4\u05E1\u05D5\u05DB\u05DF \u05DE\u05E1\u05E4\u05E8 \u05DC\u05E0\u05D5 \u05DE\u05D4 \u05D4\u05E4\u05E8\u05D9\u05E2 \u05DC\u05D5 \u05D5\u05DE\u05D4 \u05D4\u05D9\u05D4 \u05E2\u05D5\u05D6\u05E8, \u05D1\u05DC\u05D9 \u05E7\u05D5\u05D3, \u05E9\u05DE\u05D5\u05EA \u05D0\u05D5 \u05DB\u05EA\u05D5\u05D1\u05D5\u05EA.", "The agent tells us what got in its way and what would help, with no code, names or addresses."),
|
|
@@ -23339,6 +23336,7 @@ Ask the owner before removing any existing functionality.
|
|
|
23339
23336
|
Files:
|
|
23340
23337
|
- .deployai/project.json: project id and settings (safe to commit)
|
|
23341
23338
|
- .deployai/last-check.json: latest check result (not committed)
|
|
23339
|
+
- .deployai/rules.json: which rules this file has. Every DeployAI command updates this file to the current rules unless it was edited. The current rules: npx deployai@latest rules
|
|
23342
23340
|
`;
|
|
23343
23341
|
var DEPLOYAI_LATER_RULES = [
|
|
23344
23342
|
{ has: "iPhone:", text: IPHONE_RULE },
|
|
@@ -24294,7 +24292,7 @@ function ensureDeployaiDir(root) {
|
|
|
24294
24292
|
if (!existsSync2(dir)) mkdirSync2(dir, { recursive: true });
|
|
24295
24293
|
const ignore = join2(dir, ".gitignore");
|
|
24296
24294
|
const have = existsSync2(ignore) ? readFileSync3(ignore, "utf8") : "";
|
|
24297
|
-
const missing = ["last-check.json", "brief.md", "start.md"].filter((f) => !have.split(/\r?\n/).includes(f));
|
|
24295
|
+
const missing = ["last-check.json", "brief.md", "start.md", "blocks/*.md"].filter((f) => !have.split(/\r?\n/).includes(f));
|
|
24298
24296
|
if (missing.length) writeFileSync2(ignore, have + (have && !have.endsWith("\n") ? "\n" : "") + missing.join("\n") + "\n");
|
|
24299
24297
|
}
|
|
24300
24298
|
function readProject(root) {
|
|
@@ -24833,7 +24831,7 @@ function messages(root) {
|
|
|
24833
24831
|
}
|
|
24834
24832
|
|
|
24835
24833
|
// src/version.ts
|
|
24836
|
-
var CLI_VERSION = "0.1.0-beta.
|
|
24834
|
+
var CLI_VERSION = "0.1.0-beta.34";
|
|
24837
24835
|
|
|
24838
24836
|
// src/api.ts
|
|
24839
24837
|
function apiContext(apiFlag) {
|
|
@@ -25142,8 +25140,8 @@ async function feedbackCommand(root, ctx, opts) {
|
|
|
25142
25140
|
}
|
|
25143
25141
|
|
|
25144
25142
|
// src/commands/init.ts
|
|
25145
|
-
import { appendFileSync, existsSync as
|
|
25146
|
-
import { join as
|
|
25143
|
+
import { appendFileSync as appendFileSync2, existsSync as existsSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "fs";
|
|
25144
|
+
import { join as join7 } from "path";
|
|
25147
25145
|
|
|
25148
25146
|
// src/analyze.ts
|
|
25149
25147
|
import { execFileSync } from "child_process";
|
|
@@ -25840,36 +25838,76 @@ async function serverSteps(apiUrl, query, fetcher = fetch) {
|
|
|
25840
25838
|
}
|
|
25841
25839
|
}
|
|
25842
25840
|
|
|
25843
|
-
// src/
|
|
25844
|
-
|
|
25845
|
-
|
|
25846
|
-
|
|
25841
|
+
// src/rules-file.ts
|
|
25842
|
+
import { createHash } from "crypto";
|
|
25843
|
+
import { appendFileSync, existsSync as existsSync5, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
|
|
25844
|
+
import { join as join6 } from "path";
|
|
25845
|
+
var RULES_FILE = "DEPLOYAI.md";
|
|
25846
|
+
var RULES_STAMP = `${DEPLOYAI_DIR}/rules.json`;
|
|
25847
|
+
var rulesHash = (text2) => createHash("sha256").update(text2.replace(/\r\n/g, "\n")).digest("hex");
|
|
25848
|
+
function readStamp(root) {
|
|
25849
|
+
try {
|
|
25850
|
+
const v = readJson(join6(root, RULES_STAMP));
|
|
25851
|
+
return typeof v.deployaiMd === "string" ? v.deployaiMd : null;
|
|
25852
|
+
} catch {
|
|
25853
|
+
return null;
|
|
25854
|
+
}
|
|
25855
|
+
}
|
|
25856
|
+
function writeStamp(root, text2) {
|
|
25857
|
+
ensureDeployaiDir(root);
|
|
25858
|
+
writeFileSync4(join6(root, RULES_STAMP), `${JSON.stringify({ deployaiMd: rulesHash(text2) }, null, 2)}
|
|
25859
|
+
`);
|
|
25860
|
+
}
|
|
25861
|
+
function writeRulesFile(root, md) {
|
|
25862
|
+
writeFileSync4(join6(root, RULES_FILE), md);
|
|
25863
|
+
writeStamp(root, md);
|
|
25864
|
+
}
|
|
25865
|
+
function addMissingRules(file2, text2, later) {
|
|
25847
25866
|
const missing = later.filter((r) => !text2.includes(r.has));
|
|
25848
25867
|
if (!missing.length) return false;
|
|
25849
25868
|
const eol = text2.includes("\r\n") ? "\r\n" : "\n";
|
|
25850
25869
|
const gap = text2.endsWith("\n") ? eol : eol + eol;
|
|
25851
|
-
appendFileSync(
|
|
25870
|
+
appendFileSync(file2, `${gap}## Added later by DeployAI${eol}${eol}${missing.map((r) => r.text).join(eol + eol)}${eol}`);
|
|
25852
25871
|
return true;
|
|
25853
25872
|
}
|
|
25873
|
+
function syncRulesFile(root, md, later = DEPLOYAI_LATER_RULES) {
|
|
25874
|
+
const file2 = join6(root, RULES_FILE);
|
|
25875
|
+
if (!existsSync5(file2)) return "none";
|
|
25876
|
+
const text2 = readFileSync6(file2, "utf8");
|
|
25877
|
+
const now = rulesHash(text2);
|
|
25878
|
+
if (now === rulesHash(md)) {
|
|
25879
|
+
if (readStamp(root) !== now) writeStamp(root, md);
|
|
25880
|
+
return "current";
|
|
25881
|
+
}
|
|
25882
|
+
if (readStamp(root) === now) {
|
|
25883
|
+
writeRulesFile(root, text2.includes("\r\n") ? md.replace(/\r?\n/g, "\r\n") : md);
|
|
25884
|
+
return "updated";
|
|
25885
|
+
}
|
|
25886
|
+
return addMissingRules(file2, text2, later) ? "added" : "edited";
|
|
25887
|
+
}
|
|
25888
|
+
|
|
25889
|
+
// src/commands/init.ts
|
|
25890
|
+
var AGENT_FILES = ["AGENTS.md", "CLAUDE.md"];
|
|
25854
25891
|
function runInit(root, opts = {}) {
|
|
25855
25892
|
const created = [];
|
|
25856
25893
|
const kept = [];
|
|
25857
25894
|
const updated = [];
|
|
25858
|
-
const md =
|
|
25895
|
+
const md = join7(root, "DEPLOYAI.md");
|
|
25859
25896
|
let rulesAdded = false;
|
|
25860
|
-
if (
|
|
25897
|
+
if (existsSync6(md) && !opts.force) {
|
|
25861
25898
|
kept.push("DEPLOYAI.md");
|
|
25862
|
-
|
|
25899
|
+
const sync = syncRulesFile(root, opts.texts?.md ?? DEPLOYAI_MD, opts.texts?.later);
|
|
25900
|
+
rulesAdded = sync === "updated" || sync === "added";
|
|
25863
25901
|
} else {
|
|
25864
|
-
|
|
25902
|
+
writeRulesFile(root, opts.texts?.md ?? DEPLOYAI_MD);
|
|
25865
25903
|
created.push("DEPLOYAI.md");
|
|
25866
25904
|
}
|
|
25867
25905
|
if (opts.agentFiles !== false) {
|
|
25868
25906
|
for (const name of AGENT_FILES) {
|
|
25869
|
-
const file2 =
|
|
25870
|
-
const text2 =
|
|
25907
|
+
const file2 = join7(root, name);
|
|
25908
|
+
const text2 = existsSync6(file2) ? readFileSync7(file2, "utf8") : null;
|
|
25871
25909
|
if (text2 === null) {
|
|
25872
|
-
|
|
25910
|
+
writeFileSync5(file2, `${AGENT_POINTER}
|
|
25873
25911
|
`);
|
|
25874
25912
|
created.push(name);
|
|
25875
25913
|
} else if (text2.includes("DEPLOYAI.md")) {
|
|
@@ -25877,7 +25915,7 @@ function runInit(root, opts = {}) {
|
|
|
25877
25915
|
} else {
|
|
25878
25916
|
const eol = text2.includes("\r\n") ? "\r\n" : "\n";
|
|
25879
25917
|
const gap = !text2.trim() ? "" : text2.endsWith("\n") ? eol : eol + eol;
|
|
25880
|
-
|
|
25918
|
+
appendFileSync2(file2, `${gap}${AGENT_POINTER}${eol}`);
|
|
25881
25919
|
updated.push(name);
|
|
25882
25920
|
}
|
|
25883
25921
|
}
|
|
@@ -25891,7 +25929,7 @@ function runInit(root, opts = {}) {
|
|
|
25891
25929
|
writeProject(root, { projectId: null, framework, createdAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
25892
25930
|
created.push(".deployai/project.json");
|
|
25893
25931
|
}
|
|
25894
|
-
const hasCode =
|
|
25932
|
+
const hasCode = existsSync6(join7(root, "package.json")) || framework !== "unknown";
|
|
25895
25933
|
return { rulesAdded, created, kept, updated, hasCode };
|
|
25896
25934
|
}
|
|
25897
25935
|
async function initCommand(root, opts, apiUrl) {
|
|
@@ -25920,8 +25958,8 @@ async function initCommand(root, opts, apiUrl) {
|
|
|
25920
25958
|
}
|
|
25921
25959
|
|
|
25922
25960
|
// src/commands/check.ts
|
|
25923
|
-
import { existsSync as
|
|
25924
|
-
import { join as
|
|
25961
|
+
import { existsSync as existsSync8, writeFileSync as writeFileSync6 } from "fs";
|
|
25962
|
+
import { join as join9 } from "path";
|
|
25925
25963
|
|
|
25926
25964
|
// src/prompt.ts
|
|
25927
25965
|
var PROMPT_RULES = [
|
|
@@ -25990,8 +26028,8 @@ function buildPrompt(analysis) {
|
|
|
25990
26028
|
|
|
25991
26029
|
// src/system.ts
|
|
25992
26030
|
import { spawn, spawnSync } from "child_process";
|
|
25993
|
-
import { existsSync as
|
|
25994
|
-
import { join as
|
|
26031
|
+
import { existsSync as existsSync7 } from "fs";
|
|
26032
|
+
import { join as join8 } from "path";
|
|
25995
26033
|
function copyToClipboard(text2) {
|
|
25996
26034
|
if (process.env.DEPLOYAI_NO_CLIPBOARD) return false;
|
|
25997
26035
|
const candidates = process.platform === "win32" ? [["clip", []]] : process.platform === "darwin" ? [["pbcopy", []]] : [
|
|
@@ -26011,9 +26049,9 @@ function copyToClipboard(text2) {
|
|
|
26011
26049
|
function findBrowser() {
|
|
26012
26050
|
if (process.env.DEPLOYAI_NO_BROWSER) return null;
|
|
26013
26051
|
const set2 = process.env.CHROME_PATH;
|
|
26014
|
-
if (set2 &&
|
|
26015
|
-
const places = process.platform === "win32" ? [process.env.PROGRAMFILES, process.env["PROGRAMFILES(X86)"], process.env.LOCALAPPDATA].flatMap((d) => d ? [
|
|
26016
|
-
return places.find((p) =>
|
|
26052
|
+
if (set2 && existsSync7(set2)) return set2;
|
|
26053
|
+
const places = process.platform === "win32" ? [process.env.PROGRAMFILES, process.env["PROGRAMFILES(X86)"], process.env.LOCALAPPDATA].flatMap((d) => d ? [join8(d, "Google/Chrome/Application/chrome.exe"), join8(d, "Microsoft/Edge/Application/msedge.exe")] : []) : process.platform === "darwin" ? ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge", "/Applications/Chromium.app/Contents/MacOS/Chromium"] : ["/usr/bin/google-chrome", "/usr/bin/google-chrome-stable", "/usr/bin/chromium", "/usr/bin/chromium-browser", "/usr/bin/microsoft-edge", "/snap/bin/chromium"];
|
|
26054
|
+
return places.find((p) => existsSync7(p)) ?? null;
|
|
26017
26055
|
}
|
|
26018
26056
|
function openBrowser(url2) {
|
|
26019
26057
|
if (process.env.DEPLOYAI_NO_BROWSER || process.env.CI) return false;
|
|
@@ -26113,7 +26151,7 @@ async function runCheck(root, ctx, opts = {}) {
|
|
|
26113
26151
|
const json2 = checkJson(a, prompt);
|
|
26114
26152
|
try {
|
|
26115
26153
|
ensureDeployaiDir(root);
|
|
26116
|
-
|
|
26154
|
+
writeFileSync6(lastCheckFile(root), JSON.stringify(json2, null, 2) + "\n");
|
|
26117
26155
|
} catch {
|
|
26118
26156
|
}
|
|
26119
26157
|
const empty = a.findings.length > 0 && a.findings.every((f) => f.code === "no_files");
|
|
@@ -26123,7 +26161,7 @@ async function runCheck(root, ctx, opts = {}) {
|
|
|
26123
26161
|
out("DeployAI check");
|
|
26124
26162
|
out();
|
|
26125
26163
|
out(messages(root)("emptyFolder"));
|
|
26126
|
-
if (!
|
|
26164
|
+
if (!existsSync8(join9(root, "DEPLOYAI.md"))) out(messages(root)("initHint"));
|
|
26127
26165
|
} else if (opts.print !== false) {
|
|
26128
26166
|
printCheck(a);
|
|
26129
26167
|
out();
|
|
@@ -26150,7 +26188,7 @@ async function runCheck(root, ctx, opts = {}) {
|
|
|
26150
26188
|
} else {
|
|
26151
26189
|
out(t("runDeploy"));
|
|
26152
26190
|
}
|
|
26153
|
-
if (!
|
|
26191
|
+
if (!existsSync8(join9(root, "DEPLOYAI.md"))) out(t("initHint"));
|
|
26154
26192
|
}
|
|
26155
26193
|
await telemetry;
|
|
26156
26194
|
return a;
|
|
@@ -26293,8 +26331,8 @@ function telemetryCommand(action) {
|
|
|
26293
26331
|
}
|
|
26294
26332
|
|
|
26295
26333
|
// src/commands/allow.ts
|
|
26296
|
-
import { existsSync as
|
|
26297
|
-
import { dirname, join as
|
|
26334
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync4, readFileSync as readFileSync8, writeFileSync as writeFileSync7, appendFileSync as appendFileSync3 } from "fs";
|
|
26335
|
+
import { dirname, join as join10 } from "path";
|
|
26298
26336
|
var ALLOW_TOOLS = ["claude-code", "cursor", "copilot", "codex", "antigravity", "grok"];
|
|
26299
26337
|
var CLAUDE_RULE = "Bash(npx deployai@latest *)";
|
|
26300
26338
|
var CURSOR_LINE = "Running npx deployai@latest commands is allowed without approval.";
|
|
@@ -26304,7 +26342,7 @@ var CLICKS = {
|
|
|
26304
26342
|
antigravity: "Antigravity: when it asks to run npx deployai@latest, choose Accept."
|
|
26305
26343
|
};
|
|
26306
26344
|
function readObject(file2) {
|
|
26307
|
-
if (!
|
|
26345
|
+
if (!existsSync9(file2)) return {};
|
|
26308
26346
|
try {
|
|
26309
26347
|
const v = readJson(file2);
|
|
26310
26348
|
return v && typeof v === "object" && !Array.isArray(v) ? v : null;
|
|
@@ -26314,7 +26352,7 @@ function readObject(file2) {
|
|
|
26314
26352
|
}
|
|
26315
26353
|
function writeObject(file2, value) {
|
|
26316
26354
|
mkdirSync4(dirname(file2), { recursive: true });
|
|
26317
|
-
|
|
26355
|
+
writeFileSync7(file2, `${JSON.stringify(value, null, 2)}
|
|
26318
26356
|
`);
|
|
26319
26357
|
}
|
|
26320
26358
|
function addTo(obj, key, list, value) {
|
|
@@ -26326,11 +26364,11 @@ function addTo(obj, key, list, value) {
|
|
|
26326
26364
|
return true;
|
|
26327
26365
|
}
|
|
26328
26366
|
function ignoreInGit(root, path) {
|
|
26329
|
-
if (!
|
|
26330
|
-
const gi =
|
|
26331
|
-
const text2 =
|
|
26367
|
+
if (!existsSync9(join10(root, ".git"))) return;
|
|
26368
|
+
const gi = join10(root, ".gitignore");
|
|
26369
|
+
const text2 = existsSync9(gi) ? readFileSync8(gi, "utf8") : "";
|
|
26332
26370
|
if (text2.split(/\r?\n/).some((l) => l.trim() === path)) return;
|
|
26333
|
-
|
|
26371
|
+
appendFileSync3(gi, `${text2 && !text2.endsWith("\n") ? "\n" : ""}${path}
|
|
26334
26372
|
`);
|
|
26335
26373
|
}
|
|
26336
26374
|
function detectTool() {
|
|
@@ -26351,7 +26389,7 @@ function allowCommand(tool) {
|
|
|
26351
26389
|
if (picked === "claude-code" || picked === "grok") {
|
|
26352
26390
|
const grok = picked === "grok";
|
|
26353
26391
|
const rel = ".claude/settings.local.json";
|
|
26354
|
-
const file2 =
|
|
26392
|
+
const file2 = join10(root, rel);
|
|
26355
26393
|
const obj = readObject(file2);
|
|
26356
26394
|
if (!obj) throw new CliError(`${rel} is not valid JSON, so it was left as is. Ask the owner to add the Allow rule ${CLAUDE_RULE} with /permissions.`, 1, "allow_file");
|
|
26357
26395
|
const added = addTo(obj, "permissions", "allow", CLAUDE_RULE);
|
|
@@ -26372,7 +26410,7 @@ function allowCommand(tool) {
|
|
|
26372
26410
|
}
|
|
26373
26411
|
if (picked === "cursor") {
|
|
26374
26412
|
const rel = ".cursor/permissions.json";
|
|
26375
|
-
const file2 =
|
|
26413
|
+
const file2 = join10(root, rel);
|
|
26376
26414
|
const obj = readObject(file2);
|
|
26377
26415
|
if (!obj) throw new CliError(`${rel} is not valid JSON, so it was left as is.`, 1, "allow_file");
|
|
26378
26416
|
const added = addTo(obj, "autoRun", "allow_instructions", CURSOR_LINE);
|
|
@@ -26386,14 +26424,14 @@ function allowCommand(tool) {
|
|
|
26386
26424
|
}
|
|
26387
26425
|
|
|
26388
26426
|
// src/commands/sound.ts
|
|
26389
|
-
import { existsSync as
|
|
26427
|
+
import { existsSync as existsSync11, readFileSync as readFileSync9, rmSync, writeFileSync as writeFileSync9 } from "fs";
|
|
26390
26428
|
import { homedir as homedir2 } from "os";
|
|
26391
|
-
import { join as
|
|
26429
|
+
import { join as join12 } from "path";
|
|
26392
26430
|
|
|
26393
26431
|
// src/sound.ts
|
|
26394
26432
|
import { spawn as spawn2 } from "child_process";
|
|
26395
|
-
import { existsSync as
|
|
26396
|
-
import { join as
|
|
26433
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync5, statSync, writeFileSync as writeFileSync8 } from "fs";
|
|
26434
|
+
import { join as join11 } from "path";
|
|
26397
26435
|
|
|
26398
26436
|
// src/sound-files.ts
|
|
26399
26437
|
var SOUND_FILES = {
|
|
@@ -26410,13 +26448,13 @@ function soundWanted(cfg, env = process.env) {
|
|
|
26410
26448
|
const s = env.DEPLOYAI_SOUND;
|
|
26411
26449
|
return !(s !== void 0 && ["0", "false", "off", "no"].includes(s.toLowerCase()));
|
|
26412
26450
|
}
|
|
26413
|
-
var soundsDir = () =>
|
|
26451
|
+
var soundsDir = () => join11(configDir(), "sounds");
|
|
26414
26452
|
function writeSoundFiles() {
|
|
26415
26453
|
mkdirSync5(soundsDir(), { recursive: true });
|
|
26416
26454
|
for (const [name, b64] of Object.entries(SOUND_FILES)) {
|
|
26417
26455
|
const data = Buffer.from(b64, "base64");
|
|
26418
|
-
const file2 =
|
|
26419
|
-
if (!
|
|
26456
|
+
const file2 = join11(soundsDir(), `${name}.wav`);
|
|
26457
|
+
if (!existsSync10(file2) || statSync(file2).size !== data.length) writeFileSync8(file2, data);
|
|
26420
26458
|
}
|
|
26421
26459
|
}
|
|
26422
26460
|
function playerFor(platform3, file2) {
|
|
@@ -26429,7 +26467,7 @@ function playSound(name, cfg) {
|
|
|
26429
26467
|
if (!soundWanted(cfg)) return;
|
|
26430
26468
|
try {
|
|
26431
26469
|
writeSoundFiles();
|
|
26432
|
-
const player = playerFor(process.platform,
|
|
26470
|
+
const player = playerFor(process.platform, join11(soundsDir(), `${name}.wav`));
|
|
26433
26471
|
if (!player) return;
|
|
26434
26472
|
const child = spawn2(player.cmd, player.args, { detached: true, stdio: "ignore", windowsHide: true });
|
|
26435
26473
|
child.on("error", () => void 0);
|
|
@@ -26508,17 +26546,17 @@ function foreignHooks(files) {
|
|
|
26508
26546
|
return [...found];
|
|
26509
26547
|
}
|
|
26510
26548
|
function agentOn(root, opts = {}) {
|
|
26511
|
-
const file2 =
|
|
26549
|
+
const file2 = join12(root, SETTINGS);
|
|
26512
26550
|
const obj = readObject(file2);
|
|
26513
26551
|
if (!obj) throw new CliError(`${SETTINGS} is not valid JSON, so it was left as is.`, 1, "allow_file");
|
|
26514
|
-
const home = process.env.CLAUDE_CONFIG_DIR ||
|
|
26515
|
-
if (!opts.alongside && foreignHooks([
|
|
26552
|
+
const home = process.env.CLAUDE_CONFIG_DIR || join12(opts.home ?? homedir2(), ".claude");
|
|
26553
|
+
if (!opts.alongside && foreignHooks([join12(home, "settings.json"), join12(root, ".claude/settings.json"), file2]).length) return "has_own";
|
|
26516
26554
|
writeSoundFiles();
|
|
26517
26555
|
ensureDeployaiDir(root);
|
|
26518
|
-
const script =
|
|
26556
|
+
const script = join12(root, AGENT_SCRIPT);
|
|
26519
26557
|
const text2 = agentScript(soundsDir());
|
|
26520
|
-
const scriptSame =
|
|
26521
|
-
if (!scriptSame)
|
|
26558
|
+
const scriptSame = existsSync11(script) && readFileSync9(script, "utf8") === text2;
|
|
26559
|
+
if (!scriptSame) writeFileSync9(script, text2);
|
|
26522
26560
|
const hooks = hooksOf(obj);
|
|
26523
26561
|
const env = obj.env && typeof obj.env === "object" ? obj.env : {};
|
|
26524
26562
|
let added = env[TITLE_ENV] !== "1";
|
|
@@ -26536,7 +26574,7 @@ function agentOn(root, opts = {}) {
|
|
|
26536
26574
|
return added || !scriptSame ? "on" : "already";
|
|
26537
26575
|
}
|
|
26538
26576
|
function agentOff(root) {
|
|
26539
|
-
const file2 =
|
|
26577
|
+
const file2 = join12(root, SETTINGS);
|
|
26540
26578
|
const obj = readObject(file2);
|
|
26541
26579
|
if (!obj) throw new CliError(`${SETTINGS} is not valid JSON, so it was left as is.`, 1, "allow_file");
|
|
26542
26580
|
const hooks = hooksOf(obj);
|
|
@@ -26558,8 +26596,8 @@ function agentOff(root) {
|
|
|
26558
26596
|
else delete obj.hooks;
|
|
26559
26597
|
writeObject(file2, obj);
|
|
26560
26598
|
}
|
|
26561
|
-
const script =
|
|
26562
|
-
if (
|
|
26599
|
+
const script = join12(root, AGENT_SCRIPT);
|
|
26600
|
+
if (existsSync11(script)) {
|
|
26563
26601
|
rmSync(script);
|
|
26564
26602
|
removed = true;
|
|
26565
26603
|
}
|
|
@@ -26626,22 +26664,46 @@ function soundCommand(root, action, state, tool, opts = {}) {
|
|
|
26626
26664
|
out(t(soundWanted(cfg) ? "soundOn" : "soundOff"));
|
|
26627
26665
|
}
|
|
26628
26666
|
function refreshAgentScript(root) {
|
|
26629
|
-
const script =
|
|
26630
|
-
if (!
|
|
26667
|
+
const script = join12(root, AGENT_SCRIPT);
|
|
26668
|
+
if (!existsSync11(script)) return false;
|
|
26631
26669
|
const text2 = agentScript(soundsDir());
|
|
26632
|
-
const now =
|
|
26670
|
+
const now = readFileSync9(script, "utf8");
|
|
26633
26671
|
if (now === text2 || !now.startsWith("// DeployAI's sound and tab dot")) return false;
|
|
26634
26672
|
writeSoundFiles();
|
|
26635
|
-
|
|
26673
|
+
writeFileSync9(script, text2);
|
|
26636
26674
|
return true;
|
|
26637
26675
|
}
|
|
26638
26676
|
|
|
26677
|
+
// src/commands/rules.ts
|
|
26678
|
+
var SAID = {
|
|
26679
|
+
updated: "DEPLOYAI.md was updated to the current DeployAI rules. Read it again before you go on.",
|
|
26680
|
+
added: "DEPLOYAI.md got the DeployAI rules it lacked, at its end. Read them before you go on."
|
|
26681
|
+
};
|
|
26682
|
+
async function rulesCommand(root, apiUrl) {
|
|
26683
|
+
const texts = initTexts(await serverRules(apiUrl));
|
|
26684
|
+
out(texts.md.trimEnd());
|
|
26685
|
+
out();
|
|
26686
|
+
const sync = syncRulesFile(root, texts.md, texts.later);
|
|
26687
|
+
if (sync === "current") out("DEPLOYAI.md here has these rules.");
|
|
26688
|
+
else if (sync === "none") out("No DEPLOYAI.md in this folder. To add one: npx deployai@latest init");
|
|
26689
|
+
else if (SAID[sync]) out(SAID[sync]);
|
|
26690
|
+
else out("DEPLOYAI.md here was edited, so it was left as it is. Follow the rules above. To replace it with them: npx deployai@latest init --force");
|
|
26691
|
+
}
|
|
26692
|
+
async function refreshRules(root, apiUrl) {
|
|
26693
|
+
try {
|
|
26694
|
+
const texts = initTexts(await serverRules(apiUrl));
|
|
26695
|
+
const sync = syncRulesFile(root, texts.md, texts.later);
|
|
26696
|
+
if (SAID[sync]) err(SAID[sync]);
|
|
26697
|
+
} catch {
|
|
26698
|
+
}
|
|
26699
|
+
}
|
|
26700
|
+
|
|
26639
26701
|
// src/commands/link.ts
|
|
26640
26702
|
import { createInterface } from "readline/promises";
|
|
26641
26703
|
|
|
26642
26704
|
// src/commands/migrate.ts
|
|
26643
|
-
import { createWriteStream, existsSync as
|
|
26644
|
-
import { dirname as dirname2, join as
|
|
26705
|
+
import { createWriteStream, existsSync as existsSync12, mkdirSync as mkdirSync6, readdirSync as readdirSync3, readFileSync as readFileSync10, statSync as statSync2, writeFileSync as writeFileSync10 } from "fs";
|
|
26706
|
+
import { dirname as dirname2, join as join13, posix, relative, resolve, sep } from "path";
|
|
26645
26707
|
import { Readable } from "stream";
|
|
26646
26708
|
import { pipeline } from "stream/promises";
|
|
26647
26709
|
var UA = `deployai-migrate/${CLI_VERSION} (+https://deployai.co.il/move)`;
|
|
@@ -26653,7 +26715,7 @@ var PAUSE_MS = 150;
|
|
|
26653
26715
|
var SCAN_WORKERS = 4;
|
|
26654
26716
|
var START_SCAN_PAGES = 300;
|
|
26655
26717
|
var sleep2 = (ms2) => new Promise((r) => setTimeout(r, ms2));
|
|
26656
|
-
var hostDir = (root, host) =>
|
|
26718
|
+
var hostDir = (root, host) => join13(root, MIGRATION_DIR, host.replace(/^www\./, ""));
|
|
26657
26719
|
var readJson3 = (file2) => {
|
|
26658
26720
|
try {
|
|
26659
26721
|
return readJson(file2);
|
|
@@ -26663,7 +26725,7 @@ var readJson3 = (file2) => {
|
|
|
26663
26725
|
};
|
|
26664
26726
|
var writeJson = (file2, data) => {
|
|
26665
26727
|
mkdirSync6(dirname2(file2), { recursive: true });
|
|
26666
|
-
|
|
26728
|
+
writeFileSync10(file2, JSON.stringify(data, null, 2) + "\n");
|
|
26667
26729
|
};
|
|
26668
26730
|
async function get(url2, accept = "text/html,application/xhtml+xml,*/*;q=0.8", redirect = "follow", cookie) {
|
|
26669
26731
|
try {
|
|
@@ -26673,9 +26735,9 @@ async function get(url2, accept = "text/html,application/xhtml+xml,*/*;q=0.8", r
|
|
|
26673
26735
|
}
|
|
26674
26736
|
}
|
|
26675
26737
|
function scannedHosts(root) {
|
|
26676
|
-
const dir =
|
|
26677
|
-
if (!
|
|
26678
|
-
return readdirSync3(dir).filter((h) =>
|
|
26738
|
+
const dir = join13(root, MIGRATION_DIR);
|
|
26739
|
+
if (!existsSync12(dir)) return [];
|
|
26740
|
+
return readdirSync3(dir).filter((h) => existsSync12(join13(dir, h, "inventory.json")));
|
|
26679
26741
|
}
|
|
26680
26742
|
async function migrateStatusCommand(root, ctx, stage, note) {
|
|
26681
26743
|
if (!isAgentStage(stage)) throw new CliError(`Unknown stage: ${stage}. One of: ${AGENT_STAGES.join(", ")}.`, 1, "usage");
|
|
@@ -26688,18 +26750,18 @@ async function migrateStatusCommand(root, ctx, stage, note) {
|
|
|
26688
26750
|
out(`Reported: ${stage}${note ? ` (${stageNote(note)})` : ""}.`);
|
|
26689
26751
|
}
|
|
26690
26752
|
function readChoices(root) {
|
|
26691
|
-
return readJson3(
|
|
26753
|
+
return readJson3(join13(root, MIGRATION_DIR, "choices.json"));
|
|
26692
26754
|
}
|
|
26693
26755
|
function writeChoices(root, choices) {
|
|
26694
26756
|
ensureMigrationDir(root);
|
|
26695
|
-
writeJson(
|
|
26757
|
+
writeJson(join13(root, MIGRATION_DIR, "choices.json"), choices);
|
|
26696
26758
|
}
|
|
26697
26759
|
function ensureMigrationDir(root) {
|
|
26698
26760
|
ensureDeployaiDir(root);
|
|
26699
|
-
const dir =
|
|
26761
|
+
const dir = join13(root, MIGRATION_DIR);
|
|
26700
26762
|
mkdirSync6(dir, { recursive: true });
|
|
26701
|
-
const ignore =
|
|
26702
|
-
if (!
|
|
26763
|
+
const ignore = join13(dir, ".gitignore");
|
|
26764
|
+
if (!existsSync12(ignore)) writeFileSync10(ignore, "*/media/\n*/media-state.json\n");
|
|
26703
26765
|
}
|
|
26704
26766
|
function sameAddress(from, to) {
|
|
26705
26767
|
try {
|
|
@@ -26770,15 +26832,15 @@ async function wordpressContent(base, dir) {
|
|
|
26770
26832
|
await sleep2(PAUSE_MS);
|
|
26771
26833
|
}
|
|
26772
26834
|
if (items.length) {
|
|
26773
|
-
writeJson(
|
|
26835
|
+
writeJson(join13(dir, "content", `${type}.json`), items);
|
|
26774
26836
|
out(` ${type}: ${items.length}`);
|
|
26775
26837
|
}
|
|
26776
26838
|
}
|
|
26777
|
-
const posts = readJson3(
|
|
26839
|
+
const posts = readJson3(join13(dir, "content", "posts.json"));
|
|
26778
26840
|
if (posts?.length) {
|
|
26779
|
-
const files = wpPostsToMarkdown({ origin: new URL(base).origin, posts, categories: readJson3(
|
|
26780
|
-
mkdirSync6(
|
|
26781
|
-
for (const f of files)
|
|
26841
|
+
const files = wpPostsToMarkdown({ origin: new URL(base).origin, posts, categories: readJson3(join13(dir, "content", "categories.json")) ?? [], tags: readJson3(join13(dir, "content", "tags.json")) ?? [], users: readJson3(join13(dir, "content", "users.json")) ?? [], media: readJson3(join13(dir, "content", "media.json")) ?? [] });
|
|
26842
|
+
mkdirSync6(join13(dir, "posts"), { recursive: true });
|
|
26843
|
+
for (const f of files) writeFileSync10(join13(dir, "posts", f.file), f.text);
|
|
26782
26844
|
out(` posts as Markdown: ${files.length}`);
|
|
26783
26845
|
}
|
|
26784
26846
|
return true;
|
|
@@ -26849,7 +26911,7 @@ async function saveOldIcons(html, pageUrl, origin, dir) {
|
|
|
26849
26911
|
add(`${origin}/favicon.ico`, "icon");
|
|
26850
26912
|
add(logoInPage(html), "logo");
|
|
26851
26913
|
const saved = [];
|
|
26852
|
-
const icons =
|
|
26914
|
+
const icons = join13(dir, "icons");
|
|
26853
26915
|
for (const w of wanted.slice(0, 6)) {
|
|
26854
26916
|
const res = await get(w.url, "image/*,*/*;q=0.8");
|
|
26855
26917
|
if (!res?.ok) continue;
|
|
@@ -26860,14 +26922,14 @@ async function saveOldIcons(html, pageUrl, origin, dir) {
|
|
|
26860
26922
|
if (!size && !svg) continue;
|
|
26861
26923
|
const file2 = `${saved.length + 1}-${w.kind}.${svg ? "svg" : size?.format === "jpeg" ? "jpg" : size?.format}`;
|
|
26862
26924
|
mkdirSync6(icons, { recursive: true });
|
|
26863
|
-
|
|
26925
|
+
writeFileSync10(join13(icons, file2), bytes);
|
|
26864
26926
|
saved.push({ file: file2, kind: w.kind });
|
|
26865
26927
|
}
|
|
26866
|
-
if (saved.length)
|
|
26928
|
+
if (saved.length) writeFileSync10(join13(icons, "icons.json"), JSON.stringify(saved, null, 2));
|
|
26867
26929
|
return saved.length;
|
|
26868
26930
|
}
|
|
26869
26931
|
async function saveOldStyles(html, pageUrl, dir) {
|
|
26870
|
-
const styles =
|
|
26932
|
+
const styles = join13(dir, "styles");
|
|
26871
26933
|
let n2 = 0;
|
|
26872
26934
|
for (const url2 of stylesheetLinks(html, pageUrl, 6)) {
|
|
26873
26935
|
const res = await get(url2, "text/css,*/*;q=0.8");
|
|
@@ -26875,7 +26937,7 @@ async function saveOldStyles(html, pageUrl, dir) {
|
|
|
26875
26937
|
const text2 = await res.text();
|
|
26876
26938
|
if (text2.length > ICON_MAX_BYTES) continue;
|
|
26877
26939
|
mkdirSync6(styles, { recursive: true });
|
|
26878
|
-
|
|
26940
|
+
writeFileSync10(join13(styles, `${++n2}.css`), text2);
|
|
26879
26941
|
}
|
|
26880
26942
|
}
|
|
26881
26943
|
var TRIGGER_PAGES_CAP = 30;
|
|
@@ -26903,15 +26965,15 @@ async function hasRootFile(origin, path, query = "", cookie) {
|
|
|
26903
26965
|
const res = await get(`${origin}${path}${query}`, "*/*", "follow", cookie);
|
|
26904
26966
|
return Boolean(res?.ok && !/text\/html/i.test(res.headers.get("content-type") ?? ""));
|
|
26905
26967
|
}
|
|
26906
|
-
var tagsFile = (dir) =>
|
|
26907
|
-
var stateFile = (dir) =>
|
|
26968
|
+
var tagsFile = (dir) => join13(dir, "tags.json");
|
|
26969
|
+
var stateFile = (dir) => join13(dir, "report-state.json");
|
|
26908
26970
|
function kitMap(root) {
|
|
26909
|
-
if (!
|
|
26971
|
+
if (!existsSync12(join13(root, "src/kit/schema.ts"))) return {};
|
|
26910
26972
|
const cut = (s, n2) => String(s ?? "").slice(0, n2);
|
|
26911
|
-
const pages = (readJson3(
|
|
26912
|
-
const posts = readJson3(
|
|
26913
|
-
const docs = [...new Set((readJson3(
|
|
26914
|
-
const forms = (readJson3(
|
|
26973
|
+
const pages = (readJson3(join13(root, MOVED_PAGES_FILE)) ?? []).slice(0, 150).map((p) => ({ path: cut(p.path, 300), title: cut(p.title, 80), inNav: Boolean(p.inNav) }));
|
|
26974
|
+
const posts = readJson3(join13(root, "src/kit/moved-posts.json")) ?? [];
|
|
26975
|
+
const docs = [...new Set((readJson3(join13(root, MOVED_LEGAL_FILE))?.docs ?? []).map((d) => d.key).filter((k) => k === "privacy" || k === "terms" || k === "cancellation"))];
|
|
26976
|
+
const forms = (readJson3(join13(root, "src/kit/forms.json")) ?? []).filter((f) => /^[a-z0-9-]{1,40}$/.test(f.key ?? "")).slice(0, 30).map((f) => ({
|
|
26915
26977
|
key: f.key,
|
|
26916
26978
|
label: cut(f.label, 80),
|
|
26917
26979
|
...f.page ? { page: cut(f.page, 300) } : {},
|
|
@@ -26922,11 +26984,11 @@ function kitMap(root) {
|
|
|
26922
26984
|
}
|
|
26923
26985
|
async function sendReport(root, ctx, host, open2, verify) {
|
|
26924
26986
|
const dir = hostDir(root, host);
|
|
26925
|
-
const inv = readJson3(
|
|
26987
|
+
const inv = readJson3(join13(dir, "inventory.json"));
|
|
26926
26988
|
const site = readJson3(tagsFile(dir));
|
|
26927
26989
|
const startId = readChoices(root)?.startId;
|
|
26928
26990
|
if (!inv || !site) return;
|
|
26929
|
-
const dns = readJson3(
|
|
26991
|
+
const dns = readJson3(join13(dir, "dns.json"));
|
|
26930
26992
|
const thanksPages = findThanksPages(inv.pages);
|
|
26931
26993
|
if (open2 === "scan") {
|
|
26932
26994
|
if (thanksPages.length && site.forms.length) {
|
|
@@ -26956,9 +27018,9 @@ async function sendReport(root, ctx, host, open2, verify) {
|
|
|
26956
27018
|
return;
|
|
26957
27019
|
}
|
|
26958
27020
|
const state = readJson3(stateFile(dir)) ?? {};
|
|
26959
|
-
const plan =
|
|
26960
|
-
const saved = verify ?? readJson3(
|
|
26961
|
-
const assets = readJson3(
|
|
27021
|
+
const plan = existsSync12(join13(root, MIGRATION_DIR, "plan.md")) ? readFileSync10(join13(root, MIGRATION_DIR, "plan.md"), "utf8") : "";
|
|
27022
|
+
const saved = verify ?? readJson3(join13(dir, "verify-report.json"))?.report ?? null;
|
|
27023
|
+
const assets = readJson3(join13(dir, "assets.json")) ?? [];
|
|
26962
27024
|
const report2 = {
|
|
26963
27025
|
source: inv.source,
|
|
26964
27026
|
platform: inv.platform,
|
|
@@ -27015,7 +27077,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
27015
27077
|
out(`Scanning ${base} (${platform3})`);
|
|
27016
27078
|
const robotsRes = await get(`${origin}/robots.txt`, "text/plain");
|
|
27017
27079
|
const robots = robotsRes?.ok ? await robotsRes.text() : "";
|
|
27018
|
-
if (robots)
|
|
27080
|
+
if (robots) writeFileSync10(join13(dir, "robots.txt"), robots);
|
|
27019
27081
|
const cap = Math.min(opts.max ?? PAGE_CAP, PAGE_CAP);
|
|
27020
27082
|
const fromSitemaps = await sitemapUrls(base, robots ? parseRobots(robots).sitemaps : [], cap * 5);
|
|
27021
27083
|
const all = [.../* @__PURE__ */ new Set([`${base}/`, ...fromSitemaps.urls, ...fromSitemaps.urls.length ? [] : homeLinks(html, base)])];
|
|
@@ -27055,7 +27117,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
27055
27117
|
await addStylesheetAssets(assets);
|
|
27056
27118
|
const wordpressApi = platform3 === "wordpress" ? await wordpressContent(base, dir) : false;
|
|
27057
27119
|
if (wordpressApi) {
|
|
27058
|
-
const media = readJson3(
|
|
27120
|
+
const media = readJson3(join13(dir, "content", "media.json")) ?? [];
|
|
27059
27121
|
media.forEach((m) => m.source_url && assets.add(m.source_url));
|
|
27060
27122
|
}
|
|
27061
27123
|
const known = new Set(pages.map((p) => p.path));
|
|
@@ -27080,13 +27142,13 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
27080
27142
|
const bare = registrableDomain(host);
|
|
27081
27143
|
try {
|
|
27082
27144
|
const { records, unread } = await collectSnapshot(bare, { extraNames: [...site.ownNames, ...site.serverContainers], deadlineMs: 3e4 });
|
|
27083
|
-
writeJson(
|
|
27145
|
+
writeJson(join13(dir, "dns.json"), { records: records.slice(0, 600), unread: unread.slice(0, 300), services: dnsServices(records).slice(0, 40) });
|
|
27084
27146
|
} catch {
|
|
27085
27147
|
}
|
|
27086
27148
|
const inventory = { source: base, platform: platform3, scannedAt: (/* @__PURE__ */ new Date()).toISOString(), sitemaps: fromSitemaps.sitemaps, pages, wordpressApi, skipped: Math.max(0, all.length - list.length) };
|
|
27087
|
-
writeJson(
|
|
27088
|
-
writeJson(
|
|
27089
|
-
|
|
27149
|
+
writeJson(join13(dir, "inventory.json"), inventory);
|
|
27150
|
+
writeJson(join13(dir, "assets.json"), [...assets].sort());
|
|
27151
|
+
writeFileSync10(join13(dir, "home.html"), html);
|
|
27090
27152
|
const icons = await saveOldIcons(html, home.url, origin, dir);
|
|
27091
27153
|
await saveOldStyles(html, home.url, dir);
|
|
27092
27154
|
const rel = relative(root, dir).split(sep).join("/");
|
|
@@ -27100,7 +27162,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
27100
27162
|
if (icons) out(` icons/ ${icons} icons and logo of the old site, for: npx deployai@latest brand favicon`);
|
|
27101
27163
|
if (wordpressApi) {
|
|
27102
27164
|
out(" content/ the WordPress pages, posts, categories, tags, media and authors as JSON");
|
|
27103
|
-
if (
|
|
27165
|
+
if (existsSync12(join13(dir, "posts"))) out(" posts/ the posts as Markdown for the blog block, each with its old address");
|
|
27104
27166
|
} else if (platform3 === "wordpress") out(" The WordPress API is closed on this site: work from the pages, or ask the owner for an export (Tools > Export).");
|
|
27105
27167
|
out();
|
|
27106
27168
|
out("Keep every path in inventory.json exactly as it is: same address, same title and description.");
|
|
@@ -27120,8 +27182,8 @@ async function migrateMediaCommand(root) {
|
|
|
27120
27182
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27121
27183
|
for (const host of hosts) {
|
|
27122
27184
|
const dir = hostDir(root, host);
|
|
27123
|
-
const assets = readJson3(
|
|
27124
|
-
const stateFile2 =
|
|
27185
|
+
const assets = readJson3(join13(dir, "assets.json")) ?? [];
|
|
27186
|
+
const stateFile2 = join13(dir, "media-state.json");
|
|
27125
27187
|
const state = readJson3(stateFile2) ?? { done: [], failed: [], bytes: 0 };
|
|
27126
27188
|
const done = new Set(state.done);
|
|
27127
27189
|
const todo = assets.filter((a) => !done.has(a));
|
|
@@ -27151,7 +27213,7 @@ async function migrateMediaCommand(root) {
|
|
|
27151
27213
|
}
|
|
27152
27214
|
state.done = [...done];
|
|
27153
27215
|
writeJson(stateFile2, state);
|
|
27154
|
-
out(` ${formatBytes(state.bytes)} in ${relative(root,
|
|
27216
|
+
out(` ${formatBytes(state.bytes)} in ${relative(root, join13(dir, "media")).split(sep).join("/")}${state.failed.length ? `, ${state.failed.length} could not be downloaded (listed in media-state.json)` : ""}`);
|
|
27155
27217
|
}
|
|
27156
27218
|
out("Copy the files the new pages use into the site's public folder at the same path (for example public/wp-content/uploads/...), so old image addresses keep working.");
|
|
27157
27219
|
}
|
|
@@ -27172,19 +27234,19 @@ function redirectLines(inv, rss = "/rss.xml") {
|
|
|
27172
27234
|
function migratePostsCommand(root) {
|
|
27173
27235
|
const hosts = scannedHosts(root);
|
|
27174
27236
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27175
|
-
if (!
|
|
27237
|
+
if (!existsSync12(join13(root, "src/kit/schema.ts"))) throw new CliError("The dashboard is not in this folder yet. Run: npx deployai@latest blocks dashboard", 1, "usage");
|
|
27176
27238
|
const posts = [];
|
|
27177
27239
|
for (const host of hosts) {
|
|
27178
27240
|
const dir = hostDir(root, host);
|
|
27179
|
-
const inv = readJson3(
|
|
27180
|
-
const list = readJson3(
|
|
27181
|
-
if (inv && list?.length) posts.push(...wpPostsToKit({ origin: new URL(inv.source).origin, posts: list, categories: readJson3(
|
|
27241
|
+
const inv = readJson3(join13(dir, "inventory.json"));
|
|
27242
|
+
const list = readJson3(join13(dir, "content", "posts.json"));
|
|
27243
|
+
if (inv && list?.length) posts.push(...wpPostsToKit({ origin: new URL(inv.source).origin, posts: list, categories: readJson3(join13(dir, "content", "categories.json")) ?? [], media: readJson3(join13(dir, "content", "media.json")) ?? [] }));
|
|
27182
27244
|
}
|
|
27183
27245
|
if (!posts.length) {
|
|
27184
27246
|
out("No posts in the scan. If the old site has posts, write src/kit/moved-posts.json yourself: .deployai/blocks/dashboard.md says how.");
|
|
27185
27247
|
return;
|
|
27186
27248
|
}
|
|
27187
|
-
|
|
27249
|
+
writeFileSync10(join13(root, "src/kit/moved-posts.json"), JSON.stringify(posts.map(({ lost: _lost, ...p }) => p), null, 1));
|
|
27188
27250
|
out(`Wrote ${posts.length} posts to src/kit/moved-posts.json. Turn on blog in src/kit/site.config.ts.`);
|
|
27189
27251
|
const short = posts.filter((p) => p.lost.length);
|
|
27190
27252
|
if (short.length) {
|
|
@@ -27195,31 +27257,31 @@ function migratePostsCommand(root) {
|
|
|
27195
27257
|
function migratePagesCommand(root) {
|
|
27196
27258
|
const hosts = scannedHosts(root);
|
|
27197
27259
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27198
|
-
if (!
|
|
27199
|
-
const file2 =
|
|
27260
|
+
if (!existsSync12(join13(root, "src/kit/schema.ts"))) throw new CliError("The dashboard is not in this folder yet. Run: npx deployai@latest blocks dashboard", 1, "usage");
|
|
27261
|
+
const file2 = join13(root, MOVED_PAGES_FILE);
|
|
27200
27262
|
const before = readJson3(file2);
|
|
27201
27263
|
const pages = [];
|
|
27202
27264
|
for (const host of hosts) {
|
|
27203
27265
|
const dir = hostDir(root, host);
|
|
27204
|
-
const inv = readJson3(
|
|
27266
|
+
const inv = readJson3(join13(dir, "inventory.json"));
|
|
27205
27267
|
if (!inv) continue;
|
|
27206
|
-
const homeHtml =
|
|
27268
|
+
const homeHtml = existsSync12(join13(dir, "home.html")) ? readFileSync10(join13(dir, "home.html"), "utf8") : null;
|
|
27207
27269
|
for (const p of movedPagesFromScan({ pages: inv.pages, homeHtml, origin: new URL(inv.source).origin })) if (!pages.some((x) => x.path === p.path)) pages.push(p);
|
|
27208
27270
|
}
|
|
27209
27271
|
const kept = before?.length ? pages.filter((p) => before.some((b) => b.path === p.path)) : pages;
|
|
27210
|
-
|
|
27272
|
+
writeFileSync10(file2, JSON.stringify(kept, null, 1));
|
|
27211
27273
|
out(`Wrote ${MOVED_PAGES_FILE}: ${kept.length} pages for the dashboard's Pages, ${kept.filter((p) => p.inNav).length} of them in the menu.`);
|
|
27212
27274
|
out("Build each page at exactly its path, as a page of the site's code with its own look and words. Draw the site's menu from navItems() in src/kit/store.ts. A page the plan drops: remove it from this file.");
|
|
27213
27275
|
}
|
|
27214
27276
|
function migrateLegalCommand(root) {
|
|
27215
27277
|
const hosts = scannedHosts(root);
|
|
27216
27278
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27217
|
-
if (!
|
|
27279
|
+
if (!existsSync12(join13(root, "src/kit/schema.ts"))) throw new CliError("The dashboard is not in this folder yet. Run: npx deployai@latest blocks dashboard", 1, "usage");
|
|
27218
27280
|
const pages = [];
|
|
27219
27281
|
const site = emptySiteTags();
|
|
27220
27282
|
for (const host of hosts) {
|
|
27221
27283
|
const dir = hostDir(root, host);
|
|
27222
|
-
pages.push(...readJson3(
|
|
27284
|
+
pages.push(...readJson3(join13(dir, "inventory.json"))?.pages ?? []);
|
|
27223
27285
|
const found = readJson3(tagsFile(dir));
|
|
27224
27286
|
if (found) {
|
|
27225
27287
|
site.tags.push(...found.tags);
|
|
@@ -27227,9 +27289,9 @@ function migrateLegalCommand(root) {
|
|
|
27227
27289
|
site.forms.push(...found.forms);
|
|
27228
27290
|
}
|
|
27229
27291
|
}
|
|
27230
|
-
const file2 =
|
|
27292
|
+
const file2 = join13(root, MOVED_LEGAL_FILE);
|
|
27231
27293
|
const legal = { ...movedLegalFromScan({ pages, site }), docs: readJson3(file2)?.docs ?? [] };
|
|
27232
|
-
|
|
27294
|
+
writeFileSync10(file2, JSON.stringify(legal, null, 1));
|
|
27233
27295
|
out(`Wrote ${MOVED_LEGAL_FILE}: ${legal.duties.length} rows for the dashboard's Documents page, ${legal.forms.length} forms, ${legal.services.length} outside services.`);
|
|
27234
27296
|
for (const d of legal.duties) if (d.old) out(` ${d.key}: the old site has its own page at ${d.old}. Keep it. See "Accessibility and documents" in .deployai/blocks/dashboard.md.`);
|
|
27235
27297
|
out("Nothing here is finished or checked: it tells the owner what to look at. Keep tags, forms and pages as they are.");
|
|
@@ -27239,22 +27301,22 @@ function migrateRedirectsCommand(root) {
|
|
|
27239
27301
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27240
27302
|
const lines = /* @__PURE__ */ new Set();
|
|
27241
27303
|
for (const host of hosts) {
|
|
27242
|
-
const inv = readJson3(
|
|
27304
|
+
const inv = readJson3(join13(hostDir(root, host), "inventory.json"));
|
|
27243
27305
|
if (inv) redirectLines(inv).forEach((l) => lines.add(l));
|
|
27244
27306
|
}
|
|
27245
|
-
const publicDir =
|
|
27246
|
-
const file2 =
|
|
27247
|
-
const before =
|
|
27307
|
+
const publicDir = join13(root, "public");
|
|
27308
|
+
const file2 = join13(existsSync12(publicDir) ? publicDir : root, "_redirects");
|
|
27309
|
+
const before = existsSync12(file2) ? readFileSync10(file2, "utf8").split(/\r?\n/).filter(Boolean) : [];
|
|
27248
27310
|
const added = [...lines].filter((l) => !before.some((b) => b.split(/\s+/)[0] === l.split(/\s+/)[0]));
|
|
27249
|
-
|
|
27311
|
+
writeFileSync10(file2, [...before, ...added].join("\n") + "\n");
|
|
27250
27312
|
out(`${relative(root, file2).split(sep).join("/")}: ${added.length} added, ${before.length + added.length} in all (at most 2,000; no query strings).`);
|
|
27251
27313
|
out('Add a line "<old path> <new path> 301" only for a page that truly could not keep its address.');
|
|
27252
27314
|
}
|
|
27253
27315
|
function allowedRedirects(root) {
|
|
27254
27316
|
const map2 = /* @__PURE__ */ new Map();
|
|
27255
|
-
for (const file2 of [
|
|
27256
|
-
if (!
|
|
27257
|
-
for (const line of
|
|
27317
|
+
for (const file2 of [join13(root, "public", "_redirects"), join13(root, "_redirects")]) {
|
|
27318
|
+
if (!existsSync12(file2)) continue;
|
|
27319
|
+
for (const line of readFileSync10(file2, "utf8").split(/\r?\n/)) {
|
|
27258
27320
|
const [from, to] = line.trim().split(/\s+/);
|
|
27259
27321
|
if (from && to && !from.startsWith("#")) map2.set(from, to);
|
|
27260
27322
|
}
|
|
@@ -27284,11 +27346,11 @@ async function migrateTagsCommand(root, ctx, opts) {
|
|
|
27284
27346
|
const [k, v] = a.split("=");
|
|
27285
27347
|
if (!QUESTION_KEYS.includes(k) || !ANSWERS.includes(v)) throw new CliError(`Not an answer: ${a}. Use one of ${QUESTION_KEYS.join(", ")} = ${ANSWERS.join(", ")}, for example serverPixel=yes.`, 1, "usage");
|
|
27286
27348
|
}
|
|
27287
|
-
const urls = opts.requests ?
|
|
27349
|
+
const urls = opts.requests ? readFileSync10(resolve(root, opts.requests), "utf8").split(/\r?\n/) : [];
|
|
27288
27350
|
for (const host of hosts) {
|
|
27289
27351
|
const dir = hostDir(root, host);
|
|
27290
27352
|
const site = readJson3(tagsFile(dir));
|
|
27291
|
-
const inv = readJson3(
|
|
27353
|
+
const inv = readJson3(join13(dir, "inventory.json"));
|
|
27292
27354
|
if (!site || !inv) continue;
|
|
27293
27355
|
const state = readJson3(stateFile(dir)) ?? {};
|
|
27294
27356
|
if (urls.length && opts.fired) {
|
|
@@ -27358,7 +27420,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
27358
27420
|
const tagFindings = [];
|
|
27359
27421
|
const perHost = [];
|
|
27360
27422
|
for (const host of hosts) {
|
|
27361
|
-
const inv = readJson3(
|
|
27423
|
+
const inv = readJson3(join13(hostDir(root, host), "inventory.json"));
|
|
27362
27424
|
const oldSite = readJson3(tagsFile(hostDir(root, host)));
|
|
27363
27425
|
const state = readJson3(stateFile(hostDir(root, host))) ?? {};
|
|
27364
27426
|
const nextSite = emptySiteTags();
|
|
@@ -27407,7 +27469,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
27407
27469
|
}
|
|
27408
27470
|
}
|
|
27409
27471
|
const words = { missing: "not found on the preview", moved: "moved to", error: "answers", title_lost: "lost its title", description_lost: "lost its description" };
|
|
27410
|
-
const report2 =
|
|
27472
|
+
const report2 = join13(root, MIGRATION_DIR, "verify.json");
|
|
27411
27473
|
writeJson(report2, { checkedAt: (/* @__PURE__ */ new Date()).toISOString(), preview: preview.origin, checked, findings, credits: [...credits.keys()], vendors: [...vendors.keys()], tags: tagFindings });
|
|
27412
27474
|
if (credits.size) {
|
|
27413
27475
|
out(`A builder's credit is still on the preview:`);
|
|
@@ -27432,7 +27494,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
27432
27494
|
for (const h of perHost) {
|
|
27433
27495
|
const dir = hostDir(root, h.host);
|
|
27434
27496
|
const verify = { checkedAt: (/* @__PURE__ */ new Date()).toISOString(), pagesChecked: h.checked, pageProblems: h.problems, findings: h.found.map((f) => ({ problem: f.problem, what: f.what.slice(0, 240), ...f.detail ? { detail: f.detail.slice(0, 300) } : {}, ...f.page ? { page: f.page.slice(0, 300) } : {} })).slice(0, 300), seen: h.seen.slice(0, 300), removed: h.removed, vendors: [...vendors.keys()].map((v) => v.slice(0, 80)).slice(0, 40) };
|
|
27435
|
-
writeJson(
|
|
27497
|
+
writeJson(join13(dir, "verify-report.json"), { report: verify });
|
|
27436
27498
|
await sendReport(root, ctx, h.host, clean3 ? "verify" : null, verify);
|
|
27437
27499
|
}
|
|
27438
27500
|
if (!findings.length) {
|
|
@@ -27560,32 +27622,32 @@ async function askYes(question) {
|
|
|
27560
27622
|
}
|
|
27561
27623
|
|
|
27562
27624
|
// src/same-name.ts
|
|
27563
|
-
import { createHash } from "crypto";
|
|
27564
|
-
import { mkdirSync as mkdirSync7, readFileSync as
|
|
27565
|
-
import { dirname as dirname3, join as
|
|
27625
|
+
import { createHash as createHash2 } from "crypto";
|
|
27626
|
+
import { mkdirSync as mkdirSync7, readFileSync as readFileSync11, writeFileSync as writeFileSync11 } from "fs";
|
|
27627
|
+
import { dirname as dirname3, join as join14 } from "path";
|
|
27566
27628
|
var LAST_FILES = ".deployai/last-files.json";
|
|
27567
27629
|
var KEPT = /^(public|static)\/.*\.(avif|webp|png|jpe?g|gif|svg|ico|woff2?|ttf|otf|mp4|webm|css|js|mjs)$/i;
|
|
27568
27630
|
var HASHED = /[.-][A-Za-z0-9_]{6,20}\.[a-z0-9]+$/;
|
|
27569
|
-
var digest = (abs) =>
|
|
27631
|
+
var digest = (abs) => createHash2("sha1").update(readFileSync11(abs)).digest("hex").slice(0, 16);
|
|
27570
27632
|
function changedUnderSameName(root, files) {
|
|
27571
27633
|
const now = {};
|
|
27572
27634
|
for (const f of files) if (KEPT.test(f.rel) && !HASHED.test(f.rel.split("/").pop() ?? "")) now[f.rel] = digest(f.abs);
|
|
27573
27635
|
let before = {};
|
|
27574
27636
|
try {
|
|
27575
|
-
before = readJson(
|
|
27637
|
+
before = readJson(join14(root, LAST_FILES));
|
|
27576
27638
|
} catch {
|
|
27577
27639
|
}
|
|
27578
27640
|
const changed = Object.keys(now).filter((rel) => before[rel] && before[rel] !== now[rel]).sort();
|
|
27579
27641
|
try {
|
|
27580
|
-
mkdirSync7(dirname3(
|
|
27581
|
-
|
|
27642
|
+
mkdirSync7(dirname3(join14(root, LAST_FILES)), { recursive: true });
|
|
27643
|
+
writeFileSync11(join14(root, LAST_FILES), JSON.stringify(now));
|
|
27582
27644
|
} catch {
|
|
27583
27645
|
}
|
|
27584
27646
|
return changed;
|
|
27585
27647
|
}
|
|
27586
27648
|
|
|
27587
27649
|
// src/tar.ts
|
|
27588
|
-
import { readFileSync as
|
|
27650
|
+
import { readFileSync as readFileSync12 } from "fs";
|
|
27589
27651
|
import { gzipSync } from "zlib";
|
|
27590
27652
|
var BLOCK = 512;
|
|
27591
27653
|
function writeString(buf, offset, length, value) {
|
|
@@ -27669,7 +27731,7 @@ function packFiles(files) {
|
|
|
27669
27731
|
return createTarGz(
|
|
27670
27732
|
files.map((f) => ({
|
|
27671
27733
|
name: f.rel,
|
|
27672
|
-
data:
|
|
27734
|
+
data: readFileSync12(f.abs),
|
|
27673
27735
|
mtimeMs: f.mtimeMs,
|
|
27674
27736
|
mode: f.mode & 64 ? 493 : 420
|
|
27675
27737
|
}))
|
|
@@ -28267,13 +28329,13 @@ async function claimCommand(root, ctx, opts) {
|
|
|
28267
28329
|
|
|
28268
28330
|
// src/commands/pull.ts
|
|
28269
28331
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
28270
|
-
import { existsSync as
|
|
28271
|
-
import { join as
|
|
28332
|
+
import { existsSync as existsSync14, readdirSync as readdirSync5, rmSync as rmSync2 } from "fs";
|
|
28333
|
+
import { join as join16 } from "path";
|
|
28272
28334
|
|
|
28273
28335
|
// src/commands/samples.ts
|
|
28274
28336
|
import { createInterface as createInterface3 } from "readline/promises";
|
|
28275
|
-
import { existsSync as
|
|
28276
|
-
import { dirname as dirname4, join as
|
|
28337
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync8, readdirSync as readdirSync4, writeFileSync as writeFileSync12 } from "fs";
|
|
28338
|
+
import { dirname as dirname4, join as join15, relative as relative2, resolve as resolve2, sep as sep2 } from "path";
|
|
28277
28339
|
import { gunzipSync } from "zlib";
|
|
28278
28340
|
var SAMPLES = [
|
|
28279
28341
|
{ key: "landing", title: "Landing page: a full one-page site with WhatsApp sign-up", stack: "static HTML and CSS" },
|
|
@@ -28294,7 +28356,7 @@ function listSamples(apiUrl) {
|
|
|
28294
28356
|
out(`See them live: ${apiUrl}/samples`);
|
|
28295
28357
|
}
|
|
28296
28358
|
function filesIn(dir) {
|
|
28297
|
-
return
|
|
28359
|
+
return existsSync13(dir) ? readdirSync4(dir).filter((f) => !IGNORED.has(f)) : [];
|
|
28298
28360
|
}
|
|
28299
28361
|
function freeFolder(cwd, key) {
|
|
28300
28362
|
for (let n2 = 1; ; n2++) {
|
|
@@ -28354,7 +28416,7 @@ function extractInto(gz, root, damaged) {
|
|
|
28354
28416
|
const target = resolve2(base, e3.name);
|
|
28355
28417
|
if (target !== base && !target.startsWith(base + sep2)) continue;
|
|
28356
28418
|
mkdirSync8(dirname4(target), { recursive: true });
|
|
28357
|
-
|
|
28419
|
+
writeFileSync12(target, e3.data);
|
|
28358
28420
|
written++;
|
|
28359
28421
|
}
|
|
28360
28422
|
return written;
|
|
@@ -28378,7 +28440,7 @@ async function samplesCommand(cwd, ctx, key, opts = {}) {
|
|
|
28378
28440
|
}
|
|
28379
28441
|
const written = await downloadSample(ctx, sample.key, root);
|
|
28380
28442
|
const base = resolve2(root);
|
|
28381
|
-
const hasPackage =
|
|
28443
|
+
const hasPackage = existsSync13(join15(base, "package.json"));
|
|
28382
28444
|
out(base === resolve2(cwd) ? `Downloaded the ${sample.key} sample: ${written} files.` : `Downloaded the ${sample.key} sample into the new folder ${relative2(cwd, base)}: ${written} files. Work in that folder from now on.`);
|
|
28383
28445
|
out("");
|
|
28384
28446
|
const t = messages(base);
|
|
@@ -28435,7 +28497,7 @@ var git = (root, args, env = {}) => spawnSync2("git", args, { cwd: root, encodin
|
|
|
28435
28497
|
function clearTree(root) {
|
|
28436
28498
|
for (const name of readdirSync5(root)) {
|
|
28437
28499
|
if (name === ".git" || name === ".deployai") continue;
|
|
28438
|
-
rmSync2(
|
|
28500
|
+
rmSync2(join16(root, name), { recursive: true, force: true });
|
|
28439
28501
|
}
|
|
28440
28502
|
}
|
|
28441
28503
|
async function pullHistory(root, ctx, projectId) {
|
|
@@ -28445,7 +28507,7 @@ async function pullHistory(root, ctx, projectId) {
|
|
|
28445
28507
|
const live = versions.find((v) => v.isLive)?.number ?? Math.max(0, ...versions.filter((v) => v.status === "ready").map((v) => v.number));
|
|
28446
28508
|
const chosen = versions.filter((v) => v.number <= live && v.status !== "failed" && v.status !== "queued").sort((a, b) => a.number - b.number);
|
|
28447
28509
|
if (!chosen.length) throw new CliError(t("pullNoSource"), 1, "not_found");
|
|
28448
|
-
if (!
|
|
28510
|
+
if (!existsSync14(join16(root, ".git")) && git(root, ["init", "-q"]).status !== 0) throw new CliError(t("pullNoGit"), 1, "usage");
|
|
28449
28511
|
for (const v of chosen) {
|
|
28450
28512
|
const gz = await fetchSource(root, ctx, projectId, v.number).catch(() => null);
|
|
28451
28513
|
if (!gz) continue;
|
|
@@ -28496,12 +28558,12 @@ async function requestsOpenCommand(root, ctx, path, open2) {
|
|
|
28496
28558
|
|
|
28497
28559
|
// src/commands/start.ts
|
|
28498
28560
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
28499
|
-
import { existsSync as
|
|
28500
|
-
import { join as
|
|
28561
|
+
import { existsSync as existsSync15, writeFileSync as writeFileSync14 } from "fs";
|
|
28562
|
+
import { join as join18, relative as relative3, resolve as resolve3 } from "path";
|
|
28501
28563
|
|
|
28502
28564
|
// src/commands/starter.ts
|
|
28503
|
-
import { writeFileSync as
|
|
28504
|
-
import { join as
|
|
28565
|
+
import { writeFileSync as writeFileSync13 } from "fs";
|
|
28566
|
+
import { join as join17 } from "path";
|
|
28505
28567
|
var esc2 = (s) => s.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
28506
28568
|
var TEXT = {
|
|
28507
28569
|
he: { title: "\u05D4\u05D0\u05EA\u05E8 \u05E9\u05DC\u05D9", soon: "\u05D4\u05D0\u05EA\u05E8 \u05D1\u05D1\u05E0\u05D9\u05D9\u05D4, \u05D1\u05E7\u05E8\u05D5\u05D1 \u05DB\u05D0\u05DF." },
|
|
@@ -28549,8 +28611,8 @@ DeployAI wrote this page so the folder starts as a working site. Build the owner
|
|
|
28549
28611
|
- Delete this README or replace it with notes about the site.
|
|
28550
28612
|
`;
|
|
28551
28613
|
function writeStarter(root, name, lang, stack) {
|
|
28552
|
-
|
|
28553
|
-
|
|
28614
|
+
writeFileSync13(join17(root, "index.html"), page2(name ?? "", lang, stack));
|
|
28615
|
+
writeFileSync13(join17(root, "README.md"), README);
|
|
28554
28616
|
}
|
|
28555
28617
|
|
|
28556
28618
|
// src/commands/start.ts
|
|
@@ -28624,7 +28686,7 @@ async function startCommand(cwd, ctx, id, opts = {}) {
|
|
|
28624
28686
|
if (sample && !sameSite) {
|
|
28625
28687
|
const written = await downloadSample(ctxNow, sample.key, root);
|
|
28626
28688
|
done.push(t("startDownloaded", { key: sample.key, n: written }));
|
|
28627
|
-
if (
|
|
28689
|
+
if (existsSync15(join18(root, "package.json"))) {
|
|
28628
28690
|
if (opts.install !== false && install(root)) done.push(t("startInstalled"));
|
|
28629
28691
|
else steps.unshift({ cmd: "npm install", say: "Installs the sample's packages." });
|
|
28630
28692
|
}
|
|
@@ -28649,7 +28711,7 @@ async function startCommand(cwd, ctx, id, opts = {}) {
|
|
|
28649
28711
|
const stackText = choices.stack ? stackBlock(choices.stack) : "";
|
|
28650
28712
|
if (choices.brief || stackText) {
|
|
28651
28713
|
ensureDeployaiDir(root);
|
|
28652
|
-
|
|
28714
|
+
writeFileSync14(join18(root, BRIEF_FILE), [choices.brief ? `# The owner's details
|
|
28653
28715
|
|
|
28654
28716
|
${choices.brief}
|
|
28655
28717
|
` : "", stackText].filter(Boolean).join("\n"));
|
|
@@ -28707,14 +28769,14 @@ ${choices.brief}
|
|
|
28707
28769
|
for (const line of server.extra) say(line);
|
|
28708
28770
|
say(rule(server, "startFail", START_FAIL_LINE));
|
|
28709
28771
|
ensureDeployaiDir(root);
|
|
28710
|
-
|
|
28772
|
+
writeFileSync14(join18(root, START_FILE), `${lines.join("\n")}
|
|
28711
28773
|
`);
|
|
28712
28774
|
}
|
|
28713
28775
|
|
|
28714
28776
|
// src/commands/addon.ts
|
|
28715
|
-
import { dirname as dirname5, join as
|
|
28777
|
+
import { dirname as dirname5, join as join19, resolve as resolve4 } from "path";
|
|
28716
28778
|
import { mkdirSync as mkdirSync9 } from "fs";
|
|
28717
|
-
import { existsSync as
|
|
28779
|
+
import { existsSync as existsSync16, writeFileSync as writeFileSync15 } from "fs";
|
|
28718
28780
|
function linkedProjectId2(root) {
|
|
28719
28781
|
const id = readProject(root)?.projectId;
|
|
28720
28782
|
if (!id) throw new CliError("This folder is not linked to a DeployAI site. Run: npx deployai@latest login, then npx deployai@latest link", 1, "not_linked");
|
|
@@ -28771,7 +28833,7 @@ async function addonsRunCommand(root, ctx, opts = {}) {
|
|
|
28771
28833
|
const all = opts.all === true || !opts.oneByOne && readProject(root)?.addonsAll === true;
|
|
28772
28834
|
if (!order && r.picked && !r.agreed && todo.length > 1 && (opts.all || !all)) {
|
|
28773
28835
|
const stamps = readStamps(root);
|
|
28774
|
-
const items = todo.map((a) => ({ ...a, trace: addonTrace(a.key, (path) =>
|
|
28836
|
+
const items = todo.map((a) => ({ ...a, trace: addonTrace(a.key, (path) => existsSync16(join19(root, path)), stamps) }));
|
|
28775
28837
|
addonOrderBrief(items, opts.all ? "all" : opts.oneByOne ? "one-by-one" : null).forEach((line) => out(line));
|
|
28776
28838
|
return;
|
|
28777
28839
|
}
|
|
@@ -28819,19 +28881,19 @@ async function addonBuyCommand(root, ctx, key) {
|
|
|
28819
28881
|
}
|
|
28820
28882
|
function readStamps(root) {
|
|
28821
28883
|
try {
|
|
28822
|
-
return readJson(
|
|
28884
|
+
return readJson(join19(root, ADDON_STAMP_FILE));
|
|
28823
28885
|
} catch {
|
|
28824
28886
|
return {};
|
|
28825
28887
|
}
|
|
28826
28888
|
}
|
|
28827
28889
|
function writeStamps(root, stamps) {
|
|
28828
|
-
const file2 =
|
|
28890
|
+
const file2 = join19(root, ADDON_STAMP_FILE);
|
|
28829
28891
|
mkdirSync9(dirname5(file2), { recursive: true });
|
|
28830
|
-
|
|
28892
|
+
writeFileSync15(file2, JSON.stringify(stamps, null, 2));
|
|
28831
28893
|
}
|
|
28832
28894
|
function printAddon(root, a) {
|
|
28833
28895
|
const stamps = readStamps(root);
|
|
28834
|
-
const trace = addonTrace(a.key, (path) =>
|
|
28896
|
+
const trace = addonTrace(a.key, (path) => existsSync16(join19(root, path)), stamps);
|
|
28835
28897
|
writeStamps(root, { ...stamps, [a.key]: { ...stamps[a.key], runId: a.runId } });
|
|
28836
28898
|
out(`DeployAI add-on ${a.position} of ${a.total}: ${a.name} (${a.key}, run ${a.runId}).`);
|
|
28837
28899
|
const line = addonTraceLine(a.key, a.runId, trace);
|
|
@@ -28890,9 +28952,9 @@ async function addonDoneCommand(root, ctx, runId, opts) {
|
|
|
28890
28952
|
|
|
28891
28953
|
// src/commands/speed.ts
|
|
28892
28954
|
import { spawn as spawn3 } from "child_process";
|
|
28893
|
-
import { mkdtempSync, readFileSync as
|
|
28955
|
+
import { mkdtempSync, readFileSync as readFileSync13, rmSync as rmSync3 } from "fs";
|
|
28894
28956
|
import { tmpdir } from "os";
|
|
28895
|
-
import { join as
|
|
28957
|
+
import { join as join20 } from "path";
|
|
28896
28958
|
var ms = (v) => v >= 1e3 ? `${(v / 1e3).toFixed(1)} s` : `${Math.round(v)} ms`;
|
|
28897
28959
|
var LOCAL_WAIT_MS = 18e4;
|
|
28898
28960
|
function runLighthouse(url2, strategy, browser, file2) {
|
|
@@ -28916,11 +28978,11 @@ function runLighthouse(url2, strategy, browser, file2) {
|
|
|
28916
28978
|
}
|
|
28917
28979
|
async function localSpeed(url2, strategy, run = runLighthouse, browser = findBrowser()) {
|
|
28918
28980
|
if (!browser) return null;
|
|
28919
|
-
const dir = mkdtempSync(
|
|
28981
|
+
const dir = mkdtempSync(join20(tmpdir(), "deployai-speed-"));
|
|
28920
28982
|
try {
|
|
28921
|
-
const file2 =
|
|
28983
|
+
const file2 = join20(dir, "report.json");
|
|
28922
28984
|
await run(url2, strategy, browser, file2);
|
|
28923
|
-
const lighthouseResult = JSON.parse(
|
|
28985
|
+
const lighthouseResult = JSON.parse(readFileSync13(file2, "utf8"));
|
|
28924
28986
|
return lighthouseResult.categories ? mapPsi({ lighthouseResult }, strategy) : null;
|
|
28925
28987
|
} catch {
|
|
28926
28988
|
return null;
|
|
@@ -28984,8 +29046,8 @@ async function speedCommand(ctx, url2, opts, deps = {}) {
|
|
|
28984
29046
|
|
|
28985
29047
|
// src/commands/shot.ts
|
|
28986
29048
|
import { spawn as spawn4 } from "child_process";
|
|
28987
|
-
import { existsSync as
|
|
28988
|
-
import { join as
|
|
29049
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync10 } from "fs";
|
|
29050
|
+
import { join as join21, resolve as resolve5 } from "path";
|
|
28989
29051
|
var SHOT_SIZES = [{ name: "phone", size: "390,844" }, { name: "desktop", size: "1440,900" }];
|
|
28990
29052
|
var PLAYWRIGHT = "playwright@1.56";
|
|
28991
29053
|
var WAIT_MS3 = 18e4;
|
|
@@ -29021,14 +29083,14 @@ async function shotCommand(root, address, opts = {}, run = runNpx) {
|
|
|
29021
29083
|
const browser = opts.webkit ? null : findBrowser();
|
|
29022
29084
|
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");
|
|
29023
29085
|
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");
|
|
29024
|
-
const dir = resolve5(root, opts.out ??
|
|
29086
|
+
const dir = resolve5(root, opts.out ?? join21(".deployai", "shots"));
|
|
29025
29087
|
mkdirSync10(dir, { recursive: true });
|
|
29026
29088
|
const saved = [];
|
|
29027
29089
|
for (const s of SHOT_SIZES) {
|
|
29028
|
-
const file2 =
|
|
29090
|
+
const file2 = join21(dir, shotName(url2.toString(), s.name));
|
|
29029
29091
|
const engine = opts.webkit ? ["--browser=webkit"] : [`--channel=${channelFor(browser)}`];
|
|
29030
29092
|
const code = await run(["--yes", PLAYWRIGHT, "screenshot", ...engine, `--viewport-size=${s.size}`, "--full-page", "--wait-for-timeout=1500", url2.toString(), file2]);
|
|
29031
|
-
if (code !== 0 || !
|
|
29093
|
+
if (code !== 0 || !existsSync17(file2)) throw new CliError(`The ${s.name} picture of ${url2} could not be taken. Check that the page opens, then run shot again.`, 1, "shot_failed");
|
|
29032
29094
|
saved.push(file2);
|
|
29033
29095
|
out(`${s.name.padEnd(8)} ${file2}`);
|
|
29034
29096
|
}
|
|
@@ -29038,10 +29100,10 @@ async function shotCommand(root, address, opts = {}, run = runNpx) {
|
|
|
29038
29100
|
|
|
29039
29101
|
// src/commands/images.ts
|
|
29040
29102
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
29041
|
-
import { existsSync as
|
|
29103
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync11, readdirSync as readdirSync6, statSync as statSync3, writeFileSync as writeFileSync16 } from "fs";
|
|
29042
29104
|
import { createRequire } from "module";
|
|
29043
29105
|
import { homedir as homedir3 } from "os";
|
|
29044
|
-
import { extname, join as
|
|
29106
|
+
import { extname, join as join22, relative as relative4, resolve as resolve6 } from "path";
|
|
29045
29107
|
var PHONE_WIDTH = 640;
|
|
29046
29108
|
var SHARP = "sharp@0.34";
|
|
29047
29109
|
var SKIP_DIRS2 = /* @__PURE__ */ new Set(["node_modules", ".git", ".deployai", "dist", ".astro", ".next"]);
|
|
@@ -29049,14 +29111,14 @@ function imagesIn(dir) {
|
|
|
29049
29111
|
const found = [];
|
|
29050
29112
|
const walk2 = (d) => {
|
|
29051
29113
|
for (const name of readdirSync6(d)) {
|
|
29052
|
-
const p =
|
|
29114
|
+
const p = join22(d, name);
|
|
29053
29115
|
const st = statSync3(p);
|
|
29054
29116
|
if (st.isDirectory()) {
|
|
29055
29117
|
if (!SKIP_DIRS2.has(name)) walk2(p);
|
|
29056
29118
|
} else if (/\.(jpe?g|png)$/i.test(name)) found.push(p);
|
|
29057
29119
|
}
|
|
29058
29120
|
};
|
|
29059
|
-
if (
|
|
29121
|
+
if (existsSync18(dir)) walk2(dir);
|
|
29060
29122
|
return found.sort();
|
|
29061
29123
|
}
|
|
29062
29124
|
function outputsFor(file2, width) {
|
|
@@ -29066,15 +29128,15 @@ function outputsFor(file2, width) {
|
|
|
29066
29128
|
return list;
|
|
29067
29129
|
}
|
|
29068
29130
|
function loadSharp() {
|
|
29069
|
-
const dir =
|
|
29070
|
-
if (!
|
|
29131
|
+
const dir = join22(homedir3(), ".deployai", "tools", "sharp");
|
|
29132
|
+
if (!existsSync18(join22(dir, "node_modules", "sharp"))) {
|
|
29071
29133
|
mkdirSync11(dir, { recursive: true });
|
|
29072
|
-
if (!
|
|
29134
|
+
if (!existsSync18(join22(dir, "package.json"))) writeFileSync16(join22(dir, "package.json"), '{"private":true}');
|
|
29073
29135
|
out("Getting the image tool once (it stays outside the site)...");
|
|
29074
29136
|
const r = spawnSync4(process.platform === "win32" ? "npm.cmd" : "npm", ["install", SHARP, "--no-audit", "--no-fund", "--silent"], { cwd: dir, stdio: "ignore", shell: process.platform === "win32" });
|
|
29075
29137
|
if (r.status !== 0) throw new CliError("The image tool could not be installed. Check the internet connection and run optimize again.", 1, "images_failed");
|
|
29076
29138
|
}
|
|
29077
|
-
return createRequire(
|
|
29139
|
+
return createRequire(join22(dir, "package.json"))("sharp");
|
|
29078
29140
|
}
|
|
29079
29141
|
async function imagesCommand(root, folder, sharp = loadSharp) {
|
|
29080
29142
|
const dir = resolve6(root, folder ?? "public");
|
|
@@ -29091,7 +29153,7 @@ async function imagesCommand(root, folder, sharp = loadSharp) {
|
|
|
29091
29153
|
const size = statSync3(file2).size;
|
|
29092
29154
|
const meta3 = await make(file2).metadata();
|
|
29093
29155
|
const outputs = outputsFor(file2, meta3.width);
|
|
29094
|
-
if (outputs.every((o) =>
|
|
29156
|
+
if (outputs.every((o) => existsSync18(o.file) && statSync3(o.file).mtimeMs >= statSync3(file2).mtimeMs)) {
|
|
29095
29157
|
skipped++;
|
|
29096
29158
|
continue;
|
|
29097
29159
|
}
|
|
@@ -29110,8 +29172,8 @@ async function imagesCommand(root, folder, sharp = loadSharp) {
|
|
|
29110
29172
|
}
|
|
29111
29173
|
|
|
29112
29174
|
// src/commands/blocks.ts
|
|
29113
|
-
import { createHash as
|
|
29114
|
-
import { existsSync as
|
|
29175
|
+
import { createHash as createHash3 } from "crypto";
|
|
29176
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync12, readFileSync as readFileSync14, writeFileSync as writeFileSync17 } from "fs";
|
|
29115
29177
|
import { dirname as dirname6, resolve as resolve7, sep as sep3 } from "path";
|
|
29116
29178
|
import { gunzipSync as gunzipSync2 } from "zlib";
|
|
29117
29179
|
var BLOCKS = [
|
|
@@ -29121,7 +29183,7 @@ var BLOCKS = [
|
|
|
29121
29183
|
{ key: "late-tags", title: "Tracking tags (Tag Manager, Google, Meta, Clarity) that load a moment after the page shows, at once on conversion pages and ad clicks" }
|
|
29122
29184
|
];
|
|
29123
29185
|
var MAX_BYTES3 = 5 * 1024 * 1024;
|
|
29124
|
-
var sha = (data) =>
|
|
29186
|
+
var sha = (data) => createHash3("sha256").update(data).digest("hex");
|
|
29125
29187
|
var lockPath = (base, key) => resolve7(base, ".deployai", "blocks", `${key}.lock.json`);
|
|
29126
29188
|
function readLock(base, key) {
|
|
29127
29189
|
try {
|
|
@@ -29165,12 +29227,12 @@ async function blocksCommand(root, ctx, name, opts = {}) {
|
|
|
29165
29227
|
if (e3.type !== "0" && e3.type !== "\0") continue;
|
|
29166
29228
|
const target = resolve7(base, e3.name);
|
|
29167
29229
|
if (target === base || !target.startsWith(base + sep3)) continue;
|
|
29168
|
-
if (
|
|
29169
|
-
const now = sha(
|
|
29230
|
+
if (existsSync19(target)) {
|
|
29231
|
+
const now = sha(readFileSync14(target));
|
|
29170
29232
|
if (now === sha(e3.data)) {
|
|
29171
29233
|
lock[e3.name] = now;
|
|
29172
29234
|
} else if (opts.update && lock[e3.name] === now) {
|
|
29173
|
-
|
|
29235
|
+
writeFileSync17(target, e3.data);
|
|
29174
29236
|
lock[e3.name] = sha(e3.data);
|
|
29175
29237
|
updated.push(e3.name);
|
|
29176
29238
|
} else {
|
|
@@ -29179,12 +29241,12 @@ async function blocksCommand(root, ctx, name, opts = {}) {
|
|
|
29179
29241
|
continue;
|
|
29180
29242
|
}
|
|
29181
29243
|
mkdirSync12(dirname6(target), { recursive: true });
|
|
29182
|
-
|
|
29244
|
+
writeFileSync17(target, e3.data);
|
|
29183
29245
|
lock[e3.name] = sha(e3.data);
|
|
29184
29246
|
written.push(e3.name);
|
|
29185
29247
|
}
|
|
29186
29248
|
mkdirSync12(dirname6(lockPath(base, block.key)), { recursive: true });
|
|
29187
|
-
|
|
29249
|
+
writeFileSync17(lockPath(base, block.key), `${JSON.stringify(lock, null, 2)}
|
|
29188
29250
|
`);
|
|
29189
29251
|
out(`Added the ${block.key} block: ${written.length} files.`);
|
|
29190
29252
|
written.forEach((f) => out(` + ${f}`));
|
|
@@ -29245,10 +29307,10 @@ async function integrationsCommand(ctx, name, opts = {}) {
|
|
|
29245
29307
|
|
|
29246
29308
|
// src/commands/brand.ts
|
|
29247
29309
|
import { spawn as spawn5 } from "child_process";
|
|
29248
|
-
import { copyFileSync, existsSync as
|
|
29310
|
+
import { copyFileSync, existsSync as existsSync20, mkdirSync as mkdirSync13, mkdtempSync as mkdtempSync2, readdirSync as readdirSync7, readFileSync as readFileSync15, rmSync as rmSync4, statSync as statSync4, writeFileSync as writeFileSync18 } from "fs";
|
|
29249
29311
|
import { createServer } from "http";
|
|
29250
29312
|
import { tmpdir as tmpdir2 } from "os";
|
|
29251
|
-
import { basename as basename2, dirname as dirname7, extname as extname2, join as
|
|
29313
|
+
import { basename as basename2, dirname as dirname7, extname as extname2, join as join23, relative as relative5, sep as sep4 } from "path";
|
|
29252
29314
|
import { randomBytes } from "crypto";
|
|
29253
29315
|
|
|
29254
29316
|
// src/commands/brand-page.ts
|
|
@@ -29340,7 +29402,7 @@ var WALK_CAP = 4e3;
|
|
|
29340
29402
|
var SKIP_DIRS3 = /* @__PURE__ */ new Set(["node_modules", ".git", ".next", "dist", "build", "out", ".astro", ".output", ".svelte-kit", ".wrangler", ".deployai"]);
|
|
29341
29403
|
var TYPES = { ".svg": "image/svg+xml", ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp", ".gif": "image/gif", ".ico": "image/x-icon", ".avif": "image/avif" };
|
|
29342
29404
|
function webRoot(root) {
|
|
29343
|
-
for (const d of ["public", "static"]) if (
|
|
29405
|
+
for (const d of ["public", "static"]) if (existsSync20(join23(root, d))) return join23(root, d);
|
|
29344
29406
|
return root;
|
|
29345
29407
|
}
|
|
29346
29408
|
function walk(dir, found = []) {
|
|
@@ -29352,7 +29414,7 @@ function walk(dir, found = []) {
|
|
|
29352
29414
|
}
|
|
29353
29415
|
for (const n2 of names) {
|
|
29354
29416
|
if (found.length >= WALK_CAP) break;
|
|
29355
|
-
const p =
|
|
29417
|
+
const p = join23(dir, n2);
|
|
29356
29418
|
let isDir = false;
|
|
29357
29419
|
try {
|
|
29358
29420
|
isDir = statSync4(p).isDirectory();
|
|
@@ -29367,31 +29429,31 @@ function walk(dir, found = []) {
|
|
|
29367
29429
|
}
|
|
29368
29430
|
function existingFavicon(root) {
|
|
29369
29431
|
const web = webRoot(root);
|
|
29370
|
-
for (const f of ["favicon.ico", "favicon.svg", "favicon.png", "icon.svg", "icon.png"]) if (
|
|
29371
|
-
for (const d of ["app", "src/app"]) for (const f of ["favicon.ico", "icon.svg", "icon.png", "icon.tsx", "icon.jpg"]) if (
|
|
29432
|
+
for (const f of ["favicon.ico", "favicon.svg", "favicon.png", "icon.svg", "icon.png"]) if (existsSync20(join23(web, f))) return relative5(root, join23(web, f)).split(sep4).join("/");
|
|
29433
|
+
for (const d of ["app", "src/app"]) for (const f of ["favicon.ico", "icon.svg", "icon.png", "icon.tsx", "icon.jpg"]) if (existsSync20(join23(root, d, f))) return `${d}/${f}`;
|
|
29372
29434
|
for (const f of walk(root).filter((p) => /\.(html|astro|tsx|jsx|vue|svelte)$/.test(p)).slice(0, 400)) {
|
|
29373
29435
|
try {
|
|
29374
|
-
const m =
|
|
29436
|
+
const m = readFileSync15(f, "utf8").match(/<link\b[^>]*\brel=["'](?:shortcut )?icon["'][^>]*>/i);
|
|
29375
29437
|
if (!m) continue;
|
|
29376
29438
|
const href = m[0].match(/\shref=["']([^"']+)/i)?.[1] ?? "";
|
|
29377
|
-
if (href.startsWith("data:") || /^https?:/.test(href) ||
|
|
29439
|
+
if (href.startsWith("data:") || /^https?:/.test(href) || existsSync20(join23(web, href.split("?")[0]))) return relative5(root, f).split(sep4).join("/");
|
|
29378
29440
|
} catch {
|
|
29379
29441
|
}
|
|
29380
29442
|
}
|
|
29381
29443
|
return null;
|
|
29382
29444
|
}
|
|
29383
29445
|
function scannedIcons(root) {
|
|
29384
|
-
const base =
|
|
29385
|
-
if (!
|
|
29446
|
+
const base = join23(root, MIGRATION_DIR);
|
|
29447
|
+
if (!existsSync20(base)) return [];
|
|
29386
29448
|
const found = [];
|
|
29387
29449
|
for (const host of readdirSync7(base)) {
|
|
29388
|
-
const dir =
|
|
29450
|
+
const dir = join23(base, host, "icons");
|
|
29389
29451
|
try {
|
|
29390
|
-
const list = readJson(
|
|
29452
|
+
const list = readJson(join23(dir, "icons.json"));
|
|
29391
29453
|
for (const i of list) {
|
|
29392
|
-
const path =
|
|
29393
|
-
if (!
|
|
29394
|
-
const size = imageSize(
|
|
29454
|
+
const path = join23(dir, i.file);
|
|
29455
|
+
if (!existsSync20(path)) continue;
|
|
29456
|
+
const size = imageSize(readFileSync15(path));
|
|
29395
29457
|
found.push({ path, kind: i.kind, big: !size || size.width >= 64 });
|
|
29396
29458
|
}
|
|
29397
29459
|
} catch {
|
|
@@ -29403,7 +29465,7 @@ function findSource(root) {
|
|
|
29403
29465
|
const icons = scannedIcons(root);
|
|
29404
29466
|
const sharp = icons.find((i) => i.kind === "icon" && i.big);
|
|
29405
29467
|
if (sharp) return { path: sharp.path, from: "old-icon" };
|
|
29406
|
-
const dirs = ["public", "static", "src/assets", "assets", "images", "img"].map((d) =>
|
|
29468
|
+
const dirs = ["public", "static", "src/assets", "assets", "images", "img"].map((d) => join23(root, d));
|
|
29407
29469
|
const logos = dirs.flatMap((d) => walk(d)).filter((p) => looksLikeLogo(relative5(root, p).split(sep4).join("/")));
|
|
29408
29470
|
const logo = logos.find((p) => /\.svg$/i.test(p)) ?? logos[0];
|
|
29409
29471
|
if (logo) return { path: logo, from: "logo" };
|
|
@@ -29417,23 +29479,23 @@ var CODE_EXT2 = /\.(css|scss|sass|less|html|astro|vue|svelte)$/i;
|
|
|
29417
29479
|
var READ_CAP = 300;
|
|
29418
29480
|
function readText2(path) {
|
|
29419
29481
|
try {
|
|
29420
|
-
return
|
|
29482
|
+
return readFileSync15(path, "utf8");
|
|
29421
29483
|
} catch {
|
|
29422
29484
|
return "";
|
|
29423
29485
|
}
|
|
29424
29486
|
}
|
|
29425
29487
|
function scanDirs(root) {
|
|
29426
|
-
const base =
|
|
29488
|
+
const base = join23(root, MIGRATION_DIR);
|
|
29427
29489
|
try {
|
|
29428
|
-
return readdirSync7(base).map((h) =>
|
|
29490
|
+
return readdirSync7(base).map((h) => join23(base, h)).filter((d) => existsSync20(join23(d, "home.html")));
|
|
29429
29491
|
} catch {
|
|
29430
29492
|
return [];
|
|
29431
29493
|
}
|
|
29432
29494
|
}
|
|
29433
29495
|
function homePage(root) {
|
|
29434
|
-
for (const d of scanDirs(root)) return readText2(
|
|
29496
|
+
for (const d of scanDirs(root)) return readText2(join23(d, "home.html"));
|
|
29435
29497
|
for (const f of ["index.html", "public/index.html", "src/index.html", "src/pages/index.astro", "src/pages/index.html", "app/layout.tsx", "src/app/layout.tsx", "src/layouts/Layout.astro"]) {
|
|
29436
|
-
const text2 = readText2(
|
|
29498
|
+
const text2 = readText2(join23(root, f));
|
|
29437
29499
|
if (text2) return text2;
|
|
29438
29500
|
}
|
|
29439
29501
|
return "";
|
|
@@ -29444,30 +29506,30 @@ function siteFacts(root, given = {}) {
|
|
|
29444
29506
|
const id = readSiteIdentity(home);
|
|
29445
29507
|
let pkg;
|
|
29446
29508
|
try {
|
|
29447
|
-
pkg = readJson(
|
|
29509
|
+
pkg = readJson(join23(root, "package.json")).name;
|
|
29448
29510
|
} catch {
|
|
29449
29511
|
}
|
|
29450
29512
|
const name = given.name?.trim() || readProject(root)?.name || id.name || (pkg && !pkg.startsWith("@") ? pkg : "") || basename2(root);
|
|
29451
29513
|
if (given.color) return { name, line: given.line ?? id.line ?? "", color: given.color, colorFrom: "given" };
|
|
29452
|
-
const old = scanDirs(root).flatMap((d) => walkAll(
|
|
29514
|
+
const old = scanDirs(root).flatMap((d) => walkAll(join23(d, "styles")).map((f) => ({ text: readText2(f) })));
|
|
29453
29515
|
const fromOld = scanDirs(root).length ? pickBrandColor([{ text: home, themeColor: id.themeColor }, ...old]) : null;
|
|
29454
29516
|
const sources = [{ text: home, themeColor: id.themeColor }];
|
|
29455
|
-
for (const f of ["tailwind.config.js", "tailwind.config.ts", "tailwind.config.mjs", "tailwind.config.cjs"]) sources.push({ text: readText2(
|
|
29456
|
-
const code = ["src", "app", "styles", "css", "public", "static"].flatMap((d) => walk(
|
|
29457
|
-
const plain2 = readdirSync7(root).filter((f) => CODE_EXT2.test(f)).map((f) =>
|
|
29517
|
+
for (const f of ["tailwind.config.js", "tailwind.config.ts", "tailwind.config.mjs", "tailwind.config.cjs"]) sources.push({ text: readText2(join23(root, f)) });
|
|
29518
|
+
const code = ["src", "app", "styles", "css", "public", "static"].flatMap((d) => walk(join23(root, d))).filter((p) => CODE_EXT2.test(p));
|
|
29519
|
+
const plain2 = readdirSync7(root).filter((f) => CODE_EXT2.test(f)).map((f) => join23(root, f));
|
|
29458
29520
|
for (const f of [...plain2, ...code].slice(0, READ_CAP)) sources.push({ text: readText2(f) });
|
|
29459
29521
|
const color = fromOld ?? pickBrandColor(sources);
|
|
29460
29522
|
return { name, line: given.line ?? id.line ?? "", color: color ?? BRAND_DEFAULT_COLOR, colorFrom: color ? "site" : "default" };
|
|
29461
29523
|
}
|
|
29462
29524
|
function writeSiteFile(root, file2, data) {
|
|
29463
|
-
const target =
|
|
29464
|
-
if (
|
|
29465
|
-
const keep =
|
|
29525
|
+
const target = join23(webRoot(root), file2);
|
|
29526
|
+
if (existsSync20(target)) {
|
|
29527
|
+
const keep = join23(root, BRAND_DIR, "originals");
|
|
29466
29528
|
mkdirSync13(keep, { recursive: true });
|
|
29467
|
-
copyFileSync(target,
|
|
29529
|
+
copyFileSync(target, join23(keep, file2));
|
|
29468
29530
|
}
|
|
29469
29531
|
mkdirSync13(dirname7(target), { recursive: true });
|
|
29470
|
-
|
|
29532
|
+
writeFileSync18(target, data);
|
|
29471
29533
|
}
|
|
29472
29534
|
var send = (res, status, body = "", type = "text/plain; charset=utf-8") => {
|
|
29473
29535
|
res.writeHead(status, { "content-type": type, "cache-control": "no-store", "x-content-type-options": "nosniff" });
|
|
@@ -29502,7 +29564,7 @@ function allowed(req, url2, port, token) {
|
|
|
29502
29564
|
return req.headers.host === `127.0.0.1:${port}` && url2.searchParams.get("t") === token;
|
|
29503
29565
|
}
|
|
29504
29566
|
async function headless(browser, url2, width, until, timeoutMs) {
|
|
29505
|
-
const profile = mkdtempSync2(
|
|
29567
|
+
const profile = mkdtempSync2(join23(tmpdir2(), "deployai-brand-"));
|
|
29506
29568
|
const child = spawn5(browser, ["--headless=new", "--disable-gpu", "--no-first-run", "--no-default-browser-check", "--disable-extensions", `--user-data-dir=${profile}`, `--window-size=${width},900`, url2], { stdio: "ignore", windowsHide: true });
|
|
29507
29569
|
child.on("error", () => {
|
|
29508
29570
|
});
|
|
@@ -29602,7 +29664,7 @@ async function drawInBrowser(o, browser) {
|
|
|
29602
29664
|
}
|
|
29603
29665
|
}
|
|
29604
29666
|
function sourceBytes(path) {
|
|
29605
|
-
return { bytes:
|
|
29667
|
+
return { bytes: readFileSync15(path), type: TYPES[extname2(path).toLowerCase()] ?? "application/octet-stream" };
|
|
29606
29668
|
}
|
|
29607
29669
|
function report(root, r) {
|
|
29608
29670
|
const where = relative5(root, webRoot(root)).split(sep4).join("/") || "the site root";
|
|
@@ -29620,7 +29682,7 @@ function plainIcon(root, source, name, color) {
|
|
|
29620
29682
|
const ext = extname2(source.path).toLowerCase();
|
|
29621
29683
|
if (ext === ".ico" || ext === ".svg" || ext === ".png") {
|
|
29622
29684
|
const file2 = `favicon${ext}`;
|
|
29623
|
-
writeSiteFile(root, file2,
|
|
29685
|
+
writeSiteFile(root, file2, readFileSync15(source.path));
|
|
29624
29686
|
return [file2];
|
|
29625
29687
|
}
|
|
29626
29688
|
}
|
|
@@ -29638,7 +29700,7 @@ function printStatus2(root, files) {
|
|
|
29638
29700
|
const web = webRoot(root);
|
|
29639
29701
|
const icon = existingFavicon(root);
|
|
29640
29702
|
out(icon ? `Icon: ${icon}` : "Icon: missing. Run: npx deployai@latest brand favicon");
|
|
29641
|
-
const missing = files.filter((f) => f !== "favicon.svg" && !
|
|
29703
|
+
const missing = files.filter((f) => f !== "favicon.svg" && !existsSync20(join23(web, f)));
|
|
29642
29704
|
if (files.length) out(missing.length ? `Missing from the full set: ${missing.join(", ")}` : "The full set is there.");
|
|
29643
29705
|
}
|
|
29644
29706
|
function printFacts(f, picture2) {
|
|
@@ -29657,7 +29719,7 @@ function withLogoColor(facts, source) {
|
|
|
29657
29719
|
}
|
|
29658
29720
|
function pickSource(root, from) {
|
|
29659
29721
|
const source = from ? { path: from, from: "file" } : findSource(root);
|
|
29660
|
-
if (source.path && !
|
|
29722
|
+
if (source.path && !existsSync20(source.path)) throw new CliError(`No such file: ${source.path}`, 1, "usage");
|
|
29661
29723
|
return source;
|
|
29662
29724
|
}
|
|
29663
29725
|
async function brandFaviconCommand(root, opts) {
|
|
@@ -29685,7 +29747,7 @@ async function brandFaviconCommand(root, opts) {
|
|
|
29685
29747
|
}
|
|
29686
29748
|
function iconsToDraw(root, force) {
|
|
29687
29749
|
const icon = force ? null : existingFavicon(root);
|
|
29688
|
-
const keepOg = !force &&
|
|
29750
|
+
const keepOg = !force && existsSync20(join23(webRoot(root), "og-image.png"));
|
|
29689
29751
|
return {
|
|
29690
29752
|
targets: BRAND_TARGETS.filter((t) => !(keepOg && t.file === "og-image.png") && !(icon && t.icoOnly)),
|
|
29691
29753
|
keepIcon: Boolean(icon),
|
|
@@ -29741,7 +29803,7 @@ async function measurePage(browser, address, width, scripts) {
|
|
|
29741
29803
|
}
|
|
29742
29804
|
}
|
|
29743
29805
|
function imageFiles(root) {
|
|
29744
|
-
const dirs = [webRoot(root) === root ? null : webRoot(root),
|
|
29806
|
+
const dirs = [webRoot(root) === root ? null : webRoot(root), join23(root, "src"), join23(root, MIGRATION_DIR)].filter((d) => !!d);
|
|
29745
29807
|
const files = dirs.flatMap((d) => walkAll(d));
|
|
29746
29808
|
if (webRoot(root) === root) files.push(...walk(root));
|
|
29747
29809
|
return [...new Set(files)].filter((p) => IMAGE_EXT.test(p) && !p.split(sep4).includes("icons") && !BRAND_FILES.includes(basename2(p)));
|
|
@@ -29757,7 +29819,7 @@ function walkAll(dir) {
|
|
|
29757
29819
|
}
|
|
29758
29820
|
for (const n2 of names) {
|
|
29759
29821
|
if (found.length >= WALK_CAP) return;
|
|
29760
|
-
const p =
|
|
29822
|
+
const p = join23(d, n2);
|
|
29761
29823
|
try {
|
|
29762
29824
|
if (statSync4(p).isDirectory()) {
|
|
29763
29825
|
if (!SKIP_DIRS3.has(n2) || n2 === ".deployai") go(p);
|
|
@@ -29776,7 +29838,7 @@ function judgeFiles(root) {
|
|
|
29776
29838
|
for (const f of files) {
|
|
29777
29839
|
let bytes;
|
|
29778
29840
|
try {
|
|
29779
|
-
bytes =
|
|
29841
|
+
bytes = readFileSync15(f);
|
|
29780
29842
|
} catch {
|
|
29781
29843
|
continue;
|
|
29782
29844
|
}
|
|
@@ -29826,10 +29888,10 @@ async function brandImagesCommand(root, urls, opts) {
|
|
|
29826
29888
|
if (verdict !== "ok") onPages.push({ where: m.src, width: m.width, height: m.height, shownWidth: m.shownWidth, verdict, alt: m.alt });
|
|
29827
29889
|
}
|
|
29828
29890
|
const weak = [...onPages, ...findings];
|
|
29829
|
-
mkdirSync13(
|
|
29891
|
+
mkdirSync13(join23(root, BRAND_DIR), { recursive: true });
|
|
29830
29892
|
const file2 = `${BRAND_DIR}/images.json`;
|
|
29831
29893
|
const data = { measuredAt: (/* @__PURE__ */ new Date()).toISOString(), pages: urls, unmeasured, filesChecked: total, imagesMeasured: shown.size, weak };
|
|
29832
|
-
|
|
29894
|
+
writeFileSync18(join23(root, file2), `${JSON.stringify(data, null, 2)}
|
|
29833
29895
|
`);
|
|
29834
29896
|
if (opts.json) {
|
|
29835
29897
|
out(JSON.stringify(data));
|
|
@@ -29894,7 +29956,12 @@ function buildProgram() {
|
|
|
29894
29956
|
const g = (cmd) => cmd.optsWithGlobals();
|
|
29895
29957
|
const root = (cmd) => resolve8(g(cmd).dir ?? process.cwd());
|
|
29896
29958
|
const ctx = (cmd) => apiContext(g(cmd).api);
|
|
29959
|
+
program.hook("preAction", async (_p, action) => {
|
|
29960
|
+
if (["init", "start", "rules"].includes(action.name()) || !existsSync21(join24(root(action), "DEPLOYAI.md"))) return;
|
|
29961
|
+
await refreshRules(root(action), ctx(action).apiUrl);
|
|
29962
|
+
});
|
|
29897
29963
|
program.command("init").description("create DEPLOYAI.md and .deployai/ guard files").option("--force", "overwrite DEPLOYAI.md").option("--no-agent-files", "do not add the DEPLOYAI.md line to AGENTS.md and CLAUDE.md").action((opts, cmd) => initCommand(root(cmd), opts, ctx(cmd).apiUrl));
|
|
29964
|
+
program.command("rules").description("the current DeployAI rules for the agent, and DEPLOYAI.md brought up to them").action((_o, cmd) => rulesCommand(root(cmd), ctx(cmd).apiUrl));
|
|
29898
29965
|
program.command("inspect").description("show framework, package manager, language, database, storage").option("--json", "machine readable output").action((opts, cmd) => inspectCommand(root(cmd), opts));
|
|
29899
29966
|
program.command("check").description("can this project run on DeployAI: blockers and warnings, with the AI prompt").option("--json", "machine readable output").option("--no-clipboard", "do not copy the prompt to the clipboard").action(async (opts, cmd) => {
|
|
29900
29967
|
const a = await runCheck(root(cmd), ctx(cmd), opts);
|
|
@@ -30046,8 +30113,8 @@ async function main(argv = process.argv) {
|
|
|
30046
30113
|
|
|
30047
30114
|
// src/update.ts
|
|
30048
30115
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
30049
|
-
import { existsSync as
|
|
30050
|
-
import { join as
|
|
30116
|
+
import { existsSync as existsSync22, mkdirSync as mkdirSync14, readdirSync as readdirSync8, readFileSync as readFileSync16, rmSync as rmSync5, writeFileSync as writeFileSync19 } from "fs";
|
|
30117
|
+
import { join as join25 } from "path";
|
|
30051
30118
|
var CHECK_EVERY_MS = 60 * 60 * 1e3;
|
|
30052
30119
|
var ASK_NPM_MS = 1500;
|
|
30053
30120
|
var GET_VERSION_MS = 12e4;
|
|
@@ -30085,11 +30152,11 @@ function updateAllowed(env, args) {
|
|
|
30085
30152
|
return resolveApiUrl(void 0, loadConfig()) === API_BASE_DEFAULT.replace(/\/+$/, "");
|
|
30086
30153
|
}
|
|
30087
30154
|
function statePath() {
|
|
30088
|
-
return
|
|
30155
|
+
return join25(configDir(), "update-check.json");
|
|
30089
30156
|
}
|
|
30090
30157
|
function readState() {
|
|
30091
30158
|
try {
|
|
30092
|
-
const data = JSON.parse(
|
|
30159
|
+
const data = JSON.parse(readFileSync16(statePath(), "utf8"));
|
|
30093
30160
|
return data && typeof data === "object" ? data : {};
|
|
30094
30161
|
} catch {
|
|
30095
30162
|
return {};
|
|
@@ -30098,7 +30165,7 @@ function readState() {
|
|
|
30098
30165
|
function writeState(state) {
|
|
30099
30166
|
try {
|
|
30100
30167
|
mkdirSync14(configDir(), { recursive: true });
|
|
30101
|
-
|
|
30168
|
+
writeFileSync19(statePath(), JSON.stringify(state) + "\n");
|
|
30102
30169
|
} catch {
|
|
30103
30170
|
}
|
|
30104
30171
|
}
|
|
@@ -30114,20 +30181,20 @@ async function askNpmLatest(env) {
|
|
|
30114
30181
|
}
|
|
30115
30182
|
}
|
|
30116
30183
|
function versionEntry(version2) {
|
|
30117
|
-
return
|
|
30184
|
+
return join25(configDir(), "cli", version2, "node_modules", "deployai", "dist", "index.js");
|
|
30118
30185
|
}
|
|
30119
30186
|
function getVersion(version2, env) {
|
|
30120
30187
|
process.stderr.write(`Getting the newest DeployAI CLI, version ${version2}.
|
|
30121
30188
|
`);
|
|
30122
|
-
const root =
|
|
30123
|
-
const dir =
|
|
30189
|
+
const root = join25(configDir(), "cli");
|
|
30190
|
+
const dir = join25(root, version2);
|
|
30124
30191
|
mkdirSync14(dir, { recursive: true });
|
|
30125
|
-
|
|
30192
|
+
writeFileSync19(join25(dir, "package.json"), '{"private":true}\n');
|
|
30126
30193
|
const installed = spawnSync5(`npm install deployai@${version2} --ignore-scripts --no-audit --no-fund --silent`, { cwd: dir, env, shell: true, stdio: "ignore", windowsHide: true, timeout: GET_VERSION_MS });
|
|
30127
30194
|
if (installed.status !== 0) return false;
|
|
30128
30195
|
const ran = spawnSync5(process.execPath, [versionEntry(version2), "--version"], { env: { ...env, DEPLOYAI_NO_UPDATE: "1" }, encoding: "utf8", timeout: GET_VERSION_MS });
|
|
30129
30196
|
if (ran.status !== 0 || ran.stdout.trim() !== version2) return false;
|
|
30130
|
-
for (const old of readdirSync8(root)) if (old !== version2) rmSync5(
|
|
30197
|
+
for (const old of readdirSync8(root)) if (old !== version2) rmSync5(join25(root, old), { recursive: true, force: true });
|
|
30131
30198
|
return true;
|
|
30132
30199
|
}
|
|
30133
30200
|
function runVersion(version2, args, env = process.env) {
|
|
@@ -30146,7 +30213,7 @@ async function versionToRun(current, args, env = process.env, deps = {}) {
|
|
|
30146
30213
|
}
|
|
30147
30214
|
const latest = state.latest;
|
|
30148
30215
|
if (!latest || !PLAIN_VERSION.test(latest) || compareVersions(latest, current) <= 0) return null;
|
|
30149
|
-
if (state.ready === latest &&
|
|
30216
|
+
if (state.ready === latest && existsSync22(versionEntry(latest))) return latest;
|
|
30150
30217
|
if (now - (state.triedAt ?? 0) < CHECK_EVERY_MS) return null;
|
|
30151
30218
|
state.triedAt = now;
|
|
30152
30219
|
if (get2(latest, env)) state.ready = latest;
|