deployai 0.1.0-beta.44 → 0.1.0-beta.46
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 +387 -49
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ It stays up to date by itself. `npx deployai@latest` always runs the newest vers
|
|
|
53
53
|
| `deployai promote v5` | Puts version 5 live. New database changes (SQL) are shown and run first, after a yes; SQL that removes data needs the database name typed. An agent passes `--approve-sql <code>` only after the owner said yes, and never for SQL that removes data. |
|
|
54
54
|
| `deployai sql v5` | The database changes version 5 runs before it goes live. |
|
|
55
55
|
| `deployai status` | Site state, address, live version, the newest version when it is not live yet (with the promote command once it is ready), and queue. When the live site is closed to the country you run this from, it says so and how to open it, or to use a VPN. |
|
|
56
|
+
| `deployai logs` | Live logs of the linked site's code: each request it answered, its console lines and errors, with the time, for up to 10 minutes (Ctrl+C stops). `--errors` keeps only errors, `--json` prints one JSON object a line. For the site's owner or an editor; the lines may hold your visitors' data, so they go only to your terminal and DeployAI never stores them. |
|
|
56
57
|
| `deployai deploy --guest` | No login needed: puts the site live as a temporary site with a claim link. More below. |
|
|
57
58
|
| `deployai pull` | Downloads the code of the linked site's live version into this empty folder. Needs login. |
|
|
58
59
|
| `deployai pull --history` | The same, with the site's history as git commits, one per version up to the live one, oldest first. |
|
package/dist/index.js
CHANGED
|
@@ -21352,6 +21352,9 @@ var Version = external_exports.object({
|
|
|
21352
21352
|
});
|
|
21353
21353
|
var VersionsResponse = external_exports.object({ versions: external_exports.array(Version) });
|
|
21354
21354
|
var RequestsResponse = external_exports.object({ lines: external_exports.array(external_exports.object({ at: external_exports.number(), method: external_exports.string(), path: external_exports.string(), status: external_exports.number(), outcome: external_exports.string(), country: external_exports.string(), dropped: external_exports.number().optional() })).nullable() });
|
|
21355
|
+
var LogLine = external_exports.object({ at: external_exports.number(), kind: external_exports.enum(["request", "log", "exception"]), level: external_exports.string(), text: external_exports.string() });
|
|
21356
|
+
var LogsReady = external_exports.object({ name: external_exports.string(), url: external_exports.string().nullable(), until: external_exports.number() });
|
|
21357
|
+
var LogsEnd = external_exports.object({ reason: external_exports.enum(["time", "replaced", "cloudflare"]) });
|
|
21355
21358
|
var EnvSetRequest = external_exports.object({ projectId: external_exports.string(), key: external_exports.string(), value: external_exports.string(), secret: external_exports.boolean().default(true) });
|
|
21356
21359
|
var EnvSetResponse = external_exports.object({ ok: external_exports.literal(true), key: external_exports.string(), secret: external_exports.boolean(), delivered: external_exports.boolean() });
|
|
21357
21360
|
var EnvRemoveRequest = external_exports.object({ projectId: external_exports.string(), key: external_exports.string() });
|
|
@@ -21410,7 +21413,9 @@ var StatusResponse = external_exports.object({
|
|
|
21410
21413
|
/** The live site's country rule shuts out the country this call came from (D-682). `settingsUrl` is null when only the owner can change it. */
|
|
21411
21414
|
closedHere: external_exports.object({ country: external_exports.string(), countries: external_exports.array(external_exports.string()), settingsUrl: external_exports.string().nullable() }).nullable().optional(),
|
|
21412
21415
|
/** How the live version went live and when (D-817). `via` is cli, chat, dashboard or deploy; null for one from before it was recorded. */
|
|
21413
|
-
liveVia: external_exports.object({ via: external_exports.string().nullable(), at: external_exports.string() }).nullable().optional()
|
|
21416
|
+
liveVia: external_exports.object({ via: external_exports.string().nullable(), at: external_exports.string() }).nullable().optional(),
|
|
21417
|
+
/** The newest version that waits in an open pull request on GitHub (D-997), with the line to print in each language. */
|
|
21418
|
+
githubPull: external_exports.object({ version: external_exports.number(), number: external_exports.number(), url: external_exports.string(), he: external_exports.string(), en: external_exports.string() }).nullable().optional()
|
|
21414
21419
|
});
|
|
21415
21420
|
var ApiError = external_exports.object({
|
|
21416
21421
|
error: external_exports.string(),
|
|
@@ -21671,6 +21676,7 @@ var ARCH_EDGES = [
|
|
|
21671
21676
|
{ id: "uptime-web", from: "uptime-worker", to: "web", kind: "http", label: "health check" },
|
|
21672
21677
|
{ id: "dispatch-requests", from: "dispatch", to: "requests-worker", kind: "http", label: "request lines, service binding" },
|
|
21673
21678
|
{ id: "web-requests", from: "web", to: "requests-worker", kind: "http", label: "signed reads" },
|
|
21679
|
+
{ id: "web-dispatch-tail", from: "web", to: "dispatch", kind: "http", label: "live tail for deployai logs (D-991)" },
|
|
21674
21680
|
{ id: "web-app-uptime", from: "web", to: "app-uptime", kind: "http", label: "signed /__app/ calls" },
|
|
21675
21681
|
{ id: "web-app-cron", from: "web", to: "app-cron", kind: "http", label: "signed /__app/ calls" },
|
|
21676
21682
|
{ id: "app-cron-web", from: "app-cron", to: "web", kind: "http", label: "failure and slow-run email" },
|
|
@@ -22711,6 +22717,7 @@ function deployToolFromEnv(env) {
|
|
|
22711
22717
|
}
|
|
22712
22718
|
|
|
22713
22719
|
// ../shared/src/start-flow.ts
|
|
22720
|
+
var START_ID_ALPHABET = "abcdefghjkmnpqrstuvwxyz23456789";
|
|
22714
22721
|
var START_ID_RE = /^[a-hjkmnp-z2-9]{10}$/;
|
|
22715
22722
|
var MIGRATION_DIR = ".deployai/migration";
|
|
22716
22723
|
var BRIEF_FILE = ".deployai/brief.md";
|
|
@@ -22910,6 +22917,8 @@ var CLI_MAP_NODES = [
|
|
|
22910
22917
|
n("api-sql", "server", "/api/cli/sql", "\u05D4\u05E9\u05D9\u05E0\u05D5\u05D9\u05D9\u05DD \u05E9\u05DE\u05D7\u05DB\u05D9\u05DD \u05DC\u05D0\u05D9\u05E9\u05D5\u05E8, \u05D5\u05E7\u05D5\u05D3 \u05E9\u05DE\u05D7\u05D1\u05E8 \u05D0\u05EA \u05D4\u05D0\u05D9\u05E9\u05D5\u05E8 \u05D0\u05DC\u05D9\u05D4\u05DD.", "The changes that wait for a yes, and a code that ties the yes to them."),
|
|
22911
22918
|
n("cmd-versions", "cli", "versions", "\u05E8\u05E9\u05D9\u05DE\u05EA \u05D4\u05D2\u05E8\u05E1\u05D0\u05D5\u05EA \u05E9\u05DC \u05D4\u05D0\u05EA\u05E8.", "The site's versions."),
|
|
22912
22919
|
n("cmd-requests", "cli", "requests / requests open <address>", "\u05D4\u05D1\u05E7\u05E9\u05D5\u05EA \u05D4\u05E0\u05DB\u05E0\u05E1\u05D5\u05EA \u05DC\u05D0\u05EA\u05E8 \u05D5\u05DE\u05D4 \u05E7\u05E8\u05D4 \u05DC\u05D4\u05DF, \u05D5\u05E4\u05EA\u05D9\u05D7\u05EA \u05DB\u05EA\u05D5\u05D1\u05EA \u05DB\u05DE\u05D5 webhook \u05DC\u05DB\u05DC \u05D4\u05DE\u05D3\u05D9\u05E0\u05D5\u05EA.", "The site's incoming requests and what happened to them, and opening an address such as a webhook to every country."),
|
|
22920
|
+
n("cmd-logs", "cli", "logs [--json] [--errors]", "\u05DC\u05D5\u05D2\u05D9\u05DD \u05D7\u05D9\u05D9\u05DD \u05E9\u05DC \u05D4\u05E7\u05D5\u05D3 \u05E9\u05DC \u05D4\u05D0\u05EA\u05E8: \u05D1\u05E7\u05E9\u05D5\u05EA, \u05E9\u05D5\u05E8\u05D5\u05EA console \u05D5\u05E9\u05D2\u05D9\u05D0\u05D5\u05EA, \u05E2\u05D3 10 \u05D3\u05E7\u05D5\u05EA. \u05E8\u05E7 \u05DC\u05D1\u05E2\u05DC\u05D9\u05DD \u05D0\u05D5 \u05DC\u05E2\u05D5\u05E8\u05DA, \u05D5\u05DC\u05D0 \u05E0\u05E9\u05DE\u05E8\u05D9\u05DD \u05D0\u05E6\u05DC\u05E0\u05D5.", "Live logs of the site's code: requests, console lines and errors, up to 10 minutes. Owner or editor only, never stored by us."),
|
|
22921
|
+
n("api-logs", "server", "/api/cli/logs", "\u05D6\u05E8\u05DD \u05D0\u05D9\u05E8\u05D5\u05E2\u05D9\u05DD \u05DE\u05D4\u05BEtail \u05E9\u05DC \u05D4\u05BEdispatch Worker, \u05DE\u05E1\u05D5\u05E0\u05DF \u05DC\u05E1\u05E7\u05E8\u05D9\u05E4\u05D8 \u05E9\u05DC \u05D4\u05D0\u05EA\u05E8 \u05D1\u05DC\u05D1\u05D3. \u05D1\u05DC\u05D9 \u05DB\u05D5\u05EA\u05E8\u05D5\u05EA \u05D5\u05D1\u05DC\u05D9 IP.", "An event stream from the dispatch Worker's tail, filtered to the site's own script. No headers and no IP."),
|
|
22913
22922
|
n("api-requests", "server", "/api/cli/requests", "\u05D4\u05E8\u05E9\u05D9\u05DE\u05D4 \u05D1\u05DC\u05D9 IP \u05D5\u05D1\u05DC\u05D9 \u05EA\u05D5\u05DB\u05DF, \u05D5\u05E4\u05EA\u05D9\u05D7\u05D4 \u05D0\u05D5 \u05E1\u05D2\u05D9\u05E8\u05D4 \u05E9\u05DC \u05DB\u05EA\u05D5\u05D1\u05EA.", "The list with no IP and no content, and opening or closing an address."),
|
|
22914
22923
|
n("cmd-rollback", "cli", "rollback v<N>", "\u05D7\u05D5\u05D6\u05E8 \u05DC\u05D2\u05E8\u05E1\u05D4 \u05E7\u05D5\u05D3\u05DE\u05EA.", "Goes back to an earlier version."),
|
|
22915
22924
|
n("cmd-addons", "cli", "addons / addon next / addon buy", "\u05D4\u05EA\u05D5\u05E1\u05E4\u05D9\u05DD \u05E9\u05DC \u05D4\u05D0\u05EA\u05E8, \u05D4\u05E9\u05DC\u05D1 \u05D4\u05D1\u05D0 \u05E9\u05DC \u05EA\u05D5\u05E1\u05E3 \u05E9\u05E0\u05E7\u05E0\u05D4, \u05D5\u05E7\u05D9\u05E9\u05D5\u05E8 \u05E7\u05E0\u05D9\u05D9\u05D4 \u05DC\u05D1\u05E2\u05DC \u05D4\u05D0\u05EA\u05E8.", "The site's add-ons, the next step of one it bought, and a buy link for the owner."),
|
|
@@ -22993,6 +23002,7 @@ var CLI_MAP_EDGES = [
|
|
|
22993
23002
|
e("cmd-telemetry", "api-check"),
|
|
22994
23003
|
e("cmd-feedback", "api-check"),
|
|
22995
23004
|
e("cmd-requests", "api-requests"),
|
|
23005
|
+
e("cmd-logs", "api-logs"),
|
|
22996
23006
|
e("cmd-status", "api-status"),
|
|
22997
23007
|
e("cmd-versions", "api-status"),
|
|
22998
23008
|
e("cmd-promote", "api-promote"),
|
|
@@ -23621,6 +23631,7 @@ var ENV_KEYS = {
|
|
|
23621
23631
|
BETTER_AUTH_SECRET: { scope: "own", section: "app", required: ["server"], sample: { local: "change-me-to-a-long-random-string", server: "" }, about: "Signs login sessions and our own links; changing it logs everyone out. 32 characters or more in production: openssl rand -base64 48" },
|
|
23622
23632
|
APP_SHOTS_SITES: { scope: "local", section: "app", about: "The demo app sites whose product page screenshots are taken again with each new app version (D-609): uptime:<siteId>:<host>,cron:<siteId>:<host>. Unset: no automatic screenshots; pnpm apps:shots still works by hand." },
|
|
23623
23633
|
DEV_SUPERADMIN_PASSWORD: { scope: "local", section: "app", about: "The superadmin password after every local wipe. Without it the one in apps/web/local-logins.md is kept (D-100)." },
|
|
23634
|
+
POSTHOG_PROJECT_KEY: { scope: "own", section: "app", about: "PostHog project key (phc_..., EU cloud) for session replay on our own sign up, move and pay pages, Israel only (D-999). Read by the server at request time, so no rebuild. A separate project for dev and prod. Empty records nothing." },
|
|
23624
23635
|
NEXT_PUBLIC_SUPPORT_WHATSAPP: { scope: "same", section: "app", about: "The WhatsApp number people reach us on, digits with the country code (972...). Empty shows only the email (D-237)." },
|
|
23625
23636
|
OPENAI_APPS_CHALLENGE: { scope: "server", section: "app", about: "The domain check token from the OpenAI platform portal (Plugins, domain verification), served as plain text at /.well-known/openai-apps-challenge (D-474). Unset: that page is a 404." },
|
|
23626
23637
|
TUNNEL_ORIGIN_CERT: { scope: "local", section: "app", about: "The cloudflared login certificate pnpm dev:public checks. Default ~/.cloudflared/cert.pem." },
|
|
@@ -23828,6 +23839,44 @@ var AGENT_POINTER = "Read DEPLOYAI.md before your first answer and before you wr
|
|
|
23828
23839
|
var SITE_COPY_RULE = "Words on the site: write each language from what a visitor must know, the way a native writer of that language says it, never word for word from another language. Read each page alone in its own language: if it sounds translated, rewrite it. Keep one term for each thing in every language (when .deployai/glossary.md exists, use its terms and add new ones to it), and dates, prices, phone numbers and addresses in the local form of that language. Never reword text the owner wrote without asking. When you wrote a language you are not sure of, or a legal page, say in one line that a native speaker should read it.";
|
|
23829
23840
|
var FOLDER_READY_RULE = `This folder is already set up. When the owner has not asked for anything yet, say only, in their language: "The folder is set up and ready. What do you want to change?" Add the site's name when .deployai/project.json has it. If the folder has no site files yet, ask instead: "The folder is set up and ready. What do you want to build?" Never ask them for a start line, a command or an id. While the folder holds a site, never offer a sample or a new start: go on with that site.`;
|
|
23830
23841
|
|
|
23842
|
+
// ../shared/src/blocked-reasons.ts
|
|
23843
|
+
var BLOCKED_REASONS = [
|
|
23844
|
+
// migrate verify: old pages on the preview
|
|
23845
|
+
"pages_missing",
|
|
23846
|
+
"pages_moved",
|
|
23847
|
+
"pages_error",
|
|
23848
|
+
"title_lost",
|
|
23849
|
+
"description_lost",
|
|
23850
|
+
// migrate verify: tags and connections (the tag finding's own problem)
|
|
23851
|
+
"tag_lost",
|
|
23852
|
+
"trigger_lost",
|
|
23853
|
+
"field_lost",
|
|
23854
|
+
"verification_lost",
|
|
23855
|
+
"file_lost",
|
|
23856
|
+
"blocked_by_headers",
|
|
23857
|
+
"event_lost",
|
|
23858
|
+
// migrate verify: what is left of the old site
|
|
23859
|
+
"builder_credit",
|
|
23860
|
+
"vendor_files",
|
|
23861
|
+
"old_host_assets",
|
|
23862
|
+
// migrate scan
|
|
23863
|
+
"source_closed",
|
|
23864
|
+
// deploy
|
|
23865
|
+
"check_blocked",
|
|
23866
|
+
"build_failed",
|
|
23867
|
+
"preview_down",
|
|
23868
|
+
"not_live",
|
|
23869
|
+
// start
|
|
23870
|
+
"login_wait",
|
|
23871
|
+
"other_account",
|
|
23872
|
+
// sync
|
|
23873
|
+
"sync_conflicts"
|
|
23874
|
+
];
|
|
23875
|
+
function blockedLine(codes) {
|
|
23876
|
+
const set2 = new Set(codes);
|
|
23877
|
+
return BLOCKED_REASONS.filter((c) => set2.has(c)).join(" ");
|
|
23878
|
+
}
|
|
23879
|
+
|
|
23831
23880
|
// ../shared/src/deployai-md.ts
|
|
23832
23881
|
var DEPLOYAI_MD = `# DeployAI rules
|
|
23833
23882
|
|
|
@@ -24438,10 +24487,10 @@ function parseSiteCron(expr) {
|
|
|
24438
24487
|
const raw = expr.trim().split(/\s+/);
|
|
24439
24488
|
if (raw.length !== 5 || expr.length > 100) return { error: "A schedule has five parts: minute, hour, day of month, month, day of week." };
|
|
24440
24489
|
const [mi, ho, dm, mo, dw] = raw;
|
|
24441
|
-
const
|
|
24490
|
+
const minutes2 = field(mi, 0, 59);
|
|
24442
24491
|
const hours = field(ho, 0, 23);
|
|
24443
24492
|
const months = field(mo, 1, 12, MONTHS);
|
|
24444
|
-
if (!
|
|
24493
|
+
if (!minutes2 || !hours || !months) return { error: "The minute, hour or month part does not read." };
|
|
24445
24494
|
const dom = { any: dm === "*" || dm === "?", days: [], last: false, lastWeekday: false, nearest: [] };
|
|
24446
24495
|
if (!dom.any) {
|
|
24447
24496
|
for (const part of dm.split(",")) {
|
|
@@ -24476,7 +24525,7 @@ function parseSiteCron(expr) {
|
|
|
24476
24525
|
}
|
|
24477
24526
|
}
|
|
24478
24527
|
}
|
|
24479
|
-
return { raw: [mi, ho, dm, mo, dw], minutes, hours, dom, months, dow };
|
|
24528
|
+
return { raw: [mi, ho, dm, mo, dw], minutes: minutes2, hours, dom, months, dow };
|
|
24480
24529
|
}
|
|
24481
24530
|
var isSiteCronSpec = (x) => !("error" in x);
|
|
24482
24531
|
var lastDayOf = (y, m) => new Date(Date.UTC(y, m, 0)).getUTCDate();
|
|
@@ -24790,14 +24839,16 @@ function updateProject(root, patch) {
|
|
|
24790
24839
|
|
|
24791
24840
|
// src/errors.ts
|
|
24792
24841
|
var CliError = class extends Error {
|
|
24793
|
-
constructor(message, exitCode = 1, category = "error") {
|
|
24842
|
+
constructor(message, exitCode = 1, category = "error", reason2) {
|
|
24794
24843
|
super(message);
|
|
24795
24844
|
this.exitCode = exitCode;
|
|
24796
24845
|
this.category = category;
|
|
24846
|
+
this.reason = reason2;
|
|
24797
24847
|
this.name = "CliError";
|
|
24798
24848
|
}
|
|
24799
24849
|
exitCode;
|
|
24800
24850
|
category;
|
|
24851
|
+
reason;
|
|
24801
24852
|
};
|
|
24802
24853
|
|
|
24803
24854
|
// src/i18n.ts
|
|
@@ -25101,6 +25152,17 @@ var M = {
|
|
|
25101
25152
|
runLink: " Run: npx deployai@latest link",
|
|
25102
25153
|
nextSteps: "Next steps",
|
|
25103
25154
|
readme: "Read README.md in the folder for what each file does.",
|
|
25155
|
+
logsWatching: "Live logs of {name} ({url}) until {time}. Ctrl+C stops.",
|
|
25156
|
+
logsErrorsOnly: "Errors only.",
|
|
25157
|
+
logsNote: "Only what runs the site's code shows here: pages and files sent as they are do not. DeployAI does not save these lines.",
|
|
25158
|
+
logsEndTime: "Stopped after 10 minutes. To keep watching, run: npx deployai@latest logs",
|
|
25159
|
+
logsEndReplaced: "Stopped: logs of this site were opened somewhere else. One at a time per site.",
|
|
25160
|
+
logsEndCloudflare: "The logs stopped on Cloudflare's side. Run the same command again.",
|
|
25161
|
+
logsEndClosed: "The connection to DeployAI closed. Run the same command again.",
|
|
25162
|
+
logsStopped: "Stopped.",
|
|
25163
|
+
logsNotLive: 'This site has nothing live yet, so there are no logs. Put a version live first: npx deployai@latest deploy -m "<message>" --live',
|
|
25164
|
+
logsSiteOff: "The site is off, so its code does not run and there are no logs. The owner turns it back on in the dashboard.",
|
|
25165
|
+
logsUnavailable: "Logs cannot be read right now. Try again in a few minutes.",
|
|
25104
25166
|
states: { online: "live", building: "building", ready: "ready for review", failed: "failed", paused: "paused", off: "off", queued: "waiting", replaced: "replaced by a newer upload", deleted: "deleted", new: "new" }
|
|
25105
25167
|
},
|
|
25106
25168
|
he: {
|
|
@@ -25391,6 +25453,17 @@ var M = {
|
|
|
25391
25453
|
runLink: " \u05D4\u05E8\u05D9\u05E6\u05D5: npx deployai@latest link",
|
|
25392
25454
|
nextSteps: "\u05D4\u05E9\u05DC\u05D1\u05D9\u05DD \u05D4\u05D1\u05D0\u05D9\u05DD",
|
|
25393
25455
|
readme: "\u05D1\u05BEREADME.md \u05E9\u05D1\u05EA\u05D9\u05E7\u05D9\u05D9\u05D4 \u05DB\u05EA\u05D5\u05D1 \u05DE\u05D4 \u05DB\u05DC \u05E7\u05D5\u05D1\u05E5 \u05E2\u05D5\u05E9\u05D4.",
|
|
25456
|
+
logsWatching: "\u05DC\u05D5\u05D2\u05D9\u05DD \u05D7\u05D9\u05D9\u05DD \u05E9\u05DC {name} ({url}) \u05E2\u05D3 {time}. \u05DC\u05E2\u05E6\u05D9\u05E8\u05D4: Ctrl+C.",
|
|
25457
|
+
logsErrorsOnly: "\u05E8\u05E7 \u05E9\u05D2\u05D9\u05D0\u05D5\u05EA.",
|
|
25458
|
+
logsNote: "\u05DE\u05D5\u05E4\u05D9\u05E2 \u05DB\u05D0\u05DF \u05E8\u05E7 \u05DE\u05D4 \u05E9\u05DE\u05E8\u05D9\u05E5 \u05D0\u05EA \u05D4\u05E7\u05D5\u05D3 \u05E9\u05DC \u05D4\u05D0\u05EA\u05E8. \u05D3\u05E4\u05D9\u05DD \u05D5\u05E7\u05D1\u05E6\u05D9\u05DD \u05E9\u05E0\u05E9\u05DC\u05D7\u05D9\u05DD \u05DB\u05DE\u05D5 \u05E9\u05D4\u05DD \u05DC\u05D0 \u05DE\u05D5\u05E4\u05D9\u05E2\u05D9\u05DD. DeployAI \u05DC\u05D0 \u05E9\u05D5\u05DE\u05E8\u05EA \u05D0\u05EA \u05D4\u05E9\u05D5\u05E8\u05D5\u05EA \u05D4\u05D0\u05DC\u05D4.",
|
|
25459
|
+
logsEndTime: "\u05E2\u05E6\u05E8\u05E0\u05D5 \u05D0\u05D7\u05E8\u05D9 10 \u05D3\u05E7\u05D5\u05EA. \u05DB\u05D3\u05D9 \u05DC\u05D4\u05DE\u05E9\u05D9\u05DA \u05DC\u05E8\u05D0\u05D5\u05EA, \u05D4\u05E8\u05D9\u05E6\u05D5: npx deployai@latest logs",
|
|
25460
|
+
logsEndReplaced: "\u05E0\u05E2\u05E6\u05E8: \u05D4\u05DC\u05D5\u05D2\u05D9\u05DD \u05E9\u05DC \u05D4\u05D0\u05EA\u05E8 \u05D4\u05D6\u05D4 \u05E0\u05E4\u05EA\u05D7\u05D5 \u05D1\u05DE\u05E7\u05D5\u05DD \u05D0\u05D7\u05E8. \u05D0\u05E4\u05E9\u05E8 \u05DC\u05E6\u05E4\u05D5\u05EA \u05D1\u05D4\u05DD \u05E8\u05E7 \u05D1\u05DE\u05E7\u05D5\u05DD \u05D0\u05D7\u05D3 \u05D1\u05DB\u05DC \u05E4\u05E2\u05DD.",
|
|
25461
|
+
logsEndCloudflare: "\u05D4\u05DC\u05D5\u05D2\u05D9\u05DD \u05E0\u05E2\u05E6\u05E8\u05D5 \u05D1\u05E6\u05D3 \u05E9\u05DC Cloudflare. \u05D4\u05E8\u05D9\u05E6\u05D5 \u05E9\u05D5\u05D1 \u05D0\u05EA \u05D0\u05D5\u05EA\u05D4 \u05E4\u05E7\u05D5\u05D3\u05D4.",
|
|
25462
|
+
logsEndClosed: "\u05D4\u05D7\u05D9\u05D1\u05D5\u05E8 \u05DC\u05BEDeployAI \u05E0\u05E1\u05D2\u05E8. \u05D4\u05E8\u05D9\u05E6\u05D5 \u05E9\u05D5\u05D1 \u05D0\u05EA \u05D0\u05D5\u05EA\u05D4 \u05E4\u05E7\u05D5\u05D3\u05D4.",
|
|
25463
|
+
logsStopped: "\u05E0\u05E2\u05E6\u05E8.",
|
|
25464
|
+
logsNotLive: '\u05DC\u05D0\u05EA\u05E8 \u05D4\u05D6\u05D4 \u05E2\u05D5\u05D3 \u05D0\u05D9\u05DF \u05D2\u05E8\u05E1\u05D4 \u05D1\u05D0\u05D5\u05D5\u05D9\u05E8, \u05D5\u05DC\u05DB\u05DF \u05D0\u05D9\u05DF \u05DC\u05D5\u05D2\u05D9\u05DD. \u05D4\u05E2\u05DC\u05D5 \u05E7\u05D5\u05D3\u05DD \u05D2\u05E8\u05E1\u05D4 \u05DC\u05D0\u05D5\u05D5\u05D9\u05E8: npx deployai@latest deploy -m "<message>" --live',
|
|
25465
|
+
logsSiteOff: "\u05D4\u05D0\u05EA\u05E8 \u05DB\u05D1\u05D5\u05D9, \u05D5\u05DC\u05DB\u05DF \u05D4\u05E7\u05D5\u05D3 \u05E9\u05DC\u05D5 \u05DC\u05D0 \u05E8\u05E5 \u05D5\u05D0\u05D9\u05DF \u05DC\u05D5\u05D2\u05D9\u05DD. \u05D1\u05E2\u05DC \u05D4\u05D0\u05EA\u05E8 \u05DE\u05D3\u05DC\u05D9\u05E7 \u05D0\u05D5\u05EA\u05D5 \u05DE\u05D7\u05D3\u05E9 \u05D1\u05DC\u05D5\u05D7 \u05D4\u05D1\u05E7\u05E8\u05D4.",
|
|
25466
|
+
logsUnavailable: "\u05D0\u05D9 \u05D0\u05E4\u05E9\u05E8 \u05DC\u05E7\u05E8\u05D5\u05D0 \u05DC\u05D5\u05D2\u05D9\u05DD \u05DB\u05E8\u05D2\u05E2. \u05E0\u05E1\u05D5 \u05E9\u05D5\u05D1 \u05D1\u05E2\u05D5\u05D3 \u05DB\u05DE\u05D4 \u05D3\u05E7\u05D5\u05EA.",
|
|
25394
25467
|
states: { online: "\u05D1\u05D0\u05D5\u05D5\u05D9\u05E8", building: "\u05D1\u05D1\u05E0\u05D9\u05D9\u05D4", ready: "\u05DE\u05D7\u05DB\u05D4 \u05DC\u05D0\u05D9\u05E9\u05D5\u05E8", failed: "\u05E0\u05DB\u05E9\u05DC", paused: "\u05DE\u05D5\u05E9\u05D4\u05D4", off: "\u05DB\u05D1\u05D5\u05D9", queued: "\u05D1\u05EA\u05D5\u05E8", replaced: "\u05D4\u05D5\u05D7\u05DC\u05E4\u05D4 \u05D1\u05D4\u05E2\u05DC\u05D0\u05D4 \u05D7\u05D3\u05E9\u05D4 \u05D9\u05D5\u05EA\u05E8", deleted: "\u05E0\u05DE\u05D7\u05E7", new: "\u05D7\u05D3\u05E9" }
|
|
25395
25468
|
}
|
|
25396
25469
|
};
|
|
@@ -25428,7 +25501,7 @@ function formatBytes(n2) {
|
|
|
25428
25501
|
}
|
|
25429
25502
|
|
|
25430
25503
|
// src/version.ts
|
|
25431
|
-
var CLI_VERSION = "0.1.0-beta.
|
|
25504
|
+
var CLI_VERSION = "0.1.0-beta.46";
|
|
25432
25505
|
|
|
25433
25506
|
// src/api.ts
|
|
25434
25507
|
function apiContext(apiFlag, root) {
|
|
@@ -25615,7 +25688,7 @@ import { arch as arch2, platform as platform2 } from "os";
|
|
|
25615
25688
|
var TELEMETRY_SENT = [
|
|
25616
25689
|
"Install id (random, made on this computer) and CLI version",
|
|
25617
25690
|
"After each command: command name, result (success, blocked, error category), how long it took and which AI tool ran it, when the environment says so. A start that has to wait for a login sends one more, before it waits",
|
|
25618
|
-
"After an error: the error line with addresses, paths, file names, emails and ids removed, or the wrong command or flag name",
|
|
25691
|
+
"After an error: the error line with addresses, paths, file names, emails and ids removed, or the wrong command or flag name. After a blocked result: a short code for the check that stopped it (for example pages_missing)",
|
|
25619
25692
|
"A note your agent sends with the feedback command: what got in its way and what would help, or in general words what owners ask it for, one sentence each, shown to you as it was sent",
|
|
25620
25693
|
"Linked project id, detected framework and version",
|
|
25621
25694
|
"After each check: compatible or not, blocker and warning codes (for example fs_write)",
|
|
@@ -25679,7 +25752,7 @@ function buildTelemetryEvent(installId, command, result, errorCategory, extra =
|
|
|
25679
25752
|
const tool = deployToolFromEnv(process.env);
|
|
25680
25753
|
if (tool) ev.tool = tool;
|
|
25681
25754
|
if (extra.durationMs !== void 0) ev.durationMs = Math.max(0, Math.round(extra.durationMs));
|
|
25682
|
-
if (result === "error" && extra.errorLine) ev.errorLine = scrubText(extra.errorLine, ERROR_LINE_MAX);
|
|
25755
|
+
if ((result === "error" || result === "blocked") && extra.errorLine) ev.errorLine = scrubText(extra.errorLine, ERROR_LINE_MAX);
|
|
25683
25756
|
return ev;
|
|
25684
25757
|
}
|
|
25685
25758
|
async function sendTelemetryEvent(ctx, event) {
|
|
@@ -25700,6 +25773,73 @@ async function sendTelemetryEvent(ctx, event) {
|
|
|
25700
25773
|
}
|
|
25701
25774
|
}
|
|
25702
25775
|
|
|
25776
|
+
// src/blocked.ts
|
|
25777
|
+
var reasons = /* @__PURE__ */ new Set();
|
|
25778
|
+
function blockedBy(...codes) {
|
|
25779
|
+
for (const c of codes) reasons.add(c);
|
|
25780
|
+
}
|
|
25781
|
+
function takeBlockedLine() {
|
|
25782
|
+
const line = blockedLine(reasons);
|
|
25783
|
+
reasons.clear();
|
|
25784
|
+
return line || void 0;
|
|
25785
|
+
}
|
|
25786
|
+
|
|
25787
|
+
// src/did-you-mean.ts
|
|
25788
|
+
var RUN = "npx deployai@latest";
|
|
25789
|
+
var VALUE_OPTIONS = /* @__PURE__ */ new Set(["--api", "--dir", "-C", "--lang"]);
|
|
25790
|
+
var MEANS = {
|
|
25791
|
+
connect: [
|
|
25792
|
+
"There is no connect command.",
|
|
25793
|
+
`To connect this folder to the site the owner made on DeployAI, run the line the site gave: ${RUN} start <id>`,
|
|
25794
|
+
`For a site that is already on DeployAI: ${RUN} link`,
|
|
25795
|
+
"To connect a domain, the owner opens the site's Domains page in the DeployAI dashboard. To connect an AI chat: https://deployai.co.il/en/connect-ai"
|
|
25796
|
+
],
|
|
25797
|
+
publish: [`To publish: ${RUN} deploy`],
|
|
25798
|
+
upload: [`To upload a new version: ${RUN} deploy`],
|
|
25799
|
+
push: [`To upload a new version: ${RUN} deploy`],
|
|
25800
|
+
live: [`To put a ready version live: ${RUN} promote <version>`]
|
|
25801
|
+
};
|
|
25802
|
+
function editDistance(a, b) {
|
|
25803
|
+
let prev = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
25804
|
+
for (let i = 1; i <= a.length; i++) {
|
|
25805
|
+
const row2 = [i];
|
|
25806
|
+
for (let j = 1; j <= b.length; j++) row2[j] = Math.min(prev[j] + 1, row2[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
25807
|
+
prev = row2;
|
|
25808
|
+
}
|
|
25809
|
+
return prev[b.length];
|
|
25810
|
+
}
|
|
25811
|
+
function closestCommand(word, names) {
|
|
25812
|
+
const w = word.toLowerCase();
|
|
25813
|
+
let best = null;
|
|
25814
|
+
for (const name of names) {
|
|
25815
|
+
const d = name.startsWith(w) && w.length >= 3 ? 0.5 : editDistance(w, name);
|
|
25816
|
+
if (!best || d < best.d) best = { name, d };
|
|
25817
|
+
}
|
|
25818
|
+
return best && best.d <= Math.max(1, Math.floor(w.length / 3)) ? best.name : null;
|
|
25819
|
+
}
|
|
25820
|
+
var START_ID = new RegExp(`^[${START_ID_ALPHABET}]{10}$`);
|
|
25821
|
+
function unknownCommandHelp(args, program) {
|
|
25822
|
+
const words = [];
|
|
25823
|
+
for (let i = 0; i < args.length; i++) {
|
|
25824
|
+
const a = args[i];
|
|
25825
|
+
if (VALUE_OPTIONS.has(a)) i++;
|
|
25826
|
+
else if (!a.startsWith("-")) words.push({ w: a, at: i });
|
|
25827
|
+
}
|
|
25828
|
+
const rest = (at) => args.length > at + 1 ? ` ${args.slice(at + 1).join(" ")}` : "";
|
|
25829
|
+
const [first, second] = words;
|
|
25830
|
+
if (!first) return [`All commands: ${RUN} --help`];
|
|
25831
|
+
const group = program.commands.find((c) => c.name() === first.w && c.commands.length);
|
|
25832
|
+
if (group && second) {
|
|
25833
|
+
const near2 = closestCommand(second.w, group.commands.map((c) => c.name()));
|
|
25834
|
+
return [...near2 ? [`Did you mean: ${RUN} ${first.w} ${near2}${rest(second.at)}`] : [], `The ${first.w} commands: ${RUN} ${first.w} --help`];
|
|
25835
|
+
}
|
|
25836
|
+
const meant = MEANS[first.w.toLowerCase()];
|
|
25837
|
+
if (meant) return [...meant, `All commands: ${RUN} --help`];
|
|
25838
|
+
if (START_ID.test(first.w)) return [`That looks like the site's start id. Run: ${RUN} start ${first.w}`];
|
|
25839
|
+
const near = closestCommand(first.w, program.commands.map((c) => c.name()));
|
|
25840
|
+
return [...near ? [`Did you mean: ${RUN} ${near}${rest(first.at)}`] : [], `All commands: ${RUN} --help`];
|
|
25841
|
+
}
|
|
25842
|
+
|
|
25703
25843
|
// src/commands/feedback.ts
|
|
25704
25844
|
var COMMAND = /^[a-z][a-z -]{0,59}$/;
|
|
25705
25845
|
async function feedbackCommand(root, ctx, opts) {
|
|
@@ -26674,11 +26814,16 @@ function copyToClipboard(text2) {
|
|
|
26674
26814
|
}
|
|
26675
26815
|
return false;
|
|
26676
26816
|
}
|
|
26817
|
+
function windowsBrowserDirs(env = process.env) {
|
|
26818
|
+
const drive = env.SystemDrive || "C:";
|
|
26819
|
+
const dirs = [env.ProgramW6432, env.PROGRAMFILES, env.ProgramFiles, env["PROGRAMFILES(X86)"], env["ProgramFiles(x86)"], `${drive}\\Program Files`, `${drive}\\Program Files (x86)`, env.LOCALAPPDATA, env.USERPROFILE ? join8(env.USERPROFILE, "AppData", "Local") : void 0];
|
|
26820
|
+
return [...new Set(dirs.filter((d) => !!d))];
|
|
26821
|
+
}
|
|
26677
26822
|
function findBrowser() {
|
|
26678
26823
|
if (process.env.DEPLOYAI_NO_BROWSER) return null;
|
|
26679
26824
|
const set2 = process.env.CHROME_PATH;
|
|
26680
26825
|
if (set2 && existsSync7(set2)) return set2;
|
|
26681
|
-
const places = process.platform === "win32" ?
|
|
26826
|
+
const places = process.platform === "win32" ? windowsBrowserDirs().flatMap((d) => d ? [join8(d, "Google/Chrome/Application/chrome.exe"), join8(d, "Microsoft/Edge/Application/msedge.exe")] : []) : process.platform === "darwin" ? ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge", "/Applications/Chromium.app/Contents/MacOS/Chromium"] : ["/usr/bin/google-chrome", "/usr/bin/google-chrome-stable", "/usr/bin/chromium", "/usr/bin/chromium-browser", "/usr/bin/microsoft-edge", "/snap/bin/chromium"];
|
|
26682
26827
|
return places.find((p) => existsSync7(p)) ?? null;
|
|
26683
26828
|
}
|
|
26684
26829
|
function openBrowser(url2) {
|
|
@@ -27760,7 +27905,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
27760
27905
|
if (isBlockedMoveSite(source)) throw new CliError("We do not move sites of banks, hospitals, health funds, insurers, payment services or government bodies. Tell the owner this in one line and stop.", 1, "blocked_site");
|
|
27761
27906
|
const home = await get(source);
|
|
27762
27907
|
if (!home) throw new CliError(`Could not reach ${source}. Check the address, or that the site is up.`, 1, "network");
|
|
27763
|
-
if (home.status === 401 || home.status === 403) throw new CliError(`${source} answers ${home.status}: it is behind a login or a security check. If it opens in a browser, open it in your browser tool, ask the owner to pass any check in that window, and read the pages there (recommended). Else ask the owner to pause the check while it moves, or work from their export.`, 1, "blocked");
|
|
27908
|
+
if (home.status === 401 || home.status === 403) throw new CliError(`${source} answers ${home.status}: it is behind a login or a security check. If it opens in a browser, open it in your browser tool, ask the owner to pass any check in that window, and read the pages there (recommended). Else ask the owner to pause the check while it moves, or work from their export.`, 1, "blocked", "source_closed");
|
|
27764
27909
|
const origin = new URL(home.url).origin;
|
|
27765
27910
|
const base = (origin + new URL(home.url).pathname).replace(/\/+$/, "");
|
|
27766
27911
|
const html = await home.text();
|
|
@@ -28179,12 +28324,14 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
28179
28324
|
out(`A builder's credit is still on the preview:`);
|
|
28180
28325
|
for (const [text2, path] of credits) out(` ${path} ${text2}`);
|
|
28181
28326
|
out("Remove each and put the site's own name and the year in its place, unless the owner asked to keep it, then deploy again and run verify again.");
|
|
28327
|
+
blockedBy("builder_credit");
|
|
28182
28328
|
process.exitCode = 1;
|
|
28183
28329
|
}
|
|
28184
28330
|
if (vendors.size) {
|
|
28185
28331
|
out(`Files of a plugin or theme are still on the preview:`);
|
|
28186
28332
|
for (const [name, path] of vendors) out(` ${path} ${name}`);
|
|
28187
28333
|
out("Remove them. Write what the page needs into the site's own stylesheet and scripts, or use a UI source, so it looks and works the same, then deploy again and run verify again.");
|
|
28334
|
+
blockedBy("vendor_files");
|
|
28188
28335
|
process.exitCode = 1;
|
|
28189
28336
|
}
|
|
28190
28337
|
if (leftOnOld.length) {
|
|
@@ -28192,6 +28339,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
28192
28339
|
out("Still loading from the old site and missing from this one, so it breaks when the old site closes:");
|
|
28193
28340
|
for (const a of leftOnOld) out(` ${what[a.kind]} ${a.url}`);
|
|
28194
28341
|
out("Put each file in the site's own public folder (migrate media saved the images in .deployai/migration), point the tag at the site's own address, deploy again and run verify again.");
|
|
28342
|
+
blockedBy("old_host_assets");
|
|
28195
28343
|
process.exitCode = 1;
|
|
28196
28344
|
}
|
|
28197
28345
|
if (tagFindings.length) {
|
|
@@ -28199,6 +28347,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
28199
28347
|
for (const f of tagFindings.slice(0, 60)) out(` ${f.what} ${TAG_WORDS[f.problem]}${f.detail ? ` (${f.detail})` : ""}${f.page ? ` on ${f.page}` : ""}`);
|
|
28200
28348
|
if (tagFindings.length > 60) out(` and ${tagFindings.length - 60} more in verify.json`);
|
|
28201
28349
|
out('Put each one back, deploy again and run verify again. If one was left out on purpose (the owner asked, or the plan replaced it with ours): npx deployai@latest migrate tags --removed "<its number or name>", and give its plan row the status "Replaced with <what took its place>" so the report says so.');
|
|
28350
|
+
blockedBy(...tagFindings.map((f) => f.problem));
|
|
28202
28351
|
process.exitCode = 1;
|
|
28203
28352
|
}
|
|
28204
28353
|
const clean3 = !findings.length && !tagFindings.length && !credits.size && !vendors.size && !leftOnOld.length;
|
|
@@ -28216,6 +28365,8 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
28216
28365
|
for (const f of findings.slice(0, 60)) out(` ${f.path} ${words[f.problem]}${f.detail ? ` ${f.detail}` : ""}`);
|
|
28217
28366
|
if (findings.length > 60) out(` and ${findings.length - 60} more in verify.json`);
|
|
28218
28367
|
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.");
|
|
28368
|
+
const pageReason = { missing: "pages_missing", moved: "pages_moved", error: "pages_error", title_lost: "title_lost", description_lost: "description_lost" };
|
|
28369
|
+
blockedBy(...findings.map((f) => pageReason[f.problem]));
|
|
28219
28370
|
process.exitCode = 1;
|
|
28220
28371
|
}
|
|
28221
28372
|
|
|
@@ -28924,7 +29075,10 @@ async function syncCommand(root, ctx) {
|
|
|
28924
29075
|
}
|
|
28925
29076
|
out();
|
|
28926
29077
|
out(r.conflicts.length || r.clashes.length ? t("syncNextConflicts") : t("syncNext"));
|
|
28927
|
-
if (r.conflicts.length || r.clashes.length)
|
|
29078
|
+
if (r.conflicts.length || r.clashes.length) {
|
|
29079
|
+
blockedBy("sync_conflicts");
|
|
29080
|
+
process.exitCode = 1;
|
|
29081
|
+
}
|
|
28928
29082
|
}
|
|
28929
29083
|
function syncLeftovers(root) {
|
|
28930
29084
|
let state;
|
|
@@ -29066,6 +29220,10 @@ function printStatus(root, ctx, projectId, s) {
|
|
|
29066
29220
|
])
|
|
29067
29221
|
);
|
|
29068
29222
|
printClosedHere(root, s);
|
|
29223
|
+
if (s.githubPull) {
|
|
29224
|
+
out();
|
|
29225
|
+
out(cliLang(root) === "he" ? s.githubPull.he : s.githubPull.en);
|
|
29226
|
+
}
|
|
29069
29227
|
if (s.latest?.goingLive) {
|
|
29070
29228
|
out();
|
|
29071
29229
|
out(t("goingLive", { n: s.latest.number }));
|
|
@@ -29244,7 +29402,7 @@ async function prepare(root, ctx, maxBytes) {
|
|
|
29244
29402
|
if (!analysis.compatible) {
|
|
29245
29403
|
await runCheck(root, { ...ctx, config: { ...ctx.config, telemetry: false } }, {});
|
|
29246
29404
|
out();
|
|
29247
|
-
throw new CliError(messages(root)("deployBlocked"), 1, "blocked");
|
|
29405
|
+
throw new CliError(messages(root)("deployBlocked"), 1, "blocked", "check_blocked");
|
|
29248
29406
|
}
|
|
29249
29407
|
const t = messages(root);
|
|
29250
29408
|
const left = syncLeftovers(root);
|
|
@@ -29391,6 +29549,7 @@ async function afterBuild(root, ctx, projectId, n2, o) {
|
|
|
29391
29549
|
}
|
|
29392
29550
|
if (ready && built.latest?.preview) {
|
|
29393
29551
|
if (!await homeAnswers(root, built.latest.preview, o.homeRetryMs)) {
|
|
29552
|
+
blockedBy("preview_down");
|
|
29394
29553
|
process.exitCode = 1;
|
|
29395
29554
|
return;
|
|
29396
29555
|
}
|
|
@@ -29425,7 +29584,10 @@ async function afterBuild(root, ctx, projectId, n2, o) {
|
|
|
29425
29584
|
return;
|
|
29426
29585
|
}
|
|
29427
29586
|
printStatus(root, ctx, projectId, built);
|
|
29428
|
-
if (built.latest?.number === n2 && built.latest.status === "failed")
|
|
29587
|
+
if (built.latest?.number === n2 && built.latest.status === "failed") {
|
|
29588
|
+
blockedBy("build_failed");
|
|
29589
|
+
process.exitCode = 1;
|
|
29590
|
+
}
|
|
29429
29591
|
return;
|
|
29430
29592
|
}
|
|
29431
29593
|
await apiRequest(ctx, "/api/cli/promote", null, { method: "POST", body: { projectId, number: n2, ...approval } });
|
|
@@ -29444,6 +29606,7 @@ async function afterBuild(root, ctx, projectId, n2, o) {
|
|
|
29444
29606
|
return;
|
|
29445
29607
|
}
|
|
29446
29608
|
printStatus(root, ctx, projectId, after);
|
|
29609
|
+
blockedBy("not_live");
|
|
29447
29610
|
process.exitCode = 1;
|
|
29448
29611
|
}
|
|
29449
29612
|
async function readPreview(url2) {
|
|
@@ -29551,6 +29714,118 @@ async function claimCommand(root, ctx, opts) {
|
|
|
29551
29714
|
out(t("claimLink", { url: url2 }));
|
|
29552
29715
|
}
|
|
29553
29716
|
|
|
29717
|
+
// src/commands/logs.ts
|
|
29718
|
+
var REFUSALS = {
|
|
29719
|
+
site_deleted: "siteDeleted",
|
|
29720
|
+
not_on_site: "notOnSite",
|
|
29721
|
+
view_only: "viewOnly",
|
|
29722
|
+
not_found: "notFound",
|
|
29723
|
+
logs_not_live: "logsNotLive",
|
|
29724
|
+
logs_site_off: "logsSiteOff",
|
|
29725
|
+
logs_unavailable: "logsUnavailable"
|
|
29726
|
+
};
|
|
29727
|
+
var two = (n2) => String(n2).padStart(2, "0");
|
|
29728
|
+
var clock = (at) => {
|
|
29729
|
+
const d = new Date(at);
|
|
29730
|
+
return `${two(d.getHours())}:${two(d.getMinutes())}:${two(d.getSeconds())}`;
|
|
29731
|
+
};
|
|
29732
|
+
var formatLogLine = (l) => `${clock(l.at)} ${l.level.toUpperCase().padEnd(5)} ${l.text}`;
|
|
29733
|
+
function readEvents(buffer) {
|
|
29734
|
+
const events = [];
|
|
29735
|
+
const parts2 = buffer.replace(/\r\n/g, "\n").split("\n\n");
|
|
29736
|
+
const rest = parts2.pop() ?? "";
|
|
29737
|
+
for (const block of parts2) {
|
|
29738
|
+
let event = "message";
|
|
29739
|
+
const data = [];
|
|
29740
|
+
for (const line of block.split("\n")) {
|
|
29741
|
+
if (line.startsWith(":")) continue;
|
|
29742
|
+
if (line.startsWith("event:")) event = line.slice(6).trim();
|
|
29743
|
+
else if (line.startsWith("data:")) data.push(line.slice(5).replace(/^ /, ""));
|
|
29744
|
+
}
|
|
29745
|
+
if (data.length) events.push({ event, data: data.join("\n") });
|
|
29746
|
+
}
|
|
29747
|
+
return { events, rest };
|
|
29748
|
+
}
|
|
29749
|
+
async function logsCommand(root, ctx, opts) {
|
|
29750
|
+
const token = requireToken(ctx);
|
|
29751
|
+
const projectId = linkedProjectId(root);
|
|
29752
|
+
const t = messages(root);
|
|
29753
|
+
const say = opts.json ? err : out;
|
|
29754
|
+
const abort = new AbortController();
|
|
29755
|
+
let stopped = false;
|
|
29756
|
+
const onSigint = () => {
|
|
29757
|
+
stopped = true;
|
|
29758
|
+
abort.abort();
|
|
29759
|
+
};
|
|
29760
|
+
process.once("SIGINT", onSigint);
|
|
29761
|
+
try {
|
|
29762
|
+
const url2 = `${ctx.apiUrl}/api/cli/logs?projectId=${encodeURIComponent(projectId)}${opts.errors ? "&errors=1" : ""}`;
|
|
29763
|
+
const headersWait = setTimeout(() => abort.abort(), 3e4);
|
|
29764
|
+
let res;
|
|
29765
|
+
try {
|
|
29766
|
+
res = await fetch(url2, { headers: { Authorization: `Bearer ${token}`, Accept: "text/event-stream", "User-Agent": userAgent(ctx.config) }, signal: abort.signal });
|
|
29767
|
+
} catch {
|
|
29768
|
+
if (stopped) return say(t("logsStopped"));
|
|
29769
|
+
throw new CliError(t("unreachable", { url: ctx.apiUrl }), 1, "network");
|
|
29770
|
+
} finally {
|
|
29771
|
+
clearTimeout(headersWait);
|
|
29772
|
+
}
|
|
29773
|
+
if (res.status === 401) throw new CliError(t("sessionExpired"), 1, "auth");
|
|
29774
|
+
if (!res.ok || !res.body) {
|
|
29775
|
+
const parsed = ApiError.safeParse(await res.json().catch(() => null));
|
|
29776
|
+
const code = parsed.success ? parsed.data.error : `HTTP ${res.status}`;
|
|
29777
|
+
const key2 = REFUSALS[code];
|
|
29778
|
+
throw new CliError(key2 ? t(key2) : t("apiError", { code }), 1, code.startsWith("logs_") ? code : res.status === 403 ? "forbidden" : res.status === 404 ? "not_found" : "api");
|
|
29779
|
+
}
|
|
29780
|
+
const reader = res.body.getReader();
|
|
29781
|
+
const decoder = new TextDecoder();
|
|
29782
|
+
let buffer = "";
|
|
29783
|
+
let ended = null;
|
|
29784
|
+
for (; ; ) {
|
|
29785
|
+
let chunk;
|
|
29786
|
+
try {
|
|
29787
|
+
chunk = await reader.read();
|
|
29788
|
+
} catch {
|
|
29789
|
+
break;
|
|
29790
|
+
}
|
|
29791
|
+
if (chunk.done) break;
|
|
29792
|
+
buffer += decoder.decode(chunk.value, { stream: true });
|
|
29793
|
+
const { events, rest } = readEvents(buffer);
|
|
29794
|
+
buffer = rest;
|
|
29795
|
+
for (const e3 of events) {
|
|
29796
|
+
let data;
|
|
29797
|
+
try {
|
|
29798
|
+
data = JSON.parse(e3.data);
|
|
29799
|
+
} catch {
|
|
29800
|
+
continue;
|
|
29801
|
+
}
|
|
29802
|
+
if (e3.event === "ready") {
|
|
29803
|
+
const r = LogsReady.safeParse(data);
|
|
29804
|
+
if (!r.success) continue;
|
|
29805
|
+
say(t("logsWatching", { name: r.data.name, url: r.data.url ?? "-", time: clock(r.data.until).slice(0, 5) }));
|
|
29806
|
+
if (opts.errors) say(t("logsErrorsOnly"));
|
|
29807
|
+
say(t("logsNote"));
|
|
29808
|
+
} else if (e3.event === "line") {
|
|
29809
|
+
const l = LogLine.safeParse(data);
|
|
29810
|
+
if (l.success) out(opts.json ? JSON.stringify(l.data) : formatLogLine(l.data));
|
|
29811
|
+
} else if (e3.event === "end") {
|
|
29812
|
+
const r = LogsEnd.safeParse(data);
|
|
29813
|
+
if (r.success) ended = r.data.reason;
|
|
29814
|
+
}
|
|
29815
|
+
}
|
|
29816
|
+
if (ended) break;
|
|
29817
|
+
}
|
|
29818
|
+
if (stopped) return say(t("logsStopped"));
|
|
29819
|
+
if (ended === "time") return say(t("logsEndTime"));
|
|
29820
|
+
if (ended === "replaced") return say(t("logsEndReplaced"));
|
|
29821
|
+
if (ended === "cloudflare") throw new CliError(t("logsEndCloudflare"), 1, "logs_ended");
|
|
29822
|
+
throw new CliError(t("logsEndClosed"), 1, "logs_ended");
|
|
29823
|
+
} finally {
|
|
29824
|
+
process.removeListener("SIGINT", onSigint);
|
|
29825
|
+
abort.abort();
|
|
29826
|
+
}
|
|
29827
|
+
}
|
|
29828
|
+
|
|
29554
29829
|
// src/commands/requests.ts
|
|
29555
29830
|
var OUTCOME = {
|
|
29556
29831
|
site: "reached the site",
|
|
@@ -29679,7 +29954,7 @@ async function startCommand(cwd, ctx, id, opts = {}) {
|
|
|
29679
29954
|
out(messages(process.cwd())("startLoginFirst"));
|
|
29680
29955
|
out(START_LOGIN_WAIT_LINE);
|
|
29681
29956
|
out();
|
|
29682
|
-
await sendTelemetryEvent(ctxNow, buildTelemetryEvent(ctxNow.config.installId, "start", "blocked"));
|
|
29957
|
+
await sendTelemetryEvent(ctxNow, buildTelemetryEvent(ctxNow.config.installId, "start", "blocked", void 0, { errorLine: "login_wait" }));
|
|
29683
29958
|
await loginCommand(ctxNow, { pollMs: opts.pollMs, quiet: true }).catch((e3) => {
|
|
29684
29959
|
if (e3 instanceof CliError && e3.category === "auth_expired") throw new CliError(messages(process.cwd())("startLoginExpired", { id: key2 }), 1, "auth_expired");
|
|
29685
29960
|
throw e3;
|
|
@@ -29694,7 +29969,7 @@ async function startCommand(cwd, ctx, id, opts = {}) {
|
|
|
29694
29969
|
out(t0("startOtherAccount", { email: ctxNow.config.email ?? "?", maker }));
|
|
29695
29970
|
out(START_LOGIN_WAIT_LINE);
|
|
29696
29971
|
out();
|
|
29697
|
-
await sendTelemetryEvent(ctxNow, buildTelemetryEvent(ctxNow.config.installId, "start", "blocked", "other_account"));
|
|
29972
|
+
await sendTelemetryEvent(ctxNow, buildTelemetryEvent(ctxNow.config.installId, "start", "blocked", void 0, { errorLine: "other_account" }));
|
|
29698
29973
|
await loginCommand(ctxNow, { pollMs: opts.pollMs, quiet: true, force: true }).catch((e3) => {
|
|
29699
29974
|
if (e3 instanceof CliError && e3.category === "auth_expired") throw new CliError(t0("startLoginExpired", { id: key2 }), 1, "auth_expired");
|
|
29700
29975
|
throw e3;
|
|
@@ -29846,6 +30121,10 @@ function linkedProjectId2(root) {
|
|
|
29846
30121
|
if (!id) throw new CliError("This folder is not linked to a DeployAI site. Run: npx deployai@latest login, then npx deployai@latest link", 1, "not_linked");
|
|
29847
30122
|
return id;
|
|
29848
30123
|
}
|
|
30124
|
+
function requireSiteCode(root) {
|
|
30125
|
+
if (filesIn(root).length) return;
|
|
30126
|
+
throw new CliError("This folder has no site code yet, so an add-on has nothing to change. Run: npx deployai@latest pull, then run this command again. If pull says the site has no version yet, build the site and deploy it first, then add the add-ons.", 1, "empty_folder");
|
|
30127
|
+
}
|
|
29849
30128
|
var STATUS_WORDS = { todo: "not started", served: "in progress", done: "done", failed: "failed", skipped: "skipped" };
|
|
29850
30129
|
async function addonsCommand(root, ctx) {
|
|
29851
30130
|
requireToken(ctx);
|
|
@@ -29894,6 +30173,7 @@ async function addonsRunCommand(root, ctx, opts = {}) {
|
|
|
29894
30173
|
out(r.addons.some((a) => a.owned) ? "Every add-on of this site is done or skipped. To run one again: npx deployai@latest addon run <name>" : "This site has no add-ons yet. See them: npx deployai@latest addons");
|
|
29895
30174
|
return;
|
|
29896
30175
|
}
|
|
30176
|
+
requireSiteCode(root);
|
|
29897
30177
|
const all = opts.all === true || !opts.oneByOne && readProject(root)?.addonsAll === true;
|
|
29898
30178
|
if (!order && r.picked && !r.agreed && todo.length > 1 && (opts.all || !all)) {
|
|
29899
30179
|
const stamps = readStamps(root);
|
|
@@ -29969,6 +30249,7 @@ function printAddon(root, a) {
|
|
|
29969
30249
|
async function addonNextCommand(root, ctx) {
|
|
29970
30250
|
requireToken(ctx);
|
|
29971
30251
|
const projectId = linkedProjectId2(root);
|
|
30252
|
+
requireSiteCode(root);
|
|
29972
30253
|
try {
|
|
29973
30254
|
printAddon(root, await apiRequest(ctx, "/api/cli/addons/next", AddonServe, { method: "POST", body: { projectId } }));
|
|
29974
30255
|
} catch (e3) {
|
|
@@ -29982,6 +30263,7 @@ async function addonNextCommand(root, ctx) {
|
|
|
29982
30263
|
async function addonRunCommand(root, ctx, key2) {
|
|
29983
30264
|
requireToken(ctx);
|
|
29984
30265
|
const projectId = linkedProjectId2(root);
|
|
30266
|
+
requireSiteCode(root);
|
|
29985
30267
|
printAddon(root, await apiRequest(ctx, `/api/cli/addons/${encodeURIComponent(key2.trim().toLowerCase())}?projectId=${encodeURIComponent(projectId)}`, AddonServe));
|
|
29986
30268
|
}
|
|
29987
30269
|
async function addonDoneCommand(root, ctx, runId, opts) {
|
|
@@ -30016,7 +30298,8 @@ async function addonDoneCommand(root, ctx, runId, opts) {
|
|
|
30016
30298
|
|
|
30017
30299
|
// src/commands/speed.ts
|
|
30018
30300
|
import { spawn as spawn3 } from "child_process";
|
|
30019
|
-
import {
|
|
30301
|
+
import { createHash as createHash4 } from "crypto";
|
|
30302
|
+
import { mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync2, readFileSync as readFileSync14, rmSync as rmSync4, writeFileSync as writeFileSync17 } from "fs";
|
|
30020
30303
|
import { tmpdir as tmpdir2 } from "os";
|
|
30021
30304
|
import { join as join21 } from "path";
|
|
30022
30305
|
var ms = (v) => v >= 1e3 ? `${(v / 1e3).toFixed(1)} s` : `${Math.round(v)} ms`;
|
|
@@ -30054,9 +30337,9 @@ async function localSpeed(url2, strategy, run = runLighthouse, browser = findBro
|
|
|
30054
30337
|
rmSync4(dir, { recursive: true, force: true, maxRetries: 3 });
|
|
30055
30338
|
}
|
|
30056
30339
|
}
|
|
30057
|
-
function printReport(r, strategy,
|
|
30340
|
+
function printReport(r, strategy, local2) {
|
|
30058
30341
|
out();
|
|
30059
|
-
out(`Lab test (one simulated ${strategy} load${
|
|
30342
|
+
out(`Lab test (one simulated ${strategy} load${local2 ? " on this computer" : ""}), Lighthouse ${r.lighthouseVersion ?? ""}`);
|
|
30060
30343
|
out(` Performance score ${r.scores.performance ?? "?"}`);
|
|
30061
30344
|
for (const m of r.lab) out(` ${m.id.padEnd(26)} ${m.display ?? "?"}`);
|
|
30062
30345
|
out();
|
|
@@ -30064,7 +30347,7 @@ function printReport(r, strategy, local) {
|
|
|
30064
30347
|
out(`Real visitors, last 28 days (${r.field.scope === "url" ? "this page" : "whole site"}, 75th percentile)`);
|
|
30065
30348
|
for (const f of r.field.metrics) out(` ${f.id.toUpperCase().padEnd(6)} ${(f.id === "cls" ? f.p75.toFixed(2) : ms(f.p75)).padEnd(10)} ${f.rating.replace("_", " ")}`);
|
|
30066
30349
|
} else {
|
|
30067
|
-
out(
|
|
30350
|
+
out(local2 ? "Real visitors: only Google has these, so this test does not show them." : "Real visitors: Google has not enough data for this site yet.");
|
|
30068
30351
|
}
|
|
30069
30352
|
if (r.opportunities.length) {
|
|
30070
30353
|
out();
|
|
@@ -30072,6 +30355,24 @@ function printReport(r, strategy, local) {
|
|
|
30072
30355
|
for (const a of r.opportunities.slice(0, 8)) out(` - ${a.title}${a.display ? ` (${a.display})` : a.savingsMs ? ` (about ${ms(a.savingsMs)})` : ""}`);
|
|
30073
30356
|
}
|
|
30074
30357
|
}
|
|
30358
|
+
var CACHE_MS = 10 * 6e4;
|
|
30359
|
+
var cacheFile = (dir, url2, strategy) => join21(dir, `${createHash4("sha256").update(`${strategy} ${url2}`).digest("hex").slice(0, 24)}.json`);
|
|
30360
|
+
function readCache(dir, url2, strategy) {
|
|
30361
|
+
try {
|
|
30362
|
+
return JSON.parse(readFileSync14(cacheFile(dir, url2, strategy), "utf8"));
|
|
30363
|
+
} catch {
|
|
30364
|
+
return null;
|
|
30365
|
+
}
|
|
30366
|
+
}
|
|
30367
|
+
function writeCache(dir, url2, strategy, c) {
|
|
30368
|
+
try {
|
|
30369
|
+
mkdirSync11(dir, { recursive: true });
|
|
30370
|
+
writeFileSync17(cacheFile(dir, url2, strategy), JSON.stringify(c));
|
|
30371
|
+
} catch {
|
|
30372
|
+
}
|
|
30373
|
+
}
|
|
30374
|
+
var minutes = (msLeft) => Math.max(1, Math.ceil(msLeft / 6e4));
|
|
30375
|
+
var waitText = (s) => s >= 7200 ? `in about ${Math.ceil(s / 3600)} hours` : `in about ${minutes(s * 1e3)} minutes`;
|
|
30075
30376
|
async function speedCommand(ctx, url2, opts, deps = {}) {
|
|
30076
30377
|
requireToken(ctx);
|
|
30077
30378
|
const strategy = opts.desktop ? "desktop" : "mobile";
|
|
@@ -30082,7 +30383,32 @@ async function speedCommand(ctx, url2, opts, deps = {}) {
|
|
|
30082
30383
|
} catch {
|
|
30083
30384
|
throw new CliError(`Not an address: ${url2}. Use the full address, for example https://example.com/`, 1, "usage");
|
|
30084
30385
|
}
|
|
30085
|
-
const
|
|
30386
|
+
const dir = deps.cacheDir ?? join21(tmpdir2(), "deployai-speed-cache");
|
|
30387
|
+
const now = deps.now ?? Date.now;
|
|
30388
|
+
const cached2 = readCache(dir, page3, strategy);
|
|
30389
|
+
if (cached2 && now() - cached2.at < CACHE_MS) {
|
|
30390
|
+
out(`Showing the result from ${minutes(now() - cached2.at)} minutes ago: a new test of the same page runs after ${minutes(CACHE_MS - (now() - cached2.at))} more minutes.`);
|
|
30391
|
+
printReport(cached2.report, strategy, cached2.local);
|
|
30392
|
+
if (cached2.link) {
|
|
30393
|
+
out();
|
|
30394
|
+
out(`Full report: ${cached2.link}`);
|
|
30395
|
+
}
|
|
30396
|
+
return;
|
|
30397
|
+
}
|
|
30398
|
+
const started = await apiRequest(ctx, "/api/cli/speed", null, { method: "POST", body: { url: url2, strategy } });
|
|
30399
|
+
if (started.limited) {
|
|
30400
|
+
const when = waitText(started.retryAfter ?? 3600);
|
|
30401
|
+
if (cached2 || started.last) {
|
|
30402
|
+
out(`Too many speed tests for now. Try again ${when}. Here is the last result of this page${started.last ? ` (${started.last.at.slice(0, 16).replace("T", " ")} UTC)` : ""}.`);
|
|
30403
|
+
if (cached2) printReport(cached2.report, strategy, cached2.local);
|
|
30404
|
+
out();
|
|
30405
|
+
out(`Full report: ${started.last ? `${ctx.apiUrl}/tools/r/${started.last.id}` : cached2?.link ?? ""}`);
|
|
30406
|
+
return;
|
|
30407
|
+
}
|
|
30408
|
+
throw new CliError(`Too many speed tests for now, and this page has no earlier result. Try again ${when}, or go on without speed numbers and tell the owner in one line.`, 1, "speed_limited");
|
|
30409
|
+
}
|
|
30410
|
+
const id = started.id;
|
|
30411
|
+
if (!id) return local(page3, strategy, deps, dir, now);
|
|
30086
30412
|
out(`Testing ${url2} (${strategy}) with Google PageSpeed Insights. This usually takes 15 to 40 seconds...`);
|
|
30087
30413
|
const deadline = Date.now() + (deps.waitMs ?? 15e4);
|
|
30088
30414
|
let run = null;
|
|
@@ -30092,17 +30418,22 @@ async function speedCommand(ctx, url2, opts, deps = {}) {
|
|
|
30092
30418
|
if (run.status === "done" || run.status === "failed") break;
|
|
30093
30419
|
}
|
|
30094
30420
|
if (run?.status === "done" && run.result) {
|
|
30421
|
+
writeCache(dir, page3, strategy, { at: now(), report: run.result, local: false, link: `${ctx.apiUrl}/tools/r/${id}` });
|
|
30095
30422
|
printReport(run.result, strategy, false);
|
|
30096
30423
|
out();
|
|
30097
30424
|
out(`Full report: ${ctx.apiUrl}/tools/r/${id}`);
|
|
30098
30425
|
return;
|
|
30099
30426
|
}
|
|
30100
30427
|
if (run?.error === "psi_unreachable") throw new CliError("Google could not load this page. Check that the address opens and is public, then try again.", 1, "speed_failed");
|
|
30428
|
+
return local(page3, strategy, deps, dir, now);
|
|
30429
|
+
}
|
|
30430
|
+
async function local(page3, strategy, deps, dir, now) {
|
|
30101
30431
|
out("Google's test is not available right now, so Lighthouse is running on this computer. This takes about a minute...");
|
|
30102
30432
|
const browser = deps.browser === void 0 ? findBrowser() : deps.browser;
|
|
30103
30433
|
if (!browser) throw new CliError("The speed test could not run: Google's test is not available, and no Chrome or Edge was found on this computer (looked in Program Files and the user's apps). If one is installed elsewhere, set CHROME_PATH to its path and run speed again; else go on without speed numbers and tell the owner in one line.", 1, "speed_failed");
|
|
30104
30434
|
const report2 = await localSpeed(page3, strategy, deps.run, browser);
|
|
30105
30435
|
if (!report2) throw new CliError(`The speed test could not finish: Lighthouse started with ${browser} and gave no result. Its first run downloads Lighthouse, which can take a few minutes, and it needs Node 22.19 or newer. Run speed again once; if it fails again, go on without speed numbers and tell the owner in one line.`, 1, "speed_failed");
|
|
30436
|
+
writeCache(dir, page3, strategy, { at: now(), report: report2, local: true, link: null });
|
|
30106
30437
|
printReport(report2, strategy, true);
|
|
30107
30438
|
out();
|
|
30108
30439
|
out("Measured on this computer, so compare it only with numbers measured the same way.");
|
|
@@ -30110,7 +30441,7 @@ async function speedCommand(ctx, url2, opts, deps = {}) {
|
|
|
30110
30441
|
|
|
30111
30442
|
// src/commands/shot.ts
|
|
30112
30443
|
import { spawn as spawn4 } from "child_process";
|
|
30113
|
-
import { existsSync as existsSync18, mkdirSync as
|
|
30444
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync12, readFileSync as readFileSync15, rmSync as rmSync5, writeFileSync as writeFileSync18 } from "fs";
|
|
30114
30445
|
import { tmpdir as tmpdir3 } from "os";
|
|
30115
30446
|
import { join as join22, resolve as resolve6 } from "path";
|
|
30116
30447
|
var SHOT_SIZES = [{ name: "phone", size: "390,844" }, { name: "desktop", size: "1440,900" }];
|
|
@@ -30177,9 +30508,9 @@ async function shotCommand(root, address, opts = {}, run = runNpx) {
|
|
|
30177
30508
|
if (!opts.webkit && !browser) throw new CliError("No Chrome or Edge was found on this computer. Install Chrome, set CHROME_PATH to its path, or run shot again with --webkit (it downloads Safari's engine first).", 1, "no_browser");
|
|
30178
30509
|
if (opts.webkit && await run(["--yes", PLAYWRIGHT, "install", "webkit"]) !== 0) throw new CliError("Safari's engine could not be installed. Run shot without --webkit to use Chrome or Edge.", 1, "shot_failed");
|
|
30179
30510
|
const dir = resolve6(root, opts.out ?? join22(".deployai", "shots"));
|
|
30180
|
-
|
|
30511
|
+
mkdirSync12(dir, { recursive: true });
|
|
30181
30512
|
const taker = join22(tmpdir3(), "deployai-shot.cjs");
|
|
30182
|
-
|
|
30513
|
+
writeFileSync18(taker, TAKER);
|
|
30183
30514
|
const saved = [];
|
|
30184
30515
|
for (const s of SHOT_SIZES) {
|
|
30185
30516
|
const file2 = join22(dir, shotName(url2.toString(), s.name));
|
|
@@ -30200,7 +30531,7 @@ async function shotCommand(root, address, opts = {}, run = runNpx) {
|
|
|
30200
30531
|
|
|
30201
30532
|
// src/commands/images.ts
|
|
30202
30533
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
30203
|
-
import { existsSync as existsSync19, mkdirSync as
|
|
30534
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync13, readdirSync as readdirSync6, statSync as statSync3, writeFileSync as writeFileSync19 } from "fs";
|
|
30204
30535
|
import { createRequire } from "module";
|
|
30205
30536
|
import { homedir as homedir3 } from "os";
|
|
30206
30537
|
import { extname, join as join23, relative as relative4, resolve as resolve7 } from "path";
|
|
@@ -30230,8 +30561,8 @@ function outputsFor(file2, width) {
|
|
|
30230
30561
|
function loadSharp() {
|
|
30231
30562
|
const dir = join23(homedir3(), ".deployai", "tools", "sharp");
|
|
30232
30563
|
if (!existsSync19(join23(dir, "node_modules", "sharp"))) {
|
|
30233
|
-
|
|
30234
|
-
if (!existsSync19(join23(dir, "package.json")))
|
|
30564
|
+
mkdirSync13(dir, { recursive: true });
|
|
30565
|
+
if (!existsSync19(join23(dir, "package.json"))) writeFileSync19(join23(dir, "package.json"), '{"private":true}');
|
|
30235
30566
|
out("Getting the image tool once (it stays outside the site)...");
|
|
30236
30567
|
const r = spawnSync5(process.platform === "win32" ? "npm.cmd" : "npm", ["install", SHARP, "--no-audit", "--no-fund", "--silent"], { cwd: dir, stdio: "ignore", shell: process.platform === "win32" });
|
|
30237
30568
|
if (r.status !== 0) throw new CliError("The image tool could not be installed. Check the internet connection and run optimize again.", 1, "images_failed");
|
|
@@ -30272,8 +30603,8 @@ async function imagesCommand(root, folder, sharp = loadSharp) {
|
|
|
30272
30603
|
}
|
|
30273
30604
|
|
|
30274
30605
|
// src/commands/blocks.ts
|
|
30275
|
-
import { createHash as
|
|
30276
|
-
import { existsSync as existsSync20, mkdirSync as
|
|
30606
|
+
import { createHash as createHash5 } from "crypto";
|
|
30607
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync14, readFileSync as readFileSync16, writeFileSync as writeFileSync20 } from "fs";
|
|
30277
30608
|
import { dirname as dirname7, resolve as resolve8, sep as sep3 } from "path";
|
|
30278
30609
|
import { gunzipSync as gunzipSync3 } from "zlib";
|
|
30279
30610
|
var BLOCKS = [
|
|
@@ -30283,7 +30614,7 @@ var BLOCKS = [
|
|
|
30283
30614
|
{ key: "late-tags", title: "Tracking tags (Tag Manager, Google, Meta, Clarity) that load a moment after the page shows, at once on conversion pages and ad clicks" }
|
|
30284
30615
|
];
|
|
30285
30616
|
var MAX_BYTES3 = 5 * 1024 * 1024;
|
|
30286
|
-
var sha = (data) =>
|
|
30617
|
+
var sha = (data) => createHash5("sha256").update(data).digest("hex");
|
|
30287
30618
|
var lockPath = (base, key2) => resolve8(base, ".deployai", "blocks", `${key2}.lock.json`);
|
|
30288
30619
|
function readLock(base, key2) {
|
|
30289
30620
|
try {
|
|
@@ -30332,26 +30663,26 @@ async function blocksCommand(root, ctx, name, opts = {}) {
|
|
|
30332
30663
|
if (now === sha(e3.data)) {
|
|
30333
30664
|
lock[e3.name] = now;
|
|
30334
30665
|
} else if (opts.update && lock[e3.name] === now) {
|
|
30335
|
-
|
|
30666
|
+
writeFileSync20(target, e3.data);
|
|
30336
30667
|
lock[e3.name] = sha(e3.data);
|
|
30337
30668
|
updated.push(e3.name);
|
|
30338
30669
|
} else {
|
|
30339
30670
|
const upstream = resolve8(base, ".deployai", "blocks", `${block.key}-upstream`, e3.name);
|
|
30340
30671
|
if (upstream.startsWith(base + sep3)) {
|
|
30341
|
-
|
|
30342
|
-
|
|
30672
|
+
mkdirSync14(dirname7(upstream), { recursive: true });
|
|
30673
|
+
writeFileSync20(upstream, e3.data);
|
|
30343
30674
|
}
|
|
30344
30675
|
kept.push(e3.name);
|
|
30345
30676
|
}
|
|
30346
30677
|
continue;
|
|
30347
30678
|
}
|
|
30348
|
-
|
|
30349
|
-
|
|
30679
|
+
mkdirSync14(dirname7(target), { recursive: true });
|
|
30680
|
+
writeFileSync20(target, e3.data);
|
|
30350
30681
|
lock[e3.name] = sha(e3.data);
|
|
30351
30682
|
written.push(e3.name);
|
|
30352
30683
|
}
|
|
30353
|
-
|
|
30354
|
-
|
|
30684
|
+
mkdirSync14(dirname7(lockPath(base, block.key)), { recursive: true });
|
|
30685
|
+
writeFileSync20(lockPath(base, block.key), `${JSON.stringify(lock, null, 2)}
|
|
30355
30686
|
`);
|
|
30356
30687
|
out(`Added the ${block.key} block: ${written.length} files.`);
|
|
30357
30688
|
written.forEach((f) => out(` + ${f}`));
|
|
@@ -30413,7 +30744,7 @@ async function integrationsCommand(ctx, name, opts = {}) {
|
|
|
30413
30744
|
|
|
30414
30745
|
// src/commands/brand.ts
|
|
30415
30746
|
import { spawn as spawn5 } from "child_process";
|
|
30416
|
-
import { copyFileSync, existsSync as existsSync21, mkdirSync as
|
|
30747
|
+
import { copyFileSync, existsSync as existsSync21, mkdirSync as mkdirSync15, mkdtempSync as mkdtempSync3, readdirSync as readdirSync7, readFileSync as readFileSync17, rmSync as rmSync6, statSync as statSync4, writeFileSync as writeFileSync21 } from "fs";
|
|
30417
30748
|
import { createServer } from "http";
|
|
30418
30749
|
import { tmpdir as tmpdir4 } from "os";
|
|
30419
30750
|
import { basename as basename2, dirname as dirname8, extname as extname2, join as join24, relative as relative5, sep as sep4 } from "path";
|
|
@@ -30631,11 +30962,11 @@ function writeSiteFile(root, file2, data) {
|
|
|
30631
30962
|
const target = join24(webRoot(root), file2);
|
|
30632
30963
|
if (existsSync21(target)) {
|
|
30633
30964
|
const keep = join24(root, BRAND_DIR, "originals");
|
|
30634
|
-
|
|
30965
|
+
mkdirSync15(keep, { recursive: true });
|
|
30635
30966
|
copyFileSync(target, join24(keep, file2));
|
|
30636
30967
|
}
|
|
30637
|
-
|
|
30638
|
-
|
|
30968
|
+
mkdirSync15(dirname8(target), { recursive: true });
|
|
30969
|
+
writeFileSync21(target, data);
|
|
30639
30970
|
}
|
|
30640
30971
|
var send = (res, status, body = "", type = "text/plain; charset=utf-8") => {
|
|
30641
30972
|
res.writeHead(status, { "content-type": type, "cache-control": "no-store", "x-content-type-options": "nosniff" });
|
|
@@ -30994,10 +31325,10 @@ async function brandImagesCommand(root, urls, opts) {
|
|
|
30994
31325
|
if (verdict !== "ok") onPages.push({ where: m.src, width: m.width, height: m.height, shownWidth: m.shownWidth, verdict, alt: m.alt });
|
|
30995
31326
|
}
|
|
30996
31327
|
const weak = [...onPages, ...findings];
|
|
30997
|
-
|
|
31328
|
+
mkdirSync15(join24(root, BRAND_DIR), { recursive: true });
|
|
30998
31329
|
const file2 = `${BRAND_DIR}/images.json`;
|
|
30999
31330
|
const data = { measuredAt: (/* @__PURE__ */ new Date()).toISOString(), pages: urls, unmeasured, filesChecked: total, imagesMeasured: shown.size, weak };
|
|
31000
|
-
|
|
31331
|
+
writeFileSync21(join24(root, file2), `${JSON.stringify(data, null, 2)}
|
|
31001
31332
|
`);
|
|
31002
31333
|
if (opts.json) {
|
|
31003
31334
|
out(JSON.stringify(data));
|
|
@@ -31096,6 +31427,7 @@ ${AGENT_FEEDBACK_RULES.join("\n\n")}
|
|
|
31096
31427
|
if (!address) throw new CliError("Name the address, for example: npx deployai@latest requests open /api/webhooks/payments", 1, "usage");
|
|
31097
31428
|
return requestsOpenCommand(root(cmd), ctx(cmd), address, action === "open");
|
|
31098
31429
|
});
|
|
31430
|
+
program.command("logs").description("live logs of the linked site's code: the requests it answered, console lines and errors, up to 10 minutes, Ctrl+C stops. A failed build's log is in: npx deployai@latest status").option("--json", "one JSON object a line").option("--errors", "only errors").action((opts, cmd) => logsCommand(root(cmd), ctx(cmd), opts));
|
|
31099
31431
|
program.command("versions").description("list versions").action((_opts, cmd) => versionsCommand(root(cmd), ctx(cmd)));
|
|
31100
31432
|
program.command("rollback").description("put an earlier version back live, with no rebuild").argument("<version>", "for example v5").action((version2, _opts, cmd) => changeLiveCommand(root(cmd), ctx(cmd), version2, "rollback"));
|
|
31101
31433
|
program.command("promote").description("put a version live; new database changes (SQL) are shown and run first, after a yes").argument("<version>", "for example v5").option("--approve-sql <code>", "for an agent, after the owner said yes to the SQL that sql printed: the code it printed; never for SQL that removes data").option("--anyway", "put live a version made before a newer one went live, only after the owner said so (D-907)").action((version2, opts, cmd) => changeLiveCommand(root(cmd), ctx(cmd), version2, "promote", opts));
|
|
@@ -31161,8 +31493,10 @@ function withoutDoubledName(argv) {
|
|
|
31161
31493
|
}
|
|
31162
31494
|
async function main(rawArgv = process.argv) {
|
|
31163
31495
|
const argv = withoutDoubledName(rawArgv);
|
|
31496
|
+
if (argv !== rawArgv) err(`The first word was deployai again, so it was left out. Next time run: npx deployai@latest ${argv.slice(2).join(" ") || "--help"}`);
|
|
31164
31497
|
const program = buildProgram();
|
|
31165
31498
|
const started = Date.now();
|
|
31499
|
+
takeBlockedLine();
|
|
31166
31500
|
let command = null;
|
|
31167
31501
|
let apiFlag;
|
|
31168
31502
|
program.hook("preAction", (_this, actionCmd) => {
|
|
@@ -31179,13 +31513,17 @@ async function main(rawArgv = process.argv) {
|
|
|
31179
31513
|
let errorLine;
|
|
31180
31514
|
try {
|
|
31181
31515
|
await program.parseAsync(argv);
|
|
31182
|
-
if (process.exitCode === 1 && exitBefore !== 1)
|
|
31516
|
+
if (process.exitCode === 1 && exitBefore !== 1) {
|
|
31517
|
+
result = "blocked";
|
|
31518
|
+
errorLine = takeBlockedLine();
|
|
31519
|
+
}
|
|
31183
31520
|
} catch (e3) {
|
|
31184
31521
|
if (e3 instanceof CliError) {
|
|
31185
31522
|
err(e3.message);
|
|
31186
31523
|
process.exitCode = e3.exitCode;
|
|
31187
31524
|
if (e3.category === "blocked") {
|
|
31188
31525
|
result = "blocked";
|
|
31526
|
+
errorLine = e3.reason;
|
|
31189
31527
|
} else {
|
|
31190
31528
|
result = "error";
|
|
31191
31529
|
errorCategory = e3.category;
|
|
@@ -31202,7 +31540,7 @@ async function main(rawArgv = process.argv) {
|
|
|
31202
31540
|
errorCategory = "usage";
|
|
31203
31541
|
errorLine = parserErrorLine(e3.code, e3.message);
|
|
31204
31542
|
if (asked.quoted) err(`Pass each word on its own, with no quotes around them: npx deployai@latest ${asked.quoted}`);
|
|
31205
|
-
if (
|
|
31543
|
+
if (e3.code === "commander.unknownCommand" && !asked.quoted) for (const line of unknownCommandHelp(argv.slice(2), program)) err(line);
|
|
31206
31544
|
}
|
|
31207
31545
|
} else {
|
|
31208
31546
|
err(`Unexpected error: ${e3?.message ?? String(e3)}`);
|
|
@@ -31239,7 +31577,7 @@ function nodeGuideUrl(lang, base = API_BASE_DEFAULT) {
|
|
|
31239
31577
|
|
|
31240
31578
|
// src/update.ts
|
|
31241
31579
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
31242
|
-
import { existsSync as existsSync23, mkdirSync as
|
|
31580
|
+
import { existsSync as existsSync23, mkdirSync as mkdirSync16, readdirSync as readdirSync8, readFileSync as readFileSync18, rmSync as rmSync7, writeFileSync as writeFileSync22 } from "fs";
|
|
31243
31581
|
import { join as join26 } from "path";
|
|
31244
31582
|
var CHECK_EVERY_MS = 60 * 60 * 1e3;
|
|
31245
31583
|
var ASK_NPM_MS = 1500;
|
|
@@ -31290,8 +31628,8 @@ function readState() {
|
|
|
31290
31628
|
}
|
|
31291
31629
|
function writeState(state) {
|
|
31292
31630
|
try {
|
|
31293
|
-
|
|
31294
|
-
|
|
31631
|
+
mkdirSync16(configDir(), { recursive: true });
|
|
31632
|
+
writeFileSync22(statePath(), JSON.stringify(state) + "\n");
|
|
31295
31633
|
} catch {
|
|
31296
31634
|
}
|
|
31297
31635
|
}
|
|
@@ -31314,8 +31652,8 @@ function getVersion(version2, env) {
|
|
|
31314
31652
|
`);
|
|
31315
31653
|
const root = join26(configDir(), "cli");
|
|
31316
31654
|
const dir = join26(root, version2);
|
|
31317
|
-
|
|
31318
|
-
|
|
31655
|
+
mkdirSync16(dir, { recursive: true });
|
|
31656
|
+
writeFileSync22(join26(dir, "package.json"), '{"private":true}\n');
|
|
31319
31657
|
const installed = spawnSync6(`npm install deployai@${version2} --ignore-scripts --no-audit --no-fund --silent`, { cwd: dir, env, shell: true, stdio: "ignore", windowsHide: true, timeout: GET_VERSION_MS });
|
|
31320
31658
|
if (installed.status !== 0) return false;
|
|
31321
31659
|
const ran = spawnSync6(process.execPath, [versionEntry(version2), "--version"], { env: { ...env, DEPLOYAI_NO_UPDATE: "1" }, encoding: "utf8", timeout: GET_VERSION_MS });
|