deployai 0.1.0-beta.44 → 0.1.0-beta.45
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 +379 -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"),
|
|
@@ -23828,6 +23838,44 @@ var AGENT_POINTER = "Read DEPLOYAI.md before your first answer and before you wr
|
|
|
23828
23838
|
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
23839
|
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
23840
|
|
|
23841
|
+
// ../shared/src/blocked-reasons.ts
|
|
23842
|
+
var BLOCKED_REASONS = [
|
|
23843
|
+
// migrate verify: old pages on the preview
|
|
23844
|
+
"pages_missing",
|
|
23845
|
+
"pages_moved",
|
|
23846
|
+
"pages_error",
|
|
23847
|
+
"title_lost",
|
|
23848
|
+
"description_lost",
|
|
23849
|
+
// migrate verify: tags and connections (the tag finding's own problem)
|
|
23850
|
+
"tag_lost",
|
|
23851
|
+
"trigger_lost",
|
|
23852
|
+
"field_lost",
|
|
23853
|
+
"verification_lost",
|
|
23854
|
+
"file_lost",
|
|
23855
|
+
"blocked_by_headers",
|
|
23856
|
+
"event_lost",
|
|
23857
|
+
// migrate verify: what is left of the old site
|
|
23858
|
+
"builder_credit",
|
|
23859
|
+
"vendor_files",
|
|
23860
|
+
"old_host_assets",
|
|
23861
|
+
// migrate scan
|
|
23862
|
+
"source_closed",
|
|
23863
|
+
// deploy
|
|
23864
|
+
"check_blocked",
|
|
23865
|
+
"build_failed",
|
|
23866
|
+
"preview_down",
|
|
23867
|
+
"not_live",
|
|
23868
|
+
// start
|
|
23869
|
+
"login_wait",
|
|
23870
|
+
"other_account",
|
|
23871
|
+
// sync
|
|
23872
|
+
"sync_conflicts"
|
|
23873
|
+
];
|
|
23874
|
+
function blockedLine(codes) {
|
|
23875
|
+
const set2 = new Set(codes);
|
|
23876
|
+
return BLOCKED_REASONS.filter((c) => set2.has(c)).join(" ");
|
|
23877
|
+
}
|
|
23878
|
+
|
|
23831
23879
|
// ../shared/src/deployai-md.ts
|
|
23832
23880
|
var DEPLOYAI_MD = `# DeployAI rules
|
|
23833
23881
|
|
|
@@ -24438,10 +24486,10 @@ function parseSiteCron(expr) {
|
|
|
24438
24486
|
const raw = expr.trim().split(/\s+/);
|
|
24439
24487
|
if (raw.length !== 5 || expr.length > 100) return { error: "A schedule has five parts: minute, hour, day of month, month, day of week." };
|
|
24440
24488
|
const [mi, ho, dm, mo, dw] = raw;
|
|
24441
|
-
const
|
|
24489
|
+
const minutes2 = field(mi, 0, 59);
|
|
24442
24490
|
const hours = field(ho, 0, 23);
|
|
24443
24491
|
const months = field(mo, 1, 12, MONTHS);
|
|
24444
|
-
if (!
|
|
24492
|
+
if (!minutes2 || !hours || !months) return { error: "The minute, hour or month part does not read." };
|
|
24445
24493
|
const dom = { any: dm === "*" || dm === "?", days: [], last: false, lastWeekday: false, nearest: [] };
|
|
24446
24494
|
if (!dom.any) {
|
|
24447
24495
|
for (const part of dm.split(",")) {
|
|
@@ -24476,7 +24524,7 @@ function parseSiteCron(expr) {
|
|
|
24476
24524
|
}
|
|
24477
24525
|
}
|
|
24478
24526
|
}
|
|
24479
|
-
return { raw: [mi, ho, dm, mo, dw], minutes, hours, dom, months, dow };
|
|
24527
|
+
return { raw: [mi, ho, dm, mo, dw], minutes: minutes2, hours, dom, months, dow };
|
|
24480
24528
|
}
|
|
24481
24529
|
var isSiteCronSpec = (x) => !("error" in x);
|
|
24482
24530
|
var lastDayOf = (y, m) => new Date(Date.UTC(y, m, 0)).getUTCDate();
|
|
@@ -24790,14 +24838,16 @@ function updateProject(root, patch) {
|
|
|
24790
24838
|
|
|
24791
24839
|
// src/errors.ts
|
|
24792
24840
|
var CliError = class extends Error {
|
|
24793
|
-
constructor(message, exitCode = 1, category = "error") {
|
|
24841
|
+
constructor(message, exitCode = 1, category = "error", reason2) {
|
|
24794
24842
|
super(message);
|
|
24795
24843
|
this.exitCode = exitCode;
|
|
24796
24844
|
this.category = category;
|
|
24845
|
+
this.reason = reason2;
|
|
24797
24846
|
this.name = "CliError";
|
|
24798
24847
|
}
|
|
24799
24848
|
exitCode;
|
|
24800
24849
|
category;
|
|
24850
|
+
reason;
|
|
24801
24851
|
};
|
|
24802
24852
|
|
|
24803
24853
|
// src/i18n.ts
|
|
@@ -25101,6 +25151,17 @@ var M = {
|
|
|
25101
25151
|
runLink: " Run: npx deployai@latest link",
|
|
25102
25152
|
nextSteps: "Next steps",
|
|
25103
25153
|
readme: "Read README.md in the folder for what each file does.",
|
|
25154
|
+
logsWatching: "Live logs of {name} ({url}) until {time}. Ctrl+C stops.",
|
|
25155
|
+
logsErrorsOnly: "Errors only.",
|
|
25156
|
+
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.",
|
|
25157
|
+
logsEndTime: "Stopped after 10 minutes. To keep watching, run: npx deployai@latest logs",
|
|
25158
|
+
logsEndReplaced: "Stopped: logs of this site were opened somewhere else. One at a time per site.",
|
|
25159
|
+
logsEndCloudflare: "The logs stopped on Cloudflare's side. Run the same command again.",
|
|
25160
|
+
logsEndClosed: "The connection to DeployAI closed. Run the same command again.",
|
|
25161
|
+
logsStopped: "Stopped.",
|
|
25162
|
+
logsNotLive: 'This site has nothing live yet, so there are no logs. Put a version live first: npx deployai@latest deploy -m "<message>" --live',
|
|
25163
|
+
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.",
|
|
25164
|
+
logsUnavailable: "Logs cannot be read right now. Try again in a few minutes.",
|
|
25104
25165
|
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
25166
|
},
|
|
25106
25167
|
he: {
|
|
@@ -25391,6 +25452,17 @@ var M = {
|
|
|
25391
25452
|
runLink: " \u05D4\u05E8\u05D9\u05E6\u05D5: npx deployai@latest link",
|
|
25392
25453
|
nextSteps: "\u05D4\u05E9\u05DC\u05D1\u05D9\u05DD \u05D4\u05D1\u05D0\u05D9\u05DD",
|
|
25393
25454
|
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.",
|
|
25455
|
+
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.",
|
|
25456
|
+
logsErrorsOnly: "\u05E8\u05E7 \u05E9\u05D2\u05D9\u05D0\u05D5\u05EA.",
|
|
25457
|
+
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.",
|
|
25458
|
+
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",
|
|
25459
|
+
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.",
|
|
25460
|
+
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.",
|
|
25461
|
+
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.",
|
|
25462
|
+
logsStopped: "\u05E0\u05E2\u05E6\u05E8.",
|
|
25463
|
+
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',
|
|
25464
|
+
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.",
|
|
25465
|
+
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
25466
|
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
25467
|
}
|
|
25396
25468
|
};
|
|
@@ -25428,7 +25500,7 @@ function formatBytes(n2) {
|
|
|
25428
25500
|
}
|
|
25429
25501
|
|
|
25430
25502
|
// src/version.ts
|
|
25431
|
-
var CLI_VERSION = "0.1.0-beta.
|
|
25503
|
+
var CLI_VERSION = "0.1.0-beta.45";
|
|
25432
25504
|
|
|
25433
25505
|
// src/api.ts
|
|
25434
25506
|
function apiContext(apiFlag, root) {
|
|
@@ -25615,7 +25687,7 @@ import { arch as arch2, platform as platform2 } from "os";
|
|
|
25615
25687
|
var TELEMETRY_SENT = [
|
|
25616
25688
|
"Install id (random, made on this computer) and CLI version",
|
|
25617
25689
|
"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",
|
|
25690
|
+
"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
25691
|
"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
25692
|
"Linked project id, detected framework and version",
|
|
25621
25693
|
"After each check: compatible or not, blocker and warning codes (for example fs_write)",
|
|
@@ -25679,7 +25751,7 @@ function buildTelemetryEvent(installId, command, result, errorCategory, extra =
|
|
|
25679
25751
|
const tool = deployToolFromEnv(process.env);
|
|
25680
25752
|
if (tool) ev.tool = tool;
|
|
25681
25753
|
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);
|
|
25754
|
+
if ((result === "error" || result === "blocked") && extra.errorLine) ev.errorLine = scrubText(extra.errorLine, ERROR_LINE_MAX);
|
|
25683
25755
|
return ev;
|
|
25684
25756
|
}
|
|
25685
25757
|
async function sendTelemetryEvent(ctx, event) {
|
|
@@ -25700,6 +25772,73 @@ async function sendTelemetryEvent(ctx, event) {
|
|
|
25700
25772
|
}
|
|
25701
25773
|
}
|
|
25702
25774
|
|
|
25775
|
+
// src/blocked.ts
|
|
25776
|
+
var reasons = /* @__PURE__ */ new Set();
|
|
25777
|
+
function blockedBy(...codes) {
|
|
25778
|
+
for (const c of codes) reasons.add(c);
|
|
25779
|
+
}
|
|
25780
|
+
function takeBlockedLine() {
|
|
25781
|
+
const line = blockedLine(reasons);
|
|
25782
|
+
reasons.clear();
|
|
25783
|
+
return line || void 0;
|
|
25784
|
+
}
|
|
25785
|
+
|
|
25786
|
+
// src/did-you-mean.ts
|
|
25787
|
+
var RUN = "npx deployai@latest";
|
|
25788
|
+
var VALUE_OPTIONS = /* @__PURE__ */ new Set(["--api", "--dir", "-C", "--lang"]);
|
|
25789
|
+
var MEANS = {
|
|
25790
|
+
connect: [
|
|
25791
|
+
"There is no connect command.",
|
|
25792
|
+
`To connect this folder to the site the owner made on DeployAI, run the line the site gave: ${RUN} start <id>`,
|
|
25793
|
+
`For a site that is already on DeployAI: ${RUN} link`,
|
|
25794
|
+
"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"
|
|
25795
|
+
],
|
|
25796
|
+
publish: [`To publish: ${RUN} deploy`],
|
|
25797
|
+
upload: [`To upload a new version: ${RUN} deploy`],
|
|
25798
|
+
push: [`To upload a new version: ${RUN} deploy`],
|
|
25799
|
+
live: [`To put a ready version live: ${RUN} promote <version>`]
|
|
25800
|
+
};
|
|
25801
|
+
function editDistance(a, b) {
|
|
25802
|
+
let prev = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
25803
|
+
for (let i = 1; i <= a.length; i++) {
|
|
25804
|
+
const row2 = [i];
|
|
25805
|
+
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));
|
|
25806
|
+
prev = row2;
|
|
25807
|
+
}
|
|
25808
|
+
return prev[b.length];
|
|
25809
|
+
}
|
|
25810
|
+
function closestCommand(word, names) {
|
|
25811
|
+
const w = word.toLowerCase();
|
|
25812
|
+
let best = null;
|
|
25813
|
+
for (const name of names) {
|
|
25814
|
+
const d = name.startsWith(w) && w.length >= 3 ? 0.5 : editDistance(w, name);
|
|
25815
|
+
if (!best || d < best.d) best = { name, d };
|
|
25816
|
+
}
|
|
25817
|
+
return best && best.d <= Math.max(1, Math.floor(w.length / 3)) ? best.name : null;
|
|
25818
|
+
}
|
|
25819
|
+
var START_ID = new RegExp(`^[${START_ID_ALPHABET}]{10}$`);
|
|
25820
|
+
function unknownCommandHelp(args, program) {
|
|
25821
|
+
const words = [];
|
|
25822
|
+
for (let i = 0; i < args.length; i++) {
|
|
25823
|
+
const a = args[i];
|
|
25824
|
+
if (VALUE_OPTIONS.has(a)) i++;
|
|
25825
|
+
else if (!a.startsWith("-")) words.push({ w: a, at: i });
|
|
25826
|
+
}
|
|
25827
|
+
const rest = (at) => args.length > at + 1 ? ` ${args.slice(at + 1).join(" ")}` : "";
|
|
25828
|
+
const [first, second] = words;
|
|
25829
|
+
if (!first) return [`All commands: ${RUN} --help`];
|
|
25830
|
+
const group = program.commands.find((c) => c.name() === first.w && c.commands.length);
|
|
25831
|
+
if (group && second) {
|
|
25832
|
+
const near2 = closestCommand(second.w, group.commands.map((c) => c.name()));
|
|
25833
|
+
return [...near2 ? [`Did you mean: ${RUN} ${first.w} ${near2}${rest(second.at)}`] : [], `The ${first.w} commands: ${RUN} ${first.w} --help`];
|
|
25834
|
+
}
|
|
25835
|
+
const meant = MEANS[first.w.toLowerCase()];
|
|
25836
|
+
if (meant) return [...meant, `All commands: ${RUN} --help`];
|
|
25837
|
+
if (START_ID.test(first.w)) return [`That looks like the site's start id. Run: ${RUN} start ${first.w}`];
|
|
25838
|
+
const near = closestCommand(first.w, program.commands.map((c) => c.name()));
|
|
25839
|
+
return [...near ? [`Did you mean: ${RUN} ${near}${rest(first.at)}`] : [], `All commands: ${RUN} --help`];
|
|
25840
|
+
}
|
|
25841
|
+
|
|
25703
25842
|
// src/commands/feedback.ts
|
|
25704
25843
|
var COMMAND = /^[a-z][a-z -]{0,59}$/;
|
|
25705
25844
|
async function feedbackCommand(root, ctx, opts) {
|
|
@@ -26674,11 +26813,16 @@ function copyToClipboard(text2) {
|
|
|
26674
26813
|
}
|
|
26675
26814
|
return false;
|
|
26676
26815
|
}
|
|
26816
|
+
function windowsBrowserDirs(env = process.env) {
|
|
26817
|
+
const drive = env.SystemDrive || "C:";
|
|
26818
|
+
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];
|
|
26819
|
+
return [...new Set(dirs.filter((d) => !!d))];
|
|
26820
|
+
}
|
|
26677
26821
|
function findBrowser() {
|
|
26678
26822
|
if (process.env.DEPLOYAI_NO_BROWSER) return null;
|
|
26679
26823
|
const set2 = process.env.CHROME_PATH;
|
|
26680
26824
|
if (set2 && existsSync7(set2)) return set2;
|
|
26681
|
-
const places = process.platform === "win32" ?
|
|
26825
|
+
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
26826
|
return places.find((p) => existsSync7(p)) ?? null;
|
|
26683
26827
|
}
|
|
26684
26828
|
function openBrowser(url2) {
|
|
@@ -27760,7 +27904,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
|
|
|
27760
27904
|
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
27905
|
const home = await get(source);
|
|
27762
27906
|
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");
|
|
27907
|
+
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
27908
|
const origin = new URL(home.url).origin;
|
|
27765
27909
|
const base = (origin + new URL(home.url).pathname).replace(/\/+$/, "");
|
|
27766
27910
|
const html = await home.text();
|
|
@@ -28179,12 +28323,14 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
28179
28323
|
out(`A builder's credit is still on the preview:`);
|
|
28180
28324
|
for (const [text2, path] of credits) out(` ${path} ${text2}`);
|
|
28181
28325
|
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.");
|
|
28326
|
+
blockedBy("builder_credit");
|
|
28182
28327
|
process.exitCode = 1;
|
|
28183
28328
|
}
|
|
28184
28329
|
if (vendors.size) {
|
|
28185
28330
|
out(`Files of a plugin or theme are still on the preview:`);
|
|
28186
28331
|
for (const [name, path] of vendors) out(` ${path} ${name}`);
|
|
28187
28332
|
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.");
|
|
28333
|
+
blockedBy("vendor_files");
|
|
28188
28334
|
process.exitCode = 1;
|
|
28189
28335
|
}
|
|
28190
28336
|
if (leftOnOld.length) {
|
|
@@ -28192,6 +28338,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
28192
28338
|
out("Still loading from the old site and missing from this one, so it breaks when the old site closes:");
|
|
28193
28339
|
for (const a of leftOnOld) out(` ${what[a.kind]} ${a.url}`);
|
|
28194
28340
|
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.");
|
|
28341
|
+
blockedBy("old_host_assets");
|
|
28195
28342
|
process.exitCode = 1;
|
|
28196
28343
|
}
|
|
28197
28344
|
if (tagFindings.length) {
|
|
@@ -28199,6 +28346,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
28199
28346
|
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
28347
|
if (tagFindings.length > 60) out(` and ${tagFindings.length - 60} more in verify.json`);
|
|
28201
28348
|
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.');
|
|
28349
|
+
blockedBy(...tagFindings.map((f) => f.problem));
|
|
28202
28350
|
process.exitCode = 1;
|
|
28203
28351
|
}
|
|
28204
28352
|
const clean3 = !findings.length && !tagFindings.length && !credits.size && !vendors.size && !leftOnOld.length;
|
|
@@ -28216,6 +28364,8 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
|
|
|
28216
28364
|
for (const f of findings.slice(0, 60)) out(` ${f.path} ${words[f.problem]}${f.detail ? ` ${f.detail}` : ""}`);
|
|
28217
28365
|
if (findings.length > 60) out(` and ${findings.length - 60} more in verify.json`);
|
|
28218
28366
|
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.");
|
|
28367
|
+
const pageReason = { missing: "pages_missing", moved: "pages_moved", error: "pages_error", title_lost: "title_lost", description_lost: "description_lost" };
|
|
28368
|
+
blockedBy(...findings.map((f) => pageReason[f.problem]));
|
|
28219
28369
|
process.exitCode = 1;
|
|
28220
28370
|
}
|
|
28221
28371
|
|
|
@@ -28924,7 +29074,10 @@ async function syncCommand(root, ctx) {
|
|
|
28924
29074
|
}
|
|
28925
29075
|
out();
|
|
28926
29076
|
out(r.conflicts.length || r.clashes.length ? t("syncNextConflicts") : t("syncNext"));
|
|
28927
|
-
if (r.conflicts.length || r.clashes.length)
|
|
29077
|
+
if (r.conflicts.length || r.clashes.length) {
|
|
29078
|
+
blockedBy("sync_conflicts");
|
|
29079
|
+
process.exitCode = 1;
|
|
29080
|
+
}
|
|
28928
29081
|
}
|
|
28929
29082
|
function syncLeftovers(root) {
|
|
28930
29083
|
let state;
|
|
@@ -29066,6 +29219,10 @@ function printStatus(root, ctx, projectId, s) {
|
|
|
29066
29219
|
])
|
|
29067
29220
|
);
|
|
29068
29221
|
printClosedHere(root, s);
|
|
29222
|
+
if (s.githubPull) {
|
|
29223
|
+
out();
|
|
29224
|
+
out(cliLang(root) === "he" ? s.githubPull.he : s.githubPull.en);
|
|
29225
|
+
}
|
|
29069
29226
|
if (s.latest?.goingLive) {
|
|
29070
29227
|
out();
|
|
29071
29228
|
out(t("goingLive", { n: s.latest.number }));
|
|
@@ -29244,7 +29401,7 @@ async function prepare(root, ctx, maxBytes) {
|
|
|
29244
29401
|
if (!analysis.compatible) {
|
|
29245
29402
|
await runCheck(root, { ...ctx, config: { ...ctx.config, telemetry: false } }, {});
|
|
29246
29403
|
out();
|
|
29247
|
-
throw new CliError(messages(root)("deployBlocked"), 1, "blocked");
|
|
29404
|
+
throw new CliError(messages(root)("deployBlocked"), 1, "blocked", "check_blocked");
|
|
29248
29405
|
}
|
|
29249
29406
|
const t = messages(root);
|
|
29250
29407
|
const left = syncLeftovers(root);
|
|
@@ -29391,6 +29548,7 @@ async function afterBuild(root, ctx, projectId, n2, o) {
|
|
|
29391
29548
|
}
|
|
29392
29549
|
if (ready && built.latest?.preview) {
|
|
29393
29550
|
if (!await homeAnswers(root, built.latest.preview, o.homeRetryMs)) {
|
|
29551
|
+
blockedBy("preview_down");
|
|
29394
29552
|
process.exitCode = 1;
|
|
29395
29553
|
return;
|
|
29396
29554
|
}
|
|
@@ -29425,7 +29583,10 @@ async function afterBuild(root, ctx, projectId, n2, o) {
|
|
|
29425
29583
|
return;
|
|
29426
29584
|
}
|
|
29427
29585
|
printStatus(root, ctx, projectId, built);
|
|
29428
|
-
if (built.latest?.number === n2 && built.latest.status === "failed")
|
|
29586
|
+
if (built.latest?.number === n2 && built.latest.status === "failed") {
|
|
29587
|
+
blockedBy("build_failed");
|
|
29588
|
+
process.exitCode = 1;
|
|
29589
|
+
}
|
|
29429
29590
|
return;
|
|
29430
29591
|
}
|
|
29431
29592
|
await apiRequest(ctx, "/api/cli/promote", null, { method: "POST", body: { projectId, number: n2, ...approval } });
|
|
@@ -29444,6 +29605,7 @@ async function afterBuild(root, ctx, projectId, n2, o) {
|
|
|
29444
29605
|
return;
|
|
29445
29606
|
}
|
|
29446
29607
|
printStatus(root, ctx, projectId, after);
|
|
29608
|
+
blockedBy("not_live");
|
|
29447
29609
|
process.exitCode = 1;
|
|
29448
29610
|
}
|
|
29449
29611
|
async function readPreview(url2) {
|
|
@@ -29551,6 +29713,118 @@ async function claimCommand(root, ctx, opts) {
|
|
|
29551
29713
|
out(t("claimLink", { url: url2 }));
|
|
29552
29714
|
}
|
|
29553
29715
|
|
|
29716
|
+
// src/commands/logs.ts
|
|
29717
|
+
var REFUSALS = {
|
|
29718
|
+
site_deleted: "siteDeleted",
|
|
29719
|
+
not_on_site: "notOnSite",
|
|
29720
|
+
view_only: "viewOnly",
|
|
29721
|
+
not_found: "notFound",
|
|
29722
|
+
logs_not_live: "logsNotLive",
|
|
29723
|
+
logs_site_off: "logsSiteOff",
|
|
29724
|
+
logs_unavailable: "logsUnavailable"
|
|
29725
|
+
};
|
|
29726
|
+
var two = (n2) => String(n2).padStart(2, "0");
|
|
29727
|
+
var clock = (at) => {
|
|
29728
|
+
const d = new Date(at);
|
|
29729
|
+
return `${two(d.getHours())}:${two(d.getMinutes())}:${two(d.getSeconds())}`;
|
|
29730
|
+
};
|
|
29731
|
+
var formatLogLine = (l) => `${clock(l.at)} ${l.level.toUpperCase().padEnd(5)} ${l.text}`;
|
|
29732
|
+
function readEvents(buffer) {
|
|
29733
|
+
const events = [];
|
|
29734
|
+
const parts2 = buffer.replace(/\r\n/g, "\n").split("\n\n");
|
|
29735
|
+
const rest = parts2.pop() ?? "";
|
|
29736
|
+
for (const block of parts2) {
|
|
29737
|
+
let event = "message";
|
|
29738
|
+
const data = [];
|
|
29739
|
+
for (const line of block.split("\n")) {
|
|
29740
|
+
if (line.startsWith(":")) continue;
|
|
29741
|
+
if (line.startsWith("event:")) event = line.slice(6).trim();
|
|
29742
|
+
else if (line.startsWith("data:")) data.push(line.slice(5).replace(/^ /, ""));
|
|
29743
|
+
}
|
|
29744
|
+
if (data.length) events.push({ event, data: data.join("\n") });
|
|
29745
|
+
}
|
|
29746
|
+
return { events, rest };
|
|
29747
|
+
}
|
|
29748
|
+
async function logsCommand(root, ctx, opts) {
|
|
29749
|
+
const token = requireToken(ctx);
|
|
29750
|
+
const projectId = linkedProjectId(root);
|
|
29751
|
+
const t = messages(root);
|
|
29752
|
+
const say = opts.json ? err : out;
|
|
29753
|
+
const abort = new AbortController();
|
|
29754
|
+
let stopped = false;
|
|
29755
|
+
const onSigint = () => {
|
|
29756
|
+
stopped = true;
|
|
29757
|
+
abort.abort();
|
|
29758
|
+
};
|
|
29759
|
+
process.once("SIGINT", onSigint);
|
|
29760
|
+
try {
|
|
29761
|
+
const url2 = `${ctx.apiUrl}/api/cli/logs?projectId=${encodeURIComponent(projectId)}${opts.errors ? "&errors=1" : ""}`;
|
|
29762
|
+
const headersWait = setTimeout(() => abort.abort(), 3e4);
|
|
29763
|
+
let res;
|
|
29764
|
+
try {
|
|
29765
|
+
res = await fetch(url2, { headers: { Authorization: `Bearer ${token}`, Accept: "text/event-stream", "User-Agent": userAgent(ctx.config) }, signal: abort.signal });
|
|
29766
|
+
} catch {
|
|
29767
|
+
if (stopped) return say(t("logsStopped"));
|
|
29768
|
+
throw new CliError(t("unreachable", { url: ctx.apiUrl }), 1, "network");
|
|
29769
|
+
} finally {
|
|
29770
|
+
clearTimeout(headersWait);
|
|
29771
|
+
}
|
|
29772
|
+
if (res.status === 401) throw new CliError(t("sessionExpired"), 1, "auth");
|
|
29773
|
+
if (!res.ok || !res.body) {
|
|
29774
|
+
const parsed = ApiError.safeParse(await res.json().catch(() => null));
|
|
29775
|
+
const code = parsed.success ? parsed.data.error : `HTTP ${res.status}`;
|
|
29776
|
+
const key2 = REFUSALS[code];
|
|
29777
|
+
throw new CliError(key2 ? t(key2) : t("apiError", { code }), 1, code.startsWith("logs_") ? code : res.status === 403 ? "forbidden" : res.status === 404 ? "not_found" : "api");
|
|
29778
|
+
}
|
|
29779
|
+
const reader = res.body.getReader();
|
|
29780
|
+
const decoder = new TextDecoder();
|
|
29781
|
+
let buffer = "";
|
|
29782
|
+
let ended = null;
|
|
29783
|
+
for (; ; ) {
|
|
29784
|
+
let chunk;
|
|
29785
|
+
try {
|
|
29786
|
+
chunk = await reader.read();
|
|
29787
|
+
} catch {
|
|
29788
|
+
break;
|
|
29789
|
+
}
|
|
29790
|
+
if (chunk.done) break;
|
|
29791
|
+
buffer += decoder.decode(chunk.value, { stream: true });
|
|
29792
|
+
const { events, rest } = readEvents(buffer);
|
|
29793
|
+
buffer = rest;
|
|
29794
|
+
for (const e3 of events) {
|
|
29795
|
+
let data;
|
|
29796
|
+
try {
|
|
29797
|
+
data = JSON.parse(e3.data);
|
|
29798
|
+
} catch {
|
|
29799
|
+
continue;
|
|
29800
|
+
}
|
|
29801
|
+
if (e3.event === "ready") {
|
|
29802
|
+
const r = LogsReady.safeParse(data);
|
|
29803
|
+
if (!r.success) continue;
|
|
29804
|
+
say(t("logsWatching", { name: r.data.name, url: r.data.url ?? "-", time: clock(r.data.until).slice(0, 5) }));
|
|
29805
|
+
if (opts.errors) say(t("logsErrorsOnly"));
|
|
29806
|
+
say(t("logsNote"));
|
|
29807
|
+
} else if (e3.event === "line") {
|
|
29808
|
+
const l = LogLine.safeParse(data);
|
|
29809
|
+
if (l.success) out(opts.json ? JSON.stringify(l.data) : formatLogLine(l.data));
|
|
29810
|
+
} else if (e3.event === "end") {
|
|
29811
|
+
const r = LogsEnd.safeParse(data);
|
|
29812
|
+
if (r.success) ended = r.data.reason;
|
|
29813
|
+
}
|
|
29814
|
+
}
|
|
29815
|
+
if (ended) break;
|
|
29816
|
+
}
|
|
29817
|
+
if (stopped) return say(t("logsStopped"));
|
|
29818
|
+
if (ended === "time") return say(t("logsEndTime"));
|
|
29819
|
+
if (ended === "replaced") return say(t("logsEndReplaced"));
|
|
29820
|
+
if (ended === "cloudflare") throw new CliError(t("logsEndCloudflare"), 1, "logs_ended");
|
|
29821
|
+
throw new CliError(t("logsEndClosed"), 1, "logs_ended");
|
|
29822
|
+
} finally {
|
|
29823
|
+
process.removeListener("SIGINT", onSigint);
|
|
29824
|
+
abort.abort();
|
|
29825
|
+
}
|
|
29826
|
+
}
|
|
29827
|
+
|
|
29554
29828
|
// src/commands/requests.ts
|
|
29555
29829
|
var OUTCOME = {
|
|
29556
29830
|
site: "reached the site",
|
|
@@ -29679,7 +29953,7 @@ async function startCommand(cwd, ctx, id, opts = {}) {
|
|
|
29679
29953
|
out(messages(process.cwd())("startLoginFirst"));
|
|
29680
29954
|
out(START_LOGIN_WAIT_LINE);
|
|
29681
29955
|
out();
|
|
29682
|
-
await sendTelemetryEvent(ctxNow, buildTelemetryEvent(ctxNow.config.installId, "start", "blocked"));
|
|
29956
|
+
await sendTelemetryEvent(ctxNow, buildTelemetryEvent(ctxNow.config.installId, "start", "blocked", void 0, { errorLine: "login_wait" }));
|
|
29683
29957
|
await loginCommand(ctxNow, { pollMs: opts.pollMs, quiet: true }).catch((e3) => {
|
|
29684
29958
|
if (e3 instanceof CliError && e3.category === "auth_expired") throw new CliError(messages(process.cwd())("startLoginExpired", { id: key2 }), 1, "auth_expired");
|
|
29685
29959
|
throw e3;
|
|
@@ -29694,7 +29968,7 @@ async function startCommand(cwd, ctx, id, opts = {}) {
|
|
|
29694
29968
|
out(t0("startOtherAccount", { email: ctxNow.config.email ?? "?", maker }));
|
|
29695
29969
|
out(START_LOGIN_WAIT_LINE);
|
|
29696
29970
|
out();
|
|
29697
|
-
await sendTelemetryEvent(ctxNow, buildTelemetryEvent(ctxNow.config.installId, "start", "blocked", "other_account"));
|
|
29971
|
+
await sendTelemetryEvent(ctxNow, buildTelemetryEvent(ctxNow.config.installId, "start", "blocked", void 0, { errorLine: "other_account" }));
|
|
29698
29972
|
await loginCommand(ctxNow, { pollMs: opts.pollMs, quiet: true, force: true }).catch((e3) => {
|
|
29699
29973
|
if (e3 instanceof CliError && e3.category === "auth_expired") throw new CliError(t0("startLoginExpired", { id: key2 }), 1, "auth_expired");
|
|
29700
29974
|
throw e3;
|
|
@@ -30016,7 +30290,8 @@ async function addonDoneCommand(root, ctx, runId, opts) {
|
|
|
30016
30290
|
|
|
30017
30291
|
// src/commands/speed.ts
|
|
30018
30292
|
import { spawn as spawn3 } from "child_process";
|
|
30019
|
-
import {
|
|
30293
|
+
import { createHash as createHash4 } from "crypto";
|
|
30294
|
+
import { mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync2, readFileSync as readFileSync14, rmSync as rmSync4, writeFileSync as writeFileSync17 } from "fs";
|
|
30020
30295
|
import { tmpdir as tmpdir2 } from "os";
|
|
30021
30296
|
import { join as join21 } from "path";
|
|
30022
30297
|
var ms = (v) => v >= 1e3 ? `${(v / 1e3).toFixed(1)} s` : `${Math.round(v)} ms`;
|
|
@@ -30054,9 +30329,9 @@ async function localSpeed(url2, strategy, run = runLighthouse, browser = findBro
|
|
|
30054
30329
|
rmSync4(dir, { recursive: true, force: true, maxRetries: 3 });
|
|
30055
30330
|
}
|
|
30056
30331
|
}
|
|
30057
|
-
function printReport(r, strategy,
|
|
30332
|
+
function printReport(r, strategy, local2) {
|
|
30058
30333
|
out();
|
|
30059
|
-
out(`Lab test (one simulated ${strategy} load${
|
|
30334
|
+
out(`Lab test (one simulated ${strategy} load${local2 ? " on this computer" : ""}), Lighthouse ${r.lighthouseVersion ?? ""}`);
|
|
30060
30335
|
out(` Performance score ${r.scores.performance ?? "?"}`);
|
|
30061
30336
|
for (const m of r.lab) out(` ${m.id.padEnd(26)} ${m.display ?? "?"}`);
|
|
30062
30337
|
out();
|
|
@@ -30064,7 +30339,7 @@ function printReport(r, strategy, local) {
|
|
|
30064
30339
|
out(`Real visitors, last 28 days (${r.field.scope === "url" ? "this page" : "whole site"}, 75th percentile)`);
|
|
30065
30340
|
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
30341
|
} else {
|
|
30067
|
-
out(
|
|
30342
|
+
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
30343
|
}
|
|
30069
30344
|
if (r.opportunities.length) {
|
|
30070
30345
|
out();
|
|
@@ -30072,6 +30347,24 @@ function printReport(r, strategy, local) {
|
|
|
30072
30347
|
for (const a of r.opportunities.slice(0, 8)) out(` - ${a.title}${a.display ? ` (${a.display})` : a.savingsMs ? ` (about ${ms(a.savingsMs)})` : ""}`);
|
|
30073
30348
|
}
|
|
30074
30349
|
}
|
|
30350
|
+
var CACHE_MS = 10 * 6e4;
|
|
30351
|
+
var cacheFile = (dir, url2, strategy) => join21(dir, `${createHash4("sha256").update(`${strategy} ${url2}`).digest("hex").slice(0, 24)}.json`);
|
|
30352
|
+
function readCache(dir, url2, strategy) {
|
|
30353
|
+
try {
|
|
30354
|
+
return JSON.parse(readFileSync14(cacheFile(dir, url2, strategy), "utf8"));
|
|
30355
|
+
} catch {
|
|
30356
|
+
return null;
|
|
30357
|
+
}
|
|
30358
|
+
}
|
|
30359
|
+
function writeCache(dir, url2, strategy, c) {
|
|
30360
|
+
try {
|
|
30361
|
+
mkdirSync11(dir, { recursive: true });
|
|
30362
|
+
writeFileSync17(cacheFile(dir, url2, strategy), JSON.stringify(c));
|
|
30363
|
+
} catch {
|
|
30364
|
+
}
|
|
30365
|
+
}
|
|
30366
|
+
var minutes = (msLeft) => Math.max(1, Math.ceil(msLeft / 6e4));
|
|
30367
|
+
var waitText = (s) => s >= 7200 ? `in about ${Math.ceil(s / 3600)} hours` : `in about ${minutes(s * 1e3)} minutes`;
|
|
30075
30368
|
async function speedCommand(ctx, url2, opts, deps = {}) {
|
|
30076
30369
|
requireToken(ctx);
|
|
30077
30370
|
const strategy = opts.desktop ? "desktop" : "mobile";
|
|
@@ -30082,7 +30375,32 @@ async function speedCommand(ctx, url2, opts, deps = {}) {
|
|
|
30082
30375
|
} catch {
|
|
30083
30376
|
throw new CliError(`Not an address: ${url2}. Use the full address, for example https://example.com/`, 1, "usage");
|
|
30084
30377
|
}
|
|
30085
|
-
const
|
|
30378
|
+
const dir = deps.cacheDir ?? join21(tmpdir2(), "deployai-speed-cache");
|
|
30379
|
+
const now = deps.now ?? Date.now;
|
|
30380
|
+
const cached2 = readCache(dir, page3, strategy);
|
|
30381
|
+
if (cached2 && now() - cached2.at < CACHE_MS) {
|
|
30382
|
+
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.`);
|
|
30383
|
+
printReport(cached2.report, strategy, cached2.local);
|
|
30384
|
+
if (cached2.link) {
|
|
30385
|
+
out();
|
|
30386
|
+
out(`Full report: ${cached2.link}`);
|
|
30387
|
+
}
|
|
30388
|
+
return;
|
|
30389
|
+
}
|
|
30390
|
+
const started = await apiRequest(ctx, "/api/cli/speed", null, { method: "POST", body: { url: url2, strategy } });
|
|
30391
|
+
if (started.limited) {
|
|
30392
|
+
const when = waitText(started.retryAfter ?? 3600);
|
|
30393
|
+
if (cached2 || started.last) {
|
|
30394
|
+
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)` : ""}.`);
|
|
30395
|
+
if (cached2) printReport(cached2.report, strategy, cached2.local);
|
|
30396
|
+
out();
|
|
30397
|
+
out(`Full report: ${started.last ? `${ctx.apiUrl}/tools/r/${started.last.id}` : cached2?.link ?? ""}`);
|
|
30398
|
+
return;
|
|
30399
|
+
}
|
|
30400
|
+
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");
|
|
30401
|
+
}
|
|
30402
|
+
const id = started.id;
|
|
30403
|
+
if (!id) return local(page3, strategy, deps, dir, now);
|
|
30086
30404
|
out(`Testing ${url2} (${strategy}) with Google PageSpeed Insights. This usually takes 15 to 40 seconds...`);
|
|
30087
30405
|
const deadline = Date.now() + (deps.waitMs ?? 15e4);
|
|
30088
30406
|
let run = null;
|
|
@@ -30092,17 +30410,22 @@ async function speedCommand(ctx, url2, opts, deps = {}) {
|
|
|
30092
30410
|
if (run.status === "done" || run.status === "failed") break;
|
|
30093
30411
|
}
|
|
30094
30412
|
if (run?.status === "done" && run.result) {
|
|
30413
|
+
writeCache(dir, page3, strategy, { at: now(), report: run.result, local: false, link: `${ctx.apiUrl}/tools/r/${id}` });
|
|
30095
30414
|
printReport(run.result, strategy, false);
|
|
30096
30415
|
out();
|
|
30097
30416
|
out(`Full report: ${ctx.apiUrl}/tools/r/${id}`);
|
|
30098
30417
|
return;
|
|
30099
30418
|
}
|
|
30100
30419
|
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");
|
|
30420
|
+
return local(page3, strategy, deps, dir, now);
|
|
30421
|
+
}
|
|
30422
|
+
async function local(page3, strategy, deps, dir, now) {
|
|
30101
30423
|
out("Google's test is not available right now, so Lighthouse is running on this computer. This takes about a minute...");
|
|
30102
30424
|
const browser = deps.browser === void 0 ? findBrowser() : deps.browser;
|
|
30103
30425
|
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
30426
|
const report2 = await localSpeed(page3, strategy, deps.run, browser);
|
|
30105
30427
|
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");
|
|
30428
|
+
writeCache(dir, page3, strategy, { at: now(), report: report2, local: true, link: null });
|
|
30106
30429
|
printReport(report2, strategy, true);
|
|
30107
30430
|
out();
|
|
30108
30431
|
out("Measured on this computer, so compare it only with numbers measured the same way.");
|
|
@@ -30110,7 +30433,7 @@ async function speedCommand(ctx, url2, opts, deps = {}) {
|
|
|
30110
30433
|
|
|
30111
30434
|
// src/commands/shot.ts
|
|
30112
30435
|
import { spawn as spawn4 } from "child_process";
|
|
30113
|
-
import { existsSync as existsSync18, mkdirSync as
|
|
30436
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync12, readFileSync as readFileSync15, rmSync as rmSync5, writeFileSync as writeFileSync18 } from "fs";
|
|
30114
30437
|
import { tmpdir as tmpdir3 } from "os";
|
|
30115
30438
|
import { join as join22, resolve as resolve6 } from "path";
|
|
30116
30439
|
var SHOT_SIZES = [{ name: "phone", size: "390,844" }, { name: "desktop", size: "1440,900" }];
|
|
@@ -30177,9 +30500,9 @@ async function shotCommand(root, address, opts = {}, run = runNpx) {
|
|
|
30177
30500
|
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
30501
|
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
30502
|
const dir = resolve6(root, opts.out ?? join22(".deployai", "shots"));
|
|
30180
|
-
|
|
30503
|
+
mkdirSync12(dir, { recursive: true });
|
|
30181
30504
|
const taker = join22(tmpdir3(), "deployai-shot.cjs");
|
|
30182
|
-
|
|
30505
|
+
writeFileSync18(taker, TAKER);
|
|
30183
30506
|
const saved = [];
|
|
30184
30507
|
for (const s of SHOT_SIZES) {
|
|
30185
30508
|
const file2 = join22(dir, shotName(url2.toString(), s.name));
|
|
@@ -30200,7 +30523,7 @@ async function shotCommand(root, address, opts = {}, run = runNpx) {
|
|
|
30200
30523
|
|
|
30201
30524
|
// src/commands/images.ts
|
|
30202
30525
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
30203
|
-
import { existsSync as existsSync19, mkdirSync as
|
|
30526
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync13, readdirSync as readdirSync6, statSync as statSync3, writeFileSync as writeFileSync19 } from "fs";
|
|
30204
30527
|
import { createRequire } from "module";
|
|
30205
30528
|
import { homedir as homedir3 } from "os";
|
|
30206
30529
|
import { extname, join as join23, relative as relative4, resolve as resolve7 } from "path";
|
|
@@ -30230,8 +30553,8 @@ function outputsFor(file2, width) {
|
|
|
30230
30553
|
function loadSharp() {
|
|
30231
30554
|
const dir = join23(homedir3(), ".deployai", "tools", "sharp");
|
|
30232
30555
|
if (!existsSync19(join23(dir, "node_modules", "sharp"))) {
|
|
30233
|
-
|
|
30234
|
-
if (!existsSync19(join23(dir, "package.json")))
|
|
30556
|
+
mkdirSync13(dir, { recursive: true });
|
|
30557
|
+
if (!existsSync19(join23(dir, "package.json"))) writeFileSync19(join23(dir, "package.json"), '{"private":true}');
|
|
30235
30558
|
out("Getting the image tool once (it stays outside the site)...");
|
|
30236
30559
|
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
30560
|
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 +30595,8 @@ async function imagesCommand(root, folder, sharp = loadSharp) {
|
|
|
30272
30595
|
}
|
|
30273
30596
|
|
|
30274
30597
|
// src/commands/blocks.ts
|
|
30275
|
-
import { createHash as
|
|
30276
|
-
import { existsSync as existsSync20, mkdirSync as
|
|
30598
|
+
import { createHash as createHash5 } from "crypto";
|
|
30599
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync14, readFileSync as readFileSync16, writeFileSync as writeFileSync20 } from "fs";
|
|
30277
30600
|
import { dirname as dirname7, resolve as resolve8, sep as sep3 } from "path";
|
|
30278
30601
|
import { gunzipSync as gunzipSync3 } from "zlib";
|
|
30279
30602
|
var BLOCKS = [
|
|
@@ -30283,7 +30606,7 @@ var BLOCKS = [
|
|
|
30283
30606
|
{ 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
30607
|
];
|
|
30285
30608
|
var MAX_BYTES3 = 5 * 1024 * 1024;
|
|
30286
|
-
var sha = (data) =>
|
|
30609
|
+
var sha = (data) => createHash5("sha256").update(data).digest("hex");
|
|
30287
30610
|
var lockPath = (base, key2) => resolve8(base, ".deployai", "blocks", `${key2}.lock.json`);
|
|
30288
30611
|
function readLock(base, key2) {
|
|
30289
30612
|
try {
|
|
@@ -30332,26 +30655,26 @@ async function blocksCommand(root, ctx, name, opts = {}) {
|
|
|
30332
30655
|
if (now === sha(e3.data)) {
|
|
30333
30656
|
lock[e3.name] = now;
|
|
30334
30657
|
} else if (opts.update && lock[e3.name] === now) {
|
|
30335
|
-
|
|
30658
|
+
writeFileSync20(target, e3.data);
|
|
30336
30659
|
lock[e3.name] = sha(e3.data);
|
|
30337
30660
|
updated.push(e3.name);
|
|
30338
30661
|
} else {
|
|
30339
30662
|
const upstream = resolve8(base, ".deployai", "blocks", `${block.key}-upstream`, e3.name);
|
|
30340
30663
|
if (upstream.startsWith(base + sep3)) {
|
|
30341
|
-
|
|
30342
|
-
|
|
30664
|
+
mkdirSync14(dirname7(upstream), { recursive: true });
|
|
30665
|
+
writeFileSync20(upstream, e3.data);
|
|
30343
30666
|
}
|
|
30344
30667
|
kept.push(e3.name);
|
|
30345
30668
|
}
|
|
30346
30669
|
continue;
|
|
30347
30670
|
}
|
|
30348
|
-
|
|
30349
|
-
|
|
30671
|
+
mkdirSync14(dirname7(target), { recursive: true });
|
|
30672
|
+
writeFileSync20(target, e3.data);
|
|
30350
30673
|
lock[e3.name] = sha(e3.data);
|
|
30351
30674
|
written.push(e3.name);
|
|
30352
30675
|
}
|
|
30353
|
-
|
|
30354
|
-
|
|
30676
|
+
mkdirSync14(dirname7(lockPath(base, block.key)), { recursive: true });
|
|
30677
|
+
writeFileSync20(lockPath(base, block.key), `${JSON.stringify(lock, null, 2)}
|
|
30355
30678
|
`);
|
|
30356
30679
|
out(`Added the ${block.key} block: ${written.length} files.`);
|
|
30357
30680
|
written.forEach((f) => out(` + ${f}`));
|
|
@@ -30413,7 +30736,7 @@ async function integrationsCommand(ctx, name, opts = {}) {
|
|
|
30413
30736
|
|
|
30414
30737
|
// src/commands/brand.ts
|
|
30415
30738
|
import { spawn as spawn5 } from "child_process";
|
|
30416
|
-
import { copyFileSync, existsSync as existsSync21, mkdirSync as
|
|
30739
|
+
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
30740
|
import { createServer } from "http";
|
|
30418
30741
|
import { tmpdir as tmpdir4 } from "os";
|
|
30419
30742
|
import { basename as basename2, dirname as dirname8, extname as extname2, join as join24, relative as relative5, sep as sep4 } from "path";
|
|
@@ -30631,11 +30954,11 @@ function writeSiteFile(root, file2, data) {
|
|
|
30631
30954
|
const target = join24(webRoot(root), file2);
|
|
30632
30955
|
if (existsSync21(target)) {
|
|
30633
30956
|
const keep = join24(root, BRAND_DIR, "originals");
|
|
30634
|
-
|
|
30957
|
+
mkdirSync15(keep, { recursive: true });
|
|
30635
30958
|
copyFileSync(target, join24(keep, file2));
|
|
30636
30959
|
}
|
|
30637
|
-
|
|
30638
|
-
|
|
30960
|
+
mkdirSync15(dirname8(target), { recursive: true });
|
|
30961
|
+
writeFileSync21(target, data);
|
|
30639
30962
|
}
|
|
30640
30963
|
var send = (res, status, body = "", type = "text/plain; charset=utf-8") => {
|
|
30641
30964
|
res.writeHead(status, { "content-type": type, "cache-control": "no-store", "x-content-type-options": "nosniff" });
|
|
@@ -30994,10 +31317,10 @@ async function brandImagesCommand(root, urls, opts) {
|
|
|
30994
31317
|
if (verdict !== "ok") onPages.push({ where: m.src, width: m.width, height: m.height, shownWidth: m.shownWidth, verdict, alt: m.alt });
|
|
30995
31318
|
}
|
|
30996
31319
|
const weak = [...onPages, ...findings];
|
|
30997
|
-
|
|
31320
|
+
mkdirSync15(join24(root, BRAND_DIR), { recursive: true });
|
|
30998
31321
|
const file2 = `${BRAND_DIR}/images.json`;
|
|
30999
31322
|
const data = { measuredAt: (/* @__PURE__ */ new Date()).toISOString(), pages: urls, unmeasured, filesChecked: total, imagesMeasured: shown.size, weak };
|
|
31000
|
-
|
|
31323
|
+
writeFileSync21(join24(root, file2), `${JSON.stringify(data, null, 2)}
|
|
31001
31324
|
`);
|
|
31002
31325
|
if (opts.json) {
|
|
31003
31326
|
out(JSON.stringify(data));
|
|
@@ -31096,6 +31419,7 @@ ${AGENT_FEEDBACK_RULES.join("\n\n")}
|
|
|
31096
31419
|
if (!address) throw new CliError("Name the address, for example: npx deployai@latest requests open /api/webhooks/payments", 1, "usage");
|
|
31097
31420
|
return requestsOpenCommand(root(cmd), ctx(cmd), address, action === "open");
|
|
31098
31421
|
});
|
|
31422
|
+
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
31423
|
program.command("versions").description("list versions").action((_opts, cmd) => versionsCommand(root(cmd), ctx(cmd)));
|
|
31100
31424
|
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
31425
|
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 +31485,10 @@ function withoutDoubledName(argv) {
|
|
|
31161
31485
|
}
|
|
31162
31486
|
async function main(rawArgv = process.argv) {
|
|
31163
31487
|
const argv = withoutDoubledName(rawArgv);
|
|
31488
|
+
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
31489
|
const program = buildProgram();
|
|
31165
31490
|
const started = Date.now();
|
|
31491
|
+
takeBlockedLine();
|
|
31166
31492
|
let command = null;
|
|
31167
31493
|
let apiFlag;
|
|
31168
31494
|
program.hook("preAction", (_this, actionCmd) => {
|
|
@@ -31179,13 +31505,17 @@ async function main(rawArgv = process.argv) {
|
|
|
31179
31505
|
let errorLine;
|
|
31180
31506
|
try {
|
|
31181
31507
|
await program.parseAsync(argv);
|
|
31182
|
-
if (process.exitCode === 1 && exitBefore !== 1)
|
|
31508
|
+
if (process.exitCode === 1 && exitBefore !== 1) {
|
|
31509
|
+
result = "blocked";
|
|
31510
|
+
errorLine = takeBlockedLine();
|
|
31511
|
+
}
|
|
31183
31512
|
} catch (e3) {
|
|
31184
31513
|
if (e3 instanceof CliError) {
|
|
31185
31514
|
err(e3.message);
|
|
31186
31515
|
process.exitCode = e3.exitCode;
|
|
31187
31516
|
if (e3.category === "blocked") {
|
|
31188
31517
|
result = "blocked";
|
|
31518
|
+
errorLine = e3.reason;
|
|
31189
31519
|
} else {
|
|
31190
31520
|
result = "error";
|
|
31191
31521
|
errorCategory = e3.category;
|
|
@@ -31202,7 +31532,7 @@ async function main(rawArgv = process.argv) {
|
|
|
31202
31532
|
errorCategory = "usage";
|
|
31203
31533
|
errorLine = parserErrorLine(e3.code, e3.message);
|
|
31204
31534
|
if (asked.quoted) err(`Pass each word on its own, with no quotes around them: npx deployai@latest ${asked.quoted}`);
|
|
31205
|
-
if (
|
|
31535
|
+
if (e3.code === "commander.unknownCommand" && !asked.quoted) for (const line of unknownCommandHelp(argv.slice(2), program)) err(line);
|
|
31206
31536
|
}
|
|
31207
31537
|
} else {
|
|
31208
31538
|
err(`Unexpected error: ${e3?.message ?? String(e3)}`);
|
|
@@ -31239,7 +31569,7 @@ function nodeGuideUrl(lang, base = API_BASE_DEFAULT) {
|
|
|
31239
31569
|
|
|
31240
31570
|
// src/update.ts
|
|
31241
31571
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
31242
|
-
import { existsSync as existsSync23, mkdirSync as
|
|
31572
|
+
import { existsSync as existsSync23, mkdirSync as mkdirSync16, readdirSync as readdirSync8, readFileSync as readFileSync18, rmSync as rmSync7, writeFileSync as writeFileSync22 } from "fs";
|
|
31243
31573
|
import { join as join26 } from "path";
|
|
31244
31574
|
var CHECK_EVERY_MS = 60 * 60 * 1e3;
|
|
31245
31575
|
var ASK_NPM_MS = 1500;
|
|
@@ -31290,8 +31620,8 @@ function readState() {
|
|
|
31290
31620
|
}
|
|
31291
31621
|
function writeState(state) {
|
|
31292
31622
|
try {
|
|
31293
|
-
|
|
31294
|
-
|
|
31623
|
+
mkdirSync16(configDir(), { recursive: true });
|
|
31624
|
+
writeFileSync22(statePath(), JSON.stringify(state) + "\n");
|
|
31295
31625
|
} catch {
|
|
31296
31626
|
}
|
|
31297
31627
|
}
|
|
@@ -31314,8 +31644,8 @@ function getVersion(version2, env) {
|
|
|
31314
31644
|
`);
|
|
31315
31645
|
const root = join26(configDir(), "cli");
|
|
31316
31646
|
const dir = join26(root, version2);
|
|
31317
|
-
|
|
31318
|
-
|
|
31647
|
+
mkdirSync16(dir, { recursive: true });
|
|
31648
|
+
writeFileSync22(join26(dir, "package.json"), '{"private":true}\n');
|
|
31319
31649
|
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
31650
|
if (installed.status !== 0) return false;
|
|
31321
31651
|
const ran = spawnSync6(process.execPath, [versionEntry(version2), "--version"], { env: { ...env, DEPLOYAI_NO_UPDATE: "1" }, encoding: "utf8", timeout: GET_VERSION_MS });
|