deployai 0.1.0-beta.20 → 0.1.0-beta.21
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/README.md +1 -0
- package/dist/index.js +1007 -83
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21665,6 +21665,29 @@ function parseRobots(text) {
|
|
|
21665
21665
|
return { groups, sitemaps };
|
|
21666
21666
|
}
|
|
21667
21667
|
|
|
21668
|
+
// ../shared/src/rtl-audit.ts
|
|
21669
|
+
function stylesheetLinks(html, pageUrl, max = 4) {
|
|
21670
|
+
let host = "";
|
|
21671
|
+
try {
|
|
21672
|
+
host = new URL(pageUrl).host.replace(/^www\./, "");
|
|
21673
|
+
} catch {
|
|
21674
|
+
return [];
|
|
21675
|
+
}
|
|
21676
|
+
const own2 = [];
|
|
21677
|
+
const other = [];
|
|
21678
|
+
for (const t of tags(html, "link")) {
|
|
21679
|
+
if (!/(^|\s)stylesheet(\s|$)/i.test(t.attrs.rel ?? "") || !t.attrs.href) continue;
|
|
21680
|
+
try {
|
|
21681
|
+
const u = new URL(decode3(t.attrs.href), pageUrl);
|
|
21682
|
+
if (!/^https?:$/.test(u.protocol) || /(^|\.)fonts\.googleapis\.com$/i.test(u.hostname)) continue;
|
|
21683
|
+
const list = u.host.replace(/^www\./, "") === host ? own2 : other;
|
|
21684
|
+
if (!list.includes(u.toString())) list.push(u.toString());
|
|
21685
|
+
} catch {
|
|
21686
|
+
}
|
|
21687
|
+
}
|
|
21688
|
+
return [...own2, ...other].slice(0, max);
|
|
21689
|
+
}
|
|
21690
|
+
|
|
21668
21691
|
// ../shared/src/plan-copy.ts
|
|
21669
21692
|
var PLAN_FEATURES = [
|
|
21670
21693
|
{ key: "sites", limit: "maxSites" },
|
|
@@ -21695,6 +21718,7 @@ var CHECK = { cmd: "npx deployai@latest check", say: "Fix every blocker it lists
|
|
|
21695
21718
|
var DEPLOY_ASK_RULE = 'Never deploy on your own, and never after each small edit: every deploy is a full build. Deploy only when what the owner asked for is done. Then say in short what changed and ask: "Put it live, see a preview first, or not yet?" Put it live: deploy with --live. Preview first: deploy without it and send the owner the preview address. Not yet: keep working, and the next change goes up in the same deploy. If the owner said to always put changes live, deploy with --live without asking. Database changes still get their own yes.';
|
|
21696
21719
|
var ASK = { say: DEPLOY_ASK_RULE };
|
|
21697
21720
|
var GUEST_ASK = { say: 'Deploy only when what the owner asked for is done. Say in short what you made and ask: "Put it up now, or not yet?" On Not yet, keep working and ask again when the next request is done.' };
|
|
21721
|
+
var FAVICON = { cmd: "npx deployai@latest brand favicon", say: "Gives the site an icon if it has none, made from the site itself: the old site's icon, else its logo, else the first letter of its name in its own color. Add the head lines it prints to every page. It changes nothing when the site has an icon." };
|
|
21698
21722
|
var LOGIN = { cmd: "npx deployai@latest login", say: "The owner approves it in the browser window it opens." };
|
|
21699
21723
|
var PROMOTE = { cmd: "npx deployai@latest promote v<N>", say: "Only when deploy ran without --live, and only after the owner approves the preview. N is the version number deploy printed. Then give the owner the live address." };
|
|
21700
21724
|
var DEPLOY_SAY = "Add --live only if the owner chose to put it live right away. It waits for the build: with --live it ends with the live address, else with the preview address to send the owner. When it prints database changes, a yes to going live does not cover them (D-541): show the owner the changes and ask the question it prints, and only after a yes run the promote --approve-sql command it printed; changes it says remove data only the owner approves, never you. Write the -m message in a few words in the language of the owner, about what they see changed.";
|
|
@@ -21703,6 +21727,8 @@ var MIGRATE_STEPS = [
|
|
|
21703
21727
|
{ cmd: "npx deployai@latest blocks inbox", say: "Only if the old site has a contact or quote form: the form with its own messages page for the owner." },
|
|
21704
21728
|
{ cmd: "npx deployai@latest blocks blog", say: "Only if the old site has posts, news or articles: the blog, with the posts as Markdown files." },
|
|
21705
21729
|
{ cmd: "npx deployai@latest migrate media", say: "Downloads the old site's images and files into .deployai/migration/media; run it again if it stops, it goes on where it stopped. Move the files the new pages use into the site." },
|
|
21730
|
+
FAVICON,
|
|
21731
|
+
{ cmd: "npx deployai@latest brand images <the old site address> <one address of each kind of page>", say: "Measures every image against where it shows and changes nothing. Add each weak one to .deployai/migration/plan.md as Needs me, with what it shows. A move keeps the images as they are: only the owner chooses to replace one, and a photo of a real person, product or place is never replaced with a made up one." },
|
|
21706
21732
|
{ ...CHECK },
|
|
21707
21733
|
LOGIN,
|
|
21708
21734
|
{ 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." },
|
|
@@ -21716,11 +21742,11 @@ var MIGRATE_STEPS = [
|
|
|
21716
21742
|
var managedStatus = (stage, note, say) => ({ cmd: `npx deployai@latest migrate status ${stage} "${note}"`, say });
|
|
21717
21743
|
var MANAGED_STEPS = [
|
|
21718
21744
|
managedStatus("building", "<what is done>", "First, once the plan in .deployai/migration/plan.md is agreed: the request shows the build started."),
|
|
21719
|
-
...MIGRATE_STEPS.slice(0,
|
|
21745
|
+
...MIGRATE_STEPS.slice(0, 11),
|
|
21720
21746
|
managedStatus("preview_ready", "<preview address>", "The owner gets an email with the preview address."),
|
|
21721
|
-
...MIGRATE_STEPS.slice(
|
|
21747
|
+
...MIGRATE_STEPS.slice(11, 13),
|
|
21722
21748
|
managedStatus("live", "<live address>", "Only after it is live. Then the team transfers the site to the owner."),
|
|
21723
|
-
...MIGRATE_STEPS.slice(
|
|
21749
|
+
...MIGRATE_STEPS.slice(13)
|
|
21724
21750
|
];
|
|
21725
21751
|
var PULL = { cmd: "npx deployai@latest pull", say: "This folder was empty, so it downloads the code of the live site first. Work on that code." };
|
|
21726
21752
|
function startSteps(kind, opts = {}) {
|
|
@@ -21729,13 +21755,14 @@ function startSteps(kind, opts = {}) {
|
|
|
21729
21755
|
function stepsOf(kind, opts) {
|
|
21730
21756
|
switch (kind) {
|
|
21731
21757
|
case "new":
|
|
21732
|
-
return [...opts.starter ? [BUILD] : [], CHECK, ASK, LOGIN, { cmd: 'npx deployai@latest deploy -m "first version"', say: DEPLOY_SAY }, PROMOTE];
|
|
21758
|
+
return [...opts.starter ? [BUILD] : [], FAVICON, CHECK, ASK, LOGIN, { cmd: 'npx deployai@latest deploy -m "first version"', say: DEPLOY_SAY }, PROMOTE];
|
|
21733
21759
|
case "update": {
|
|
21734
21760
|
const deploy = { cmd: 'npx deployai@latest deploy -m "<what changed, in a few words>"', say: DEPLOY_SAY };
|
|
21735
21761
|
return opts.emptyFolder ? [LOGIN, PULL, CHECK, ASK, deploy, PROMOTE] : [CHECK, ASK, LOGIN, deploy, PROMOTE];
|
|
21736
21762
|
}
|
|
21737
21763
|
case "move":
|
|
21738
21764
|
return [
|
|
21765
|
+
FAVICON,
|
|
21739
21766
|
CHECK,
|
|
21740
21767
|
ASK,
|
|
21741
21768
|
LOGIN,
|
|
@@ -21748,6 +21775,7 @@ function stepsOf(kind, opts) {
|
|
|
21748
21775
|
case "guest":
|
|
21749
21776
|
return [
|
|
21750
21777
|
...opts.starter ? [BUILD] : [],
|
|
21778
|
+
FAVICON,
|
|
21751
21779
|
{ ...CHECK, say: "Fix every blocker it lists, then run it again until it shows none. If the site needs environment variables, secrets, file storage or sending email, never stop building for it: tell the owner once, in one plain line, that putting those parts live needs a free account (one link, about a minute), keep building what they asked, and ask about the account only at the deploy step." },
|
|
21752
21780
|
GUEST_ASK,
|
|
21753
21781
|
{ cmd: "npx deployai@latest deploy --guest", say: "It prints the address, the claim link and any owner keys." },
|
|
@@ -21776,6 +21804,7 @@ var CLI_MAP_NODES = [
|
|
|
21776
21804
|
n("cmd-start", "cli", "start <id>", "\u05DE\u05DB\u05D9\u05DF \u05D0\u05EA \u05D4\u05EA\u05D9\u05E7\u05D9\u05D9\u05D4 \u05DC\u05E4\u05D9 \u05DB\u05DC \u05D4\u05D1\u05D7\u05D9\u05E8\u05D5\u05EA: \u05EA\u05D9\u05E7\u05D9\u05D9\u05D4, \u05D3\u05D5\u05D2\u05DE\u05D4 \u05D5\u05D4\u05EA\u05E7\u05E0\u05D4, \u05E7\u05D5\u05D1\u05E5 \u05D4\u05E4\u05E8\u05D8\u05D9\u05DD \u05D5\u05D7\u05D9\u05D1\u05D5\u05E8 \u05DC\u05D0\u05EA\u05E8. \u05DE\u05D3\u05E4\u05D9\u05E1 \u05DC\u05E1\u05D5\u05DB\u05DF \u05D0\u05EA \u05D4\u05D8\u05E7\u05E1\u05D8 \u05D5\u05D0\u05EA \u05D4\u05E4\u05E7\u05D5\u05D3\u05D5\u05EA.", "Prepares the folder with every choice: folder, sample and install, the details file and the site link. Prints the text and the commands for the agent."),
|
|
21777
21805
|
n("cmd-migrate", "cli", "migrate scan / media / redirects / verify / status", "\u05D4\u05D0\u05EA\u05E8 \u05D4\u05D9\u05E9\u05DF: \u05E1\u05E8\u05D9\u05E7\u05EA \u05D4\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05D5\u05D4\u05EA\u05D5\u05DB\u05DF, \u05D4\u05D5\u05E8\u05D3\u05EA \u05D4\u05E7\u05D1\u05E6\u05D9\u05DD, \u05D4\u05E4\u05E0\u05D9\u05D5\u05EA 301 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E9\u05DC\u05D0 \u05E0\u05E9\u05D0\u05E8\u05D5, \u05D5\u05D1\u05D3\u05D9\u05E7\u05D4 \u05E9\u05DB\u05DC \u05DB\u05EA\u05D5\u05D1\u05EA \u05D9\u05E9\u05E0\u05D4 \u05E0\u05E4\u05EA\u05D7\u05EA \u05D1\u05EA\u05E6\u05D5\u05D2\u05D4 \u05D4\u05DE\u05E7\u05D3\u05D9\u05DE\u05D4.", "The old site: scan its addresses and content, download its files, 301s for addresses that could not stay, and a check that every old address opens on the preview."),
|
|
21778
21806
|
n("cmd-blocks", "cli", "blocks [name]", "\u05D0\u05D1\u05E0\u05D9 \u05D1\u05E0\u05D9\u05D9\u05DF \u05E9\u05DC\u05E0\u05D5 \u05DC\u05D0\u05EA\u05E8 \u05E7\u05D9\u05D9\u05DD: inbox (\u05D8\u05D5\u05E4\u05E1 \u05D5\u05E2\u05DE\u05D5\u05D3 \u05D4\u05D5\u05D3\u05E2\u05D5\u05EA \u05DC\u05D1\u05E2\u05DC\u05D9\u05DD), blog. \u05DC\u05D0 \u05D3\u05D5\u05E8\u05E1 \u05E7\u05D1\u05E6\u05D9\u05DD.", "Our building blocks for an existing site: inbox (form and owner messages page), blog. Never writes over files."),
|
|
21807
|
+
n("cmd-brand", "cli", "brand favicon / icons / images", "\u05D4\u05D0\u05D9\u05D9\u05E7\u05D5\u05E0\u05D9\u05DD \u05D5\u05EA\u05DE\u05D5\u05E0\u05EA \u05D4\u05E9\u05D9\u05EA\u05D5\u05E3 \u05E0\u05D5\u05E6\u05E8\u05D9\u05DD \u05D1\u05E7\u05D5\u05D3 \u05DE\u05D4\u05D0\u05EA\u05E8 \u05E2\u05E6\u05DE\u05D5: \u05D4\u05E9\u05DD, \u05D4\u05E6\u05D1\u05E2\u05D9\u05DD \u05D5\u05D4\u05DC\u05D5\u05D2\u05D5. favicon \u05D7\u05D9\u05E0\u05DD \u05DC\u05DB\u05DC \u05D0\u05EA\u05E8, \u05E1\u05D8 \u05DE\u05DC\u05D0, \u05D5\u05D3\u05D5\u05D7 \u05EA\u05DE\u05D5\u05E0\u05D5\u05EA \u05D7\u05DC\u05E9\u05D5\u05EA \u05DC\u05E4\u05D9 \u05DE\u05D3\u05D9\u05D3\u05D4. \u05DC\u05D0 \u05DE\u05D7\u05DC\u05D9\u05E3 \u05EA\u05DE\u05D5\u05E0\u05D4 \u05DC\u05D1\u05D3.", "The site's icons and share image, made by code from the site itself: its name, colors and logo. A free favicon for every site, the full set, and a measured report of weak images. Never replaces an image by itself."),
|
|
21779
21808
|
n("cmd-samples", "cli", "samples [key]", "\u05E8\u05E9\u05D9\u05DE\u05EA \u05D4\u05D3\u05D5\u05D2\u05DE\u05D0\u05D5\u05EA, \u05D0\u05D5 \u05D4\u05D5\u05E8\u05D3\u05D4 \u05E9\u05DC \u05D0\u05D7\u05EA.", "Lists the samples, or downloads one."),
|
|
21780
21809
|
n("cmd-check", "cli", "check", "\u05D4\u05D0\u05DD \u05D4\u05E4\u05E8\u05D5\u05D9\u05E7\u05D8 \u05D9\u05DB\u05D5\u05DC \u05DC\u05E8\u05D5\u05E5 \u05D0\u05E6\u05DC\u05E0\u05D5: \u05D7\u05D5\u05E1\u05DE\u05D9\u05DD \u05D5\u05D0\u05D6\u05D4\u05E8\u05D5\u05EA, \u05E2\u05DD \u05E4\u05E8\u05D5\u05DE\u05E4\u05D8 \u05EA\u05D9\u05E7\u05D5\u05DF.", "Can the project run on our hosting: blockers and warnings, with a fix prompt."),
|
|
21781
21810
|
n("cmd-init", "cli", "init", "\u05D9\u05D5\u05E6\u05E8 DEPLOYAI.md \u05E2\u05DD \u05D4\u05DB\u05DC\u05DC\u05D9\u05DD \u05DC\u05E1\u05D5\u05DB\u05DF, \u05E9\u05D5\u05E8\u05D4 \u05D0\u05DC\u05D9\u05D5 \u05D1 AGENTS.md \u05D5 CLAUDE.md, \u05D5 .deployai/project.json. \u05E8\u05D0\u05E9\u05D5\u05DF \u05D1\u05E4\u05E8\u05D5\u05D9\u05E7\u05D8 \u05D7\u05D3\u05E9.", "Creates DEPLOYAI.md with the agent rules, a line to it in AGENTS.md and CLAUDE.md, and .deployai/project.json. First in a new project."),
|
|
@@ -21866,6 +21895,7 @@ var CLI_MAP_EDGES = [
|
|
|
21866
21895
|
e("cmd-sql", "api-sql"),
|
|
21867
21896
|
e("cmd-deploy", "api-sql"),
|
|
21868
21897
|
e("cmd-rollback", "api-promote"),
|
|
21898
|
+
e("cmd-start", "cmd-brand"),
|
|
21869
21899
|
e("page-move-url", "cmd-start"),
|
|
21870
21900
|
e("cmd-start", "text-migrate"),
|
|
21871
21901
|
e("cmd-start", "cmd-migrate"),
|
|
@@ -22095,6 +22125,8 @@ var BUILD_WITH = [
|
|
|
22095
22125
|
"Uploaded files and images: Cloudflare R2 (object storage), never the local disk.",
|
|
22096
22126
|
"Settings and secrets: environment variables, set with: npx deployai@latest env set <key>",
|
|
22097
22127
|
"Images: resize at build time or serve them as they are; no native image modules at runtime.",
|
|
22128
|
+
// D-616: an icon is part of a finished site, and the command keeps one the site has.
|
|
22129
|
+
"Icon: every site has one. npx deployai@latest brand favicon keeps the one it has, or makes one from the site itself: its logo, or the first letter of its name in its own color.",
|
|
22098
22130
|
"Passwords: bcryptjs or Web Crypto, never native bcrypt.",
|
|
22099
22131
|
"Server code runs per request: no long-running processes, background servers or child processes.",
|
|
22100
22132
|
// D-611: Durable Objects run when the site's own code exports them; D1 stays the default, they cost more for plain data.
|
|
@@ -22239,10 +22271,10 @@ function normalizeSourceUrl(raw) {
|
|
|
22239
22271
|
u.hash = "";
|
|
22240
22272
|
return u.pathname === "/" && !u.search ? u.origin : u.toString();
|
|
22241
22273
|
}
|
|
22242
|
-
function parseSitemapXml(
|
|
22274
|
+
function parseSitemapXml(xml2) {
|
|
22243
22275
|
const locs = (block) => [...block.matchAll(/<loc>\s*([\s\S]*?)\s*<\/loc>/gi)].map((m) => decode3(m[1].replace(/^<!\[CDATA\[|\]\]>$/g, "")).trim()).filter(Boolean);
|
|
22244
|
-
const sitemaps = [...
|
|
22245
|
-
const urls = [...
|
|
22276
|
+
const sitemaps = [...xml2.matchAll(/<sitemap\b[^>]*>([\s\S]*?)<\/sitemap>/gi)].flatMap((m) => locs(m[1]));
|
|
22277
|
+
const urls = [...xml2.matchAll(/<url\b[^>]*>([\s\S]*?)<\/url>/gi)].flatMap((m) => locs(m[1]));
|
|
22246
22278
|
return { urls, sitemaps };
|
|
22247
22279
|
}
|
|
22248
22280
|
function detectPlatform(html, headers = {}) {
|
|
@@ -22344,6 +22376,244 @@ var enc2 = new TextEncoder();
|
|
|
22344
22376
|
// ../shared/src/app-gate.ts
|
|
22345
22377
|
var enc3 = new TextEncoder();
|
|
22346
22378
|
|
|
22379
|
+
// ../shared/src/brand.ts
|
|
22380
|
+
var ICO_SIZES = [32, 48];
|
|
22381
|
+
var ICO_TARGETS = ICO_SIZES.map((s) => ({ file: `ico-${s}.png`, width: s, height: s, icoOnly: true }));
|
|
22382
|
+
var FAVICON_TARGETS = [
|
|
22383
|
+
...ICO_TARGETS,
|
|
22384
|
+
{ file: "apple-touch-icon.png", width: 180, height: 180, opaque: true, pad: 0.1 }
|
|
22385
|
+
];
|
|
22386
|
+
var BRAND_TARGETS = [
|
|
22387
|
+
...FAVICON_TARGETS,
|
|
22388
|
+
{ file: "favicon-96x96.png", width: 96, height: 96 },
|
|
22389
|
+
{ file: "icon-192.png", width: 192, height: 192 },
|
|
22390
|
+
{ file: "icon-512.png", width: 512, height: 512 },
|
|
22391
|
+
{ file: "icon-maskable-512.png", width: 512, height: 512, opaque: true, pad: 0.2 },
|
|
22392
|
+
{ file: "og-image.png", width: 1200, height: 630, opaque: true, og: true }
|
|
22393
|
+
];
|
|
22394
|
+
var BRAND_FILES = ["favicon.ico", "favicon.svg", "site.webmanifest", ...BRAND_TARGETS.filter((t) => !t.icoOnly).map((t) => t.file)];
|
|
22395
|
+
function canDraw(target, source) {
|
|
22396
|
+
if (source.vector || target.og) return true;
|
|
22397
|
+
return Math.max(target.width, target.height) <= Math.max(source.width, source.height) * 2;
|
|
22398
|
+
}
|
|
22399
|
+
var xml = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
22400
|
+
function letterTileSvg(name, color) {
|
|
22401
|
+
const letter = [...name.trim()][0]?.toLocaleUpperCase() ?? "S";
|
|
22402
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="14" fill="${xml(color)}"/><text x="32" y="33" font-family="system-ui,Arial,sans-serif" font-size="38" font-weight="700" fill="${contrastInk(color)}" text-anchor="middle" dominant-baseline="central">${xml(letter)}</text></svg>
|
|
22403
|
+
`;
|
|
22404
|
+
}
|
|
22405
|
+
function contrastInk(color) {
|
|
22406
|
+
const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color);
|
|
22407
|
+
if (!m) return "#FFFFFF";
|
|
22408
|
+
const [r, g, b] = [m[1], m[2], m[3]].map((h) => parseInt(h, 16));
|
|
22409
|
+
return 0.299 * r + 0.587 * g + 0.114 * b > 150 ? "#0A0A0A" : "#FFFFFF";
|
|
22410
|
+
}
|
|
22411
|
+
var BRAND_DEFAULT_COLOR = "#111827";
|
|
22412
|
+
function webManifest(name, color) {
|
|
22413
|
+
return `${JSON.stringify({
|
|
22414
|
+
name,
|
|
22415
|
+
short_name: name.slice(0, 12),
|
|
22416
|
+
icons: [
|
|
22417
|
+
{ src: "/icon-192.png", sizes: "192x192", type: "image/png" },
|
|
22418
|
+
{ src: "/icon-512.png", sizes: "512x512", type: "image/png" },
|
|
22419
|
+
{ src: "/icon-maskable-512.png", sizes: "512x512", type: "image/png", purpose: "maskable" }
|
|
22420
|
+
],
|
|
22421
|
+
theme_color: color,
|
|
22422
|
+
background_color: color,
|
|
22423
|
+
display: "browser"
|
|
22424
|
+
}, null, 2)}
|
|
22425
|
+
`;
|
|
22426
|
+
}
|
|
22427
|
+
function brandHeadTags(files) {
|
|
22428
|
+
const has = (f) => files.includes(f);
|
|
22429
|
+
return [
|
|
22430
|
+
has("favicon.ico") ? '<link rel="icon" href="/favicon.ico" sizes="48x48">' : "",
|
|
22431
|
+
has("favicon.svg") ? '<link rel="icon" href="/favicon.svg" type="image/svg+xml">' : "",
|
|
22432
|
+
has("favicon-96x96.png") ? '<link rel="icon" href="/favicon-96x96.png" type="image/png" sizes="96x96">' : "",
|
|
22433
|
+
has("apple-touch-icon.png") ? '<link rel="apple-touch-icon" href="/apple-touch-icon.png">' : "",
|
|
22434
|
+
has("site.webmanifest") ? '<link rel="manifest" href="/site.webmanifest">' : "",
|
|
22435
|
+
has("og-image.png") ? '<meta property="og:image" content="<the site address>/og-image.png">' : "",
|
|
22436
|
+
has("og-image.png") ? '<meta property="og:image:width" content="1200">' : "",
|
|
22437
|
+
has("og-image.png") ? '<meta property="og:image:height" content="630">' : ""
|
|
22438
|
+
].filter(Boolean);
|
|
22439
|
+
}
|
|
22440
|
+
function buildIco(images) {
|
|
22441
|
+
const headerSize = 6 + images.length * 16;
|
|
22442
|
+
const out2 = new Uint8Array(headerSize + images.reduce((n2, i) => n2 + i.png.length, 0));
|
|
22443
|
+
const view = new DataView(out2.buffer);
|
|
22444
|
+
view.setUint16(2, 1, true);
|
|
22445
|
+
view.setUint16(4, images.length, true);
|
|
22446
|
+
let offset = headerSize;
|
|
22447
|
+
images.forEach((img, i) => {
|
|
22448
|
+
const at = 6 + i * 16;
|
|
22449
|
+
out2[at] = img.size >= 256 ? 0 : img.size;
|
|
22450
|
+
out2[at + 1] = img.size >= 256 ? 0 : img.size;
|
|
22451
|
+
view.setUint16(at + 4, 1, true);
|
|
22452
|
+
view.setUint16(at + 6, 32, true);
|
|
22453
|
+
view.setUint32(at + 8, img.png.length, true);
|
|
22454
|
+
view.setUint32(at + 12, offset, true);
|
|
22455
|
+
out2.set(img.png, offset);
|
|
22456
|
+
offset += img.png.length;
|
|
22457
|
+
});
|
|
22458
|
+
return out2;
|
|
22459
|
+
}
|
|
22460
|
+
function imageSize(b) {
|
|
22461
|
+
const v = new DataView(b.buffer, b.byteOffset, b.byteLength);
|
|
22462
|
+
const ascii = (at, n2) => String.fromCharCode(...b.subarray(at, at + n2));
|
|
22463
|
+
if (b.length >= 24 && b[0] === 137 && ascii(1, 3) === "PNG") return { width: v.getUint32(16), height: v.getUint32(20), format: "png" };
|
|
22464
|
+
if (b.length >= 10 && ascii(0, 3) === "GIF") return { width: v.getUint16(6, true), height: v.getUint16(8, true), format: "gif" };
|
|
22465
|
+
if (b.length >= 22 && v.getUint16(0, true) === 0 && v.getUint16(2, true) === 1 && v.getUint16(4, true) > 0) {
|
|
22466
|
+
let best = 0;
|
|
22467
|
+
const count = v.getUint16(4, true);
|
|
22468
|
+
for (let i = 0; i < count && 6 + i * 16 < b.length; i++) best = Math.max(best, b[6 + i * 16] || 256);
|
|
22469
|
+
return { width: best, height: best, format: "ico" };
|
|
22470
|
+
}
|
|
22471
|
+
if (b.length >= 30 && ascii(0, 4) === "RIFF" && ascii(8, 4) === "WEBP") {
|
|
22472
|
+
const kind = ascii(12, 4);
|
|
22473
|
+
if (kind === "VP8X") return { width: 1 + (b[24] | b[25] << 8 | b[26] << 16), height: 1 + (b[27] | b[28] << 8 | b[29] << 16), format: "webp" };
|
|
22474
|
+
if (kind === "VP8 ") return { width: v.getUint16(26, true) & 16383, height: v.getUint16(28, true) & 16383, format: "webp" };
|
|
22475
|
+
if (kind === "VP8L") {
|
|
22476
|
+
const bits = v.getUint32(21, true);
|
|
22477
|
+
return { width: (bits & 16383) + 1, height: (bits >> 14 & 16383) + 1, format: "webp" };
|
|
22478
|
+
}
|
|
22479
|
+
return null;
|
|
22480
|
+
}
|
|
22481
|
+
if (b.length >= 4 && b[0] === 255 && b[1] === 216) {
|
|
22482
|
+
let at = 2;
|
|
22483
|
+
while (at + 9 < b.length) {
|
|
22484
|
+
if (b[at] !== 255) {
|
|
22485
|
+
at++;
|
|
22486
|
+
continue;
|
|
22487
|
+
}
|
|
22488
|
+
const marker = b[at + 1];
|
|
22489
|
+
if (marker === 255) {
|
|
22490
|
+
at++;
|
|
22491
|
+
continue;
|
|
22492
|
+
}
|
|
22493
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) return { width: v.getUint16(at + 7), height: v.getUint16(at + 5), format: "jpeg" };
|
|
22494
|
+
at += 2 + v.getUint16(at + 2);
|
|
22495
|
+
}
|
|
22496
|
+
}
|
|
22497
|
+
return null;
|
|
22498
|
+
}
|
|
22499
|
+
var IMAGE_MIN_DENSITY = 1.5;
|
|
22500
|
+
var IMAGE_SMALL_WIDTH = 400;
|
|
22501
|
+
var JPEG_MIN_BYTES_PER_PIXEL = 0.04;
|
|
22502
|
+
var IMAGE_IGNORE_UNDER = 96;
|
|
22503
|
+
function judgeImage(img) {
|
|
22504
|
+
if (img.shownWidth !== void 0) {
|
|
22505
|
+
if (img.shownWidth < IMAGE_IGNORE_UNDER) return "ok";
|
|
22506
|
+
if (img.width < img.shownWidth * IMAGE_MIN_DENSITY) return "soft";
|
|
22507
|
+
} else if (img.width >= IMAGE_IGNORE_UNDER && img.width < IMAGE_SMALL_WIDTH) {
|
|
22508
|
+
return "small";
|
|
22509
|
+
}
|
|
22510
|
+
if (img.format === "jpeg" && img.bytes !== void 0 && img.width >= IMAGE_SMALL_WIDTH && img.bytes / (img.width * img.height) < JPEG_MIN_BYTES_PER_PIXEL) return "compressed";
|
|
22511
|
+
return "ok";
|
|
22512
|
+
}
|
|
22513
|
+
function looksLikeLogo(path) {
|
|
22514
|
+
return /(^|[/_.-])logo([/_.-]|\d|$)/i.test(path) && /\.(svg|png|webp|jpe?g)(\?|$)/i.test(path);
|
|
22515
|
+
}
|
|
22516
|
+
var decode4 = (s) => s.replace(/&/g, "&").replace(/"/g, '"').replace(/�?39;|'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/\s+/g, " ").trim();
|
|
22517
|
+
function metaContent2(html, attr, key) {
|
|
22518
|
+
for (const m of html.matchAll(/<meta\b[^>]*>/gi)) {
|
|
22519
|
+
if (!new RegExp(`\\s${attr}=["']${key}["']`, "i").test(m[0])) continue;
|
|
22520
|
+
const v = m[0].match(/\scontent=["']([^"']*)/i)?.[1];
|
|
22521
|
+
if (v) return decode4(v);
|
|
22522
|
+
}
|
|
22523
|
+
return null;
|
|
22524
|
+
}
|
|
22525
|
+
function readSiteIdentity(html) {
|
|
22526
|
+
const title = decode4(html.match(/<title[^>]*>([^<]*)/i)?.[1] ?? "");
|
|
22527
|
+
const fromTitle = title.split(/\s[|\-\u2013\u2014\u00b7:]\s/).map((s) => s.trim()).filter((s) => s && !/^(home|home ?page|welcome|main|בית|דף הבית|ראשי|עמוד הבית|ברוכים הבאים)$/i.test(s)).sort((a, b) => a.length - b.length)[0] ?? null;
|
|
22528
|
+
const description = metaContent2(html, "name", "description") ?? metaContent2(html, "property", "og:description");
|
|
22529
|
+
return { name: metaContent2(html, "property", "og:site_name") ?? fromTitle, line: description ? shareLine(description) : null, themeColor: metaContent2(html, "name", "theme-color") };
|
|
22530
|
+
}
|
|
22531
|
+
function shareLine(text, max = 70) {
|
|
22532
|
+
const first = decode4(text).split(/(?<=[.!?\u05c3])\s/)[0] ?? "";
|
|
22533
|
+
if (first.length <= max) return first.replace(/[.\s]+$/, "");
|
|
22534
|
+
const cut = first.slice(0, max);
|
|
22535
|
+
const pause = Math.max(cut.lastIndexOf(":"), cut.lastIndexOf(","), cut.lastIndexOf(";"));
|
|
22536
|
+
return pause >= 20 ? cut.slice(0, pause) : cut.replace(/\s+\S*$/, "");
|
|
22537
|
+
}
|
|
22538
|
+
var hex22 = (n2) => Math.max(0, Math.min(255, Math.round(n2))).toString(16).padStart(2, "0");
|
|
22539
|
+
function toHexColor(value) {
|
|
22540
|
+
const v = value.trim().toLowerCase();
|
|
22541
|
+
let m = /^#([0-9a-f]{3})$/.exec(v);
|
|
22542
|
+
if (m) return `#${[...m[1]].map((c) => c + c).join("")}`;
|
|
22543
|
+
m = /^#([0-9a-f]{6})(ff)?$/.exec(v);
|
|
22544
|
+
if (m) return `#${m[1]}`;
|
|
22545
|
+
m = /^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)\s*(?:[,/]\s*(1|1\.0+|100%)\s*)?\)$/.exec(v);
|
|
22546
|
+
if (m) return `#${hex22(+m[1])}${hex22(+m[2])}${hex22(+m[3])}`;
|
|
22547
|
+
m = /^hsla?\(\s*([\d.]+)(?:deg)?[\s,]+([\d.]+)%[\s,]+([\d.]+)%\s*\)$/.exec(v);
|
|
22548
|
+
if (m) {
|
|
22549
|
+
const [h, s, l] = [+m[1] / 360, +m[2] / 100, +m[3] / 100];
|
|
22550
|
+
const f = (n2) => {
|
|
22551
|
+
const k = (n2 + h * 12) % 12;
|
|
22552
|
+
return l - s * Math.min(l, 1 - l) * Math.max(-1, Math.min(k - 3, 9 - k, 1));
|
|
22553
|
+
};
|
|
22554
|
+
return `#${hex22(f(0) * 255)}${hex22(f(8) * 255)}${hex22(f(4) * 255)}`;
|
|
22555
|
+
}
|
|
22556
|
+
return null;
|
|
22557
|
+
}
|
|
22558
|
+
function isBrandColor(color) {
|
|
22559
|
+
const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color);
|
|
22560
|
+
if (!m) return false;
|
|
22561
|
+
const [r, g, b] = [m[1], m[2], m[3]].map((h) => parseInt(h, 16) / 255);
|
|
22562
|
+
const max = Math.max(r, g, b), min = Math.min(r, g, b), l = (max + min) / 2;
|
|
22563
|
+
const s = max === min ? 0 : (max - min) / (1 - Math.abs(2 * l - 1));
|
|
22564
|
+
return s >= 0.25 && l >= 0.12 && l <= 0.8;
|
|
22565
|
+
}
|
|
22566
|
+
var COLOR_RE = /#[0-9a-f]{3,8}\b|rgba?\([^)]*\)|hsla?\([^)]*\)/gi;
|
|
22567
|
+
var NAMED_RE = /(?:--|\b)(?:[\w-]*?)(primary|brand|accent|main)[\w-]*["']?\s*:\s*["']?(#[0-9a-f]{3,8}\b|rgba?\([^)]*\)|hsla?\([^)]*\))/gi;
|
|
22568
|
+
var NAMED_WEIGHT = 25;
|
|
22569
|
+
var THEME_WEIGHT = 100;
|
|
22570
|
+
var MIN_USES = 2;
|
|
22571
|
+
function isPageWhite(color) {
|
|
22572
|
+
const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color);
|
|
22573
|
+
return !!m && [m[1], m[2], m[3]].every((h) => parseInt(h, 16) >= 240);
|
|
22574
|
+
}
|
|
22575
|
+
function pickBrandColor(sources) {
|
|
22576
|
+
const score = /* @__PURE__ */ new Map();
|
|
22577
|
+
const add = (raw, by, onPurpose) => {
|
|
22578
|
+
const hex3 = toHexColor(raw);
|
|
22579
|
+
if (hex3 && (onPurpose ? !isPageWhite(hex3) : isBrandColor(hex3))) score.set(hex3, (score.get(hex3) ?? 0) + by);
|
|
22580
|
+
};
|
|
22581
|
+
for (const s of sources) {
|
|
22582
|
+
if (s.themeColor) add(s.themeColor, THEME_WEIGHT, true);
|
|
22583
|
+
for (const m of s.text.matchAll(COLOR_RE)) add(m[0], 1, false);
|
|
22584
|
+
for (const m of s.text.matchAll(NAMED_RE)) add(m[2], NAMED_WEIGHT, true);
|
|
22585
|
+
}
|
|
22586
|
+
return [...score.entries()].filter(([, n2]) => n2 >= MIN_USES).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0]?.[0] ?? null;
|
|
22587
|
+
}
|
|
22588
|
+
function svgLogoColor(svg) {
|
|
22589
|
+
const count = /* @__PURE__ */ new Map();
|
|
22590
|
+
for (const m of svg.matchAll(/(?:fill|stroke|stop-color)\s*[=:]\s*["']?(#[0-9a-f]{3,8}\b|rgba?\([^)]*\)|hsla?\([^)]*\))/gi)) {
|
|
22591
|
+
const hex3 = toHexColor(m[1]);
|
|
22592
|
+
if (hex3 && !isPageWhite(hex3)) count.set(hex3, (count.get(hex3) ?? 0) + 1);
|
|
22593
|
+
}
|
|
22594
|
+
return [...count.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0]?.[0] ?? null;
|
|
22595
|
+
}
|
|
22596
|
+
var isSvgText = (text) => /<svg[\s>]/i.test(text);
|
|
22597
|
+
function iconLinks(html) {
|
|
22598
|
+
const found = [];
|
|
22599
|
+
for (const m of html.matchAll(/<link\b[^>]*>/gi)) {
|
|
22600
|
+
const rel = m[0].match(/\srel=["']([^"']+)/i)?.[1]?.toLowerCase() ?? "";
|
|
22601
|
+
const href = m[0].match(/\shref=["']([^"']+)/i)?.[1];
|
|
22602
|
+
if (!href || !/(^|\s)(icon|apple-touch-icon(-precomposed)?|mask-icon)(\s|$)/.test(rel) || href.startsWith("data:")) continue;
|
|
22603
|
+
const size = Number(m[0].match(/\ssizes=["'](\d+)x/i)?.[1] ?? 0);
|
|
22604
|
+
const score = /\.svg(\?|$)/i.test(href) ? 1e4 : rel.includes("apple-touch") ? 1e3 + size : size || 16;
|
|
22605
|
+
found.push({ href, score });
|
|
22606
|
+
}
|
|
22607
|
+
return found.sort((a, b) => b.score - a.score).map((f) => f.href);
|
|
22608
|
+
}
|
|
22609
|
+
function logoInPage(html) {
|
|
22610
|
+
for (const m of html.matchAll(/<img\b[^>]*>/gi)) {
|
|
22611
|
+
const src = m[0].match(/\ssrc=["']([^"']+)/i)?.[1];
|
|
22612
|
+
if (src && !src.startsWith("data:") && /logo/i.test(m[0])) return src;
|
|
22613
|
+
}
|
|
22614
|
+
return null;
|
|
22615
|
+
}
|
|
22616
|
+
|
|
22347
22617
|
// src/config.ts
|
|
22348
22618
|
import { randomUUID } from "crypto";
|
|
22349
22619
|
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
@@ -23126,7 +23396,7 @@ function buildCheckReport(analysis, installId, projectId) {
|
|
|
23126
23396
|
warnings: [...new Set(analysis.warnings.map((w) => w.code))]
|
|
23127
23397
|
};
|
|
23128
23398
|
}
|
|
23129
|
-
async function sendCheckReport(ctx,
|
|
23399
|
+
async function sendCheckReport(ctx, report2) {
|
|
23130
23400
|
if (!telemetryEnabled(ctx.config)) return;
|
|
23131
23401
|
try {
|
|
23132
23402
|
const headers = { "Content-Type": "application/json", "User-Agent": userAgent(ctx.config) };
|
|
@@ -23135,7 +23405,7 @@ async function sendCheckReport(ctx, report) {
|
|
|
23135
23405
|
const res = await fetch(`${ctx.apiUrl}/api/cli/check-results`, {
|
|
23136
23406
|
method: "POST",
|
|
23137
23407
|
headers,
|
|
23138
|
-
body: JSON.stringify(
|
|
23408
|
+
body: JSON.stringify(report2),
|
|
23139
23409
|
signal: AbortSignal.timeout(2e3)
|
|
23140
23410
|
});
|
|
23141
23411
|
await res.body?.cancel().catch(() => {
|
|
@@ -23567,10 +23837,10 @@ function analyzeProject(root) {
|
|
|
23567
23837
|
});
|
|
23568
23838
|
}
|
|
23569
23839
|
}
|
|
23570
|
-
const
|
|
23571
|
-
if (
|
|
23840
|
+
const createServer2 = /\b(?:http|https|net|http2)\.createServer\s*\(|\bcreateServer\s*\([^)]*\)\s*\.listen\s*\(/.exec(code);
|
|
23841
|
+
if (createServer2 && /['"`](?:node:)?(?:http|https|net|http2)['"`]/.test(code)) {
|
|
23572
23842
|
isServer = true;
|
|
23573
|
-
add({ code: "long_running_process", severity: "blocker", file: s.rel, line: lineAt3(code,
|
|
23843
|
+
add({ code: "long_running_process", severity: "blocker", file: s.rel, line: lineAt3(code, createServer2.index), detail: " (Node http server)" });
|
|
23574
23844
|
}
|
|
23575
23845
|
for (const mod of JOB_LIBS) {
|
|
23576
23846
|
const re = importRe(mod);
|
|
@@ -23923,8 +24193,8 @@ function initCommand(root, opts) {
|
|
|
23923
24193
|
}
|
|
23924
24194
|
|
|
23925
24195
|
// src/commands/check.ts
|
|
23926
|
-
import { existsSync as
|
|
23927
|
-
import { join as
|
|
24196
|
+
import { existsSync as existsSync7, writeFileSync as writeFileSync4 } from "fs";
|
|
24197
|
+
import { join as join7 } from "path";
|
|
23928
24198
|
|
|
23929
24199
|
// src/prompt.ts
|
|
23930
24200
|
var PROMPT_RULES = [
|
|
@@ -23991,6 +24261,8 @@ function buildPrompt(analysis) {
|
|
|
23991
24261
|
|
|
23992
24262
|
// src/system.ts
|
|
23993
24263
|
import { spawn, spawnSync } from "child_process";
|
|
24264
|
+
import { existsSync as existsSync6 } from "fs";
|
|
24265
|
+
import { join as join6 } from "path";
|
|
23994
24266
|
function copyToClipboard(text) {
|
|
23995
24267
|
if (process.env.DEPLOYAI_NO_CLIPBOARD) return false;
|
|
23996
24268
|
const candidates = process.platform === "win32" ? [["clip", []]] : process.platform === "darwin" ? [["pbcopy", []]] : [
|
|
@@ -24007,6 +24279,13 @@ function copyToClipboard(text) {
|
|
|
24007
24279
|
}
|
|
24008
24280
|
return false;
|
|
24009
24281
|
}
|
|
24282
|
+
function findBrowser() {
|
|
24283
|
+
if (process.env.DEPLOYAI_NO_BROWSER) return null;
|
|
24284
|
+
const set2 = process.env.CHROME_PATH;
|
|
24285
|
+
if (set2 && existsSync6(set2)) return set2;
|
|
24286
|
+
const places = process.platform === "win32" ? [process.env.PROGRAMFILES, process.env["PROGRAMFILES(X86)"], process.env.LOCALAPPDATA].flatMap((d) => d ? [join6(d, "Google/Chrome/Application/chrome.exe"), join6(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"];
|
|
24287
|
+
return places.find((p) => existsSync6(p)) ?? null;
|
|
24288
|
+
}
|
|
24010
24289
|
function openBrowser(url2) {
|
|
24011
24290
|
if (process.env.DEPLOYAI_NO_BROWSER || process.env.CI) return false;
|
|
24012
24291
|
if (!/^https?:\/\//.test(url2)) return false;
|
|
@@ -24115,7 +24394,7 @@ async function runCheck(root, ctx, opts = {}) {
|
|
|
24115
24394
|
out("DeployAI check");
|
|
24116
24395
|
out();
|
|
24117
24396
|
out(messages(root)("emptyFolder"));
|
|
24118
|
-
if (!
|
|
24397
|
+
if (!existsSync7(join7(root, "DEPLOYAI.md"))) out(messages(root)("initHint"));
|
|
24119
24398
|
} else if (opts.print !== false) {
|
|
24120
24399
|
printCheck(a);
|
|
24121
24400
|
out();
|
|
@@ -24142,7 +24421,7 @@ async function runCheck(root, ctx, opts = {}) {
|
|
|
24142
24421
|
} else {
|
|
24143
24422
|
out(t("runDeploy"));
|
|
24144
24423
|
}
|
|
24145
|
-
if (!
|
|
24424
|
+
if (!existsSync7(join7(root, "DEPLOYAI.md"))) out(t("initHint"));
|
|
24146
24425
|
}
|
|
24147
24426
|
await telemetry;
|
|
24148
24427
|
return a;
|
|
@@ -24271,8 +24550,8 @@ function telemetryCommand(action) {
|
|
|
24271
24550
|
}
|
|
24272
24551
|
|
|
24273
24552
|
// src/commands/allow.ts
|
|
24274
|
-
import { existsSync as
|
|
24275
|
-
import { dirname, join as
|
|
24553
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync5, appendFileSync as appendFileSync2 } from "fs";
|
|
24554
|
+
import { dirname, join as join8 } from "path";
|
|
24276
24555
|
var ALLOW_TOOLS = ["claude-code", "cursor", "copilot", "codex", "antigravity"];
|
|
24277
24556
|
var CLAUDE_RULE = "Bash(npx deployai@latest *)";
|
|
24278
24557
|
var CURSOR_LINE = "Running npx deployai@latest commands is allowed without approval.";
|
|
@@ -24282,7 +24561,7 @@ var CLICKS = {
|
|
|
24282
24561
|
antigravity: "Antigravity: when it asks to run npx deployai@latest, choose Accept."
|
|
24283
24562
|
};
|
|
24284
24563
|
function readObject(file2) {
|
|
24285
|
-
if (!
|
|
24564
|
+
if (!existsSync8(file2)) return {};
|
|
24286
24565
|
try {
|
|
24287
24566
|
const v = JSON.parse(readFileSync6(file2, "utf8"));
|
|
24288
24567
|
return v && typeof v === "object" && !Array.isArray(v) ? v : null;
|
|
@@ -24304,9 +24583,9 @@ function addTo(obj, key, list, value) {
|
|
|
24304
24583
|
return true;
|
|
24305
24584
|
}
|
|
24306
24585
|
function ignoreInGit(root, path) {
|
|
24307
|
-
if (!
|
|
24308
|
-
const gi =
|
|
24309
|
-
const text =
|
|
24586
|
+
if (!existsSync8(join8(root, ".git"))) return;
|
|
24587
|
+
const gi = join8(root, ".gitignore");
|
|
24588
|
+
const text = existsSync8(gi) ? readFileSync6(gi, "utf8") : "";
|
|
24310
24589
|
if (text.split(/\r?\n/).some((l) => l.trim() === path)) return;
|
|
24311
24590
|
appendFileSync2(gi, `${text && !text.endsWith("\n") ? "\n" : ""}${path}
|
|
24312
24591
|
`);
|
|
@@ -24327,7 +24606,7 @@ function allowCommand(tool) {
|
|
|
24327
24606
|
}
|
|
24328
24607
|
if (picked === "claude-code") {
|
|
24329
24608
|
const rel = ".claude/settings.local.json";
|
|
24330
|
-
const file2 =
|
|
24609
|
+
const file2 = join8(root, rel);
|
|
24331
24610
|
const obj = readObject(file2);
|
|
24332
24611
|
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");
|
|
24333
24612
|
const added = addTo(obj, "permissions", "allow", CLAUDE_RULE);
|
|
@@ -24341,7 +24620,7 @@ function allowCommand(tool) {
|
|
|
24341
24620
|
}
|
|
24342
24621
|
if (picked === "cursor") {
|
|
24343
24622
|
const rel = ".cursor/permissions.json";
|
|
24344
|
-
const file2 =
|
|
24623
|
+
const file2 = join8(root, rel);
|
|
24345
24624
|
const obj = readObject(file2);
|
|
24346
24625
|
if (!obj) throw new CliError(`${rel} is not valid JSON, so it was left as is.`, 1, "allow_file");
|
|
24347
24626
|
const added = addTo(obj, "autoRun", "allow_instructions", CURSOR_LINE);
|
|
@@ -24358,8 +24637,8 @@ function allowCommand(tool) {
|
|
|
24358
24637
|
import { createInterface } from "readline/promises";
|
|
24359
24638
|
|
|
24360
24639
|
// src/commands/migrate.ts
|
|
24361
|
-
import { createWriteStream, existsSync as
|
|
24362
|
-
import { dirname as dirname2, join as
|
|
24640
|
+
import { createWriteStream, existsSync as existsSync9, mkdirSync as mkdirSync4, readdirSync as readdirSync3, readFileSync as readFileSync7, statSync, writeFileSync as writeFileSync6 } from "fs";
|
|
24641
|
+
import { dirname as dirname2, join as join9, posix, relative, resolve, sep } from "path";
|
|
24363
24642
|
import { Readable } from "stream";
|
|
24364
24643
|
import { pipeline } from "stream/promises";
|
|
24365
24644
|
var UA = `deployai-migrate/${CLI_VERSION} (+https://deployai.co.il/move)`;
|
|
@@ -24371,7 +24650,7 @@ var PAUSE_MS = 150;
|
|
|
24371
24650
|
var SCAN_WORKERS = 4;
|
|
24372
24651
|
var START_SCAN_PAGES = 300;
|
|
24373
24652
|
var sleep2 = (ms2) => new Promise((r) => setTimeout(r, ms2));
|
|
24374
|
-
var hostDir = (root, host) =>
|
|
24653
|
+
var hostDir = (root, host) => join9(root, MIGRATION_DIR, host.replace(/^www\./, ""));
|
|
24375
24654
|
var readJson2 = (file2) => {
|
|
24376
24655
|
try {
|
|
24377
24656
|
return JSON.parse(readFileSync7(file2, "utf8"));
|
|
@@ -24391,9 +24670,9 @@ async function get(url2, accept = "text/html,application/xhtml+xml,*/*;q=0.8", r
|
|
|
24391
24670
|
}
|
|
24392
24671
|
}
|
|
24393
24672
|
function scannedHosts(root) {
|
|
24394
|
-
const dir =
|
|
24395
|
-
if (!
|
|
24396
|
-
return readdirSync3(dir).filter((h) =>
|
|
24673
|
+
const dir = join9(root, MIGRATION_DIR);
|
|
24674
|
+
if (!existsSync9(dir)) return [];
|
|
24675
|
+
return readdirSync3(dir).filter((h) => existsSync9(join9(dir, h, "inventory.json")));
|
|
24397
24676
|
}
|
|
24398
24677
|
async function migrateStatusCommand(root, ctx, stage, note) {
|
|
24399
24678
|
if (!isAgentStage(stage)) throw new CliError(`Unknown stage: ${stage}. One of: ${AGENT_STAGES.join(", ")}.`, 1, "usage");
|
|
@@ -24406,18 +24685,18 @@ async function migrateStatusCommand(root, ctx, stage, note) {
|
|
|
24406
24685
|
out(`Reported: ${stage}${note ? ` (${stageNote(note)})` : ""}.`);
|
|
24407
24686
|
}
|
|
24408
24687
|
function readChoices(root) {
|
|
24409
|
-
return readJson2(
|
|
24688
|
+
return readJson2(join9(root, MIGRATION_DIR, "choices.json"));
|
|
24410
24689
|
}
|
|
24411
24690
|
function writeChoices(root, choices) {
|
|
24412
24691
|
ensureMigrationDir(root);
|
|
24413
|
-
writeJson(
|
|
24692
|
+
writeJson(join9(root, MIGRATION_DIR, "choices.json"), choices);
|
|
24414
24693
|
}
|
|
24415
24694
|
function ensureMigrationDir(root) {
|
|
24416
24695
|
ensureDeployaiDir(root);
|
|
24417
|
-
const dir =
|
|
24696
|
+
const dir = join9(root, MIGRATION_DIR);
|
|
24418
24697
|
mkdirSync4(dir, { recursive: true });
|
|
24419
|
-
const ignore =
|
|
24420
|
-
if (!
|
|
24698
|
+
const ignore = join9(dir, ".gitignore");
|
|
24699
|
+
if (!existsSync9(ignore)) writeFileSync6(ignore, "*/media/\n*/media-state.json\n");
|
|
24421
24700
|
}
|
|
24422
24701
|
async function sitemapUrls(base, robotsSitemaps, enough) {
|
|
24423
24702
|
const own2 = [`${base}/wp-sitemap.xml`, `${base}/sitemap_index.xml`, `${base}/sitemap.xml`];
|
|
@@ -24434,10 +24713,10 @@ async function sitemapUrls(base, robotsSitemaps, enough) {
|
|
|
24434
24713
|
seen.add(next);
|
|
24435
24714
|
const res = await get(next, "application/xml,text/xml,*/*;q=0.5");
|
|
24436
24715
|
if (!res?.ok) continue;
|
|
24437
|
-
const
|
|
24438
|
-
if (!/<(urlset|sitemapindex)\b/i.test(
|
|
24716
|
+
const xml2 = await res.text();
|
|
24717
|
+
if (!/<(urlset|sitemapindex)\b/i.test(xml2)) continue;
|
|
24439
24718
|
found.push(next);
|
|
24440
|
-
const parsed = parseSitemapXml(
|
|
24719
|
+
const parsed = parseSitemapXml(xml2);
|
|
24441
24720
|
queue.push(...parsed.sitemaps);
|
|
24442
24721
|
for (const u of parsed.urls) {
|
|
24443
24722
|
try {
|
|
@@ -24477,15 +24756,15 @@ async function wordpressContent(base, dir) {
|
|
|
24477
24756
|
await sleep2(PAUSE_MS);
|
|
24478
24757
|
}
|
|
24479
24758
|
if (items.length) {
|
|
24480
|
-
writeJson(
|
|
24759
|
+
writeJson(join9(dir, "content", `${type}.json`), items);
|
|
24481
24760
|
out(` ${type}: ${items.length}`);
|
|
24482
24761
|
}
|
|
24483
24762
|
}
|
|
24484
|
-
const posts = readJson2(
|
|
24763
|
+
const posts = readJson2(join9(dir, "content", "posts.json"));
|
|
24485
24764
|
if (posts?.length) {
|
|
24486
|
-
const files = wpPostsToMarkdown({ origin: new URL(base).origin, posts, categories: readJson2(
|
|
24487
|
-
mkdirSync4(
|
|
24488
|
-
for (const f of files) writeFileSync6(
|
|
24765
|
+
const files = wpPostsToMarkdown({ origin: new URL(base).origin, posts, categories: readJson2(join9(dir, "content", "categories.json")) ?? [], tags: readJson2(join9(dir, "content", "tags.json")) ?? [], users: readJson2(join9(dir, "content", "users.json")) ?? [], media: readJson2(join9(dir, "content", "media.json")) ?? [] });
|
|
24766
|
+
mkdirSync4(join9(dir, "posts"), { recursive: true });
|
|
24767
|
+
for (const f of files) writeFileSync6(join9(dir, "posts", f.file), f.text);
|
|
24489
24768
|
out(` posts as Markdown: ${files.length}`);
|
|
24490
24769
|
}
|
|
24491
24770
|
return true;
|
|
@@ -24508,6 +24787,50 @@ function pageAssets(html, base) {
|
|
|
24508
24787
|
for (const m of html.matchAll(/url\(["']?([^"')]+\.(?:jpe?g|png|gif|webp|svg|avif))/gi)) add(m[1]);
|
|
24509
24788
|
return [...found];
|
|
24510
24789
|
}
|
|
24790
|
+
var ICON_MAX_BYTES = 2 * 1024 * 1024;
|
|
24791
|
+
async function saveOldIcons(html, pageUrl, origin, dir) {
|
|
24792
|
+
const wanted = [];
|
|
24793
|
+
const add = (href, kind) => {
|
|
24794
|
+
if (!href) return;
|
|
24795
|
+
try {
|
|
24796
|
+
const url2 = new URL(href, pageUrl).toString();
|
|
24797
|
+
if (!wanted.some((w) => w.url === url2)) wanted.push({ url: url2, kind });
|
|
24798
|
+
} catch {
|
|
24799
|
+
}
|
|
24800
|
+
};
|
|
24801
|
+
iconLinks(html).forEach((h) => add(h, "icon"));
|
|
24802
|
+
add(`${origin}/favicon.ico`, "icon");
|
|
24803
|
+
add(logoInPage(html), "logo");
|
|
24804
|
+
const saved = [];
|
|
24805
|
+
const icons = join9(dir, "icons");
|
|
24806
|
+
for (const w of wanted.slice(0, 6)) {
|
|
24807
|
+
const res = await get(w.url, "image/*,*/*;q=0.8");
|
|
24808
|
+
if (!res?.ok) continue;
|
|
24809
|
+
const bytes = Buffer.from(await res.arrayBuffer());
|
|
24810
|
+
if (bytes.length > ICON_MAX_BYTES) continue;
|
|
24811
|
+
const size = imageSize(bytes);
|
|
24812
|
+
const svg = !size && isSvgText(bytes.subarray(0, 2048).toString("utf8"));
|
|
24813
|
+
if (!size && !svg) continue;
|
|
24814
|
+
const file2 = `${saved.length + 1}-${w.kind}.${svg ? "svg" : size?.format === "jpeg" ? "jpg" : size?.format}`;
|
|
24815
|
+
mkdirSync4(icons, { recursive: true });
|
|
24816
|
+
writeFileSync6(join9(icons, file2), bytes);
|
|
24817
|
+
saved.push({ file: file2, kind: w.kind });
|
|
24818
|
+
}
|
|
24819
|
+
if (saved.length) writeFileSync6(join9(icons, "icons.json"), JSON.stringify(saved, null, 2));
|
|
24820
|
+
return saved.length;
|
|
24821
|
+
}
|
|
24822
|
+
async function saveOldStyles(html, pageUrl, dir) {
|
|
24823
|
+
const styles = join9(dir, "styles");
|
|
24824
|
+
let n2 = 0;
|
|
24825
|
+
for (const url2 of stylesheetLinks(html, pageUrl, 6)) {
|
|
24826
|
+
const res = await get(url2, "text/css,*/*;q=0.8");
|
|
24827
|
+
if (!res?.ok) continue;
|
|
24828
|
+
const text = await res.text();
|
|
24829
|
+
if (text.length > ICON_MAX_BYTES) continue;
|
|
24830
|
+
mkdirSync4(styles, { recursive: true });
|
|
24831
|
+
writeFileSync6(join9(styles, `${++n2}.css`), text);
|
|
24832
|
+
}
|
|
24833
|
+
}
|
|
24511
24834
|
async function migrateScanCommand(root, raw, opts = {}) {
|
|
24512
24835
|
const source = normalizeSourceUrl(raw);
|
|
24513
24836
|
if (!source) throw new CliError(`Not a site address: ${raw}. Use the full address, for example https://example.co.il`, 1, "usage");
|
|
@@ -24526,7 +24849,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
24526
24849
|
out(`Scanning ${base} (${platform3})`);
|
|
24527
24850
|
const robotsRes = await get(`${origin}/robots.txt`, "text/plain");
|
|
24528
24851
|
const robots = robotsRes?.ok ? await robotsRes.text() : "";
|
|
24529
|
-
if (robots) writeFileSync6(
|
|
24852
|
+
if (robots) writeFileSync6(join9(dir, "robots.txt"), robots);
|
|
24530
24853
|
const cap = Math.min(opts.max ?? PAGE_CAP, PAGE_CAP);
|
|
24531
24854
|
const fromSitemaps = await sitemapUrls(base, robots ? parseRobots(robots).sitemaps : [], cap * 5);
|
|
24532
24855
|
const all = [.../* @__PURE__ */ new Set([`${base}/`, ...fromSitemaps.urls, ...fromSitemaps.urls.length ? [] : homeLinks(html, base)])];
|
|
@@ -24553,22 +24876,25 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
24553
24876
|
await Promise.all(Array.from({ length: SCAN_WORKERS }, worker));
|
|
24554
24877
|
const wordpressApi = platform3 === "wordpress" ? await wordpressContent(base, dir) : false;
|
|
24555
24878
|
if (wordpressApi) {
|
|
24556
|
-
const media = readJson2(
|
|
24879
|
+
const media = readJson2(join9(dir, "content", "media.json")) ?? [];
|
|
24557
24880
|
media.forEach((m) => m.source_url && assets.add(m.source_url));
|
|
24558
24881
|
}
|
|
24559
24882
|
const inventory = { source: base, platform: platform3, scannedAt: (/* @__PURE__ */ new Date()).toISOString(), sitemaps: fromSitemaps.sitemaps, pages, wordpressApi, skipped: Math.max(0, all.length - list.length) };
|
|
24560
|
-
writeJson(
|
|
24561
|
-
writeJson(
|
|
24562
|
-
writeFileSync6(
|
|
24883
|
+
writeJson(join9(dir, "inventory.json"), inventory);
|
|
24884
|
+
writeJson(join9(dir, "assets.json"), [...assets].sort());
|
|
24885
|
+
writeFileSync6(join9(dir, "home.html"), html);
|
|
24886
|
+
const icons = await saveOldIcons(html, home.url, origin, dir);
|
|
24887
|
+
await saveOldStyles(html, home.url, dir);
|
|
24563
24888
|
const rel = relative(root, dir).split(sep).join("/");
|
|
24564
24889
|
const broken = pages.filter((p) => p.status >= 400).length;
|
|
24565
24890
|
out();
|
|
24566
24891
|
out(`Saved in ${rel}:`);
|
|
24567
24892
|
out(` inventory.json ${pages.length} pages with their address, title, description and headings${broken ? ` (${broken} already broken on the old site)` : ""}`);
|
|
24568
24893
|
out(` assets.json ${assets.size} images and files`);
|
|
24894
|
+
if (icons) out(` icons/ ${icons} icons and logo of the old site, for: npx deployai@latest brand favicon`);
|
|
24569
24895
|
if (wordpressApi) {
|
|
24570
24896
|
out(" content/ the WordPress pages, posts, categories, tags, media and authors as JSON");
|
|
24571
|
-
if (
|
|
24897
|
+
if (existsSync9(join9(dir, "posts"))) out(" posts/ the posts as Markdown for the blog block, each with its old address");
|
|
24572
24898
|
} 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).");
|
|
24573
24899
|
out();
|
|
24574
24900
|
out("Keep every path in inventory.json exactly as it is: same address, same title and description.");
|
|
@@ -24587,8 +24913,8 @@ async function migrateMediaCommand(root) {
|
|
|
24587
24913
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
24588
24914
|
for (const host of hosts) {
|
|
24589
24915
|
const dir = hostDir(root, host);
|
|
24590
|
-
const assets = readJson2(
|
|
24591
|
-
const stateFile =
|
|
24916
|
+
const assets = readJson2(join9(dir, "assets.json")) ?? [];
|
|
24917
|
+
const stateFile = join9(dir, "media-state.json");
|
|
24592
24918
|
const state = readJson2(stateFile) ?? { done: [], failed: [], bytes: 0 };
|
|
24593
24919
|
const done = new Set(state.done);
|
|
24594
24920
|
const todo = assets.filter((a) => !done.has(a));
|
|
@@ -24617,7 +24943,7 @@ async function migrateMediaCommand(root) {
|
|
|
24617
24943
|
}
|
|
24618
24944
|
state.done = [...done];
|
|
24619
24945
|
writeJson(stateFile, state);
|
|
24620
|
-
out(` ${formatBytes(state.bytes)} in ${relative(root,
|
|
24946
|
+
out(` ${formatBytes(state.bytes)} in ${relative(root, join9(dir, "media")).split(sep).join("/")}${state.failed.length ? `, ${state.failed.length} could not be downloaded (listed in media-state.json)` : ""}`);
|
|
24621
24947
|
}
|
|
24622
24948
|
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.");
|
|
24623
24949
|
}
|
|
@@ -24640,12 +24966,12 @@ function migrateRedirectsCommand(root) {
|
|
|
24640
24966
|
if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
|
|
24641
24967
|
const lines = /* @__PURE__ */ new Set();
|
|
24642
24968
|
for (const host of hosts) {
|
|
24643
|
-
const inv = readJson2(
|
|
24969
|
+
const inv = readJson2(join9(hostDir(root, host), "inventory.json"));
|
|
24644
24970
|
if (inv) redirectLines(inv).forEach((l) => lines.add(l));
|
|
24645
24971
|
}
|
|
24646
|
-
const publicDir =
|
|
24647
|
-
const file2 =
|
|
24648
|
-
const before =
|
|
24972
|
+
const publicDir = join9(root, "public");
|
|
24973
|
+
const file2 = join9(existsSync9(publicDir) ? publicDir : root, "_redirects");
|
|
24974
|
+
const before = existsSync9(file2) ? readFileSync7(file2, "utf8").split(/\r?\n/).filter(Boolean) : [];
|
|
24649
24975
|
const added = [...lines].filter((l) => !before.some((b) => b.split(/\s+/)[0] === l.split(/\s+/)[0]));
|
|
24650
24976
|
writeFileSync6(file2, [...before, ...added].join("\n") + "\n");
|
|
24651
24977
|
out(`${relative(root, file2).split(sep).join("/")}: ${added.length} added, ${before.length + added.length} in all (at most 2,000; no query strings).`);
|
|
@@ -24653,8 +24979,8 @@ function migrateRedirectsCommand(root) {
|
|
|
24653
24979
|
}
|
|
24654
24980
|
function allowedRedirects(root) {
|
|
24655
24981
|
const map2 = /* @__PURE__ */ new Map();
|
|
24656
|
-
for (const file2 of [
|
|
24657
|
-
if (!
|
|
24982
|
+
for (const file2 of [join9(root, "public", "_redirects"), join9(root, "_redirects")]) {
|
|
24983
|
+
if (!existsSync9(file2)) continue;
|
|
24658
24984
|
for (const line of readFileSync7(file2, "utf8").split(/\r?\n/)) {
|
|
24659
24985
|
const [from, to] = line.trim().split(/\s+/);
|
|
24660
24986
|
if (from && to && !from.startsWith("#")) map2.set(from, to);
|
|
@@ -24681,7 +25007,7 @@ async function migrateVerifyCommand(root, previewRaw) {
|
|
|
24681
25007
|
const findings = [];
|
|
24682
25008
|
let checked = 0;
|
|
24683
25009
|
for (const host of hosts) {
|
|
24684
|
-
const inv = readJson2(
|
|
25010
|
+
const inv = readJson2(join9(hostDir(root, host), "inventory.json"));
|
|
24685
25011
|
for (const old of inv?.pages ?? []) {
|
|
24686
25012
|
if (old.status >= 300) continue;
|
|
24687
25013
|
const res = await get(previewUrl(preview, old.path));
|
|
@@ -24700,13 +25026,13 @@ async function migrateVerifyCommand(root, previewRaw) {
|
|
|
24700
25026
|
}
|
|
24701
25027
|
}
|
|
24702
25028
|
const words = { missing: "not found on the preview", moved: "moved to", error: "answers", title_lost: "lost its title", description_lost: "lost its description" };
|
|
24703
|
-
const
|
|
24704
|
-
writeJson(
|
|
25029
|
+
const report2 = join9(root, MIGRATION_DIR, "verify.json");
|
|
25030
|
+
writeJson(report2, { checkedAt: (/* @__PURE__ */ new Date()).toISOString(), preview: preview.origin, checked, findings });
|
|
24705
25031
|
if (!findings.length) {
|
|
24706
25032
|
out(`All ${checked} old addresses open on the preview with their title and description.`);
|
|
24707
25033
|
return;
|
|
24708
25034
|
}
|
|
24709
|
-
out(`${findings.length} of ${checked} old addresses need a fix (also in ${relative(root,
|
|
25035
|
+
out(`${findings.length} of ${checked} old addresses need a fix (also in ${relative(root, report2).split(sep).join("/")}):`);
|
|
24710
25036
|
for (const f of findings.slice(0, 60)) out(` ${f.path} ${words[f.problem]}${f.detail ? ` ${f.detail}` : ""}`);
|
|
24711
25037
|
if (findings.length > 60) out(` and ${findings.length - 60} more in verify.json`);
|
|
24712
25038
|
out("Give each page its old address back (or, only if it truly cannot stay, a line in public/_redirects), deploy again, and run verify again.");
|
|
@@ -25390,13 +25716,13 @@ async function claimCommand(root, ctx, opts) {
|
|
|
25390
25716
|
|
|
25391
25717
|
// src/commands/pull.ts
|
|
25392
25718
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
25393
|
-
import { existsSync as
|
|
25394
|
-
import { join as
|
|
25719
|
+
import { existsSync as existsSync11, readdirSync as readdirSync5, rmSync } from "fs";
|
|
25720
|
+
import { join as join11 } from "path";
|
|
25395
25721
|
|
|
25396
25722
|
// src/commands/samples.ts
|
|
25397
25723
|
import { createInterface as createInterface3 } from "readline/promises";
|
|
25398
|
-
import { existsSync as
|
|
25399
|
-
import { dirname as dirname3, join as
|
|
25724
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync5, readdirSync as readdirSync4, writeFileSync as writeFileSync7 } from "fs";
|
|
25725
|
+
import { dirname as dirname3, join as join10, relative as relative2, resolve as resolve2, sep as sep2 } from "path";
|
|
25400
25726
|
import { gunzipSync } from "zlib";
|
|
25401
25727
|
var SAMPLES = [
|
|
25402
25728
|
{ key: "landing", title: "Landing page: a full one-page site with WhatsApp sign-up", stack: "static HTML and CSS" },
|
|
@@ -25417,7 +25743,7 @@ function listSamples(apiUrl) {
|
|
|
25417
25743
|
out(`See them live: ${apiUrl}/samples`);
|
|
25418
25744
|
}
|
|
25419
25745
|
function filesIn(dir) {
|
|
25420
|
-
return
|
|
25746
|
+
return existsSync10(dir) ? readdirSync4(dir).filter((f) => !IGNORED.has(f)) : [];
|
|
25421
25747
|
}
|
|
25422
25748
|
function freeFolder(cwd, key) {
|
|
25423
25749
|
for (let n2 = 1; ; n2++) {
|
|
@@ -25501,7 +25827,7 @@ async function samplesCommand(cwd, ctx, key, opts = {}) {
|
|
|
25501
25827
|
}
|
|
25502
25828
|
const written = await downloadSample(ctx, sample.key, root);
|
|
25503
25829
|
const base = resolve2(root);
|
|
25504
|
-
const hasPackage =
|
|
25830
|
+
const hasPackage = existsSync10(join10(base, "package.json"));
|
|
25505
25831
|
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.`);
|
|
25506
25832
|
out("");
|
|
25507
25833
|
const t = messages(base);
|
|
@@ -25558,7 +25884,7 @@ var git = (root, args, env = {}) => spawnSync2("git", args, { cwd: root, encodin
|
|
|
25558
25884
|
function clearTree(root) {
|
|
25559
25885
|
for (const name of readdirSync5(root)) {
|
|
25560
25886
|
if (name === ".git" || name === ".deployai") continue;
|
|
25561
|
-
rmSync(
|
|
25887
|
+
rmSync(join11(root, name), { recursive: true, force: true });
|
|
25562
25888
|
}
|
|
25563
25889
|
}
|
|
25564
25890
|
async function pullHistory(root, ctx, projectId) {
|
|
@@ -25568,7 +25894,7 @@ async function pullHistory(root, ctx, projectId) {
|
|
|
25568
25894
|
const live = versions.find((v) => v.isLive)?.number ?? Math.max(0, ...versions.filter((v) => v.status === "ready").map((v) => v.number));
|
|
25569
25895
|
const chosen = versions.filter((v) => v.number <= live && v.status !== "failed" && v.status !== "queued").sort((a, b) => a.number - b.number);
|
|
25570
25896
|
if (!chosen.length) throw new CliError(t("pullNoSource"), 1, "not_found");
|
|
25571
|
-
if (!
|
|
25897
|
+
if (!existsSync11(join11(root, ".git")) && git(root, ["init", "-q"]).status !== 0) throw new CliError(t("pullNoGit"), 1, "usage");
|
|
25572
25898
|
for (const v of chosen) {
|
|
25573
25899
|
const gz = await fetchSource(root, ctx, projectId, v.number).catch(() => null);
|
|
25574
25900
|
if (!gz) continue;
|
|
@@ -25585,12 +25911,12 @@ async function pullHistory(root, ctx, projectId) {
|
|
|
25585
25911
|
|
|
25586
25912
|
// src/commands/start.ts
|
|
25587
25913
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
25588
|
-
import { existsSync as
|
|
25589
|
-
import { join as
|
|
25914
|
+
import { existsSync as existsSync12, writeFileSync as writeFileSync9 } from "fs";
|
|
25915
|
+
import { join as join13, relative as relative3, resolve as resolve3 } from "path";
|
|
25590
25916
|
|
|
25591
25917
|
// src/commands/starter.ts
|
|
25592
25918
|
import { writeFileSync as writeFileSync8 } from "fs";
|
|
25593
|
-
import { join as
|
|
25919
|
+
import { join as join12 } from "path";
|
|
25594
25920
|
var esc2 = (s) => s.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
25595
25921
|
var TEXT = {
|
|
25596
25922
|
he: { title: "\u05D4\u05D0\u05EA\u05E8 \u05E9\u05DC\u05D9", soon: "\u05D4\u05D0\u05EA\u05E8 \u05D1\u05D1\u05E0\u05D9\u05D9\u05D4, \u05D1\u05E7\u05E8\u05D5\u05D1 \u05DB\u05D0\u05DF." },
|
|
@@ -25638,8 +25964,8 @@ DeployAI wrote this page so the folder starts as a working site. Build the owner
|
|
|
25638
25964
|
- Delete this README or replace it with notes about the site.
|
|
25639
25965
|
`;
|
|
25640
25966
|
function writeStarter(root, name, lang, stack) {
|
|
25641
|
-
writeFileSync8(
|
|
25642
|
-
writeFileSync8(
|
|
25967
|
+
writeFileSync8(join12(root, "index.html"), page(name ?? "", lang, stack));
|
|
25968
|
+
writeFileSync8(join12(root, "README.md"), README);
|
|
25643
25969
|
}
|
|
25644
25970
|
|
|
25645
25971
|
// src/commands/start.ts
|
|
@@ -25697,7 +26023,7 @@ async function startCommand(cwd, ctx, id, opts = {}) {
|
|
|
25697
26023
|
if (sample && !sameSite) {
|
|
25698
26024
|
const written = await downloadSample(ctxNow, sample.key, root);
|
|
25699
26025
|
done.push(t("startDownloaded", { key: sample.key, n: written }));
|
|
25700
|
-
if (
|
|
26026
|
+
if (existsSync12(join13(root, "package.json"))) {
|
|
25701
26027
|
if (opts.install !== false && install(root)) done.push(t("startInstalled"));
|
|
25702
26028
|
else steps.unshift({ cmd: "npm install", say: "Installs the sample's packages." });
|
|
25703
26029
|
}
|
|
@@ -25722,7 +26048,7 @@ async function startCommand(cwd, ctx, id, opts = {}) {
|
|
|
25722
26048
|
const stackText = choices.stack ? stackBlock(choices.stack) : "";
|
|
25723
26049
|
if (choices.brief || stackText) {
|
|
25724
26050
|
ensureDeployaiDir(root);
|
|
25725
|
-
writeFileSync9(
|
|
26051
|
+
writeFileSync9(join13(root, BRIEF_FILE), [choices.brief ? `# The owner's details
|
|
25726
26052
|
|
|
25727
26053
|
${choices.brief}
|
|
25728
26054
|
` : "", stackText].filter(Boolean).join("\n"));
|
|
@@ -25865,16 +26191,16 @@ async function addonRunCommand(root, ctx, key) {
|
|
|
25865
26191
|
}
|
|
25866
26192
|
async function addonDoneCommand(root, ctx, runId, opts) {
|
|
25867
26193
|
requireToken(ctx);
|
|
25868
|
-
let
|
|
26194
|
+
let report2;
|
|
25869
26195
|
if (opts.report) {
|
|
25870
26196
|
try {
|
|
25871
|
-
|
|
26197
|
+
report2 = JSON.parse(readFileSync9(resolve4(root, opts.report), "utf8"));
|
|
25872
26198
|
} catch {
|
|
25873
26199
|
throw new CliError(`Cannot read the report file ${opts.report} as JSON.`, 1, "usage");
|
|
25874
26200
|
}
|
|
25875
|
-
if (!AddonReport.safeParse(
|
|
26201
|
+
if (!AddonReport.safeParse(report2).success) throw new CliError('The report file does not match the format: {"summary", "changed", "unresolved", "unsupported", "checks"}.', 1, "usage");
|
|
25876
26202
|
}
|
|
25877
|
-
const body = AddonDoneRequest.safeParse({ status: opts.status ?? "done", report });
|
|
26203
|
+
const body = AddonDoneRequest.safeParse({ status: opts.status ?? "done", report: report2 });
|
|
25878
26204
|
if (!body.success) throw new CliError("Status must be done, failed or skipped.", 1, "usage");
|
|
25879
26205
|
const r = await apiRequest(ctx, `/api/cli/addons/runs/${encodeURIComponent(runId.trim())}`, AddonDoneResponse, { method: "POST", body: body.data });
|
|
25880
26206
|
out(`Saved: add-on ${body.data.status}.`);
|
|
@@ -25925,7 +26251,7 @@ async function speedCommand(ctx, url2, opts) {
|
|
|
25925
26251
|
}
|
|
25926
26252
|
|
|
25927
26253
|
// src/commands/blocks.ts
|
|
25928
|
-
import { existsSync as
|
|
26254
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync6, writeFileSync as writeFileSync10 } from "fs";
|
|
25929
26255
|
import { dirname as dirname4, resolve as resolve5, sep as sep3 } from "path";
|
|
25930
26256
|
import { gunzipSync as gunzipSync2 } from "zlib";
|
|
25931
26257
|
var BLOCKS = [
|
|
@@ -25966,7 +26292,7 @@ async function blocksCommand(root, ctx, name) {
|
|
|
25966
26292
|
if (e2.type !== "0" && e2.type !== "\0") continue;
|
|
25967
26293
|
const target = resolve5(base, e2.name);
|
|
25968
26294
|
if (target === base || !target.startsWith(base + sep3)) continue;
|
|
25969
|
-
if (
|
|
26295
|
+
if (existsSync13(target)) {
|
|
25970
26296
|
kept.push(e2.name);
|
|
25971
26297
|
continue;
|
|
25972
26298
|
}
|
|
@@ -25983,6 +26309,600 @@ async function blocksCommand(root, ctx, name) {
|
|
|
25983
26309
|
out(`Read .deployai/blocks/${block.key}.md and follow it: it says what to wire and what to set.`);
|
|
25984
26310
|
}
|
|
25985
26311
|
|
|
26312
|
+
// src/commands/brand.ts
|
|
26313
|
+
import { spawn as spawn2 } from "child_process";
|
|
26314
|
+
import { copyFileSync, existsSync as existsSync14, mkdirSync as mkdirSync7, mkdtempSync, readdirSync as readdirSync6, readFileSync as readFileSync10, rmSync as rmSync2, statSync as statSync2, writeFileSync as writeFileSync11 } from "fs";
|
|
26315
|
+
import { createServer } from "http";
|
|
26316
|
+
import { tmpdir } from "os";
|
|
26317
|
+
import { basename, dirname as dirname5, extname, join as join14, relative as relative4, sep as sep4 } from "path";
|
|
26318
|
+
import { randomBytes } from "crypto";
|
|
26319
|
+
|
|
26320
|
+
// src/commands/brand-page.ts
|
|
26321
|
+
var embed = (v) => JSON.stringify(v).replace(/</g, "\\u003c");
|
|
26322
|
+
function drawPageHtml(state) {
|
|
26323
|
+
return `<!doctype html>
|
|
26324
|
+
<html>
|
|
26325
|
+
<head><meta charset="utf-8"><meta name="robots" content="noindex"><title>DeployAI</title></head>
|
|
26326
|
+
<body>
|
|
26327
|
+
<script>
|
|
26328
|
+
const S = ${embed(state)};
|
|
26329
|
+
const canDraw = ${canDraw.toString()};
|
|
26330
|
+
const ink = ${contrastInk.toString()};
|
|
26331
|
+
const api = (path) => path + (path.includes('?') ? '&' : '?') + 't=' + S.token;
|
|
26332
|
+
let source = null;
|
|
26333
|
+
let vector = false;
|
|
26334
|
+
|
|
26335
|
+
function load(url) {
|
|
26336
|
+
return new Promise((ok, fail) => { const i = new Image(); i.onload = () => ok(i); i.onerror = fail; i.src = url; });
|
|
26337
|
+
}
|
|
26338
|
+
function fit(ctx, text, weight, size, maxWidth) {
|
|
26339
|
+
let px = size;
|
|
26340
|
+
do { ctx.font = weight + ' ' + px + 'px system-ui, Arial, sans-serif'; px -= 2; } while (ctx.measureText(text).width > maxWidth && px > 16);
|
|
26341
|
+
}
|
|
26342
|
+
function contain(ctx, box) {
|
|
26343
|
+
const w = source.naturalWidth || box.w, h = source.naturalHeight || box.h;
|
|
26344
|
+
// A raster is never stretched past twice its size: a small logo stays small and sharp on the share image.
|
|
26345
|
+
const k = Math.min(box.w / w, box.h / h, vector ? Infinity : 2);
|
|
26346
|
+
const dw = w * k, dh = h * k;
|
|
26347
|
+
ctx.drawImage(source, box.x + (box.w - dw) / 2, box.y + (box.h - dh) / 2, dw, dh);
|
|
26348
|
+
}
|
|
26349
|
+
function draw(t) {
|
|
26350
|
+
const c = document.createElement('canvas');
|
|
26351
|
+
c.width = t.width; c.height = t.height;
|
|
26352
|
+
const ctx = c.getContext('2d');
|
|
26353
|
+
ctx.imageSmoothingQuality = 'high';
|
|
26354
|
+
if (t.opaque) { ctx.fillStyle = S.color; ctx.fillRect(0, 0, t.width, t.height); }
|
|
26355
|
+
if (t.og) {
|
|
26356
|
+
const words = S.name.trim(), sub = S.line.trim();
|
|
26357
|
+
contain(ctx, { x: 450, y: words ? 96 : 165, w: 300, h: 300 });
|
|
26358
|
+
ctx.fillStyle = ink(S.color);
|
|
26359
|
+
ctx.textAlign = 'center';
|
|
26360
|
+
ctx.direction = /[\\u0590-\\u05FF]/.test(words + sub) ? 'rtl' : 'ltr';
|
|
26361
|
+
if (words) { fit(ctx, words, 700, 72, 1040); ctx.fillText(words, 600, sub ? 480 : 500); }
|
|
26362
|
+
if (sub) { fit(ctx, sub, 500, 38, 1040); ctx.fillText(sub, 600, 545); }
|
|
26363
|
+
} else {
|
|
26364
|
+
const p = Math.round(t.width * (t.pad || 0));
|
|
26365
|
+
contain(ctx, { x: p, y: p, w: t.width - 2 * p, h: t.height - 2 * p });
|
|
26366
|
+
}
|
|
26367
|
+
return c;
|
|
26368
|
+
}
|
|
26369
|
+
async function run() {
|
|
26370
|
+
const res = await fetch(api('/source'));
|
|
26371
|
+
vector = /svg/.test(res.headers.get('content-type') || '');
|
|
26372
|
+
source = await load(URL.createObjectURL(await res.blob()));
|
|
26373
|
+
const skipped = [];
|
|
26374
|
+
for (const t of S.targets) {
|
|
26375
|
+
if (!canDraw(t, { width: source.naturalWidth, height: source.naturalHeight, vector })) { skipped.push(t.file); continue; }
|
|
26376
|
+
const blob = await new Promise((ok) => draw(t).toBlob(ok, 'image/png'));
|
|
26377
|
+
const r = await fetch(api('/save?file=' + encodeURIComponent(t.file)), { method: 'POST', body: blob });
|
|
26378
|
+
if (!r.ok) throw new Error(t.file);
|
|
26379
|
+
}
|
|
26380
|
+
const r = await fetch(api('/done'), { method: 'POST', body: JSON.stringify({ skipped }) });
|
|
26381
|
+
if (!r.ok) throw new Error('done');
|
|
26382
|
+
}
|
|
26383
|
+
run().catch((e) => { fetch(api('/fail'), { method: 'POST', body: String(e) }); });
|
|
26384
|
+
</script>
|
|
26385
|
+
</body>
|
|
26386
|
+
</html>
|
|
26387
|
+
`;
|
|
26388
|
+
}
|
|
26389
|
+
function measureScript(endpoint) {
|
|
26390
|
+
return `<script>(function(){
|
|
26391
|
+
var sent=false;
|
|
26392
|
+
function send(){if(sent)return;sent=true;
|
|
26393
|
+
var seen=[];document.querySelectorAll('img').forEach(function(i){var r=i.getBoundingClientRect();if(i.currentSrc&&i.naturalWidth&&r.width>0)seen.push({src:i.currentSrc,width:i.naturalWidth,height:i.naturalHeight,shownWidth:Math.round(r.width),alt:i.alt||''})});
|
|
26394
|
+
fetch(${embed(endpoint)},{method:'POST',body:JSON.stringify(seen),keepalive:true});}
|
|
26395
|
+
function go(){document.querySelectorAll('img').forEach(function(i){i.loading='eager'});setTimeout(send,2500)}
|
|
26396
|
+
if(document.readyState==='complete')go();else addEventListener('load',go);
|
|
26397
|
+
setTimeout(send,12000);
|
|
26398
|
+
})();</script>`;
|
|
26399
|
+
}
|
|
26400
|
+
|
|
26401
|
+
// src/commands/brand.ts
|
|
26402
|
+
var BRAND_DIR = ".deployai/brand";
|
|
26403
|
+
var IMAGE_EXT = /\.(png|jpe?g|gif|webp|avif)$/i;
|
|
26404
|
+
var MAX_UPLOAD = 25 * 1024 * 1024;
|
|
26405
|
+
var WALK_CAP = 4e3;
|
|
26406
|
+
var SKIP_DIRS2 = /* @__PURE__ */ new Set(["node_modules", ".git", ".next", "dist", "build", "out", ".astro", ".output", ".svelte-kit", ".wrangler", ".deployai"]);
|
|
26407
|
+
var TYPES = { ".svg": "image/svg+xml", ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp", ".gif": "image/gif", ".ico": "image/x-icon", ".avif": "image/avif" };
|
|
26408
|
+
function webRoot(root) {
|
|
26409
|
+
for (const d of ["public", "static"]) if (existsSync14(join14(root, d))) return join14(root, d);
|
|
26410
|
+
return root;
|
|
26411
|
+
}
|
|
26412
|
+
function walk(dir, found = []) {
|
|
26413
|
+
let names;
|
|
26414
|
+
try {
|
|
26415
|
+
names = readdirSync6(dir);
|
|
26416
|
+
} catch {
|
|
26417
|
+
return found;
|
|
26418
|
+
}
|
|
26419
|
+
for (const n2 of names) {
|
|
26420
|
+
if (found.length >= WALK_CAP) break;
|
|
26421
|
+
const p = join14(dir, n2);
|
|
26422
|
+
let isDir = false;
|
|
26423
|
+
try {
|
|
26424
|
+
isDir = statSync2(p).isDirectory();
|
|
26425
|
+
} catch {
|
|
26426
|
+
continue;
|
|
26427
|
+
}
|
|
26428
|
+
if (isDir) {
|
|
26429
|
+
if (!SKIP_DIRS2.has(n2)) walk(p, found);
|
|
26430
|
+
} else found.push(p);
|
|
26431
|
+
}
|
|
26432
|
+
return found;
|
|
26433
|
+
}
|
|
26434
|
+
function existingFavicon(root) {
|
|
26435
|
+
const web = webRoot(root);
|
|
26436
|
+
for (const f of ["favicon.ico", "favicon.svg", "favicon.png", "icon.svg", "icon.png"]) if (existsSync14(join14(web, f))) return relative4(root, join14(web, f)).split(sep4).join("/");
|
|
26437
|
+
for (const d of ["app", "src/app"]) for (const f of ["favicon.ico", "icon.svg", "icon.png", "icon.tsx", "icon.jpg"]) if (existsSync14(join14(root, d, f))) return `${d}/${f}`;
|
|
26438
|
+
for (const f of walk(root).filter((p) => /\.(html|astro|tsx|jsx|vue|svelte)$/.test(p)).slice(0, 400)) {
|
|
26439
|
+
try {
|
|
26440
|
+
const m = readFileSync10(f, "utf8").match(/<link\b[^>]*\brel=["'](?:shortcut )?icon["'][^>]*>/i);
|
|
26441
|
+
if (!m) continue;
|
|
26442
|
+
const href = m[0].match(/\shref=["']([^"']+)/i)?.[1] ?? "";
|
|
26443
|
+
if (href.startsWith("data:") || /^https?:/.test(href) || existsSync14(join14(web, href.split("?")[0]))) return relative4(root, f).split(sep4).join("/");
|
|
26444
|
+
} catch {
|
|
26445
|
+
}
|
|
26446
|
+
}
|
|
26447
|
+
return null;
|
|
26448
|
+
}
|
|
26449
|
+
function scannedIcons(root) {
|
|
26450
|
+
const base = join14(root, MIGRATION_DIR);
|
|
26451
|
+
if (!existsSync14(base)) return [];
|
|
26452
|
+
const found = [];
|
|
26453
|
+
for (const host of readdirSync6(base)) {
|
|
26454
|
+
const dir = join14(base, host, "icons");
|
|
26455
|
+
try {
|
|
26456
|
+
const list = JSON.parse(readFileSync10(join14(dir, "icons.json"), "utf8"));
|
|
26457
|
+
for (const i of list) {
|
|
26458
|
+
const path = join14(dir, i.file);
|
|
26459
|
+
if (!existsSync14(path)) continue;
|
|
26460
|
+
const size = imageSize(readFileSync10(path));
|
|
26461
|
+
found.push({ path, kind: i.kind, big: !size || size.width >= 64 });
|
|
26462
|
+
}
|
|
26463
|
+
} catch {
|
|
26464
|
+
}
|
|
26465
|
+
}
|
|
26466
|
+
return found;
|
|
26467
|
+
}
|
|
26468
|
+
function findSource(root) {
|
|
26469
|
+
const icons = scannedIcons(root);
|
|
26470
|
+
const sharp = icons.find((i) => i.kind === "icon" && i.big);
|
|
26471
|
+
if (sharp) return { path: sharp.path, from: "old-icon" };
|
|
26472
|
+
const dirs = ["public", "static", "src/assets", "assets", "images", "img"].map((d) => join14(root, d));
|
|
26473
|
+
const logos = dirs.flatMap((d) => walk(d)).filter((p) => looksLikeLogo(relative4(root, p).split(sep4).join("/")));
|
|
26474
|
+
const logo = logos.find((p) => /\.svg$/i.test(p)) ?? logos[0];
|
|
26475
|
+
if (logo) return { path: logo, from: "logo" };
|
|
26476
|
+
const oldLogo = icons.find((i) => i.kind === "logo");
|
|
26477
|
+
if (oldLogo) return { path: oldLogo.path, from: "old-logo" };
|
|
26478
|
+
const small = icons.find((i) => i.kind === "icon");
|
|
26479
|
+
if (small) return { path: small.path, from: "old-icon" };
|
|
26480
|
+
return { path: null, from: "letter" };
|
|
26481
|
+
}
|
|
26482
|
+
var CODE_EXT2 = /\.(css|scss|sass|less|html|astro|vue|svelte)$/i;
|
|
26483
|
+
var READ_CAP = 300;
|
|
26484
|
+
function readText(path) {
|
|
26485
|
+
try {
|
|
26486
|
+
return readFileSync10(path, "utf8");
|
|
26487
|
+
} catch {
|
|
26488
|
+
return "";
|
|
26489
|
+
}
|
|
26490
|
+
}
|
|
26491
|
+
function scanDirs(root) {
|
|
26492
|
+
const base = join14(root, MIGRATION_DIR);
|
|
26493
|
+
try {
|
|
26494
|
+
return readdirSync6(base).map((h) => join14(base, h)).filter((d) => existsSync14(join14(d, "home.html")));
|
|
26495
|
+
} catch {
|
|
26496
|
+
return [];
|
|
26497
|
+
}
|
|
26498
|
+
}
|
|
26499
|
+
function homePage(root) {
|
|
26500
|
+
for (const d of scanDirs(root)) return readText(join14(d, "home.html"));
|
|
26501
|
+
for (const f of ["index.html", "public/index.html", "src/index.html", "src/pages/index.astro", "src/pages/index.html", "app/layout.tsx", "src/app/layout.tsx", "src/layouts/Layout.astro"]) {
|
|
26502
|
+
const text = readText(join14(root, f));
|
|
26503
|
+
if (text) return text;
|
|
26504
|
+
}
|
|
26505
|
+
return "";
|
|
26506
|
+
}
|
|
26507
|
+
function siteFacts(root, given = {}) {
|
|
26508
|
+
if (given.color !== void 0 && !/^#[0-9a-f]{6}$/i.test(given.color)) throw new CliError(`Not a color: ${given.color}. Use the form #112233.`, 1, "usage");
|
|
26509
|
+
const home = homePage(root);
|
|
26510
|
+
const id = readSiteIdentity(home);
|
|
26511
|
+
let pkg;
|
|
26512
|
+
try {
|
|
26513
|
+
pkg = JSON.parse(readFileSync10(join14(root, "package.json"), "utf8")).name;
|
|
26514
|
+
} catch {
|
|
26515
|
+
}
|
|
26516
|
+
const name = given.name?.trim() || readProject(root)?.name || id.name || (pkg && !pkg.startsWith("@") ? pkg : "") || basename(root);
|
|
26517
|
+
if (given.color) return { name, line: given.line ?? id.line ?? "", color: given.color, colorFrom: "given" };
|
|
26518
|
+
const old = scanDirs(root).flatMap((d) => walkAll(join14(d, "styles")).map((f) => ({ text: readText(f) })));
|
|
26519
|
+
const fromOld = scanDirs(root).length ? pickBrandColor([{ text: home, themeColor: id.themeColor }, ...old]) : null;
|
|
26520
|
+
const sources = [{ text: home, themeColor: id.themeColor }];
|
|
26521
|
+
for (const f of ["tailwind.config.js", "tailwind.config.ts", "tailwind.config.mjs", "tailwind.config.cjs"]) sources.push({ text: readText(join14(root, f)) });
|
|
26522
|
+
const code = ["src", "app", "styles", "css", "public", "static"].flatMap((d) => walk(join14(root, d))).filter((p) => CODE_EXT2.test(p));
|
|
26523
|
+
const plain2 = readdirSync6(root).filter((f) => CODE_EXT2.test(f)).map((f) => join14(root, f));
|
|
26524
|
+
for (const f of [...plain2, ...code].slice(0, READ_CAP)) sources.push({ text: readText(f) });
|
|
26525
|
+
const color = fromOld ?? pickBrandColor(sources);
|
|
26526
|
+
return { name, line: given.line ?? id.line ?? "", color: color ?? BRAND_DEFAULT_COLOR, colorFrom: color ? "site" : "default" };
|
|
26527
|
+
}
|
|
26528
|
+
function writeSiteFile(root, file2, data) {
|
|
26529
|
+
const target = join14(webRoot(root), file2);
|
|
26530
|
+
if (existsSync14(target)) {
|
|
26531
|
+
const keep = join14(root, BRAND_DIR, "originals");
|
|
26532
|
+
mkdirSync7(keep, { recursive: true });
|
|
26533
|
+
copyFileSync(target, join14(keep, file2));
|
|
26534
|
+
}
|
|
26535
|
+
mkdirSync7(dirname5(target), { recursive: true });
|
|
26536
|
+
writeFileSync11(target, data);
|
|
26537
|
+
}
|
|
26538
|
+
var send = (res, status, body = "", type = "text/plain; charset=utf-8") => {
|
|
26539
|
+
res.writeHead(status, { "content-type": type, "cache-control": "no-store", "x-content-type-options": "nosniff" });
|
|
26540
|
+
res.end(body);
|
|
26541
|
+
};
|
|
26542
|
+
function readBody(req) {
|
|
26543
|
+
return new Promise((ok, fail) => {
|
|
26544
|
+
const parts = [];
|
|
26545
|
+
let size = 0;
|
|
26546
|
+
req.on("data", (c) => {
|
|
26547
|
+
size += c.length;
|
|
26548
|
+
if (size > MAX_UPLOAD) {
|
|
26549
|
+
req.destroy();
|
|
26550
|
+
fail(new Error("too large"));
|
|
26551
|
+
} else parts.push(c);
|
|
26552
|
+
});
|
|
26553
|
+
req.on("end", () => ok(Buffer.concat(parts)));
|
|
26554
|
+
req.on("error", fail);
|
|
26555
|
+
});
|
|
26556
|
+
}
|
|
26557
|
+
function listen(server) {
|
|
26558
|
+
return new Promise((ok, fail) => {
|
|
26559
|
+
server.once("error", fail);
|
|
26560
|
+
server.listen(0, "127.0.0.1", () => {
|
|
26561
|
+
const a = server.address();
|
|
26562
|
+
if (a && typeof a === "object") ok(a.port);
|
|
26563
|
+
else fail(new Error("no port"));
|
|
26564
|
+
});
|
|
26565
|
+
});
|
|
26566
|
+
}
|
|
26567
|
+
function allowed(req, url2, port, token) {
|
|
26568
|
+
return req.headers.host === `127.0.0.1:${port}` && url2.searchParams.get("t") === token;
|
|
26569
|
+
}
|
|
26570
|
+
async function headless(browser, url2, width, until, timeoutMs) {
|
|
26571
|
+
const profile = mkdtempSync(join14(tmpdir(), "deployai-brand-"));
|
|
26572
|
+
const child = spawn2(browser, ["--headless=new", "--disable-gpu", "--no-first-run", "--no-default-browser-check", "--disable-extensions", `--user-data-dir=${profile}`, `--window-size=${width},900`, url2], { stdio: "ignore", windowsHide: true });
|
|
26573
|
+
child.on("error", () => {
|
|
26574
|
+
});
|
|
26575
|
+
let timer;
|
|
26576
|
+
try {
|
|
26577
|
+
await Promise.race([until, new Promise((_, fail) => {
|
|
26578
|
+
timer = setTimeout(() => fail(new Error("timeout")), timeoutMs);
|
|
26579
|
+
})]);
|
|
26580
|
+
} finally {
|
|
26581
|
+
if (timer) clearTimeout(timer);
|
|
26582
|
+
await new Promise((done) => {
|
|
26583
|
+
if (child.exitCode !== null || child.pid === void 0) return done();
|
|
26584
|
+
child.once("exit", () => done());
|
|
26585
|
+
if (process.platform === "win32") spawn2("taskkill", ["/PID", String(child.pid), "/T", "/F"], { stdio: "ignore", windowsHide: true }).on("error", () => {
|
|
26586
|
+
});
|
|
26587
|
+
else child.kill();
|
|
26588
|
+
setTimeout(done, 3e3);
|
|
26589
|
+
});
|
|
26590
|
+
try {
|
|
26591
|
+
rmSync2(profile, { recursive: true, force: true, maxRetries: 3, retryDelay: 200 });
|
|
26592
|
+
} catch {
|
|
26593
|
+
}
|
|
26594
|
+
}
|
|
26595
|
+
}
|
|
26596
|
+
async function drawInBrowser(o, browser) {
|
|
26597
|
+
const token = randomBytes(24).toString("hex");
|
|
26598
|
+
const parts = /* @__PURE__ */ new Map();
|
|
26599
|
+
const source = o.source;
|
|
26600
|
+
let port = 0;
|
|
26601
|
+
let finish;
|
|
26602
|
+
let abort;
|
|
26603
|
+
const finished = new Promise((ok, fail) => {
|
|
26604
|
+
finish = ok;
|
|
26605
|
+
abort = fail;
|
|
26606
|
+
});
|
|
26607
|
+
const allowedFiles = new Set(o.targets.map((t) => t.file));
|
|
26608
|
+
const server = createServer((req, res) => {
|
|
26609
|
+
void (async () => {
|
|
26610
|
+
const url2 = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
26611
|
+
if (!allowed(req, url2, port, token)) return send(res, 403);
|
|
26612
|
+
if (req.method === "GET" && url2.pathname === "/") {
|
|
26613
|
+
return send(res, 200, drawPageHtml({ token, name: o.name, line: o.line, color: o.color, targets: o.targets }), "text/html; charset=utf-8");
|
|
26614
|
+
}
|
|
26615
|
+
if (req.method === "GET" && url2.pathname === "/source") return send(res, 200, source.bytes, source.type);
|
|
26616
|
+
if (req.method !== "POST") return send(res, 404);
|
|
26617
|
+
const body = await readBody(req);
|
|
26618
|
+
if (url2.pathname === "/save") {
|
|
26619
|
+
const file2 = url2.searchParams.get("file") ?? "";
|
|
26620
|
+
if (!allowedFiles.has(file2) || !imageSize(body)) return send(res, 400);
|
|
26621
|
+
parts.set(file2, body);
|
|
26622
|
+
return send(res, 204);
|
|
26623
|
+
}
|
|
26624
|
+
if (url2.pathname === "/fail") {
|
|
26625
|
+
send(res, 204);
|
|
26626
|
+
return abort(new Error(body.toString("utf8").slice(0, 200)));
|
|
26627
|
+
}
|
|
26628
|
+
if (url2.pathname === "/done") {
|
|
26629
|
+
const done = JSON.parse(body.toString("utf8"));
|
|
26630
|
+
const written = [];
|
|
26631
|
+
for (const t of o.targets) {
|
|
26632
|
+
const png = parts.get(t.file);
|
|
26633
|
+
if (!png || t.icoOnly) continue;
|
|
26634
|
+
writeSiteFile(o.root, t.file, png);
|
|
26635
|
+
written.push(t.file);
|
|
26636
|
+
}
|
|
26637
|
+
const ico = ICO_SIZES.flatMap((size) => {
|
|
26638
|
+
const png = parts.get(`ico-${size}.png`);
|
|
26639
|
+
return png ? [{ size, png }] : [];
|
|
26640
|
+
});
|
|
26641
|
+
if (ico.length) {
|
|
26642
|
+
writeSiteFile(o.root, "favicon.ico", buildIco(ico));
|
|
26643
|
+
written.push("favicon.ico");
|
|
26644
|
+
}
|
|
26645
|
+
if (/svg/.test(source.type)) {
|
|
26646
|
+
writeSiteFile(o.root, "favicon.svg", source.bytes);
|
|
26647
|
+
written.push("favicon.svg");
|
|
26648
|
+
}
|
|
26649
|
+
if (o.full && parts.has("icon-192.png") && parts.has("icon-512.png")) {
|
|
26650
|
+
writeSiteFile(o.root, "site.webmanifest", webManifest(o.name, o.color));
|
|
26651
|
+
written.push("site.webmanifest");
|
|
26652
|
+
}
|
|
26653
|
+
send(res, 204);
|
|
26654
|
+
return finish({ written, skipped: done.skipped.filter((f) => !f.startsWith("ico-")) });
|
|
26655
|
+
}
|
|
26656
|
+
return send(res, 404);
|
|
26657
|
+
})().catch(() => {
|
|
26658
|
+
if (!res.headersSent) send(res, 400);
|
|
26659
|
+
});
|
|
26660
|
+
});
|
|
26661
|
+
port = await listen(server);
|
|
26662
|
+
try {
|
|
26663
|
+
await headless(browser, `http://127.0.0.1:${port}/?t=${token}`, 1280, finished, 45e3);
|
|
26664
|
+
return await finished;
|
|
26665
|
+
} finally {
|
|
26666
|
+
server.closeAllConnections();
|
|
26667
|
+
server.close();
|
|
26668
|
+
}
|
|
26669
|
+
}
|
|
26670
|
+
function sourceBytes(path) {
|
|
26671
|
+
return { bytes: readFileSync10(path), type: TYPES[extname(path).toLowerCase()] ?? "application/octet-stream" };
|
|
26672
|
+
}
|
|
26673
|
+
function report(root, r) {
|
|
26674
|
+
const where = relative4(root, webRoot(root)).split(sep4).join("/") || "the site root";
|
|
26675
|
+
out(`Written in ${where}: ${r.written.join(", ")}`);
|
|
26676
|
+
if (r.skipped.length) out(`Left out, the picture is too small to stay sharp: ${r.skipped.join(", ")}. A larger logo makes them.`);
|
|
26677
|
+
const tags2 = brandHeadTags(r.written);
|
|
26678
|
+
if (tags2.length) {
|
|
26679
|
+
out("");
|
|
26680
|
+
out("Add these lines to the <head> of every page, in place of any older icon lines:");
|
|
26681
|
+
tags2.forEach((t) => out(` ${t}`));
|
|
26682
|
+
}
|
|
26683
|
+
}
|
|
26684
|
+
function plainIcon(root, source, name, color) {
|
|
26685
|
+
if (source.path) {
|
|
26686
|
+
const ext = extname(source.path).toLowerCase();
|
|
26687
|
+
if (ext === ".ico" || ext === ".svg" || ext === ".png") {
|
|
26688
|
+
const file2 = `favicon${ext}`;
|
|
26689
|
+
writeSiteFile(root, file2, readFileSync10(source.path));
|
|
26690
|
+
return [file2];
|
|
26691
|
+
}
|
|
26692
|
+
}
|
|
26693
|
+
writeSiteFile(root, "favicon.svg", letterTileSvg(name, color));
|
|
26694
|
+
return ["favicon.svg"];
|
|
26695
|
+
}
|
|
26696
|
+
var FROM = {
|
|
26697
|
+
file: "the picture you named",
|
|
26698
|
+
"old-icon": "the old site's icon",
|
|
26699
|
+
logo: "the logo in this folder",
|
|
26700
|
+
"old-logo": "the old site's logo",
|
|
26701
|
+
letter: "the first letter of the name, since there is no icon or logo"
|
|
26702
|
+
};
|
|
26703
|
+
function printStatus2(root, files) {
|
|
26704
|
+
const web = webRoot(root);
|
|
26705
|
+
const icon = existingFavicon(root);
|
|
26706
|
+
out(icon ? `Icon: ${icon}` : "Icon: missing. Run: npx deployai@latest brand favicon");
|
|
26707
|
+
const missing = files.filter((f) => f !== "favicon.svg" && !existsSync14(join14(web, f)));
|
|
26708
|
+
if (files.length) out(missing.length ? `Missing from the full set: ${missing.join(", ")}` : "The full set is there.");
|
|
26709
|
+
}
|
|
26710
|
+
function printFacts(f, picture2) {
|
|
26711
|
+
const color = f.colorFrom === "site" ? `${f.color}, from the site's own colors` : f.colorFrom === "given" ? f.color : `${f.color}, since the site has no color of its own`;
|
|
26712
|
+
out(`Name: ${f.name}`);
|
|
26713
|
+
out(`Color: ${color}`);
|
|
26714
|
+
out(`Picture: ${picture2}`);
|
|
26715
|
+
}
|
|
26716
|
+
function picture(source, facts) {
|
|
26717
|
+
return source.path ? sourceBytes(source.path) : { bytes: new TextEncoder().encode(letterTileSvg(facts.name, facts.color)), type: "image/svg+xml" };
|
|
26718
|
+
}
|
|
26719
|
+
function withLogoColor(facts, source) {
|
|
26720
|
+
if (facts.colorFrom === "given" || !source.path || !/\.svg$/i.test(source.path)) return facts;
|
|
26721
|
+
const color = svgLogoColor(readText(source.path));
|
|
26722
|
+
return color ? { ...facts, color, colorFrom: "site" } : facts;
|
|
26723
|
+
}
|
|
26724
|
+
function pickSource(root, from) {
|
|
26725
|
+
const source = from ? { path: from, from: "file" } : findSource(root);
|
|
26726
|
+
if (source.path && !existsSync14(source.path)) throw new CliError(`No such file: ${source.path}`, 1, "usage");
|
|
26727
|
+
return source;
|
|
26728
|
+
}
|
|
26729
|
+
async function brandFaviconCommand(root, opts) {
|
|
26730
|
+
if (opts.check) return printStatus2(root, []);
|
|
26731
|
+
const has = existingFavicon(root);
|
|
26732
|
+
if (has && !opts.force) {
|
|
26733
|
+
out(`This site has an icon: ${has}. Nothing changed.`);
|
|
26734
|
+
return;
|
|
26735
|
+
}
|
|
26736
|
+
const source = pickSource(root, opts.from);
|
|
26737
|
+
const facts = withLogoColor(siteFacts(root, opts), source);
|
|
26738
|
+
printFacts(facts, FROM[source.from]);
|
|
26739
|
+
const browser = findBrowser();
|
|
26740
|
+
let result = null;
|
|
26741
|
+
if (browser) {
|
|
26742
|
+
try {
|
|
26743
|
+
result = await drawInBrowser({ root, name: facts.name, line: "", color: facts.color, source: picture(source, facts), targets: FAVICON_TARGETS, full: false }, browser);
|
|
26744
|
+
} catch {
|
|
26745
|
+
out("The browser could not draw it, so the icon is kept as a plain file.");
|
|
26746
|
+
}
|
|
26747
|
+
}
|
|
26748
|
+
if (!result) result = { written: plainIcon(root, source, facts.name, facts.color), skipped: [] };
|
|
26749
|
+
report(root, result);
|
|
26750
|
+
if (source.from === "letter") out("Tell the owner in one line: the icon is the first letter of the name in the site's color, and a logo from them would replace it.");
|
|
26751
|
+
}
|
|
26752
|
+
async function brandIconsCommand(root, opts) {
|
|
26753
|
+
if (opts.check) return printStatus2(root, BRAND_FILES);
|
|
26754
|
+
const browser = findBrowser();
|
|
26755
|
+
if (!browser) throw new CliError("This needs Chrome or Edge on this computer. Install one, or set CHROME_PATH to it, and run this again.", 1, "usage");
|
|
26756
|
+
const source = pickSource(root, opts.from);
|
|
26757
|
+
const facts = withLogoColor(siteFacts(root, opts), source);
|
|
26758
|
+
printFacts(facts, FROM[source.from]);
|
|
26759
|
+
if (facts.line) out(`Line: ${facts.line}`);
|
|
26760
|
+
report(root, await drawInBrowser({ root, name: facts.name, line: facts.line, color: facts.color, source: picture(source, facts), targets: BRAND_TARGETS, full: true }, browser));
|
|
26761
|
+
}
|
|
26762
|
+
async function measurePage(browser, address, width, scripts) {
|
|
26763
|
+
const token = randomBytes(24).toString("hex");
|
|
26764
|
+
let port = 0;
|
|
26765
|
+
let finish;
|
|
26766
|
+
const finished = new Promise((ok) => {
|
|
26767
|
+
finish = ok;
|
|
26768
|
+
});
|
|
26769
|
+
const res = await fetch(address, { headers: { accept: "text/html" }, signal: AbortSignal.timeout(2e4) });
|
|
26770
|
+
const page2 = await res.text();
|
|
26771
|
+
const server = createServer((req, r) => {
|
|
26772
|
+
void (async () => {
|
|
26773
|
+
const url2 = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
26774
|
+
if (!allowed(req, url2, port, token)) return send(r, 403);
|
|
26775
|
+
if (req.method === "POST" && url2.pathname === "/measure") {
|
|
26776
|
+
const body = await readBody(req);
|
|
26777
|
+
send(r, 204);
|
|
26778
|
+
return finish(JSON.parse(body.toString("utf8")));
|
|
26779
|
+
}
|
|
26780
|
+
const head = `<base href="${res.url.replace(/"/g, """)}">${measureScript(`http://127.0.0.1:${port}/measure?t=${token}`)}`;
|
|
26781
|
+
const noPolicy = page2.replace(/<meta[^>]+http-equiv=["']?content-security-policy[^>]*>/gi, "");
|
|
26782
|
+
const clean = scripts ? noPolicy : noPolicy.replace(/<script\b[\s\S]*?<\/script>/gi, "");
|
|
26783
|
+
const html = /<head[^>]*>/i.test(clean) ? clean.replace(/<head[^>]*>/i, (m) => m + head) : head + clean;
|
|
26784
|
+
return send(r, 200, html, "text/html; charset=utf-8");
|
|
26785
|
+
})().catch(() => {
|
|
26786
|
+
if (!r.headersSent) send(r, 400);
|
|
26787
|
+
});
|
|
26788
|
+
});
|
|
26789
|
+
port = await listen(server);
|
|
26790
|
+
try {
|
|
26791
|
+
await headless(browser, `http://127.0.0.1:${port}/?t=${token}`, width, finished, 3e4);
|
|
26792
|
+
return await finished;
|
|
26793
|
+
} finally {
|
|
26794
|
+
server.closeAllConnections();
|
|
26795
|
+
server.close();
|
|
26796
|
+
}
|
|
26797
|
+
}
|
|
26798
|
+
function imageFiles(root) {
|
|
26799
|
+
const dirs = [webRoot(root) === root ? null : webRoot(root), join14(root, "src"), join14(root, MIGRATION_DIR)].filter((d) => !!d);
|
|
26800
|
+
const files = dirs.flatMap((d) => walkAll(d));
|
|
26801
|
+
if (webRoot(root) === root) files.push(...walk(root));
|
|
26802
|
+
return [...new Set(files)].filter((p) => IMAGE_EXT.test(p) && !p.split(sep4).includes("icons") && !BRAND_FILES.includes(basename(p)));
|
|
26803
|
+
}
|
|
26804
|
+
function walkAll(dir) {
|
|
26805
|
+
const found = [];
|
|
26806
|
+
const go = (d) => {
|
|
26807
|
+
let names = [];
|
|
26808
|
+
try {
|
|
26809
|
+
names = readdirSync6(d);
|
|
26810
|
+
} catch {
|
|
26811
|
+
return;
|
|
26812
|
+
}
|
|
26813
|
+
for (const n2 of names) {
|
|
26814
|
+
if (found.length >= WALK_CAP) return;
|
|
26815
|
+
const p = join14(d, n2);
|
|
26816
|
+
try {
|
|
26817
|
+
if (statSync2(p).isDirectory()) {
|
|
26818
|
+
if (!SKIP_DIRS2.has(n2) || n2 === ".deployai") go(p);
|
|
26819
|
+
} else found.push(p);
|
|
26820
|
+
} catch {
|
|
26821
|
+
}
|
|
26822
|
+
}
|
|
26823
|
+
};
|
|
26824
|
+
go(dir);
|
|
26825
|
+
return found;
|
|
26826
|
+
}
|
|
26827
|
+
function judgeFiles(root) {
|
|
26828
|
+
const findings = [];
|
|
26829
|
+
const files = imageFiles(root);
|
|
26830
|
+
let total = 0;
|
|
26831
|
+
for (const f of files) {
|
|
26832
|
+
let bytes;
|
|
26833
|
+
try {
|
|
26834
|
+
bytes = readFileSync10(f);
|
|
26835
|
+
} catch {
|
|
26836
|
+
continue;
|
|
26837
|
+
}
|
|
26838
|
+
const size = imageSize(bytes);
|
|
26839
|
+
if (!size) continue;
|
|
26840
|
+
total++;
|
|
26841
|
+
const verdict = judgeImage({ width: size.width, height: size.height, bytes: bytes.length, format: size.format });
|
|
26842
|
+
if (verdict !== "ok") findings.push({ where: relative4(root, f).split(sep4).join("/"), width: size.width, height: size.height, verdict });
|
|
26843
|
+
}
|
|
26844
|
+
return { findings, total };
|
|
26845
|
+
}
|
|
26846
|
+
var SAY = {
|
|
26847
|
+
ok: "fine",
|
|
26848
|
+
soft: "too few pixels for where it shows",
|
|
26849
|
+
small: "small, check where it shows",
|
|
26850
|
+
compressed: "squeezed until it shows blocks"
|
|
26851
|
+
};
|
|
26852
|
+
async function brandImagesCommand(root, urls, opts) {
|
|
26853
|
+
for (const u of urls) if (!/^https?:\/\//.test(u)) throw new CliError(`Not a page address: ${u}. Use the full address, with https://`, 1, "usage");
|
|
26854
|
+
if (urls.length > 10) throw new CliError("Up to 10 pages at a time. Pick one page of each kind.", 1, "usage");
|
|
26855
|
+
const { findings, total } = judgeFiles(root);
|
|
26856
|
+
const shown = /* @__PURE__ */ new Map();
|
|
26857
|
+
const browser = urls.length ? findBrowser() : null;
|
|
26858
|
+
const unmeasured = [];
|
|
26859
|
+
if (urls.length && !browser) unmeasured.push(...urls);
|
|
26860
|
+
if (browser) {
|
|
26861
|
+
for (const url2 of urls) {
|
|
26862
|
+
out(`Measuring ${url2}`);
|
|
26863
|
+
try {
|
|
26864
|
+
for (const width of [1440, 390]) {
|
|
26865
|
+
let seen = await measurePage(browser, url2, width, true).catch(() => []);
|
|
26866
|
+
if (!seen.length) seen = await measurePage(browser, url2, width, false);
|
|
26867
|
+
for (const m of seen) {
|
|
26868
|
+
if (/\.svg(\?|$)/i.test(m.src) || m.src.startsWith("data:")) continue;
|
|
26869
|
+
const had = shown.get(m.src);
|
|
26870
|
+
if (!had || m.shownWidth > had.shownWidth) shown.set(m.src, m);
|
|
26871
|
+
}
|
|
26872
|
+
}
|
|
26873
|
+
} catch {
|
|
26874
|
+
unmeasured.push(url2);
|
|
26875
|
+
}
|
|
26876
|
+
}
|
|
26877
|
+
}
|
|
26878
|
+
const onPages = [];
|
|
26879
|
+
for (const m of shown.values()) {
|
|
26880
|
+
const verdict = judgeImage({ width: m.width, height: m.height, shownWidth: m.shownWidth });
|
|
26881
|
+
if (verdict !== "ok") onPages.push({ where: m.src, width: m.width, height: m.height, shownWidth: m.shownWidth, verdict, alt: m.alt });
|
|
26882
|
+
}
|
|
26883
|
+
const weak = [...onPages, ...findings];
|
|
26884
|
+
mkdirSync7(join14(root, BRAND_DIR), { recursive: true });
|
|
26885
|
+
const file2 = `${BRAND_DIR}/images.json`;
|
|
26886
|
+
const data = { measuredAt: (/* @__PURE__ */ new Date()).toISOString(), pages: urls, unmeasured, filesChecked: total, imagesMeasured: shown.size, weak };
|
|
26887
|
+
writeFileSync11(join14(root, file2), `${JSON.stringify(data, null, 2)}
|
|
26888
|
+
`);
|
|
26889
|
+
if (opts.json) {
|
|
26890
|
+
out(JSON.stringify(data));
|
|
26891
|
+
return;
|
|
26892
|
+
}
|
|
26893
|
+
out(`Checked ${total} image files${shown.size ? ` and measured ${shown.size} images on the pages` : ""}. Saved in ${file2}. Nothing changed.`);
|
|
26894
|
+
if (unmeasured.length) out(`Not measured, ${browser ? "the page did not answer" : "this needs Chrome or Edge"}: ${unmeasured.join(", ")}`);
|
|
26895
|
+
if (!weak.length) {
|
|
26896
|
+
out("No weak images.");
|
|
26897
|
+
return;
|
|
26898
|
+
}
|
|
26899
|
+
out("");
|
|
26900
|
+
out(rows(weak.slice(0, 40).map((w) => [w.where.length > 70 ? `...${w.where.slice(-67)}` : w.where, `${w.width}x${w.height}${w.shownWidth ? `, shown at ${w.shownWidth}` : ""}: ${SAY[w.verdict]}`])));
|
|
26901
|
+
if (weak.length > 40) out(`and ${weak.length - 40} more in ${file2}`);
|
|
26902
|
+
out("");
|
|
26903
|
+
out("Only with the owner's yes, one by one. Decoration may be replaced. A photo of a real person, product, place or job is never replaced with a made up one: ask the owner for a better photo.");
|
|
26904
|
+
}
|
|
26905
|
+
|
|
25986
26906
|
// src/commands/env.ts
|
|
25987
26907
|
async function readStdin() {
|
|
25988
26908
|
const chunks = [];
|
|
@@ -26061,6 +26981,10 @@ function buildProgram() {
|
|
|
26061
26981
|
migrate.command("verify").description("open every old address on the preview: lists pages that moved, are missing or lost their title or description").argument("<preview>", "the preview address deploy printed").action(async (preview, _opts, cmd) => migrateVerifyCommand(root(cmd), preview));
|
|
26062
26982
|
migrate.command("status").description("a managed move: report a stage to the request (scanning, building, preview_ready, customer_review, live, blocked)").argument("<stage>", "the stage").argument("[note]", "one line: the preview address, what is done, or why it is blocked").action((stage, note, _opts, cmd) => migrateStatusCommand(root(cmd), ctx(cmd), stage, note));
|
|
26063
26983
|
program.command("blocks").description("list our building blocks, or add one to this site (inbox, blog); never writes over a file").argument("[name]", "inbox or blog").action((name, _opts, cmd) => blocksCommand(root(cmd), ctx(cmd), name));
|
|
26984
|
+
const brand = program.command("brand").description("the site's icons and share image, made by code from the site's own name, colors and logo");
|
|
26985
|
+
brand.command("favicon").description("gives the site an icon if it has none: the old site's, else its logo, else a letter").option("--from <file>", "the logo or picture to use").option("--name <name>", "the site's name, for the letter").option("--color <#rrggbb>", "the background color").option("--force", "replace the icon the site has").option("--check", "only say whether the site has an icon").action((opts, cmd) => brandFaviconCommand(root(cmd), opts));
|
|
26986
|
+
brand.command("icons").description("makes every icon size and the 1200 by 630 share image from the site itself").option("--from <file>", "use this picture instead of the logo it finds").option("--name <name>", "correct the name it reads").option("--line <text>", "correct the line it reads").option("--color <#rrggbb>", "correct the color it reads").option("--check", "only list what is missing").action((opts, cmd) => brandIconsCommand(root(cmd), opts));
|
|
26987
|
+
brand.command("images").description("reports images too weak for where they show, by measuring them; never changes one").argument("[pages...]", "up to 10 page addresses to measure in a browser").option("--json", "print the result as JSON").action((pages, opts, cmd) => brandImagesCommand(root(cmd), pages, opts));
|
|
26064
26988
|
program.command("addons").description("the add-ons of this site: which it has, which are done and which is next; addons run runs them all in one go").argument("[action]", "run: every add-on that is not done, one after the other").action((action, _opts, cmd) => {
|
|
26065
26989
|
if (!action) return addonsCommand(root(cmd), ctx(cmd));
|
|
26066
26990
|
if (action === "run") return addonsRunCommand(root(cmd), ctx(cmd));
|