deployai 0.1.0-beta.32 → 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 +288 -259
- 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;
|
|
@@ -26558,13 +26626,13 @@ function soundCommand(root, action, state, tool, opts = {}) {
|
|
|
26558
26626
|
out(t(soundWanted(cfg) ? "soundOn" : "soundOff"));
|
|
26559
26627
|
}
|
|
26560
26628
|
function refreshAgentScript(root) {
|
|
26561
|
-
const script =
|
|
26629
|
+
const script = join11(root, AGENT_SCRIPT);
|
|
26562
26630
|
if (!existsSync10(script)) return false;
|
|
26563
26631
|
const text2 = agentScript(soundsDir());
|
|
26564
26632
|
const now = readFileSync8(script, "utf8");
|
|
26565
26633
|
if (now === text2 || !now.startsWith("// DeployAI's sound and tab dot")) return false;
|
|
26566
26634
|
writeSoundFiles();
|
|
26567
|
-
|
|
26635
|
+
writeFileSync8(script, text2);
|
|
26568
26636
|
return true;
|
|
26569
26637
|
}
|
|
26570
26638
|
|
|
@@ -26572,8 +26640,8 @@ function refreshAgentScript(root) {
|
|
|
26572
26640
|
import { createInterface } from "readline/promises";
|
|
26573
26641
|
|
|
26574
26642
|
// src/commands/migrate.ts
|
|
26575
|
-
import { createWriteStream, existsSync as existsSync11, mkdirSync as
|
|
26576
|
-
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";
|
|
26577
26645
|
import { Readable } from "stream";
|
|
26578
26646
|
import { pipeline } from "stream/promises";
|
|
26579
26647
|
var UA = `deployai-migrate/${CLI_VERSION} (+https://deployai.co.il/move)`;
|
|
@@ -26585,7 +26653,7 @@ var PAUSE_MS = 150;
|
|
|
26585
26653
|
var SCAN_WORKERS = 4;
|
|
26586
26654
|
var START_SCAN_PAGES = 300;
|
|
26587
26655
|
var sleep2 = (ms2) => new Promise((r) => setTimeout(r, ms2));
|
|
26588
|
-
var hostDir = (root, host) =>
|
|
26656
|
+
var hostDir = (root, host) => join12(root, MIGRATION_DIR, host.replace(/^www\./, ""));
|
|
26589
26657
|
var readJson3 = (file2) => {
|
|
26590
26658
|
try {
|
|
26591
26659
|
return readJson(file2);
|
|
@@ -26594,8 +26662,8 @@ var readJson3 = (file2) => {
|
|
|
26594
26662
|
}
|
|
26595
26663
|
};
|
|
26596
26664
|
var writeJson = (file2, data) => {
|
|
26597
|
-
|
|
26598
|
-
|
|
26665
|
+
mkdirSync6(dirname2(file2), { recursive: true });
|
|
26666
|
+
writeFileSync9(file2, JSON.stringify(data, null, 2) + "\n");
|
|
26599
26667
|
};
|
|
26600
26668
|
async function get(url2, accept = "text/html,application/xhtml+xml,*/*;q=0.8", redirect = "follow", cookie) {
|
|
26601
26669
|
try {
|
|
@@ -26605,9 +26673,9 @@ async function get(url2, accept = "text/html,application/xhtml+xml,*/*;q=0.8", r
|
|
|
26605
26673
|
}
|
|
26606
26674
|
}
|
|
26607
26675
|
function scannedHosts(root) {
|
|
26608
|
-
const dir =
|
|
26676
|
+
const dir = join12(root, MIGRATION_DIR);
|
|
26609
26677
|
if (!existsSync11(dir)) return [];
|
|
26610
|
-
return readdirSync3(dir).filter((h) => existsSync11(
|
|
26678
|
+
return readdirSync3(dir).filter((h) => existsSync11(join12(dir, h, "inventory.json")));
|
|
26611
26679
|
}
|
|
26612
26680
|
async function migrateStatusCommand(root, ctx, stage, note) {
|
|
26613
26681
|
if (!isAgentStage(stage)) throw new CliError(`Unknown stage: ${stage}. One of: ${AGENT_STAGES.join(", ")}.`, 1, "usage");
|
|
@@ -26620,18 +26688,18 @@ async function migrateStatusCommand(root, ctx, stage, note) {
|
|
|
26620
26688
|
out(`Reported: ${stage}${note ? ` (${stageNote(note)})` : ""}.`);
|
|
26621
26689
|
}
|
|
26622
26690
|
function readChoices(root) {
|
|
26623
|
-
return readJson3(
|
|
26691
|
+
return readJson3(join12(root, MIGRATION_DIR, "choices.json"));
|
|
26624
26692
|
}
|
|
26625
26693
|
function writeChoices(root, choices) {
|
|
26626
26694
|
ensureMigrationDir(root);
|
|
26627
|
-
writeJson(
|
|
26695
|
+
writeJson(join12(root, MIGRATION_DIR, "choices.json"), choices);
|
|
26628
26696
|
}
|
|
26629
26697
|
function ensureMigrationDir(root) {
|
|
26630
26698
|
ensureDeployaiDir(root);
|
|
26631
|
-
const dir =
|
|
26632
|
-
|
|
26633
|
-
const ignore =
|
|
26634
|
-
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");
|
|
26635
26703
|
}
|
|
26636
26704
|
function sameAddress(from, to) {
|
|
26637
26705
|
try {
|
|
@@ -26702,15 +26770,15 @@ async function wordpressContent(base, dir) {
|
|
|
26702
26770
|
await sleep2(PAUSE_MS);
|
|
26703
26771
|
}
|
|
26704
26772
|
if (items.length) {
|
|
26705
|
-
writeJson(
|
|
26773
|
+
writeJson(join12(dir, "content", `${type}.json`), items);
|
|
26706
26774
|
out(` ${type}: ${items.length}`);
|
|
26707
26775
|
}
|
|
26708
26776
|
}
|
|
26709
|
-
const posts = readJson3(
|
|
26777
|
+
const posts = readJson3(join12(dir, "content", "posts.json"));
|
|
26710
26778
|
if (posts?.length) {
|
|
26711
|
-
const files = wpPostsToMarkdown({ origin: new URL(base).origin, posts, categories: readJson3(
|
|
26712
|
-
|
|
26713
|
-
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);
|
|
26714
26782
|
out(` posts as Markdown: ${files.length}`);
|
|
26715
26783
|
}
|
|
26716
26784
|
return true;
|
|
@@ -26781,7 +26849,7 @@ async function saveOldIcons(html, pageUrl, origin, dir) {
|
|
|
26781
26849
|
add(`${origin}/favicon.ico`, "icon");
|
|
26782
26850
|
add(logoInPage(html), "logo");
|
|
26783
26851
|
const saved = [];
|
|
26784
|
-
const icons =
|
|
26852
|
+
const icons = join12(dir, "icons");
|
|
26785
26853
|
for (const w of wanted.slice(0, 6)) {
|
|
26786
26854
|
const res = await get(w.url, "image/*,*/*;q=0.8");
|
|
26787
26855
|
if (!res?.ok) continue;
|
|
@@ -26791,23 +26859,23 @@ async function saveOldIcons(html, pageUrl, origin, dir) {
|
|
|
26791
26859
|
const svg = !size && isSvgText(bytes.subarray(0, 2048).toString("utf8"));
|
|
26792
26860
|
if (!size && !svg) continue;
|
|
26793
26861
|
const file2 = `${saved.length + 1}-${w.kind}.${svg ? "svg" : size?.format === "jpeg" ? "jpg" : size?.format}`;
|
|
26794
|
-
|
|
26795
|
-
|
|
26862
|
+
mkdirSync6(icons, { recursive: true });
|
|
26863
|
+
writeFileSync9(join12(icons, file2), bytes);
|
|
26796
26864
|
saved.push({ file: file2, kind: w.kind });
|
|
26797
26865
|
}
|
|
26798
|
-
if (saved.length)
|
|
26866
|
+
if (saved.length) writeFileSync9(join12(icons, "icons.json"), JSON.stringify(saved, null, 2));
|
|
26799
26867
|
return saved.length;
|
|
26800
26868
|
}
|
|
26801
26869
|
async function saveOldStyles(html, pageUrl, dir) {
|
|
26802
|
-
const styles =
|
|
26870
|
+
const styles = join12(dir, "styles");
|
|
26803
26871
|
let n2 = 0;
|
|
26804
26872
|
for (const url2 of stylesheetLinks(html, pageUrl, 6)) {
|
|
26805
26873
|
const res = await get(url2, "text/css,*/*;q=0.8");
|
|
26806
26874
|
if (!res?.ok) continue;
|
|
26807
26875
|
const text2 = await res.text();
|
|
26808
26876
|
if (text2.length > ICON_MAX_BYTES) continue;
|
|
26809
|
-
|
|
26810
|
-
|
|
26877
|
+
mkdirSync6(styles, { recursive: true });
|
|
26878
|
+
writeFileSync9(join12(styles, `${++n2}.css`), text2);
|
|
26811
26879
|
}
|
|
26812
26880
|
}
|
|
26813
26881
|
var TRIGGER_PAGES_CAP = 30;
|
|
@@ -26835,15 +26903,15 @@ async function hasRootFile(origin, path, query = "", cookie) {
|
|
|
26835
26903
|
const res = await get(`${origin}${path}${query}`, "*/*", "follow", cookie);
|
|
26836
26904
|
return Boolean(res?.ok && !/text\/html/i.test(res.headers.get("content-type") ?? ""));
|
|
26837
26905
|
}
|
|
26838
|
-
var tagsFile = (dir) =>
|
|
26839
|
-
var stateFile = (dir) =>
|
|
26906
|
+
var tagsFile = (dir) => join12(dir, "tags.json");
|
|
26907
|
+
var stateFile = (dir) => join12(dir, "report-state.json");
|
|
26840
26908
|
function kitMap(root) {
|
|
26841
|
-
if (!existsSync11(
|
|
26909
|
+
if (!existsSync11(join12(root, "src/kit/schema.ts"))) return {};
|
|
26842
26910
|
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(
|
|
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) => ({
|
|
26847
26915
|
key: f.key,
|
|
26848
26916
|
label: cut(f.label, 80),
|
|
26849
26917
|
...f.page ? { page: cut(f.page, 300) } : {},
|
|
@@ -26854,11 +26922,11 @@ function kitMap(root) {
|
|
|
26854
26922
|
}
|
|
26855
26923
|
async function sendReport(root, ctx, host, open2, verify) {
|
|
26856
26924
|
const dir = hostDir(root, host);
|
|
26857
|
-
const inv = readJson3(
|
|
26925
|
+
const inv = readJson3(join12(dir, "inventory.json"));
|
|
26858
26926
|
const site = readJson3(tagsFile(dir));
|
|
26859
26927
|
const startId = readChoices(root)?.startId;
|
|
26860
26928
|
if (!inv || !site) return;
|
|
26861
|
-
const dns = readJson3(
|
|
26929
|
+
const dns = readJson3(join12(dir, "dns.json"));
|
|
26862
26930
|
const thanksPages = findThanksPages(inv.pages);
|
|
26863
26931
|
if (open2 === "scan") {
|
|
26864
26932
|
if (thanksPages.length && site.forms.length) {
|
|
@@ -26888,9 +26956,9 @@ async function sendReport(root, ctx, host, open2, verify) {
|
|
|
26888
26956
|
return;
|
|
26889
26957
|
}
|
|
26890
26958
|
const state = readJson3(stateFile(dir)) ?? {};
|
|
26891
|
-
const plan = existsSync11(
|
|
26892
|
-
const saved = verify ?? readJson3(
|
|
26893
|
-
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")) ?? [];
|
|
26894
26962
|
const report2 = {
|
|
26895
26963
|
source: inv.source,
|
|
26896
26964
|
platform: inv.platform,
|
|
@@ -26943,11 +27011,11 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
26943
27011
|
const host = new URL(origin).hostname;
|
|
26944
27012
|
ensureMigrationDir(root);
|
|
26945
27013
|
const dir = hostDir(root, host);
|
|
26946
|
-
|
|
27014
|
+
mkdirSync6(dir, { recursive: true });
|
|
26947
27015
|
out(`Scanning ${base} (${platform3})`);
|
|
26948
27016
|
const robotsRes = await get(`${origin}/robots.txt`, "text/plain");
|
|
26949
27017
|
const robots = robotsRes?.ok ? await robotsRes.text() : "";
|
|
26950
|
-
if (robots)
|
|
27018
|
+
if (robots) writeFileSync9(join12(dir, "robots.txt"), robots);
|
|
26951
27019
|
const cap = Math.min(opts.max ?? PAGE_CAP, PAGE_CAP);
|
|
26952
27020
|
const fromSitemaps = await sitemapUrls(base, robots ? parseRobots(robots).sitemaps : [], cap * 5);
|
|
26953
27021
|
const all = [.../* @__PURE__ */ new Set([`${base}/`, ...fromSitemaps.urls, ...fromSitemaps.urls.length ? [] : homeLinks(html, base)])];
|
|
@@ -26987,7 +27055,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
26987
27055
|
await addStylesheetAssets(assets);
|
|
26988
27056
|
const wordpressApi = platform3 === "wordpress" ? await wordpressContent(base, dir) : false;
|
|
26989
27057
|
if (wordpressApi) {
|
|
26990
|
-
const media = readJson3(
|
|
27058
|
+
const media = readJson3(join12(dir, "content", "media.json")) ?? [];
|
|
26991
27059
|
media.forEach((m) => m.source_url && assets.add(m.source_url));
|
|
26992
27060
|
}
|
|
26993
27061
|
const known = new Set(pages.map((p) => p.path));
|
|
@@ -27012,13 +27080,13 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
27012
27080
|
const bare = registrableDomain(host);
|
|
27013
27081
|
try {
|
|
27014
27082
|
const { records, unread } = await collectSnapshot(bare, { extraNames: [...site.ownNames, ...site.serverContainers], deadlineMs: 3e4 });
|
|
27015
|
-
writeJson(
|
|
27083
|
+
writeJson(join12(dir, "dns.json"), { records: records.slice(0, 600), unread: unread.slice(0, 300), services: dnsServices(records).slice(0, 40) });
|
|
27016
27084
|
} catch {
|
|
27017
27085
|
}
|
|
27018
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) };
|
|
27019
|
-
writeJson(
|
|
27020
|
-
writeJson(
|
|
27021
|
-
|
|
27087
|
+
writeJson(join12(dir, "inventory.json"), inventory);
|
|
27088
|
+
writeJson(join12(dir, "assets.json"), [...assets].sort());
|
|
27089
|
+
writeFileSync9(join12(dir, "home.html"), html);
|
|
27022
27090
|
const icons = await saveOldIcons(html, home.url, origin, dir);
|
|
27023
27091
|
await saveOldStyles(html, home.url, dir);
|
|
27024
27092
|
const rel = relative(root, dir).split(sep).join("/");
|
|
@@ -27032,7 +27100,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
27032
27100
|
if (icons) out(` icons/ ${icons} icons and logo of the old site, for: npx deployai@latest brand favicon`);
|
|
27033
27101
|
if (wordpressApi) {
|
|
27034
27102
|
out(" content/ the WordPress pages, posts, categories, tags, media and authors as JSON");
|
|
27035
|
-
if (existsSync11(
|
|
27103
|
+
if (existsSync11(join12(dir, "posts"))) out(" posts/ the posts as Markdown for the blog block, each with its old address");
|
|
27036
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).");
|
|
27037
27105
|
out();
|
|
27038
27106
|
out("Keep every path in inventory.json exactly as it is: same address, same title and description.");
|
|
@@ -27052,8 +27120,8 @@ async function migrateMediaCommand(root) {
|
|
|
27052
27120
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27053
27121
|
for (const host of hosts) {
|
|
27054
27122
|
const dir = hostDir(root, host);
|
|
27055
|
-
const assets = readJson3(
|
|
27056
|
-
const stateFile2 =
|
|
27123
|
+
const assets = readJson3(join12(dir, "assets.json")) ?? [];
|
|
27124
|
+
const stateFile2 = join12(dir, "media-state.json");
|
|
27057
27125
|
const state = readJson3(stateFile2) ?? { done: [], failed: [], bytes: 0 };
|
|
27058
27126
|
const done = new Set(state.done);
|
|
27059
27127
|
const todo = assets.filter((a) => !done.has(a));
|
|
@@ -27072,7 +27140,7 @@ async function migrateMediaCommand(root) {
|
|
|
27072
27140
|
done.add(url2);
|
|
27073
27141
|
continue;
|
|
27074
27142
|
}
|
|
27075
|
-
|
|
27143
|
+
mkdirSync6(dirname2(target), { recursive: true });
|
|
27076
27144
|
await pipeline(Readable.fromWeb(res.body), createWriteStream(target));
|
|
27077
27145
|
const bytes = statSync2(target).size;
|
|
27078
27146
|
state.bytes += bytes;
|
|
@@ -27083,7 +27151,7 @@ async function migrateMediaCommand(root) {
|
|
|
27083
27151
|
}
|
|
27084
27152
|
state.done = [...done];
|
|
27085
27153
|
writeJson(stateFile2, state);
|
|
27086
|
-
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)` : ""}`);
|
|
27087
27155
|
}
|
|
27088
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.");
|
|
27089
27157
|
}
|
|
@@ -27104,19 +27172,19 @@ function redirectLines(inv, rss = "/rss.xml") {
|
|
|
27104
27172
|
function migratePostsCommand(root) {
|
|
27105
27173
|
const hosts = scannedHosts(root);
|
|
27106
27174
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27107
|
-
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");
|
|
27108
27176
|
const posts = [];
|
|
27109
27177
|
for (const host of hosts) {
|
|
27110
27178
|
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(
|
|
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")) ?? [] }));
|
|
27114
27182
|
}
|
|
27115
27183
|
if (!posts.length) {
|
|
27116
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.");
|
|
27117
27185
|
return;
|
|
27118
27186
|
}
|
|
27119
|
-
|
|
27187
|
+
writeFileSync9(join12(root, "src/kit/moved-posts.json"), JSON.stringify(posts.map(({ lost: _lost, ...p }) => p), null, 1));
|
|
27120
27188
|
out(`Wrote ${posts.length} posts to src/kit/moved-posts.json. Turn on blog in src/kit/site.config.ts.`);
|
|
27121
27189
|
const short = posts.filter((p) => p.lost.length);
|
|
27122
27190
|
if (short.length) {
|
|
@@ -27127,31 +27195,31 @@ function migratePostsCommand(root) {
|
|
|
27127
27195
|
function migratePagesCommand(root) {
|
|
27128
27196
|
const hosts = scannedHosts(root);
|
|
27129
27197
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27130
|
-
if (!existsSync11(
|
|
27131
|
-
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);
|
|
27132
27200
|
const before = readJson3(file2);
|
|
27133
27201
|
const pages = [];
|
|
27134
27202
|
for (const host of hosts) {
|
|
27135
27203
|
const dir = hostDir(root, host);
|
|
27136
|
-
const inv = readJson3(
|
|
27204
|
+
const inv = readJson3(join12(dir, "inventory.json"));
|
|
27137
27205
|
if (!inv) continue;
|
|
27138
|
-
const homeHtml = existsSync11(
|
|
27206
|
+
const homeHtml = existsSync11(join12(dir, "home.html")) ? readFileSync9(join12(dir, "home.html"), "utf8") : null;
|
|
27139
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);
|
|
27140
27208
|
}
|
|
27141
27209
|
const kept = before?.length ? pages.filter((p) => before.some((b) => b.path === p.path)) : pages;
|
|
27142
|
-
|
|
27210
|
+
writeFileSync9(file2, JSON.stringify(kept, null, 1));
|
|
27143
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.`);
|
|
27144
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.");
|
|
27145
27213
|
}
|
|
27146
27214
|
function migrateLegalCommand(root) {
|
|
27147
27215
|
const hosts = scannedHosts(root);
|
|
27148
27216
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27149
|
-
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");
|
|
27150
27218
|
const pages = [];
|
|
27151
27219
|
const site = emptySiteTags();
|
|
27152
27220
|
for (const host of hosts) {
|
|
27153
27221
|
const dir = hostDir(root, host);
|
|
27154
|
-
pages.push(...readJson3(
|
|
27222
|
+
pages.push(...readJson3(join12(dir, "inventory.json"))?.pages ?? []);
|
|
27155
27223
|
const found = readJson3(tagsFile(dir));
|
|
27156
27224
|
if (found) {
|
|
27157
27225
|
site.tags.push(...found.tags);
|
|
@@ -27159,9 +27227,9 @@ function migrateLegalCommand(root) {
|
|
|
27159
27227
|
site.forms.push(...found.forms);
|
|
27160
27228
|
}
|
|
27161
27229
|
}
|
|
27162
|
-
const file2 =
|
|
27230
|
+
const file2 = join12(root, MOVED_LEGAL_FILE);
|
|
27163
27231
|
const legal = { ...movedLegalFromScan({ pages, site }), docs: readJson3(file2)?.docs ?? [] };
|
|
27164
|
-
|
|
27232
|
+
writeFileSync9(file2, JSON.stringify(legal, null, 1));
|
|
27165
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.`);
|
|
27166
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.`);
|
|
27167
27235
|
out("Nothing here is finished or checked: it tells the owner what to look at. Keep tags, forms and pages as they are.");
|
|
@@ -27171,20 +27239,20 @@ function migrateRedirectsCommand(root) {
|
|
|
27171
27239
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
27172
27240
|
const lines = /* @__PURE__ */ new Set();
|
|
27173
27241
|
for (const host of hosts) {
|
|
27174
|
-
const inv = readJson3(
|
|
27242
|
+
const inv = readJson3(join12(hostDir(root, host), "inventory.json"));
|
|
27175
27243
|
if (inv) redirectLines(inv).forEach((l) => lines.add(l));
|
|
27176
27244
|
}
|
|
27177
|
-
const publicDir =
|
|
27178
|
-
const file2 =
|
|
27245
|
+
const publicDir = join12(root, "public");
|
|
27246
|
+
const file2 = join12(existsSync11(publicDir) ? publicDir : root, "_redirects");
|
|
27179
27247
|
const before = existsSync11(file2) ? readFileSync9(file2, "utf8").split(/\r?\n/).filter(Boolean) : [];
|
|
27180
27248
|
const added = [...lines].filter((l) => !before.some((b) => b.split(/\s+/)[0] === l.split(/\s+/)[0]));
|
|
27181
|
-
|
|
27249
|
+
writeFileSync9(file2, [...before, ...added].join("\n") + "\n");
|
|
27182
27250
|
out(`${relative(root, file2).split(sep).join("/")}: ${added.length} added, ${before.length + added.length} in all (at most 2,000; no query strings).`);
|
|
27183
27251
|
out('Add a line "<old path> <new path> 301" only for a page that truly could not keep its address.');
|
|
27184
27252
|
}
|
|
27185
27253
|
function allowedRedirects(root) {
|
|
27186
27254
|
const map2 = /* @__PURE__ */ new Map();
|
|
27187
|
-
for (const file2 of [
|
|
27255
|
+
for (const file2 of [join12(root, "public", "_redirects"), join12(root, "_redirects")]) {
|
|
27188
27256
|
if (!existsSync11(file2)) continue;
|
|
27189
27257
|
for (const line of readFileSync9(file2, "utf8").split(/\r?\n/)) {
|
|
27190
27258
|
const [from, to] = line.trim().split(/\s+/);
|
|
@@ -27220,7 +27288,7 @@ async function migrateTagsCommand(root, ctx, opts) {
|
|
|
27220
27288
|
for (const host of hosts) {
|
|
27221
27289
|
const dir = hostDir(root, host);
|
|
27222
27290
|
const site = readJson3(tagsFile(dir));
|
|
27223
|
-
const inv = readJson3(
|
|
27291
|
+
const inv = readJson3(join12(dir, "inventory.json"));
|
|
27224
27292
|
if (!site || !inv) continue;
|
|
27225
27293
|
const state = readJson3(stateFile(dir)) ?? {};
|
|
27226
27294
|
if (urls.length && opts.fired) {
|
|
@@ -27290,7 +27358,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
27290
27358
|
const tagFindings = [];
|
|
27291
27359
|
const perHost = [];
|
|
27292
27360
|
for (const host of hosts) {
|
|
27293
|
-
const inv = readJson3(
|
|
27361
|
+
const inv = readJson3(join12(hostDir(root, host), "inventory.json"));
|
|
27294
27362
|
const oldSite = readJson3(tagsFile(hostDir(root, host)));
|
|
27295
27363
|
const state = readJson3(stateFile(hostDir(root, host))) ?? {};
|
|
27296
27364
|
const nextSite = emptySiteTags();
|
|
@@ -27339,7 +27407,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
27339
27407
|
}
|
|
27340
27408
|
}
|
|
27341
27409
|
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 =
|
|
27410
|
+
const report2 = join12(root, MIGRATION_DIR, "verify.json");
|
|
27343
27411
|
writeJson(report2, { checkedAt: (/* @__PURE__ */ new Date()).toISOString(), preview: preview.origin, checked, findings, credits: [...credits.keys()], vendors: [...vendors.keys()], tags: tagFindings });
|
|
27344
27412
|
if (credits.size) {
|
|
27345
27413
|
out(`A builder's credit is still on the preview:`);
|
|
@@ -27364,7 +27432,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
27364
27432
|
for (const h of perHost) {
|
|
27365
27433
|
const dir = hostDir(root, h.host);
|
|
27366
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) };
|
|
27367
|
-
writeJson(
|
|
27435
|
+
writeJson(join12(dir, "verify-report.json"), { report: verify });
|
|
27368
27436
|
await sendReport(root, ctx, h.host, clean3 ? "verify" : null, verify);
|
|
27369
27437
|
}
|
|
27370
27438
|
if (!findings.length) {
|
|
@@ -27493,8 +27561,8 @@ async function askYes(question) {
|
|
|
27493
27561
|
|
|
27494
27562
|
// src/same-name.ts
|
|
27495
27563
|
import { createHash } from "crypto";
|
|
27496
|
-
import { mkdirSync as
|
|
27497
|
-
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";
|
|
27498
27566
|
var LAST_FILES = ".deployai/last-files.json";
|
|
27499
27567
|
var KEPT = /^(public|static)\/.*\.(avif|webp|png|jpe?g|gif|svg|ico|woff2?|ttf|otf|mp4|webm|css|js|mjs)$/i;
|
|
27500
27568
|
var HASHED = /[.-][A-Za-z0-9_]{6,20}\.[a-z0-9]+$/;
|
|
@@ -27504,13 +27572,13 @@ function changedUnderSameName(root, files) {
|
|
|
27504
27572
|
for (const f of files) if (KEPT.test(f.rel) && !HASHED.test(f.rel.split("/").pop() ?? "")) now[f.rel] = digest(f.abs);
|
|
27505
27573
|
let before = {};
|
|
27506
27574
|
try {
|
|
27507
|
-
before = readJson(
|
|
27575
|
+
before = readJson(join13(root, LAST_FILES));
|
|
27508
27576
|
} catch {
|
|
27509
27577
|
}
|
|
27510
27578
|
const changed = Object.keys(now).filter((rel) => before[rel] && before[rel] !== now[rel]).sort();
|
|
27511
27579
|
try {
|
|
27512
|
-
|
|
27513
|
-
|
|
27580
|
+
mkdirSync7(dirname3(join13(root, LAST_FILES)), { recursive: true });
|
|
27581
|
+
writeFileSync10(join13(root, LAST_FILES), JSON.stringify(now));
|
|
27514
27582
|
} catch {
|
|
27515
27583
|
}
|
|
27516
27584
|
return changed;
|
|
@@ -27708,14 +27776,14 @@ async function promoteWithSql(root, ctx, projectId, number4, kind, approve) {
|
|
|
27708
27776
|
function fetchStatus(ctx, projectId) {
|
|
27709
27777
|
return apiRequest(ctx, `/api/cli/status?projectId=${encodeURIComponent(projectId)}`, StatusResponse);
|
|
27710
27778
|
}
|
|
27711
|
-
var
|
|
27779
|
+
var WAIT_MS2 = 5 * 6e4;
|
|
27712
27780
|
var statusBusy = (s) => s.queue.running || s.queue.position > 0 || Boolean(s.latest?.goingLive) || s.latest?.status === "queued" || s.latest?.status === "building";
|
|
27713
27781
|
async function statusCommand(root, ctx, opts = {}) {
|
|
27714
27782
|
requireToken(ctx);
|
|
27715
27783
|
const projectId = linkedProjectId(root);
|
|
27716
27784
|
let s = await fetchStatus(ctx, projectId);
|
|
27717
27785
|
if (opts.wait) {
|
|
27718
|
-
const end = Date.now() +
|
|
27786
|
+
const end = Date.now() + WAIT_MS2;
|
|
27719
27787
|
while (statusBusy(s) && Date.now() < end) {
|
|
27720
27788
|
await new Promise((r) => setTimeout(r, opts.pollMs ?? 3e3));
|
|
27721
27789
|
s = await fetchStatus(ctx, projectId);
|
|
@@ -28200,12 +28268,12 @@ async function claimCommand(root, ctx, opts) {
|
|
|
28200
28268
|
// src/commands/pull.ts
|
|
28201
28269
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
28202
28270
|
import { existsSync as existsSync13, readdirSync as readdirSync5, rmSync as rmSync2 } from "fs";
|
|
28203
|
-
import { join as
|
|
28271
|
+
import { join as join15 } from "path";
|
|
28204
28272
|
|
|
28205
28273
|
// src/commands/samples.ts
|
|
28206
28274
|
import { createInterface as createInterface3 } from "readline/promises";
|
|
28207
|
-
import { existsSync as existsSync12, mkdirSync as
|
|
28208
|
-
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";
|
|
28209
28277
|
import { gunzipSync } from "zlib";
|
|
28210
28278
|
var SAMPLES = [
|
|
28211
28279
|
{ key: "landing", title: "Landing page: a full one-page site with WhatsApp sign-up", stack: "static HTML and CSS" },
|
|
@@ -28255,7 +28323,7 @@ async function askWhere(cwd, key, count) {
|
|
|
28255
28323
|
}
|
|
28256
28324
|
}
|
|
28257
28325
|
async function downloadSample(ctx, key, root) {
|
|
28258
|
-
|
|
28326
|
+
mkdirSync8(root, { recursive: true });
|
|
28259
28327
|
let res;
|
|
28260
28328
|
try {
|
|
28261
28329
|
res = await fetch(`${ctx.apiUrl}/samples-src/${key}.tar.gz`, {
|
|
@@ -28277,7 +28345,7 @@ function extractInto(gz, root, damaged) {
|
|
|
28277
28345
|
} catch {
|
|
28278
28346
|
throw new CliError(damaged, 1, "api");
|
|
28279
28347
|
}
|
|
28280
|
-
|
|
28348
|
+
mkdirSync8(root, { recursive: true });
|
|
28281
28349
|
const base = resolve2(root);
|
|
28282
28350
|
let written = 0;
|
|
28283
28351
|
for (const e3 of entries) {
|
|
@@ -28285,8 +28353,8 @@ function extractInto(gz, root, damaged) {
|
|
|
28285
28353
|
if (privateProjectFile(e3.name.replace(/\\/g, "/"))) continue;
|
|
28286
28354
|
const target = resolve2(base, e3.name);
|
|
28287
28355
|
if (target !== base && !target.startsWith(base + sep2)) continue;
|
|
28288
|
-
|
|
28289
|
-
|
|
28356
|
+
mkdirSync8(dirname4(target), { recursive: true });
|
|
28357
|
+
writeFileSync11(target, e3.data);
|
|
28290
28358
|
written++;
|
|
28291
28359
|
}
|
|
28292
28360
|
return written;
|
|
@@ -28310,7 +28378,7 @@ async function samplesCommand(cwd, ctx, key, opts = {}) {
|
|
|
28310
28378
|
}
|
|
28311
28379
|
const written = await downloadSample(ctx, sample.key, root);
|
|
28312
28380
|
const base = resolve2(root);
|
|
28313
|
-
const hasPackage = existsSync12(
|
|
28381
|
+
const hasPackage = existsSync12(join14(base, "package.json"));
|
|
28314
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.`);
|
|
28315
28383
|
out("");
|
|
28316
28384
|
const t = messages(base);
|
|
@@ -28367,7 +28435,7 @@ var git = (root, args, env = {}) => spawnSync2("git", args, { cwd: root, encodin
|
|
|
28367
28435
|
function clearTree(root) {
|
|
28368
28436
|
for (const name of readdirSync5(root)) {
|
|
28369
28437
|
if (name === ".git" || name === ".deployai") continue;
|
|
28370
|
-
rmSync2(
|
|
28438
|
+
rmSync2(join15(root, name), { recursive: true, force: true });
|
|
28371
28439
|
}
|
|
28372
28440
|
}
|
|
28373
28441
|
async function pullHistory(root, ctx, projectId) {
|
|
@@ -28377,7 +28445,7 @@ async function pullHistory(root, ctx, projectId) {
|
|
|
28377
28445
|
const live = versions.find((v) => v.isLive)?.number ?? Math.max(0, ...versions.filter((v) => v.status === "ready").map((v) => v.number));
|
|
28378
28446
|
const chosen = versions.filter((v) => v.number <= live && v.status !== "failed" && v.status !== "queued").sort((a, b) => a.number - b.number);
|
|
28379
28447
|
if (!chosen.length) throw new CliError(t("pullNoSource"), 1, "not_found");
|
|
28380
|
-
if (!existsSync13(
|
|
28448
|
+
if (!existsSync13(join15(root, ".git")) && git(root, ["init", "-q"]).status !== 0) throw new CliError(t("pullNoGit"), 1, "usage");
|
|
28381
28449
|
for (const v of chosen) {
|
|
28382
28450
|
const gz = await fetchSource(root, ctx, projectId, v.number).catch(() => null);
|
|
28383
28451
|
if (!gz) continue;
|
|
@@ -28431,46 +28499,6 @@ import { spawnSync as spawnSync3 } from "child_process";
|
|
|
28431
28499
|
import { existsSync as existsSync14, writeFileSync as writeFileSync13 } from "fs";
|
|
28432
28500
|
import { join as join17, relative as relative3, resolve as resolve3 } from "path";
|
|
28433
28501
|
|
|
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;
|
|
28473
|
-
|
|
28474
28502
|
// src/commands/starter.ts
|
|
28475
28503
|
import { writeFileSync as writeFileSync12 } from "fs";
|
|
28476
28504
|
import { join as join16 } from "path";
|
|
@@ -28583,7 +28611,9 @@ async function startCommand(cwd, ctx, id, opts = {}) {
|
|
|
28583
28611
|
const starter = (kind === "new" || kind === "guest") && !sample && empty;
|
|
28584
28612
|
const signedIn = Boolean(choices.projectId && tokenIfOwnApi(ctxNow));
|
|
28585
28613
|
const pullNow = update && empty && signedIn;
|
|
28586
|
-
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);
|
|
28587
28617
|
const inClaude = process.env.CLAUDECODE === "1";
|
|
28588
28618
|
if (ctxNow.config.sound === void 0) {
|
|
28589
28619
|
if (inClaude) steps.unshift(ASK_SOUND_TERMINAL_STEP);
|
|
@@ -28629,7 +28659,7 @@ ${choices.brief}
|
|
|
28629
28659
|
updateProject(root, { stack: choices.stack });
|
|
28630
28660
|
done.push(t("startStack", { stack: stackSummary(choices.stack) }));
|
|
28631
28661
|
}
|
|
28632
|
-
const init = runInit(root);
|
|
28662
|
+
const init = runInit(root, { texts: initTexts(server) });
|
|
28633
28663
|
if (init.created.includes("DEPLOYAI.md") || init.rulesAdded) done.push(t("startRules"));
|
|
28634
28664
|
if (choices.projectId) {
|
|
28635
28665
|
const before = readProject(root);
|
|
@@ -28667,7 +28697,6 @@ ${choices.brief}
|
|
|
28667
28697
|
say("Then, in this order:");
|
|
28668
28698
|
steps.forEach((s, i) => say(`${i + 1}. ${s.cmd ? `Run ${s.cmd}. ` : ""}${s.say}`));
|
|
28669
28699
|
say();
|
|
28670
|
-
const server = await serverRules(ctx.apiUrl);
|
|
28671
28700
|
const lang = langOf(choices.ownerLanguage);
|
|
28672
28701
|
say(rule(server, `runCommands.${lang}`, runCommandsRule(lang)));
|
|
28673
28702
|
say(rule(server, "modelFlag", MODEL_FLAG_RULE));
|
|
@@ -29865,7 +29894,7 @@ function buildProgram() {
|
|
|
29865
29894
|
const g = (cmd) => cmd.optsWithGlobals();
|
|
29866
29895
|
const root = (cmd) => resolve8(g(cmd).dir ?? process.cwd());
|
|
29867
29896
|
const ctx = (cmd) => apiContext(g(cmd).api);
|
|
29868
|
-
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));
|
|
29869
29898
|
program.command("inspect").description("show framework, package manager, language, database, storage").option("--json", "machine readable output").action((opts, cmd) => inspectCommand(root(cmd), opts));
|
|
29870
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) => {
|
|
29871
29900
|
const a = await runCheck(root(cmd), ctx(cmd), opts);
|