flypod 0.16.1 → 0.18.0
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 +165 -41
- package/dist/bin/deploy.js +877 -383
- package/dist/{cli-8h0vc7g2.js → cli-4d5fkx95.js} +842 -83
- package/dist/src/api-error.d.ts +4 -0
- package/dist/src/cli/agent-env.d.ts +5 -0
- package/dist/src/cli/build-hint.d.ts +13 -0
- package/dist/src/cli/client.d.ts +15 -3
- package/dist/src/cli/commands.d.ts +4 -0
- package/dist/src/cli/errors.d.ts +105 -1
- package/dist/src/cli/install-id.d.ts +42 -0
- package/dist/src/cli/limits.d.ts +45 -1
- package/dist/src/cli/projects.d.ts +51 -3
- package/dist/src/cli/receipt.d.ts +18 -0
- package/dist/src/cli/skill.d.ts +26 -5
- package/dist/src/cli/source.d.ts +3 -1
- package/dist/src/cli/telemetry.d.ts +38 -0
- package/dist/src/cli-error-codes.d.ts +28 -0
- package/dist/src/cli.d.ts +16 -3
- package/dist/src/cli.js +1 -1
- package/dist/src/client-meta.d.ts +50 -0
- package/dist/src/deploy-source.d.ts +20 -0
- package/dist/src/ingest-error.d.ts +58 -1
- package/dist/src/upload-shape.d.ts +57 -0
- package/package.json +4 -1
package/dist/bin/deploy.js
CHANGED
|
@@ -2,299 +2,64 @@
|
|
|
2
2
|
import {
|
|
3
3
|
BUILD_DIR_CANDIDATES,
|
|
4
4
|
DeployError,
|
|
5
|
+
FIRST_RUN_NOTICE,
|
|
6
|
+
HOSTED_UPLOAD_LIMITS,
|
|
7
|
+
IGNORE_FILE,
|
|
8
|
+
NOT_SIGNED_IN,
|
|
9
|
+
NO_SITE,
|
|
10
|
+
PLAIN,
|
|
11
|
+
UNAUTHORIZED_FIX,
|
|
5
12
|
atomicWriteFile,
|
|
13
|
+
classifyResponse,
|
|
6
14
|
clearSession,
|
|
7
15
|
collectFiles,
|
|
8
16
|
createClient,
|
|
9
|
-
|
|
17
|
+
emitError,
|
|
18
|
+
errorEnvelope,
|
|
19
|
+
exitCodeFor,
|
|
20
|
+
fail,
|
|
21
|
+
failure,
|
|
22
|
+
field,
|
|
23
|
+
flushFailureReports,
|
|
24
|
+
headline,
|
|
25
|
+
hero,
|
|
26
|
+
installId,
|
|
10
27
|
installSkill,
|
|
28
|
+
loadSession,
|
|
29
|
+
networkError,
|
|
30
|
+
noBuildDir,
|
|
31
|
+
noSite,
|
|
32
|
+
notice,
|
|
11
33
|
packDeploy,
|
|
12
34
|
projectsFilePath,
|
|
35
|
+
readServerMessage,
|
|
36
|
+
reportFailure,
|
|
13
37
|
resolveCredentials,
|
|
14
38
|
resolveDeployDir,
|
|
15
|
-
saveSession
|
|
16
|
-
|
|
39
|
+
saveSession,
|
|
40
|
+
serverError,
|
|
41
|
+
setCliVersion,
|
|
42
|
+
shortVersion,
|
|
43
|
+
startFailureReports,
|
|
44
|
+
storedZipBytes,
|
|
45
|
+
unauthorizedFor,
|
|
46
|
+
unexpectedError,
|
|
47
|
+
uploadLimitsFor
|
|
48
|
+
} from "../cli-4d5fkx95.js";
|
|
17
49
|
|
|
18
50
|
// bin/deploy.ts
|
|
19
|
-
import { readFile as
|
|
51
|
+
import { readFile as readFile3, stat as stat4 } from "node:fs/promises";
|
|
20
52
|
import { homedir } from "node:os";
|
|
21
|
-
import { relative } from "node:path";
|
|
53
|
+
import { relative as relative3, resolve as resolve3 } from "node:path";
|
|
22
54
|
import { fileURLToPath } from "node:url";
|
|
23
55
|
|
|
24
|
-
// src/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
maxTotalBytes: 10 * 1024 * 1024,
|
|
28
|
-
maxZipBytes: 12 * 1024 * 1024
|
|
29
|
-
};
|
|
30
|
-
function uploadLimitsFor(baseUrl) {
|
|
31
|
-
try {
|
|
32
|
-
const host = new URL(baseUrl).hostname;
|
|
33
|
-
return host === "flypod.dev" || host.endsWith(".flypod.dev") ? HOSTED_UPLOAD_LIMITS : null;
|
|
34
|
-
} catch {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function storedZipBytes(files) {
|
|
39
|
-
const encoder = new TextEncoder;
|
|
40
|
-
let total = 22;
|
|
41
|
-
for (const [name, bytes] of Object.entries(files)) {
|
|
42
|
-
total += 76 + 2 * encoder.encode(name).byteLength + bytes.byteLength;
|
|
43
|
-
}
|
|
44
|
-
return total;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// src/cli/screen.ts
|
|
48
|
-
var WIDTH = 66;
|
|
49
|
-
var GUTTER = 10;
|
|
50
|
-
var id = (s) => s;
|
|
51
|
-
var PLAIN = {
|
|
52
|
-
dim: id,
|
|
53
|
-
bold: id,
|
|
54
|
-
muted: id,
|
|
55
|
-
accent: id,
|
|
56
|
-
ok: id,
|
|
57
|
-
err: id,
|
|
58
|
-
warn: id
|
|
59
|
-
};
|
|
60
|
-
function wrap(text, width) {
|
|
61
|
-
const lines = [];
|
|
62
|
-
for (const paragraph of text.split(`
|
|
63
|
-
`)) {
|
|
64
|
-
let line = "";
|
|
65
|
-
for (const word of paragraph.split(/\s+/).filter(Boolean)) {
|
|
66
|
-
if (line && line.length + 1 + word.length > width) {
|
|
67
|
-
lines.push(line);
|
|
68
|
-
line = word;
|
|
69
|
-
} else {
|
|
70
|
-
line = line ? `${line} ${word}` : word;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
lines.push(line);
|
|
74
|
-
}
|
|
75
|
-
return lines;
|
|
76
|
-
}
|
|
77
|
-
function headline(text, detail, s) {
|
|
78
|
-
return ` ${s.ok("✓")} ${text}${detail ? s.dim(` · ${detail}`) : ""}`;
|
|
79
|
-
}
|
|
80
|
-
function hero(url, s) {
|
|
81
|
-
return ` ${s.bold(s.accent(url))}`;
|
|
82
|
-
}
|
|
83
|
-
function field(label, value, hint, s) {
|
|
84
|
-
return ` ${s.muted(label.padEnd(GUTTER))}${value}${hint ? ` ${s.dim(hint)}` : ""}`;
|
|
85
|
-
}
|
|
86
|
-
function notice(title, body, s) {
|
|
87
|
-
return [
|
|
88
|
-
` ${(s.warn ?? id)("!")} ${s.bold(title)}`,
|
|
89
|
-
...wrap(body, WIDTH - 4).map((line) => ` ${s.dim(line)}`),
|
|
90
|
-
""
|
|
91
|
-
];
|
|
92
|
-
}
|
|
93
|
-
function failure(error, fix, s) {
|
|
94
|
-
const [first = "", ...rest] = wrap(error, WIDTH - 4);
|
|
95
|
-
return [
|
|
96
|
-
` ${(s.err ?? id)("✗")} ${first}`,
|
|
97
|
-
...rest.map((line) => ` ${line}`),
|
|
98
|
-
...fix ? wrap(fix, WIDTH - 4).map((line) => ` ${s.dim(line)}`) : []
|
|
99
|
-
];
|
|
100
|
-
}
|
|
101
|
-
function shortVersion(versionId) {
|
|
102
|
-
return versionId.slice(0, 8);
|
|
103
|
-
}
|
|
56
|
+
// src/cli/commands.ts
|
|
57
|
+
import { stat as stat3 } from "node:fs/promises";
|
|
58
|
+
import { relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
|
|
104
59
|
|
|
105
|
-
// src/cli/
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
"unknown_command",
|
|
109
|
-
"unknown_flag",
|
|
110
|
-
"interactive_login_required"
|
|
111
|
-
]);
|
|
112
|
-
var AUTH_CODES = new Set([
|
|
113
|
-
"not_signed_in",
|
|
114
|
-
"unauthorized",
|
|
115
|
-
"token_rejected",
|
|
116
|
-
"no_token",
|
|
117
|
-
"login_denied"
|
|
118
|
-
]);
|
|
119
|
-
var RETRY_CODES = new Set([
|
|
120
|
-
"rate_limited",
|
|
121
|
-
"server_error",
|
|
122
|
-
"network",
|
|
123
|
-
"authorization_pending",
|
|
124
|
-
"login_timeout"
|
|
125
|
-
]);
|
|
126
|
-
function exitCodeFor(code) {
|
|
127
|
-
if (USAGE_CODES.has(code))
|
|
128
|
-
return 2;
|
|
129
|
-
if (AUTH_CODES.has(code))
|
|
130
|
-
return 3;
|
|
131
|
-
if (RETRY_CODES.has(code))
|
|
132
|
-
return 4;
|
|
133
|
-
return 1;
|
|
134
|
-
}
|
|
135
|
-
function errorEnvelope(err) {
|
|
136
|
-
return {
|
|
137
|
-
ok: false,
|
|
138
|
-
code: err.code,
|
|
139
|
-
error: err.error,
|
|
140
|
-
...err.fix ? { fix: err.fix } : {},
|
|
141
|
-
...err.status !== undefined ? { status: err.status } : {},
|
|
142
|
-
...err.extra ?? {}
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
function emitError(err, args, io, _opts = {}) {
|
|
146
|
-
if (args.json) {
|
|
147
|
-
io.out(JSON.stringify(errorEnvelope(err)));
|
|
148
|
-
} else {
|
|
149
|
-
for (const line of failure(err.error, err.fix, io.style ?? PLAIN))
|
|
150
|
-
io.err(line);
|
|
151
|
-
}
|
|
152
|
-
return exitCodeFor(err.code);
|
|
153
|
-
}
|
|
154
|
-
function fail(code, error, args, io, opts = {}) {
|
|
155
|
-
return emitError({ code, error, fix: opts.fix, status: opts.status, extra: opts.extra }, args, io, { prefix: opts.prefix });
|
|
156
|
-
}
|
|
157
|
-
async function readServerMessage(res) {
|
|
158
|
-
const text = await res.text().catch(() => "");
|
|
159
|
-
if (!text)
|
|
160
|
-
return { message: `HTTP ${res.status}` };
|
|
161
|
-
try {
|
|
162
|
-
const body = JSON.parse(text);
|
|
163
|
-
const message = typeof body.error === "string" ? body.error : typeof body.message === "string" ? body.message : text;
|
|
164
|
-
return { message, code: typeof body.code === "string" ? body.code : undefined, json: true };
|
|
165
|
-
} catch {
|
|
166
|
-
return { message: text.length > 200 ? `${text.slice(0, 200)}…` : text };
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
async function classifyResponse(res, ctx) {
|
|
170
|
-
const { message, code: serverCode, json } = await readServerMessage(res);
|
|
171
|
-
const status = res.status;
|
|
172
|
-
const site = ctx.siteId ? ` ${ctx.siteId}` : "";
|
|
173
|
-
const base = { status, error: message };
|
|
174
|
-
if (serverCode === "token_rejected") {
|
|
175
|
-
return {
|
|
176
|
-
...base,
|
|
177
|
-
code: "token_rejected",
|
|
178
|
-
error: "The credential you sent was not accepted, so nothing was deployed.",
|
|
179
|
-
fix: "Run `flypod login` again, or set a valid FLYPOD_TOKEN (unset it to deploy anonymously)."
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
if (serverCode === "challenge_required" || /challenge required/i.test(message)) {
|
|
183
|
-
return {
|
|
184
|
-
...base,
|
|
185
|
-
code: "challenge_required",
|
|
186
|
-
error: "The server wants a human challenge for this deploy.",
|
|
187
|
-
fix: "Run `flypod login` and deploy again: signed-in deploys skip the challenge."
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
switch (status) {
|
|
191
|
-
case 401:
|
|
192
|
-
case 403:
|
|
193
|
-
if (!json && message !== `HTTP ${status}`) {
|
|
194
|
-
return {
|
|
195
|
-
...base,
|
|
196
|
-
code: "network",
|
|
197
|
-
error: `Something between this machine and the server refused the request (HTTP ${status}): ${message}`,
|
|
198
|
-
fix: "Check the proxy or firewall settings (and DEPLOY_URL, if set), then retry."
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
if (serverCode === "blocked") {
|
|
202
|
-
return {
|
|
203
|
-
...base,
|
|
204
|
-
code: "blocked",
|
|
205
|
-
error: `Deploy refused: ${message}`,
|
|
206
|
-
fix: "The content tripped the abuse guard. Remove the flagged files and try again."
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
return {
|
|
210
|
-
...base,
|
|
211
|
-
code: "unauthorized",
|
|
212
|
-
error: `Not authorized for site${site}.`,
|
|
213
|
-
fix: "Run `flypod login`, or pass --token <manage_token> for a site this machine does not remember."
|
|
214
|
-
};
|
|
215
|
-
case 404:
|
|
216
|
-
return ctx.siteScoped ? {
|
|
217
|
-
...base,
|
|
218
|
-
code: "site_gone",
|
|
219
|
-
error: `Site${site} is gone (expired or deleted).`,
|
|
220
|
-
fix: "Run `flypod` to create a new site."
|
|
221
|
-
} : { ...base, code: "not_found", error: message };
|
|
222
|
-
case 409:
|
|
223
|
-
return {
|
|
224
|
-
...base,
|
|
225
|
-
code: "already_claimed",
|
|
226
|
-
error: `Site${site} already belongs to another account.`
|
|
227
|
-
};
|
|
228
|
-
case 400:
|
|
229
|
-
return { ...base, code: "invalid_upload", error: `Rejected: ${message}` };
|
|
230
|
-
case 413:
|
|
231
|
-
return {
|
|
232
|
-
...base,
|
|
233
|
-
code: "too_large",
|
|
234
|
-
error: /^upload too large\.?$/i.test(message) ? "The upload is larger than the server accepts." : `The server refused the upload: ${message}.`,
|
|
235
|
-
fix: "Shrink the build (fewer files, smaller assets) or split it. See flypod.dev/limits."
|
|
236
|
-
};
|
|
237
|
-
case 429:
|
|
238
|
-
return {
|
|
239
|
-
...base,
|
|
240
|
-
code: "rate_limited",
|
|
241
|
-
error: "Too many requests from this network right now.",
|
|
242
|
-
fix: "Wait a minute and retry the same command.",
|
|
243
|
-
extra: retryAfter(res)
|
|
244
|
-
};
|
|
245
|
-
default:
|
|
246
|
-
if (status >= 500) {
|
|
247
|
-
return {
|
|
248
|
-
...base,
|
|
249
|
-
code: "server_error",
|
|
250
|
-
error: `${ctx.verb}: the server returned ${status}.`,
|
|
251
|
-
fix: "Retry in a moment; if it keeps failing, check https://flypod.dev/status."
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
return { ...base, code: "bad_request", error: `${ctx.verb}: ${message}` };
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
function retryAfter(res) {
|
|
258
|
-
const raw = res.headers.get("retry-after");
|
|
259
|
-
const seconds = raw ? Number(raw) : Number.NaN;
|
|
260
|
-
return Number.isFinite(seconds) ? { retry_after_s: seconds } : {};
|
|
261
|
-
}
|
|
262
|
-
function noBuildDir(message) {
|
|
263
|
-
const cut = message.indexOf(". ");
|
|
264
|
-
if (cut === -1)
|
|
265
|
-
return { code: "no_build_dir", error: message };
|
|
266
|
-
return { code: "no_build_dir", error: message.slice(0, cut + 1), fix: message.slice(cut + 2) };
|
|
267
|
-
}
|
|
268
|
-
function networkError(e, baseUrl) {
|
|
269
|
-
const reason = e instanceof Error ? e.message : String(e);
|
|
270
|
-
const host = baseUrl ? ` ${safeHost(baseUrl)}` : "";
|
|
271
|
-
return {
|
|
272
|
-
code: "network",
|
|
273
|
-
error: `Could not reach the flypod server${host}: ${reason}`,
|
|
274
|
-
fix: "Check your connection (and DEPLOY_URL, if set), then retry."
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
function safeHost(url) {
|
|
278
|
-
try {
|
|
279
|
-
return new URL(url).host;
|
|
280
|
-
} catch {
|
|
281
|
-
return url;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
var NO_SITE = {
|
|
285
|
-
code: "no_site",
|
|
286
|
-
error: "No flypod site is linked to this folder.",
|
|
287
|
-
fix: "Run `flypod` here to create one, or pass --site <id>."
|
|
288
|
-
};
|
|
289
|
-
var NOT_SIGNED_IN = {
|
|
290
|
-
code: "not_signed_in",
|
|
291
|
-
error: "Not signed in.",
|
|
292
|
-
fix: "Run `flypod login`, or set FLYPOD_TOKEN."
|
|
293
|
-
};
|
|
294
|
-
function unexpectedError(e) {
|
|
295
|
-
const reason = e instanceof Error ? e.message : String(e);
|
|
296
|
-
return { code: "unexpected", error: `unexpected error: ${reason}` };
|
|
297
|
-
}
|
|
60
|
+
// src/cli/limits.ts
|
|
61
|
+
import { readdir as readdir2, stat as stat2 } from "node:fs/promises";
|
|
62
|
+
import { basename, dirname, join as join2, relative, resolve } from "node:path";
|
|
298
63
|
|
|
299
64
|
// src/ui.ts
|
|
300
65
|
var ESC = "\x1B[";
|
|
@@ -315,8 +80,8 @@ function paint(open, s) {
|
|
|
315
80
|
}
|
|
316
81
|
function makeStyle(enabled) {
|
|
317
82
|
if (!enabled) {
|
|
318
|
-
const
|
|
319
|
-
return { dim:
|
|
83
|
+
const id = (s) => s;
|
|
84
|
+
return { dim: id, bold: id, accent: id, ok: id, err: id, warn: id, muted: id };
|
|
320
85
|
}
|
|
321
86
|
return {
|
|
322
87
|
dim: (s) => paint("2", s),
|
|
@@ -402,18 +167,359 @@ function fmtCount(n, singular) {
|
|
|
402
167
|
return `${n} ${singular}${n === 1 ? "" : "s"}`;
|
|
403
168
|
}
|
|
404
169
|
|
|
170
|
+
// src/upload-shape.ts
|
|
171
|
+
var BYTE_KINDS = [
|
|
172
|
+
"html",
|
|
173
|
+
"script",
|
|
174
|
+
"style",
|
|
175
|
+
"image",
|
|
176
|
+
"media",
|
|
177
|
+
"font",
|
|
178
|
+
"source_map",
|
|
179
|
+
"data",
|
|
180
|
+
"archive",
|
|
181
|
+
"other"
|
|
182
|
+
];
|
|
183
|
+
var EXT_KIND = {
|
|
184
|
+
html: "html",
|
|
185
|
+
htm: "html",
|
|
186
|
+
md: "html",
|
|
187
|
+
markdown: "html",
|
|
188
|
+
js: "script",
|
|
189
|
+
mjs: "script",
|
|
190
|
+
cjs: "script",
|
|
191
|
+
ts: "script",
|
|
192
|
+
tsx: "script",
|
|
193
|
+
jsx: "script",
|
|
194
|
+
wasm: "script",
|
|
195
|
+
css: "style",
|
|
196
|
+
scss: "style",
|
|
197
|
+
less: "style",
|
|
198
|
+
png: "image",
|
|
199
|
+
jpg: "image",
|
|
200
|
+
jpeg: "image",
|
|
201
|
+
gif: "image",
|
|
202
|
+
webp: "image",
|
|
203
|
+
avif: "image",
|
|
204
|
+
svg: "image",
|
|
205
|
+
ico: "image",
|
|
206
|
+
bmp: "image",
|
|
207
|
+
tif: "image",
|
|
208
|
+
tiff: "image",
|
|
209
|
+
heic: "image",
|
|
210
|
+
psd: "image",
|
|
211
|
+
mp4: "media",
|
|
212
|
+
webm: "media",
|
|
213
|
+
mov: "media",
|
|
214
|
+
m4v: "media",
|
|
215
|
+
avi: "media",
|
|
216
|
+
mkv: "media",
|
|
217
|
+
mp3: "media",
|
|
218
|
+
wav: "media",
|
|
219
|
+
ogg: "media",
|
|
220
|
+
m4a: "media",
|
|
221
|
+
flac: "media",
|
|
222
|
+
aac: "media",
|
|
223
|
+
woff: "font",
|
|
224
|
+
woff2: "font",
|
|
225
|
+
ttf: "font",
|
|
226
|
+
otf: "font",
|
|
227
|
+
eot: "font",
|
|
228
|
+
map: "source_map",
|
|
229
|
+
json: "data",
|
|
230
|
+
csv: "data",
|
|
231
|
+
xml: "data",
|
|
232
|
+
txt: "data",
|
|
233
|
+
pdf: "data",
|
|
234
|
+
yaml: "data",
|
|
235
|
+
yml: "data",
|
|
236
|
+
glb: "data",
|
|
237
|
+
gltf: "data",
|
|
238
|
+
zip: "archive",
|
|
239
|
+
gz: "archive",
|
|
240
|
+
tgz: "archive",
|
|
241
|
+
tar: "archive",
|
|
242
|
+
rar: "archive",
|
|
243
|
+
"7z": "archive"
|
|
244
|
+
};
|
|
245
|
+
function kindOf(path) {
|
|
246
|
+
const base = path.split("/").pop() ?? path;
|
|
247
|
+
const dot = base.lastIndexOf(".");
|
|
248
|
+
if (dot <= 0)
|
|
249
|
+
return "other";
|
|
250
|
+
return EXT_KIND[base.slice(dot + 1).toLowerCase()] ?? "other";
|
|
251
|
+
}
|
|
252
|
+
var kb = (bytes) => Math.round(bytes / 1024);
|
|
253
|
+
function uploadShape(files) {
|
|
254
|
+
const bytesByKind = new Map;
|
|
255
|
+
let total = 0;
|
|
256
|
+
let largest = { kind: null, bytes: -1 };
|
|
257
|
+
for (const [name, data] of Object.entries(files)) {
|
|
258
|
+
const kind = kindOf(name);
|
|
259
|
+
const n = data?.byteLength ?? 0;
|
|
260
|
+
total += n;
|
|
261
|
+
bytesByKind.set(kind, (bytesByKind.get(kind) ?? 0) + n);
|
|
262
|
+
if (n > largest.bytes)
|
|
263
|
+
largest = { kind, bytes: n };
|
|
264
|
+
}
|
|
265
|
+
const kb_by_kind = {};
|
|
266
|
+
let topKind = null;
|
|
267
|
+
let topBytes = -1;
|
|
268
|
+
for (const [kind, bytes] of bytesByKind) {
|
|
269
|
+
kb_by_kind[kind] = kb(bytes);
|
|
270
|
+
if (bytes > topBytes) {
|
|
271
|
+
topKind = kind;
|
|
272
|
+
topBytes = bytes;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
file_count: Object.keys(files).length,
|
|
277
|
+
total_kb: kb(total),
|
|
278
|
+
kb_by_kind,
|
|
279
|
+
largest_kind: topKind,
|
|
280
|
+
largest_file_kind: largest.kind,
|
|
281
|
+
largest_file_kb: Math.max(0, kb(largest.bytes))
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
var BUILD_DIRS = [
|
|
285
|
+
"dist",
|
|
286
|
+
"build",
|
|
287
|
+
"out",
|
|
288
|
+
"public",
|
|
289
|
+
"_site",
|
|
290
|
+
".output",
|
|
291
|
+
".next",
|
|
292
|
+
"www"
|
|
293
|
+
];
|
|
294
|
+
function folderMarkers(paths) {
|
|
295
|
+
const top = new Set;
|
|
296
|
+
const topDirs = new Set;
|
|
297
|
+
for (const p of paths) {
|
|
298
|
+
const slash = p.indexOf("/");
|
|
299
|
+
if (slash === -1)
|
|
300
|
+
top.add(p);
|
|
301
|
+
else
|
|
302
|
+
topDirs.add(p.slice(0, slash));
|
|
303
|
+
}
|
|
304
|
+
const has_package_json = top.has("package.json");
|
|
305
|
+
const has_index_html = top.has("index.html") || top.has("index.htm");
|
|
306
|
+
const has_src_dir = topDirs.has("src");
|
|
307
|
+
const build_dirs = BUILD_DIRS.filter((d) => topDirs.has(d));
|
|
308
|
+
return {
|
|
309
|
+
has_package_json,
|
|
310
|
+
has_index_html,
|
|
311
|
+
has_src_dir,
|
|
312
|
+
build_dirs,
|
|
313
|
+
looks_like_project_root: has_package_json && !has_index_html
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
function shapeProps(shape, markers) {
|
|
317
|
+
const out = {
|
|
318
|
+
file_count: shape.file_count,
|
|
319
|
+
total_kb: shape.total_kb,
|
|
320
|
+
largest_kind: shape.largest_kind,
|
|
321
|
+
largest_file_kind: shape.largest_file_kind,
|
|
322
|
+
largest_file_kb: shape.largest_file_kb
|
|
323
|
+
};
|
|
324
|
+
for (const kind of BYTE_KINDS) {
|
|
325
|
+
const v = shape.kb_by_kind[kind];
|
|
326
|
+
if (v !== undefined)
|
|
327
|
+
out[`kb_${kind}`] = v;
|
|
328
|
+
}
|
|
329
|
+
if (markers) {
|
|
330
|
+
out.looks_like_project_root = markers.looks_like_project_root;
|
|
331
|
+
out.has_package_json = markers.has_package_json;
|
|
332
|
+
out.has_src_dir = markers.has_src_dir;
|
|
333
|
+
if (markers.build_dirs.length)
|
|
334
|
+
out.build_dirs = markers.build_dirs.join(",");
|
|
335
|
+
}
|
|
336
|
+
return out;
|
|
337
|
+
}
|
|
338
|
+
var fmtKb = (n) => n >= 1024 ? `${(n / 1024).toFixed(1)} MB` : `${n} KB`;
|
|
339
|
+
function sizeAdvice(shape, markers) {
|
|
340
|
+
switch (sizeCause(shape, markers)) {
|
|
341
|
+
case "project_root": {
|
|
342
|
+
const dir = markers?.build_dirs.find((d) => d !== "public") ?? markers?.build_dirs[0];
|
|
343
|
+
return dir ? `This looks like the project folder, not its build output. Deploy the built files instead: \`flypod ./${dir}\`.` : "This looks like the project folder (it has a package.json and no index.html). Build the site, then deploy the output folder, e.g. `flypod ./dist`.";
|
|
344
|
+
}
|
|
345
|
+
case "source_map":
|
|
346
|
+
return `${fmtKb(shape.kb_by_kind.source_map ?? 0)} of this is source maps, which a browser never needs to show the site. Add \`*.map\` to a .flypodignore and deploy again.`;
|
|
347
|
+
case "media":
|
|
348
|
+
return `${fmtKb(shape.kb_by_kind.media ?? 0)} of this is video or audio. Host large media elsewhere (a video platform or object storage) and link to it.`;
|
|
349
|
+
case "archive":
|
|
350
|
+
return `${fmtKb(shape.kb_by_kind.archive ?? 0)} of this is archives (.zip, .tar, …). Leave them out with a .flypodignore unless the site is meant to offer them as downloads.`;
|
|
351
|
+
case "image":
|
|
352
|
+
return `${fmtKb(shape.kb_by_kind.image ?? 0)} of this is images. Compress them (WebP or AVIF usually cuts size by more than half) or leave unused ones out with a .flypodignore.`;
|
|
353
|
+
default:
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function sizeCause(shape, markers) {
|
|
358
|
+
if (markers?.looks_like_project_root)
|
|
359
|
+
return "project_root";
|
|
360
|
+
const share = (k) => shape.total_kb > 0 ? (shape.kb_by_kind[k] ?? 0) / shape.total_kb : 0;
|
|
361
|
+
if (share("source_map") >= 0.2)
|
|
362
|
+
return "source_map";
|
|
363
|
+
if (share("media") >= 0.3)
|
|
364
|
+
return "media";
|
|
365
|
+
if (share("archive") >= 0.3)
|
|
366
|
+
return "archive";
|
|
367
|
+
if (share("image") >= 0.5)
|
|
368
|
+
return "image";
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// src/cli/build-hint.ts
|
|
373
|
+
import { readdir, readFile, stat } from "node:fs/promises";
|
|
374
|
+
import { join } from "node:path";
|
|
375
|
+
var FRAMEWORKS = [
|
|
376
|
+
["next", { label: "Next.js", out: "out" }],
|
|
377
|
+
["nuxt", { label: "Nuxt", out: ".output/public" }],
|
|
378
|
+
["astro", { label: "Astro", out: "dist" }],
|
|
379
|
+
["@sveltejs/kit", { label: "SvelteKit", out: "build" }],
|
|
380
|
+
["gatsby", { label: "Gatsby", out: "public" }],
|
|
381
|
+
["@docusaurus/core", { label: "Docusaurus", out: "build" }],
|
|
382
|
+
["@11ty/eleventy", { label: "Eleventy", out: "_site" }],
|
|
383
|
+
["vitepress", { label: "VitePress", out: ".vitepress/dist" }],
|
|
384
|
+
["@angular/core", { label: "Angular", out: "dist" }],
|
|
385
|
+
["react-scripts", { label: "Create React App", out: "build" }],
|
|
386
|
+
["@vue/cli-service", { label: "Vue CLI", out: "dist" }],
|
|
387
|
+
["vite", { label: "Vite", out: "dist" }],
|
|
388
|
+
["parcel", { label: "Parcel", out: "dist" }]
|
|
389
|
+
];
|
|
390
|
+
var GENERATORS = [
|
|
391
|
+
["_config.yml", "bundle exec jekyll build", "_site"],
|
|
392
|
+
["mkdocs.yml", "mkdocs build", "site"],
|
|
393
|
+
["hugo.toml", "hugo", "public"]
|
|
394
|
+
];
|
|
395
|
+
async function isFile(path) {
|
|
396
|
+
try {
|
|
397
|
+
return (await stat(path)).isFile();
|
|
398
|
+
} catch {
|
|
399
|
+
return false;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
function runBuild(top) {
|
|
403
|
+
if (top.has("bun.lock") || top.has("bun.lockb"))
|
|
404
|
+
return "bun run build";
|
|
405
|
+
if (top.has("pnpm-lock.yaml"))
|
|
406
|
+
return "pnpm build";
|
|
407
|
+
if (top.has("yarn.lock"))
|
|
408
|
+
return "yarn build";
|
|
409
|
+
return "npm run build";
|
|
410
|
+
}
|
|
411
|
+
async function buildHint(cwd, opts) {
|
|
412
|
+
let entries;
|
|
413
|
+
try {
|
|
414
|
+
entries = (await readdir(cwd, { withFileTypes: true })).map((e) => ({
|
|
415
|
+
name: e.name,
|
|
416
|
+
dir: e.isDirectory()
|
|
417
|
+
}));
|
|
418
|
+
} catch {
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
const top = new Set(entries.map((e) => e.name));
|
|
422
|
+
const sites = [];
|
|
423
|
+
for (const e of entries) {
|
|
424
|
+
if (!e.dir || e.name === "node_modules" || e.name.startsWith("."))
|
|
425
|
+
continue;
|
|
426
|
+
if (e.name === opts.exclude)
|
|
427
|
+
continue;
|
|
428
|
+
if (await isFile(join(cwd, e.name, "index.html")))
|
|
429
|
+
sites.push(e.name);
|
|
430
|
+
}
|
|
431
|
+
const deploy = (dir) => `\`${opts.verb} ${/^(\/|\.\.?\/)/.test(dir) ? dir : `./${dir}`}\``;
|
|
432
|
+
const remembered = opts.remembered && opts.remembered !== opts.exclude ? opts.remembered : null;
|
|
433
|
+
let pkg = null;
|
|
434
|
+
if (top.has("package.json")) {
|
|
435
|
+
try {
|
|
436
|
+
pkg = JSON.parse(await readFile(join(cwd, "package.json"), "utf8"));
|
|
437
|
+
} catch {
|
|
438
|
+
pkg = {};
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (pkg) {
|
|
442
|
+
const deps = { ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} };
|
|
443
|
+
const fw = FRAMEWORKS.find(([dep]) => (dep in deps))?.[1];
|
|
444
|
+
const hasBuild = typeof pkg.scripts?.build === "string";
|
|
445
|
+
const run = runBuild(top);
|
|
446
|
+
const present = ["dist", "build", "out", "_site"].find((d) => top.has(d) && d !== opts.exclude);
|
|
447
|
+
const out = remembered ?? fw?.out ?? present ?? "dist";
|
|
448
|
+
if (fw?.label === "Next.js" && !top.has("out") && !await nextExports(cwd, top)) {
|
|
449
|
+
return `This is a Next.js project, and it builds a server app, not static files. Set \`output: "export"\` in next.config, run \`${run}\`, then ${deploy("out")}.`;
|
|
450
|
+
}
|
|
451
|
+
if (hasBuild) {
|
|
452
|
+
const what = fw ? `${fw.label} project` : "project";
|
|
453
|
+
const where = fw || remembered || present ? deploy(out) : `${deploy("dist")} (or the folder the build writes)`;
|
|
454
|
+
return `This ${what} has no build output yet. Run \`${run}\`, then ${where}.`;
|
|
455
|
+
}
|
|
456
|
+
if (sites.length > 0)
|
|
457
|
+
return namedSites(sites, deploy);
|
|
458
|
+
if (present && !top.has("index.html")) {
|
|
459
|
+
return `This looks like the project folder, and ${present}/ has no index.html yet. Build the site (e.g. \`${run}\`), then ${deploy(present)}.`;
|
|
460
|
+
}
|
|
461
|
+
if (top.has("index.html")) {
|
|
462
|
+
return `This folder has a package.json but no build script. If its index.html is the site, deploy it as it is (node_modules and .git are left out): \`${opts.verb} .\`.`;
|
|
463
|
+
}
|
|
464
|
+
return null;
|
|
465
|
+
}
|
|
466
|
+
if (sites.length > 0)
|
|
467
|
+
return namedSites(sites, deploy);
|
|
468
|
+
for (const [marker, build, out] of GENERATORS) {
|
|
469
|
+
if (top.has(marker)) {
|
|
470
|
+
return `This is a static-site generator's source folder. Run \`${build}\`, then ${deploy(out)}.`;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
const pages = entries.filter((e) => !e.dir && /\.html?$/i.test(e.name)).map((e) => e.name);
|
|
474
|
+
if (pages.length > 0) {
|
|
475
|
+
return `There is no index.html here. Deploy one page with ${deploy(pages[0])}, or rename the main page to index.html.`;
|
|
476
|
+
}
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
async function nextExports(cwd, top) {
|
|
480
|
+
for (const name of ["next.config.js", "next.config.mjs", "next.config.ts", "next.config.cjs"]) {
|
|
481
|
+
if (!top.has(name))
|
|
482
|
+
continue;
|
|
483
|
+
const text = await readFile(join(cwd, name), "utf8").catch(() => "");
|
|
484
|
+
if (/output\s*:\s*["'`]export["'`]/.test(text))
|
|
485
|
+
return true;
|
|
486
|
+
}
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
function namedSites(sites, deploy) {
|
|
490
|
+
const listed = sites.slice(0, 3);
|
|
491
|
+
if (listed.length === 1) {
|
|
492
|
+
return `${listed[0]}/ has an index.html. Deploy it: ${deploy(listed[0])}.`;
|
|
493
|
+
}
|
|
494
|
+
return `These folders have an index.html: ${listed.map((d) => `${d}/`).join(", ")}. Deploy the site's one, e.g. ${deploy(listed[0])}.`;
|
|
495
|
+
}
|
|
496
|
+
|
|
405
497
|
// src/cli/limits.ts
|
|
406
|
-
function
|
|
498
|
+
function uploadReport(files, skippedCount) {
|
|
499
|
+
return {
|
|
500
|
+
...shapeProps(uploadShape(files), folderMarkers(Object.keys(files))),
|
|
501
|
+
upload_kb: Math.round(storedZipBytes(files) / 1024),
|
|
502
|
+
...skippedCount !== undefined ? { skipped_count: skippedCount } : {}
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
function checkUploadSize(files, limits, skippedCount, opts = {}) {
|
|
407
506
|
if (!limits)
|
|
408
507
|
return null;
|
|
409
508
|
const names = Object.keys(files);
|
|
410
|
-
const
|
|
509
|
+
const shape = () => uploadShape(files);
|
|
510
|
+
const markers = () => folderMarkers(names);
|
|
511
|
+
const advice = () => sizeAdvice(shape(), markers());
|
|
512
|
+
const report = (limit2) => ({ limit: limit2, ...uploadReport(files, skippedCount) });
|
|
411
513
|
if (names.length > limits.maxFiles) {
|
|
514
|
+
const generic = "Deploy only the build output, or list what the site does not need in a .flypodignore.";
|
|
515
|
+
const crowded = opts.ignoreFile ? crowdedFolder(names, names.length - limits.maxFiles) : null;
|
|
516
|
+
const tip2 = crowded ? ` ${crowded.dir}/ holds ${crowded.count} of the ${names.length} files; if the site does not need them, add \`/${crowded.dir}/\` to ${opts.ignoreFile}.` : "";
|
|
412
517
|
return {
|
|
413
518
|
code: "too_large",
|
|
414
519
|
error: `This build has ${names.length} files; flypod accepts at most ${limits.maxFiles} per deploy.`,
|
|
415
|
-
fix:
|
|
416
|
-
extra: { files: names.length, limit_files: limits.maxFiles }
|
|
520
|
+
fix: `${advice() ?? generic}${sizeCause(shape(), markers()) === "project_root" ? "" : tip2}`,
|
|
521
|
+
extra: { limit: "files", files: names.length, limit_files: limits.maxFiles },
|
|
522
|
+
telemetry: report("files")
|
|
417
523
|
};
|
|
418
524
|
}
|
|
419
525
|
const total = names.reduce((sum, n) => sum + (files[n]?.byteLength ?? 0), 0);
|
|
@@ -426,21 +532,103 @@ function checkUploadSize(files, limits) {
|
|
|
426
532
|
const listed = largest.map((f) => `${f.path} (${fmtBytes(f.bytes)})`).join(", ");
|
|
427
533
|
const limit = overZip ? limits.maxZipBytes : limits.maxTotalBytes;
|
|
428
534
|
const what = overZip ? "upload" : "site";
|
|
535
|
+
const which = overZip ? "zip_bytes" : "total_bytes";
|
|
536
|
+
const cause = sizeCause(shape(), markers());
|
|
537
|
+
const lines = opts.ignoreFile && cause !== "project_root" && cause !== "source_map" ? ignoreLines(files, Math.max(total - limits.maxTotalBytes, zipped - limits.maxZipBytes), cause ?? undefined) : null;
|
|
538
|
+
const tip = lines ? ` Leaving out ${lines.length === 1 ? "this file" : `these ${lines.length} files`} brings it under the limit; add ${lines.length === 1 ? "it" : "them"} to ${opts.ignoreFile}: ${lines.map((l) => `\`${l}\``).join(", ")}.` : "";
|
|
429
539
|
return {
|
|
430
540
|
code: "too_large",
|
|
431
541
|
error: `This build is ${fmtBytes(overZip ? zipped : total)}; flypod accepts at most ${fmtBytes(limit)} per ${what}. Largest files: ${listed}.`,
|
|
432
|
-
fix,
|
|
542
|
+
fix: `${advice() ?? "Remove or shrink the largest files (or list them in a .flypodignore), then deploy again."}${tip}`,
|
|
433
543
|
extra: {
|
|
544
|
+
limit: which,
|
|
434
545
|
bytes: total,
|
|
435
546
|
upload_bytes: zipped,
|
|
436
547
|
limit_bytes: limit,
|
|
437
548
|
largest
|
|
438
|
-
}
|
|
549
|
+
},
|
|
550
|
+
telemetry: report(which)
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
async function ignoreFilePath(dir, cwd) {
|
|
554
|
+
try {
|
|
555
|
+
if (!(await stat2(dir)).isDirectory())
|
|
556
|
+
return;
|
|
557
|
+
} catch {
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
const rel = relative(cwd, resolve(dir));
|
|
561
|
+
if (rel === "")
|
|
562
|
+
return IGNORE_FILE;
|
|
563
|
+
return rel.startsWith("..") ? join2(resolve(dir), IGNORE_FILE) : join2(rel, IGNORE_FILE);
|
|
564
|
+
}
|
|
565
|
+
var MAX_IGNORE_LINES = 5;
|
|
566
|
+
var NOT_A_LITERAL = /[*?[\]\\]|^\s|\s$/;
|
|
567
|
+
function ignoreLines(files, overBy, kind) {
|
|
568
|
+
const pool = Object.keys(files).filter((n) => n !== "index.html" && !NOT_A_LITERAL.test(n)).filter((n) => !kind || kindOf(n) === kind).map((n) => ({ path: n, bytes: files[n]?.byteLength ?? 0 })).sort((a, b) => b.bytes - a.bytes);
|
|
569
|
+
const out = [];
|
|
570
|
+
let removed = 0;
|
|
571
|
+
for (const f of pool) {
|
|
572
|
+
if (removed >= overBy)
|
|
573
|
+
break;
|
|
574
|
+
if (out.length === MAX_IGNORE_LINES)
|
|
575
|
+
return null;
|
|
576
|
+
out.push(`/${f.path}`);
|
|
577
|
+
removed += f.bytes + 2 * f.path.length + 76;
|
|
578
|
+
}
|
|
579
|
+
return removed >= overBy && out.length > 0 ? out : null;
|
|
580
|
+
}
|
|
581
|
+
function crowdedFolder(names, over) {
|
|
582
|
+
const counts = new Map;
|
|
583
|
+
for (const n of names) {
|
|
584
|
+
const slash = n.indexOf("/");
|
|
585
|
+
if (slash > 0)
|
|
586
|
+
counts.set(n.slice(0, slash), (counts.get(n.slice(0, slash)) ?? 0) + 1);
|
|
587
|
+
}
|
|
588
|
+
let best = null;
|
|
589
|
+
for (const [dir, count] of counts)
|
|
590
|
+
if (!best || count > best.count)
|
|
591
|
+
best = { dir, count };
|
|
592
|
+
if (!best || best.count < over || NOT_A_LITERAL.test(best.dir))
|
|
593
|
+
return null;
|
|
594
|
+
return best;
|
|
595
|
+
}
|
|
596
|
+
async function markersOf(dir) {
|
|
597
|
+
try {
|
|
598
|
+
const entries = await readdir2(dir, { withFileTypes: true });
|
|
599
|
+
return folderMarkers(entries.map((e) => e.isDirectory() ? `${e.name}/` : e.name));
|
|
600
|
+
} catch {
|
|
601
|
+
return null;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
async function withFolderHint(err, cwd, deployed, opts = {}) {
|
|
605
|
+
const markers = await markersOf(cwd);
|
|
606
|
+
if (!markers)
|
|
607
|
+
return err;
|
|
608
|
+
const exclude = deployed && resolve(dirname(resolve(cwd, deployed))) === resolve(cwd) ? basename(resolve(cwd, deployed)) : undefined;
|
|
609
|
+
const telemetry = {
|
|
610
|
+
...err.telemetry,
|
|
611
|
+
looks_like_project_root: markers.looks_like_project_root,
|
|
612
|
+
has_package_json: markers.has_package_json,
|
|
613
|
+
has_src_dir: markers.has_src_dir,
|
|
614
|
+
...markers.build_dirs.length ? { build_dirs: markers.build_dirs.join(",") } : {}
|
|
439
615
|
};
|
|
616
|
+
const hint = await buildHint(cwd, {
|
|
617
|
+
verb: opts.verb ?? "flypod",
|
|
618
|
+
exclude,
|
|
619
|
+
remembered: opts.remembered
|
|
620
|
+
});
|
|
621
|
+
if (hint)
|
|
622
|
+
return { ...err, fix: hint, telemetry };
|
|
623
|
+
if (!markers.looks_like_project_root)
|
|
624
|
+
return { ...err, telemetry };
|
|
625
|
+
const fix = "This looks like the project folder, and it has no build output yet. Build the site (e.g. `npm run build`), then deploy the output folder.";
|
|
626
|
+
return { ...err, fix, telemetry };
|
|
440
627
|
}
|
|
441
628
|
|
|
442
629
|
// src/cli/projects.ts
|
|
443
|
-
import { readFile } from "node:fs/promises";
|
|
630
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
631
|
+
import { sep } from "node:path";
|
|
444
632
|
var MAX_PROJECTS = 64;
|
|
445
633
|
function prune(projects, now) {
|
|
446
634
|
const out = {};
|
|
@@ -465,24 +653,56 @@ function cap(projects) {
|
|
|
465
653
|
return Object.fromEntries(keep);
|
|
466
654
|
}
|
|
467
655
|
async function loadProjects(env) {
|
|
656
|
+
const raw = await loadFile(env);
|
|
657
|
+
return raw ? prune(raw.projects, Date.now()) : {};
|
|
658
|
+
}
|
|
659
|
+
async function loadFile(env) {
|
|
468
660
|
try {
|
|
469
|
-
const text = await
|
|
661
|
+
const text = await readFile2(projectsFilePath(env), "utf8");
|
|
470
662
|
const parsed = JSON.parse(text);
|
|
471
663
|
if (!parsed || typeof parsed !== "object" || typeof parsed.projects !== "object")
|
|
472
|
-
return
|
|
473
|
-
return
|
|
664
|
+
return null;
|
|
665
|
+
return parsed;
|
|
474
666
|
} catch {
|
|
475
|
-
return
|
|
667
|
+
return null;
|
|
476
668
|
}
|
|
477
669
|
}
|
|
478
|
-
async function saveProjects(projects, env) {
|
|
479
|
-
const
|
|
480
|
-
const
|
|
670
|
+
async function saveProjects(projects, env, goneNow = {}) {
|
|
671
|
+
const now = Date.now();
|
|
672
|
+
const cleaned = cap(prune(projects, now));
|
|
673
|
+
const raw = await loadFile(env);
|
|
674
|
+
const gone = { ...raw?.gone ?? {} };
|
|
675
|
+
for (const [dir, rec] of [...Object.entries(raw?.projects ?? {}), ...Object.entries(projects)]) {
|
|
676
|
+
if (dir.startsWith(DETACHED_PREFIX) || rec.expires_at === null || rec.expires_at > now)
|
|
677
|
+
continue;
|
|
678
|
+
gone[dir] = { site_id: rec.site_id, url: rec.url, reason: "expired", at: rec.expires_at };
|
|
679
|
+
}
|
|
680
|
+
for (const [dir, rec] of Object.entries(goneNow)) {
|
|
681
|
+
gone[dir] = { site_id: rec.site_id, url: rec.url, reason: "gone", at: now };
|
|
682
|
+
}
|
|
683
|
+
for (const dir of Object.keys(cleaned))
|
|
684
|
+
delete gone[dir];
|
|
685
|
+
const kept = Object.entries(gone).sort(([, a], [, b]) => b.at - a.at).slice(0, MAX_PROJECTS);
|
|
686
|
+
const file = {
|
|
687
|
+
v: 1,
|
|
688
|
+
projects: cleaned,
|
|
689
|
+
...kept.length ? { gone: Object.fromEntries(kept) } : {}
|
|
690
|
+
};
|
|
481
691
|
const path = projectsFilePath(env);
|
|
482
692
|
await atomicWriteFile(path, `${JSON.stringify(file, null, 2)}
|
|
483
693
|
`);
|
|
484
694
|
return path;
|
|
485
695
|
}
|
|
696
|
+
async function goneForDir(dir, env) {
|
|
697
|
+
const raw = await loadFile(env);
|
|
698
|
+
if (!raw)
|
|
699
|
+
return null;
|
|
700
|
+
const rec = raw.projects[dir];
|
|
701
|
+
if (rec && rec.expires_at !== null && rec.expires_at <= Date.now()) {
|
|
702
|
+
return { site_id: rec.site_id, url: rec.url, reason: "expired", at: rec.expires_at };
|
|
703
|
+
}
|
|
704
|
+
return raw.gone?.[dir] ?? null;
|
|
705
|
+
}
|
|
486
706
|
var DETACHED_PREFIX = "detached:";
|
|
487
707
|
function holdsOnlyCredential(rec) {
|
|
488
708
|
return rec.expires_at !== null && typeof rec.manage_token === "string";
|
|
@@ -513,14 +733,25 @@ async function projectForSite(site_id, env) {
|
|
|
513
733
|
}
|
|
514
734
|
return detached;
|
|
515
735
|
}
|
|
516
|
-
async function forgetDir(dir, env) {
|
|
736
|
+
async function forgetDir(dir, env, opts = {}) {
|
|
517
737
|
const projects = await loadProjects(env);
|
|
518
|
-
|
|
738
|
+
const rec = projects[dir];
|
|
739
|
+
if (!rec)
|
|
519
740
|
return false;
|
|
520
741
|
delete projects[dir];
|
|
521
|
-
await saveProjects(projects, env);
|
|
742
|
+
await saveProjects(projects, env, opts.gone ? { [dir]: rec } : {});
|
|
522
743
|
return true;
|
|
523
744
|
}
|
|
745
|
+
async function nearbyLink(dir, env) {
|
|
746
|
+
const projects = await loadProjects(env);
|
|
747
|
+
const linked = Object.entries(projects).filter(([key]) => !key.startsWith(DETACHED_PREFIX));
|
|
748
|
+
const isUnder = (child, parent) => child.startsWith(parent.endsWith(sep) ? parent : `${parent}${sep}`);
|
|
749
|
+
const above = linked.filter(([key]) => isUnder(dir, key)).sort(([a], [b]) => b.length - a.length)[0];
|
|
750
|
+
if (above)
|
|
751
|
+
return { dir: above[0], rec: above[1] };
|
|
752
|
+
const below = linked.filter(([key]) => isUnder(key, dir));
|
|
753
|
+
return below.length === 1 ? { dir: below[0]?.[0], rec: below[0]?.[1] } : null;
|
|
754
|
+
}
|
|
524
755
|
async function forgetSite(site_id, env) {
|
|
525
756
|
const projects = await loadProjects(env);
|
|
526
757
|
let removed = 0;
|
|
@@ -635,6 +866,16 @@ function relinkNotice(prev, style) {
|
|
|
635
866
|
` ${s.bold("flypod update")}${s.dim(" ships there. This run makes a second site.")}`
|
|
636
867
|
];
|
|
637
868
|
}
|
|
869
|
+
var RELINK_WARNING = "new-site-in-linked-folder";
|
|
870
|
+
function relinkWarning(prev, newUrl) {
|
|
871
|
+
return {
|
|
872
|
+
code: RELINK_WARNING,
|
|
873
|
+
fix_recipe: `This folder already deployed to ${prev.url}, so \`flypod\` made a second site (${newUrl}, live now; nothing to redo). ` + "To ship changes to a site you already have, run `flypod update`, never `flypod` again. " + `To put this build on the earlier URL instead: \`flypod update --site ${prev.site_id}\`.`
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
function relinkHint(prev) {
|
|
877
|
+
return `flypod: this folder already deploys to ${prev.url}; this run makes a second site. Use \`flypod update\` to ship there.`;
|
|
878
|
+
}
|
|
638
879
|
function skippedRows(skipped, style) {
|
|
639
880
|
if (skipped.length === 0)
|
|
640
881
|
return [];
|
|
@@ -845,7 +1086,11 @@ async function pollDeviceToken(client, deviceCode) {
|
|
|
845
1086
|
const { access_token } = await res.json();
|
|
846
1087
|
return { state: "approved", access_token };
|
|
847
1088
|
}
|
|
848
|
-
const
|
|
1089
|
+
const text = await res.text().catch(() => "");
|
|
1090
|
+
let body = {};
|
|
1091
|
+
try {
|
|
1092
|
+
body = JSON.parse(text) ?? {};
|
|
1093
|
+
} catch {}
|
|
849
1094
|
if (body.error === "authorization_pending")
|
|
850
1095
|
return { state: "pending" };
|
|
851
1096
|
if (body.error === "slow_down")
|
|
@@ -854,7 +1099,9 @@ async function pollDeviceToken(client, deviceCode) {
|
|
|
854
1099
|
return { state: "denied" };
|
|
855
1100
|
if (body.error === "expired_token")
|
|
856
1101
|
return { state: "expired" };
|
|
857
|
-
|
|
1102
|
+
if (body.error === "invalid_grant")
|
|
1103
|
+
return { state: "invalid" };
|
|
1104
|
+
return { state: "error", res: new Response(text, { status: res.status, headers: res.headers }) };
|
|
858
1105
|
}
|
|
859
1106
|
async function verifyToken(accessToken, baseUrl, args, io, env) {
|
|
860
1107
|
const client = await createClient({
|
|
@@ -908,7 +1155,9 @@ async function login(args, io) {
|
|
|
908
1155
|
} catch (e) {
|
|
909
1156
|
return emitError(networkError(e, baseUrl), args, io, { prefix: "flypod login" });
|
|
910
1157
|
}
|
|
911
|
-
return poll.state === "approved" ? finishLogin(poll.access_token, baseUrl, args, io, env) : emitError(loginPollError(poll, args.deviceCode), args, io, {
|
|
1158
|
+
return poll.state === "approved" ? finishLogin(poll.access_token, baseUrl, args, io, env) : emitError(await loginPollError(poll, args.deviceCode, args), args, io, {
|
|
1159
|
+
prefix: "flypod login"
|
|
1160
|
+
});
|
|
912
1161
|
}
|
|
913
1162
|
let startRes;
|
|
914
1163
|
try {
|
|
@@ -926,7 +1175,7 @@ async function login(args, io) {
|
|
|
926
1175
|
return emitError({
|
|
927
1176
|
code: "interactive_login_required",
|
|
928
1177
|
error: "Sign-in needs a browser. Ask the user to open the URL and confirm the code.",
|
|
929
|
-
fix: `
|
|
1178
|
+
fix: `Ask the user to open ${openUrl} and confirm code ${start.user_code}. Then run \`flypod login --device-code ${start.device_code} --json\`; while it answers authorization_pending, wait ${start.interval ?? 5}s and run it again.`,
|
|
930
1179
|
extra: {
|
|
931
1180
|
verification_uri: start.verification_uri,
|
|
932
1181
|
verification_uri_complete: openUrl,
|
|
@@ -961,7 +1210,7 @@ async function login(args, io) {
|
|
|
961
1210
|
pollMs += 5000;
|
|
962
1211
|
continue;
|
|
963
1212
|
}
|
|
964
|
-
return emitError(loginPollError(poll, start.device_code), args, io, {
|
|
1213
|
+
return emitError(await loginPollError(poll, start.device_code, args), args, io, {
|
|
965
1214
|
prefix: "flypod login"
|
|
966
1215
|
});
|
|
967
1216
|
}
|
|
@@ -969,26 +1218,33 @@ async function login(args, io) {
|
|
|
969
1218
|
fix: "Run `flypod login` to try again."
|
|
970
1219
|
});
|
|
971
1220
|
}
|
|
972
|
-
function loginPollError(poll, deviceCode) {
|
|
1221
|
+
async function loginPollError(poll, deviceCode, args) {
|
|
1222
|
+
const json = args.json ? " --json" : "";
|
|
1223
|
+
const restart = `Run \`flypod login${json}\` to start again.`;
|
|
973
1224
|
switch (poll.state) {
|
|
974
1225
|
case "pending":
|
|
975
1226
|
case "slow_down":
|
|
976
1227
|
return {
|
|
977
1228
|
code: "authorization_pending",
|
|
978
1229
|
error: "The sign-in has not been confirmed in the browser yet.",
|
|
979
|
-
fix: `Wait for the user to confirm, then run \`flypod login --device-code ${deviceCode}\` again.`
|
|
1230
|
+
fix: `Wait for the user to confirm, then run \`flypod login --device-code ${deviceCode}${json}\` again.`
|
|
980
1231
|
};
|
|
981
1232
|
case "denied":
|
|
982
1233
|
return { code: "login_denied", error: "Authorization denied in browser." };
|
|
983
1234
|
case "expired":
|
|
1235
|
+
return { code: "login_expired", error: "The sign-in code expired.", fix: restart };
|
|
1236
|
+
case "invalid":
|
|
984
1237
|
return {
|
|
985
1238
|
code: "login_expired",
|
|
986
|
-
error: "
|
|
987
|
-
fix:
|
|
1239
|
+
error: "That sign-in code is no longer valid: it expired, was already used, or is not a device_code (the user_code is the one the person types).",
|
|
1240
|
+
fix: `If an earlier \`flypod login --device-code\` printed ok, you are already signed in. Otherwise: ${restart}`
|
|
988
1241
|
};
|
|
989
1242
|
case "error":
|
|
1243
|
+
if (poll.res.status >= 500) {
|
|
1244
|
+
return serverError(poll.res.status, await readServerMessage(poll.res), "flypod login");
|
|
1245
|
+
}
|
|
990
1246
|
return {
|
|
991
|
-
code:
|
|
1247
|
+
code: "bad_request",
|
|
992
1248
|
error: `unexpected response ${poll.res.status} while polling for approval.`,
|
|
993
1249
|
status: poll.res.status
|
|
994
1250
|
};
|
|
@@ -1154,9 +1410,22 @@ async function withTarget(name, args, io) {
|
|
|
1154
1410
|
const env = io.env ?? process.env;
|
|
1155
1411
|
const target = await resolveTarget(args, io);
|
|
1156
1412
|
if (!target)
|
|
1157
|
-
return emitError(
|
|
1413
|
+
return emitError(await whyNoSite(name, io, env), args, io);
|
|
1158
1414
|
return { env, target };
|
|
1159
1415
|
}
|
|
1416
|
+
async function whyNoSite(verb, io, env) {
|
|
1417
|
+
const cwd = io.cwd ?? process.cwd();
|
|
1418
|
+
const gone = await goneForDir(cwd, env).catch(() => null);
|
|
1419
|
+
const near = gone ? null : await nearbyLink(cwd, env).catch(() => null);
|
|
1420
|
+
const session = await loadSession(env).catch(() => null);
|
|
1421
|
+
const signedIn = Boolean(resolveCredentials(env, session).token);
|
|
1422
|
+
return noSite({
|
|
1423
|
+
verb,
|
|
1424
|
+
gone,
|
|
1425
|
+
nearby: near ? { dir: near.dir, site_id: near.rec.site_id } : null,
|
|
1426
|
+
signedIn
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1160
1429
|
function clientForTarget(target, args, io) {
|
|
1161
1430
|
return createClient({
|
|
1162
1431
|
env: io.env ?? process.env,
|
|
@@ -1169,40 +1438,179 @@ function clientForTarget(target, args, io) {
|
|
|
1169
1438
|
}
|
|
1170
1439
|
});
|
|
1171
1440
|
}
|
|
1172
|
-
async function failSiteRequest(verb, res, target, args, io, env) {
|
|
1441
|
+
async function failSiteRequest(verb, res, target, args, io, env, opts = {}) {
|
|
1173
1442
|
if (res.status === 404 && target.dir)
|
|
1174
|
-
await forgetDir(target.dir, env);
|
|
1175
|
-
|
|
1443
|
+
await forgetDir(target.dir, env, { gone: true });
|
|
1444
|
+
let err = await classifyResponse(res, { verb, siteId: target.site_id, siteScoped: true });
|
|
1445
|
+
if (err.code === "too_large" && opts.upload) {
|
|
1446
|
+
err.telemetry = { ...err.telemetry, ...opts.upload() };
|
|
1447
|
+
}
|
|
1448
|
+
if (err.code === "unauthorized" && err.fix === UNAUTHORIZED_FIX && opts.client) {
|
|
1449
|
+
err = unauthorizedFor({
|
|
1450
|
+
siteId: target.site_id,
|
|
1451
|
+
sent: credentialSent(target, args, opts.client),
|
|
1452
|
+
known: target.rec !== null,
|
|
1453
|
+
status: err.status
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1176
1456
|
return emitError(err, args, io, { prefix: verb });
|
|
1177
1457
|
}
|
|
1178
|
-
|
|
1458
|
+
function credentialSent(target, args, client) {
|
|
1459
|
+
if (args.token)
|
|
1460
|
+
return "flag";
|
|
1461
|
+
if (!client.token)
|
|
1462
|
+
return "none";
|
|
1463
|
+
if (target.rec?.manage_token && client.token === target.rec.manage_token)
|
|
1464
|
+
return "manage_token";
|
|
1465
|
+
return "account";
|
|
1466
|
+
}
|
|
1467
|
+
async function sendForTarget(target, args, io, env, call) {
|
|
1179
1468
|
const client = await clientForTarget(target, args, io);
|
|
1180
|
-
|
|
1469
|
+
const res = await call(client);
|
|
1470
|
+
if (res.status !== 401 || credentialSent(target, args, client) !== "manage_token") {
|
|
1471
|
+
return { res, client };
|
|
1472
|
+
}
|
|
1473
|
+
const account = await createClient({
|
|
1474
|
+
env,
|
|
1475
|
+
fetch: io.fetch,
|
|
1476
|
+
cwd: io.cwd,
|
|
1477
|
+
overrides: { baseUrl: target.rec?.base_url }
|
|
1478
|
+
});
|
|
1479
|
+
if (!account.token || account.token === client.token)
|
|
1480
|
+
return { res, client };
|
|
1481
|
+
const again = await call(account);
|
|
1482
|
+
if (again.status === 401) {
|
|
1483
|
+
await again.body?.cancel().catch(() => {});
|
|
1484
|
+
return { res, client };
|
|
1485
|
+
}
|
|
1486
|
+
await res.body?.cancel().catch(() => {});
|
|
1487
|
+
if (again.ok)
|
|
1488
|
+
await adoptForAccount(target, env).catch(() => {});
|
|
1489
|
+
return { res: again, client: account };
|
|
1490
|
+
}
|
|
1491
|
+
async function adoptForAccount(target, env) {
|
|
1492
|
+
const owned = (r) => {
|
|
1493
|
+
const { manage_token: _retired, ...rest } = r;
|
|
1494
|
+
return { ...rest, expires_at: null };
|
|
1495
|
+
};
|
|
1496
|
+
if (target.rec)
|
|
1497
|
+
target.rec = owned(target.rec);
|
|
1498
|
+
const projects = await loadProjects(env);
|
|
1499
|
+
let changed = false;
|
|
1500
|
+
for (const [key, rec] of Object.entries(projects)) {
|
|
1501
|
+
if (rec.site_id !== target.site_id)
|
|
1502
|
+
continue;
|
|
1503
|
+
projects[key] = owned(rec);
|
|
1504
|
+
changed = true;
|
|
1505
|
+
}
|
|
1506
|
+
if (changed)
|
|
1507
|
+
await saveProjects(projects, env);
|
|
1508
|
+
}
|
|
1509
|
+
async function fetchSite(verb, target, args, io, env) {
|
|
1510
|
+
let sent;
|
|
1181
1511
|
try {
|
|
1182
|
-
|
|
1512
|
+
sent = await sendForTarget(target, args, io, env, (c) => c.getSite(target.site_id));
|
|
1183
1513
|
} catch (e) {
|
|
1184
|
-
|
|
1514
|
+
const { baseUrl } = await clientForTarget(target, args, io);
|
|
1515
|
+
return { error: emitError(networkError(e, baseUrl), args, io, { prefix: verb }) };
|
|
1516
|
+
}
|
|
1517
|
+
const { res, client } = sent;
|
|
1518
|
+
if (!res.ok) {
|
|
1519
|
+
return { error: await failSiteRequest(verb, res, target, args, io, env, { client }) };
|
|
1185
1520
|
}
|
|
1186
|
-
if (!res.ok)
|
|
1187
|
-
return { error: await failSiteRequest(verb, res, target, args, io, env) };
|
|
1188
1521
|
return { data: await res.json() };
|
|
1189
1522
|
}
|
|
1190
|
-
async function touchLink(target, version_id, env) {
|
|
1523
|
+
async function touchLink(target, version_id, env, deployDir) {
|
|
1191
1524
|
if (target.dir && target.rec) {
|
|
1192
|
-
await linkProject(target.dir, {
|
|
1525
|
+
await linkProject(target.dir, {
|
|
1526
|
+
...target.rec,
|
|
1527
|
+
version_id,
|
|
1528
|
+
last_used: Date.now(),
|
|
1529
|
+
...deployDir ? { deploy_dir: deployDir } : {}
|
|
1530
|
+
}, env);
|
|
1193
1531
|
}
|
|
1194
1532
|
}
|
|
1533
|
+
var UPDATE_RETRY_MS = 2000;
|
|
1534
|
+
var delay = (ms) => new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
1535
|
+
async function sendUpdate(target, args, io, env, zip, baseUrl) {
|
|
1536
|
+
let sent;
|
|
1537
|
+
try {
|
|
1538
|
+
sent = await sendForTarget(target, args, io, env, (c) => c.redeploy(target.site_id, zip));
|
|
1539
|
+
} catch (e) {
|
|
1540
|
+
return { kind: "retry", err: networkError(e, baseUrl) };
|
|
1541
|
+
}
|
|
1542
|
+
const { res, client } = sent;
|
|
1543
|
+
if (res.status >= 500) {
|
|
1544
|
+
const err = await classifyResponse(res, {
|
|
1545
|
+
verb: "flypod update",
|
|
1546
|
+
siteId: target.site_id,
|
|
1547
|
+
siteScoped: true
|
|
1548
|
+
});
|
|
1549
|
+
return { kind: "retry", err };
|
|
1550
|
+
}
|
|
1551
|
+
if (!res.ok)
|
|
1552
|
+
return { kind: "refused", res, client };
|
|
1553
|
+
try {
|
|
1554
|
+
return { kind: "ok", body: await res.json(), client };
|
|
1555
|
+
} catch {
|
|
1556
|
+
return {
|
|
1557
|
+
kind: "retry",
|
|
1558
|
+
err: {
|
|
1559
|
+
code: "server_error",
|
|
1560
|
+
status: res.status,
|
|
1561
|
+
error: "flypod update: the server's answer was cut off, so whether the new version went live is unknown.",
|
|
1562
|
+
fix: "Run the same command again: repeating an update is safe.",
|
|
1563
|
+
telemetry: { origin: "unreadable" }
|
|
1564
|
+
}
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
async function pathExists(path) {
|
|
1569
|
+
try {
|
|
1570
|
+
await stat3(path);
|
|
1571
|
+
return true;
|
|
1572
|
+
} catch {
|
|
1573
|
+
return false;
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
function shortPath(path, cwd) {
|
|
1577
|
+
const rel = relative2(cwd, path);
|
|
1578
|
+
if (rel === "")
|
|
1579
|
+
return ".";
|
|
1580
|
+
if (rel.startsWith("..") && rel.split(sep2).filter((p) => p === "..").length > 1)
|
|
1581
|
+
return path;
|
|
1582
|
+
return rel.startsWith("..") ? rel : `./${rel}`;
|
|
1583
|
+
}
|
|
1195
1584
|
async function update(args, io) {
|
|
1196
1585
|
const pre = await withTarget("update", args, io);
|
|
1197
1586
|
if (typeof pre === "number")
|
|
1198
1587
|
return pre;
|
|
1199
1588
|
const { env, target } = pre;
|
|
1200
1589
|
const cwd = io.cwd ?? process.cwd();
|
|
1590
|
+
const hintOpts = { verb: "flypod update" };
|
|
1591
|
+
if (args.path !== undefined && !await pathExists(args.path)) {
|
|
1592
|
+
return emitError(await withFolderHint({
|
|
1593
|
+
code: "no_build_dir",
|
|
1594
|
+
error: `Nothing to deploy at ${args.path}: no such file or folder.`,
|
|
1595
|
+
fix: "Pass the folder of built files, e.g. `flypod update ./dist`, or build the site first."
|
|
1596
|
+
}, cwd, undefined, hintOpts), args, io);
|
|
1597
|
+
}
|
|
1598
|
+
const remembered = !args.path && target.dir ? target.rec?.deploy_dir : undefined;
|
|
1201
1599
|
let dir;
|
|
1202
|
-
|
|
1203
|
-
dir =
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1600
|
+
if (remembered && await pathExists(remembered)) {
|
|
1601
|
+
dir = remembered;
|
|
1602
|
+
} else {
|
|
1603
|
+
try {
|
|
1604
|
+
dir = await resolveDeployDir({ cwd, explicit: args.path });
|
|
1605
|
+
} catch (e) {
|
|
1606
|
+
const shown = remembered ? shortPath(remembered, cwd) : undefined;
|
|
1607
|
+
const err = shown ? {
|
|
1608
|
+
code: "no_build_dir",
|
|
1609
|
+
error: `This folder's site was last deployed from ${shown}, which is not there now.`,
|
|
1610
|
+
fix: `Build the site again, then run \`flypod update\`; or pass the folder: \`flypod update ${shown}\`.`
|
|
1611
|
+
} : noBuildDir(e.message);
|
|
1612
|
+
return emitError(await withFolderHint(err, cwd, undefined, { ...hintOpts, remembered: shown }), args, io);
|
|
1613
|
+
}
|
|
1206
1614
|
}
|
|
1207
1615
|
let files;
|
|
1208
1616
|
let skipped;
|
|
@@ -1212,24 +1620,39 @@ async function update(args, io) {
|
|
|
1212
1620
|
return fail("no_files", `Could not read ${dir}: ${e.message}`, args, io);
|
|
1213
1621
|
}
|
|
1214
1622
|
if (Object.keys(files).length === 0) {
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1623
|
+
const empty = await withFolderHint({
|
|
1624
|
+
code: "no_files",
|
|
1625
|
+
error: `No files to deploy in ${dir}.`,
|
|
1626
|
+
fix: "Build the site first, then deploy the output folder.",
|
|
1627
|
+
telemetry: { file_count: 0, skipped_count: skipped.length }
|
|
1628
|
+
}, cwd, dir, hintOpts);
|
|
1629
|
+
return emitError(empty, args, io);
|
|
1630
|
+
}
|
|
1631
|
+
const first = await clientForTarget(target, args, io);
|
|
1632
|
+
const tooLarge = checkUploadSize(files, uploadLimitsFor(first.baseUrl), skipped.length, {
|
|
1633
|
+
ignoreFile: await ignoreFilePath(dir, cwd)
|
|
1634
|
+
});
|
|
1221
1635
|
if (tooLarge)
|
|
1222
1636
|
return emitError(tooLarge, args, io, { prefix: "flypod update" });
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1637
|
+
const zip = packDeploy(files);
|
|
1638
|
+
let sent = await sendUpdate(target, args, io, env, zip, first.baseUrl);
|
|
1639
|
+
if (sent.kind === "retry") {
|
|
1640
|
+
await (io.sleep ?? delay)(UPDATE_RETRY_MS);
|
|
1641
|
+
sent = await sendUpdate(target, args, io, env, zip, first.baseUrl);
|
|
1642
|
+
if (sent.kind === "retry")
|
|
1643
|
+
sent.err.telemetry = { ...sent.err.telemetry, attempts: 2 };
|
|
1644
|
+
}
|
|
1645
|
+
if (sent.kind === "retry")
|
|
1646
|
+
return emitError(sent.err, args, io, { prefix: "flypod update" });
|
|
1647
|
+
const { client } = sent;
|
|
1648
|
+
if (sent.kind === "refused") {
|
|
1649
|
+
return failSiteRequest("flypod update", sent.res, target, args, io, env, {
|
|
1650
|
+
upload: () => uploadReport(files, skipped.length),
|
|
1651
|
+
client
|
|
1652
|
+
});
|
|
1228
1653
|
}
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
const body = await res.json();
|
|
1232
|
-
await touchLink(target, body.version_id, env);
|
|
1654
|
+
const { body } = sent;
|
|
1655
|
+
await touchLink(target, body.version_id, env, resolve2(dir));
|
|
1233
1656
|
const switched = args.timeline === undefined ? undefined : await switchTimeline(client, target.site_id, args.timeline);
|
|
1234
1657
|
const timeline = switched?.timeline;
|
|
1235
1658
|
const expiresAt = body.expires_at !== undefined ? body.expires_at : target.rec?.expires_at ?? null;
|
|
@@ -1307,15 +1730,19 @@ async function versions(args, io) {
|
|
|
1307
1730
|
return pre;
|
|
1308
1731
|
const { env, target } = pre;
|
|
1309
1732
|
if (args.timeline !== undefined) {
|
|
1310
|
-
const
|
|
1311
|
-
let
|
|
1733
|
+
const enabled = args.timeline;
|
|
1734
|
+
let sent;
|
|
1312
1735
|
try {
|
|
1313
|
-
|
|
1736
|
+
sent = await sendForTarget(target, args, io, env, (c) => c.setTimeline(target.site_id, enabled));
|
|
1314
1737
|
} catch (e) {
|
|
1315
|
-
|
|
1738
|
+
const { baseUrl } = await clientForTarget(target, args, io);
|
|
1739
|
+
return emitError(networkError(e, baseUrl), args, io, { prefix: "flypod versions" });
|
|
1740
|
+
}
|
|
1741
|
+
if (!sent.res.ok) {
|
|
1742
|
+
return failSiteRequest("flypod versions", sent.res, target, args, io, env, {
|
|
1743
|
+
client: sent.client
|
|
1744
|
+
});
|
|
1316
1745
|
}
|
|
1317
|
-
if (!res.ok)
|
|
1318
|
-
return failSiteRequest("flypod versions", res, target, args, io, env);
|
|
1319
1746
|
}
|
|
1320
1747
|
const site = await fetchSite("flypod versions", target, args, io, env);
|
|
1321
1748
|
if ("error" in site)
|
|
@@ -1411,7 +1838,7 @@ async function rollback(args, io) {
|
|
|
1411
1838
|
return emitError(networkError(e, client.baseUrl), args, io, { prefix: "flypod rollback" });
|
|
1412
1839
|
}
|
|
1413
1840
|
if (!res.ok)
|
|
1414
|
-
return failSiteRequest("flypod rollback", res, target, args, io, env);
|
|
1841
|
+
return failSiteRequest("flypod rollback", res, target, args, io, env, { client });
|
|
1415
1842
|
const body = await res.json();
|
|
1416
1843
|
await touchLink(target, body.live_version_id, env);
|
|
1417
1844
|
const url = body.url ?? target.rec?.url ?? siteUrlFrom(target.site_id, client.baseUrl);
|
|
@@ -1639,7 +2066,7 @@ function requireCommentWriteToken(verb, token2, args, io) {
|
|
|
1639
2066
|
if (!token2)
|
|
1640
2067
|
return emitError(NOT_SIGNED_IN, args, io, { prefix });
|
|
1641
2068
|
if (token2.startsWith("fk_")) {
|
|
1642
|
-
return fail("unauthorized", "Comments operations require an account session
|
|
2069
|
+
return fail("unauthorized", "Comments operations require an account session; an fk_ token (a site's manage token or a retired API key) cannot write comments.", args, io, { prefix, fix: "Run `flypod login`, or set FLYPOD_TOKEN to a session token." });
|
|
1643
2070
|
}
|
|
1644
2071
|
return null;
|
|
1645
2072
|
}
|
|
@@ -1943,7 +2370,7 @@ function multiselect(opts) {
|
|
|
1943
2370
|
const output = opts.output ?? process.stderr;
|
|
1944
2371
|
const { style } = opts;
|
|
1945
2372
|
const choices = opts.choices.map((c) => ({ ...c }));
|
|
1946
|
-
return new Promise((
|
|
2373
|
+
return new Promise((resolve3) => {
|
|
1947
2374
|
let index = 0;
|
|
1948
2375
|
let printed = 0;
|
|
1949
2376
|
const footer = style.dim("↑/↓ move · space toggle · a all · enter confirm · esc cancel");
|
|
@@ -1984,7 +2411,7 @@ function multiselect(opts) {
|
|
|
1984
2411
|
};
|
|
1985
2412
|
const finish = (value) => {
|
|
1986
2413
|
cleanup();
|
|
1987
|
-
|
|
2414
|
+
resolve3(value);
|
|
1988
2415
|
};
|
|
1989
2416
|
const onData = (buf) => {
|
|
1990
2417
|
const key = buf.toString("utf8");
|
|
@@ -2030,6 +2457,17 @@ function multiselect(opts) {
|
|
|
2030
2457
|
});
|
|
2031
2458
|
}
|
|
2032
2459
|
|
|
2460
|
+
// src/ingest-error.ts
|
|
2461
|
+
var KB = 1024;
|
|
2462
|
+
var MB = 1024 * 1024;
|
|
2463
|
+
function formatBytes(n) {
|
|
2464
|
+
if (n >= MB)
|
|
2465
|
+
return `${Number((n / MB).toFixed(1))} MB`;
|
|
2466
|
+
if (n >= KB)
|
|
2467
|
+
return `${Math.ceil(n / KB)} KB`;
|
|
2468
|
+
return `${n} bytes`;
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2033
2471
|
// bin/deploy.ts
|
|
2034
2472
|
var SUBCOMMANDS = new Set([
|
|
2035
2473
|
"deploy",
|
|
@@ -2103,7 +2541,8 @@ var TOP_LEVEL_FLAG_SPEC = {
|
|
|
2103
2541
|
};
|
|
2104
2542
|
var COMMENT_MODES = ["anonymous", "passcode", "approved", "open", "review", "members"];
|
|
2105
2543
|
function exitUsage(err, argv) {
|
|
2106
|
-
|
|
2544
|
+
const json = argv.includes("--json");
|
|
2545
|
+
if (json) {
|
|
2107
2546
|
process.stdout.write(`${JSON.stringify(errorEnvelope(err))}
|
|
2108
2547
|
`);
|
|
2109
2548
|
} else {
|
|
@@ -2112,7 +2551,16 @@ function exitUsage(err, argv) {
|
|
|
2112
2551
|
`)}
|
|
2113
2552
|
`);
|
|
2114
2553
|
}
|
|
2115
|
-
|
|
2554
|
+
reportFailure(err, { json });
|
|
2555
|
+
throw new CliExit(exitCodeFor(err.code));
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
class CliExit extends Error {
|
|
2559
|
+
exitCode;
|
|
2560
|
+
constructor(exitCode) {
|
|
2561
|
+
super(`exit ${exitCode}`);
|
|
2562
|
+
this.exitCode = exitCode;
|
|
2563
|
+
}
|
|
2116
2564
|
}
|
|
2117
2565
|
function rejectFlagProblems(parsed, spec, argv, helpCmd) {
|
|
2118
2566
|
const problem = flagProblem(parsed, spec, helpCmd);
|
|
@@ -2259,12 +2707,7 @@ async function runSubcommand(name, argv) {
|
|
|
2259
2707
|
}
|
|
2260
2708
|
}
|
|
2261
2709
|
function emitCliError(err, json, io) {
|
|
2262
|
-
|
|
2263
|
-
io.out(JSON.stringify(errorEnvelope(err)));
|
|
2264
|
-
else
|
|
2265
|
-
for (const line of failure(err.error, err.fix, io.style ?? PLAIN))
|
|
2266
|
-
io.err(line);
|
|
2267
|
-
return exitCodeFor(err.code);
|
|
2710
|
+
return emitError(err, { json }, io);
|
|
2268
2711
|
}
|
|
2269
2712
|
function shortHome(path) {
|
|
2270
2713
|
const home = homedir();
|
|
@@ -2287,16 +2730,16 @@ async function runInstall(argv, io) {
|
|
|
2287
2730
|
}
|
|
2288
2731
|
rejectFlagProblems(parsed, INSTALL_FLAG_SPEC, argv, "flypod install --help");
|
|
2289
2732
|
const targets = [];
|
|
2290
|
-
for (const [flag,
|
|
2291
|
-
if (flags[flag] && !targets.includes(
|
|
2292
|
-
targets.push(
|
|
2733
|
+
for (const [flag, id] of Object.entries(TARGET_FLAGS)) {
|
|
2734
|
+
if (flags[flag] && !targets.includes(id))
|
|
2735
|
+
targets.push(id);
|
|
2293
2736
|
}
|
|
2294
2737
|
const all = Boolean(flags["--all"]);
|
|
2295
2738
|
const global = Boolean(flags["--global"]);
|
|
2296
2739
|
const list2 = Boolean(flags["--list"]);
|
|
2297
2740
|
const dryRun = Boolean(flags["--dry-run"] || flags["--print"]);
|
|
2298
2741
|
const yes = Boolean(flags["--yes"] || flags["-y"]);
|
|
2299
|
-
const interactive = !list2 && !dryRun && !all && !yes && targets.length === 0 && canPrompt(process.stdin);
|
|
2742
|
+
const interactive = !json && !list2 && !dryRun && !all && !yes && targets.length === 0 && canPrompt(process.stdin);
|
|
2300
2743
|
const picker = interactive ? async (plan) => {
|
|
2301
2744
|
const style = makeStyle(colorsEnabled(process.stderr));
|
|
2302
2745
|
process.stderr.write(`
|
|
@@ -2316,14 +2759,14 @@ async function runInstall(argv, io) {
|
|
|
2316
2759
|
err: (line) => io.err(shortHome(line)),
|
|
2317
2760
|
env: io.env
|
|
2318
2761
|
};
|
|
2319
|
-
return installSkill({ targets, all: all || yes, global, list: list2, dryRun, picker }, io2);
|
|
2762
|
+
return installSkill({ targets, all: all || yes, global, list: list2, dryRun, picker, json }, io2);
|
|
2320
2763
|
}
|
|
2321
2764
|
async function readVersion() {
|
|
2322
2765
|
const here = fileURLToPath(import.meta.url);
|
|
2323
2766
|
for (const rel of ["../../package.json", "../package.json"]) {
|
|
2324
2767
|
try {
|
|
2325
2768
|
const url = new URL(rel, `file://${here}`);
|
|
2326
|
-
const text = await
|
|
2769
|
+
const text = await readFile3(url, "utf8");
|
|
2327
2770
|
const version = JSON.parse(text).version;
|
|
2328
2771
|
if (version)
|
|
2329
2772
|
return version;
|
|
@@ -2456,17 +2899,22 @@ Environment:
|
|
|
2456
2899
|
FLYPOD_SHOW_TOKEN Set to 1 to print the manage token inline on deploy
|
|
2457
2900
|
NO_COLOR Disable ANSI colors
|
|
2458
2901
|
FORCE_COLOR Force ANSI colors even when stderr is not a TTY
|
|
2902
|
+
DO_NOT_TRACK Set to 1 to stop the random install id and failure
|
|
2903
|
+
reports (FLYPOD_TELEMETRY=0 does the same)
|
|
2459
2904
|
|
|
2460
2905
|
When no path is given, flypod looks for a build folder in the current directory:
|
|
2461
2906
|
dist, build, out, .output/public, .vercel/output/static, public, _site
|
|
2462
|
-
(each must contain an index.html)
|
|
2907
|
+
(each must contain an index.html). A folder of plain pages (an index.html,
|
|
2908
|
+
no package.json) deploys as it is. 'update' with no path deploys the
|
|
2909
|
+
folder the site was last deployed from.
|
|
2463
2910
|
|
|
2464
2911
|
What is uploaded:
|
|
2465
2912
|
Everything in the folder except .git, .hg, .svn, node_modules, .DS_Store,
|
|
2466
2913
|
Thumbs.db, .env and .env.* — at any depth. Add gitignore-style patterns to
|
|
2467
2914
|
a .flypodignore in the folder to leave out more. What was left out is
|
|
2468
|
-
listed after the deploy ("skipped" in --json).
|
|
2469
|
-
|
|
2915
|
+
listed after the deploy ("skipped" in --json). On flypod.dev a deploy may be
|
|
2916
|
+
at most ${HOSTED_UPLOAD_LIMITS.maxFiles} files, ${formatBytes(HOSTED_UPLOAD_LIMITS.maxTotalBytes)} of files and ${formatBytes(HOSTED_UPLOAD_LIMITS.maxZipBytes)} as an upload; flypod checks
|
|
2917
|
+
before uploading.
|
|
2470
2918
|
|
|
2471
2919
|
Docs: https://flypod.dev
|
|
2472
2920
|
`;
|
|
@@ -2477,14 +2925,14 @@ function showHelp(version, json) {
|
|
|
2477
2925
|
}
|
|
2478
2926
|
async function exists(path) {
|
|
2479
2927
|
try {
|
|
2480
|
-
await
|
|
2928
|
+
await stat4(path);
|
|
2481
2929
|
return true;
|
|
2482
2930
|
} catch {
|
|
2483
2931
|
return false;
|
|
2484
2932
|
}
|
|
2485
2933
|
}
|
|
2486
2934
|
function shortDir(dir) {
|
|
2487
|
-
const rel =
|
|
2935
|
+
const rel = relative3(process.cwd(), dir);
|
|
2488
2936
|
return rel === "" || rel.startsWith("..") ? dir : rel || ".";
|
|
2489
2937
|
}
|
|
2490
2938
|
function fail2(err, args, style) {
|
|
@@ -2497,7 +2945,19 @@ function fail2(err, args, style) {
|
|
|
2497
2945
|
|
|
2498
2946
|
`);
|
|
2499
2947
|
}
|
|
2500
|
-
|
|
2948
|
+
reportFailure(err, args);
|
|
2949
|
+
throw new CliExit(exitCodeFor(err.code));
|
|
2950
|
+
}
|
|
2951
|
+
async function firstRunNotice(argv) {
|
|
2952
|
+
const install = await installId(process.env);
|
|
2953
|
+
if (!install?.isNew || !process.stderr.isTTY)
|
|
2954
|
+
return;
|
|
2955
|
+
if (argv.some((a) => a === "--json" || a === "-q" || a === "--quiet"))
|
|
2956
|
+
return;
|
|
2957
|
+
const style = makeStyle(colorsEnabled(process.stderr));
|
|
2958
|
+
process.stderr.write(` ${style.dim(FIRST_RUN_NOTICE)}
|
|
2959
|
+
|
|
2960
|
+
`);
|
|
2501
2961
|
}
|
|
2502
2962
|
async function main() {
|
|
2503
2963
|
const rawArgv = process.argv.slice(2);
|
|
@@ -2505,8 +2965,18 @@ async function main() {
|
|
|
2505
2965
|
const at = firstPositionalIndex(rawArgv, ANY_VALUE_FLAG);
|
|
2506
2966
|
const firstPositional = at === -1 ? undefined : rawArgv[at];
|
|
2507
2967
|
const withoutVerb = at === -1 ? rawArgv : [...rawArgv.slice(0, at), ...rawArgv.slice(at + 1)];
|
|
2508
|
-
|
|
2968
|
+
const isSubcommand = Boolean(firstPositional && SUBCOMMANDS.has(firstPositional) && firstPositional !== "deploy");
|
|
2969
|
+
const answersLocally = rawArgv.some((a) => ["-h", "--help", "-v", "--version"].includes(a));
|
|
2970
|
+
setCliVersion(version);
|
|
2971
|
+
startFailureReports({
|
|
2972
|
+
verb: isSubcommand ? firstPositional : "deploy",
|
|
2973
|
+
help: answersLocally
|
|
2974
|
+
});
|
|
2975
|
+
if (!answersLocally)
|
|
2976
|
+
await firstRunNotice(rawArgv);
|
|
2977
|
+
if (isSubcommand) {
|
|
2509
2978
|
const code = await runSubcommand(firstPositional, withoutVerb);
|
|
2979
|
+
await flushFailureReports();
|
|
2510
2980
|
process.exit(code);
|
|
2511
2981
|
}
|
|
2512
2982
|
const args = parseArgs(firstPositional === "deploy" ? withoutVerb : rawArgv);
|
|
@@ -2530,17 +3000,19 @@ async function main() {
|
|
|
2530
3000
|
code: "unknown_command",
|
|
2531
3001
|
error: `unknown command "${args.path}" — did you mean \`flypod ${verb}\`?`,
|
|
2532
3002
|
fix: `flypod ${verb}`
|
|
2533
|
-
} : {
|
|
3003
|
+
} : await withFolderHint({
|
|
2534
3004
|
code: "no_build_dir",
|
|
2535
3005
|
error: `Nothing to deploy at ${args.path}: no such file or folder.`,
|
|
2536
3006
|
fix: "Pass the folder of built files, e.g. `flypod ./dist`, or build the site first."
|
|
2537
|
-
}, args, style);
|
|
3007
|
+
}, process.cwd()), args, style);
|
|
2538
3008
|
}
|
|
3009
|
+
const priorLink = await projectForDir(process.cwd()).catch(() => null);
|
|
2539
3010
|
let dir;
|
|
2540
3011
|
try {
|
|
2541
|
-
|
|
3012
|
+
const remembered = args.path === undefined && priorLink?.deploy_dir && await exists(priorLink.deploy_dir) ? priorLink.deploy_dir : undefined;
|
|
3013
|
+
dir = remembered ?? await resolveDeployDir({ explicit: args.path });
|
|
2542
3014
|
} catch (error) {
|
|
2543
|
-
fail2(noBuildDir(error.message), args, style);
|
|
3015
|
+
fail2(await withFolderHint(noBuildDir(error.message), process.cwd()), args, style);
|
|
2544
3016
|
}
|
|
2545
3017
|
let files;
|
|
2546
3018
|
let skipped;
|
|
@@ -2556,21 +3028,26 @@ async function main() {
|
|
|
2556
3028
|
const fileNames = Object.keys(files);
|
|
2557
3029
|
const totalBytes = fileNames.reduce((sum, name) => sum + (files[name]?.byteLength ?? 0), 0);
|
|
2558
3030
|
if (fileNames.length === 0) {
|
|
2559
|
-
fail2({
|
|
3031
|
+
fail2(await withFolderHint({
|
|
2560
3032
|
code: "no_files",
|
|
2561
3033
|
error: `No files found in ${shortDir(dir)}.`,
|
|
2562
|
-
fix: "Build the site first, then deploy the output folder."
|
|
2563
|
-
|
|
3034
|
+
fix: "Build the site first, then deploy the output folder.",
|
|
3035
|
+
telemetry: { file_count: 0, skipped_count: skipped.length }
|
|
3036
|
+
}, process.cwd(), dir), args, style);
|
|
2564
3037
|
}
|
|
2565
|
-
const tooLarge = checkUploadSize(files, uploadLimitsFor(baseUrl)
|
|
3038
|
+
const tooLarge = checkUploadSize(files, uploadLimitsFor(baseUrl), skipped.length, {
|
|
3039
|
+
ignoreFile: await ignoreFilePath(dir, process.cwd())
|
|
3040
|
+
});
|
|
2566
3041
|
if (tooLarge)
|
|
2567
3042
|
fail2(tooLarge, args, style);
|
|
2568
|
-
const priorLink = await projectForDir(process.cwd()).catch(() => null);
|
|
2569
3043
|
if (priorLink && useUI) {
|
|
2570
3044
|
for (const line of relinkNotice(priorLink, style))
|
|
2571
3045
|
process.stderr.write(`${line}
|
|
2572
3046
|
`);
|
|
2573
3047
|
process.stderr.write(`
|
|
3048
|
+
`);
|
|
3049
|
+
} else if (priorLink && args.quiet) {
|
|
3050
|
+
process.stderr.write(`${relinkHint(priorLink)}
|
|
2574
3051
|
`);
|
|
2575
3052
|
}
|
|
2576
3053
|
if (useUI)
|
|
@@ -2582,10 +3059,16 @@ async function main() {
|
|
|
2582
3059
|
const started = Date.now();
|
|
2583
3060
|
let result;
|
|
2584
3061
|
try {
|
|
2585
|
-
|
|
3062
|
+
const res = await client.createSite(packDeploy(files), { relink: Boolean(priorLink) });
|
|
3063
|
+
if (!res.ok)
|
|
3064
|
+
throw await DeployError.fromResponse(res);
|
|
3065
|
+
result = await res.json();
|
|
2586
3066
|
} catch (error) {
|
|
2587
3067
|
spinner.stop();
|
|
2588
3068
|
const err = error instanceof DeployError ? await classifyResponse(error.toResponse(), { verb: "flypod" }) : networkError(error, baseUrl);
|
|
3069
|
+
if (err.code === "too_large") {
|
|
3070
|
+
err.telemetry = { ...err.telemetry, ...uploadReport(files, skipped.length) };
|
|
3071
|
+
}
|
|
2589
3072
|
fail2(err, args, style);
|
|
2590
3073
|
}
|
|
2591
3074
|
const elapsed = Date.now() - started;
|
|
@@ -2600,7 +3083,8 @@ async function main() {
|
|
|
2600
3083
|
...owned ? {} : { manage_token: result.manage_token },
|
|
2601
3084
|
expires_at: result.expires_at,
|
|
2602
3085
|
last_used: Date.now(),
|
|
2603
|
-
version_id: result.version_id
|
|
3086
|
+
version_id: result.version_id,
|
|
3087
|
+
deploy_dir: resolve3(dir)
|
|
2604
3088
|
});
|
|
2605
3089
|
} catch {
|
|
2606
3090
|
linkSaved = false;
|
|
@@ -2640,7 +3124,10 @@ async function main() {
|
|
|
2640
3124
|
if (args.json) {
|
|
2641
3125
|
const shared = {
|
|
2642
3126
|
healed: result.healed ?? [],
|
|
2643
|
-
warnings:
|
|
3127
|
+
warnings: [
|
|
3128
|
+
...result.warnings ?? [],
|
|
3129
|
+
...priorLink && priorLink.site_id !== result.site_id ? [relinkWarning(priorLink, result.url)] : []
|
|
3130
|
+
],
|
|
2644
3131
|
link_saved: linkSaved,
|
|
2645
3132
|
...priorLink && priorLink.site_id !== result.site_id ? { replaced_link: { site_id: priorLink.site_id, url: priorLink.url } } : {},
|
|
2646
3133
|
...args.comments ? {
|
|
@@ -2729,9 +3216,14 @@ async function main() {
|
|
|
2729
3216
|
process.stdout.write(`${result.url}
|
|
2730
3217
|
`);
|
|
2731
3218
|
}
|
|
2732
|
-
main().catch((error) => {
|
|
3219
|
+
main().catch(async (error) => {
|
|
3220
|
+
if (error instanceof CliExit) {
|
|
3221
|
+
await flushFailureReports();
|
|
3222
|
+
process.exit(error.exitCode);
|
|
3223
|
+
}
|
|
2733
3224
|
const err = unexpectedError(error);
|
|
2734
|
-
|
|
3225
|
+
const json = process.argv.includes("--json");
|
|
3226
|
+
if (json) {
|
|
2735
3227
|
process.stdout.write(`${JSON.stringify(errorEnvelope(err))}
|
|
2736
3228
|
`);
|
|
2737
3229
|
} else {
|
|
@@ -2739,5 +3231,7 @@ main().catch((error) => {
|
|
|
2739
3231
|
`)}
|
|
2740
3232
|
`);
|
|
2741
3233
|
}
|
|
3234
|
+
reportFailure(err, { json });
|
|
3235
|
+
await flushFailureReports();
|
|
2742
3236
|
process.exit(exitCodeFor(err.code));
|
|
2743
3237
|
});
|