@afroze9/terrastudio-cli 0.42.2 → 0.47.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,192 +0,0 @@
1
- import { Command } from 'commander';
2
- import { storage, toLoadedProject } from '../platform/node-io.js';
3
- import { Project } from '@terrastudio/project';
4
- import { spawn } from 'node:child_process';
5
- import { existsSync } from 'node:fs';
6
- import path from 'node:path';
7
- /** Resolve the terraform/ directory for a project path. */
8
- function tfDir(projectPath) {
9
- return path.join(projectPath, 'terraform');
10
- }
11
- /**
12
- * Spawn terraform with the given args in the terraform/ directory.
13
- * Streams stdout/stderr directly to the terminal.
14
- * Rejects with the exit code if non-zero.
15
- */
16
- function runTerraform(cwd, args, allowedCodes = [0]) {
17
- return new Promise((resolve, reject) => {
18
- const proc = spawn('terraform', args, {
19
- cwd,
20
- stdio: 'inherit',
21
- shell: process.platform === 'win32',
22
- });
23
- proc.on('close', (code) => {
24
- if (code !== null && allowedCodes.includes(code))
25
- resolve();
26
- else
27
- reject(new Error(`terraform exited with code ${code}`));
28
- });
29
- proc.on('error', (err) => {
30
- if (err.code === 'ENOENT') {
31
- reject(new Error('terraform binary not found. Install Terraform: https://developer.hashicorp.com/terraform/install'));
32
- }
33
- else {
34
- reject(err);
35
- }
36
- });
37
- });
38
- }
39
- /** Check that terraform files exist in the project. Exits with an error if not. */
40
- async function requireTerraformFiles(projectPath) {
41
- const files = await storage.readTerraformFiles(projectPath);
42
- if (Object.keys(files).length === 0) {
43
- console.error('No Terraform files found in terraform/ directory.');
44
- console.error(`Run first: tstudio hcl generate "${projectPath}"`);
45
- process.exit(1);
46
- }
47
- }
48
- export function makeTerraformCommand() {
49
- const cmd = new Command('terraform').alias('tf').description('Run Terraform commands against a project');
50
- // ─── init ──────────────────────────────────────────────────────────────────
51
- cmd
52
- .command('init <path>')
53
- .description('Run terraform init in the project\'s terraform/ directory')
54
- .action(async (projectPath) => {
55
- const dir = tfDir(projectPath);
56
- if (!existsSync(dir)) {
57
- console.error(`terraform/ directory not found at: ${dir}`);
58
- console.error('Run `tstudio hcl generate <path>` first.');
59
- process.exit(1);
60
- }
61
- await runTerraform(dir, ['init']).catch((err) => {
62
- console.error(err.message);
63
- process.exit(1);
64
- });
65
- });
66
- // ─── validate ──────────────────────────────────────────────────────────────
67
- cmd
68
- .command('validate <path>')
69
- .description('Run terraform validate in the project\'s terraform/ directory')
70
- .action(async (projectPath) => {
71
- const dir = tfDir(projectPath);
72
- await runTerraform(dir, ['validate']).catch((err) => {
73
- console.error(err.message);
74
- process.exit(1);
75
- });
76
- });
77
- // ─── plan ──────────────────────────────────────────────────────────────────
78
- cmd
79
- .command('plan <path>')
80
- .description('Run terraform plan')
81
- .option('--out <planFile>', 'Save plan to file (relative to terraform/ dir)')
82
- .action(async (projectPath, options) => {
83
- await requireTerraformFiles(projectPath);
84
- const dir = tfDir(projectPath);
85
- const args = ['plan'];
86
- if (options.out)
87
- args.push('-out', options.out);
88
- // Exit code 2 = changes present (not an error)
89
- await runTerraform(dir, args, [0, 2]).catch((err) => {
90
- console.error(err.message);
91
- process.exit(1);
92
- });
93
- });
94
- // ─── apply ─────────────────────────────────────────────────────────────────
95
- cmd
96
- .command('apply <path>')
97
- .description('Run terraform apply (auto-approves)')
98
- .option('--plan <planFile>', 'Apply a saved plan file instead of planning inline')
99
- .action(async (projectPath, options) => {
100
- await requireTerraformFiles(projectPath);
101
- const dir = tfDir(projectPath);
102
- const args = options.plan
103
- ? ['apply', '-auto-approve', options.plan]
104
- : ['apply', '-auto-approve'];
105
- await runTerraform(dir, args).catch((err) => {
106
- console.error(err.message);
107
- process.exit(1);
108
- });
109
- });
110
- // ─── destroy ───────────────────────────────────────────────────────────────
111
- cmd
112
- .command('destroy <path>')
113
- .description('Run terraform destroy (auto-approves)')
114
- .action(async (projectPath) => {
115
- const dir = tfDir(projectPath);
116
- await runTerraform(dir, ['destroy', '-auto-approve']).catch((err) => {
117
- console.error(err.message);
118
- process.exit(1);
119
- });
120
- });
121
- // ─── status ────────────────────────────────────────────────────────────────
122
- cmd
123
- .command('status <path>')
124
- .description('Show deployment status by reading terraform state (terraform show -json)')
125
- .action(async (projectPath) => {
126
- const stored = await storage.loadProject(projectPath);
127
- const project = Project.fromLoaded(toLoadedProject(stored));
128
- const dir = tfDir(projectPath);
129
- // Capture JSON output from terraform show
130
- const output = await new Promise((resolve, reject) => {
131
- const chunks = [];
132
- const proc = spawn('terraform', ['show', '-json'], {
133
- cwd: dir,
134
- shell: process.platform === 'win32',
135
- });
136
- proc.stdout.on('data', (d) => chunks.push(d));
137
- proc.stderr.on('data', (d) => process.stderr.write(d));
138
- proc.on('close', (code) => {
139
- if (code === 0)
140
- resolve(Buffer.concat(chunks).toString('utf8'));
141
- else
142
- reject(new Error(`terraform show exited with code ${code}`));
143
- });
144
- proc.on('error', (err) => {
145
- if (err.code === 'ENOENT') {
146
- reject(new Error('terraform binary not found.'));
147
- }
148
- else {
149
- reject(err);
150
- }
151
- });
152
- }).catch((err) => {
153
- console.error(err.message);
154
- process.exit(1);
155
- });
156
- let state;
157
- try {
158
- state = JSON.parse(output);
159
- }
160
- catch {
161
- console.log('No state found (project not yet deployed).');
162
- return;
163
- }
164
- const values = state['values']?.['root_module'];
165
- const tfResources = values?.['resources'] ?? [];
166
- if (tfResources.length === 0) {
167
- console.log('No deployed resources found in state.');
168
- return;
169
- }
170
- // Build a map of terraform address → node label for display
171
- const addressToLabel = new Map();
172
- for (const node of project.nodes) {
173
- if (node.data.terraformName && node.type && !node.type.startsWith('_')) {
174
- const tfType = node.type.split('/').pop() ?? node.type;
175
- const addr = `${tfType}.${node.data.terraformName}`;
176
- addressToLabel.set(addr, node.data.label ?? node.data.terraformName ?? addr);
177
- }
178
- }
179
- const colAddr = 'Address'.padEnd(55);
180
- const colStatus = 'Status';
181
- console.log(`${colAddr} ${colStatus}`);
182
- console.log(`${'-'.repeat(55)} ${'-'.repeat(10)}`);
183
- for (const res of tfResources) {
184
- const addr = String(res['address'] ?? '');
185
- const label = addressToLabel.get(addr);
186
- const display = label ? `${addr} (${label})` : addr;
187
- console.log(`${display.padEnd(55)} deployed`);
188
- }
189
- });
190
- return cmd;
191
- }
192
- //# sourceMappingURL=terraform.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"terraform.js","sourceRoot":"","sources":["../../src/commands/terraform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,2DAA2D;AAC3D,SAAS,KAAK,CAAC,WAAmB;IAChC,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAC7C,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,GAAW,EAAE,IAAc,EAAE,eAAyB,CAAC,CAAC,CAAC;IAC7E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,EAAE,IAAI,EAAE;YACpC,GAAG;YACH,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO;SACpC,CAAC,CAAC;QACH,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACxB,IAAI,IAAI,KAAK,IAAI,IAAI,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAAE,OAAO,EAAE,CAAC;;gBACvD,MAAM,CAAC,IAAI,KAAK,CAAC,8BAA8B,IAAI,EAAE,CAAC,CAAC,CAAC;QAC/D,CAAC,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AC;YACpD,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC;QACjD,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export { storage, loadValidator, toLoadedProject } from './platform/node-io.js';
2
- export { NodeProjectStorage } from '@terrastudio/platform-node';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC"}
package/dist/index.js DELETED
@@ -1,4 +0,0 @@
1
- // Public API for programmatic use of the CLI's I/O layer
2
- export { storage, loadValidator, toLoadedProject } from './platform/node-io.js';
3
- export { NodeProjectStorage } from '@terrastudio/platform-node';
4
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -1,29 +0,0 @@
1
- /**
2
- * CLI-specific platform utilities.
3
- *
4
- * Project file I/O is handled by NodeProjectStorage from @terrastudio/platform-node.
5
- * This module provides the shared storage instance and CLI-only utilities such as
6
- * loadRegistry / loadValidator (plugin loading — desktop uses a reactive registry instead).
7
- */
8
- import { NodeProjectStorage } from '@terrastudio/platform-node';
9
- import { PluginRegistry } from '@terrastudio/core';
10
- import type { ProviderId, StoredProjectData } from '@terrastudio/types';
11
- import type { ProjectValidatorContext, LoadedProject } from '@terrastudio/project';
12
- /** Shared storage instance for all CLI commands. */
13
- export declare const storage: NodeProjectStorage;
14
- /**
15
- * Convert a StoredProjectData (from IProjectStorage) to LoadedProject (for Project.fromLoaded).
16
- * The projectConfig field is cast — the CLI trusts that on-disk data matches the expected shape.
17
- */
18
- export declare function toLoadedProject(stored: StoredProjectData): LoadedProject;
19
- /**
20
- * Load plugins for the given providers and return the fully loaded PluginRegistry.
21
- * Use this when you need the registry for HCL generation (connectionRules, schemas, pipeline).
22
- */
23
- export declare function loadRegistry(providerIds: ProviderId[]): Promise<PluginRegistry>;
24
- /**
25
- * Load plugins for the given providers and return a ProjectValidatorContext.
26
- * Use this for mutation validation (addNode, addEdge, moveNode).
27
- */
28
- export declare function loadValidator(providerIds: ProviderId[]): Promise<ProjectValidatorContext>;
29
- //# sourceMappingURL=node-io.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-io.d.ts","sourceRoot":"","sources":["../../src/platform/node-io.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAqB,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAkB,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,KAAK,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEnF,oDAAoD;AACpD,eAAO,MAAM,OAAO,oBAA2B,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,iBAAiB,GAAG,aAAa,CAExE;AAqBD;;;GAGG;AACH,wBAAsB,YAAY,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAKrF;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAQ/F"}
@@ -1,61 +0,0 @@
1
- /**
2
- * CLI-specific platform utilities.
3
- *
4
- * Project file I/O is handled by NodeProjectStorage from @terrastudio/platform-node.
5
- * This module provides the shared storage instance and CLI-only utilities such as
6
- * loadRegistry / loadValidator (plugin loading — desktop uses a reactive registry instead).
7
- */
8
- import { NodeProjectStorage } from '@terrastudio/platform-node';
9
- import { PluginRegistry, EdgeRuleValidator } from '@terrastudio/core';
10
- /** Shared storage instance for all CLI commands. */
11
- export const storage = new NodeProjectStorage();
12
- /**
13
- * Convert a StoredProjectData (from IProjectStorage) to LoadedProject (for Project.fromLoaded).
14
- * The projectConfig field is cast — the CLI trusts that on-disk data matches the expected shape.
15
- */
16
- export function toLoadedProject(stored) {
17
- return stored;
18
- }
19
- /**
20
- * Register lazy plugin loaders for the given provider IDs onto a PluginRegistry.
21
- */
22
- function registerPlugins(registry, providerIds) {
23
- for (const providerId of providerIds) {
24
- if (providerId === 'azurerm') {
25
- registry.registerLazyPlugin('azurerm', () => import('@terrastudio/plugin-azure-networking'));
26
- registry.registerLazyPlugin('azurerm', () => import('@terrastudio/plugin-azure-compute'));
27
- registry.registerLazyPlugin('azurerm', () => import('@terrastudio/plugin-azure-storage'));
28
- registry.registerLazyPlugin('azurerm', () => import('@terrastudio/plugin-azure-database'));
29
- registry.registerLazyPlugin('azurerm', () => import('@terrastudio/plugin-azure-monitoring'));
30
- registry.registerLazyPlugin('azurerm', () => import('@terrastudio/plugin-azure-security'));
31
- }
32
- else if (providerId === 'aws') {
33
- registry.registerLazyPlugin('aws', () => import('@terrastudio/plugin-aws-networking'));
34
- registry.registerLazyPlugin('aws', () => import('@terrastudio/plugin-aws-compute'));
35
- }
36
- }
37
- }
38
- /**
39
- * Load plugins for the given providers and return the fully loaded PluginRegistry.
40
- * Use this when you need the registry for HCL generation (connectionRules, schemas, pipeline).
41
- */
42
- export async function loadRegistry(providerIds) {
43
- const registry = new PluginRegistry();
44
- registerPlugins(registry, providerIds);
45
- await registry.loadPluginsForProviders(providerIds);
46
- return registry;
47
- }
48
- /**
49
- * Load plugins for the given providers and return a ProjectValidatorContext.
50
- * Use this for mutation validation (addNode, addEdge, moveNode).
51
- */
52
- export async function loadValidator(providerIds) {
53
- const registry = await loadRegistry(providerIds);
54
- const rules = registry.getConnectionRules();
55
- const edgeValidator = new EdgeRuleValidator(rules);
56
- return {
57
- getSchema: (typeId) => registry.getResourceSchema(typeId),
58
- edgeValidator,
59
- };
60
- }
61
- //# sourceMappingURL=node-io.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-io.js","sourceRoot":"","sources":["../../src/platform/node-io.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAItE,oDAAoD;AACpD,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,kBAAkB,EAAE,CAAC;AAEhD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,MAAyB;IACvD,OAAO,MAAkC,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,QAAwB,EAAE,WAAyB;IAC1E,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,QAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,sCAAsC,CAAC,CAAC,CAAC;YAC7F,QAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,mCAAmC,CAAC,CAAC,CAAC;YAC1F,QAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,mCAAmC,CAAC,CAAC,CAAC;YAC1F,QAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,oCAAoC,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