deployai 0.1.0-beta.32 → 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 +486 -390
- 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
|
|
@@ -22332,7 +22328,7 @@ var MIGRATE_STEPS = [
|
|
|
22332
22328
|
FAVICON,
|
|
22333
22329
|
{ ...CHECK },
|
|
22334
22330
|
LOGIN,
|
|
22335
|
-
{ cmd: 'npx deployai@latest link --create "<the site name>"', say: "Makes the site in the owner's account and links this folder. The add-ons come with it for free while the offer lasts. Do not run them now: the last step offers them, once the move is done." },
|
|
22331
|
+
{ cmd: 'npx deployai@latest link --create "<the site name>"', say: "Makes the site in the owner's account and links this folder. The add-ons come with it for free while the offer lasts, and once the site has them they stay with it, with no time limit. Do not run them now: the last step offers them, once the move is done." },
|
|
22336
22332
|
LOOK_DEPLOY,
|
|
22337
22333
|
{ say: `${LOOK_OPEN} Once you saw the home page, not an empty or not found page: send the owner the address as a first look at their home page, say it is private and that the rest is on the way, and go on without waiting for an answer. Then build the rest of the site with the steps below.` },
|
|
22338
22334
|
DASHBOARD,
|
|
@@ -22390,6 +22386,12 @@ var PULL = { cmd: "npx deployai@latest pull", say: "This folder was empty, so it
|
|
|
22390
22386
|
function startSteps(kind, opts = {}) {
|
|
22391
22387
|
return opts.signedIn ? stepsOf(kind, opts).filter((s) => s !== LOGIN) : stepsOf(kind, opts);
|
|
22392
22388
|
}
|
|
22389
|
+
function withServerSteps(bundled, server) {
|
|
22390
|
+
if (!Array.isArray(server) || server.length !== bundled.length) return bundled;
|
|
22391
|
+
const ok = server.every((s, i) => s && typeof s === "object" && typeof s.say === "string" && s.say.trim() && s.say.length < 8e3 && (s.cmd ?? void 0) === bundled[i].cmd);
|
|
22392
|
+
return ok ? bundled.map((b, i) => ({ ...b, say: server[i].say })) : bundled;
|
|
22393
|
+
}
|
|
22394
|
+
var startStepsQuery = (kind, opts) => `kind=${kind}&o=${["emptyFolder", "starter", "managed", "signedIn", "addons"].filter((k) => opts[k]).join(",")}`;
|
|
22393
22395
|
function stepsOf(kind, opts) {
|
|
22394
22396
|
switch (kind) {
|
|
22395
22397
|
case "new":
|
|
@@ -22478,6 +22480,7 @@ var CLI_MAP_NODES = [
|
|
|
22478
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."),
|
|
22479
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."),
|
|
22480
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."),
|
|
22481
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."),
|
|
22482
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."),
|
|
22483
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."),
|
|
@@ -23262,6 +23265,97 @@ var KEEP_DATA_RULES = [
|
|
|
23262
23265
|
var AGENT_POINTER = "Read DEPLOYAI.md before your first answer and before you write code, change the plan or add a dependency: this project is published with DeployAI.";
|
|
23263
23266
|
var FOLDER_READY_RULE = `This folder is already set up. When the owner has not asked for anything yet, say only, in their language: "The folder is set up and ready. What do you want to change?" Add the site's name when .deployai/project.json has it. If the folder has no site files yet, ask instead: "The folder is set up and ready. What do you want to build?" Never ask them for a start line, a command or an id. While the folder holds a site, never offer a sample or a new start: go on with that site.`;
|
|
23264
23267
|
|
|
23268
|
+
// ../shared/src/deployai-md.ts
|
|
23269
|
+
var DEPLOYAI_MD = `# DeployAI rules
|
|
23270
|
+
|
|
23271
|
+
This project is published with DeployAI.
|
|
23272
|
+
|
|
23273
|
+
${FOLDER_READY_RULE}
|
|
23274
|
+
|
|
23275
|
+
Always explain to the owner in simple words, in the language they write to you in. The owner may not read English.
|
|
23276
|
+
|
|
23277
|
+
${START_FAIL_LINE}
|
|
23278
|
+
|
|
23279
|
+
${OWNER_TEXT_RULE}
|
|
23280
|
+
|
|
23281
|
+
When you install or set something up, say what it does for the site, not the package name. Say "installing the site runtime" or "setting up a local test database", not "installing the Cloudflare adapter" or "installing wrangler".
|
|
23282
|
+
|
|
23283
|
+
Before you write code or change the plan, compare it with these rules. If something in it does not fit, say what and propose the change.
|
|
23284
|
+
|
|
23285
|
+
## Build with
|
|
23286
|
+
|
|
23287
|
+
${BUILD_WITH.map((l) => `- ${l}`).join("\n")}
|
|
23288
|
+
|
|
23289
|
+
Only when this folder has no site yet and the owner asks to start from working code: npx deployai@latest samples
|
|
23290
|
+
When the owner wants an outside service, such as card payments, invoices or sending email, start here and read the provider's current docs, not your memory: npx deployai@latest integrations
|
|
23291
|
+
|
|
23292
|
+
## Do not add
|
|
23293
|
+
|
|
23294
|
+
- local file system writes
|
|
23295
|
+
- database drivers DeployAI does not support (see: npx deployai@latest inspect)
|
|
23296
|
+
- long-running processes or background servers
|
|
23297
|
+
- Durable Objects (not supported yet; keep state in D1)
|
|
23298
|
+
- native binary modules
|
|
23299
|
+
- DeployAI or any cloud credentials in source code
|
|
23300
|
+
|
|
23301
|
+
## Do not run
|
|
23302
|
+
|
|
23303
|
+
- wrangler commands that need a Cloudflare account (login, deploy, d1 create, r2 bucket create). Wrangler is installed only for local development. The owner does not need a Cloudflare account: DeployAI creates the database and storage and publishes the site, with: npx deployai@latest deploy
|
|
23304
|
+
|
|
23305
|
+
## Keep existing data
|
|
23306
|
+
|
|
23307
|
+
${KEEP_DATA_RULES.join("\n")}
|
|
23308
|
+
|
|
23309
|
+
## Running DeployAI commands
|
|
23310
|
+
|
|
23311
|
+
${runCommandsRule()}
|
|
23312
|
+
|
|
23313
|
+
## Asking the owner
|
|
23314
|
+
|
|
23315
|
+
${ASK_OWNER_RULE}
|
|
23316
|
+
|
|
23317
|
+
Never stop building for an account, a plan or a limit. Build what the owner asks; say once, in one plain line, what going live will need, and ask about it only at the deploy step.
|
|
23318
|
+
|
|
23319
|
+
## A site's first version
|
|
23320
|
+
|
|
23321
|
+
${FIRST_SITE_RULE}
|
|
23322
|
+
|
|
23323
|
+
## When to deploy
|
|
23324
|
+
|
|
23325
|
+
${DEPLOY_ASK_RULE}
|
|
23326
|
+
|
|
23327
|
+
## When DeployAI gets in your way
|
|
23328
|
+
|
|
23329
|
+
${AGENT_FEEDBACK_RULES.join("\n\n")}
|
|
23330
|
+
|
|
23331
|
+
## Check
|
|
23332
|
+
|
|
23333
|
+
Before adding a dependency or a new server feature, run: npx deployai@latest check
|
|
23334
|
+
Ask the owner before removing any existing functionality.
|
|
23335
|
+
|
|
23336
|
+
Files:
|
|
23337
|
+
- .deployai/project.json: project id and settings (safe to commit)
|
|
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
|
|
23340
|
+
`;
|
|
23341
|
+
var DEPLOYAI_LATER_RULES = [
|
|
23342
|
+
{ has: "iPhone:", text: IPHONE_RULE },
|
|
23343
|
+
{ has: "set up and ready", text: FOLDER_READY_RULE },
|
|
23344
|
+
{ has: "one or two short sentences", text: START_FAIL_LINE },
|
|
23345
|
+
{ has: "direction marks", text: OWNER_TEXT_RULE },
|
|
23346
|
+
{ has: "deployai@latest feedback", text: AGENT_FEEDBACK_RULES.join(" ") },
|
|
23347
|
+
{ has: "never been live", text: FIRST_SITE_RULE }
|
|
23348
|
+
];
|
|
23349
|
+
function parseLaterRules(json2) {
|
|
23350
|
+
try {
|
|
23351
|
+
const v = JSON.parse(json2 ?? "");
|
|
23352
|
+
const list = Array.isArray(v) ? v.filter((r) => r && typeof r.has === "string" && r.has.trim() && typeof r.text === "string" && r.text.trim() && r.text.length < 8e3) : [];
|
|
23353
|
+
return list.length ? list.map((r) => ({ has: r.has, text: r.text })) : DEPLOYAI_LATER_RULES;
|
|
23354
|
+
} catch {
|
|
23355
|
+
return DEPLOYAI_LATER_RULES;
|
|
23356
|
+
}
|
|
23357
|
+
}
|
|
23358
|
+
|
|
23265
23359
|
// ../shared/src/stack.ts
|
|
23266
23360
|
var SITE_LANG_INFO = {
|
|
23267
23361
|
he: { name: "Hebrew", dir: "rtl", font: "Heebo" },
|
|
@@ -24198,7 +24292,7 @@ function ensureDeployaiDir(root) {
|
|
|
24198
24292
|
if (!existsSync2(dir)) mkdirSync2(dir, { recursive: true });
|
|
24199
24293
|
const ignore = join2(dir, ".gitignore");
|
|
24200
24294
|
const have = existsSync2(ignore) ? readFileSync3(ignore, "utf8") : "";
|
|
24201
|
-
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));
|
|
24202
24296
|
if (missing.length) writeFileSync2(ignore, have + (have && !have.endsWith("\n") ? "\n" : "") + missing.join("\n") + "\n");
|
|
24203
24297
|
}
|
|
24204
24298
|
function readProject(root) {
|
|
@@ -24737,7 +24831,7 @@ function messages(root) {
|
|
|
24737
24831
|
}
|
|
24738
24832
|
|
|
24739
24833
|
// src/version.ts
|
|
24740
|
-
var CLI_VERSION = "0.1.0-beta.
|
|
24834
|
+
var CLI_VERSION = "0.1.0-beta.34";
|
|
24741
24835
|
|
|
24742
24836
|
// src/api.ts
|
|
24743
24837
|
function apiContext(apiFlag) {
|
|
@@ -25046,8 +25140,8 @@ async function feedbackCommand(root, ctx, opts) {
|
|
|
25046
25140
|
}
|
|
25047
25141
|
|
|
25048
25142
|
// src/commands/init.ts
|
|
25049
|
-
import { appendFileSync, existsSync as
|
|
25050
|
-
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";
|
|
25051
25145
|
|
|
25052
25146
|
// src/analyze.ts
|
|
25053
25147
|
import { execFileSync } from "child_process";
|
|
@@ -25693,115 +25787,127 @@ function groupFindings(findings) {
|
|
|
25693
25787
|
return [...groups.values()];
|
|
25694
25788
|
}
|
|
25695
25789
|
|
|
25696
|
-
// src/
|
|
25697
|
-
|
|
25698
|
-
|
|
25699
|
-
|
|
25700
|
-
|
|
25701
|
-
|
|
25702
|
-
|
|
25703
|
-
|
|
25704
|
-
|
|
25705
|
-
|
|
25706
|
-
|
|
25707
|
-
|
|
25708
|
-
|
|
25709
|
-
|
|
25710
|
-
|
|
25711
|
-
|
|
25712
|
-
|
|
25713
|
-
|
|
25714
|
-
|
|
25715
|
-
|
|
25716
|
-
|
|
25717
|
-
|
|
25718
|
-
|
|
25719
|
-
|
|
25720
|
-
|
|
25721
|
-
|
|
25722
|
-
|
|
25723
|
-
|
|
25724
|
-
|
|
25725
|
-
|
|
25726
|
-
|
|
25727
|
-
|
|
25728
|
-
|
|
25729
|
-
|
|
25730
|
-
|
|
25731
|
-
|
|
25732
|
-
|
|
25733
|
-
|
|
25734
|
-
|
|
25735
|
-
|
|
25736
|
-
|
|
25737
|
-
|
|
25738
|
-
|
|
25739
|
-
|
|
25740
|
-
|
|
25741
|
-
|
|
25742
|
-
|
|
25743
|
-
|
|
25744
|
-
|
|
25745
|
-
|
|
25746
|
-
|
|
25747
|
-
## A site's first version
|
|
25748
|
-
|
|
25749
|
-
${FIRST_SITE_RULE}
|
|
25750
|
-
|
|
25751
|
-
## When to deploy
|
|
25752
|
-
|
|
25753
|
-
${DEPLOY_ASK_RULE}
|
|
25754
|
-
|
|
25755
|
-
## When DeployAI gets in your way
|
|
25756
|
-
|
|
25757
|
-
${AGENT_FEEDBACK_RULES.join("\n\n")}
|
|
25758
|
-
|
|
25759
|
-
## Check
|
|
25760
|
-
|
|
25761
|
-
Before adding a dependency or a new server feature, run: npx deployai@latest check
|
|
25762
|
-
Ask the owner before removing any existing functionality.
|
|
25790
|
+
// src/rules.ts
|
|
25791
|
+
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
25792
|
+
import { join as join5 } from "path";
|
|
25793
|
+
var CACHE_FILE = "rules-cache.json";
|
|
25794
|
+
var DAY_MS = 864e5;
|
|
25795
|
+
var WAIT_MS = 2e3;
|
|
25796
|
+
var EMPTY = { rules: {}, extra: [] };
|
|
25797
|
+
function cleanRules(v) {
|
|
25798
|
+
const o = v && typeof v === "object" ? v : {};
|
|
25799
|
+
const rules = {};
|
|
25800
|
+
if (o.rules && typeof o.rules === "object") {
|
|
25801
|
+
for (const [k, t] of Object.entries(o.rules)) if (typeof t === "string" && t.trim() && t.length < 2e4) rules[k] = t;
|
|
25802
|
+
}
|
|
25803
|
+
const extra = Array.isArray(o.extra) ? o.extra.filter((t) => typeof t === "string" && t.trim().length > 0 && t.length < 4e3).slice(0, 20) : [];
|
|
25804
|
+
return { rules, extra };
|
|
25805
|
+
}
|
|
25806
|
+
async function serverRules(apiUrl, fetcher = fetch, now = Date.now()) {
|
|
25807
|
+
const file2 = join5(configDir(), CACHE_FILE);
|
|
25808
|
+
let cached2 = null;
|
|
25809
|
+
try {
|
|
25810
|
+
cached2 = readJson(file2);
|
|
25811
|
+
} catch {
|
|
25812
|
+
}
|
|
25813
|
+
if (cached2 && cached2.version === CLI_VERSION && now - cached2.at < DAY_MS) return cleanRules(cached2.data);
|
|
25814
|
+
try {
|
|
25815
|
+
const r = await fetcher(`${apiUrl}/api/cli/rules?cli=${encodeURIComponent(CLI_VERSION)}`, { signal: AbortSignal.timeout(WAIT_MS) });
|
|
25816
|
+
if (!r.ok) throw new Error(String(r.status));
|
|
25817
|
+
const data = cleanRules(await r.json());
|
|
25818
|
+
try {
|
|
25819
|
+
mkdirSync3(configDir(), { recursive: true });
|
|
25820
|
+
writeFileSync3(file2, JSON.stringify({ at: now, version: CLI_VERSION, data }));
|
|
25821
|
+
} catch {
|
|
25822
|
+
}
|
|
25823
|
+
return data;
|
|
25824
|
+
} catch {
|
|
25825
|
+
return cached2 ? cleanRules(cached2.data) : EMPTY;
|
|
25826
|
+
}
|
|
25827
|
+
}
|
|
25828
|
+
var rule = (r, key, bundled) => r.rules[key] ?? bundled;
|
|
25829
|
+
function initTexts(r) {
|
|
25830
|
+
return { md: rule(r, "deployaiMd", DEPLOYAI_MD), later: parseLaterRules(r.rules.laterRules) };
|
|
25831
|
+
}
|
|
25832
|
+
async function serverSteps(apiUrl, query, fetcher = fetch) {
|
|
25833
|
+
try {
|
|
25834
|
+
const r = await fetcher(`${apiUrl}/api/cli/steps?${query}&cli=${encodeURIComponent(CLI_VERSION)}`, { signal: AbortSignal.timeout(WAIT_MS) });
|
|
25835
|
+
return r.ok ? (await r.json()).steps : null;
|
|
25836
|
+
} catch {
|
|
25837
|
+
return null;
|
|
25838
|
+
}
|
|
25839
|
+
}
|
|
25763
25840
|
|
|
25764
|
-
|
|
25765
|
-
|
|
25766
|
-
|
|
25767
|
-
|
|
25768
|
-
var
|
|
25769
|
-
var
|
|
25770
|
-
|
|
25771
|
-
|
|
25772
|
-
{
|
|
25773
|
-
|
|
25774
|
-
|
|
25775
|
-
|
|
25776
|
-
|
|
25777
|
-
|
|
25778
|
-
|
|
25779
|
-
|
|
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) {
|
|
25866
|
+
const missing = later.filter((r) => !text2.includes(r.has));
|
|
25780
25867
|
if (!missing.length) return false;
|
|
25781
25868
|
const eol = text2.includes("\r\n") ? "\r\n" : "\n";
|
|
25782
25869
|
const gap = text2.endsWith("\n") ? eol : eol + eol;
|
|
25783
|
-
appendFileSync(
|
|
25870
|
+
appendFileSync(file2, `${gap}## Added later by DeployAI${eol}${eol}${missing.map((r) => r.text).join(eol + eol)}${eol}`);
|
|
25784
25871
|
return true;
|
|
25785
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"];
|
|
25786
25891
|
function runInit(root, opts = {}) {
|
|
25787
25892
|
const created = [];
|
|
25788
25893
|
const kept = [];
|
|
25789
25894
|
const updated = [];
|
|
25790
|
-
const md =
|
|
25895
|
+
const md = join7(root, "DEPLOYAI.md");
|
|
25791
25896
|
let rulesAdded = false;
|
|
25792
|
-
if (
|
|
25897
|
+
if (existsSync6(md) && !opts.force) {
|
|
25793
25898
|
kept.push("DEPLOYAI.md");
|
|
25794
|
-
|
|
25899
|
+
const sync = syncRulesFile(root, opts.texts?.md ?? DEPLOYAI_MD, opts.texts?.later);
|
|
25900
|
+
rulesAdded = sync === "updated" || sync === "added";
|
|
25795
25901
|
} else {
|
|
25796
|
-
|
|
25902
|
+
writeRulesFile(root, opts.texts?.md ?? DEPLOYAI_MD);
|
|
25797
25903
|
created.push("DEPLOYAI.md");
|
|
25798
25904
|
}
|
|
25799
25905
|
if (opts.agentFiles !== false) {
|
|
25800
25906
|
for (const name of AGENT_FILES) {
|
|
25801
|
-
const file2 =
|
|
25802
|
-
const text2 =
|
|
25907
|
+
const file2 = join7(root, name);
|
|
25908
|
+
const text2 = existsSync6(file2) ? readFileSync7(file2, "utf8") : null;
|
|
25803
25909
|
if (text2 === null) {
|
|
25804
|
-
|
|
25910
|
+
writeFileSync5(file2, `${AGENT_POINTER}
|
|
25805
25911
|
`);
|
|
25806
25912
|
created.push(name);
|
|
25807
25913
|
} else if (text2.includes("DEPLOYAI.md")) {
|
|
@@ -25809,7 +25915,7 @@ function runInit(root, opts = {}) {
|
|
|
25809
25915
|
} else {
|
|
25810
25916
|
const eol = text2.includes("\r\n") ? "\r\n" : "\n";
|
|
25811
25917
|
const gap = !text2.trim() ? "" : text2.endsWith("\n") ? eol : eol + eol;
|
|
25812
|
-
|
|
25918
|
+
appendFileSync2(file2, `${gap}${AGENT_POINTER}${eol}`);
|
|
25813
25919
|
updated.push(name);
|
|
25814
25920
|
}
|
|
25815
25921
|
}
|
|
@@ -25823,11 +25929,11 @@ function runInit(root, opts = {}) {
|
|
|
25823
25929
|
writeProject(root, { projectId: null, framework, createdAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
25824
25930
|
created.push(".deployai/project.json");
|
|
25825
25931
|
}
|
|
25826
|
-
const hasCode =
|
|
25932
|
+
const hasCode = existsSync6(join7(root, "package.json")) || framework !== "unknown";
|
|
25827
25933
|
return { rulesAdded, created, kept, updated, hasCode };
|
|
25828
25934
|
}
|
|
25829
|
-
function initCommand(root, opts) {
|
|
25830
|
-
const res = runInit(root, opts);
|
|
25935
|
+
async function initCommand(root, opts, apiUrl) {
|
|
25936
|
+
const res = runInit(root, { ...opts, texts: apiUrl ? initTexts(await serverRules(apiUrl)) : void 0 });
|
|
25831
25937
|
const project = readProject(root);
|
|
25832
25938
|
out("DeployAI init");
|
|
25833
25939
|
out();
|
|
@@ -25852,8 +25958,8 @@ function initCommand(root, opts) {
|
|
|
25852
25958
|
}
|
|
25853
25959
|
|
|
25854
25960
|
// src/commands/check.ts
|
|
25855
|
-
import { existsSync as
|
|
25856
|
-
import { join as
|
|
25961
|
+
import { existsSync as existsSync8, writeFileSync as writeFileSync6 } from "fs";
|
|
25962
|
+
import { join as join9 } from "path";
|
|
25857
25963
|
|
|
25858
25964
|
// src/prompt.ts
|
|
25859
25965
|
var PROMPT_RULES = [
|
|
@@ -25922,8 +26028,8 @@ function buildPrompt(analysis) {
|
|
|
25922
26028
|
|
|
25923
26029
|
// src/system.ts
|
|
25924
26030
|
import { spawn, spawnSync } from "child_process";
|
|
25925
|
-
import { existsSync as
|
|
25926
|
-
import { join as
|
|
26031
|
+
import { existsSync as existsSync7 } from "fs";
|
|
26032
|
+
import { join as join8 } from "path";
|
|
25927
26033
|
function copyToClipboard(text2) {
|
|
25928
26034
|
if (process.env.DEPLOYAI_NO_CLIPBOARD) return false;
|
|
25929
26035
|
const candidates = process.platform === "win32" ? [["clip", []]] : process.platform === "darwin" ? [["pbcopy", []]] : [
|
|
@@ -25943,9 +26049,9 @@ function copyToClipboard(text2) {
|
|
|
25943
26049
|
function findBrowser() {
|
|
25944
26050
|
if (process.env.DEPLOYAI_NO_BROWSER) return null;
|
|
25945
26051
|
const set2 = process.env.CHROME_PATH;
|
|
25946
|
-
if (set2 &&
|
|
25947
|
-
const places = process.platform === "win32" ? [process.env.PROGRAMFILES, process.env["PROGRAMFILES(X86)"], process.env.LOCALAPPDATA].flatMap((d) => d ? [
|
|
25948
|
-
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;
|
|
25949
26055
|
}
|
|
25950
26056
|
function openBrowser(url2) {
|
|
25951
26057
|
if (process.env.DEPLOYAI_NO_BROWSER || process.env.CI) return false;
|
|
@@ -26045,7 +26151,7 @@ async function runCheck(root, ctx, opts = {}) {
|
|
|
26045
26151
|
const json2 = checkJson(a, prompt);
|
|
26046
26152
|
try {
|
|
26047
26153
|
ensureDeployaiDir(root);
|
|
26048
|
-
|
|
26154
|
+
writeFileSync6(lastCheckFile(root), JSON.stringify(json2, null, 2) + "\n");
|
|
26049
26155
|
} catch {
|
|
26050
26156
|
}
|
|
26051
26157
|
const empty = a.findings.length > 0 && a.findings.every((f) => f.code === "no_files");
|
|
@@ -26055,7 +26161,7 @@ async function runCheck(root, ctx, opts = {}) {
|
|
|
26055
26161
|
out("DeployAI check");
|
|
26056
26162
|
out();
|
|
26057
26163
|
out(messages(root)("emptyFolder"));
|
|
26058
|
-
if (!
|
|
26164
|
+
if (!existsSync8(join9(root, "DEPLOYAI.md"))) out(messages(root)("initHint"));
|
|
26059
26165
|
} else if (opts.print !== false) {
|
|
26060
26166
|
printCheck(a);
|
|
26061
26167
|
out();
|
|
@@ -26082,7 +26188,7 @@ async function runCheck(root, ctx, opts = {}) {
|
|
|
26082
26188
|
} else {
|
|
26083
26189
|
out(t("runDeploy"));
|
|
26084
26190
|
}
|
|
26085
|
-
if (!
|
|
26191
|
+
if (!existsSync8(join9(root, "DEPLOYAI.md"))) out(t("initHint"));
|
|
26086
26192
|
}
|
|
26087
26193
|
await telemetry;
|
|
26088
26194
|
return a;
|
|
@@ -26225,8 +26331,8 @@ function telemetryCommand(action) {
|
|
|
26225
26331
|
}
|
|
26226
26332
|
|
|
26227
26333
|
// src/commands/allow.ts
|
|
26228
|
-
import { existsSync as
|
|
26229
|
-
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";
|
|
26230
26336
|
var ALLOW_TOOLS = ["claude-code", "cursor", "copilot", "codex", "antigravity", "grok"];
|
|
26231
26337
|
var CLAUDE_RULE = "Bash(npx deployai@latest *)";
|
|
26232
26338
|
var CURSOR_LINE = "Running npx deployai@latest commands is allowed without approval.";
|
|
@@ -26236,7 +26342,7 @@ var CLICKS = {
|
|
|
26236
26342
|
antigravity: "Antigravity: when it asks to run npx deployai@latest, choose Accept."
|
|
26237
26343
|
};
|
|
26238
26344
|
function readObject(file2) {
|
|
26239
|
-
if (!
|
|
26345
|
+
if (!existsSync9(file2)) return {};
|
|
26240
26346
|
try {
|
|
26241
26347
|
const v = readJson(file2);
|
|
26242
26348
|
return v && typeof v === "object" && !Array.isArray(v) ? v : null;
|
|
@@ -26245,8 +26351,8 @@ function readObject(file2) {
|
|
|
26245
26351
|
}
|
|
26246
26352
|
}
|
|
26247
26353
|
function writeObject(file2, value) {
|
|
26248
|
-
|
|
26249
|
-
|
|
26354
|
+
mkdirSync4(dirname(file2), { recursive: true });
|
|
26355
|
+
writeFileSync7(file2, `${JSON.stringify(value, null, 2)}
|
|
26250
26356
|
`);
|
|
26251
26357
|
}
|
|
26252
26358
|
function addTo(obj, key, list, value) {
|
|
@@ -26258,11 +26364,11 @@ function addTo(obj, key, list, value) {
|
|
|
26258
26364
|
return true;
|
|
26259
26365
|
}
|
|
26260
26366
|
function ignoreInGit(root, path) {
|
|
26261
|
-
if (!
|
|
26262
|
-
const gi =
|
|
26263
|
-
const text2 =
|
|
26367
|
+
if (!existsSync9(join10(root, ".git"))) return;
|
|
26368
|
+
const gi = join10(root, ".gitignore");
|
|
26369
|
+
const text2 = existsSync9(gi) ? readFileSync8(gi, "utf8") : "";
|
|
26264
26370
|
if (text2.split(/\r?\n/).some((l) => l.trim() === path)) return;
|
|
26265
|
-
|
|
26371
|
+
appendFileSync3(gi, `${text2 && !text2.endsWith("\n") ? "\n" : ""}${path}
|
|
26266
26372
|
`);
|
|
26267
26373
|
}
|
|
26268
26374
|
function detectTool() {
|
|
@@ -26283,7 +26389,7 @@ function allowCommand(tool) {
|
|
|
26283
26389
|
if (picked === "claude-code" || picked === "grok") {
|
|
26284
26390
|
const grok = picked === "grok";
|
|
26285
26391
|
const rel = ".claude/settings.local.json";
|
|
26286
|
-
const file2 =
|
|
26392
|
+
const file2 = join10(root, rel);
|
|
26287
26393
|
const obj = readObject(file2);
|
|
26288
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");
|
|
26289
26395
|
const added = addTo(obj, "permissions", "allow", CLAUDE_RULE);
|
|
@@ -26304,7 +26410,7 @@ function allowCommand(tool) {
|
|
|
26304
26410
|
}
|
|
26305
26411
|
if (picked === "cursor") {
|
|
26306
26412
|
const rel = ".cursor/permissions.json";
|
|
26307
|
-
const file2 =
|
|
26413
|
+
const file2 = join10(root, rel);
|
|
26308
26414
|
const obj = readObject(file2);
|
|
26309
26415
|
if (!obj) throw new CliError(`${rel} is not valid JSON, so it was left as is.`, 1, "allow_file");
|
|
26310
26416
|
const added = addTo(obj, "autoRun", "allow_instructions", CURSOR_LINE);
|
|
@@ -26318,14 +26424,14 @@ function allowCommand(tool) {
|
|
|
26318
26424
|
}
|
|
26319
26425
|
|
|
26320
26426
|
// src/commands/sound.ts
|
|
26321
|
-
import { existsSync as
|
|
26427
|
+
import { existsSync as existsSync11, readFileSync as readFileSync9, rmSync, writeFileSync as writeFileSync9 } from "fs";
|
|
26322
26428
|
import { homedir as homedir2 } from "os";
|
|
26323
|
-
import { join as
|
|
26429
|
+
import { join as join12 } from "path";
|
|
26324
26430
|
|
|
26325
26431
|
// src/sound.ts
|
|
26326
26432
|
import { spawn as spawn2 } from "child_process";
|
|
26327
|
-
import { existsSync as
|
|
26328
|
-
import { join as
|
|
26433
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync5, statSync, writeFileSync as writeFileSync8 } from "fs";
|
|
26434
|
+
import { join as join11 } from "path";
|
|
26329
26435
|
|
|
26330
26436
|
// src/sound-files.ts
|
|
26331
26437
|
var SOUND_FILES = {
|
|
@@ -26342,13 +26448,13 @@ function soundWanted(cfg, env = process.env) {
|
|
|
26342
26448
|
const s = env.DEPLOYAI_SOUND;
|
|
26343
26449
|
return !(s !== void 0 && ["0", "false", "off", "no"].includes(s.toLowerCase()));
|
|
26344
26450
|
}
|
|
26345
|
-
var soundsDir = () =>
|
|
26451
|
+
var soundsDir = () => join11(configDir(), "sounds");
|
|
26346
26452
|
function writeSoundFiles() {
|
|
26347
|
-
|
|
26453
|
+
mkdirSync5(soundsDir(), { recursive: true });
|
|
26348
26454
|
for (const [name, b64] of Object.entries(SOUND_FILES)) {
|
|
26349
26455
|
const data = Buffer.from(b64, "base64");
|
|
26350
|
-
const file2 =
|
|
26351
|
-
if (!
|
|
26456
|
+
const file2 = join11(soundsDir(), `${name}.wav`);
|
|
26457
|
+
if (!existsSync10(file2) || statSync(file2).size !== data.length) writeFileSync8(file2, data);
|
|
26352
26458
|
}
|
|
26353
26459
|
}
|
|
26354
26460
|
function playerFor(platform3, file2) {
|
|
@@ -26361,7 +26467,7 @@ function playSound(name, cfg) {
|
|
|
26361
26467
|
if (!soundWanted(cfg)) return;
|
|
26362
26468
|
try {
|
|
26363
26469
|
writeSoundFiles();
|
|
26364
|
-
const player = playerFor(process.platform,
|
|
26470
|
+
const player = playerFor(process.platform, join11(soundsDir(), `${name}.wav`));
|
|
26365
26471
|
if (!player) return;
|
|
26366
26472
|
const child = spawn2(player.cmd, player.args, { detached: true, stdio: "ignore", windowsHide: true });
|
|
26367
26473
|
child.on("error", () => void 0);
|
|
@@ -26440,17 +26546,17 @@ function foreignHooks(files) {
|
|
|
26440
26546
|
return [...found];
|
|
26441
26547
|
}
|
|
26442
26548
|
function agentOn(root, opts = {}) {
|
|
26443
|
-
const file2 =
|
|
26549
|
+
const file2 = join12(root, SETTINGS);
|
|
26444
26550
|
const obj = readObject(file2);
|
|
26445
26551
|
if (!obj) throw new CliError(`${SETTINGS} is not valid JSON, so it was left as is.`, 1, "allow_file");
|
|
26446
|
-
const home = process.env.CLAUDE_CONFIG_DIR ||
|
|
26447
|
-
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";
|
|
26448
26554
|
writeSoundFiles();
|
|
26449
26555
|
ensureDeployaiDir(root);
|
|
26450
|
-
const script =
|
|
26556
|
+
const script = join12(root, AGENT_SCRIPT);
|
|
26451
26557
|
const text2 = agentScript(soundsDir());
|
|
26452
|
-
const scriptSame =
|
|
26453
|
-
if (!scriptSame)
|
|
26558
|
+
const scriptSame = existsSync11(script) && readFileSync9(script, "utf8") === text2;
|
|
26559
|
+
if (!scriptSame) writeFileSync9(script, text2);
|
|
26454
26560
|
const hooks = hooksOf(obj);
|
|
26455
26561
|
const env = obj.env && typeof obj.env === "object" ? obj.env : {};
|
|
26456
26562
|
let added = env[TITLE_ENV] !== "1";
|
|
@@ -26468,7 +26574,7 @@ function agentOn(root, opts = {}) {
|
|
|
26468
26574
|
return added || !scriptSame ? "on" : "already";
|
|
26469
26575
|
}
|
|
26470
26576
|
function agentOff(root) {
|
|
26471
|
-
const file2 =
|
|
26577
|
+
const file2 = join12(root, SETTINGS);
|
|
26472
26578
|
const obj = readObject(file2);
|
|
26473
26579
|
if (!obj) throw new CliError(`${SETTINGS} is not valid JSON, so it was left as is.`, 1, "allow_file");
|
|
26474
26580
|
const hooks = hooksOf(obj);
|
|
@@ -26490,8 +26596,8 @@ function agentOff(root) {
|
|
|
26490
26596
|
else delete obj.hooks;
|
|
26491
26597
|
writeObject(file2, obj);
|
|
26492
26598
|
}
|
|
26493
|
-
const script =
|
|
26494
|
-
if (
|
|
26599
|
+
const script = join12(root, AGENT_SCRIPT);
|
|
26600
|
+
if (existsSync11(script)) {
|
|
26495
26601
|
rmSync(script);
|
|
26496
26602
|
removed = true;
|
|
26497
26603
|
}
|
|
@@ -26558,22 +26664,46 @@ function soundCommand(root, action, state, tool, opts = {}) {
|
|
|
26558
26664
|
out(t(soundWanted(cfg) ? "soundOn" : "soundOff"));
|
|
26559
26665
|
}
|
|
26560
26666
|
function refreshAgentScript(root) {
|
|
26561
|
-
const script =
|
|
26562
|
-
if (!
|
|
26667
|
+
const script = join12(root, AGENT_SCRIPT);
|
|
26668
|
+
if (!existsSync11(script)) return false;
|
|
26563
26669
|
const text2 = agentScript(soundsDir());
|
|
26564
|
-
const now =
|
|
26670
|
+
const now = readFileSync9(script, "utf8");
|
|
26565
26671
|
if (now === text2 || !now.startsWith("// DeployAI's sound and tab dot")) return false;
|
|
26566
26672
|
writeSoundFiles();
|
|
26567
|
-
|
|
26673
|
+
writeFileSync9(script, text2);
|
|
26568
26674
|
return true;
|
|
26569
26675
|
}
|
|
26570
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
|
+
|
|
26571
26701
|
// src/commands/link.ts
|
|
26572
26702
|
import { createInterface } from "readline/promises";
|
|
26573
26703
|
|
|
26574
26704
|
// src/commands/migrate.ts
|
|
26575
|
-
import { createWriteStream, existsSync as
|
|
26576
|
-
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";
|
|
26577
26707
|
import { Readable } from "stream";
|
|
26578
26708
|
import { pipeline } from "stream/promises";
|
|
26579
26709
|
var UA = `deployai-migrate/${CLI_VERSION} (+https://deployai.co.il/move)`;
|
|
@@ -26585,7 +26715,7 @@ var PAUSE_MS = 150;
|
|
|
26585
26715
|
var SCAN_WORKERS = 4;
|
|
26586
26716
|
var START_SCAN_PAGES = 300;
|
|
26587
26717
|
var sleep2 = (ms2) => new Promise((r) => setTimeout(r, ms2));
|
|
26588
|
-
var hostDir = (root, host) =>
|
|
26718
|
+
var hostDir = (root, host) => join13(root, MIGRATION_DIR, host.replace(/^www\./, ""));
|
|
26589
26719
|
var readJson3 = (file2) => {
|
|
26590
26720
|
try {
|
|
26591
26721
|
return readJson(file2);
|
|
@@ -26594,8 +26724,8 @@ var readJson3 = (file2) => {
|
|
|
26594
26724
|
}
|
|
26595
26725
|
};
|
|
26596
26726
|
var writeJson = (file2, data) => {
|
|
26597
|
-
|
|
26598
|
-
|
|
26727
|
+
mkdirSync6(dirname2(file2), { recursive: true });
|
|
26728
|
+
writeFileSync10(file2, JSON.stringify(data, null, 2) + "\n");
|
|
26599
26729
|
};
|
|
26600
26730
|
async function get(url2, accept = "text/html,application/xhtml+xml,*/*;q=0.8", redirect = "follow", cookie) {
|
|
26601
26731
|
try {
|
|
@@ -26605,9 +26735,9 @@ async function get(url2, accept = "text/html,application/xhtml+xml,*/*;q=0.8", r
|
|
|
26605
26735
|
}
|
|
26606
26736
|
}
|
|
26607
26737
|
function scannedHosts(root) {
|
|
26608
|
-
const dir =
|
|
26609
|
-
if (!
|
|
26610
|
-
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")));
|
|
26611
26741
|
}
|
|
26612
26742
|
async function migrateStatusCommand(root, ctx, stage, note) {
|
|
26613
26743
|
if (!isAgentStage(stage)) throw new CliError(`Unknown stage: ${stage}. One of: ${AGENT_STAGES.join(", ")}.`, 1, "usage");
|
|
@@ -26620,18 +26750,18 @@ async function migrateStatusCommand(root, ctx, stage, note) {
|
|
|
26620
26750
|
out(`Reported: ${stage}${note ? ` (${stageNote(note)})` : ""}.`);
|
|
26621
26751
|
}
|
|
26622
26752
|
function readChoices(root) {
|
|
26623
|
-
return readJson3(
|
|
26753
|
+
return readJson3(join13(root, MIGRATION_DIR, "choices.json"));
|
|
26624
26754
|
}
|
|
26625
26755
|
function writeChoices(root, choices) {
|
|
26626
26756
|
ensureMigrationDir(root);
|
|
26627
|
-
writeJson(
|
|
26757
|
+
writeJson(join13(root, MIGRATION_DIR, "choices.json"), choices);
|
|
26628
26758
|
}
|
|
26629
26759
|
function ensureMigrationDir(root) {
|
|
26630
26760
|
ensureDeployaiDir(root);
|
|
26631
|
-
const dir =
|
|
26632
|
-
|
|
26633
|
-
const ignore =
|
|
26634
|
-
if (!
|
|
26761
|
+
const dir = join13(root, MIGRATION_DIR);
|
|
26762
|
+
mkdirSync6(dir, { recursive: true });
|
|
26763
|
+
const ignore = join13(dir, ".gitignore");
|
|
26764
|
+
if (!existsSync12(ignore)) writeFileSync10(ignore, "*/media/\n*/media-state.json\n");
|
|
26635
26765
|
}
|
|
26636
26766
|
function sameAddress(from, to) {
|
|
26637
26767
|
try {
|
|
@@ -26702,15 +26832,15 @@ async function wordpressContent(base, dir) {
|
|
|
26702
26832
|
await sleep2(PAUSE_MS);
|
|
26703
26833
|
}
|
|
26704
26834
|
if (items.length) {
|
|
26705
|
-
writeJson(
|
|
26835
|
+
writeJson(join13(dir, "content", `${type}.json`), items);
|
|
26706
26836
|
out(` ${type}: ${items.length}`);
|
|
26707
26837
|
}
|
|
26708
26838
|
}
|
|
26709
|
-
const posts = readJson3(
|
|
26839
|
+
const posts = readJson3(join13(dir, "content", "posts.json"));
|
|
26710
26840
|
if (posts?.length) {
|
|
26711
|
-
const files = wpPostsToMarkdown({ origin: new URL(base).origin, posts, categories: readJson3(
|
|
26712
|
-
|
|
26713
|
-
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);
|
|
26714
26844
|
out(` posts as Markdown: ${files.length}`);
|
|
26715
26845
|
}
|
|
26716
26846
|
return true;
|
|
@@ -26781,7 +26911,7 @@ async function saveOldIcons(html, pageUrl, origin, dir) {
|
|
|
26781
26911
|
add(`${origin}/favicon.ico`, "icon");
|
|
26782
26912
|
add(logoInPage(html), "logo");
|
|
26783
26913
|
const saved = [];
|
|
26784
|
-
const icons =
|
|
26914
|
+
const icons = join13(dir, "icons");
|
|
26785
26915
|
for (const w of wanted.slice(0, 6)) {
|
|
26786
26916
|
const res = await get(w.url, "image/*,*/*;q=0.8");
|
|
26787
26917
|
if (!res?.ok) continue;
|
|
@@ -26791,23 +26921,23 @@ async function saveOldIcons(html, pageUrl, origin, dir) {
|
|
|
26791
26921
|
const svg = !size && isSvgText(bytes.subarray(0, 2048).toString("utf8"));
|
|
26792
26922
|
if (!size && !svg) continue;
|
|
26793
26923
|
const file2 = `${saved.length + 1}-${w.kind}.${svg ? "svg" : size?.format === "jpeg" ? "jpg" : size?.format}`;
|
|
26794
|
-
|
|
26795
|
-
|
|
26924
|
+
mkdirSync6(icons, { recursive: true });
|
|
26925
|
+
writeFileSync10(join13(icons, file2), bytes);
|
|
26796
26926
|
saved.push({ file: file2, kind: w.kind });
|
|
26797
26927
|
}
|
|
26798
|
-
if (saved.length)
|
|
26928
|
+
if (saved.length) writeFileSync10(join13(icons, "icons.json"), JSON.stringify(saved, null, 2));
|
|
26799
26929
|
return saved.length;
|
|
26800
26930
|
}
|
|
26801
26931
|
async function saveOldStyles(html, pageUrl, dir) {
|
|
26802
|
-
const styles =
|
|
26932
|
+
const styles = join13(dir, "styles");
|
|
26803
26933
|
let n2 = 0;
|
|
26804
26934
|
for (const url2 of stylesheetLinks(html, pageUrl, 6)) {
|
|
26805
26935
|
const res = await get(url2, "text/css,*/*;q=0.8");
|
|
26806
26936
|
if (!res?.ok) continue;
|
|
26807
26937
|
const text2 = await res.text();
|
|
26808
26938
|
if (text2.length > ICON_MAX_BYTES) continue;
|
|
26809
|
-
|
|
26810
|
-
|
|
26939
|
+
mkdirSync6(styles, { recursive: true });
|
|
26940
|
+
writeFileSync10(join13(styles, `${++n2}.css`), text2);
|
|
26811
26941
|
}
|
|
26812
26942
|
}
|
|
26813
26943
|
var TRIGGER_PAGES_CAP = 30;
|
|
@@ -26835,15 +26965,15 @@ async function hasRootFile(origin, path, query = "", cookie) {
|
|
|
26835
26965
|
const res = await get(`${origin}${path}${query}`, "*/*", "follow", cookie);
|
|
26836
26966
|
return Boolean(res?.ok && !/text\/html/i.test(res.headers.get("content-type") ?? ""));
|
|
26837
26967
|
}
|
|
26838
|
-
var tagsFile = (dir) =>
|
|
26839
|
-
var stateFile = (dir) =>
|
|
26968
|
+
var tagsFile = (dir) => join13(dir, "tags.json");
|
|
26969
|
+
var stateFile = (dir) => join13(dir, "report-state.json");
|
|
26840
26970
|
function kitMap(root) {
|
|
26841
|
-
if (!
|
|
26971
|
+
if (!existsSync12(join13(root, "src/kit/schema.ts"))) return {};
|
|
26842
26972
|
const cut = (s, n2) => String(s ?? "").slice(0, n2);
|
|
26843
|
-
const pages = (readJson3(
|
|
26844
|
-
const posts = readJson3(
|
|
26845
|
-
const docs = [...new Set((readJson3(
|
|
26846
|
-
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) => ({
|
|
26847
26977
|
key: f.key,
|
|
26848
26978
|
label: cut(f.label, 80),
|
|
26849
26979
|
...f.page ? { page: cut(f.page, 300) } : {},
|
|
@@ -26854,11 +26984,11 @@ function kitMap(root) {
|
|
|
26854
26984
|
}
|
|
26855
26985
|
async function sendReport(root, ctx, host, open2, verify) {
|
|
26856
26986
|
const dir = hostDir(root, host);
|
|
26857
|
-
const inv = readJson3(
|
|
26987
|
+
const inv = readJson3(join13(dir, "inventory.json"));
|
|
26858
26988
|
const site = readJson3(tagsFile(dir));
|
|
26859
26989
|
const startId = readChoices(root)?.startId;
|
|
26860
26990
|
if (!inv || !site) return;
|
|
26861
|
-
const dns = readJson3(
|
|
26991
|
+
const dns = readJson3(join13(dir, "dns.json"));
|
|
26862
26992
|
const thanksPages = findThanksPages(inv.pages);
|
|
26863
26993
|
if (open2 === "scan") {
|
|
26864
26994
|
if (thanksPages.length && site.forms.length) {
|
|
@@ -26888,9 +27018,9 @@ async function sendReport(root, ctx, host, open2, verify) {
|
|
|
26888
27018
|
return;
|
|
26889
27019
|
}
|
|
26890
27020
|
const state = readJson3(stateFile(dir)) ?? {};
|
|
26891
|
-
const plan =
|
|
26892
|
-
const saved = verify ?? readJson3(
|
|
26893
|
-
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")) ?? [];
|
|
26894
27024
|
const report2 = {
|
|
26895
27025
|
source: inv.source,
|
|
26896
27026
|
platform: inv.platform,
|
|
@@ -26943,11 +27073,11 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
26943
27073
|
const host = new URL(origin).hostname;
|
|
26944
27074
|
ensureMigrationDir(root);
|
|
26945
27075
|
const dir = hostDir(root, host);
|
|
26946
|
-
|
|
27076
|
+
mkdirSync6(dir, { recursive: true });
|
|
26947
27077
|
out(`Scanning ${base} (${platform3})`);
|
|
26948
27078
|
const robotsRes = await get(`${origin}/robots.txt`, "text/plain");
|
|
26949
27079
|
const robots = robotsRes?.ok ? await robotsRes.text() : "";
|
|
26950
|
-
if (robots)
|
|
27080
|
+
if (robots) writeFileSync10(join13(dir, "robots.txt"), robots);
|
|
26951
27081
|
const cap = Math.min(opts.max ?? PAGE_CAP, PAGE_CAP);
|
|
26952
27082
|
const fromSitemaps = await sitemapUrls(base, robots ? parseRobots(robots).sitemaps : [], cap * 5);
|
|
26953
27083
|
const all = [.../* @__PURE__ */ new Set([`${base}/`, ...fromSitemaps.urls, ...fromSitemaps.urls.length ? [] : homeLinks(html, base)])];
|
|
@@ -26987,7 +27117,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
26987
27117
|
await addStylesheetAssets(assets);
|
|
26988
27118
|
const wordpressApi = platform3 === "wordpress" ? await wordpressContent(base, dir) : false;
|
|
26989
27119
|
if (wordpressApi) {
|
|
26990
|
-
const media = readJson3(
|
|
27120
|
+
const media = readJson3(join13(dir, "content", "media.json")) ?? [];
|
|
26991
27121
|
media.forEach((m) => m.source_url && assets.add(m.source_url));
|
|
26992
27122
|
}
|
|
26993
27123
|
const known = new Set(pages.map((p) => p.path));
|
|
@@ -27012,13 +27142,13 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
27012
27142
|
const bare = registrableDomain(host);
|
|
27013
27143
|
try {
|
|
27014
27144
|
const { records, unread } = await collectSnapshot(bare, { extraNames: [...site.ownNames, ...site.serverContainers], deadlineMs: 3e4 });
|
|
27015
|
-
writeJson(
|
|
27145
|
+
writeJson(join13(dir, "dns.json"), { records: records.slice(0, 600), unread: unread.slice(0, 300), services: dnsServices(records).slice(0, 40) });
|
|
27016
27146
|
} catch {
|
|
27017
27147
|
}
|
|
27018
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) };
|
|
27019
|
-
writeJson(
|
|
27020
|
-
writeJson(
|
|
27021
|
-
|
|
27149
|
+
writeJson(join13(dir, "inventory.json"), inventory);
|
|
27150
|
+
writeJson(join13(dir, "assets.json"), [...assets].sort());
|
|
27151
|
+
writeFileSync10(join13(dir, "home.html"), html);
|
|
27022
27152
|
const icons = await saveOldIcons(html, home.url, origin, dir);
|
|
27023
27153
|
await saveOldStyles(html, home.url, dir);
|
|
27024
27154
|
const rel = relative(root, dir).split(sep).join("/");
|
|
@@ -27032,7 +27162,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
27032
27162
|
if (icons) out(` icons/ ${icons} icons and logo of the old site, for: npx deployai@latest brand favicon`);
|
|
27033
27163
|
if (wordpressApi) {
|
|
27034
27164
|
out(" content/ the WordPress pages, posts, categories, tags, media and authors as JSON");
|
|
27035
|
-
if (
|
|
27165
|
+
if (existsSync12(join13(dir, "posts"))) out(" posts/ the posts as Markdown for the blog block, each with its old address");
|
|
27036
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).");
|
|
27037
27167
|
out();
|
|
27038
27168
|
out("Keep every path in inventory.json exactly as it is: same address, same title and description.");
|
|
@@ -27052,8 +27182,8 @@ async function migrateMediaCommand(root) {
|
|
|
27052
27182
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27053
27183
|
for (const host of hosts) {
|
|
27054
27184
|
const dir = hostDir(root, host);
|
|
27055
|
-
const assets = readJson3(
|
|
27056
|
-
const stateFile2 =
|
|
27185
|
+
const assets = readJson3(join13(dir, "assets.json")) ?? [];
|
|
27186
|
+
const stateFile2 = join13(dir, "media-state.json");
|
|
27057
27187
|
const state = readJson3(stateFile2) ?? { done: [], failed: [], bytes: 0 };
|
|
27058
27188
|
const done = new Set(state.done);
|
|
27059
27189
|
const todo = assets.filter((a) => !done.has(a));
|
|
@@ -27072,7 +27202,7 @@ async function migrateMediaCommand(root) {
|
|
|
27072
27202
|
done.add(url2);
|
|
27073
27203
|
continue;
|
|
27074
27204
|
}
|
|
27075
|
-
|
|
27205
|
+
mkdirSync6(dirname2(target), { recursive: true });
|
|
27076
27206
|
await pipeline(Readable.fromWeb(res.body), createWriteStream(target));
|
|
27077
27207
|
const bytes = statSync2(target).size;
|
|
27078
27208
|
state.bytes += bytes;
|
|
@@ -27083,7 +27213,7 @@ async function migrateMediaCommand(root) {
|
|
|
27083
27213
|
}
|
|
27084
27214
|
state.done = [...done];
|
|
27085
27215
|
writeJson(stateFile2, state);
|
|
27086
|
-
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)` : ""}`);
|
|
27087
27217
|
}
|
|
27088
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.");
|
|
27089
27219
|
}
|
|
@@ -27104,19 +27234,19 @@ function redirectLines(inv, rss = "/rss.xml") {
|
|
|
27104
27234
|
function migratePostsCommand(root) {
|
|
27105
27235
|
const hosts = scannedHosts(root);
|
|
27106
27236
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27107
|
-
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");
|
|
27108
27238
|
const posts = [];
|
|
27109
27239
|
for (const host of hosts) {
|
|
27110
27240
|
const dir = hostDir(root, host);
|
|
27111
|
-
const inv = readJson3(
|
|
27112
|
-
const list = readJson3(
|
|
27113
|
-
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")) ?? [] }));
|
|
27114
27244
|
}
|
|
27115
27245
|
if (!posts.length) {
|
|
27116
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.");
|
|
27117
27247
|
return;
|
|
27118
27248
|
}
|
|
27119
|
-
|
|
27249
|
+
writeFileSync10(join13(root, "src/kit/moved-posts.json"), JSON.stringify(posts.map(({ lost: _lost, ...p }) => p), null, 1));
|
|
27120
27250
|
out(`Wrote ${posts.length} posts to src/kit/moved-posts.json. Turn on blog in src/kit/site.config.ts.`);
|
|
27121
27251
|
const short = posts.filter((p) => p.lost.length);
|
|
27122
27252
|
if (short.length) {
|
|
@@ -27127,31 +27257,31 @@ function migratePostsCommand(root) {
|
|
|
27127
27257
|
function migratePagesCommand(root) {
|
|
27128
27258
|
const hosts = scannedHosts(root);
|
|
27129
27259
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27130
|
-
if (!
|
|
27131
|
-
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);
|
|
27132
27262
|
const before = readJson3(file2);
|
|
27133
27263
|
const pages = [];
|
|
27134
27264
|
for (const host of hosts) {
|
|
27135
27265
|
const dir = hostDir(root, host);
|
|
27136
|
-
const inv = readJson3(
|
|
27266
|
+
const inv = readJson3(join13(dir, "inventory.json"));
|
|
27137
27267
|
if (!inv) continue;
|
|
27138
|
-
const homeHtml =
|
|
27268
|
+
const homeHtml = existsSync12(join13(dir, "home.html")) ? readFileSync10(join13(dir, "home.html"), "utf8") : null;
|
|
27139
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);
|
|
27140
27270
|
}
|
|
27141
27271
|
const kept = before?.length ? pages.filter((p) => before.some((b) => b.path === p.path)) : pages;
|
|
27142
|
-
|
|
27272
|
+
writeFileSync10(file2, JSON.stringify(kept, null, 1));
|
|
27143
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.`);
|
|
27144
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.");
|
|
27145
27275
|
}
|
|
27146
27276
|
function migrateLegalCommand(root) {
|
|
27147
27277
|
const hosts = scannedHosts(root);
|
|
27148
27278
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27149
|
-
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");
|
|
27150
27280
|
const pages = [];
|
|
27151
27281
|
const site = emptySiteTags();
|
|
27152
27282
|
for (const host of hosts) {
|
|
27153
27283
|
const dir = hostDir(root, host);
|
|
27154
|
-
pages.push(...readJson3(
|
|
27284
|
+
pages.push(...readJson3(join13(dir, "inventory.json"))?.pages ?? []);
|
|
27155
27285
|
const found = readJson3(tagsFile(dir));
|
|
27156
27286
|
if (found) {
|
|
27157
27287
|
site.tags.push(...found.tags);
|
|
@@ -27159,9 +27289,9 @@ function migrateLegalCommand(root) {
|
|
|
27159
27289
|
site.forms.push(...found.forms);
|
|
27160
27290
|
}
|
|
27161
27291
|
}
|
|
27162
|
-
const file2 =
|
|
27292
|
+
const file2 = join13(root, MOVED_LEGAL_FILE);
|
|
27163
27293
|
const legal = { ...movedLegalFromScan({ pages, site }), docs: readJson3(file2)?.docs ?? [] };
|
|
27164
|
-
|
|
27294
|
+
writeFileSync10(file2, JSON.stringify(legal, null, 1));
|
|
27165
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.`);
|
|
27166
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.`);
|
|
27167
27297
|
out("Nothing here is finished or checked: it tells the owner what to look at. Keep tags, forms and pages as they are.");
|
|
@@ -27171,22 +27301,22 @@ function migrateRedirectsCommand(root) {
|
|
|
27171
27301
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27172
27302
|
const lines = /* @__PURE__ */ new Set();
|
|
27173
27303
|
for (const host of hosts) {
|
|
27174
|
-
const inv = readJson3(
|
|
27304
|
+
const inv = readJson3(join13(hostDir(root, host), "inventory.json"));
|
|
27175
27305
|
if (inv) redirectLines(inv).forEach((l) => lines.add(l));
|
|
27176
27306
|
}
|
|
27177
|
-
const publicDir =
|
|
27178
|
-
const file2 =
|
|
27179
|
-
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) : [];
|
|
27180
27310
|
const added = [...lines].filter((l) => !before.some((b) => b.split(/\s+/)[0] === l.split(/\s+/)[0]));
|
|
27181
|
-
|
|
27311
|
+
writeFileSync10(file2, [...before, ...added].join("\n") + "\n");
|
|
27182
27312
|
out(`${relative(root, file2).split(sep).join("/")}: ${added.length} added, ${before.length + added.length} in all (at most 2,000; no query strings).`);
|
|
27183
27313
|
out('Add a line "<old path> <new path> 301" only for a page that truly could not keep its address.');
|
|
27184
27314
|
}
|
|
27185
27315
|
function allowedRedirects(root) {
|
|
27186
27316
|
const map2 = /* @__PURE__ */ new Map();
|
|
27187
|
-
for (const file2 of [
|
|
27188
|
-
if (!
|
|
27189
|
-
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/)) {
|
|
27190
27320
|
const [from, to] = line.trim().split(/\s+/);
|
|
27191
27321
|
if (from && to && !from.startsWith("#")) map2.set(from, to);
|
|
27192
27322
|
}
|
|
@@ -27216,11 +27346,11 @@ async function migrateTagsCommand(root, ctx, opts) {
|
|
|
27216
27346
|
const [k, v] = a.split("=");
|
|
27217
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");
|
|
27218
27348
|
}
|
|
27219
|
-
const urls = opts.requests ?
|
|
27349
|
+
const urls = opts.requests ? readFileSync10(resolve(root, opts.requests), "utf8").split(/\r?\n/) : [];
|
|
27220
27350
|
for (const host of hosts) {
|
|
27221
27351
|
const dir = hostDir(root, host);
|
|
27222
27352
|
const site = readJson3(tagsFile(dir));
|
|
27223
|
-
const inv = readJson3(
|
|
27353
|
+
const inv = readJson3(join13(dir, "inventory.json"));
|
|
27224
27354
|
if (!site || !inv) continue;
|
|
27225
27355
|
const state = readJson3(stateFile(dir)) ?? {};
|
|
27226
27356
|
if (urls.length && opts.fired) {
|
|
@@ -27290,7 +27420,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
27290
27420
|
const tagFindings = [];
|
|
27291
27421
|
const perHost = [];
|
|
27292
27422
|
for (const host of hosts) {
|
|
27293
|
-
const inv = readJson3(
|
|
27423
|
+
const inv = readJson3(join13(hostDir(root, host), "inventory.json"));
|
|
27294
27424
|
const oldSite = readJson3(tagsFile(hostDir(root, host)));
|
|
27295
27425
|
const state = readJson3(stateFile(hostDir(root, host))) ?? {};
|
|
27296
27426
|
const nextSite = emptySiteTags();
|
|
@@ -27339,7 +27469,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
27339
27469
|
}
|
|
27340
27470
|
}
|
|
27341
27471
|
const words = { missing: "not found on the preview", moved: "moved to", error: "answers", title_lost: "lost its title", description_lost: "lost its description" };
|
|
27342
|
-
const report2 =
|
|
27472
|
+
const report2 = join13(root, MIGRATION_DIR, "verify.json");
|
|
27343
27473
|
writeJson(report2, { checkedAt: (/* @__PURE__ */ new Date()).toISOString(), preview: preview.origin, checked, findings, credits: [...credits.keys()], vendors: [...vendors.keys()], tags: tagFindings });
|
|
27344
27474
|
if (credits.size) {
|
|
27345
27475
|
out(`A builder's credit is still on the preview:`);
|
|
@@ -27364,7 +27494,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
27364
27494
|
for (const h of perHost) {
|
|
27365
27495
|
const dir = hostDir(root, h.host);
|
|
27366
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) };
|
|
27367
|
-
writeJson(
|
|
27497
|
+
writeJson(join13(dir, "verify-report.json"), { report: verify });
|
|
27368
27498
|
await sendReport(root, ctx, h.host, clean3 ? "verify" : null, verify);
|
|
27369
27499
|
}
|
|
27370
27500
|
if (!findings.length) {
|
|
@@ -27492,32 +27622,32 @@ async function askYes(question) {
|
|
|
27492
27622
|
}
|
|
27493
27623
|
|
|
27494
27624
|
// src/same-name.ts
|
|
27495
|
-
import { createHash } from "crypto";
|
|
27496
|
-
import { mkdirSync as
|
|
27497
|
-
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";
|
|
27498
27628
|
var LAST_FILES = ".deployai/last-files.json";
|
|
27499
27629
|
var KEPT = /^(public|static)\/.*\.(avif|webp|png|jpe?g|gif|svg|ico|woff2?|ttf|otf|mp4|webm|css|js|mjs)$/i;
|
|
27500
27630
|
var HASHED = /[.-][A-Za-z0-9_]{6,20}\.[a-z0-9]+$/;
|
|
27501
|
-
var digest = (abs) =>
|
|
27631
|
+
var digest = (abs) => createHash2("sha1").update(readFileSync11(abs)).digest("hex").slice(0, 16);
|
|
27502
27632
|
function changedUnderSameName(root, files) {
|
|
27503
27633
|
const now = {};
|
|
27504
27634
|
for (const f of files) if (KEPT.test(f.rel) && !HASHED.test(f.rel.split("/").pop() ?? "")) now[f.rel] = digest(f.abs);
|
|
27505
27635
|
let before = {};
|
|
27506
27636
|
try {
|
|
27507
|
-
before = readJson(
|
|
27637
|
+
before = readJson(join14(root, LAST_FILES));
|
|
27508
27638
|
} catch {
|
|
27509
27639
|
}
|
|
27510
27640
|
const changed = Object.keys(now).filter((rel) => before[rel] && before[rel] !== now[rel]).sort();
|
|
27511
27641
|
try {
|
|
27512
|
-
|
|
27513
|
-
|
|
27642
|
+
mkdirSync7(dirname3(join14(root, LAST_FILES)), { recursive: true });
|
|
27643
|
+
writeFileSync11(join14(root, LAST_FILES), JSON.stringify(now));
|
|
27514
27644
|
} catch {
|
|
27515
27645
|
}
|
|
27516
27646
|
return changed;
|
|
27517
27647
|
}
|
|
27518
27648
|
|
|
27519
27649
|
// src/tar.ts
|
|
27520
|
-
import { readFileSync as
|
|
27650
|
+
import { readFileSync as readFileSync12 } from "fs";
|
|
27521
27651
|
import { gzipSync } from "zlib";
|
|
27522
27652
|
var BLOCK = 512;
|
|
27523
27653
|
function writeString(buf, offset, length, value) {
|
|
@@ -27601,7 +27731,7 @@ function packFiles(files) {
|
|
|
27601
27731
|
return createTarGz(
|
|
27602
27732
|
files.map((f) => ({
|
|
27603
27733
|
name: f.rel,
|
|
27604
|
-
data:
|
|
27734
|
+
data: readFileSync12(f.abs),
|
|
27605
27735
|
mtimeMs: f.mtimeMs,
|
|
27606
27736
|
mode: f.mode & 64 ? 493 : 420
|
|
27607
27737
|
}))
|
|
@@ -27708,14 +27838,14 @@ async function promoteWithSql(root, ctx, projectId, number4, kind, approve) {
|
|
|
27708
27838
|
function fetchStatus(ctx, projectId) {
|
|
27709
27839
|
return apiRequest(ctx, `/api/cli/status?projectId=${encodeURIComponent(projectId)}`, StatusResponse);
|
|
27710
27840
|
}
|
|
27711
|
-
var
|
|
27841
|
+
var WAIT_MS2 = 5 * 6e4;
|
|
27712
27842
|
var statusBusy = (s) => s.queue.running || s.queue.position > 0 || Boolean(s.latest?.goingLive) || s.latest?.status === "queued" || s.latest?.status === "building";
|
|
27713
27843
|
async function statusCommand(root, ctx, opts = {}) {
|
|
27714
27844
|
requireToken(ctx);
|
|
27715
27845
|
const projectId = linkedProjectId(root);
|
|
27716
27846
|
let s = await fetchStatus(ctx, projectId);
|
|
27717
27847
|
if (opts.wait) {
|
|
27718
|
-
const end = Date.now() +
|
|
27848
|
+
const end = Date.now() + WAIT_MS2;
|
|
27719
27849
|
while (statusBusy(s) && Date.now() < end) {
|
|
27720
27850
|
await new Promise((r) => setTimeout(r, opts.pollMs ?? 3e3));
|
|
27721
27851
|
s = await fetchStatus(ctx, projectId);
|
|
@@ -28199,13 +28329,13 @@ async function claimCommand(root, ctx, opts) {
|
|
|
28199
28329
|
|
|
28200
28330
|
// src/commands/pull.ts
|
|
28201
28331
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
28202
|
-
import { existsSync as
|
|
28203
|
-
import { join as
|
|
28332
|
+
import { existsSync as existsSync14, readdirSync as readdirSync5, rmSync as rmSync2 } from "fs";
|
|
28333
|
+
import { join as join16 } from "path";
|
|
28204
28334
|
|
|
28205
28335
|
// src/commands/samples.ts
|
|
28206
28336
|
import { createInterface as createInterface3 } from "readline/promises";
|
|
28207
|
-
import { existsSync as
|
|
28208
|
-
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";
|
|
28209
28339
|
import { gunzipSync } from "zlib";
|
|
28210
28340
|
var SAMPLES = [
|
|
28211
28341
|
{ key: "landing", title: "Landing page: a full one-page site with WhatsApp sign-up", stack: "static HTML and CSS" },
|
|
@@ -28226,7 +28356,7 @@ function listSamples(apiUrl) {
|
|
|
28226
28356
|
out(`See them live: ${apiUrl}/samples`);
|
|
28227
28357
|
}
|
|
28228
28358
|
function filesIn(dir) {
|
|
28229
|
-
return
|
|
28359
|
+
return existsSync13(dir) ? readdirSync4(dir).filter((f) => !IGNORED.has(f)) : [];
|
|
28230
28360
|
}
|
|
28231
28361
|
function freeFolder(cwd, key) {
|
|
28232
28362
|
for (let n2 = 1; ; n2++) {
|
|
@@ -28255,7 +28385,7 @@ async function askWhere(cwd, key, count) {
|
|
|
28255
28385
|
}
|
|
28256
28386
|
}
|
|
28257
28387
|
async function downloadSample(ctx, key, root) {
|
|
28258
|
-
|
|
28388
|
+
mkdirSync8(root, { recursive: true });
|
|
28259
28389
|
let res;
|
|
28260
28390
|
try {
|
|
28261
28391
|
res = await fetch(`${ctx.apiUrl}/samples-src/${key}.tar.gz`, {
|
|
@@ -28277,7 +28407,7 @@ function extractInto(gz, root, damaged) {
|
|
|
28277
28407
|
} catch {
|
|
28278
28408
|
throw new CliError(damaged, 1, "api");
|
|
28279
28409
|
}
|
|
28280
|
-
|
|
28410
|
+
mkdirSync8(root, { recursive: true });
|
|
28281
28411
|
const base = resolve2(root);
|
|
28282
28412
|
let written = 0;
|
|
28283
28413
|
for (const e3 of entries) {
|
|
@@ -28285,8 +28415,8 @@ function extractInto(gz, root, damaged) {
|
|
|
28285
28415
|
if (privateProjectFile(e3.name.replace(/\\/g, "/"))) continue;
|
|
28286
28416
|
const target = resolve2(base, e3.name);
|
|
28287
28417
|
if (target !== base && !target.startsWith(base + sep2)) continue;
|
|
28288
|
-
|
|
28289
|
-
|
|
28418
|
+
mkdirSync8(dirname4(target), { recursive: true });
|
|
28419
|
+
writeFileSync12(target, e3.data);
|
|
28290
28420
|
written++;
|
|
28291
28421
|
}
|
|
28292
28422
|
return written;
|
|
@@ -28310,7 +28440,7 @@ async function samplesCommand(cwd, ctx, key, opts = {}) {
|
|
|
28310
28440
|
}
|
|
28311
28441
|
const written = await downloadSample(ctx, sample.key, root);
|
|
28312
28442
|
const base = resolve2(root);
|
|
28313
|
-
const hasPackage =
|
|
28443
|
+
const hasPackage = existsSync13(join15(base, "package.json"));
|
|
28314
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.`);
|
|
28315
28445
|
out("");
|
|
28316
28446
|
const t = messages(base);
|
|
@@ -28367,7 +28497,7 @@ var git = (root, args, env = {}) => spawnSync2("git", args, { cwd: root, encodin
|
|
|
28367
28497
|
function clearTree(root) {
|
|
28368
28498
|
for (const name of readdirSync5(root)) {
|
|
28369
28499
|
if (name === ".git" || name === ".deployai") continue;
|
|
28370
|
-
rmSync2(
|
|
28500
|
+
rmSync2(join16(root, name), { recursive: true, force: true });
|
|
28371
28501
|
}
|
|
28372
28502
|
}
|
|
28373
28503
|
async function pullHistory(root, ctx, projectId) {
|
|
@@ -28377,7 +28507,7 @@ async function pullHistory(root, ctx, projectId) {
|
|
|
28377
28507
|
const live = versions.find((v) => v.isLive)?.number ?? Math.max(0, ...versions.filter((v) => v.status === "ready").map((v) => v.number));
|
|
28378
28508
|
const chosen = versions.filter((v) => v.number <= live && v.status !== "failed" && v.status !== "queued").sort((a, b) => a.number - b.number);
|
|
28379
28509
|
if (!chosen.length) throw new CliError(t("pullNoSource"), 1, "not_found");
|
|
28380
|
-
if (!
|
|
28510
|
+
if (!existsSync14(join16(root, ".git")) && git(root, ["init", "-q"]).status !== 0) throw new CliError(t("pullNoGit"), 1, "usage");
|
|
28381
28511
|
for (const v of chosen) {
|
|
28382
28512
|
const gz = await fetchSource(root, ctx, projectId, v.number).catch(() => null);
|
|
28383
28513
|
if (!gz) continue;
|
|
@@ -28428,52 +28558,12 @@ async function requestsOpenCommand(root, ctx, path, open2) {
|
|
|
28428
28558
|
|
|
28429
28559
|
// src/commands/start.ts
|
|
28430
28560
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
28431
|
-
import { existsSync as
|
|
28432
|
-
import { join as
|
|
28433
|
-
|
|
28434
|
-
// src/rules.ts
|
|
28435
|
-
import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync11 } from "fs";
|
|
28436
|
-
import { join as join15 } from "path";
|
|
28437
|
-
var CACHE_FILE = "rules-cache.json";
|
|
28438
|
-
var DAY_MS = 864e5;
|
|
28439
|
-
var WAIT_MS2 = 2e3;
|
|
28440
|
-
var EMPTY = { rules: {}, extra: [] };
|
|
28441
|
-
function cleanRules(v) {
|
|
28442
|
-
const o = v && typeof v === "object" ? v : {};
|
|
28443
|
-
const rules = {};
|
|
28444
|
-
if (o.rules && typeof o.rules === "object") {
|
|
28445
|
-
for (const [k, t] of Object.entries(o.rules)) if (typeof t === "string" && t.trim() && t.length < 2e4) rules[k] = t;
|
|
28446
|
-
}
|
|
28447
|
-
const extra = Array.isArray(o.extra) ? o.extra.filter((t) => typeof t === "string" && t.trim().length > 0 && t.length < 4e3).slice(0, 20) : [];
|
|
28448
|
-
return { rules, extra };
|
|
28449
|
-
}
|
|
28450
|
-
async function serverRules(apiUrl, fetcher = fetch, now = Date.now()) {
|
|
28451
|
-
const file2 = join15(configDir(), CACHE_FILE);
|
|
28452
|
-
let cached2 = null;
|
|
28453
|
-
try {
|
|
28454
|
-
cached2 = readJson(file2);
|
|
28455
|
-
} catch {
|
|
28456
|
-
}
|
|
28457
|
-
if (cached2 && cached2.version === CLI_VERSION && now - cached2.at < DAY_MS) return cleanRules(cached2.data);
|
|
28458
|
-
try {
|
|
28459
|
-
const r = await fetcher(`${apiUrl}/api/cli/rules?cli=${encodeURIComponent(CLI_VERSION)}`, { signal: AbortSignal.timeout(WAIT_MS2) });
|
|
28460
|
-
if (!r.ok) throw new Error(String(r.status));
|
|
28461
|
-
const data = cleanRules(await r.json());
|
|
28462
|
-
try {
|
|
28463
|
-
mkdirSync8(configDir(), { recursive: true });
|
|
28464
|
-
writeFileSync11(file2, JSON.stringify({ at: now, version: CLI_VERSION, data }));
|
|
28465
|
-
} catch {
|
|
28466
|
-
}
|
|
28467
|
-
return data;
|
|
28468
|
-
} catch {
|
|
28469
|
-
return cached2 ? cleanRules(cached2.data) : EMPTY;
|
|
28470
|
-
}
|
|
28471
|
-
}
|
|
28472
|
-
var rule = (r, key, bundled) => r.rules[key] ?? bundled;
|
|
28561
|
+
import { existsSync as existsSync15, writeFileSync as writeFileSync14 } from "fs";
|
|
28562
|
+
import { join as join18, relative as relative3, resolve as resolve3 } from "path";
|
|
28473
28563
|
|
|
28474
28564
|
// src/commands/starter.ts
|
|
28475
|
-
import { writeFileSync as
|
|
28476
|
-
import { join as
|
|
28565
|
+
import { writeFileSync as writeFileSync13 } from "fs";
|
|
28566
|
+
import { join as join17 } from "path";
|
|
28477
28567
|
var esc2 = (s) => s.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
28478
28568
|
var TEXT = {
|
|
28479
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." },
|
|
@@ -28521,8 +28611,8 @@ DeployAI wrote this page so the folder starts as a working site. Build the owner
|
|
|
28521
28611
|
- Delete this README or replace it with notes about the site.
|
|
28522
28612
|
`;
|
|
28523
28613
|
function writeStarter(root, name, lang, stack) {
|
|
28524
|
-
|
|
28525
|
-
|
|
28614
|
+
writeFileSync13(join17(root, "index.html"), page2(name ?? "", lang, stack));
|
|
28615
|
+
writeFileSync13(join17(root, "README.md"), README);
|
|
28526
28616
|
}
|
|
28527
28617
|
|
|
28528
28618
|
// src/commands/start.ts
|
|
@@ -28583,7 +28673,9 @@ async function startCommand(cwd, ctx, id, opts = {}) {
|
|
|
28583
28673
|
const starter = (kind === "new" || kind === "guest") && !sample && empty;
|
|
28584
28674
|
const signedIn = Boolean(choices.projectId && tokenIfOwnApi(ctxNow));
|
|
28585
28675
|
const pullNow = update && empty && signedIn;
|
|
28586
|
-
const
|
|
28676
|
+
const stepOpts = { emptyFolder: kind === "update" && empty && !pullNow, starter, managed: Boolean(choices.migration?.requestId), signedIn, addons: Boolean(choices.runAddons) };
|
|
28677
|
+
const [server, stepTexts] = await Promise.all([serverRules(ctx.apiUrl), serverSteps(ctx.apiUrl, startStepsQuery(kind, stepOpts))]);
|
|
28678
|
+
const steps = withServerSteps(startSteps(kind, stepOpts), stepTexts);
|
|
28587
28679
|
const inClaude = process.env.CLAUDECODE === "1";
|
|
28588
28680
|
if (ctxNow.config.sound === void 0) {
|
|
28589
28681
|
if (inClaude) steps.unshift(ASK_SOUND_TERMINAL_STEP);
|
|
@@ -28594,7 +28686,7 @@ async function startCommand(cwd, ctx, id, opts = {}) {
|
|
|
28594
28686
|
if (sample && !sameSite) {
|
|
28595
28687
|
const written = await downloadSample(ctxNow, sample.key, root);
|
|
28596
28688
|
done.push(t("startDownloaded", { key: sample.key, n: written }));
|
|
28597
|
-
if (
|
|
28689
|
+
if (existsSync15(join18(root, "package.json"))) {
|
|
28598
28690
|
if (opts.install !== false && install(root)) done.push(t("startInstalled"));
|
|
28599
28691
|
else steps.unshift({ cmd: "npm install", say: "Installs the sample's packages." });
|
|
28600
28692
|
}
|
|
@@ -28619,7 +28711,7 @@ async function startCommand(cwd, ctx, id, opts = {}) {
|
|
|
28619
28711
|
const stackText = choices.stack ? stackBlock(choices.stack) : "";
|
|
28620
28712
|
if (choices.brief || stackText) {
|
|
28621
28713
|
ensureDeployaiDir(root);
|
|
28622
|
-
|
|
28714
|
+
writeFileSync14(join18(root, BRIEF_FILE), [choices.brief ? `# The owner's details
|
|
28623
28715
|
|
|
28624
28716
|
${choices.brief}
|
|
28625
28717
|
` : "", stackText].filter(Boolean).join("\n"));
|
|
@@ -28629,7 +28721,7 @@ ${choices.brief}
|
|
|
28629
28721
|
updateProject(root, { stack: choices.stack });
|
|
28630
28722
|
done.push(t("startStack", { stack: stackSummary(choices.stack) }));
|
|
28631
28723
|
}
|
|
28632
|
-
const init = runInit(root);
|
|
28724
|
+
const init = runInit(root, { texts: initTexts(server) });
|
|
28633
28725
|
if (init.created.includes("DEPLOYAI.md") || init.rulesAdded) done.push(t("startRules"));
|
|
28634
28726
|
if (choices.projectId) {
|
|
28635
28727
|
const before = readProject(root);
|
|
@@ -28667,7 +28759,6 @@ ${choices.brief}
|
|
|
28667
28759
|
say("Then, in this order:");
|
|
28668
28760
|
steps.forEach((s, i) => say(`${i + 1}. ${s.cmd ? `Run ${s.cmd}. ` : ""}${s.say}`));
|
|
28669
28761
|
say();
|
|
28670
|
-
const server = await serverRules(ctx.apiUrl);
|
|
28671
28762
|
const lang = langOf(choices.ownerLanguage);
|
|
28672
28763
|
say(rule(server, `runCommands.${lang}`, runCommandsRule(lang)));
|
|
28673
28764
|
say(rule(server, "modelFlag", MODEL_FLAG_RULE));
|
|
@@ -28678,14 +28769,14 @@ ${choices.brief}
|
|
|
28678
28769
|
for (const line of server.extra) say(line);
|
|
28679
28770
|
say(rule(server, "startFail", START_FAIL_LINE));
|
|
28680
28771
|
ensureDeployaiDir(root);
|
|
28681
|
-
|
|
28772
|
+
writeFileSync14(join18(root, START_FILE), `${lines.join("\n")}
|
|
28682
28773
|
`);
|
|
28683
28774
|
}
|
|
28684
28775
|
|
|
28685
28776
|
// src/commands/addon.ts
|
|
28686
|
-
import { dirname as dirname5, join as
|
|
28777
|
+
import { dirname as dirname5, join as join19, resolve as resolve4 } from "path";
|
|
28687
28778
|
import { mkdirSync as mkdirSync9 } from "fs";
|
|
28688
|
-
import { existsSync as
|
|
28779
|
+
import { existsSync as existsSync16, writeFileSync as writeFileSync15 } from "fs";
|
|
28689
28780
|
function linkedProjectId2(root) {
|
|
28690
28781
|
const id = readProject(root)?.projectId;
|
|
28691
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");
|
|
@@ -28742,7 +28833,7 @@ async function addonsRunCommand(root, ctx, opts = {}) {
|
|
|
28742
28833
|
const all = opts.all === true || !opts.oneByOne && readProject(root)?.addonsAll === true;
|
|
28743
28834
|
if (!order && r.picked && !r.agreed && todo.length > 1 && (opts.all || !all)) {
|
|
28744
28835
|
const stamps = readStamps(root);
|
|
28745
|
-
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) }));
|
|
28746
28837
|
addonOrderBrief(items, opts.all ? "all" : opts.oneByOne ? "one-by-one" : null).forEach((line) => out(line));
|
|
28747
28838
|
return;
|
|
28748
28839
|
}
|
|
@@ -28790,19 +28881,19 @@ async function addonBuyCommand(root, ctx, key) {
|
|
|
28790
28881
|
}
|
|
28791
28882
|
function readStamps(root) {
|
|
28792
28883
|
try {
|
|
28793
|
-
return readJson(
|
|
28884
|
+
return readJson(join19(root, ADDON_STAMP_FILE));
|
|
28794
28885
|
} catch {
|
|
28795
28886
|
return {};
|
|
28796
28887
|
}
|
|
28797
28888
|
}
|
|
28798
28889
|
function writeStamps(root, stamps) {
|
|
28799
|
-
const file2 =
|
|
28890
|
+
const file2 = join19(root, ADDON_STAMP_FILE);
|
|
28800
28891
|
mkdirSync9(dirname5(file2), { recursive: true });
|
|
28801
|
-
|
|
28892
|
+
writeFileSync15(file2, JSON.stringify(stamps, null, 2));
|
|
28802
28893
|
}
|
|
28803
28894
|
function printAddon(root, a) {
|
|
28804
28895
|
const stamps = readStamps(root);
|
|
28805
|
-
const trace = addonTrace(a.key, (path) =>
|
|
28896
|
+
const trace = addonTrace(a.key, (path) => existsSync16(join19(root, path)), stamps);
|
|
28806
28897
|
writeStamps(root, { ...stamps, [a.key]: { ...stamps[a.key], runId: a.runId } });
|
|
28807
28898
|
out(`DeployAI add-on ${a.position} of ${a.total}: ${a.name} (${a.key}, run ${a.runId}).`);
|
|
28808
28899
|
const line = addonTraceLine(a.key, a.runId, trace);
|
|
@@ -28861,9 +28952,9 @@ async function addonDoneCommand(root, ctx, runId, opts) {
|
|
|
28861
28952
|
|
|
28862
28953
|
// src/commands/speed.ts
|
|
28863
28954
|
import { spawn as spawn3 } from "child_process";
|
|
28864
|
-
import { mkdtempSync, readFileSync as
|
|
28955
|
+
import { mkdtempSync, readFileSync as readFileSync13, rmSync as rmSync3 } from "fs";
|
|
28865
28956
|
import { tmpdir } from "os";
|
|
28866
|
-
import { join as
|
|
28957
|
+
import { join as join20 } from "path";
|
|
28867
28958
|
var ms = (v) => v >= 1e3 ? `${(v / 1e3).toFixed(1)} s` : `${Math.round(v)} ms`;
|
|
28868
28959
|
var LOCAL_WAIT_MS = 18e4;
|
|
28869
28960
|
function runLighthouse(url2, strategy, browser, file2) {
|
|
@@ -28887,11 +28978,11 @@ function runLighthouse(url2, strategy, browser, file2) {
|
|
|
28887
28978
|
}
|
|
28888
28979
|
async function localSpeed(url2, strategy, run = runLighthouse, browser = findBrowser()) {
|
|
28889
28980
|
if (!browser) return null;
|
|
28890
|
-
const dir = mkdtempSync(
|
|
28981
|
+
const dir = mkdtempSync(join20(tmpdir(), "deployai-speed-"));
|
|
28891
28982
|
try {
|
|
28892
|
-
const file2 =
|
|
28983
|
+
const file2 = join20(dir, "report.json");
|
|
28893
28984
|
await run(url2, strategy, browser, file2);
|
|
28894
|
-
const lighthouseResult = JSON.parse(
|
|
28985
|
+
const lighthouseResult = JSON.parse(readFileSync13(file2, "utf8"));
|
|
28895
28986
|
return lighthouseResult.categories ? mapPsi({ lighthouseResult }, strategy) : null;
|
|
28896
28987
|
} catch {
|
|
28897
28988
|
return null;
|
|
@@ -28955,8 +29046,8 @@ async function speedCommand(ctx, url2, opts, deps = {}) {
|
|
|
28955
29046
|
|
|
28956
29047
|
// src/commands/shot.ts
|
|
28957
29048
|
import { spawn as spawn4 } from "child_process";
|
|
28958
|
-
import { existsSync as
|
|
28959
|
-
import { join as
|
|
29049
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync10 } from "fs";
|
|
29050
|
+
import { join as join21, resolve as resolve5 } from "path";
|
|
28960
29051
|
var SHOT_SIZES = [{ name: "phone", size: "390,844" }, { name: "desktop", size: "1440,900" }];
|
|
28961
29052
|
var PLAYWRIGHT = "playwright@1.56";
|
|
28962
29053
|
var WAIT_MS3 = 18e4;
|
|
@@ -28992,14 +29083,14 @@ async function shotCommand(root, address, opts = {}, run = runNpx) {
|
|
|
28992
29083
|
const browser = opts.webkit ? null : findBrowser();
|
|
28993
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");
|
|
28994
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");
|
|
28995
|
-
const dir = resolve5(root, opts.out ??
|
|
29086
|
+
const dir = resolve5(root, opts.out ?? join21(".deployai", "shots"));
|
|
28996
29087
|
mkdirSync10(dir, { recursive: true });
|
|
28997
29088
|
const saved = [];
|
|
28998
29089
|
for (const s of SHOT_SIZES) {
|
|
28999
|
-
const file2 =
|
|
29090
|
+
const file2 = join21(dir, shotName(url2.toString(), s.name));
|
|
29000
29091
|
const engine = opts.webkit ? ["--browser=webkit"] : [`--channel=${channelFor(browser)}`];
|
|
29001
29092
|
const code = await run(["--yes", PLAYWRIGHT, "screenshot", ...engine, `--viewport-size=${s.size}`, "--full-page", "--wait-for-timeout=1500", url2.toString(), file2]);
|
|
29002
|
-
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");
|
|
29003
29094
|
saved.push(file2);
|
|
29004
29095
|
out(`${s.name.padEnd(8)} ${file2}`);
|
|
29005
29096
|
}
|
|
@@ -29009,10 +29100,10 @@ async function shotCommand(root, address, opts = {}, run = runNpx) {
|
|
|
29009
29100
|
|
|
29010
29101
|
// src/commands/images.ts
|
|
29011
29102
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
29012
|
-
import { existsSync as
|
|
29103
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync11, readdirSync as readdirSync6, statSync as statSync3, writeFileSync as writeFileSync16 } from "fs";
|
|
29013
29104
|
import { createRequire } from "module";
|
|
29014
29105
|
import { homedir as homedir3 } from "os";
|
|
29015
|
-
import { extname, join as
|
|
29106
|
+
import { extname, join as join22, relative as relative4, resolve as resolve6 } from "path";
|
|
29016
29107
|
var PHONE_WIDTH = 640;
|
|
29017
29108
|
var SHARP = "sharp@0.34";
|
|
29018
29109
|
var SKIP_DIRS2 = /* @__PURE__ */ new Set(["node_modules", ".git", ".deployai", "dist", ".astro", ".next"]);
|
|
@@ -29020,14 +29111,14 @@ function imagesIn(dir) {
|
|
|
29020
29111
|
const found = [];
|
|
29021
29112
|
const walk2 = (d) => {
|
|
29022
29113
|
for (const name of readdirSync6(d)) {
|
|
29023
|
-
const p =
|
|
29114
|
+
const p = join22(d, name);
|
|
29024
29115
|
const st = statSync3(p);
|
|
29025
29116
|
if (st.isDirectory()) {
|
|
29026
29117
|
if (!SKIP_DIRS2.has(name)) walk2(p);
|
|
29027
29118
|
} else if (/\.(jpe?g|png)$/i.test(name)) found.push(p);
|
|
29028
29119
|
}
|
|
29029
29120
|
};
|
|
29030
|
-
if (
|
|
29121
|
+
if (existsSync18(dir)) walk2(dir);
|
|
29031
29122
|
return found.sort();
|
|
29032
29123
|
}
|
|
29033
29124
|
function outputsFor(file2, width) {
|
|
@@ -29037,15 +29128,15 @@ function outputsFor(file2, width) {
|
|
|
29037
29128
|
return list;
|
|
29038
29129
|
}
|
|
29039
29130
|
function loadSharp() {
|
|
29040
|
-
const dir =
|
|
29041
|
-
if (!
|
|
29131
|
+
const dir = join22(homedir3(), ".deployai", "tools", "sharp");
|
|
29132
|
+
if (!existsSync18(join22(dir, "node_modules", "sharp"))) {
|
|
29042
29133
|
mkdirSync11(dir, { recursive: true });
|
|
29043
|
-
if (!
|
|
29134
|
+
if (!existsSync18(join22(dir, "package.json"))) writeFileSync16(join22(dir, "package.json"), '{"private":true}');
|
|
29044
29135
|
out("Getting the image tool once (it stays outside the site)...");
|
|
29045
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" });
|
|
29046
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");
|
|
29047
29138
|
}
|
|
29048
|
-
return createRequire(
|
|
29139
|
+
return createRequire(join22(dir, "package.json"))("sharp");
|
|
29049
29140
|
}
|
|
29050
29141
|
async function imagesCommand(root, folder, sharp = loadSharp) {
|
|
29051
29142
|
const dir = resolve6(root, folder ?? "public");
|
|
@@ -29062,7 +29153,7 @@ async function imagesCommand(root, folder, sharp = loadSharp) {
|
|
|
29062
29153
|
const size = statSync3(file2).size;
|
|
29063
29154
|
const meta3 = await make(file2).metadata();
|
|
29064
29155
|
const outputs = outputsFor(file2, meta3.width);
|
|
29065
|
-
if (outputs.every((o) =>
|
|
29156
|
+
if (outputs.every((o) => existsSync18(o.file) && statSync3(o.file).mtimeMs >= statSync3(file2).mtimeMs)) {
|
|
29066
29157
|
skipped++;
|
|
29067
29158
|
continue;
|
|
29068
29159
|
}
|
|
@@ -29081,8 +29172,8 @@ async function imagesCommand(root, folder, sharp = loadSharp) {
|
|
|
29081
29172
|
}
|
|
29082
29173
|
|
|
29083
29174
|
// src/commands/blocks.ts
|
|
29084
|
-
import { createHash as
|
|
29085
|
-
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";
|
|
29086
29177
|
import { dirname as dirname6, resolve as resolve7, sep as sep3 } from "path";
|
|
29087
29178
|
import { gunzipSync as gunzipSync2 } from "zlib";
|
|
29088
29179
|
var BLOCKS = [
|
|
@@ -29092,7 +29183,7 @@ var BLOCKS = [
|
|
|
29092
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" }
|
|
29093
29184
|
];
|
|
29094
29185
|
var MAX_BYTES3 = 5 * 1024 * 1024;
|
|
29095
|
-
var sha = (data) =>
|
|
29186
|
+
var sha = (data) => createHash3("sha256").update(data).digest("hex");
|
|
29096
29187
|
var lockPath = (base, key) => resolve7(base, ".deployai", "blocks", `${key}.lock.json`);
|
|
29097
29188
|
function readLock(base, key) {
|
|
29098
29189
|
try {
|
|
@@ -29136,12 +29227,12 @@ async function blocksCommand(root, ctx, name, opts = {}) {
|
|
|
29136
29227
|
if (e3.type !== "0" && e3.type !== "\0") continue;
|
|
29137
29228
|
const target = resolve7(base, e3.name);
|
|
29138
29229
|
if (target === base || !target.startsWith(base + sep3)) continue;
|
|
29139
|
-
if (
|
|
29140
|
-
const now = sha(
|
|
29230
|
+
if (existsSync19(target)) {
|
|
29231
|
+
const now = sha(readFileSync14(target));
|
|
29141
29232
|
if (now === sha(e3.data)) {
|
|
29142
29233
|
lock[e3.name] = now;
|
|
29143
29234
|
} else if (opts.update && lock[e3.name] === now) {
|
|
29144
|
-
|
|
29235
|
+
writeFileSync17(target, e3.data);
|
|
29145
29236
|
lock[e3.name] = sha(e3.data);
|
|
29146
29237
|
updated.push(e3.name);
|
|
29147
29238
|
} else {
|
|
@@ -29150,12 +29241,12 @@ async function blocksCommand(root, ctx, name, opts = {}) {
|
|
|
29150
29241
|
continue;
|
|
29151
29242
|
}
|
|
29152
29243
|
mkdirSync12(dirname6(target), { recursive: true });
|
|
29153
|
-
|
|
29244
|
+
writeFileSync17(target, e3.data);
|
|
29154
29245
|
lock[e3.name] = sha(e3.data);
|
|
29155
29246
|
written.push(e3.name);
|
|
29156
29247
|
}
|
|
29157
29248
|
mkdirSync12(dirname6(lockPath(base, block.key)), { recursive: true });
|
|
29158
|
-
|
|
29249
|
+
writeFileSync17(lockPath(base, block.key), `${JSON.stringify(lock, null, 2)}
|
|
29159
29250
|
`);
|
|
29160
29251
|
out(`Added the ${block.key} block: ${written.length} files.`);
|
|
29161
29252
|
written.forEach((f) => out(` + ${f}`));
|
|
@@ -29216,10 +29307,10 @@ async function integrationsCommand(ctx, name, opts = {}) {
|
|
|
29216
29307
|
|
|
29217
29308
|
// src/commands/brand.ts
|
|
29218
29309
|
import { spawn as spawn5 } from "child_process";
|
|
29219
|
-
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";
|
|
29220
29311
|
import { createServer } from "http";
|
|
29221
29312
|
import { tmpdir as tmpdir2 } from "os";
|
|
29222
|
-
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";
|
|
29223
29314
|
import { randomBytes } from "crypto";
|
|
29224
29315
|
|
|
29225
29316
|
// src/commands/brand-page.ts
|
|
@@ -29311,7 +29402,7 @@ var WALK_CAP = 4e3;
|
|
|
29311
29402
|
var SKIP_DIRS3 = /* @__PURE__ */ new Set(["node_modules", ".git", ".next", "dist", "build", "out", ".astro", ".output", ".svelte-kit", ".wrangler", ".deployai"]);
|
|
29312
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" };
|
|
29313
29404
|
function webRoot(root) {
|
|
29314
|
-
for (const d of ["public", "static"]) if (
|
|
29405
|
+
for (const d of ["public", "static"]) if (existsSync20(join23(root, d))) return join23(root, d);
|
|
29315
29406
|
return root;
|
|
29316
29407
|
}
|
|
29317
29408
|
function walk(dir, found = []) {
|
|
@@ -29323,7 +29414,7 @@ function walk(dir, found = []) {
|
|
|
29323
29414
|
}
|
|
29324
29415
|
for (const n2 of names) {
|
|
29325
29416
|
if (found.length >= WALK_CAP) break;
|
|
29326
|
-
const p =
|
|
29417
|
+
const p = join23(dir, n2);
|
|
29327
29418
|
let isDir = false;
|
|
29328
29419
|
try {
|
|
29329
29420
|
isDir = statSync4(p).isDirectory();
|
|
@@ -29338,31 +29429,31 @@ function walk(dir, found = []) {
|
|
|
29338
29429
|
}
|
|
29339
29430
|
function existingFavicon(root) {
|
|
29340
29431
|
const web = webRoot(root);
|
|
29341
|
-
for (const f of ["favicon.ico", "favicon.svg", "favicon.png", "icon.svg", "icon.png"]) if (
|
|
29342
|
-
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}`;
|
|
29343
29434
|
for (const f of walk(root).filter((p) => /\.(html|astro|tsx|jsx|vue|svelte)$/.test(p)).slice(0, 400)) {
|
|
29344
29435
|
try {
|
|
29345
|
-
const m =
|
|
29436
|
+
const m = readFileSync15(f, "utf8").match(/<link\b[^>]*\brel=["'](?:shortcut )?icon["'][^>]*>/i);
|
|
29346
29437
|
if (!m) continue;
|
|
29347
29438
|
const href = m[0].match(/\shref=["']([^"']+)/i)?.[1] ?? "";
|
|
29348
|
-
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("/");
|
|
29349
29440
|
} catch {
|
|
29350
29441
|
}
|
|
29351
29442
|
}
|
|
29352
29443
|
return null;
|
|
29353
29444
|
}
|
|
29354
29445
|
function scannedIcons(root) {
|
|
29355
|
-
const base =
|
|
29356
|
-
if (!
|
|
29446
|
+
const base = join23(root, MIGRATION_DIR);
|
|
29447
|
+
if (!existsSync20(base)) return [];
|
|
29357
29448
|
const found = [];
|
|
29358
29449
|
for (const host of readdirSync7(base)) {
|
|
29359
|
-
const dir =
|
|
29450
|
+
const dir = join23(base, host, "icons");
|
|
29360
29451
|
try {
|
|
29361
|
-
const list = readJson(
|
|
29452
|
+
const list = readJson(join23(dir, "icons.json"));
|
|
29362
29453
|
for (const i of list) {
|
|
29363
|
-
const path =
|
|
29364
|
-
if (!
|
|
29365
|
-
const size = imageSize(
|
|
29454
|
+
const path = join23(dir, i.file);
|
|
29455
|
+
if (!existsSync20(path)) continue;
|
|
29456
|
+
const size = imageSize(readFileSync15(path));
|
|
29366
29457
|
found.push({ path, kind: i.kind, big: !size || size.width >= 64 });
|
|
29367
29458
|
}
|
|
29368
29459
|
} catch {
|
|
@@ -29374,7 +29465,7 @@ function findSource(root) {
|
|
|
29374
29465
|
const icons = scannedIcons(root);
|
|
29375
29466
|
const sharp = icons.find((i) => i.kind === "icon" && i.big);
|
|
29376
29467
|
if (sharp) return { path: sharp.path, from: "old-icon" };
|
|
29377
|
-
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));
|
|
29378
29469
|
const logos = dirs.flatMap((d) => walk(d)).filter((p) => looksLikeLogo(relative5(root, p).split(sep4).join("/")));
|
|
29379
29470
|
const logo = logos.find((p) => /\.svg$/i.test(p)) ?? logos[0];
|
|
29380
29471
|
if (logo) return { path: logo, from: "logo" };
|
|
@@ -29388,23 +29479,23 @@ var CODE_EXT2 = /\.(css|scss|sass|less|html|astro|vue|svelte)$/i;
|
|
|
29388
29479
|
var READ_CAP = 300;
|
|
29389
29480
|
function readText2(path) {
|
|
29390
29481
|
try {
|
|
29391
|
-
return
|
|
29482
|
+
return readFileSync15(path, "utf8");
|
|
29392
29483
|
} catch {
|
|
29393
29484
|
return "";
|
|
29394
29485
|
}
|
|
29395
29486
|
}
|
|
29396
29487
|
function scanDirs(root) {
|
|
29397
|
-
const base =
|
|
29488
|
+
const base = join23(root, MIGRATION_DIR);
|
|
29398
29489
|
try {
|
|
29399
|
-
return readdirSync7(base).map((h) =>
|
|
29490
|
+
return readdirSync7(base).map((h) => join23(base, h)).filter((d) => existsSync20(join23(d, "home.html")));
|
|
29400
29491
|
} catch {
|
|
29401
29492
|
return [];
|
|
29402
29493
|
}
|
|
29403
29494
|
}
|
|
29404
29495
|
function homePage(root) {
|
|
29405
|
-
for (const d of scanDirs(root)) return readText2(
|
|
29496
|
+
for (const d of scanDirs(root)) return readText2(join23(d, "home.html"));
|
|
29406
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"]) {
|
|
29407
|
-
const text2 = readText2(
|
|
29498
|
+
const text2 = readText2(join23(root, f));
|
|
29408
29499
|
if (text2) return text2;
|
|
29409
29500
|
}
|
|
29410
29501
|
return "";
|
|
@@ -29415,30 +29506,30 @@ function siteFacts(root, given = {}) {
|
|
|
29415
29506
|
const id = readSiteIdentity(home);
|
|
29416
29507
|
let pkg;
|
|
29417
29508
|
try {
|
|
29418
|
-
pkg = readJson(
|
|
29509
|
+
pkg = readJson(join23(root, "package.json")).name;
|
|
29419
29510
|
} catch {
|
|
29420
29511
|
}
|
|
29421
29512
|
const name = given.name?.trim() || readProject(root)?.name || id.name || (pkg && !pkg.startsWith("@") ? pkg : "") || basename2(root);
|
|
29422
29513
|
if (given.color) return { name, line: given.line ?? id.line ?? "", color: given.color, colorFrom: "given" };
|
|
29423
|
-
const old = scanDirs(root).flatMap((d) => walkAll(
|
|
29514
|
+
const old = scanDirs(root).flatMap((d) => walkAll(join23(d, "styles")).map((f) => ({ text: readText2(f) })));
|
|
29424
29515
|
const fromOld = scanDirs(root).length ? pickBrandColor([{ text: home, themeColor: id.themeColor }, ...old]) : null;
|
|
29425
29516
|
const sources = [{ text: home, themeColor: id.themeColor }];
|
|
29426
|
-
for (const f of ["tailwind.config.js", "tailwind.config.ts", "tailwind.config.mjs", "tailwind.config.cjs"]) sources.push({ text: readText2(
|
|
29427
|
-
const code = ["src", "app", "styles", "css", "public", "static"].flatMap((d) => walk(
|
|
29428
|
-
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));
|
|
29429
29520
|
for (const f of [...plain2, ...code].slice(0, READ_CAP)) sources.push({ text: readText2(f) });
|
|
29430
29521
|
const color = fromOld ?? pickBrandColor(sources);
|
|
29431
29522
|
return { name, line: given.line ?? id.line ?? "", color: color ?? BRAND_DEFAULT_COLOR, colorFrom: color ? "site" : "default" };
|
|
29432
29523
|
}
|
|
29433
29524
|
function writeSiteFile(root, file2, data) {
|
|
29434
|
-
const target =
|
|
29435
|
-
if (
|
|
29436
|
-
const keep =
|
|
29525
|
+
const target = join23(webRoot(root), file2);
|
|
29526
|
+
if (existsSync20(target)) {
|
|
29527
|
+
const keep = join23(root, BRAND_DIR, "originals");
|
|
29437
29528
|
mkdirSync13(keep, { recursive: true });
|
|
29438
|
-
copyFileSync(target,
|
|
29529
|
+
copyFileSync(target, join23(keep, file2));
|
|
29439
29530
|
}
|
|
29440
29531
|
mkdirSync13(dirname7(target), { recursive: true });
|
|
29441
|
-
|
|
29532
|
+
writeFileSync18(target, data);
|
|
29442
29533
|
}
|
|
29443
29534
|
var send = (res, status, body = "", type = "text/plain; charset=utf-8") => {
|
|
29444
29535
|
res.writeHead(status, { "content-type": type, "cache-control": "no-store", "x-content-type-options": "nosniff" });
|
|
@@ -29473,7 +29564,7 @@ function allowed(req, url2, port, token) {
|
|
|
29473
29564
|
return req.headers.host === `127.0.0.1:${port}` && url2.searchParams.get("t") === token;
|
|
29474
29565
|
}
|
|
29475
29566
|
async function headless(browser, url2, width, until, timeoutMs) {
|
|
29476
|
-
const profile = mkdtempSync2(
|
|
29567
|
+
const profile = mkdtempSync2(join23(tmpdir2(), "deployai-brand-"));
|
|
29477
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 });
|
|
29478
29569
|
child.on("error", () => {
|
|
29479
29570
|
});
|
|
@@ -29573,7 +29664,7 @@ async function drawInBrowser(o, browser) {
|
|
|
29573
29664
|
}
|
|
29574
29665
|
}
|
|
29575
29666
|
function sourceBytes(path) {
|
|
29576
|
-
return { bytes:
|
|
29667
|
+
return { bytes: readFileSync15(path), type: TYPES[extname2(path).toLowerCase()] ?? "application/octet-stream" };
|
|
29577
29668
|
}
|
|
29578
29669
|
function report(root, r) {
|
|
29579
29670
|
const where = relative5(root, webRoot(root)).split(sep4).join("/") || "the site root";
|
|
@@ -29591,7 +29682,7 @@ function plainIcon(root, source, name, color) {
|
|
|
29591
29682
|
const ext = extname2(source.path).toLowerCase();
|
|
29592
29683
|
if (ext === ".ico" || ext === ".svg" || ext === ".png") {
|
|
29593
29684
|
const file2 = `favicon${ext}`;
|
|
29594
|
-
writeSiteFile(root, file2,
|
|
29685
|
+
writeSiteFile(root, file2, readFileSync15(source.path));
|
|
29595
29686
|
return [file2];
|
|
29596
29687
|
}
|
|
29597
29688
|
}
|
|
@@ -29609,7 +29700,7 @@ function printStatus2(root, files) {
|
|
|
29609
29700
|
const web = webRoot(root);
|
|
29610
29701
|
const icon = existingFavicon(root);
|
|
29611
29702
|
out(icon ? `Icon: ${icon}` : "Icon: missing. Run: npx deployai@latest brand favicon");
|
|
29612
|
-
const missing = files.filter((f) => f !== "favicon.svg" && !
|
|
29703
|
+
const missing = files.filter((f) => f !== "favicon.svg" && !existsSync20(join23(web, f)));
|
|
29613
29704
|
if (files.length) out(missing.length ? `Missing from the full set: ${missing.join(", ")}` : "The full set is there.");
|
|
29614
29705
|
}
|
|
29615
29706
|
function printFacts(f, picture2) {
|
|
@@ -29628,7 +29719,7 @@ function withLogoColor(facts, source) {
|
|
|
29628
29719
|
}
|
|
29629
29720
|
function pickSource(root, from) {
|
|
29630
29721
|
const source = from ? { path: from, from: "file" } : findSource(root);
|
|
29631
|
-
if (source.path && !
|
|
29722
|
+
if (source.path && !existsSync20(source.path)) throw new CliError(`No such file: ${source.path}`, 1, "usage");
|
|
29632
29723
|
return source;
|
|
29633
29724
|
}
|
|
29634
29725
|
async function brandFaviconCommand(root, opts) {
|
|
@@ -29656,7 +29747,7 @@ async function brandFaviconCommand(root, opts) {
|
|
|
29656
29747
|
}
|
|
29657
29748
|
function iconsToDraw(root, force) {
|
|
29658
29749
|
const icon = force ? null : existingFavicon(root);
|
|
29659
|
-
const keepOg = !force &&
|
|
29750
|
+
const keepOg = !force && existsSync20(join23(webRoot(root), "og-image.png"));
|
|
29660
29751
|
return {
|
|
29661
29752
|
targets: BRAND_TARGETS.filter((t) => !(keepOg && t.file === "og-image.png") && !(icon && t.icoOnly)),
|
|
29662
29753
|
keepIcon: Boolean(icon),
|
|
@@ -29712,7 +29803,7 @@ async function measurePage(browser, address, width, scripts) {
|
|
|
29712
29803
|
}
|
|
29713
29804
|
}
|
|
29714
29805
|
function imageFiles(root) {
|
|
29715
|
-
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);
|
|
29716
29807
|
const files = dirs.flatMap((d) => walkAll(d));
|
|
29717
29808
|
if (webRoot(root) === root) files.push(...walk(root));
|
|
29718
29809
|
return [...new Set(files)].filter((p) => IMAGE_EXT.test(p) && !p.split(sep4).includes("icons") && !BRAND_FILES.includes(basename2(p)));
|
|
@@ -29728,7 +29819,7 @@ function walkAll(dir) {
|
|
|
29728
29819
|
}
|
|
29729
29820
|
for (const n2 of names) {
|
|
29730
29821
|
if (found.length >= WALK_CAP) return;
|
|
29731
|
-
const p =
|
|
29822
|
+
const p = join23(d, n2);
|
|
29732
29823
|
try {
|
|
29733
29824
|
if (statSync4(p).isDirectory()) {
|
|
29734
29825
|
if (!SKIP_DIRS3.has(n2) || n2 === ".deployai") go(p);
|
|
@@ -29747,7 +29838,7 @@ function judgeFiles(root) {
|
|
|
29747
29838
|
for (const f of files) {
|
|
29748
29839
|
let bytes;
|
|
29749
29840
|
try {
|
|
29750
|
-
bytes =
|
|
29841
|
+
bytes = readFileSync15(f);
|
|
29751
29842
|
} catch {
|
|
29752
29843
|
continue;
|
|
29753
29844
|
}
|
|
@@ -29797,10 +29888,10 @@ async function brandImagesCommand(root, urls, opts) {
|
|
|
29797
29888
|
if (verdict !== "ok") onPages.push({ where: m.src, width: m.width, height: m.height, shownWidth: m.shownWidth, verdict, alt: m.alt });
|
|
29798
29889
|
}
|
|
29799
29890
|
const weak = [...onPages, ...findings];
|
|
29800
|
-
mkdirSync13(
|
|
29891
|
+
mkdirSync13(join23(root, BRAND_DIR), { recursive: true });
|
|
29801
29892
|
const file2 = `${BRAND_DIR}/images.json`;
|
|
29802
29893
|
const data = { measuredAt: (/* @__PURE__ */ new Date()).toISOString(), pages: urls, unmeasured, filesChecked: total, imagesMeasured: shown.size, weak };
|
|
29803
|
-
|
|
29894
|
+
writeFileSync18(join23(root, file2), `${JSON.stringify(data, null, 2)}
|
|
29804
29895
|
`);
|
|
29805
29896
|
if (opts.json) {
|
|
29806
29897
|
out(JSON.stringify(data));
|
|
@@ -29865,7 +29956,12 @@ function buildProgram() {
|
|
|
29865
29956
|
const g = (cmd) => cmd.optsWithGlobals();
|
|
29866
29957
|
const root = (cmd) => resolve8(g(cmd).dir ?? process.cwd());
|
|
29867
29958
|
const ctx = (cmd) => apiContext(g(cmd).api);
|
|
29868
|
-
program.
|
|
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
|
+
});
|
|
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));
|
|
29869
29965
|
program.command("inspect").description("show framework, package manager, language, database, storage").option("--json", "machine readable output").action((opts, cmd) => inspectCommand(root(cmd), opts));
|
|
29870
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) => {
|
|
29871
29967
|
const a = await runCheck(root(cmd), ctx(cmd), opts);
|
|
@@ -30017,8 +30113,8 @@ async function main(argv = process.argv) {
|
|
|
30017
30113
|
|
|
30018
30114
|
// src/update.ts
|
|
30019
30115
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
30020
|
-
import { existsSync as
|
|
30021
|
-
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";
|
|
30022
30118
|
var CHECK_EVERY_MS = 60 * 60 * 1e3;
|
|
30023
30119
|
var ASK_NPM_MS = 1500;
|
|
30024
30120
|
var GET_VERSION_MS = 12e4;
|
|
@@ -30056,11 +30152,11 @@ function updateAllowed(env, args) {
|
|
|
30056
30152
|
return resolveApiUrl(void 0, loadConfig()) === API_BASE_DEFAULT.replace(/\/+$/, "");
|
|
30057
30153
|
}
|
|
30058
30154
|
function statePath() {
|
|
30059
|
-
return
|
|
30155
|
+
return join25(configDir(), "update-check.json");
|
|
30060
30156
|
}
|
|
30061
30157
|
function readState() {
|
|
30062
30158
|
try {
|
|
30063
|
-
const data = JSON.parse(
|
|
30159
|
+
const data = JSON.parse(readFileSync16(statePath(), "utf8"));
|
|
30064
30160
|
return data && typeof data === "object" ? data : {};
|
|
30065
30161
|
} catch {
|
|
30066
30162
|
return {};
|
|
@@ -30069,7 +30165,7 @@ function readState() {
|
|
|
30069
30165
|
function writeState(state) {
|
|
30070
30166
|
try {
|
|
30071
30167
|
mkdirSync14(configDir(), { recursive: true });
|
|
30072
|
-
|
|
30168
|
+
writeFileSync19(statePath(), JSON.stringify(state) + "\n");
|
|
30073
30169
|
} catch {
|
|
30074
30170
|
}
|
|
30075
30171
|
}
|
|
@@ -30085,20 +30181,20 @@ async function askNpmLatest(env) {
|
|
|
30085
30181
|
}
|
|
30086
30182
|
}
|
|
30087
30183
|
function versionEntry(version2) {
|
|
30088
|
-
return
|
|
30184
|
+
return join25(configDir(), "cli", version2, "node_modules", "deployai", "dist", "index.js");
|
|
30089
30185
|
}
|
|
30090
30186
|
function getVersion(version2, env) {
|
|
30091
30187
|
process.stderr.write(`Getting the newest DeployAI CLI, version ${version2}.
|
|
30092
30188
|
`);
|
|
30093
|
-
const root =
|
|
30094
|
-
const dir =
|
|
30189
|
+
const root = join25(configDir(), "cli");
|
|
30190
|
+
const dir = join25(root, version2);
|
|
30095
30191
|
mkdirSync14(dir, { recursive: true });
|
|
30096
|
-
|
|
30192
|
+
writeFileSync19(join25(dir, "package.json"), '{"private":true}\n');
|
|
30097
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 });
|
|
30098
30194
|
if (installed.status !== 0) return false;
|
|
30099
30195
|
const ran = spawnSync5(process.execPath, [versionEntry(version2), "--version"], { env: { ...env, DEPLOYAI_NO_UPDATE: "1" }, encoding: "utf8", timeout: GET_VERSION_MS });
|
|
30100
30196
|
if (ran.status !== 0 || ran.stdout.trim() !== version2) return false;
|
|
30101
|
-
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 });
|
|
30102
30198
|
return true;
|
|
30103
30199
|
}
|
|
30104
30200
|
function runVersion(version2, args, env = process.env) {
|
|
@@ -30117,7 +30213,7 @@ async function versionToRun(current, args, env = process.env, deps = {}) {
|
|
|
30117
30213
|
}
|
|
30118
30214
|
const latest = state.latest;
|
|
30119
30215
|
if (!latest || !PLAIN_VERSION.test(latest) || compareVersions(latest, current) <= 0) return null;
|
|
30120
|
-
if (state.ready === latest &&
|
|
30216
|
+
if (state.ready === latest && existsSync22(versionEntry(latest))) return latest;
|
|
30121
30217
|
if (now - (state.triedAt ?? 0) < CHECK_EVERY_MS) return null;
|
|
30122
30218
|
state.triedAt = now;
|
|
30123
30219
|
if (get2(latest, env)) state.ready = latest;
|