@faable/faable 1.29.0 → 1.30.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.
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { requireApi } from '../../../api/context.js';
|
|
2
2
|
import { log } from '../../../log.js';
|
|
3
|
+
import { follow_remote_build } from '../remote/follow.js';
|
|
3
4
|
import { resolve_app_id } from '../resolve_app_id.js';
|
|
4
5
|
import { format_log_lines } from './format.js';
|
|
5
6
|
|
|
7
|
+
// Phases where the build is still producing output; anything else is a frozen
|
|
8
|
+
// record and following would just wait on nothing.
|
|
9
|
+
const FOLLOWABLE_PHASES = new Set(['UNKNOWN', 'QUEUED', 'BUILDING']);
|
|
6
10
|
const logs = {
|
|
7
11
|
command: 'logs',
|
|
8
12
|
describe: 'Show runtime logs of the app (or build logs with --build)',
|
|
@@ -21,11 +25,23 @@ const logs = {
|
|
|
21
25
|
alias: 'd',
|
|
22
26
|
type: 'string',
|
|
23
27
|
description: 'Scope to one deployment id'
|
|
28
|
+
})
|
|
29
|
+
.option('follow', {
|
|
30
|
+
alias: 'f',
|
|
31
|
+
type: 'boolean',
|
|
32
|
+
default: false,
|
|
33
|
+
description: 'With --build: keep tailing the output while the build runs'
|
|
24
34
|
})
|
|
25
35
|
.example('$0 deploy logs', 'Runtime logs of the linked app (last 24h)')
|
|
26
36
|
.example('$0 deploy logs --build', 'Build output of the latest deployment')
|
|
37
|
+
.example('$0 deploy logs --build --follow', 'Tail the build that is running right now')
|
|
27
38
|
.showHelpOnFail(false),
|
|
28
39
|
handler: async (args) => {
|
|
40
|
+
if (args.follow && !args.build) {
|
|
41
|
+
// Runtime logs have no follow mode (the API serves a 24h window, not a
|
|
42
|
+
// stream) — only the build output can be tailed.
|
|
43
|
+
throw new Error('--follow only works with --build');
|
|
44
|
+
}
|
|
29
45
|
const ctx = await requireApi();
|
|
30
46
|
const app_id = await resolve_app_id(args.app, ctx.appId, ctx.api);
|
|
31
47
|
const app = await ctx.api.getApp(app_id);
|
|
@@ -41,6 +57,20 @@ const logs = {
|
|
|
41
57
|
return;
|
|
42
58
|
}
|
|
43
59
|
}
|
|
60
|
+
if (args.follow) {
|
|
61
|
+
// Live tail (the builder re-uploads the log every ~10s): same loop the
|
|
62
|
+
// deploy command uses, so it ends at the image handoff and exits red
|
|
63
|
+
// on BUILD_ERROR. On an already-settled deployment fall through to the
|
|
64
|
+
// recorded snapshot instead of waiting on nothing.
|
|
65
|
+
const deployment = await ctx.api.getDeployment(deployment_id);
|
|
66
|
+
const phase = deployment?.status?.phase ?? '';
|
|
67
|
+
if (FOLLOWABLE_PHASES.has(phase)) {
|
|
68
|
+
log.info(`🏗️ Following the build of ${deployment_id}:`);
|
|
69
|
+
await follow_remote_build(ctx.api, deployment_id);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
log.info(`Build of ${deployment_id} already finished (${phase}) — showing the recorded output.`);
|
|
73
|
+
}
|
|
44
74
|
const build = await ctx.api.getDeploymentLogs(deployment_id);
|
|
45
75
|
if (!build.content) {
|
|
46
76
|
log.info(`📭 No build output recorded for ${deployment_id}.`);
|