@vibesdotdev/infra-generate 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/dist/cli/artifact/artifact.cli-command.descriptor.d.ts +23 -0
- package/dist/cli/artifact/artifact.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/artifact/artifact.cli-command.descriptor.js +33 -0
- package/dist/cli/artifact/artifact.cli-command.descriptor.js.map +1 -0
- package/dist/cli/artifact/artifact.cli-command.impl.d.ts +5 -0
- package/dist/cli/artifact/artifact.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/artifact/artifact.cli-command.impl.js +60 -0
- package/dist/cli/artifact/artifact.cli-command.impl.js.map +1 -0
- package/dist/cli/generate/generate.cli-command.descriptor.d.ts +30 -0
- package/dist/cli/generate/generate.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/generate/generate.cli-command.descriptor.js +25 -0
- package/dist/cli/generate/generate.cli-command.descriptor.js.map +1 -0
- package/dist/cli/generate/generate.cli-command.impl.d.ts +5 -0
- package/dist/cli/generate/generate.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/generate/generate.cli-command.impl.js +48 -0
- package/dist/cli/generate/generate.cli-command.impl.js.map +1 -0
- package/dist/cli/generate-core.d.ts +50 -0
- package/dist/cli/generate-core.d.ts.map +1 -0
- package/dist/cli/generate-core.js +124 -0
- package/dist/cli/generate-core.js.map +1 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +5 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/infra-generate.plugin.d.ts +3 -0
- package/dist/infra-generate.plugin.d.ts.map +1 -0
- package/dist/infra-generate.plugin.js +21 -0
- package/dist/infra-generate.plugin.js.map +1 -0
- package/package.json +75 -0
- package/src/cli/artifact/artifact.cli-command.descriptor.ts +33 -0
- package/src/cli/artifact/artifact.cli-command.impl.ts +67 -0
- package/src/cli/generate/generate.cli-command.descriptor.ts +25 -0
- package/src/cli/generate/generate.cli-command.impl.ts +53 -0
- package/src/cli/generate-core.ts +195 -0
- package/src/cli/index.ts +4 -0
- package/src/index.ts +29 -0
- package/src/infra-generate.plugin.ts +24 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
id: string;
|
|
3
|
+
kind: "cli/command";
|
|
4
|
+
group: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
usage: string;
|
|
8
|
+
arguments: {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
required: boolean;
|
|
12
|
+
variadic: boolean;
|
|
13
|
+
}[];
|
|
14
|
+
options: {
|
|
15
|
+
flags: string;
|
|
16
|
+
description: string;
|
|
17
|
+
}[];
|
|
18
|
+
surfaces: string[];
|
|
19
|
+
hardware: string[];
|
|
20
|
+
enabled: true;
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
|
23
|
+
//# sourceMappingURL=artifact.cli-command.descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.cli-command.descriptor.d.ts","sourceRoot":"","sources":["../../../src/cli/artifact/artifact.cli-command.descriptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAKA,wBA2BG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: vibes infra artifact
|
|
3
|
+
*/
|
|
4
|
+
import { createRuntimeAsset } from '@vibesdotdev/runtime';
|
|
5
|
+
export default createRuntimeAsset({
|
|
6
|
+
id: 'infra-generate.artifact',
|
|
7
|
+
kind: 'cli/command',
|
|
8
|
+
group: 'infra',
|
|
9
|
+
name: 'artifact',
|
|
10
|
+
description: 'List and query available artifact generators',
|
|
11
|
+
usage: 'vibes infra artifact [list|info]',
|
|
12
|
+
arguments: [
|
|
13
|
+
{
|
|
14
|
+
name: 'subcommand',
|
|
15
|
+
description: 'Subcommand (list|info)',
|
|
16
|
+
required: false,
|
|
17
|
+
variadic: false
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'id',
|
|
21
|
+
description: 'Artifact generator ID (for info subcommand)',
|
|
22
|
+
required: false,
|
|
23
|
+
variadic: false
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
options: [
|
|
27
|
+
{ flags: '-v, --verbose', description: 'Verbose output' }
|
|
28
|
+
],
|
|
29
|
+
surfaces: ['cli'],
|
|
30
|
+
hardware: ['consumer', 'cloud'],
|
|
31
|
+
enabled: true
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=artifact.cli-command.descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.cli-command.descriptor.js","sourceRoot":"","sources":["../../../src/cli/artifact/artifact.cli-command.descriptor.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,eAAe,kBAAkB,CAAC;IACjC,EAAE,EAAE,yBAAyB;IAC7B,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,8CAA8C;IAC3D,KAAK,EAAE,kCAAkC;IACzC,SAAS,EAAE;QACV;YACC,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,wBAAwB;YACrC,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,KAAK;SACf;QACD;YACC,IAAI,EAAE,IAAI;YACV,WAAW,EAAE,6CAA6C;YAC1D,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,KAAK;SACf;KACD;IACD,OAAO,EAAE;QACR,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE;KACzD;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":"artifact.cli-command.impl.d.ts","sourceRoot":"","sources":["../../../src/cli/artifact/artifact.cli-command.impl.ts"],"names":[],"mappings":";kBAOqB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;;AAD3F,wBA4DE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implementation: vibes infra artifact
|
|
3
|
+
*/
|
|
4
|
+
import { getVibesRuntime } from '@vibesdotdev/runtime';
|
|
5
|
+
export default {
|
|
6
|
+
async execute(args, opts) {
|
|
7
|
+
const runtime = getVibesRuntime();
|
|
8
|
+
const ui = (await runtime.context('cli/ui'));
|
|
9
|
+
const subcommand = args.subcommand ?? 'list';
|
|
10
|
+
const artifactId = args.id;
|
|
11
|
+
const verbose = opts.verbose === true || opts.verbose === 'true';
|
|
12
|
+
try {
|
|
13
|
+
if (subcommand === 'list') {
|
|
14
|
+
const generators = await runtime.query('infra/artifact').allWithDescriptors();
|
|
15
|
+
ui.info('\n=== Available Artifact Generators ===\n');
|
|
16
|
+
if (generators.length === 0) {
|
|
17
|
+
ui.log(' No artifact generators found.');
|
|
18
|
+
ui.log(' Make sure adapter plugins (infra-doks, infra-cloudflare, etc.) are registered.');
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
for (const { descriptor } of generators) {
|
|
22
|
+
const desc = descriptor;
|
|
23
|
+
ui.log(` ${descriptor.id}`);
|
|
24
|
+
ui.log(` Kind: ${desc.source?.kind || 'N/A'}`);
|
|
25
|
+
ui.log(` Format: ${desc.format || 'N/A'}`);
|
|
26
|
+
ui.log(` Description: ${desc.description || 'No description'}`);
|
|
27
|
+
ui.log('');
|
|
28
|
+
}
|
|
29
|
+
ui.info(`Total: ${generators.length} generators`);
|
|
30
|
+
}
|
|
31
|
+
else if (subcommand === 'info') {
|
|
32
|
+
if (!artifactId) {
|
|
33
|
+
ui.error('Error: artifact ID required');
|
|
34
|
+
ui.error('Usage: vibes infra artifact info <artifact-id>');
|
|
35
|
+
process.exitCode = 1;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const descriptors = await runtime.query('infra/artifact').withId(artifactId).descriptors();
|
|
39
|
+
if (descriptors.length === 0) {
|
|
40
|
+
ui.error(`Artifact generator not found: ${artifactId}`);
|
|
41
|
+
process.exitCode = 1;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
ui.info('=== Artifact Generator Info ===');
|
|
45
|
+
ui.info(` ID: ${artifactId}`);
|
|
46
|
+
ui.info(` Descriptor: ${JSON.stringify(descriptors[0], null, 2)}`);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
ui.error(`Unknown subcommand: ${subcommand}`);
|
|
50
|
+
ui.error('Usage: vibes infra artifact [list|info]');
|
|
51
|
+
process.exitCode = 1;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
ui.error(`Error: ${error.message}`);
|
|
56
|
+
process.exitCode = 1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=artifact.cli-command.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.cli-command.impl.js","sourceRoot":"","sources":["../../../src/cli/artifact/artifact.cli-command.impl.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,eAAe;IACd,KAAK,CAAC,OAAO,CAAC,IAA6B,EAAE,IAA6B;QACzE,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;QAClC,MAAM,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,C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@@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
id: string;
|
|
3
|
+
kind: "cli/command";
|
|
4
|
+
group: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
usage: string;
|
|
8
|
+
arguments: never[];
|
|
9
|
+
options: ({
|
|
10
|
+
flags: string;
|
|
11
|
+
description: string;
|
|
12
|
+
default: string;
|
|
13
|
+
multiple?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
flags: string;
|
|
16
|
+
description: string;
|
|
17
|
+
default?: undefined;
|
|
18
|
+
multiple?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
flags: string;
|
|
21
|
+
description: string;
|
|
22
|
+
multiple: boolean;
|
|
23
|
+
default?: undefined;
|
|
24
|
+
})[];
|
|
25
|
+
surfaces: string[];
|
|
26
|
+
hardware: string[];
|
|
27
|
+
enabled: true;
|
|
28
|
+
};
|
|
29
|
+
export default _default;
|
|
30
|
+
//# sourceMappingURL=generate.cli-command.descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.cli-command.descriptor.d.ts","sourceRoot":"","sources":["../../../src/cli/generate/generate.cli-command.descriptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,wBAmBG"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: vibes infra generate
|
|
3
|
+
*/
|
|
4
|
+
import { createRuntimeAsset } from '@vibesdotdev/runtime';
|
|
5
|
+
export default createRuntimeAsset({
|
|
6
|
+
id: 'infra-generate.run',
|
|
7
|
+
kind: 'cli/command',
|
|
8
|
+
group: 'infra',
|
|
9
|
+
name: 'generate',
|
|
10
|
+
description: 'Generate infrastructure artifacts (K8s manifests, Helm charts, wrangler configs)',
|
|
11
|
+
usage: 'vibes infra generate [options]',
|
|
12
|
+
arguments: [],
|
|
13
|
+
options: [
|
|
14
|
+
{ flags: '-o, --output <dir>', description: 'Output directory', default: './infra/generated' },
|
|
15
|
+
{ flags: '-n, --dry-run', description: 'Print what would be generated without writing' },
|
|
16
|
+
{ flags: '-t, --target <name>', description: 'Filter by artifact target', multiple: true },
|
|
17
|
+
{ flags: '-r, --resource <id>', description: 'Filter by resource ID', multiple: true },
|
|
18
|
+
{ flags: '-f, --format <format>', description: 'Filter by format (yaml|json|hcl|tar.gz)' },
|
|
19
|
+
{ flags: '-v, --verbose', description: 'Verbose output' }
|
|
20
|
+
],
|
|
21
|
+
surfaces: ['cli'],
|
|
22
|
+
hardware: ['consumer', 'cloud'],
|
|
23
|
+
enabled: true
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=generate.cli-command.descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.cli-command.descriptor.js","sourceRoot":"","sources":["../../../src/cli/generate/generate.cli-command.descriptor.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,eAAe,kBAAkB,CAAC;IACjC,EAAE,EAAE,oBAAoB;IACxB,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,kFAAkF;IAC/F,KAAK,EAAE,gCAAgC;IACvC,SAAS,EAAE,EAAE;IACb,OAAO,EAAE;QACR,EAAE,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,kBAAkB,EAAE,OAAO,EAAE,mBAAmB,EAAE;QAC9F,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,+CAA+C,EAAE;QACxF,EAAE,KAAK,EAAE,qBAAqB,EAAE,WAAW,EAAE,2BAA2B,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC1F,EAAE,KAAK,EAAE,qBAAqB,EAAE,WAAW,EAAE,uBAAuB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACtF,EAAE,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,yCAAyC,EAAE;QAC1F,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE;KACzD;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":"generate.cli-command.impl.d.ts","sourceRoot":"","sources":["../../../src/cli/generate/generate.cli-command.impl.ts"],"names":[],"mappings":";kBAQqB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;;AAD3F,wBA6CE"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implementation: vibes infra generate
|
|
3
|
+
*/
|
|
4
|
+
import { getVibesRuntime } from '@vibesdotdev/runtime';
|
|
5
|
+
import { generateArtifacts } from '../generate-core.js';
|
|
6
|
+
export default {
|
|
7
|
+
async execute(args, opts) {
|
|
8
|
+
const runtime = getVibesRuntime();
|
|
9
|
+
const ui = (await runtime.context('cli/ui'));
|
|
10
|
+
const outputDir = opts.output ?? './infra/generated';
|
|
11
|
+
const dryRun = opts.dryRun === true || opts.dryRun === 'true';
|
|
12
|
+
const targets = Array.isArray(opts.target) ? opts.target : opts.target ? [opts.target] : undefined;
|
|
13
|
+
const sourceIds = Array.isArray(opts.resource) ? opts.resource : opts.resource ? [opts.resource] : undefined;
|
|
14
|
+
const format = opts.format;
|
|
15
|
+
const verbose = opts.verbose === true || opts.verbose === 'true';
|
|
16
|
+
try {
|
|
17
|
+
const result = await generateArtifacts(runtime, {
|
|
18
|
+
outputDir,
|
|
19
|
+
dryRun,
|
|
20
|
+
target: targets,
|
|
21
|
+
sourceId: sourceIds?.[0], // TODO: support multiple source IDs
|
|
22
|
+
verbose
|
|
23
|
+
});
|
|
24
|
+
// Print summary
|
|
25
|
+
ui.info(`\n=== Generation Summary ===`);
|
|
26
|
+
ui.info(` Artifacts generated: ${result.count}`);
|
|
27
|
+
ui.info(` Errors: ${result.errors.length}`);
|
|
28
|
+
if (verbose && result.artifacts.length > 0) {
|
|
29
|
+
ui.log('\n Generated files:');
|
|
30
|
+
for (const artifact of result.artifacts) {
|
|
31
|
+
ui.log(` - ${artifact.path} (${artifact.sourceKind}/${artifact.sourceId})`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (result.errors.length > 0) {
|
|
35
|
+
ui.log('\n Errors:');
|
|
36
|
+
for (const error of result.errors) {
|
|
37
|
+
ui.error(` - ${error.sourceKind}/${error.sourceId}: ${error.error}`);
|
|
38
|
+
}
|
|
39
|
+
process.exitCode = 1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
ui.error(`Error generating artifacts: ${error.message}`);
|
|
44
|
+
process.exitCode = 1;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=generate.cli-command.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.cli-command.impl.js","sourceRoot":"","sources":["../../../src/cli/generate/generate.cli-command.impl.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAwB,MAAM,kBAAkB,CAAC;AAE3E,eAAe;IACd,KAAK,CAAC,OAAO,CAAC,IAA6B,EAAE,IAA6B;QACzE,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;QAClC,MAAM,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAc,CAAC;QAE1D,MAAM,SAAS,GAAI,IAAI,CAAC,MAAiB,IAAI,mBAAmB,CAAC;QACjE,MAAM,MAAM,GAAG,IAAI,CAAC,M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C;gBAC/B,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;oBACzC,EAAE,CAAC,GAAG,CAAC,SAAS,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,UAAU,IAAI,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAC;gBAChF,CAAC;YACF,CAAC;YAED,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC9B,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;gBACtB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;oBACnC,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;gBACzE,CAAC;gBACD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACtB,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,EAAE,CAAC,KAAK,CAAC,+BAAgC,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YACpE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACtB,CAAC;IACF,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { VibesRuntime } from '@vibesdotdev/runtime';
|
|
2
|
+
import type { RuntimeDescriptor } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
3
|
+
export interface GenerateOptions {
|
|
4
|
+
/** Output directory (default: ./infra/generated) */
|
|
5
|
+
outputDir?: string;
|
|
6
|
+
/** Dry-run mode (print to stdout, don't write) */
|
|
7
|
+
dryRun?: boolean;
|
|
8
|
+
/** Filter by artifact generator ID */
|
|
9
|
+
target?: string | string[];
|
|
10
|
+
/** Filter by source resource kind */
|
|
11
|
+
sourceKind?: string;
|
|
12
|
+
/** Filter by source resource ID */
|
|
13
|
+
sourceId?: string;
|
|
14
|
+
/** Verbose output */
|
|
15
|
+
verbose?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface GenerateResult {
|
|
18
|
+
/** Number of artifacts generated */
|
|
19
|
+
count: number;
|
|
20
|
+
/** Generated artifacts */
|
|
21
|
+
artifacts: Array<{
|
|
22
|
+
generatorId: string;
|
|
23
|
+
sourceKind?: string;
|
|
24
|
+
sourceId?: string;
|
|
25
|
+
path: string;
|
|
26
|
+
}>;
|
|
27
|
+
/** Errors encountered */
|
|
28
|
+
errors: Array<{
|
|
29
|
+
generatorId: string;
|
|
30
|
+
sourceKind?: string;
|
|
31
|
+
sourceId?: string;
|
|
32
|
+
error: string;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Generate artifacts from resource descriptors
|
|
37
|
+
*/
|
|
38
|
+
export declare function generateArtifacts(runtime: VibesRuntime, options?: GenerateOptions): Promise<GenerateResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Generation context passed to artifact generators
|
|
41
|
+
*/
|
|
42
|
+
export interface GenerationContext {
|
|
43
|
+
/** Output directory for generated artifacts */
|
|
44
|
+
outputDir: string;
|
|
45
|
+
/** Available resource descriptors */
|
|
46
|
+
resources: RuntimeDescriptor[];
|
|
47
|
+
/** Artifact generator descriptor */
|
|
48
|
+
descriptor: RuntimeDescriptor;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=generate-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-core.d.ts","sourceRoot":"","sources":["../../src/cli/generate-core.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAGjF,MAAM,WAAW,eAAe;IAC/B,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qBAAqB;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC9B,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,SAAS,EAAE,KAAK,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;KACb,CAAC,CAAC;IACH,yBAAyB;IACzB,MAAM,EAAE,KAAK,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;CACH;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACtC,OAAO,EAAE,YAAY,EACrB,OAAO,GAAE,eAAoB,GAC3B,OAAO,CAAC,cAAc,CAAC,CA+FzB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAC/B,oCAAoC;IACpC,UAAU,EAAE,iBAAiB,CAAC;CAC9B"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core artifact generation logic.
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates artifact generation by:
|
|
5
|
+
* 1. Querying runtime for artifact generators
|
|
6
|
+
* 2. Loading resource descriptors from runtime discovery
|
|
7
|
+
* 3. Calling generator.generate() for each resource
|
|
8
|
+
* 4. Writing output to disk or returning for dry-run
|
|
9
|
+
*
|
|
10
|
+
* This module is implementation-agnostic — it doesn't know what
|
|
11
|
+
* artifacts are being generated, only how to orchestrate generation.
|
|
12
|
+
*/
|
|
13
|
+
import { resolve } from 'node:path';
|
|
14
|
+
/**
|
|
15
|
+
* Generate artifacts from resource descriptors
|
|
16
|
+
*/
|
|
17
|
+
export async function generateArtifacts(runtime, options = {}) {
|
|
18
|
+
const { outputDir = './infra/generated', dryRun = false, target, sourceKind, sourceId, verbose = false } = options;
|
|
19
|
+
const result = {
|
|
20
|
+
count: 0,
|
|
21
|
+
artifacts: [],
|
|
22
|
+
errors: []
|
|
23
|
+
};
|
|
24
|
+
// Query for all artifact generators
|
|
25
|
+
const generators = await runtime.query('infra/artifact').allWithDescriptors();
|
|
26
|
+
if (verbose) {
|
|
27
|
+
console.log(`Found ${generators.length} artifact generators`);
|
|
28
|
+
}
|
|
29
|
+
// Filter by target if specified
|
|
30
|
+
let filteredGenerators = generators;
|
|
31
|
+
if (target) {
|
|
32
|
+
const targets = Array.isArray(target) ? target : [target];
|
|
33
|
+
filteredGenerators = generators.filter((g) => targets.includes(g.descriptor.id));
|
|
34
|
+
if (verbose) {
|
|
35
|
+
console.log(`Filtered to ${filteredGenerators.length} generators (targets: ${targets.join(', ')})`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Load resource descriptors from runtime discovery
|
|
39
|
+
const resources = await loadResourceDescriptors(runtime);
|
|
40
|
+
if (verbose) {
|
|
41
|
+
console.log(`Loaded ${resources.length} resource descriptors`);
|
|
42
|
+
}
|
|
43
|
+
// For each generator, resolve and call it
|
|
44
|
+
for (const { descriptor, impl } of filteredGenerators) {
|
|
45
|
+
const generatorId = descriptor.id;
|
|
46
|
+
try {
|
|
47
|
+
const generator = impl;
|
|
48
|
+
// Build generation context (implementation-specific)
|
|
49
|
+
const generationOptions = {
|
|
50
|
+
outputDir,
|
|
51
|
+
resources: resources.filter((r) => {
|
|
52
|
+
// Apply source filters if specified
|
|
53
|
+
if (sourceKind && r.kind !== sourceKind)
|
|
54
|
+
return false;
|
|
55
|
+
if (sourceId && r.id !== sourceId)
|
|
56
|
+
return false;
|
|
57
|
+
return true;
|
|
58
|
+
}),
|
|
59
|
+
descriptor
|
|
60
|
+
};
|
|
61
|
+
const output = await generator.generate(generationOptions);
|
|
62
|
+
if (dryRun) {
|
|
63
|
+
// Dry-run: just log what would be generated
|
|
64
|
+
console.log(`[DRY-RUN] Would generate ${output.path}`);
|
|
65
|
+
if (verbose) {
|
|
66
|
+
console.log(` Content preview: ${String(output.content).slice(0, 200)}...`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// Write to disk
|
|
71
|
+
await Bun.write(output.path, output.content);
|
|
72
|
+
if (verbose) {
|
|
73
|
+
console.log(` wrote ${output.path}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
result.artifacts.push({
|
|
77
|
+
generatorId,
|
|
78
|
+
sourceKind: output.metadata?.sourceKind ?? undefined,
|
|
79
|
+
sourceId: output.metadata?.sourceId ?? undefined,
|
|
80
|
+
path: output.path
|
|
81
|
+
});
|
|
82
|
+
result.count++;
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
86
|
+
result.errors.push({
|
|
87
|
+
generatorId,
|
|
88
|
+
sourceKind: undefined,
|
|
89
|
+
sourceId: undefined,
|
|
90
|
+
error: errorMessage
|
|
91
|
+
});
|
|
92
|
+
console.error(`Error generating artifact from ${generatorId}: ${errorMessage}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Load resource descriptors from runtime discovery
|
|
99
|
+
*/
|
|
100
|
+
async function loadResourceDescriptors(runtime) {
|
|
101
|
+
const allDescriptors = [];
|
|
102
|
+
// Query for all infra resource kinds
|
|
103
|
+
const infraKinds = [
|
|
104
|
+
'infra/worker',
|
|
105
|
+
'infra/web-app',
|
|
106
|
+
'infra/queue',
|
|
107
|
+
'infra/cache',
|
|
108
|
+
'infra/object-storage',
|
|
109
|
+
'infra/database',
|
|
110
|
+
'infra/git-hosting',
|
|
111
|
+
'infra/package-registry'
|
|
112
|
+
];
|
|
113
|
+
for (const kind of infraKinds) {
|
|
114
|
+
try {
|
|
115
|
+
const descriptors = await runtime.query(kind).descriptors();
|
|
116
|
+
allDescriptors.push(...descriptors);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
// Kind not registered, skip
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return allDescriptors;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=generate-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-core.js","sourceRoot":"","sources":["../../src/cli/generate-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuCpC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,OAAqB,EACrB,UAA2B,EAAE;IAE7B,MAAM,EACL,SAAS,GAAG,mBAAmB,EAC/B,MAAM,GAAG,KAAK,EACd,MAAM,EACN,UAAU,EACV,QAAQ,EACR,OAAO,GAAG,KAAK,EACf,GAAG,OAAO,CAAC;IAEZ,MAAM,MAAM,GAAmB;QAC9B,KAAK,EAAE,CAAC;QACR,SAAS,EAAE,EAAE;QACb,MAAM,EAAE,EAAE;KACV,CAAC;IAEF,oCAAoC;IACpC,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,kBAAkB,EAAE,CAAC;IAE9E,IAAI,OAAO,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,SAAS,UAAU,CAAC,MAAM,sBAAsB,CAAC,CAAC;IAC/D,CAAC;IAED,gCAAgC;IAChC,IAAI,kBAAk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aACnB,CAAC,CAAC;YACH,OAAO,CAAC,KAAK,CAAC,kCAAkC,WAAW,KAAK,YAAY,EAAE,CAAC,CAAC;QACjF,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAcD;;GAEG;AACH,KAAK,UAAU,uBAAuB,CAAC,OAAqB;IAC3D,MAAM,cAAc,GAAwB,EAAE,CAAC;IAE/C,qCAAqC;IACrC,MAAM,UAAU,GAAG;QAClB,cAAc;QACd,eAAe;QACf,aAAa;QACb,aAAa;QACb,sBAAsB;QACtB,gBAAgB;QAChB,mBAAmB;QACnB,wBAAwB;KACxB,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC/B,IAAI,CAAC;YACJ,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,IAAW,CAAC,CAAC,WAAW,EAAE,CAAC;YACnE,cAAc,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;QACrC,CAAC;QAAC,MAAM,CAAC;YACR,4BAA4B;QAC7B,CAAC;IACF,CAAC;IAED,OAAO,cAAc,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,iBAAiB,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,iBAAiB,EAAqE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vibesdotdev/infra-generate
|
|
3
|
+
*
|
|
4
|
+
* Infrastructure artifact generation package.
|
|
5
|
+
*
|
|
6
|
+
* Provides CLI commands and runtime plugin for generating infrastructure
|
|
7
|
+
* artifacts (K8s manifests, Helm charts, wrangler configs, etc.) from
|
|
8
|
+
* resource descriptors.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```bash
|
|
12
|
+
* # Generate all artifacts
|
|
13
|
+
* vibes infra generate
|
|
14
|
+
*
|
|
15
|
+
* # Generate specific artifact types
|
|
16
|
+
* vibes infra generate --target kubernetes-manifest
|
|
17
|
+
* vibes infra generate --target helm-chart
|
|
18
|
+
*
|
|
19
|
+
* # Dry-run (print to stdout)
|
|
20
|
+
* vibes infra generate --dry-run
|
|
21
|
+
*
|
|
22
|
+
* # Generate to specific output directory
|
|
23
|
+
* vibes infra generate --output ./infra/generated
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export { default as infraGeneratePlugin } from './infra-generate.plugin.ts';
|
|
27
|
+
export { generateArtifacts, type GenerateOptions, type GenerateResult } from './cli/generate-core.ts';
|
|
28
|
+
export type { ArtifactGenerator, ArtifactOutput, ArtifactDescriptor } from '@vibesdotdev/infra-core/kinds';
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACtG,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vibesdotdev/infra-generate
|
|
3
|
+
*
|
|
4
|
+
* Infrastructure artifact generation package.
|
|
5
|
+
*
|
|
6
|
+
* Provides CLI commands and runtime plugin for generating infrastructure
|
|
7
|
+
* artifacts (K8s manifests, Helm charts, wrangler configs, etc.) from
|
|
8
|
+
* resource descriptors.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```bash
|
|
12
|
+
* # Generate all artifacts
|
|
13
|
+
* vibes infra generate
|
|
14
|
+
*
|
|
15
|
+
* # Generate specific artifact types
|
|
16
|
+
* vibes infra generate --target kubernetes-manifest
|
|
17
|
+
* vibes infra generate --target helm-chart
|
|
18
|
+
*
|
|
19
|
+
* # Dry-run (print to stdout)
|
|
20
|
+
* vibes infra generate --dry-run
|
|
21
|
+
*
|
|
22
|
+
* # Generate to specific output directory
|
|
23
|
+
* vibes infra generate --output ./infra/generated
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export { default as infraGeneratePlugin } from "./infra-generate.plugin.js";
|
|
27
|
+
export { generateArtifacts } from "./cli/generate-core.js";
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAA6C,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infra-generate.plugin.d.ts","sourceRoot":"","sources":["../src/infra-generate.plugin.ts"],"names":[],"mappings":";AAYA,wBAWG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime plugin for infra-generate.
|
|
3
|
+
*
|
|
4
|
+
* Registers CLI commands under the existing 'infra' group:
|
|
5
|
+
* - vibes infra generate
|
|
6
|
+
* - vibes infra artifact
|
|
7
|
+
*/
|
|
8
|
+
import { createRuntimePlugin, loader } from '@vibesdotdev/runtime';
|
|
9
|
+
import generateCommand from "./cli/generate/generate.cli-command.descriptor.js";
|
|
10
|
+
import artifactCommand from "./cli/artifact/artifact.cli-command.descriptor.js";
|
|
11
|
+
export default createRuntimePlugin({
|
|
12
|
+
id: 'infra-generate',
|
|
13
|
+
name: 'Infra Generate',
|
|
14
|
+
description: 'Infrastructure artifact generation',
|
|
15
|
+
descriptors: [generateCommand, artifactCommand],
|
|
16
|
+
loaders: [
|
|
17
|
+
loader('infra-generate.run', () => import('./cli/generate/generate.cli-command.impl.js')),
|
|
18
|
+
loader('infra-generate.artifact', () => import('./cli/artifact/artifact.cli-command.impl.js'))
|
|
19
|
+
]
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=infra-generate.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infra-generate.plugin.js","sourceRoot":"","sources":["../src/infra-generate.plugin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,eAAe,MAAM,mDAAmD,CAAC;AAChF,OAAO,eAAe,MAAM,mDAAmD,CAAC;AAEhF,eAAe,mBAAmB,CAAC;IAClC,EAAE,EAAE,gBAAgB;IACpB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,oCAAoC;IAEjD,WAAW,EAAE,CAAC,eAAe,EAAE,eAAe,CAAC;IAE/C,OAAO,EAAE;QACR,MAAM,CAAC,oBAAoB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,6CAA6C,CAAC,CAAC;QACzF,MAAM,CAAC,yBAAyB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,6CAA6C,CAAC,CAAC;KAC9F;CACD,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vibesdotdev/infra-generate",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"bun": "./src/index.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./plugin": {
|
|
15
|
+
"types": "./dist/infra-generate.plugin.d.ts",
|
|
16
|
+
"bun": "./src/infra-generate.plugin.ts",
|
|
17
|
+
"import": "./dist/infra-generate.plugin.js",
|
|
18
|
+
"default": "./dist/infra-generate.plugin.js"
|
|
19
|
+
},
|
|
20
|
+
"./cli": {
|
|
21
|
+
"types": "./dist/cli/index.d.ts",
|
|
22
|
+
"bun": "./src/cli/index.ts",
|
|
23
|
+
"import": "./dist/cli/index.js",
|
|
24
|
+
"default": "./dist/cli/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"registry": "https://registry.npmjs.org",
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/vibesdotdev/monorepo.git",
|
|
34
|
+
"directory": "packages/infra-generate"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@vibesdotdev/runtime": "0.0.1",
|
|
38
|
+
"@vibesdotdev/cli": "0.0.1"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@vibesdotdev/infra-core": "0.0.1"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"check": "bun --bun tsc -p tsconfig.json --noEmit",
|
|
45
|
+
"build": "tsc -p tsconfig.json"
|
|
46
|
+
},
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"files": [
|
|
49
|
+
"dist",
|
|
50
|
+
"src",
|
|
51
|
+
"bin",
|
|
52
|
+
"README.md",
|
|
53
|
+
"SPEC.md",
|
|
54
|
+
"LICENSE",
|
|
55
|
+
"!src/**/__tests__/**",
|
|
56
|
+
"!src/**/__stubs__/**",
|
|
57
|
+
"!src/**/*.test.ts",
|
|
58
|
+
"!src/**/*.test.tsx",
|
|
59
|
+
"!src/**/*.spec.ts",
|
|
60
|
+
"!src/**/*.spec.tsx",
|
|
61
|
+
"!dist/**/__tests__/**",
|
|
62
|
+
"!dist/**/__stubs__/**",
|
|
63
|
+
"!dist/**/*.test.js",
|
|
64
|
+
"!dist/**/*.test.js.map",
|
|
65
|
+
"!dist/**/*.test.d.ts",
|
|
66
|
+
"!dist/**/*.test.d.ts.map",
|
|
67
|
+
"!dist/**/*.spec.js",
|
|
68
|
+
"!dist/**/*.spec.js.map",
|
|
69
|
+
"!dist/**/*.spec.d.ts",
|
|
70
|
+
"!dist/**/*.spec.d.ts.map"
|
|
71
|
+
],
|
|
72
|
+
"vibes": {
|
|
73
|
+
"visibility": "public-framework"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: vibes infra artifact
|
|
3
|
+
*/
|
|
4
|
+
import { createRuntimeAsset } from '@vibesdotdev/runtime';
|
|
5
|
+
|
|
6
|
+
export default createRuntimeAsset({
|
|
7
|
+
id: 'infra-generate.artifact',
|
|
8
|
+
kind: 'cli/command',
|
|
9
|
+
group: 'infra',
|
|
10
|
+
name: 'artifact',
|
|
11
|
+
description: 'List and query available artifact generators',
|
|
12
|
+
usage: 'vibes infra artifact [list|info]',
|
|
13
|
+
arguments: [
|
|
14
|
+
{
|
|
15
|
+
name: 'subcommand',
|
|
16
|
+
description: 'Subcommand (list|info)',
|
|
17
|
+
required: false,
|
|
18
|
+
variadic: false
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'id',
|
|
22
|
+
description: 'Artifact generator ID (for info subcommand)',
|
|
23
|
+
required: false,
|
|
24
|
+
variadic: false
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
options: [
|
|
28
|
+
{ flags: '-v, --verbose', description: 'Verbose output' }
|
|
29
|
+
],
|
|
30
|
+
surfaces: ['cli'],
|
|
31
|
+
hardware: ['consumer', 'cloud'],
|
|
32
|
+
enabled: true
|
|
33
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implementation: vibes infra artifact
|
|
3
|
+
*/
|
|
4
|
+
import { getVibesRuntime } from '@vibesdotdev/runtime';
|
|
5
|
+
import type { UIContext } from '@vibesdotdev/cli/providers';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
async execute(args: Record<string, unknown>, opts: Record<string, unknown>): Promise<void> {
|
|
9
|
+
const runtime = getVibesRuntime();
|
|
10
|
+
const ui = (await runtime.context('cli/ui')) as UIContext;
|
|
11
|
+
|
|
12
|
+
const subcommand = (args.subcommand as string) ?? 'list';
|
|
13
|
+
const artifactId = args.id as string | undefined;
|
|
14
|
+
const verbose = opts.verbose === true || opts.verbose === 'true';
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
if (subcommand === 'list') {
|
|
18
|
+
const generators = await runtime.query('infra/artifact').allWithDescriptors();
|
|
19
|
+
|
|
20
|
+
ui.info('\n=== Available Artifact Generators ===\n');
|
|
21
|
+
|
|
22
|
+
if (generators.length === 0) {
|
|
23
|
+
ui.log(' No artifact generators found.');
|
|
24
|
+
ui.log(' Make sure adapter plugins (infra-doks, infra-cloudflare, etc.) are registered.');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
for (const { descriptor } of generators) {
|
|
29
|
+
const desc = descriptor as any;
|
|
30
|
+
ui.log(` ${descriptor.id}`);
|
|
31
|
+
ui.log(` Kind: ${desc.source?.kind || 'N/A'}`);
|
|
32
|
+
ui.log(` Format: ${desc.format || 'N/A'}`);
|
|
33
|
+
ui.log(` Description: ${desc.description || 'No description'}`);
|
|
34
|
+
ui.log('');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
ui.info(`Total: ${generators.length} generators`);
|
|
38
|
+
} else if (subcommand === 'info') {
|
|
39
|
+
if (!artifactId) {
|
|
40
|
+
ui.error('Error: artifact ID required');
|
|
41
|
+
ui.error('Usage: vibes infra artifact info <artifact-id>');
|
|
42
|
+
process.exitCode = 1;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const descriptors = await runtime.query('infra/artifact').withId(artifactId).descriptors();
|
|
47
|
+
|
|
48
|
+
if (descriptors.length === 0) {
|
|
49
|
+
ui.error(`Artifact generator not found: ${artifactId}`);
|
|
50
|
+
process.exitCode = 1;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
ui.info('=== Artifact Generator Info ===');
|
|
55
|
+
ui.info(` ID: ${artifactId}`);
|
|
56
|
+
ui.info(` Descriptor: ${JSON.stringify(descriptors[0], null, 2)}`);
|
|
57
|
+
} else {
|
|
58
|
+
ui.error(`Unknown subcommand: ${subcommand}`);
|
|
59
|
+
ui.error('Usage: vibes infra artifact [list|info]');
|
|
60
|
+
process.exitCode = 1;
|
|
61
|
+
}
|
|
62
|
+
} catch (error) {
|
|
63
|
+
ui.error(`Error: ${(error as Error).message}`);
|
|
64
|
+
process.exitCode = 1;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: vibes infra generate
|
|
3
|
+
*/
|
|
4
|
+
import { createRuntimeAsset } from '@vibesdotdev/runtime';
|
|
5
|
+
|
|
6
|
+
export default createRuntimeAsset({
|
|
7
|
+
id: 'infra-generate.run',
|
|
8
|
+
kind: 'cli/command',
|
|
9
|
+
group: 'infra',
|
|
10
|
+
name: 'generate',
|
|
11
|
+
description: 'Generate infrastructure artifacts (K8s manifests, Helm charts, wrangler configs)',
|
|
12
|
+
usage: 'vibes infra generate [options]',
|
|
13
|
+
arguments: [],
|
|
14
|
+
options: [
|
|
15
|
+
{ flags: '-o, --output <dir>', description: 'Output directory', default: './infra/generated' },
|
|
16
|
+
{ flags: '-n, --dry-run', description: 'Print what would be generated without writing' },
|
|
17
|
+
{ flags: '-t, --target <name>', description: 'Filter by artifact target', multiple: true },
|
|
18
|
+
{ flags: '-r, --resource <id>', description: 'Filter by resource ID', multiple: true },
|
|
19
|
+
{ flags: '-f, --format <format>', description: 'Filter by format (yaml|json|hcl|tar.gz)' },
|
|
20
|
+
{ flags: '-v, --verbose', description: 'Verbose output' }
|
|
21
|
+
],
|
|
22
|
+
surfaces: ['cli'],
|
|
23
|
+
hardware: ['consumer', 'cloud'],
|
|
24
|
+
enabled: true
|
|
25
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implementation: vibes infra generate
|
|
3
|
+
*/
|
|
4
|
+
import { getVibesRuntime } from '@vibesdotdev/runtime';
|
|
5
|
+
import type { UIContext } from '@vibesdotdev/cli/providers';
|
|
6
|
+
import { generateArtifacts, type GenerateOptions } from '../generate-core';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
async execute(args: Record<string, unknown>, opts: Record<string, unknown>): Promise<void> {
|
|
10
|
+
const runtime = getVibesRuntime();
|
|
11
|
+
const ui = (await runtime.context('cli/ui')) as UIContext;
|
|
12
|
+
|
|
13
|
+
const outputDir = (opts.output as string) ?? './infra/generated';
|
|
14
|
+
const dryRun = opts.dryRun === true || opts.dryRun === 'true';
|
|
15
|
+
const targets = Array.isArray(opts.target) ? opts.target : opts.target ? [opts.target] : undefined;
|
|
16
|
+
const sourceIds = Array.isArray(opts.resource) ? opts.resource : opts.resource ? [opts.resource] : undefined;
|
|
17
|
+
const format = opts.format as string | undefined;
|
|
18
|
+
const verbose = opts.verbose === true || opts.verbose === 'true';
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const result = await generateArtifacts(runtime, {
|
|
22
|
+
outputDir,
|
|
23
|
+
dryRun,
|
|
24
|
+
target: targets,
|
|
25
|
+
sourceId: sourceIds?.[0], // TODO: support multiple source IDs
|
|
26
|
+
verbose
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Print summary
|
|
30
|
+
ui.info(`\n=== Generation Summary ===`);
|
|
31
|
+
ui.info(` Artifacts generated: ${result.count}`);
|
|
32
|
+
ui.info(` Errors: ${result.errors.length}`);
|
|
33
|
+
|
|
34
|
+
if (verbose && result.artifacts.length > 0) {
|
|
35
|
+
ui.log('\n Generated files:');
|
|
36
|
+
for (const artifact of result.artifacts) {
|
|
37
|
+
ui.log(` - ${artifact.path} (${artifact.sourceKind}/${artifact.sourceId})`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (result.errors.length > 0) {
|
|
42
|
+
ui.log('\n Errors:');
|
|
43
|
+
for (const error of result.errors) {
|
|
44
|
+
ui.error(` - ${error.sourceKind}/${error.sourceId}: ${error.error}`);
|
|
45
|
+
}
|
|
46
|
+
process.exitCode = 1;
|
|
47
|
+
}
|
|
48
|
+
} catch (error) {
|
|
49
|
+
ui.error(`Error generating artifacts: ${(error as Error).message}`);
|
|
50
|
+
process.exitCode = 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core artifact generation logic.
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates artifact generation by:
|
|
5
|
+
* 1. Querying runtime for artifact generators
|
|
6
|
+
* 2. Loading resource descriptors from runtime discovery
|
|
7
|
+
* 3. Calling generator.generate() for each resource
|
|
8
|
+
* 4. Writing output to disk or returning for dry-run
|
|
9
|
+
*
|
|
10
|
+
* This module is implementation-agnostic — it doesn't know what
|
|
11
|
+
* artifacts are being generated, only how to orchestrate generation.
|
|
12
|
+
*/
|
|
13
|
+
import { resolve } from 'node:path';
|
|
14
|
+
import type { VibesRuntime } from '@vibesdotdev/runtime';
|
|
15
|
+
import type { RuntimeDescriptor } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
16
|
+
import type { ArtifactGenerator, ArtifactOutput } from '@vibesdotdev/infra-core/kinds';
|
|
17
|
+
|
|
18
|
+
export interface GenerateOptions {
|
|
19
|
+
/** Output directory (default: ./infra/generated) */
|
|
20
|
+
outputDir?: string;
|
|
21
|
+
/** Dry-run mode (print to stdout, don't write) */
|
|
22
|
+
dryRun?: boolean;
|
|
23
|
+
/** Filter by artifact generator ID */
|
|
24
|
+
target?: string | string[];
|
|
25
|
+
/** Filter by source resource kind */
|
|
26
|
+
sourceKind?: string;
|
|
27
|
+
/** Filter by source resource ID */
|
|
28
|
+
sourceId?: string;
|
|
29
|
+
/** Verbose output */
|
|
30
|
+
verbose?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface GenerateResult {
|
|
34
|
+
/** Number of artifacts generated */
|
|
35
|
+
count: number;
|
|
36
|
+
/** Generated artifacts */
|
|
37
|
+
artifacts: Array<{
|
|
38
|
+
generatorId: string;
|
|
39
|
+
sourceKind?: string;
|
|
40
|
+
sourceId?: string;
|
|
41
|
+
path: string;
|
|
42
|
+
}>;
|
|
43
|
+
/** Errors encountered */
|
|
44
|
+
errors: Array<{
|
|
45
|
+
generatorId: string;
|
|
46
|
+
sourceKind?: string;
|
|
47
|
+
sourceId?: string;
|
|
48
|
+
error: string;
|
|
49
|
+
}>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Generate artifacts from resource descriptors
|
|
54
|
+
*/
|
|
55
|
+
export async function generateArtifacts(
|
|
56
|
+
runtime: VibesRuntime,
|
|
57
|
+
options: GenerateOptions = {}
|
|
58
|
+
): Promise<GenerateResult> {
|
|
59
|
+
const {
|
|
60
|
+
outputDir = './infra/generated',
|
|
61
|
+
dryRun = false,
|
|
62
|
+
target,
|
|
63
|
+
sourceKind,
|
|
64
|
+
sourceId,
|
|
65
|
+
verbose = false
|
|
66
|
+
} = options;
|
|
67
|
+
|
|
68
|
+
const result: GenerateResult = {
|
|
69
|
+
count: 0,
|
|
70
|
+
artifacts: [],
|
|
71
|
+
errors: []
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Query for all artifact generators
|
|
75
|
+
const generators = await runtime.query('infra/artifact').allWithDescriptors();
|
|
76
|
+
|
|
77
|
+
if (verbose) {
|
|
78
|
+
console.log(`Found ${generators.length} artifact generators`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Filter by target if specified
|
|
82
|
+
let filteredGenerators = generators;
|
|
83
|
+
if (target) {
|
|
84
|
+
const targets = Array.isArray(target) ? target : [target];
|
|
85
|
+
filteredGenerators = generators.filter((g) => targets.includes(g.descriptor.id));
|
|
86
|
+
if (verbose) {
|
|
87
|
+
console.log(`Filtered to ${filteredGenerators.length} generators (targets: ${targets.join(', ')})`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Load resource descriptors from runtime discovery
|
|
92
|
+
const resources = await loadResourceDescriptors(runtime);
|
|
93
|
+
|
|
94
|
+
if (verbose) {
|
|
95
|
+
console.log(`Loaded ${resources.length} resource descriptors`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// For each generator, resolve and call it
|
|
99
|
+
for (const { descriptor, impl } of filteredGenerators) {
|
|
100
|
+
const generatorId = descriptor.id;
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
const generator = impl as ArtifactGenerator;
|
|
104
|
+
|
|
105
|
+
// Build generation context (implementation-specific)
|
|
106
|
+
const generationOptions: GenerationContext = {
|
|
107
|
+
outputDir,
|
|
108
|
+
resources: resources.filter((r) => {
|
|
109
|
+
// Apply source filters if specified
|
|
110
|
+
if (sourceKind && r.kind !== sourceKind) return false;
|
|
111
|
+
if (sourceId && r.id !== sourceId) return false;
|
|
112
|
+
return true;
|
|
113
|
+
}),
|
|
114
|
+
descriptor
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const output = await generator.generate(generationOptions);
|
|
118
|
+
|
|
119
|
+
if (dryRun) {
|
|
120
|
+
// Dry-run: just log what would be generated
|
|
121
|
+
console.log(`[DRY-RUN] Would generate ${output.path}`);
|
|
122
|
+
if (verbose) {
|
|
123
|
+
console.log(` Content preview: ${String(output.content).slice(0, 200)}...`);
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
// Write to disk
|
|
127
|
+
await Bun.write(output.path, output.content);
|
|
128
|
+
if (verbose) {
|
|
129
|
+
console.log(` wrote ${output.path}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
result.artifacts.push({
|
|
134
|
+
generatorId,
|
|
135
|
+
sourceKind: (output.metadata?.sourceKind as string) ?? undefined,
|
|
136
|
+
sourceId: (output.metadata?.sourceId as string) ?? undefined,
|
|
137
|
+
path: output.path
|
|
138
|
+
});
|
|
139
|
+
result.count++;
|
|
140
|
+
} catch (error) {
|
|
141
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
142
|
+
result.errors.push({
|
|
143
|
+
generatorId,
|
|
144
|
+
sourceKind: undefined,
|
|
145
|
+
sourceId: undefined,
|
|
146
|
+
error: errorMessage
|
|
147
|
+
});
|
|
148
|
+
console.error(`Error generating artifact from ${generatorId}: ${errorMessage}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Generation context passed to artifact generators
|
|
157
|
+
*/
|
|
158
|
+
export interface GenerationContext {
|
|
159
|
+
/** Output directory for generated artifacts */
|
|
160
|
+
outputDir: string;
|
|
161
|
+
/** Available resource descriptors */
|
|
162
|
+
resources: RuntimeDescriptor[];
|
|
163
|
+
/** Artifact generator descriptor */
|
|
164
|
+
descriptor: RuntimeDescriptor;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Load resource descriptors from runtime discovery
|
|
169
|
+
*/
|
|
170
|
+
async function loadResourceDescriptors(runtime: VibesRuntime): Promise<RuntimeDescriptor[]> {
|
|
171
|
+
const allDescriptors: RuntimeDescriptor[] = [];
|
|
172
|
+
|
|
173
|
+
// Query for all infra resource kinds
|
|
174
|
+
const infraKinds = [
|
|
175
|
+
'infra/worker',
|
|
176
|
+
'infra/web-app',
|
|
177
|
+
'infra/queue',
|
|
178
|
+
'infra/cache',
|
|
179
|
+
'infra/object-storage',
|
|
180
|
+
'infra/database',
|
|
181
|
+
'infra/git-hosting',
|
|
182
|
+
'infra/package-registry'
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
for (const kind of infraKinds) {
|
|
186
|
+
try {
|
|
187
|
+
const descriptors = await runtime.query(kind as any).descriptors();
|
|
188
|
+
allDescriptors.push(...descriptors);
|
|
189
|
+
} catch {
|
|
190
|
+
// Kind not registered, skip
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return allDescriptors;
|
|
195
|
+
}
|
package/src/cli/index.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vibesdotdev/infra-generate
|
|
3
|
+
*
|
|
4
|
+
* Infrastructure artifact generation package.
|
|
5
|
+
*
|
|
6
|
+
* Provides CLI commands and runtime plugin for generating infrastructure
|
|
7
|
+
* artifacts (K8s manifests, Helm charts, wrangler configs, etc.) from
|
|
8
|
+
* resource descriptors.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```bash
|
|
12
|
+
* # Generate all artifacts
|
|
13
|
+
* vibes infra generate
|
|
14
|
+
*
|
|
15
|
+
* # Generate specific artifact types
|
|
16
|
+
* vibes infra generate --target kubernetes-manifest
|
|
17
|
+
* vibes infra generate --target helm-chart
|
|
18
|
+
*
|
|
19
|
+
* # Dry-run (print to stdout)
|
|
20
|
+
* vibes infra generate --dry-run
|
|
21
|
+
*
|
|
22
|
+
* # Generate to specific output directory
|
|
23
|
+
* vibes infra generate --output ./infra/generated
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export { default as infraGeneratePlugin } from './infra-generate.plugin.ts';
|
|
28
|
+
export { generateArtifacts, type GenerateOptions, type GenerateResult } from './cli/generate-core.ts';
|
|
29
|
+
export type { ArtifactGenerator, ArtifactOutput, ArtifactDescriptor } from '@vibesdotdev/infra-core/kinds';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime plugin for infra-generate.
|
|
3
|
+
*
|
|
4
|
+
* Registers CLI commands under the existing 'infra' group:
|
|
5
|
+
* - vibes infra generate
|
|
6
|
+
* - vibes infra artifact
|
|
7
|
+
*/
|
|
8
|
+
import { createRuntimePlugin, loader } from '@vibesdotdev/runtime';
|
|
9
|
+
|
|
10
|
+
import generateCommand from './cli/generate/generate.cli-command.descriptor.ts';
|
|
11
|
+
import artifactCommand from './cli/artifact/artifact.cli-command.descriptor.ts';
|
|
12
|
+
|
|
13
|
+
export default createRuntimePlugin({
|
|
14
|
+
id: 'infra-generate',
|
|
15
|
+
name: 'Infra Generate',
|
|
16
|
+
description: 'Infrastructure artifact generation',
|
|
17
|
+
|
|
18
|
+
descriptors: [generateCommand, artifactCommand],
|
|
19
|
+
|
|
20
|
+
loaders: [
|
|
21
|
+
loader('infra-generate.run', () => import('./cli/generate/generate.cli-command.impl.js')),
|
|
22
|
+
loader('infra-generate.artifact', () => import('./cli/artifact/artifact.cli-command.impl.js'))
|
|
23
|
+
]
|
|
24
|
+
});
|