deployai 0.1.0-beta.31 → 0.1.0-beta.33
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 +304 -260
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22332,7 +22332,7 @@ var MIGRATE_STEPS = [
|
|
|
22332
22332
|
FAVICON,
|
|
22333
22333
|
{ ...CHECK },
|
|
22334
22334
|
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." },
|
|
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, 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
22336
|
LOOK_DEPLOY,
|
|
22337
22337
|
{ 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
22338
|
DASHBOARD,
|
|
@@ -22390,6 +22390,12 @@ var PULL = { cmd: "npx deployai@latest pull", say: "This folder was empty, so it
|
|
|
22390
22390
|
function startSteps(kind, opts = {}) {
|
|
22391
22391
|
return opts.signedIn ? stepsOf(kind, opts).filter((s) => s !== LOGIN) : stepsOf(kind, opts);
|
|
22392
22392
|
}
|
|
22393
|
+
function withServerSteps(bundled, server) {
|
|
22394
|
+
if (!Array.isArray(server) || server.length !== bundled.length) return bundled;
|
|
22395
|
+
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);
|
|
22396
|
+
return ok ? bundled.map((b, i) => ({ ...b, say: server[i].say })) : bundled;
|
|
22397
|
+
}
|
|
22398
|
+
var startStepsQuery = (kind, opts) => `kind=${kind}&o=${["emptyFolder", "starter", "managed", "signedIn", "addons"].filter((k) => opts[k]).join(",")}`;
|
|
22393
22399
|
function stepsOf(kind, opts) {
|
|
22394
22400
|
switch (kind) {
|
|
22395
22401
|
case "new":
|
|
@@ -23262,6 +23268,96 @@ var KEEP_DATA_RULES = [
|
|
|
23262
23268
|
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
23269
|
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
23270
|
|
|
23271
|
+
// ../shared/src/deployai-md.ts
|
|
23272
|
+
var DEPLOYAI_MD = `# DeployAI rules
|
|
23273
|
+
|
|
23274
|
+
This project is published with DeployAI.
|
|
23275
|
+
|
|
23276
|
+
${FOLDER_READY_RULE}
|
|
23277
|
+
|
|
23278
|
+
Always explain to the owner in simple words, in the language they write to you in. The owner may not read English.
|
|
23279
|
+
|
|
23280
|
+
${START_FAIL_LINE}
|
|
23281
|
+
|
|
23282
|
+
${OWNER_TEXT_RULE}
|
|
23283
|
+
|
|
23284
|
+
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".
|
|
23285
|
+
|
|
23286
|
+
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.
|
|
23287
|
+
|
|
23288
|
+
## Build with
|
|
23289
|
+
|
|
23290
|
+
${BUILD_WITH.map((l) => `- ${l}`).join("\n")}
|
|
23291
|
+
|
|
23292
|
+
Only when this folder has no site yet and the owner asks to start from working code: npx deployai@latest samples
|
|
23293
|
+
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
|
|
23294
|
+
|
|
23295
|
+
## Do not add
|
|
23296
|
+
|
|
23297
|
+
- local file system writes
|
|
23298
|
+
- database drivers DeployAI does not support (see: npx deployai@latest inspect)
|
|
23299
|
+
- long-running processes or background servers
|
|
23300
|
+
- Durable Objects (not supported yet; keep state in D1)
|
|
23301
|
+
- native binary modules
|
|
23302
|
+
- DeployAI or any cloud credentials in source code
|
|
23303
|
+
|
|
23304
|
+
## Do not run
|
|
23305
|
+
|
|
23306
|
+
- 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
|
|
23307
|
+
|
|
23308
|
+
## Keep existing data
|
|
23309
|
+
|
|
23310
|
+
${KEEP_DATA_RULES.join("\n")}
|
|
23311
|
+
|
|
23312
|
+
## Running DeployAI commands
|
|
23313
|
+
|
|
23314
|
+
${runCommandsRule()}
|
|
23315
|
+
|
|
23316
|
+
## Asking the owner
|
|
23317
|
+
|
|
23318
|
+
${ASK_OWNER_RULE}
|
|
23319
|
+
|
|
23320
|
+
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.
|
|
23321
|
+
|
|
23322
|
+
## A site's first version
|
|
23323
|
+
|
|
23324
|
+
${FIRST_SITE_RULE}
|
|
23325
|
+
|
|
23326
|
+
## When to deploy
|
|
23327
|
+
|
|
23328
|
+
${DEPLOY_ASK_RULE}
|
|
23329
|
+
|
|
23330
|
+
## When DeployAI gets in your way
|
|
23331
|
+
|
|
23332
|
+
${AGENT_FEEDBACK_RULES.join("\n\n")}
|
|
23333
|
+
|
|
23334
|
+
## Check
|
|
23335
|
+
|
|
23336
|
+
Before adding a dependency or a new server feature, run: npx deployai@latest check
|
|
23337
|
+
Ask the owner before removing any existing functionality.
|
|
23338
|
+
|
|
23339
|
+
Files:
|
|
23340
|
+
- .deployai/project.json: project id and settings (safe to commit)
|
|
23341
|
+
- .deployai/last-check.json: latest check result (not committed)
|
|
23342
|
+
`;
|
|
23343
|
+
var DEPLOYAI_LATER_RULES = [
|
|
23344
|
+
{ has: "iPhone:", text: IPHONE_RULE },
|
|
23345
|
+
{ has: "set up and ready", text: FOLDER_READY_RULE },
|
|
23346
|
+
{ has: "one or two short sentences", text: START_FAIL_LINE },
|
|
23347
|
+
{ has: "direction marks", text: OWNER_TEXT_RULE },
|
|
23348
|
+
{ has: "deployai@latest feedback", text: AGENT_FEEDBACK_RULES.join(" ") },
|
|
23349
|
+
{ has: "never been live", text: FIRST_SITE_RULE }
|
|
23350
|
+
];
|
|
23351
|
+
function parseLaterRules(json2) {
|
|
23352
|
+
try {
|
|
23353
|
+
const v = JSON.parse(json2 ?? "");
|
|
23354
|
+
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) : [];
|
|
23355
|
+
return list.length ? list.map((r) => ({ has: r.has, text: r.text })) : DEPLOYAI_LATER_RULES;
|
|
23356
|
+
} catch {
|
|
23357
|
+
return DEPLOYAI_LATER_RULES;
|
|
23358
|
+
}
|
|
23359
|
+
}
|
|
23360
|
+
|
|
23265
23361
|
// ../shared/src/stack.ts
|
|
23266
23362
|
var SITE_LANG_INFO = {
|
|
23267
23363
|
he: { name: "Hebrew", dir: "rtl", font: "Heebo" },
|
|
@@ -24737,7 +24833,7 @@ function messages(root) {
|
|
|
24737
24833
|
}
|
|
24738
24834
|
|
|
24739
24835
|
// src/version.ts
|
|
24740
|
-
var CLI_VERSION = "0.1.0-beta.
|
|
24836
|
+
var CLI_VERSION = "0.1.0-beta.33";
|
|
24741
24837
|
|
|
24742
24838
|
// src/api.ts
|
|
24743
24839
|
function apiContext(apiFlag) {
|
|
@@ -25046,8 +25142,8 @@ async function feedbackCommand(root, ctx, opts) {
|
|
|
25046
25142
|
}
|
|
25047
25143
|
|
|
25048
25144
|
// src/commands/init.ts
|
|
25049
|
-
import { appendFileSync, existsSync as existsSync5, readFileSync as readFileSync6, writeFileSync as
|
|
25050
|
-
import { join as
|
|
25145
|
+
import { appendFileSync, existsSync as existsSync5, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
|
|
25146
|
+
import { join as join6 } from "path";
|
|
25051
25147
|
|
|
25052
25148
|
// src/analyze.ts
|
|
25053
25149
|
import { execFileSync } from "child_process";
|
|
@@ -25693,90 +25789,62 @@ function groupFindings(findings) {
|
|
|
25693
25789
|
return [...groups.values()];
|
|
25694
25790
|
}
|
|
25695
25791
|
|
|
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.
|
|
25792
|
+
// src/rules.ts
|
|
25793
|
+
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
25794
|
+
import { join as join5 } from "path";
|
|
25795
|
+
var CACHE_FILE = "rules-cache.json";
|
|
25796
|
+
var DAY_MS = 864e5;
|
|
25797
|
+
var WAIT_MS = 2e3;
|
|
25798
|
+
var EMPTY = { rules: {}, extra: [] };
|
|
25799
|
+
function cleanRules(v) {
|
|
25800
|
+
const o = v && typeof v === "object" ? v : {};
|
|
25801
|
+
const rules = {};
|
|
25802
|
+
if (o.rules && typeof o.rules === "object") {
|
|
25803
|
+
for (const [k, t] of Object.entries(o.rules)) if (typeof t === "string" && t.trim() && t.length < 2e4) rules[k] = t;
|
|
25804
|
+
}
|
|
25805
|
+
const extra = Array.isArray(o.extra) ? o.extra.filter((t) => typeof t === "string" && t.trim().length > 0 && t.length < 4e3).slice(0, 20) : [];
|
|
25806
|
+
return { rules, extra };
|
|
25807
|
+
}
|
|
25808
|
+
async function serverRules(apiUrl, fetcher = fetch, now = Date.now()) {
|
|
25809
|
+
const file2 = join5(configDir(), CACHE_FILE);
|
|
25810
|
+
let cached2 = null;
|
|
25811
|
+
try {
|
|
25812
|
+
cached2 = readJson(file2);
|
|
25813
|
+
} catch {
|
|
25814
|
+
}
|
|
25815
|
+
if (cached2 && cached2.version === CLI_VERSION && now - cached2.at < DAY_MS) return cleanRules(cached2.data);
|
|
25816
|
+
try {
|
|
25817
|
+
const r = await fetcher(`${apiUrl}/api/cli/rules?cli=${encodeURIComponent(CLI_VERSION)}`, { signal: AbortSignal.timeout(WAIT_MS) });
|
|
25818
|
+
if (!r.ok) throw new Error(String(r.status));
|
|
25819
|
+
const data = cleanRules(await r.json());
|
|
25820
|
+
try {
|
|
25821
|
+
mkdirSync3(configDir(), { recursive: true });
|
|
25822
|
+
writeFileSync3(file2, JSON.stringify({ at: now, version: CLI_VERSION, data }));
|
|
25823
|
+
} catch {
|
|
25824
|
+
}
|
|
25825
|
+
return data;
|
|
25826
|
+
} catch {
|
|
25827
|
+
return cached2 ? cleanRules(cached2.data) : EMPTY;
|
|
25828
|
+
}
|
|
25829
|
+
}
|
|
25830
|
+
var rule = (r, key, bundled) => r.rules[key] ?? bundled;
|
|
25831
|
+
function initTexts(r) {
|
|
25832
|
+
return { md: rule(r, "deployaiMd", DEPLOYAI_MD), later: parseLaterRules(r.rules.laterRules) };
|
|
25833
|
+
}
|
|
25834
|
+
async function serverSteps(apiUrl, query, fetcher = fetch) {
|
|
25835
|
+
try {
|
|
25836
|
+
const r = await fetcher(`${apiUrl}/api/cli/steps?${query}&cli=${encodeURIComponent(CLI_VERSION)}`, { signal: AbortSignal.timeout(WAIT_MS) });
|
|
25837
|
+
return r.ok ? (await r.json()).steps : null;
|
|
25838
|
+
} catch {
|
|
25839
|
+
return null;
|
|
25840
|
+
}
|
|
25841
|
+
}
|
|
25763
25842
|
|
|
25764
|
-
|
|
25765
|
-
- .deployai/project.json: project id and settings (safe to commit)
|
|
25766
|
-
- .deployai/last-check.json: latest check result (not committed)
|
|
25767
|
-
`;
|
|
25843
|
+
// src/commands/init.ts
|
|
25768
25844
|
var AGENT_FILES = ["AGENTS.md", "CLAUDE.md"];
|
|
25769
|
-
|
|
25770
|
-
{ has: "iPhone:", text: IPHONE_RULE },
|
|
25771
|
-
{ has: "set up and ready", text: FOLDER_READY_RULE },
|
|
25772
|
-
{ has: "one or two short sentences", text: START_FAIL_LINE },
|
|
25773
|
-
{ has: "direction marks", text: OWNER_TEXT_RULE },
|
|
25774
|
-
{ has: "deployai@latest feedback", text: AGENT_FEEDBACK_RULES.join(" ") },
|
|
25775
|
-
{ has: "never been live", text: FIRST_SITE_RULE }
|
|
25776
|
-
];
|
|
25777
|
-
function addMissingRules(md) {
|
|
25845
|
+
function addMissingRules(md, later = DEPLOYAI_LATER_RULES) {
|
|
25778
25846
|
const text2 = readFileSync6(md, "utf8");
|
|
25779
|
-
const missing =
|
|
25847
|
+
const missing = later.filter((r) => !text2.includes(r.has));
|
|
25780
25848
|
if (!missing.length) return false;
|
|
25781
25849
|
const eol = text2.includes("\r\n") ? "\r\n" : "\n";
|
|
25782
25850
|
const gap = text2.endsWith("\n") ? eol : eol + eol;
|
|
@@ -25787,21 +25855,21 @@ function runInit(root, opts = {}) {
|
|
|
25787
25855
|
const created = [];
|
|
25788
25856
|
const kept = [];
|
|
25789
25857
|
const updated = [];
|
|
25790
|
-
const md =
|
|
25858
|
+
const md = join6(root, "DEPLOYAI.md");
|
|
25791
25859
|
let rulesAdded = false;
|
|
25792
25860
|
if (existsSync5(md) && !opts.force) {
|
|
25793
25861
|
kept.push("DEPLOYAI.md");
|
|
25794
|
-
rulesAdded = addMissingRules(md);
|
|
25862
|
+
rulesAdded = addMissingRules(md, opts.texts?.later);
|
|
25795
25863
|
} else {
|
|
25796
|
-
|
|
25864
|
+
writeFileSync4(md, opts.texts?.md ?? DEPLOYAI_MD);
|
|
25797
25865
|
created.push("DEPLOYAI.md");
|
|
25798
25866
|
}
|
|
25799
25867
|
if (opts.agentFiles !== false) {
|
|
25800
25868
|
for (const name of AGENT_FILES) {
|
|
25801
|
-
const file2 =
|
|
25869
|
+
const file2 = join6(root, name);
|
|
25802
25870
|
const text2 = existsSync5(file2) ? readFileSync6(file2, "utf8") : null;
|
|
25803
25871
|
if (text2 === null) {
|
|
25804
|
-
|
|
25872
|
+
writeFileSync4(file2, `${AGENT_POINTER}
|
|
25805
25873
|
`);
|
|
25806
25874
|
created.push(name);
|
|
25807
25875
|
} else if (text2.includes("DEPLOYAI.md")) {
|
|
@@ -25823,11 +25891,11 @@ function runInit(root, opts = {}) {
|
|
|
25823
25891
|
writeProject(root, { projectId: null, framework, createdAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
25824
25892
|
created.push(".deployai/project.json");
|
|
25825
25893
|
}
|
|
25826
|
-
const hasCode = existsSync5(
|
|
25894
|
+
const hasCode = existsSync5(join6(root, "package.json")) || framework !== "unknown";
|
|
25827
25895
|
return { rulesAdded, created, kept, updated, hasCode };
|
|
25828
25896
|
}
|
|
25829
|
-
function initCommand(root, opts) {
|
|
25830
|
-
const res = runInit(root, opts);
|
|
25897
|
+
async function initCommand(root, opts, apiUrl) {
|
|
25898
|
+
const res = runInit(root, { ...opts, texts: apiUrl ? initTexts(await serverRules(apiUrl)) : void 0 });
|
|
25831
25899
|
const project = readProject(root);
|
|
25832
25900
|
out("DeployAI init");
|
|
25833
25901
|
out();
|
|
@@ -25852,8 +25920,8 @@ function initCommand(root, opts) {
|
|
|
25852
25920
|
}
|
|
25853
25921
|
|
|
25854
25922
|
// src/commands/check.ts
|
|
25855
|
-
import { existsSync as existsSync7, writeFileSync as
|
|
25856
|
-
import { join as
|
|
25923
|
+
import { existsSync as existsSync7, writeFileSync as writeFileSync5 } from "fs";
|
|
25924
|
+
import { join as join8 } from "path";
|
|
25857
25925
|
|
|
25858
25926
|
// src/prompt.ts
|
|
25859
25927
|
var PROMPT_RULES = [
|
|
@@ -25923,7 +25991,7 @@ function buildPrompt(analysis) {
|
|
|
25923
25991
|
// src/system.ts
|
|
25924
25992
|
import { spawn, spawnSync } from "child_process";
|
|
25925
25993
|
import { existsSync as existsSync6 } from "fs";
|
|
25926
|
-
import { join as
|
|
25994
|
+
import { join as join7 } from "path";
|
|
25927
25995
|
function copyToClipboard(text2) {
|
|
25928
25996
|
if (process.env.DEPLOYAI_NO_CLIPBOARD) return false;
|
|
25929
25997
|
const candidates = process.platform === "win32" ? [["clip", []]] : process.platform === "darwin" ? [["pbcopy", []]] : [
|
|
@@ -25944,7 +26012,7 @@ function findBrowser() {
|
|
|
25944
26012
|
if (process.env.DEPLOYAI_NO_BROWSER) return null;
|
|
25945
26013
|
const set2 = process.env.CHROME_PATH;
|
|
25946
26014
|
if (set2 && existsSync6(set2)) return set2;
|
|
25947
|
-
const places = process.platform === "win32" ? [process.env.PROGRAMFILES, process.env["PROGRAMFILES(X86)"], process.env.LOCALAPPDATA].flatMap((d) => d ? [
|
|
26015
|
+
const places = process.platform === "win32" ? [process.env.PROGRAMFILES, process.env["PROGRAMFILES(X86)"], process.env.LOCALAPPDATA].flatMap((d) => d ? [join7(d, "Google/Chrome/Application/chrome.exe"), join7(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"];
|
|
25948
26016
|
return places.find((p) => existsSync6(p)) ?? null;
|
|
25949
26017
|
}
|
|
25950
26018
|
function openBrowser(url2) {
|
|
@@ -26045,7 +26113,7 @@ async function runCheck(root, ctx, opts = {}) {
|
|
|
26045
26113
|
const json2 = checkJson(a, prompt);
|
|
26046
26114
|
try {
|
|
26047
26115
|
ensureDeployaiDir(root);
|
|
26048
|
-
|
|
26116
|
+
writeFileSync5(lastCheckFile(root), JSON.stringify(json2, null, 2) + "\n");
|
|
26049
26117
|
} catch {
|
|
26050
26118
|
}
|
|
26051
26119
|
const empty = a.findings.length > 0 && a.findings.every((f) => f.code === "no_files");
|
|
@@ -26055,7 +26123,7 @@ async function runCheck(root, ctx, opts = {}) {
|
|
|
26055
26123
|
out("DeployAI check");
|
|
26056
26124
|
out();
|
|
26057
26125
|
out(messages(root)("emptyFolder"));
|
|
26058
|
-
if (!existsSync7(
|
|
26126
|
+
if (!existsSync7(join8(root, "DEPLOYAI.md"))) out(messages(root)("initHint"));
|
|
26059
26127
|
} else if (opts.print !== false) {
|
|
26060
26128
|
printCheck(a);
|
|
26061
26129
|
out();
|
|
@@ -26082,7 +26150,7 @@ async function runCheck(root, ctx, opts = {}) {
|
|
|
26082
26150
|
} else {
|
|
26083
26151
|
out(t("runDeploy"));
|
|
26084
26152
|
}
|
|
26085
|
-
if (!existsSync7(
|
|
26153
|
+
if (!existsSync7(join8(root, "DEPLOYAI.md"))) out(t("initHint"));
|
|
26086
26154
|
}
|
|
26087
26155
|
await telemetry;
|
|
26088
26156
|
return a;
|
|
@@ -26225,8 +26293,8 @@ function telemetryCommand(action) {
|
|
|
26225
26293
|
}
|
|
26226
26294
|
|
|
26227
26295
|
// src/commands/allow.ts
|
|
26228
|
-
import { existsSync as existsSync8, mkdirSync as
|
|
26229
|
-
import { dirname, join as
|
|
26296
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync4, readFileSync as readFileSync7, writeFileSync as writeFileSync6, appendFileSync as appendFileSync2 } from "fs";
|
|
26297
|
+
import { dirname, join as join9 } from "path";
|
|
26230
26298
|
var ALLOW_TOOLS = ["claude-code", "cursor", "copilot", "codex", "antigravity", "grok"];
|
|
26231
26299
|
var CLAUDE_RULE = "Bash(npx deployai@latest *)";
|
|
26232
26300
|
var CURSOR_LINE = "Running npx deployai@latest commands is allowed without approval.";
|
|
@@ -26245,8 +26313,8 @@ function readObject(file2) {
|
|
|
26245
26313
|
}
|
|
26246
26314
|
}
|
|
26247
26315
|
function writeObject(file2, value) {
|
|
26248
|
-
|
|
26249
|
-
|
|
26316
|
+
mkdirSync4(dirname(file2), { recursive: true });
|
|
26317
|
+
writeFileSync6(file2, `${JSON.stringify(value, null, 2)}
|
|
26250
26318
|
`);
|
|
26251
26319
|
}
|
|
26252
26320
|
function addTo(obj, key, list, value) {
|
|
@@ -26258,8 +26326,8 @@ function addTo(obj, key, list, value) {
|
|
|
26258
26326
|
return true;
|
|
26259
26327
|
}
|
|
26260
26328
|
function ignoreInGit(root, path) {
|
|
26261
|
-
if (!existsSync8(
|
|
26262
|
-
const gi =
|
|
26329
|
+
if (!existsSync8(join9(root, ".git"))) return;
|
|
26330
|
+
const gi = join9(root, ".gitignore");
|
|
26263
26331
|
const text2 = existsSync8(gi) ? readFileSync7(gi, "utf8") : "";
|
|
26264
26332
|
if (text2.split(/\r?\n/).some((l) => l.trim() === path)) return;
|
|
26265
26333
|
appendFileSync2(gi, `${text2 && !text2.endsWith("\n") ? "\n" : ""}${path}
|
|
@@ -26283,7 +26351,7 @@ function allowCommand(tool) {
|
|
|
26283
26351
|
if (picked === "claude-code" || picked === "grok") {
|
|
26284
26352
|
const grok = picked === "grok";
|
|
26285
26353
|
const rel = ".claude/settings.local.json";
|
|
26286
|
-
const file2 =
|
|
26354
|
+
const file2 = join9(root, rel);
|
|
26287
26355
|
const obj = readObject(file2);
|
|
26288
26356
|
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
26357
|
const added = addTo(obj, "permissions", "allow", CLAUDE_RULE);
|
|
@@ -26304,7 +26372,7 @@ function allowCommand(tool) {
|
|
|
26304
26372
|
}
|
|
26305
26373
|
if (picked === "cursor") {
|
|
26306
26374
|
const rel = ".cursor/permissions.json";
|
|
26307
|
-
const file2 =
|
|
26375
|
+
const file2 = join9(root, rel);
|
|
26308
26376
|
const obj = readObject(file2);
|
|
26309
26377
|
if (!obj) throw new CliError(`${rel} is not valid JSON, so it was left as is.`, 1, "allow_file");
|
|
26310
26378
|
const added = addTo(obj, "autoRun", "allow_instructions", CURSOR_LINE);
|
|
@@ -26318,14 +26386,14 @@ function allowCommand(tool) {
|
|
|
26318
26386
|
}
|
|
26319
26387
|
|
|
26320
26388
|
// src/commands/sound.ts
|
|
26321
|
-
import { existsSync as existsSync10, readFileSync as readFileSync8, rmSync, writeFileSync as
|
|
26389
|
+
import { existsSync as existsSync10, readFileSync as readFileSync8, rmSync, writeFileSync as writeFileSync8 } from "fs";
|
|
26322
26390
|
import { homedir as homedir2 } from "os";
|
|
26323
|
-
import { join as
|
|
26391
|
+
import { join as join11 } from "path";
|
|
26324
26392
|
|
|
26325
26393
|
// src/sound.ts
|
|
26326
26394
|
import { spawn as spawn2 } from "child_process";
|
|
26327
|
-
import { existsSync as existsSync9, mkdirSync as
|
|
26328
|
-
import { join as
|
|
26395
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync5, statSync, writeFileSync as writeFileSync7 } from "fs";
|
|
26396
|
+
import { join as join10 } from "path";
|
|
26329
26397
|
|
|
26330
26398
|
// src/sound-files.ts
|
|
26331
26399
|
var SOUND_FILES = {
|
|
@@ -26342,13 +26410,13 @@ function soundWanted(cfg, env = process.env) {
|
|
|
26342
26410
|
const s = env.DEPLOYAI_SOUND;
|
|
26343
26411
|
return !(s !== void 0 && ["0", "false", "off", "no"].includes(s.toLowerCase()));
|
|
26344
26412
|
}
|
|
26345
|
-
var soundsDir = () =>
|
|
26413
|
+
var soundsDir = () => join10(configDir(), "sounds");
|
|
26346
26414
|
function writeSoundFiles() {
|
|
26347
|
-
|
|
26415
|
+
mkdirSync5(soundsDir(), { recursive: true });
|
|
26348
26416
|
for (const [name, b64] of Object.entries(SOUND_FILES)) {
|
|
26349
26417
|
const data = Buffer.from(b64, "base64");
|
|
26350
|
-
const file2 =
|
|
26351
|
-
if (!existsSync9(file2) || statSync(file2).size !== data.length)
|
|
26418
|
+
const file2 = join10(soundsDir(), `${name}.wav`);
|
|
26419
|
+
if (!existsSync9(file2) || statSync(file2).size !== data.length) writeFileSync7(file2, data);
|
|
26352
26420
|
}
|
|
26353
26421
|
}
|
|
26354
26422
|
function playerFor(platform3, file2) {
|
|
@@ -26361,7 +26429,7 @@ function playSound(name, cfg) {
|
|
|
26361
26429
|
if (!soundWanted(cfg)) return;
|
|
26362
26430
|
try {
|
|
26363
26431
|
writeSoundFiles();
|
|
26364
|
-
const player = playerFor(process.platform,
|
|
26432
|
+
const player = playerFor(process.platform, join10(soundsDir(), `${name}.wav`));
|
|
26365
26433
|
if (!player) return;
|
|
26366
26434
|
const child = spawn2(player.cmd, player.args, { detached: true, stdio: "ignore", windowsHide: true });
|
|
26367
26435
|
child.on("error", () => void 0);
|
|
@@ -26440,17 +26508,17 @@ function foreignHooks(files) {
|
|
|
26440
26508
|
return [...found];
|
|
26441
26509
|
}
|
|
26442
26510
|
function agentOn(root, opts = {}) {
|
|
26443
|
-
const file2 =
|
|
26511
|
+
const file2 = join11(root, SETTINGS);
|
|
26444
26512
|
const obj = readObject(file2);
|
|
26445
26513
|
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([
|
|
26514
|
+
const home = process.env.CLAUDE_CONFIG_DIR || join11(opts.home ?? homedir2(), ".claude");
|
|
26515
|
+
if (!opts.alongside && foreignHooks([join11(home, "settings.json"), join11(root, ".claude/settings.json"), file2]).length) return "has_own";
|
|
26448
26516
|
writeSoundFiles();
|
|
26449
26517
|
ensureDeployaiDir(root);
|
|
26450
|
-
const script =
|
|
26518
|
+
const script = join11(root, AGENT_SCRIPT);
|
|
26451
26519
|
const text2 = agentScript(soundsDir());
|
|
26452
26520
|
const scriptSame = existsSync10(script) && readFileSync8(script, "utf8") === text2;
|
|
26453
|
-
if (!scriptSame)
|
|
26521
|
+
if (!scriptSame) writeFileSync8(script, text2);
|
|
26454
26522
|
const hooks = hooksOf(obj);
|
|
26455
26523
|
const env = obj.env && typeof obj.env === "object" ? obj.env : {};
|
|
26456
26524
|
let added = env[TITLE_ENV] !== "1";
|
|
@@ -26468,7 +26536,7 @@ function agentOn(root, opts = {}) {
|
|
|
26468
26536
|
return added || !scriptSame ? "on" : "already";
|
|
26469
26537
|
}
|
|
26470
26538
|
function agentOff(root) {
|
|
26471
|
-
const file2 =
|
|
26539
|
+
const file2 = join11(root, SETTINGS);
|
|
26472
26540
|
const obj = readObject(file2);
|
|
26473
26541
|
if (!obj) throw new CliError(`${SETTINGS} is not valid JSON, so it was left as is.`, 1, "allow_file");
|
|
26474
26542
|
const hooks = hooksOf(obj);
|
|
@@ -26490,7 +26558,7 @@ function agentOff(root) {
|
|
|
26490
26558
|
else delete obj.hooks;
|
|
26491
26559
|
writeObject(file2, obj);
|
|
26492
26560
|
}
|
|
26493
|
-
const script =
|
|
26561
|
+
const script = join11(root, AGENT_SCRIPT);
|
|
26494
26562
|
if (existsSync10(script)) {
|
|
26495
26563
|
rmSync(script);
|
|
26496
26564
|
removed = true;
|
|
@@ -26557,13 +26625,23 @@ function soundCommand(root, action, state, tool, opts = {}) {
|
|
|
26557
26625
|
if (act !== "status") throw new CliError("Usage: npx deployai@latest sound on|off|status|test, or sound agent on|off", 1, "usage");
|
|
26558
26626
|
out(t(soundWanted(cfg) ? "soundOn" : "soundOff"));
|
|
26559
26627
|
}
|
|
26628
|
+
function refreshAgentScript(root) {
|
|
26629
|
+
const script = join11(root, AGENT_SCRIPT);
|
|
26630
|
+
if (!existsSync10(script)) return false;
|
|
26631
|
+
const text2 = agentScript(soundsDir());
|
|
26632
|
+
const now = readFileSync8(script, "utf8");
|
|
26633
|
+
if (now === text2 || !now.startsWith("// DeployAI's sound and tab dot")) return false;
|
|
26634
|
+
writeSoundFiles();
|
|
26635
|
+
writeFileSync8(script, text2);
|
|
26636
|
+
return true;
|
|
26637
|
+
}
|
|
26560
26638
|
|
|
26561
26639
|
// src/commands/link.ts
|
|
26562
26640
|
import { createInterface } from "readline/promises";
|
|
26563
26641
|
|
|
26564
26642
|
// src/commands/migrate.ts
|
|
26565
|
-
import { createWriteStream, existsSync as existsSync11, mkdirSync as
|
|
26566
|
-
import { dirname as dirname2, join as
|
|
26643
|
+
import { createWriteStream, existsSync as existsSync11, mkdirSync as mkdirSync6, readdirSync as readdirSync3, readFileSync as readFileSync9, statSync as statSync2, writeFileSync as writeFileSync9 } from "fs";
|
|
26644
|
+
import { dirname as dirname2, join as join12, posix, relative, resolve, sep } from "path";
|
|
26567
26645
|
import { Readable } from "stream";
|
|
26568
26646
|
import { pipeline } from "stream/promises";
|
|
26569
26647
|
var UA = `deployai-migrate/${CLI_VERSION} (+https://deployai.co.il/move)`;
|
|
@@ -26575,7 +26653,7 @@ var PAUSE_MS = 150;
|
|
|
26575
26653
|
var SCAN_WORKERS = 4;
|
|
26576
26654
|
var START_SCAN_PAGES = 300;
|
|
26577
26655
|
var sleep2 = (ms2) => new Promise((r) => setTimeout(r, ms2));
|
|
26578
|
-
var hostDir = (root, host) =>
|
|
26656
|
+
var hostDir = (root, host) => join12(root, MIGRATION_DIR, host.replace(/^www\./, ""));
|
|
26579
26657
|
var readJson3 = (file2) => {
|
|
26580
26658
|
try {
|
|
26581
26659
|
return readJson(file2);
|
|
@@ -26584,8 +26662,8 @@ var readJson3 = (file2) => {
|
|
|
26584
26662
|
}
|
|
26585
26663
|
};
|
|
26586
26664
|
var writeJson = (file2, data) => {
|
|
26587
|
-
|
|
26588
|
-
|
|
26665
|
+
mkdirSync6(dirname2(file2), { recursive: true });
|
|
26666
|
+
writeFileSync9(file2, JSON.stringify(data, null, 2) + "\n");
|
|
26589
26667
|
};
|
|
26590
26668
|
async function get(url2, accept = "text/html,application/xhtml+xml,*/*;q=0.8", redirect = "follow", cookie) {
|
|
26591
26669
|
try {
|
|
@@ -26595,9 +26673,9 @@ async function get(url2, accept = "text/html,application/xhtml+xml,*/*;q=0.8", r
|
|
|
26595
26673
|
}
|
|
26596
26674
|
}
|
|
26597
26675
|
function scannedHosts(root) {
|
|
26598
|
-
const dir =
|
|
26676
|
+
const dir = join12(root, MIGRATION_DIR);
|
|
26599
26677
|
if (!existsSync11(dir)) return [];
|
|
26600
|
-
return readdirSync3(dir).filter((h) => existsSync11(
|
|
26678
|
+
return readdirSync3(dir).filter((h) => existsSync11(join12(dir, h, "inventory.json")));
|
|
26601
26679
|
}
|
|
26602
26680
|
async function migrateStatusCommand(root, ctx, stage, note) {
|
|
26603
26681
|
if (!isAgentStage(stage)) throw new CliError(`Unknown stage: ${stage}. One of: ${AGENT_STAGES.join(", ")}.`, 1, "usage");
|
|
@@ -26610,18 +26688,18 @@ async function migrateStatusCommand(root, ctx, stage, note) {
|
|
|
26610
26688
|
out(`Reported: ${stage}${note ? ` (${stageNote(note)})` : ""}.`);
|
|
26611
26689
|
}
|
|
26612
26690
|
function readChoices(root) {
|
|
26613
|
-
return readJson3(
|
|
26691
|
+
return readJson3(join12(root, MIGRATION_DIR, "choices.json"));
|
|
26614
26692
|
}
|
|
26615
26693
|
function writeChoices(root, choices) {
|
|
26616
26694
|
ensureMigrationDir(root);
|
|
26617
|
-
writeJson(
|
|
26695
|
+
writeJson(join12(root, MIGRATION_DIR, "choices.json"), choices);
|
|
26618
26696
|
}
|
|
26619
26697
|
function ensureMigrationDir(root) {
|
|
26620
26698
|
ensureDeployaiDir(root);
|
|
26621
|
-
const dir =
|
|
26622
|
-
|
|
26623
|
-
const ignore =
|
|
26624
|
-
if (!existsSync11(ignore))
|
|
26699
|
+
const dir = join12(root, MIGRATION_DIR);
|
|
26700
|
+
mkdirSync6(dir, { recursive: true });
|
|
26701
|
+
const ignore = join12(dir, ".gitignore");
|
|
26702
|
+
if (!existsSync11(ignore)) writeFileSync9(ignore, "*/media/\n*/media-state.json\n");
|
|
26625
26703
|
}
|
|
26626
26704
|
function sameAddress(from, to) {
|
|
26627
26705
|
try {
|
|
@@ -26692,15 +26770,15 @@ async function wordpressContent(base, dir) {
|
|
|
26692
26770
|
await sleep2(PAUSE_MS);
|
|
26693
26771
|
}
|
|
26694
26772
|
if (items.length) {
|
|
26695
|
-
writeJson(
|
|
26773
|
+
writeJson(join12(dir, "content", `${type}.json`), items);
|
|
26696
26774
|
out(` ${type}: ${items.length}`);
|
|
26697
26775
|
}
|
|
26698
26776
|
}
|
|
26699
|
-
const posts = readJson3(
|
|
26777
|
+
const posts = readJson3(join12(dir, "content", "posts.json"));
|
|
26700
26778
|
if (posts?.length) {
|
|
26701
|
-
const files = wpPostsToMarkdown({ origin: new URL(base).origin, posts, categories: readJson3(
|
|
26702
|
-
|
|
26703
|
-
for (const f of files)
|
|
26779
|
+
const files = wpPostsToMarkdown({ origin: new URL(base).origin, posts, categories: readJson3(join12(dir, "content", "categories.json")) ?? [], tags: readJson3(join12(dir, "content", "tags.json")) ?? [], users: readJson3(join12(dir, "content", "users.json")) ?? [], media: readJson3(join12(dir, "content", "media.json")) ?? [] });
|
|
26780
|
+
mkdirSync6(join12(dir, "posts"), { recursive: true });
|
|
26781
|
+
for (const f of files) writeFileSync9(join12(dir, "posts", f.file), f.text);
|
|
26704
26782
|
out(` posts as Markdown: ${files.length}`);
|
|
26705
26783
|
}
|
|
26706
26784
|
return true;
|
|
@@ -26771,7 +26849,7 @@ async function saveOldIcons(html, pageUrl, origin, dir) {
|
|
|
26771
26849
|
add(`${origin}/favicon.ico`, "icon");
|
|
26772
26850
|
add(logoInPage(html), "logo");
|
|
26773
26851
|
const saved = [];
|
|
26774
|
-
const icons =
|
|
26852
|
+
const icons = join12(dir, "icons");
|
|
26775
26853
|
for (const w of wanted.slice(0, 6)) {
|
|
26776
26854
|
const res = await get(w.url, "image/*,*/*;q=0.8");
|
|
26777
26855
|
if (!res?.ok) continue;
|
|
@@ -26781,23 +26859,23 @@ async function saveOldIcons(html, pageUrl, origin, dir) {
|
|
|
26781
26859
|
const svg = !size && isSvgText(bytes.subarray(0, 2048).toString("utf8"));
|
|
26782
26860
|
if (!size && !svg) continue;
|
|
26783
26861
|
const file2 = `${saved.length + 1}-${w.kind}.${svg ? "svg" : size?.format === "jpeg" ? "jpg" : size?.format}`;
|
|
26784
|
-
|
|
26785
|
-
|
|
26862
|
+
mkdirSync6(icons, { recursive: true });
|
|
26863
|
+
writeFileSync9(join12(icons, file2), bytes);
|
|
26786
26864
|
saved.push({ file: file2, kind: w.kind });
|
|
26787
26865
|
}
|
|
26788
|
-
if (saved.length)
|
|
26866
|
+
if (saved.length) writeFileSync9(join12(icons, "icons.json"), JSON.stringify(saved, null, 2));
|
|
26789
26867
|
return saved.length;
|
|
26790
26868
|
}
|
|
26791
26869
|
async function saveOldStyles(html, pageUrl, dir) {
|
|
26792
|
-
const styles =
|
|
26870
|
+
const styles = join12(dir, "styles");
|
|
26793
26871
|
let n2 = 0;
|
|
26794
26872
|
for (const url2 of stylesheetLinks(html, pageUrl, 6)) {
|
|
26795
26873
|
const res = await get(url2, "text/css,*/*;q=0.8");
|
|
26796
26874
|
if (!res?.ok) continue;
|
|
26797
26875
|
const text2 = await res.text();
|
|
26798
26876
|
if (text2.length > ICON_MAX_BYTES) continue;
|
|
26799
|
-
|
|
26800
|
-
|
|
26877
|
+
mkdirSync6(styles, { recursive: true });
|
|
26878
|
+
writeFileSync9(join12(styles, `${++n2}.css`), text2);
|
|
26801
26879
|
}
|
|
26802
26880
|
}
|
|
26803
26881
|
var TRIGGER_PAGES_CAP = 30;
|
|
@@ -26825,15 +26903,15 @@ async function hasRootFile(origin, path, query = "", cookie) {
|
|
|
26825
26903
|
const res = await get(`${origin}${path}${query}`, "*/*", "follow", cookie);
|
|
26826
26904
|
return Boolean(res?.ok && !/text\/html/i.test(res.headers.get("content-type") ?? ""));
|
|
26827
26905
|
}
|
|
26828
|
-
var tagsFile = (dir) =>
|
|
26829
|
-
var stateFile = (dir) =>
|
|
26906
|
+
var tagsFile = (dir) => join12(dir, "tags.json");
|
|
26907
|
+
var stateFile = (dir) => join12(dir, "report-state.json");
|
|
26830
26908
|
function kitMap(root) {
|
|
26831
|
-
if (!existsSync11(
|
|
26909
|
+
if (!existsSync11(join12(root, "src/kit/schema.ts"))) return {};
|
|
26832
26910
|
const cut = (s, n2) => String(s ?? "").slice(0, n2);
|
|
26833
|
-
const pages = (readJson3(
|
|
26834
|
-
const posts = readJson3(
|
|
26835
|
-
const docs = [...new Set((readJson3(
|
|
26836
|
-
const forms = (readJson3(
|
|
26911
|
+
const pages = (readJson3(join12(root, MOVED_PAGES_FILE)) ?? []).slice(0, 150).map((p) => ({ path: cut(p.path, 300), title: cut(p.title, 80), inNav: Boolean(p.inNav) }));
|
|
26912
|
+
const posts = readJson3(join12(root, "src/kit/moved-posts.json")) ?? [];
|
|
26913
|
+
const docs = [...new Set((readJson3(join12(root, MOVED_LEGAL_FILE))?.docs ?? []).map((d) => d.key).filter((k) => k === "privacy" || k === "terms" || k === "cancellation"))];
|
|
26914
|
+
const forms = (readJson3(join12(root, "src/kit/forms.json")) ?? []).filter((f) => /^[a-z0-9-]{1,40}$/.test(f.key ?? "")).slice(0, 30).map((f) => ({
|
|
26837
26915
|
key: f.key,
|
|
26838
26916
|
label: cut(f.label, 80),
|
|
26839
26917
|
...f.page ? { page: cut(f.page, 300) } : {},
|
|
@@ -26844,11 +26922,11 @@ function kitMap(root) {
|
|
|
26844
26922
|
}
|
|
26845
26923
|
async function sendReport(root, ctx, host, open2, verify) {
|
|
26846
26924
|
const dir = hostDir(root, host);
|
|
26847
|
-
const inv = readJson3(
|
|
26925
|
+
const inv = readJson3(join12(dir, "inventory.json"));
|
|
26848
26926
|
const site = readJson3(tagsFile(dir));
|
|
26849
26927
|
const startId = readChoices(root)?.startId;
|
|
26850
26928
|
if (!inv || !site) return;
|
|
26851
|
-
const dns = readJson3(
|
|
26929
|
+
const dns = readJson3(join12(dir, "dns.json"));
|
|
26852
26930
|
const thanksPages = findThanksPages(inv.pages);
|
|
26853
26931
|
if (open2 === "scan") {
|
|
26854
26932
|
if (thanksPages.length && site.forms.length) {
|
|
@@ -26878,9 +26956,9 @@ async function sendReport(root, ctx, host, open2, verify) {
|
|
|
26878
26956
|
return;
|
|
26879
26957
|
}
|
|
26880
26958
|
const state = readJson3(stateFile(dir)) ?? {};
|
|
26881
|
-
const plan = existsSync11(
|
|
26882
|
-
const saved = verify ?? readJson3(
|
|
26883
|
-
const assets = readJson3(
|
|
26959
|
+
const plan = existsSync11(join12(root, MIGRATION_DIR, "plan.md")) ? readFileSync9(join12(root, MIGRATION_DIR, "plan.md"), "utf8") : "";
|
|
26960
|
+
const saved = verify ?? readJson3(join12(dir, "verify-report.json"))?.report ?? null;
|
|
26961
|
+
const assets = readJson3(join12(dir, "assets.json")) ?? [];
|
|
26884
26962
|
const report2 = {
|
|
26885
26963
|
source: inv.source,
|
|
26886
26964
|
platform: inv.platform,
|
|
@@ -26933,11 +27011,11 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
26933
27011
|
const host = new URL(origin).hostname;
|
|
26934
27012
|
ensureMigrationDir(root);
|
|
26935
27013
|
const dir = hostDir(root, host);
|
|
26936
|
-
|
|
27014
|
+
mkdirSync6(dir, { recursive: true });
|
|
26937
27015
|
out(`Scanning ${base} (${platform3})`);
|
|
26938
27016
|
const robotsRes = await get(`${origin}/robots.txt`, "text/plain");
|
|
26939
27017
|
const robots = robotsRes?.ok ? await robotsRes.text() : "";
|
|
26940
|
-
if (robots)
|
|
27018
|
+
if (robots) writeFileSync9(join12(dir, "robots.txt"), robots);
|
|
26941
27019
|
const cap = Math.min(opts.max ?? PAGE_CAP, PAGE_CAP);
|
|
26942
27020
|
const fromSitemaps = await sitemapUrls(base, robots ? parseRobots(robots).sitemaps : [], cap * 5);
|
|
26943
27021
|
const all = [.../* @__PURE__ */ new Set([`${base}/`, ...fromSitemaps.urls, ...fromSitemaps.urls.length ? [] : homeLinks(html, base)])];
|
|
@@ -26977,7 +27055,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
26977
27055
|
await addStylesheetAssets(assets);
|
|
26978
27056
|
const wordpressApi = platform3 === "wordpress" ? await wordpressContent(base, dir) : false;
|
|
26979
27057
|
if (wordpressApi) {
|
|
26980
|
-
const media = readJson3(
|
|
27058
|
+
const media = readJson3(join12(dir, "content", "media.json")) ?? [];
|
|
26981
27059
|
media.forEach((m) => m.source_url && assets.add(m.source_url));
|
|
26982
27060
|
}
|
|
26983
27061
|
const known = new Set(pages.map((p) => p.path));
|
|
@@ -27002,13 +27080,13 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
27002
27080
|
const bare = registrableDomain(host);
|
|
27003
27081
|
try {
|
|
27004
27082
|
const { records, unread } = await collectSnapshot(bare, { extraNames: [...site.ownNames, ...site.serverContainers], deadlineMs: 3e4 });
|
|
27005
|
-
writeJson(
|
|
27083
|
+
writeJson(join12(dir, "dns.json"), { records: records.slice(0, 600), unread: unread.slice(0, 300), services: dnsServices(records).slice(0, 40) });
|
|
27006
27084
|
} catch {
|
|
27007
27085
|
}
|
|
27008
27086
|
const inventory = { source: base, platform: platform3, scannedAt: (/* @__PURE__ */ new Date()).toISOString(), sitemaps: fromSitemaps.sitemaps, pages, wordpressApi, skipped: Math.max(0, all.length - list.length) };
|
|
27009
|
-
writeJson(
|
|
27010
|
-
writeJson(
|
|
27011
|
-
|
|
27087
|
+
writeJson(join12(dir, "inventory.json"), inventory);
|
|
27088
|
+
writeJson(join12(dir, "assets.json"), [...assets].sort());
|
|
27089
|
+
writeFileSync9(join12(dir, "home.html"), html);
|
|
27012
27090
|
const icons = await saveOldIcons(html, home.url, origin, dir);
|
|
27013
27091
|
await saveOldStyles(html, home.url, dir);
|
|
27014
27092
|
const rel = relative(root, dir).split(sep).join("/");
|
|
@@ -27022,7 +27100,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
27022
27100
|
if (icons) out(` icons/ ${icons} icons and logo of the old site, for: npx deployai@latest brand favicon`);
|
|
27023
27101
|
if (wordpressApi) {
|
|
27024
27102
|
out(" content/ the WordPress pages, posts, categories, tags, media and authors as JSON");
|
|
27025
|
-
if (existsSync11(
|
|
27103
|
+
if (existsSync11(join12(dir, "posts"))) out(" posts/ the posts as Markdown for the blog block, each with its old address");
|
|
27026
27104
|
} 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).");
|
|
27027
27105
|
out();
|
|
27028
27106
|
out("Keep every path in inventory.json exactly as it is: same address, same title and description.");
|
|
@@ -27042,8 +27120,8 @@ async function migrateMediaCommand(root) {
|
|
|
27042
27120
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27043
27121
|
for (const host of hosts) {
|
|
27044
27122
|
const dir = hostDir(root, host);
|
|
27045
|
-
const assets = readJson3(
|
|
27046
|
-
const stateFile2 =
|
|
27123
|
+
const assets = readJson3(join12(dir, "assets.json")) ?? [];
|
|
27124
|
+
const stateFile2 = join12(dir, "media-state.json");
|
|
27047
27125
|
const state = readJson3(stateFile2) ?? { done: [], failed: [], bytes: 0 };
|
|
27048
27126
|
const done = new Set(state.done);
|
|
27049
27127
|
const todo = assets.filter((a) => !done.has(a));
|
|
@@ -27062,7 +27140,7 @@ async function migrateMediaCommand(root) {
|
|
|
27062
27140
|
done.add(url2);
|
|
27063
27141
|
continue;
|
|
27064
27142
|
}
|
|
27065
|
-
|
|
27143
|
+
mkdirSync6(dirname2(target), { recursive: true });
|
|
27066
27144
|
await pipeline(Readable.fromWeb(res.body), createWriteStream(target));
|
|
27067
27145
|
const bytes = statSync2(target).size;
|
|
27068
27146
|
state.bytes += bytes;
|
|
@@ -27073,7 +27151,7 @@ async function migrateMediaCommand(root) {
|
|
|
27073
27151
|
}
|
|
27074
27152
|
state.done = [...done];
|
|
27075
27153
|
writeJson(stateFile2, state);
|
|
27076
|
-
out(` ${formatBytes(state.bytes)} in ${relative(root,
|
|
27154
|
+
out(` ${formatBytes(state.bytes)} in ${relative(root, join12(dir, "media")).split(sep).join("/")}${state.failed.length ? `, ${state.failed.length} could not be downloaded (listed in media-state.json)` : ""}`);
|
|
27077
27155
|
}
|
|
27078
27156
|
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.");
|
|
27079
27157
|
}
|
|
@@ -27094,19 +27172,19 @@ function redirectLines(inv, rss = "/rss.xml") {
|
|
|
27094
27172
|
function migratePostsCommand(root) {
|
|
27095
27173
|
const hosts = scannedHosts(root);
|
|
27096
27174
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27097
|
-
if (!existsSync11(
|
|
27175
|
+
if (!existsSync11(join12(root, "src/kit/schema.ts"))) throw new CliError("The dashboard is not in this folder yet. Run: npx deployai@latest blocks dashboard", 1, "usage");
|
|
27098
27176
|
const posts = [];
|
|
27099
27177
|
for (const host of hosts) {
|
|
27100
27178
|
const dir = hostDir(root, host);
|
|
27101
|
-
const inv = readJson3(
|
|
27102
|
-
const list = readJson3(
|
|
27103
|
-
if (inv && list?.length) posts.push(...wpPostsToKit({ origin: new URL(inv.source).origin, posts: list, categories: readJson3(
|
|
27179
|
+
const inv = readJson3(join12(dir, "inventory.json"));
|
|
27180
|
+
const list = readJson3(join12(dir, "content", "posts.json"));
|
|
27181
|
+
if (inv && list?.length) posts.push(...wpPostsToKit({ origin: new URL(inv.source).origin, posts: list, categories: readJson3(join12(dir, "content", "categories.json")) ?? [], media: readJson3(join12(dir, "content", "media.json")) ?? [] }));
|
|
27104
27182
|
}
|
|
27105
27183
|
if (!posts.length) {
|
|
27106
27184
|
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.");
|
|
27107
27185
|
return;
|
|
27108
27186
|
}
|
|
27109
|
-
|
|
27187
|
+
writeFileSync9(join12(root, "src/kit/moved-posts.json"), JSON.stringify(posts.map(({ lost: _lost, ...p }) => p), null, 1));
|
|
27110
27188
|
out(`Wrote ${posts.length} posts to src/kit/moved-posts.json. Turn on blog in src/kit/site.config.ts.`);
|
|
27111
27189
|
const short = posts.filter((p) => p.lost.length);
|
|
27112
27190
|
if (short.length) {
|
|
@@ -27117,31 +27195,31 @@ function migratePostsCommand(root) {
|
|
|
27117
27195
|
function migratePagesCommand(root) {
|
|
27118
27196
|
const hosts = scannedHosts(root);
|
|
27119
27197
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27120
|
-
if (!existsSync11(
|
|
27121
|
-
const file2 =
|
|
27198
|
+
if (!existsSync11(join12(root, "src/kit/schema.ts"))) throw new CliError("The dashboard is not in this folder yet. Run: npx deployai@latest blocks dashboard", 1, "usage");
|
|
27199
|
+
const file2 = join12(root, MOVED_PAGES_FILE);
|
|
27122
27200
|
const before = readJson3(file2);
|
|
27123
27201
|
const pages = [];
|
|
27124
27202
|
for (const host of hosts) {
|
|
27125
27203
|
const dir = hostDir(root, host);
|
|
27126
|
-
const inv = readJson3(
|
|
27204
|
+
const inv = readJson3(join12(dir, "inventory.json"));
|
|
27127
27205
|
if (!inv) continue;
|
|
27128
|
-
const homeHtml = existsSync11(
|
|
27206
|
+
const homeHtml = existsSync11(join12(dir, "home.html")) ? readFileSync9(join12(dir, "home.html"), "utf8") : null;
|
|
27129
27207
|
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);
|
|
27130
27208
|
}
|
|
27131
27209
|
const kept = before?.length ? pages.filter((p) => before.some((b) => b.path === p.path)) : pages;
|
|
27132
|
-
|
|
27210
|
+
writeFileSync9(file2, JSON.stringify(kept, null, 1));
|
|
27133
27211
|
out(`Wrote ${MOVED_PAGES_FILE}: ${kept.length} pages for the dashboard's Pages, ${kept.filter((p) => p.inNav).length} of them in the menu.`);
|
|
27134
27212
|
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.");
|
|
27135
27213
|
}
|
|
27136
27214
|
function migrateLegalCommand(root) {
|
|
27137
27215
|
const hosts = scannedHosts(root);
|
|
27138
27216
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27139
|
-
if (!existsSync11(
|
|
27217
|
+
if (!existsSync11(join12(root, "src/kit/schema.ts"))) throw new CliError("The dashboard is not in this folder yet. Run: npx deployai@latest blocks dashboard", 1, "usage");
|
|
27140
27218
|
const pages = [];
|
|
27141
27219
|
const site = emptySiteTags();
|
|
27142
27220
|
for (const host of hosts) {
|
|
27143
27221
|
const dir = hostDir(root, host);
|
|
27144
|
-
pages.push(...readJson3(
|
|
27222
|
+
pages.push(...readJson3(join12(dir, "inventory.json"))?.pages ?? []);
|
|
27145
27223
|
const found = readJson3(tagsFile(dir));
|
|
27146
27224
|
if (found) {
|
|
27147
27225
|
site.tags.push(...found.tags);
|
|
@@ -27149,9 +27227,9 @@ function migrateLegalCommand(root) {
|
|
|
27149
27227
|
site.forms.push(...found.forms);
|
|
27150
27228
|
}
|
|
27151
27229
|
}
|
|
27152
|
-
const file2 =
|
|
27230
|
+
const file2 = join12(root, MOVED_LEGAL_FILE);
|
|
27153
27231
|
const legal = { ...movedLegalFromScan({ pages, site }), docs: readJson3(file2)?.docs ?? [] };
|
|
27154
|
-
|
|
27232
|
+
writeFileSync9(file2, JSON.stringify(legal, null, 1));
|
|
27155
27233
|
out(`Wrote ${MOVED_LEGAL_FILE}: ${legal.duties.length} rows for the dashboard's Documents page, ${legal.forms.length} forms, ${legal.services.length} outside services.`);
|
|
27156
27234
|
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.`);
|
|
27157
27235
|
out("Nothing here is finished or checked: it tells the owner what to look at. Keep tags, forms and pages as they are.");
|
|
@@ -27161,20 +27239,20 @@ function migrateRedirectsCommand(root) {
|
|
|
27161
27239
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27162
27240
|
const lines = /* @__PURE__ */ new Set();
|
|
27163
27241
|
for (const host of hosts) {
|
|
27164
|
-
const inv = readJson3(
|
|
27242
|
+
const inv = readJson3(join12(hostDir(root, host), "inventory.json"));
|
|
27165
27243
|
if (inv) redirectLines(inv).forEach((l) => lines.add(l));
|
|
27166
27244
|
}
|
|
27167
|
-
const publicDir =
|
|
27168
|
-
const file2 =
|
|
27245
|
+
const publicDir = join12(root, "public");
|
|
27246
|
+
const file2 = join12(existsSync11(publicDir) ? publicDir : root, "_redirects");
|
|
27169
27247
|
const before = existsSync11(file2) ? readFileSync9(file2, "utf8").split(/\r?\n/).filter(Boolean) : [];
|
|
27170
27248
|
const added = [...lines].filter((l) => !before.some((b) => b.split(/\s+/)[0] === l.split(/\s+/)[0]));
|
|
27171
|
-
|
|
27249
|
+
writeFileSync9(file2, [...before, ...added].join("\n") + "\n");
|
|
27172
27250
|
out(`${relative(root, file2).split(sep).join("/")}: ${added.length} added, ${before.length + added.length} in all (at most 2,000; no query strings).`);
|
|
27173
27251
|
out('Add a line "<old path> <new path> 301" only for a page that truly could not keep its address.');
|
|
27174
27252
|
}
|
|
27175
27253
|
function allowedRedirects(root) {
|
|
27176
27254
|
const map2 = /* @__PURE__ */ new Map();
|
|
27177
|
-
for (const file2 of [
|
|
27255
|
+
for (const file2 of [join12(root, "public", "_redirects"), join12(root, "_redirects")]) {
|
|
27178
27256
|
if (!existsSync11(file2)) continue;
|
|
27179
27257
|
for (const line of readFileSync9(file2, "utf8").split(/\r?\n/)) {
|
|
27180
27258
|
const [from, to] = line.trim().split(/\s+/);
|
|
@@ -27210,7 +27288,7 @@ async function migrateTagsCommand(root, ctx, opts) {
|
|
|
27210
27288
|
for (const host of hosts) {
|
|
27211
27289
|
const dir = hostDir(root, host);
|
|
27212
27290
|
const site = readJson3(tagsFile(dir));
|
|
27213
|
-
const inv = readJson3(
|
|
27291
|
+
const inv = readJson3(join12(dir, "inventory.json"));
|
|
27214
27292
|
if (!site || !inv) continue;
|
|
27215
27293
|
const state = readJson3(stateFile(dir)) ?? {};
|
|
27216
27294
|
if (urls.length && opts.fired) {
|
|
@@ -27280,7 +27358,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
27280
27358
|
const tagFindings = [];
|
|
27281
27359
|
const perHost = [];
|
|
27282
27360
|
for (const host of hosts) {
|
|
27283
|
-
const inv = readJson3(
|
|
27361
|
+
const inv = readJson3(join12(hostDir(root, host), "inventory.json"));
|
|
27284
27362
|
const oldSite = readJson3(tagsFile(hostDir(root, host)));
|
|
27285
27363
|
const state = readJson3(stateFile(hostDir(root, host))) ?? {};
|
|
27286
27364
|
const nextSite = emptySiteTags();
|
|
@@ -27329,7 +27407,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
27329
27407
|
}
|
|
27330
27408
|
}
|
|
27331
27409
|
const words = { missing: "not found on the preview", moved: "moved to", error: "answers", title_lost: "lost its title", description_lost: "lost its description" };
|
|
27332
|
-
const report2 =
|
|
27410
|
+
const report2 = join12(root, MIGRATION_DIR, "verify.json");
|
|
27333
27411
|
writeJson(report2, { checkedAt: (/* @__PURE__ */ new Date()).toISOString(), preview: preview.origin, checked, findings, credits: [...credits.keys()], vendors: [...vendors.keys()], tags: tagFindings });
|
|
27334
27412
|
if (credits.size) {
|
|
27335
27413
|
out(`A builder's credit is still on the preview:`);
|
|
@@ -27354,7 +27432,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
27354
27432
|
for (const h of perHost) {
|
|
27355
27433
|
const dir = hostDir(root, h.host);
|
|
27356
27434
|
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) };
|
|
27357
|
-
writeJson(
|
|
27435
|
+
writeJson(join12(dir, "verify-report.json"), { report: verify });
|
|
27358
27436
|
await sendReport(root, ctx, h.host, clean3 ? "verify" : null, verify);
|
|
27359
27437
|
}
|
|
27360
27438
|
if (!findings.length) {
|
|
@@ -27483,8 +27561,8 @@ async function askYes(question) {
|
|
|
27483
27561
|
|
|
27484
27562
|
// src/same-name.ts
|
|
27485
27563
|
import { createHash } from "crypto";
|
|
27486
|
-
import { mkdirSync as
|
|
27487
|
-
import { dirname as dirname3, join as
|
|
27564
|
+
import { mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync10 } from "fs";
|
|
27565
|
+
import { dirname as dirname3, join as join13 } from "path";
|
|
27488
27566
|
var LAST_FILES = ".deployai/last-files.json";
|
|
27489
27567
|
var KEPT = /^(public|static)\/.*\.(avif|webp|png|jpe?g|gif|svg|ico|woff2?|ttf|otf|mp4|webm|css|js|mjs)$/i;
|
|
27490
27568
|
var HASHED = /[.-][A-Za-z0-9_]{6,20}\.[a-z0-9]+$/;
|
|
@@ -27494,13 +27572,13 @@ function changedUnderSameName(root, files) {
|
|
|
27494
27572
|
for (const f of files) if (KEPT.test(f.rel) && !HASHED.test(f.rel.split("/").pop() ?? "")) now[f.rel] = digest(f.abs);
|
|
27495
27573
|
let before = {};
|
|
27496
27574
|
try {
|
|
27497
|
-
before = readJson(
|
|
27575
|
+
before = readJson(join13(root, LAST_FILES));
|
|
27498
27576
|
} catch {
|
|
27499
27577
|
}
|
|
27500
27578
|
const changed = Object.keys(now).filter((rel) => before[rel] && before[rel] !== now[rel]).sort();
|
|
27501
27579
|
try {
|
|
27502
|
-
|
|
27503
|
-
|
|
27580
|
+
mkdirSync7(dirname3(join13(root, LAST_FILES)), { recursive: true });
|
|
27581
|
+
writeFileSync10(join13(root, LAST_FILES), JSON.stringify(now));
|
|
27504
27582
|
} catch {
|
|
27505
27583
|
}
|
|
27506
27584
|
return changed;
|
|
@@ -27698,14 +27776,14 @@ async function promoteWithSql(root, ctx, projectId, number4, kind, approve) {
|
|
|
27698
27776
|
function fetchStatus(ctx, projectId) {
|
|
27699
27777
|
return apiRequest(ctx, `/api/cli/status?projectId=${encodeURIComponent(projectId)}`, StatusResponse);
|
|
27700
27778
|
}
|
|
27701
|
-
var
|
|
27779
|
+
var WAIT_MS2 = 5 * 6e4;
|
|
27702
27780
|
var statusBusy = (s) => s.queue.running || s.queue.position > 0 || Boolean(s.latest?.goingLive) || s.latest?.status === "queued" || s.latest?.status === "building";
|
|
27703
27781
|
async function statusCommand(root, ctx, opts = {}) {
|
|
27704
27782
|
requireToken(ctx);
|
|
27705
27783
|
const projectId = linkedProjectId(root);
|
|
27706
27784
|
let s = await fetchStatus(ctx, projectId);
|
|
27707
27785
|
if (opts.wait) {
|
|
27708
|
-
const end = Date.now() +
|
|
27786
|
+
const end = Date.now() + WAIT_MS2;
|
|
27709
27787
|
while (statusBusy(s) && Date.now() < end) {
|
|
27710
27788
|
await new Promise((r) => setTimeout(r, opts.pollMs ?? 3e3));
|
|
27711
27789
|
s = await fetchStatus(ctx, projectId);
|
|
@@ -28190,12 +28268,12 @@ async function claimCommand(root, ctx, opts) {
|
|
|
28190
28268
|
// src/commands/pull.ts
|
|
28191
28269
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
28192
28270
|
import { existsSync as existsSync13, readdirSync as readdirSync5, rmSync as rmSync2 } from "fs";
|
|
28193
|
-
import { join as
|
|
28271
|
+
import { join as join15 } from "path";
|
|
28194
28272
|
|
|
28195
28273
|
// src/commands/samples.ts
|
|
28196
28274
|
import { createInterface as createInterface3 } from "readline/promises";
|
|
28197
|
-
import { existsSync as existsSync12, mkdirSync as
|
|
28198
|
-
import { dirname as dirname4, join as
|
|
28275
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync8, readdirSync as readdirSync4, writeFileSync as writeFileSync11 } from "fs";
|
|
28276
|
+
import { dirname as dirname4, join as join14, relative as relative2, resolve as resolve2, sep as sep2 } from "path";
|
|
28199
28277
|
import { gunzipSync } from "zlib";
|
|
28200
28278
|
var SAMPLES = [
|
|
28201
28279
|
{ key: "landing", title: "Landing page: a full one-page site with WhatsApp sign-up", stack: "static HTML and CSS" },
|
|
@@ -28245,7 +28323,7 @@ async function askWhere(cwd, key, count) {
|
|
|
28245
28323
|
}
|
|
28246
28324
|
}
|
|
28247
28325
|
async function downloadSample(ctx, key, root) {
|
|
28248
|
-
|
|
28326
|
+
mkdirSync8(root, { recursive: true });
|
|
28249
28327
|
let res;
|
|
28250
28328
|
try {
|
|
28251
28329
|
res = await fetch(`${ctx.apiUrl}/samples-src/${key}.tar.gz`, {
|
|
@@ -28267,7 +28345,7 @@ function extractInto(gz, root, damaged) {
|
|
|
28267
28345
|
} catch {
|
|
28268
28346
|
throw new CliError(damaged, 1, "api");
|
|
28269
28347
|
}
|
|
28270
|
-
|
|
28348
|
+
mkdirSync8(root, { recursive: true });
|
|
28271
28349
|
const base = resolve2(root);
|
|
28272
28350
|
let written = 0;
|
|
28273
28351
|
for (const e3 of entries) {
|
|
@@ -28275,8 +28353,8 @@ function extractInto(gz, root, damaged) {
|
|
|
28275
28353
|
if (privateProjectFile(e3.name.replace(/\\/g, "/"))) continue;
|
|
28276
28354
|
const target = resolve2(base, e3.name);
|
|
28277
28355
|
if (target !== base && !target.startsWith(base + sep2)) continue;
|
|
28278
|
-
|
|
28279
|
-
|
|
28356
|
+
mkdirSync8(dirname4(target), { recursive: true });
|
|
28357
|
+
writeFileSync11(target, e3.data);
|
|
28280
28358
|
written++;
|
|
28281
28359
|
}
|
|
28282
28360
|
return written;
|
|
@@ -28300,7 +28378,7 @@ async function samplesCommand(cwd, ctx, key, opts = {}) {
|
|
|
28300
28378
|
}
|
|
28301
28379
|
const written = await downloadSample(ctx, sample.key, root);
|
|
28302
28380
|
const base = resolve2(root);
|
|
28303
|
-
const hasPackage = existsSync12(
|
|
28381
|
+
const hasPackage = existsSync12(join14(base, "package.json"));
|
|
28304
28382
|
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.`);
|
|
28305
28383
|
out("");
|
|
28306
28384
|
const t = messages(base);
|
|
@@ -28357,7 +28435,7 @@ var git = (root, args, env = {}) => spawnSync2("git", args, { cwd: root, encodin
|
|
|
28357
28435
|
function clearTree(root) {
|
|
28358
28436
|
for (const name of readdirSync5(root)) {
|
|
28359
28437
|
if (name === ".git" || name === ".deployai") continue;
|
|
28360
|
-
rmSync2(
|
|
28438
|
+
rmSync2(join15(root, name), { recursive: true, force: true });
|
|
28361
28439
|
}
|
|
28362
28440
|
}
|
|
28363
28441
|
async function pullHistory(root, ctx, projectId) {
|
|
@@ -28367,7 +28445,7 @@ async function pullHistory(root, ctx, projectId) {
|
|
|
28367
28445
|
const live = versions.find((v) => v.isLive)?.number ?? Math.max(0, ...versions.filter((v) => v.status === "ready").map((v) => v.number));
|
|
28368
28446
|
const chosen = versions.filter((v) => v.number <= live && v.status !== "failed" && v.status !== "queued").sort((a, b) => a.number - b.number);
|
|
28369
28447
|
if (!chosen.length) throw new CliError(t("pullNoSource"), 1, "not_found");
|
|
28370
|
-
if (!existsSync13(
|
|
28448
|
+
if (!existsSync13(join15(root, ".git")) && git(root, ["init", "-q"]).status !== 0) throw new CliError(t("pullNoGit"), 1, "usage");
|
|
28371
28449
|
for (const v of chosen) {
|
|
28372
28450
|
const gz = await fetchSource(root, ctx, projectId, v.number).catch(() => null);
|
|
28373
28451
|
if (!gz) continue;
|
|
@@ -28421,46 +28499,6 @@ import { spawnSync as spawnSync3 } from "child_process";
|
|
|
28421
28499
|
import { existsSync as existsSync14, writeFileSync as writeFileSync13 } from "fs";
|
|
28422
28500
|
import { join as join17, relative as relative3, resolve as resolve3 } from "path";
|
|
28423
28501
|
|
|
28424
|
-
// src/rules.ts
|
|
28425
|
-
import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync11 } from "fs";
|
|
28426
|
-
import { join as join15 } from "path";
|
|
28427
|
-
var CACHE_FILE = "rules-cache.json";
|
|
28428
|
-
var DAY_MS = 864e5;
|
|
28429
|
-
var WAIT_MS2 = 2e3;
|
|
28430
|
-
var EMPTY = { rules: {}, extra: [] };
|
|
28431
|
-
function cleanRules(v) {
|
|
28432
|
-
const o = v && typeof v === "object" ? v : {};
|
|
28433
|
-
const rules = {};
|
|
28434
|
-
if (o.rules && typeof o.rules === "object") {
|
|
28435
|
-
for (const [k, t] of Object.entries(o.rules)) if (typeof t === "string" && t.trim() && t.length < 2e4) rules[k] = t;
|
|
28436
|
-
}
|
|
28437
|
-
const extra = Array.isArray(o.extra) ? o.extra.filter((t) => typeof t === "string" && t.trim().length > 0 && t.length < 4e3).slice(0, 20) : [];
|
|
28438
|
-
return { rules, extra };
|
|
28439
|
-
}
|
|
28440
|
-
async function serverRules(apiUrl, fetcher = fetch, now = Date.now()) {
|
|
28441
|
-
const file2 = join15(configDir(), CACHE_FILE);
|
|
28442
|
-
let cached2 = null;
|
|
28443
|
-
try {
|
|
28444
|
-
cached2 = readJson(file2);
|
|
28445
|
-
} catch {
|
|
28446
|
-
}
|
|
28447
|
-
if (cached2 && cached2.version === CLI_VERSION && now - cached2.at < DAY_MS) return cleanRules(cached2.data);
|
|
28448
|
-
try {
|
|
28449
|
-
const r = await fetcher(`${apiUrl}/api/cli/rules?cli=${encodeURIComponent(CLI_VERSION)}`, { signal: AbortSignal.timeout(WAIT_MS2) });
|
|
28450
|
-
if (!r.ok) throw new Error(String(r.status));
|
|
28451
|
-
const data = cleanRules(await r.json());
|
|
28452
|
-
try {
|
|
28453
|
-
mkdirSync8(configDir(), { recursive: true });
|
|
28454
|
-
writeFileSync11(file2, JSON.stringify({ at: now, version: CLI_VERSION, data }));
|
|
28455
|
-
} catch {
|
|
28456
|
-
}
|
|
28457
|
-
return data;
|
|
28458
|
-
} catch {
|
|
28459
|
-
return cached2 ? cleanRules(cached2.data) : EMPTY;
|
|
28460
|
-
}
|
|
28461
|
-
}
|
|
28462
|
-
var rule = (r, key, bundled) => r.rules[key] ?? bundled;
|
|
28463
|
-
|
|
28464
28502
|
// src/commands/starter.ts
|
|
28465
28503
|
import { writeFileSync as writeFileSync12 } from "fs";
|
|
28466
28504
|
import { join as join16 } from "path";
|
|
@@ -28573,7 +28611,9 @@ async function startCommand(cwd, ctx, id, opts = {}) {
|
|
|
28573
28611
|
const starter = (kind === "new" || kind === "guest") && !sample && empty;
|
|
28574
28612
|
const signedIn = Boolean(choices.projectId && tokenIfOwnApi(ctxNow));
|
|
28575
28613
|
const pullNow = update && empty && signedIn;
|
|
28576
|
-
const
|
|
28614
|
+
const stepOpts = { emptyFolder: kind === "update" && empty && !pullNow, starter, managed: Boolean(choices.migration?.requestId), signedIn, addons: Boolean(choices.runAddons) };
|
|
28615
|
+
const [server, stepTexts] = await Promise.all([serverRules(ctx.apiUrl), serverSteps(ctx.apiUrl, startStepsQuery(kind, stepOpts))]);
|
|
28616
|
+
const steps = withServerSteps(startSteps(kind, stepOpts), stepTexts);
|
|
28577
28617
|
const inClaude = process.env.CLAUDECODE === "1";
|
|
28578
28618
|
if (ctxNow.config.sound === void 0) {
|
|
28579
28619
|
if (inClaude) steps.unshift(ASK_SOUND_TERMINAL_STEP);
|
|
@@ -28619,7 +28659,7 @@ ${choices.brief}
|
|
|
28619
28659
|
updateProject(root, { stack: choices.stack });
|
|
28620
28660
|
done.push(t("startStack", { stack: stackSummary(choices.stack) }));
|
|
28621
28661
|
}
|
|
28622
|
-
const init = runInit(root);
|
|
28662
|
+
const init = runInit(root, { texts: initTexts(server) });
|
|
28623
28663
|
if (init.created.includes("DEPLOYAI.md") || init.rulesAdded) done.push(t("startRules"));
|
|
28624
28664
|
if (choices.projectId) {
|
|
28625
28665
|
const before = readProject(root);
|
|
@@ -28657,15 +28697,15 @@ ${choices.brief}
|
|
|
28657
28697
|
say("Then, in this order:");
|
|
28658
28698
|
steps.forEach((s, i) => say(`${i + 1}. ${s.cmd ? `Run ${s.cmd}. ` : ""}${s.say}`));
|
|
28659
28699
|
say();
|
|
28660
|
-
|
|
28661
|
-
say(
|
|
28700
|
+
const lang = langOf(choices.ownerLanguage);
|
|
28701
|
+
say(rule(server, `runCommands.${lang}`, runCommandsRule(lang)));
|
|
28702
|
+
say(rule(server, "modelFlag", MODEL_FLAG_RULE));
|
|
28662
28703
|
const askLine2 = toolAskLine(deployToolFromEnv(process.env));
|
|
28663
28704
|
if (askLine2) say(askLine2);
|
|
28664
|
-
const server = await serverRules(ctx.apiUrl);
|
|
28665
28705
|
say(rule(server, "askOwner", ASK_OWNER_RULE));
|
|
28666
28706
|
say(rule(server, "ownerText", OWNER_TEXT_RULE));
|
|
28667
28707
|
for (const line of server.extra) say(line);
|
|
28668
|
-
say(START_FAIL_LINE);
|
|
28708
|
+
say(rule(server, "startFail", START_FAIL_LINE));
|
|
28669
28709
|
ensureDeployaiDir(root);
|
|
28670
28710
|
writeFileSync13(join17(root, START_FILE), `${lines.join("\n")}
|
|
28671
28711
|
`);
|
|
@@ -29854,7 +29894,7 @@ function buildProgram() {
|
|
|
29854
29894
|
const g = (cmd) => cmd.optsWithGlobals();
|
|
29855
29895
|
const root = (cmd) => resolve8(g(cmd).dir ?? process.cwd());
|
|
29856
29896
|
const ctx = (cmd) => apiContext(g(cmd).api);
|
|
29857
|
-
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));
|
|
29897
|
+
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));
|
|
29858
29898
|
program.command("inspect").description("show framework, package manager, language, database, storage").option("--json", "machine readable output").action((opts, cmd) => inspectCommand(root(cmd), opts));
|
|
29859
29899
|
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) => {
|
|
29860
29900
|
const a = await runCheck(root(cmd), ctx(cmd), opts);
|
|
@@ -29950,6 +29990,10 @@ async function main(argv = process.argv) {
|
|
|
29950
29990
|
program.hook("preAction", (_this, actionCmd) => {
|
|
29951
29991
|
command = commandPath(actionCmd);
|
|
29952
29992
|
apiFlag = actionCmd.optsWithGlobals().api;
|
|
29993
|
+
try {
|
|
29994
|
+
refreshAgentScript(process.cwd());
|
|
29995
|
+
} catch {
|
|
29996
|
+
}
|
|
29953
29997
|
});
|
|
29954
29998
|
const exitBefore = process.exitCode;
|
|
29955
29999
|
let result = "success";
|