@vibesdotdev/infra-deploy 0.0.1
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 +125 -0
- package/SPEC.md +181 -0
- package/dist/cli/alerts/infra-alerts-create.cli-command.descriptor.d.ts +39 -0
- package/dist/cli/alerts/infra-alerts-create.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/alerts/infra-alerts-create.cli-command.descriptor.js +61 -0
- package/dist/cli/alerts/infra-alerts-create.cli-command.descriptor.js.map +1 -0
- package/dist/cli/alerts/infra-alerts-create.cli-command.impl.d.ts +13 -0
- package/dist/cli/alerts/infra-alerts-create.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/alerts/infra-alerts-create.cli-command.impl.js +109 -0
- package/dist/cli/alerts/infra-alerts-create.cli-command.impl.js.map +1 -0
- package/dist/cli/alerts/infra-alerts-delete.cli-command.descriptor.d.ts +31 -0
- package/dist/cli/alerts/infra-alerts-delete.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/alerts/infra-alerts-delete.cli-command.descriptor.js +36 -0
- package/dist/cli/alerts/infra-alerts-delete.cli-command.descriptor.js.map +1 -0
- package/dist/cli/alerts/infra-alerts-delete.cli-command.impl.d.ts +11 -0
- package/dist/cli/alerts/infra-alerts-delete.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/alerts/infra-alerts-delete.cli-command.impl.js +67 -0
- package/dist/cli/alerts/infra-alerts-delete.cli-command.impl.js.map +1 -0
- package/dist/cli/alerts/infra-alerts-list.cli-command.descriptor.d.ts +21 -0
- package/dist/cli/alerts/infra-alerts-list.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/alerts/infra-alerts-list.cli-command.descriptor.js +27 -0
- package/dist/cli/alerts/infra-alerts-list.cli-command.descriptor.js.map +1 -0
- package/dist/cli/alerts/infra-alerts-list.cli-command.impl.d.ts +12 -0
- package/dist/cli/alerts/infra-alerts-list.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/alerts/infra-alerts-list.cli-command.impl.js +74 -0
- package/dist/cli/alerts/infra-alerts-list.cli-command.impl.js.map +1 -0
- package/dist/cli/alerts/infra-alerts.cli-group.descriptor.d.ts +12 -0
- package/dist/cli/alerts/infra-alerts.cli-group.descriptor.d.ts.map +1 -0
- package/dist/cli/alerts/infra-alerts.cli-group.descriptor.js +12 -0
- package/dist/cli/alerts/infra-alerts.cli-group.descriptor.js.map +1 -0
- package/dist/cli/audit/infra-audit.cli-command.descriptor.d.ts +21 -0
- package/dist/cli/audit/infra-audit.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/audit/infra-audit.cli-command.descriptor.js +28 -0
- package/dist/cli/audit/infra-audit.cli-command.descriptor.js.map +1 -0
- package/dist/cli/audit/infra-audit.cli-command.impl.d.ts +18 -0
- package/dist/cli/audit/infra-audit.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/audit/infra-audit.cli-command.impl.js +219 -0
- package/dist/cli/audit/infra-audit.cli-command.impl.js.map +1 -0
- package/dist/cli/infra-deploy.cli-group.descriptor.d.ts +12 -0
- package/dist/cli/infra-deploy.cli-group.descriptor.d.ts.map +1 -0
- package/dist/cli/infra-deploy.cli-group.descriptor.js +12 -0
- package/dist/cli/infra-deploy.cli-group.descriptor.js.map +1 -0
- package/dist/cli/infra.cli-group.descriptor.d.ts +11 -0
- package/dist/cli/infra.cli-group.descriptor.d.ts.map +1 -0
- package/dist/cli/infra.cli-group.descriptor.js +11 -0
- package/dist/cli/infra.cli-group.descriptor.js.map +1 -0
- package/dist/cli/list/infra-deploy.list.cli-command.descriptor.d.ts +34 -0
- package/dist/cli/list/infra-deploy.list.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/list/infra-deploy.list.cli-command.descriptor.js +29 -0
- package/dist/cli/list/infra-deploy.list.cli-command.descriptor.js.map +1 -0
- package/dist/cli/list/infra-deploy.list.cli-command.impl.d.ts +5 -0
- package/dist/cli/list/infra-deploy.list.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/list/infra-deploy.list.cli-command.impl.js +110 -0
- package/dist/cli/list/infra-deploy.list.cli-command.impl.js.map +1 -0
- package/dist/cli/logs/infra-logs.cli-command.descriptor.d.ts +39 -0
- package/dist/cli/logs/infra-logs.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/logs/infra-logs.cli-command.descriptor.js +64 -0
- package/dist/cli/logs/infra-logs.cli-command.descriptor.js.map +1 -0
- package/dist/cli/logs/infra-logs.cli-command.impl.d.ts +5 -0
- package/dist/cli/logs/infra-logs.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/logs/infra-logs.cli-command.impl.js +323 -0
- package/dist/cli/logs/infra-logs.cli-command.impl.js.map +1 -0
- package/dist/cli/logs/stream-worker-tail.d.ts +62 -0
- package/dist/cli/logs/stream-worker-tail.d.ts.map +1 -0
- package/dist/cli/logs/stream-worker-tail.js +165 -0
- package/dist/cli/logs/stream-worker-tail.js.map +1 -0
- package/dist/cli/npm/infra-npm-publish.cli-command.descriptor.d.ts +27 -0
- package/dist/cli/npm/infra-npm-publish.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/npm/infra-npm-publish.cli-command.descriptor.js +75 -0
- package/dist/cli/npm/infra-npm-publish.cli-command.descriptor.js.map +1 -0
- package/dist/cli/npm/infra-npm-publish.cli-command.impl.d.ts +5 -0
- package/dist/cli/npm/infra-npm-publish.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/npm/infra-npm-publish.cli-command.impl.js +383 -0
- package/dist/cli/npm/infra-npm-publish.cli-command.impl.js.map +1 -0
- package/dist/cli/npm/infra-npm.cli-group.descriptor.d.ts +12 -0
- package/dist/cli/npm/infra-npm.cli-group.descriptor.d.ts.map +1 -0
- package/dist/cli/npm/infra-npm.cli-group.descriptor.js +12 -0
- package/dist/cli/npm/infra-npm.cli-group.descriptor.js.map +1 -0
- package/dist/cli/observability/infra-observability-set.cli-command.descriptor.d.ts +25 -0
- package/dist/cli/observability/infra-observability-set.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/observability/infra-observability-set.cli-command.descriptor.js +57 -0
- package/dist/cli/observability/infra-observability-set.cli-command.descriptor.js.map +1 -0
- package/dist/cli/observability/infra-observability-set.cli-command.impl.d.ts +17 -0
- package/dist/cli/observability/infra-observability-set.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/observability/infra-observability-set.cli-command.impl.js +152 -0
- package/dist/cli/observability/infra-observability-set.cli-command.impl.js.map +1 -0
- package/dist/cli/observability/infra-observability-status.cli-command.descriptor.d.ts +21 -0
- package/dist/cli/observability/infra-observability-status.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/observability/infra-observability-status.cli-command.descriptor.js +35 -0
- package/dist/cli/observability/infra-observability-status.cli-command.descriptor.js.map +1 -0
- package/dist/cli/observability/infra-observability-status.cli-command.impl.d.ts +17 -0
- package/dist/cli/observability/infra-observability-status.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/observability/infra-observability-status.cli-command.impl.js +99 -0
- package/dist/cli/observability/infra-observability-status.cli-command.impl.js.map +1 -0
- package/dist/cli/observability/infra-observability.cli-group.descriptor.d.ts +12 -0
- package/dist/cli/observability/infra-observability.cli-group.descriptor.d.ts.map +1 -0
- package/dist/cli/observability/infra-observability.cli-group.descriptor.js +12 -0
- package/dist/cli/observability/infra-observability.cli-group.descriptor.js.map +1 -0
- package/dist/cli/regenerate/infra-deploy.regenerate.cli-command.descriptor.d.ts +27 -0
- package/dist/cli/regenerate/infra-deploy.regenerate.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/regenerate/infra-deploy.regenerate.cli-command.descriptor.js +35 -0
- package/dist/cli/regenerate/infra-deploy.regenerate.cli-command.descriptor.js.map +1 -0
- package/dist/cli/regenerate/infra-deploy.regenerate.cli-command.impl.d.ts +5 -0
- package/dist/cli/regenerate/infra-deploy.regenerate.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/regenerate/infra-deploy.regenerate.cli-command.impl.js +99 -0
- package/dist/cli/regenerate/infra-deploy.regenerate.cli-command.impl.js.map +1 -0
- package/dist/cli/rum/infra-rum-status.cli-command.descriptor.d.ts +21 -0
- package/dist/cli/rum/infra-rum-status.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/rum/infra-rum-status.cli-command.descriptor.js +27 -0
- package/dist/cli/rum/infra-rum-status.cli-command.descriptor.js.map +1 -0
- package/dist/cli/rum/infra-rum-status.cli-command.impl.d.ts +12 -0
- package/dist/cli/rum/infra-rum-status.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/rum/infra-rum-status.cli-command.impl.js +88 -0
- package/dist/cli/rum/infra-rum-status.cli-command.impl.js.map +1 -0
- package/dist/cli/rum/infra-rum.cli-group.descriptor.d.ts +12 -0
- package/dist/cli/rum/infra-rum.cli-group.descriptor.d.ts.map +1 -0
- package/dist/cli/rum/infra-rum.cli-group.descriptor.js +12 -0
- package/dist/cli/rum/infra-rum.cli-group.descriptor.js.map +1 -0
- package/dist/cli/run/infra-deploy.run.cli-command.descriptor.d.ts +27 -0
- package/dist/cli/run/infra-deploy.run.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/run/infra-deploy.run.cli-command.descriptor.js +49 -0
- package/dist/cli/run/infra-deploy.run.cli-command.descriptor.js.map +1 -0
- package/dist/cli/run/infra-deploy.run.cli-command.impl.d.ts +5 -0
- package/dist/cli/run/infra-deploy.run.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/run/infra-deploy.run.cli-command.impl.js +272 -0
- package/dist/cli/run/infra-deploy.run.cli-command.impl.js.map +1 -0
- package/dist/cli/shared/discover-deployments.d.ts +41 -0
- package/dist/cli/shared/discover-deployments.d.ts.map +1 -0
- package/dist/cli/shared/discover-deployments.js +95 -0
- package/dist/cli/shared/discover-deployments.js.map +1 -0
- package/dist/config-loader.d.ts +24 -0
- package/dist/config-loader.d.ts.map +1 -0
- package/dist/config-loader.js +135 -0
- package/dist/config-loader.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/infra-deploy.plugin.d.ts +3 -0
- package/dist/infra-deploy.plugin.d.ts.map +1 -0
- package/dist/infra-deploy.plugin.js +59 -0
- package/dist/infra-deploy.plugin.js.map +1 -0
- package/dist/regenerate.d.ts +55 -0
- package/dist/regenerate.d.ts.map +1 -0
- package/dist/regenerate.js +206 -0
- package/dist/regenerate.js.map +1 -0
- package/package.json +85 -0
- package/src/cli/alerts/infra-alerts-create.cli-command.descriptor.ts +61 -0
- package/src/cli/alerts/infra-alerts-create.cli-command.impl.ts +131 -0
- package/src/cli/alerts/infra-alerts-delete.cli-command.descriptor.ts +36 -0
- package/src/cli/alerts/infra-alerts-delete.cli-command.impl.ts +75 -0
- package/src/cli/alerts/infra-alerts-list.cli-command.descriptor.ts +27 -0
- package/src/cli/alerts/infra-alerts-list.cli-command.impl.ts +88 -0
- package/src/cli/alerts/infra-alerts.cli-group.descriptor.ts +12 -0
- package/src/cli/audit/infra-audit.cli-command.descriptor.ts +28 -0
- package/src/cli/audit/infra-audit.cli-command.impl.ts +293 -0
- package/src/cli/infra-deploy.cli-group.descriptor.ts +12 -0
- package/src/cli/infra.cli-group.descriptor.ts +11 -0
- package/src/cli/list/infra-deploy.list.cli-command.descriptor.ts +29 -0
- package/src/cli/list/infra-deploy.list.cli-command.impl.ts +125 -0
- package/src/cli/logs/infra-logs.cli-command.descriptor.ts +65 -0
- package/src/cli/logs/infra-logs.cli-command.impl.ts +354 -0
- package/src/cli/logs/stream-worker-tail.ts +202 -0
- package/src/cli/npm/infra-npm-publish.cli-command.descriptor.ts +75 -0
- package/src/cli/npm/infra-npm-publish.cli-command.impl.ts +474 -0
- package/src/cli/npm/infra-npm.cli-group.descriptor.ts +12 -0
- package/src/cli/observability/infra-observability-set.cli-command.descriptor.ts +57 -0
- package/src/cli/observability/infra-observability-set.cli-command.impl.ts +173 -0
- package/src/cli/observability/infra-observability-status.cli-command.descriptor.ts +35 -0
- package/src/cli/observability/infra-observability-status.cli-command.impl.ts +124 -0
- package/src/cli/observability/infra-observability.cli-group.descriptor.ts +12 -0
- package/src/cli/regenerate/infra-deploy.regenerate.cli-command.descriptor.ts +36 -0
- package/src/cli/regenerate/infra-deploy.regenerate.cli-command.impl.ts +103 -0
- package/src/cli/rum/infra-rum-status.cli-command.descriptor.ts +27 -0
- package/src/cli/rum/infra-rum-status.cli-command.impl.ts +112 -0
- package/src/cli/rum/infra-rum.cli-group.descriptor.ts +12 -0
- package/src/cli/run/infra-deploy.run.cli-command.descriptor.ts +49 -0
- package/src/cli/run/infra-deploy.run.cli-command.impl.ts +330 -0
- package/src/cli/shared/discover-deployments.ts +127 -0
- package/src/config-loader.ts +179 -0
- package/src/index.ts +11 -0
- package/src/infra-deploy.plugin.ts +83 -0
- package/src/regenerate.ts +230 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createRuntimeAsset } from '@vibesdotdev/runtime';
|
|
2
|
+
export default createRuntimeAsset({
|
|
3
|
+
id: 'infra',
|
|
4
|
+
kind: 'cli/group',
|
|
5
|
+
name: 'infra',
|
|
6
|
+
description: 'Infrastructure commands',
|
|
7
|
+
surfaces: ['cli'],
|
|
8
|
+
hardware: ['consumer', 'cloud'],
|
|
9
|
+
enabled: true
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=infra.cli-group.descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infra.cli-group.descriptor.js","sourceRoot":"","sources":["../../src/cli/infra.cli-group.descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,eAAe,kBAAkB,CAAC;IACjC,EAAE,EAAE,OAAO;IACX,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,yBAAyB;IACtC,QAAQ,EAAE,CAAC,KAAK,CAAC;IACjB,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC;IAC/B,OAAO,EAAE,IAAI;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
id: string;
|
|
3
|
+
kind: "cli/command";
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
group: string;
|
|
7
|
+
arguments: {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
required: boolean;
|
|
11
|
+
variadic: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
options: ({
|
|
14
|
+
flags: string;
|
|
15
|
+
description: string;
|
|
16
|
+
default: string;
|
|
17
|
+
type?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
flags: string;
|
|
20
|
+
description: string;
|
|
21
|
+
default: string;
|
|
22
|
+
type: string;
|
|
23
|
+
} | {
|
|
24
|
+
flags: string;
|
|
25
|
+
description: string;
|
|
26
|
+
default?: undefined;
|
|
27
|
+
type?: undefined;
|
|
28
|
+
})[];
|
|
29
|
+
surfaces: string[];
|
|
30
|
+
hardware: string[];
|
|
31
|
+
enabled: true;
|
|
32
|
+
};
|
|
33
|
+
export default _default;
|
|
34
|
+
//# sourceMappingURL=infra-deploy.list.cli-command.descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infra-deploy.list.cli-command.descriptor.d.ts","sourceRoot":"","sources":["../../../src/cli/list/infra-deploy.list.cli-command.descriptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wBA0BG"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createRuntimeAsset } from '@vibesdotdev/runtime';
|
|
2
|
+
export default createRuntimeAsset({
|
|
3
|
+
id: 'infra-deploy.list',
|
|
4
|
+
kind: 'cli/command',
|
|
5
|
+
name: 'list',
|
|
6
|
+
description: 'List deployable apps under <root> (scans for deployment.config.ts)',
|
|
7
|
+
group: 'infra-deploy',
|
|
8
|
+
arguments: [
|
|
9
|
+
{
|
|
10
|
+
name: 'root',
|
|
11
|
+
description: 'Root directory to scan (defaults to cwd)',
|
|
12
|
+
required: false,
|
|
13
|
+
variadic: false
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
options: [
|
|
17
|
+
{
|
|
18
|
+
flags: '-o, --output <format>',
|
|
19
|
+
description: 'Output format (text|json|table)',
|
|
20
|
+
default: 'table'
|
|
21
|
+
},
|
|
22
|
+
{ flags: '--max-depth <n>', description: 'Maximum directory depth to scan', default: '4', type: 'number' },
|
|
23
|
+
{ flags: '--order, --graph', description: 'Show suggested deploy order based on dependsOn (topological)' }
|
|
24
|
+
],
|
|
25
|
+
surfaces: ['cli'],
|
|
26
|
+
hardware: ['consumer', 'cloud'],
|
|
27
|
+
enabled: true
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=infra-deploy.list.cli-command.descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infra-deploy.list.cli-command.descriptor.js","sourceRoot":"","sources":["../../../src/cli/list/infra-deploy.list.cli-command.descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,eAAe,kBAAkB,CAAC;IACjC,EAAE,EAAE,mBAAmB;IACvB,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,oEAAoE;IACjF,KAAK,EAAE,cAAc;IACrB,SAAS,EAAE;QACV;YACC,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,0CAA0C;YACvD,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,KAAK;SACf;KACD;IACD,OAAO,EAAE;QACR;YACC,KAAK,EAAE,uBAAuB;YAC9B,WAAW,EAAE,iCAAiC;YAC9C,OAAO,EAAE,OAAO;SAChB;QACD,EAAE,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,iCAAiC,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1G,EAAE,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,8DAA8D,EAAE;KAC1G;IACD,QAAQ,EAAE,CAAC,KAAK,CAAC;IACjB,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC;IAC/B,OAAO,EAAE,IAAI;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infra-deploy.list.cli-command.impl.d.ts","sourceRoot":"","sources":["../../../src/cli/list/infra-deploy.list.cli-command.impl.ts"],"names":[],"mappings":";kBAiDqB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;;AAD3F,wBA4EE"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { isAbsolute, relative, resolve } from 'node:path';
|
|
2
|
+
import { getVibesRuntime } from '@vibesdotdev/runtime';
|
|
3
|
+
import { discoverDeployments } from "../shared/discover-deployments.js";
|
|
4
|
+
function readString(v) {
|
|
5
|
+
return typeof v === 'string' && v.length > 0 ? v : undefined;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Simple topological order for deploy (earlier = must deploy first).
|
|
9
|
+
* Apps with no dependsOn come first. Uses Kahn's algorithm.
|
|
10
|
+
*/
|
|
11
|
+
function computeDeployOrder(apps) {
|
|
12
|
+
const graph = new Map();
|
|
13
|
+
const indegree = new Map();
|
|
14
|
+
for (const a of apps) {
|
|
15
|
+
if (!graph.has(a.appId))
|
|
16
|
+
graph.set(a.appId, new Set());
|
|
17
|
+
indegree.set(a.appId, indegree.get(a.appId) ?? 0);
|
|
18
|
+
for (const dep of a.dependsOn ?? []) {
|
|
19
|
+
if (!graph.has(dep.appId))
|
|
20
|
+
graph.set(dep.appId, new Set());
|
|
21
|
+
graph.get(dep.appId).add(a.appId);
|
|
22
|
+
indegree.set(a.appId, (indegree.get(a.appId) ?? 0) + 1);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const queue = [];
|
|
26
|
+
for (const [id, deg] of indegree)
|
|
27
|
+
if (deg === 0)
|
|
28
|
+
queue.push(id);
|
|
29
|
+
const order = [];
|
|
30
|
+
while (queue.length) {
|
|
31
|
+
const node = queue.shift();
|
|
32
|
+
order.push(node);
|
|
33
|
+
for (const neighbor of graph.get(node) ?? []) {
|
|
34
|
+
indegree.set(neighbor, (indegree.get(neighbor) ?? 1) - 1);
|
|
35
|
+
if (indegree.get(neighbor) === 0)
|
|
36
|
+
queue.push(neighbor);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Any remaining (cycles) appended at end
|
|
40
|
+
for (const [id] of indegree)
|
|
41
|
+
if (!order.includes(id))
|
|
42
|
+
order.push(id);
|
|
43
|
+
return order;
|
|
44
|
+
}
|
|
45
|
+
export default {
|
|
46
|
+
async execute(args, opts) {
|
|
47
|
+
const runtime = getVibesRuntime();
|
|
48
|
+
const ui = (await runtime.context('cli/ui'));
|
|
49
|
+
const rootInput = readString(args.root) ?? '.';
|
|
50
|
+
const output = readString(opts.output) ?? 'table';
|
|
51
|
+
const maxDepthRaw = readString(opts.maxDepth);
|
|
52
|
+
const maxDepthParsed = maxDepthRaw ? Number.parseInt(maxDepthRaw, 10) : 4;
|
|
53
|
+
const maxDepth = Number.isFinite(maxDepthParsed) ? maxDepthParsed : 4;
|
|
54
|
+
function readBoolean(v) {
|
|
55
|
+
return v === true || v === 'true' || v === 'yes';
|
|
56
|
+
}
|
|
57
|
+
const showOrder = readBoolean(opts.order) || readBoolean(opts.graph);
|
|
58
|
+
const rows = [];
|
|
59
|
+
const appData = [];
|
|
60
|
+
const discovered = await discoverDeployments({
|
|
61
|
+
root: rootInput,
|
|
62
|
+
maxDepth,
|
|
63
|
+
onError: ({ appDir, error }) => {
|
|
64
|
+
rows.push({
|
|
65
|
+
appId: '(unparseable)',
|
|
66
|
+
appName: error.message,
|
|
67
|
+
provider: '-',
|
|
68
|
+
path: relative(process.cwd(), appDir) || '.',
|
|
69
|
+
dependsOn: []
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
for (const d of discovered) {
|
|
74
|
+
const depIds = d.dependsOn.map((dep) => dep.appId);
|
|
75
|
+
rows.push({
|
|
76
|
+
appId: d.appId,
|
|
77
|
+
appName: d.appName,
|
|
78
|
+
provider: d.provider,
|
|
79
|
+
path: relative(process.cwd(), d.appDir) || '.',
|
|
80
|
+
dependsOn: depIds
|
|
81
|
+
});
|
|
82
|
+
appData.push({ appId: d.appId, dependsOn: d.dependsOn });
|
|
83
|
+
}
|
|
84
|
+
if (rows.length === 0) {
|
|
85
|
+
const root = isAbsolute(rootInput) ? rootInput : resolve(process.cwd(), rootInput);
|
|
86
|
+
if (output === 'json')
|
|
87
|
+
ui.json([]);
|
|
88
|
+
else
|
|
89
|
+
ui.info(`No deployment configs found under ${root}`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (showOrder) {
|
|
93
|
+
const order = computeDeployOrder(appData);
|
|
94
|
+
if (output === 'json') {
|
|
95
|
+
ui.json({ order, apps: rows });
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
ui.info('Suggested deploy order (earlier = prerequisites first):');
|
|
99
|
+
order.forEach((id, i) => ui.log(` ${i + 1}. ${id}`));
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (output === 'json') {
|
|
104
|
+
ui.json(rows);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
ui.table(rows, { columns: ['appId', 'appName', 'provider', 'path', 'dependsOn'] });
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=infra-deploy.list.cli-command.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infra-deploy.list.cli-command.impl.js","sourceRoot":"","sources":["../../../src/cli/list/infra-deploy.list.cli-command.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K,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;YACvD,CAAC;YACD,OAAO;QACR,CAAC;QAED,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACvB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACd,OAAO;QACR,CAAC;QACD,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
id: string;
|
|
3
|
+
kind: "cli/command";
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
group: string;
|
|
7
|
+
arguments: {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
required: boolean;
|
|
11
|
+
variadic: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
options: ({
|
|
14
|
+
flags: string;
|
|
15
|
+
description: string;
|
|
16
|
+
default: string;
|
|
17
|
+
type?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
flags: string;
|
|
20
|
+
description: string;
|
|
21
|
+
default: boolean;
|
|
22
|
+
type?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
flags: string;
|
|
25
|
+
description: string;
|
|
26
|
+
default: undefined;
|
|
27
|
+
type?: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
flags: string;
|
|
30
|
+
description: string;
|
|
31
|
+
default: string;
|
|
32
|
+
type: string;
|
|
33
|
+
})[];
|
|
34
|
+
surfaces: string[];
|
|
35
|
+
hardware: string[];
|
|
36
|
+
enabled: true;
|
|
37
|
+
};
|
|
38
|
+
export default _default;
|
|
39
|
+
//# sourceMappingURL=infra-logs.cli-command.descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infra-logs.cli-command.descriptor.d.ts","sourceRoot":"","sources":["../../../src/cli/logs/infra-logs.cli-command.descriptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wBA8DG"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createRuntimeAsset } from '@vibesdotdev/runtime';
|
|
2
|
+
export default createRuntimeAsset({
|
|
3
|
+
id: 'infra-logs',
|
|
4
|
+
kind: 'cli/command',
|
|
5
|
+
name: 'logs',
|
|
6
|
+
description: 'List and query log sources (Workers, Pages, D1, etc.)',
|
|
7
|
+
group: 'infra',
|
|
8
|
+
arguments: [
|
|
9
|
+
{
|
|
10
|
+
name: 'source',
|
|
11
|
+
description: 'Log source name to query (optional, lists all if omitted)',
|
|
12
|
+
required: false,
|
|
13
|
+
variadic: false
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: 'worker',
|
|
17
|
+
description: 'Worker name to filter logs (when source has multiple workers)',
|
|
18
|
+
required: false,
|
|
19
|
+
variadic: false
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
options: [
|
|
23
|
+
{
|
|
24
|
+
flags: '-o, --output <format>',
|
|
25
|
+
description: 'Output format (text|json|table)',
|
|
26
|
+
default: 'table'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
flags: '--analytics',
|
|
30
|
+
description: 'Get analytics summary for a source',
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
flags: '--timeStart <range>',
|
|
35
|
+
description: 'Time range for analytics (e.g., 1h, 24h, 7d)',
|
|
36
|
+
default: '24h'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
flags: '--tail',
|
|
40
|
+
description: 'Stream logs in real-time',
|
|
41
|
+
default: false
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
flags: '--status <status>',
|
|
45
|
+
description: 'Filter by status (ok|error|canceled)',
|
|
46
|
+
default: undefined
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
flags: '--limit <n>',
|
|
50
|
+
description: 'Max log entries to retrieve',
|
|
51
|
+
default: '100',
|
|
52
|
+
type: 'number'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
flags: '--window <duration>',
|
|
56
|
+
description: 'Capture window for windowed query mode (e.g., 30s, 2m). Default 30s. Cloudflare exposes only live Tail for per-event data, so this brief window is the largest practical batch.',
|
|
57
|
+
default: '30s'
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
surfaces: ['cli'],
|
|
61
|
+
hardware: ['consumer', 'cloud'],
|
|
62
|
+
enabled: true
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=infra-logs.cli-command.descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infra-logs.cli-command.descriptor.js","sourceRoot":"","sources":["../../../src/cli/logs/infra-logs.cli-command.descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,eAAe,kBAAkB,CAAC;IACjC,EAAE,EAAE,YAAY;IAChB,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,uDAAuD;IACpE,KAAK,EAAE,OAAO;IACd,SAAS,EAAE;QACV;YACC,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,2DAA2D;YACxE,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,KAAK;SACf;QACD;YACC,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,+DAA+D;YAC5E,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,KAAK;SACf;KACD;IACD,OAAO,EAAE;QACR;YACC,KAAK,EAAE,uBAAuB;YAC9B,WAAW,EAAE,iCAAiC;YAC9C,OAAO,EAAE,OAAO;SAChB;QACD;YACC,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,oCAAoC;YACjD,OAAO,EAAE,KAAK;SACd;QACD;YACC,KAAK,EAAE,qBAAqB;YAC5B,WAAW,EAAE,8CAA8C;YAC3D,OAAO,EAAE,KAAK;SACd;QACD;YACC,KAAK,EAAE,QAAQ;YACf,WAAW,EAAE,0BAA0B;YACvC,OAAO,EAAE,KAAK;SACd;QACD;YACC,KAAK,EAAE,mBAAmB;YAC1B,WAAW,EAAE,sCAAsC;YACnD,OAAO,EAAE,SAAS;SAClB;QACD;YACC,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,6BAA6B;YAC1C,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,QAAQ;SACd;QACD;YACC,KAAK,EAAE,qBAAqB;YAC5B,WAAW,EACV,iLAAiL;YAClL,OAAO,EAAE,KAAK;SACd;KACD;IACD,QAAQ,EAAE,CAAC,KAAK,CAAC;IACjB,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC;IAC/B,OAAO,EAAE,IAAI;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infra-logs.cli-command.impl.d.ts","sourceRoot":"","sources":["../../../src/cli/logs/infra-logs.cli-command.impl.ts"],"names":[],"mappings":";kBAuEqB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;;AAD3F,wBAyRE"}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { getVibesRuntime } from '@vibesdotdev/runtime';
|
|
2
|
+
import { requestCLIExit } from '@vibesdotdev/cli/providers';
|
|
3
|
+
import { discoverDeployments } from "../shared/discover-deployments.js";
|
|
4
|
+
import { streamWorkerTail } from "./stream-worker-tail.js";
|
|
5
|
+
/** Parse a duration suffix like "30s", "2m", "1h" → milliseconds. Falls back to 30s. */
|
|
6
|
+
function parseDurationMs(input) {
|
|
7
|
+
if (!input)
|
|
8
|
+
return 30_000;
|
|
9
|
+
const m = /^(\d+)\s*(ms|s|m|h)?$/i.exec(input.trim());
|
|
10
|
+
if (!m)
|
|
11
|
+
return 30_000;
|
|
12
|
+
const n = Number.parseInt(m[1], 10);
|
|
13
|
+
const unit = (m[2] ?? 's').toLowerCase();
|
|
14
|
+
if (unit === 'ms')
|
|
15
|
+
return n;
|
|
16
|
+
if (unit === 's')
|
|
17
|
+
return n * 1000;
|
|
18
|
+
if (unit === 'm')
|
|
19
|
+
return n * 60_000;
|
|
20
|
+
if (unit === 'h')
|
|
21
|
+
return n * 3_600_000;
|
|
22
|
+
return 30_000;
|
|
23
|
+
}
|
|
24
|
+
function readString(v) {
|
|
25
|
+
return typeof v === 'string' && v.length > 0 ? v : undefined;
|
|
26
|
+
}
|
|
27
|
+
function readBoolean(v) {
|
|
28
|
+
return v === true || v === 'true';
|
|
29
|
+
}
|
|
30
|
+
function descriptorHasWorkerSource(descriptor, workerName) {
|
|
31
|
+
return descriptor.sources?.some((s) => s.type === 'worker' && (s.name === workerName || descriptor.id === workerName)) ?? false;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Map an `infra/logs` descriptor adapter name to the deployment provider that
|
|
35
|
+
* emits workers for it. Extend as new providers register infra/logs adapters.
|
|
36
|
+
*/
|
|
37
|
+
function adapterToProvider(adapter) {
|
|
38
|
+
if (adapter === 'cloudflare-logs')
|
|
39
|
+
return 'cloudflare-workers';
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Build the `sources` list a logs descriptor should expose at display time
|
|
44
|
+
* by merging anything declared in the descriptor with workers discovered
|
|
45
|
+
* from the workspace's `deployment.config.ts` files. Sources are always
|
|
46
|
+
* de-duped by name.
|
|
47
|
+
*/
|
|
48
|
+
function mergeDescriptorSources(descriptor, discovered) {
|
|
49
|
+
const provider = adapterToProvider(descriptor.adapter);
|
|
50
|
+
const fromWorkspace = discovered
|
|
51
|
+
.filter((d) => !provider || d.provider === provider)
|
|
52
|
+
.filter((d) => Boolean(d.workerName))
|
|
53
|
+
.map((d) => ({ type: 'worker', name: d.workerName }));
|
|
54
|
+
const seen = new Set();
|
|
55
|
+
const merged = [];
|
|
56
|
+
for (const src of [...(descriptor.sources ?? []), ...fromWorkspace]) {
|
|
57
|
+
const key = `${src.type}:${src.name}`;
|
|
58
|
+
if (seen.has(key))
|
|
59
|
+
continue;
|
|
60
|
+
seen.add(key);
|
|
61
|
+
merged.push(src);
|
|
62
|
+
}
|
|
63
|
+
return merged;
|
|
64
|
+
}
|
|
65
|
+
export default {
|
|
66
|
+
async execute(args, opts) {
|
|
67
|
+
const runtime = await getVibesRuntime();
|
|
68
|
+
const ui = (await runtime.context('cli/ui'));
|
|
69
|
+
const sourceName = readString(args.source);
|
|
70
|
+
const workerName = readString(args.worker);
|
|
71
|
+
const output = readString(opts.output) ?? 'table';
|
|
72
|
+
const showAnalytics = readBoolean(opts.analytics);
|
|
73
|
+
const timeStart = readString(opts.timeStart) ?? '24h';
|
|
74
|
+
const doTail = readBoolean(opts.tail);
|
|
75
|
+
const status = readString(opts.status);
|
|
76
|
+
const limitRaw = readString(opts.limit) ?? '100';
|
|
77
|
+
const limit = Number.parseInt(limitRaw, 10);
|
|
78
|
+
const windowRaw = readString(opts.window);
|
|
79
|
+
const windowMs = parseDurationMs(windowRaw);
|
|
80
|
+
// Get all infra/logs descriptors
|
|
81
|
+
const logsAssets = runtime.assets('infra/logs');
|
|
82
|
+
const rawDescriptors = logsAssets.descriptors();
|
|
83
|
+
if (rawDescriptors.length === 0) {
|
|
84
|
+
if (output === 'json')
|
|
85
|
+
ui.json([]);
|
|
86
|
+
else
|
|
87
|
+
ui.info('No log sources configured. Add an infra/logs descriptor to enable log querying.');
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// Augment each descriptor's sources by discovering workers from the
|
|
91
|
+
// workspace's deployment.config.ts files. Framework-registered
|
|
92
|
+
// descriptors carry no app-name list — that inventory lives in
|
|
93
|
+
// per-app deployment configs and is resolved here at call time.
|
|
94
|
+
const discovered = await discoverDeployments();
|
|
95
|
+
const descriptors = rawDescriptors.map((d) => ({
|
|
96
|
+
...d,
|
|
97
|
+
sources: mergeDescriptorSources(d, discovered)
|
|
98
|
+
}));
|
|
99
|
+
// Resolve implementations for each descriptor
|
|
100
|
+
const implementations = [];
|
|
101
|
+
for (const descriptor of descriptors) {
|
|
102
|
+
try {
|
|
103
|
+
const resolved = await runtime.query('infra/logs').withId(descriptor.id).resolve();
|
|
104
|
+
const resolvedObj = resolved;
|
|
105
|
+
// The resolved object may have implementation directly or nested
|
|
106
|
+
const impl = resolvedObj.implementation ??
|
|
107
|
+
resolvedObj;
|
|
108
|
+
implementations.push({
|
|
109
|
+
id: descriptor.id,
|
|
110
|
+
descriptor,
|
|
111
|
+
implementation: impl && typeof impl === 'object' && 'getAnalytics' in impl ? impl : null,
|
|
112
|
+
error: impl && typeof impl === 'object' && 'getAnalytics' in impl ? undefined : 'Implementation not available'
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
implementations.push({
|
|
117
|
+
id: descriptor.id,
|
|
118
|
+
descriptor,
|
|
119
|
+
implementation: null,
|
|
120
|
+
error: err.message
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// If a specific source is requested, find it
|
|
125
|
+
if (sourceName) {
|
|
126
|
+
const implEntry = implementations.find((impl) => impl.id === sourceName ||
|
|
127
|
+
descriptorHasWorkerSource(impl.descriptor, sourceName));
|
|
128
|
+
if (!implEntry) {
|
|
129
|
+
ui.error(`Log source '${sourceName}' not found. Available sources: ${implementations.map((impl) => impl.id).join(', ')}`);
|
|
130
|
+
requestCLIExit(1);
|
|
131
|
+
}
|
|
132
|
+
const { implementation: logsImpl, descriptor, error } = implEntry;
|
|
133
|
+
if (!logsImpl) {
|
|
134
|
+
ui.error(`Cannot access log source '${sourceName}': ${error ?? 'Implementation not available'}`);
|
|
135
|
+
ui.info('Make sure credentials are configured in your secrets store or environment.');
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
let targetWorker;
|
|
139
|
+
if (workerName) {
|
|
140
|
+
const specific = descriptor.sources?.find(s => s.type === 'worker' && s.name === workerName);
|
|
141
|
+
if (!specific) {
|
|
142
|
+
// Worker not in the discovered inventory — pass it through to
|
|
143
|
+
// the provider anyway so the user can target ad-hoc names
|
|
144
|
+
// (workers deployed outside this workspace, sandbox names,
|
|
145
|
+
// preview environments, etc.). The provider will return a
|
|
146
|
+
// clean error if the worker truly doesn't exist.
|
|
147
|
+
const known = descriptor.sources?.map((s) => s.name).join(', ') || '(none discovered)';
|
|
148
|
+
ui.info(`Worker '${workerName}' is not in the discovered inventory (known: ${known}). Passing through to the provider.`);
|
|
149
|
+
}
|
|
150
|
+
targetWorker = workerName;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const workerSource = descriptor.sources?.find(s => s.type === 'worker');
|
|
154
|
+
targetWorker = workerSource?.name ?? sourceName;
|
|
155
|
+
}
|
|
156
|
+
if (doTail) {
|
|
157
|
+
// Real-time log streaming
|
|
158
|
+
const tailResult = await logsImpl.tailLogs(targetWorker, { status, limit });
|
|
159
|
+
ui.info(`Log tail started: ${tailResult.tailId} (worker=${targetWorker})`);
|
|
160
|
+
await streamWorkerTail({
|
|
161
|
+
url: tailResult.websocketUrl,
|
|
162
|
+
ui,
|
|
163
|
+
filterStatus: status,
|
|
164
|
+
limit
|
|
165
|
+
});
|
|
166
|
+
try {
|
|
167
|
+
await logsImpl.stopTail(targetWorker, tailResult.tailId);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
// best-effort cleanup
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else if (showAnalytics) {
|
|
174
|
+
// Analytics summary
|
|
175
|
+
const analytics = await logsImpl.getAnalytics(targetWorker, { timeStart });
|
|
176
|
+
if (output === 'json') {
|
|
177
|
+
ui.json(analytics);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
ui.info(`Analytics for ${targetWorker} (${timeStart}):`);
|
|
181
|
+
ui.table([
|
|
182
|
+
{ metric: 'Total Invocations', value: analytics.totalInvocations.toString() },
|
|
183
|
+
{ metric: 'Error Count', value: analytics.errorCount.toString() },
|
|
184
|
+
{ metric: 'Error Rate', value: `${(analytics.errorRate * 100).toFixed(2)}%` },
|
|
185
|
+
{ metric: 'Avg Duration', value: `${analytics.avgDurationMs.toFixed(2)}ms` },
|
|
186
|
+
{ metric: 'P99 Duration', value: `${analytics.p99DurationMs.toFixed(2)}ms` },
|
|
187
|
+
{ metric: 'Total CPU Time', value: `${analytics.totalCpuTimeMs}ms` }
|
|
188
|
+
], { columns: ['metric', 'value'] });
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else if (workerName) {
|
|
192
|
+
// Windowed query: a worker was named without --tail/--analytics.
|
|
193
|
+
// Cloudflare exposes only live Tail for per-event data, so we
|
|
194
|
+
// open a tail session, capture for `--window` (default 30s),
|
|
195
|
+
// then close. This is the closest thing to a batch query.
|
|
196
|
+
const tailResult = await logsImpl.tailLogs(targetWorker, { status, limit });
|
|
197
|
+
if (output !== 'json') {
|
|
198
|
+
ui.info(`Log query: ${targetWorker} (window=${windowRaw ?? '30s'}, status=${status ?? 'any'}, limit=${limit}). ` +
|
|
199
|
+
`Note: Cloudflare exposes only live Tail for per-event data — this captures errors during the window, not historical lookback.`);
|
|
200
|
+
}
|
|
201
|
+
const records = await streamWorkerTail({
|
|
202
|
+
url: tailResult.websocketUrl,
|
|
203
|
+
ui,
|
|
204
|
+
filterStatus: status,
|
|
205
|
+
limit,
|
|
206
|
+
windowMs,
|
|
207
|
+
collect: true
|
|
208
|
+
});
|
|
209
|
+
try {
|
|
210
|
+
await logsImpl.stopTail(targetWorker, tailResult.tailId);
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
// best-effort cleanup
|
|
214
|
+
}
|
|
215
|
+
const entries = records.map((rec) => ({
|
|
216
|
+
timestamp: rec.eventTimestamp ? new Date(rec.eventTimestamp).toISOString() : null,
|
|
217
|
+
outcome: rec.outcome ?? null,
|
|
218
|
+
scriptName: rec.scriptName ?? targetWorker,
|
|
219
|
+
method: rec.event?.request?.method ?? null,
|
|
220
|
+
url: rec.event?.request?.url ?? null,
|
|
221
|
+
responseStatus: rec.event?.response?.status ?? null,
|
|
222
|
+
trigger: rec.event?.cron ? `cron ${rec.event.cron}` :
|
|
223
|
+
rec.event?.rpcMethod ? `rpc ${rec.event.rpcMethod}` :
|
|
224
|
+
rec.event?.request ? 'request' : 'event',
|
|
225
|
+
logs: (rec.logs ?? []).map((l) => ({
|
|
226
|
+
level: l.level ?? 'log',
|
|
227
|
+
message: (l.message ?? []).map((m) => typeof m === 'string' ? m : (() => { try {
|
|
228
|
+
return JSON.stringify(m);
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return String(m);
|
|
232
|
+
} })()).join(' '),
|
|
233
|
+
timestamp: l.timestamp ? new Date(l.timestamp).toISOString() : null
|
|
234
|
+
})),
|
|
235
|
+
exceptions: (rec.exceptions ?? []).map((e) => ({
|
|
236
|
+
name: e.name ?? 'Error',
|
|
237
|
+
message: e.message ?? '',
|
|
238
|
+
timestamp: e.timestamp ? new Date(e.timestamp).toISOString() : null
|
|
239
|
+
}))
|
|
240
|
+
}));
|
|
241
|
+
if (output === 'json') {
|
|
242
|
+
ui.json({
|
|
243
|
+
source: descriptor.id,
|
|
244
|
+
worker: targetWorker,
|
|
245
|
+
window: windowRaw ?? '30s',
|
|
246
|
+
status: status ?? null,
|
|
247
|
+
limit,
|
|
248
|
+
capturedAt: new Date().toISOString(),
|
|
249
|
+
count: entries.length,
|
|
250
|
+
entries
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
if (entries.length === 0) {
|
|
255
|
+
ui.info(`No log entries captured in the ${windowRaw ?? '30s'} window.`);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
ui.info(`Captured ${entries.length} entries.`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
// No worker specified — show descriptor info.
|
|
264
|
+
if (output === 'json') {
|
|
265
|
+
ui.json({ descriptor });
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
ui.info(`Log source: ${descriptor.name ?? descriptor.id}`);
|
|
269
|
+
ui.info(`Adapter: ${descriptor.adapter}`);
|
|
270
|
+
ui.info(`Sources: ${descriptor.sources.length}`);
|
|
271
|
+
if (descriptor.sources.length > 0) {
|
|
272
|
+
ui.table(descriptor.sources, { columns: ['type', 'name', 'environment'] });
|
|
273
|
+
}
|
|
274
|
+
ui.info('');
|
|
275
|
+
ui.info(`To query a specific worker:`);
|
|
276
|
+
ui.info(` vibes infra logs ${descriptor.id} <worker> --status=error --window=30s --output=json`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
// List all log sources
|
|
282
|
+
const rows = [];
|
|
283
|
+
for (const impl of implementations) {
|
|
284
|
+
const descriptor = impl.descriptor;
|
|
285
|
+
const sourceCount = descriptor.sources?.length ?? 0;
|
|
286
|
+
rows.push({
|
|
287
|
+
id: impl.id,
|
|
288
|
+
name: descriptor.name ?? impl.id,
|
|
289
|
+
adapter: descriptor.adapter,
|
|
290
|
+
sources: sourceCount.toString(),
|
|
291
|
+
status: impl.error ? 'error' : 'active'
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
if (output === 'json') {
|
|
295
|
+
ui.json(rows);
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
ui.info('Available log sources:');
|
|
299
|
+
ui.table(rows, { columns: ['id', 'name', 'adapter', 'sources', 'status'] });
|
|
300
|
+
ui.info('');
|
|
301
|
+
ui.info('Usage:');
|
|
302
|
+
ui.info(' vibes infra logs <source> # Show source details');
|
|
303
|
+
ui.info(' vibes infra logs <source> <worker> # Windowed query (30s capture)');
|
|
304
|
+
ui.info(' vibes infra logs <source> <worker> --analytics # Aggregate analytics');
|
|
305
|
+
ui.info(' vibes infra logs <source> <worker> --tail # Stream logs in real-time');
|
|
306
|
+
ui.info('');
|
|
307
|
+
ui.info('Examples:');
|
|
308
|
+
ui.info(' vibes infra logs cloudflare-logs vibes-auth --status=error --window=60s --output=json');
|
|
309
|
+
ui.info(' vibes infra logs cloudflare-logs vibes-auth --analytics --timeStart=2h');
|
|
310
|
+
ui.info(' vibes infra logs cloudflare-logs vibes-auth --tail --status=error');
|
|
311
|
+
// Show errors if any
|
|
312
|
+
const errors = implementations.filter(i => i.error);
|
|
313
|
+
if (errors.length > 0) {
|
|
314
|
+
ui.info('');
|
|
315
|
+
ui.info('Errors:');
|
|
316
|
+
for (const err of errors) {
|
|
317
|
+
ui.error(` ${err.id}: ${err.error}`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
//# sourceMappingURL=infra-logs.cli-command.impl.js.map
|