tfts 0.3.3 → 0.3.4

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.
Files changed (52) hide show
  1. package/README.md +9 -3
  2. package/dist/cli/commands/deploy.d.ts +72 -0
  3. package/dist/cli/commands/deploy.d.ts.map +1 -0
  4. package/dist/cli/commands/deploy.js +42 -0
  5. package/dist/cli/commands/deploy.js.map +1 -0
  6. package/dist/cli/commands/destroy.d.ts +71 -0
  7. package/dist/cli/commands/destroy.d.ts.map +1 -0
  8. package/dist/cli/commands/destroy.js +41 -0
  9. package/dist/cli/commands/destroy.js.map +1 -0
  10. package/dist/cli/commands/diff.d.ts +16 -0
  11. package/dist/cli/commands/diff.d.ts.map +1 -1
  12. package/dist/cli/commands/diff.js +10 -0
  13. package/dist/cli/commands/diff.js.map +1 -1
  14. package/dist/cli/commands/force-unlock.d.ts +50 -0
  15. package/dist/cli/commands/force-unlock.d.ts.map +1 -0
  16. package/dist/cli/commands/force-unlock.js +28 -0
  17. package/dist/cli/commands/force-unlock.js.map +1 -0
  18. package/dist/cli/commands/list.d.ts +53 -0
  19. package/dist/cli/commands/list.d.ts.map +1 -0
  20. package/dist/cli/commands/list.js +30 -0
  21. package/dist/cli/commands/list.js.map +1 -0
  22. package/dist/cli/commands/output.d.ts +63 -0
  23. package/dist/cli/commands/output.d.ts.map +1 -0
  24. package/dist/cli/commands/output.js +36 -0
  25. package/dist/cli/commands/output.js.map +1 -0
  26. package/dist/cli/deploy.d.ts +11 -0
  27. package/dist/cli/deploy.d.ts.map +1 -0
  28. package/dist/cli/deploy.js +76 -0
  29. package/dist/cli/deploy.js.map +1 -0
  30. package/dist/cli/destroy.d.ts +11 -0
  31. package/dist/cli/destroy.d.ts.map +1 -0
  32. package/dist/cli/destroy.js +76 -0
  33. package/dist/cli/destroy.js.map +1 -0
  34. package/dist/cli/diff.d.ts +2 -0
  35. package/dist/cli/diff.d.ts.map +1 -1
  36. package/dist/cli/diff.js +10 -1
  37. package/dist/cli/diff.js.map +1 -1
  38. package/dist/cli/force-unlock.d.ts +9 -0
  39. package/dist/cli/force-unlock.d.ts.map +1 -0
  40. package/dist/cli/force-unlock.js +54 -0
  41. package/dist/cli/force-unlock.js.map +1 -0
  42. package/dist/cli/list.d.ts +8 -0
  43. package/dist/cli/list.d.ts.map +1 -0
  44. package/dist/cli/list.js +34 -0
  45. package/dist/cli/list.js.map +1 -0
  46. package/dist/cli/main.js +16 -2
  47. package/dist/cli/main.js.map +1 -1
  48. package/dist/cli/output.d.ts +10 -0
  49. package/dist/cli/output.d.ts.map +1 -0
  50. package/dist/cli/output.js +71 -0
  51. package/dist/cli/output.js.map +1 -0
  52. package/package.json +1 -1
package/README.md CHANGED
@@ -5,7 +5,7 @@ A TypeScript SDK for defining Terraform infrastructure as code. Drop-in replacem
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- bun add tfts
8
+ npm install tfts
9
9
  ```
10
10
 
11
11
  ## Quick Start
@@ -25,7 +25,7 @@ Create `cdktf.json` in your project root:
25
25
  ### Generate provider bindings
26
26
 
27
27
  ```bash
28
- bunx tfts get
28
+ npx tfts get
29
29
  ```
30
30
 
31
31
  ### Define your infrastructure
@@ -71,7 +71,7 @@ app.synth();
71
71
  ### Synthesize and deploy
72
72
 
73
73
  ```bash
74
- bunx tfts synth
74
+ npx tfts synth
75
75
  cd cdktf.out/stacks/my-stack
76
76
  terraform init
77
77
  terraform apply
@@ -83,6 +83,12 @@ terraform apply
83
83
  |---------|-------------|
84
84
  | `tfts get` | Generate provider bindings from `cdktf.json` |
85
85
  | `tfts synth` | Synthesize Terraform JSON configuration |
86
+ | `tfts diff` | Show planned changes (terraform plan) |
87
+ | `tfts deploy` | Deploy the stack (terraform apply) |
88
+ | `tfts destroy` | Destroy the stack (terraform destroy) |
89
+ | `tfts output` | Show stack outputs (terraform output) |
90
+ | `tfts list` | List all stacks |
91
+ | `tfts force-unlock` | Release a stuck state lock |
86
92
 
87
93
  ## Core Concepts
88
94
 
@@ -0,0 +1,72 @@
1
+ export declare const deployCommand: import("cleye").Command<{
2
+ name: "deploy";
3
+ alias: "apply";
4
+ help: {
5
+ description: string;
6
+ };
7
+ parameters: "[stack]"[];
8
+ flags: {
9
+ app: {
10
+ type: StringConstructor;
11
+ description: string;
12
+ };
13
+ output: {
14
+ type: StringConstructor;
15
+ description: string;
16
+ };
17
+ skipSynth: {
18
+ type: BooleanConstructor;
19
+ description: string;
20
+ };
21
+ autoApprove: {
22
+ type: BooleanConstructor;
23
+ description: string;
24
+ };
25
+ target: {
26
+ type: [StringConstructor];
27
+ description: string;
28
+ };
29
+ };
30
+ }, {
31
+ command: "deploy";
32
+ } & import("cleye").TypeFlag<{
33
+ app: {
34
+ type: StringConstructor;
35
+ description: string;
36
+ };
37
+ output: {
38
+ type: StringConstructor;
39
+ description: string;
40
+ };
41
+ skipSynth: {
42
+ type: BooleanConstructor;
43
+ description: string;
44
+ };
45
+ autoApprove: {
46
+ type: BooleanConstructor;
47
+ description: string;
48
+ };
49
+ target: {
50
+ type: [StringConstructor];
51
+ description: string;
52
+ };
53
+ } & {
54
+ help: BooleanConstructor;
55
+ }> & {
56
+ _: {
57
+ stack: string | undefined;
58
+ };
59
+ showHelp: (options?: {
60
+ version?: string;
61
+ description?: string;
62
+ usage?: false | string | string[];
63
+ examples?: string | string[];
64
+ render?: (nodes: {
65
+ id?: string;
66
+ type: keyof import("cleye").Renderers;
67
+ data: any;
68
+ }[], renderers: import("cleye").Renderers) => string;
69
+ }) => void;
70
+ showVersion: () => void;
71
+ }>;
72
+ //# sourceMappingURL=deploy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/deploy.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA0CmoM,CAAC;;;;;;;;;;;;EAD7pM,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { command } from "cleye";
2
+ import { deploy } from "../deploy.js";
3
+ export const deployCommand = command({
4
+ name: "deploy",
5
+ alias: "apply",
6
+ help: {
7
+ description: "Deploy the given stack (terraform apply)",
8
+ },
9
+ parameters: ["[stack]"],
10
+ flags: {
11
+ app: {
12
+ type: String,
13
+ description: "Command to run the app",
14
+ },
15
+ output: {
16
+ type: String,
17
+ description: "Output directory (default: cdktf.out)",
18
+ },
19
+ skipSynth: {
20
+ type: Boolean,
21
+ description: "Skip synthesis before deploy",
22
+ },
23
+ autoApprove: {
24
+ type: Boolean,
25
+ description: "Skip interactive approval",
26
+ },
27
+ target: {
28
+ type: [String],
29
+ description: "Target specific resource (can be used multiple times)",
30
+ },
31
+ },
32
+ }, async (argv) => {
33
+ await deploy({
34
+ stack: argv._.stack,
35
+ app: argv.flags.app,
36
+ output: argv.flags.output,
37
+ skipSynth: argv.flags.skipSynth,
38
+ autoApprove: argv.flags.autoApprove,
39
+ target: argv.flags.target,
40
+ });
41
+ });
42
+ //# sourceMappingURL=deploy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../../src/cli/commands/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAClC;IACE,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,OAAO;IACd,IAAI,EAAE;QACJ,WAAW,EAAE,0CAA0C;KACxD;IACD,UAAU,EAAE,CAAC,SAAS,CAAC;IACvB,KAAK,EAAE;QACL,GAAG,EAAE;YACH,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,wBAAwB;SACtC;QACD,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,uCAAuC;SACrD;QACD,SAAS,EAAE;YACT,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,8BAA8B;SAC5C;QACD,WAAW,EAAE;YACX,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,2BAA2B;SACzC;QACD,MAAM,EAAE;YACN,IAAI,EAAE,CAAC,MAAM,CAAC;YACd,WAAW,EAAE,uDAAuD;SACrE;KACF;CACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;IACb,MAAM,MAAM,CAAC;QACX,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK;QACnB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG;QACnB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;QACzB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;QAC/B,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;QACnC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;KAC1B,CAAC,CAAC;AACL,CAAC,CACF,CAAC"}
@@ -0,0 +1,71 @@
1
+ export declare const destroyCommand: import("cleye").Command<{
2
+ name: "destroy";
3
+ help: {
4
+ description: string;
5
+ };
6
+ parameters: "[stack]"[];
7
+ flags: {
8
+ app: {
9
+ type: StringConstructor;
10
+ description: string;
11
+ };
12
+ output: {
13
+ type: StringConstructor;
14
+ description: string;
15
+ };
16
+ skipSynth: {
17
+ type: BooleanConstructor;
18
+ description: string;
19
+ };
20
+ autoApprove: {
21
+ type: BooleanConstructor;
22
+ description: string;
23
+ };
24
+ target: {
25
+ type: [StringConstructor];
26
+ description: string;
27
+ };
28
+ };
29
+ }, {
30
+ command: "destroy";
31
+ } & import("cleye").TypeFlag<{
32
+ app: {
33
+ type: StringConstructor;
34
+ description: string;
35
+ };
36
+ output: {
37
+ type: StringConstructor;
38
+ description: string;
39
+ };
40
+ skipSynth: {
41
+ type: BooleanConstructor;
42
+ description: string;
43
+ };
44
+ autoApprove: {
45
+ type: BooleanConstructor;
46
+ description: string;
47
+ };
48
+ target: {
49
+ type: [StringConstructor];
50
+ description: string;
51
+ };
52
+ } & {
53
+ help: BooleanConstructor;
54
+ }> & {
55
+ _: {
56
+ stack: string | undefined;
57
+ };
58
+ showHelp: (options?: {
59
+ version?: string;
60
+ description?: string;
61
+ usage?: false | string | string[];
62
+ examples?: string | string[];
63
+ render?: (nodes: {
64
+ id?: string;
65
+ type: keyof import("cleye").Renderers;
66
+ data: any;
67
+ }[], renderers: import("cleye").Renderers) => string;
68
+ }) => void;
69
+ showVersion: () => void;
70
+ }>;
71
+ //# sourceMappingURL=destroy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/destroy.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAyC6oM,CAAC;;;;;;;;;;;;EADxqM,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { command } from "cleye";
2
+ import { destroy } from "../destroy.js";
3
+ export const destroyCommand = command({
4
+ name: "destroy",
5
+ help: {
6
+ description: "Destroy the given stack (terraform destroy)",
7
+ },
8
+ parameters: ["[stack]"],
9
+ flags: {
10
+ app: {
11
+ type: String,
12
+ description: "Command to run the app",
13
+ },
14
+ output: {
15
+ type: String,
16
+ description: "Output directory (default: cdktf.out)",
17
+ },
18
+ skipSynth: {
19
+ type: Boolean,
20
+ description: "Skip synthesis before destroy",
21
+ },
22
+ autoApprove: {
23
+ type: Boolean,
24
+ description: "Skip interactive approval",
25
+ },
26
+ target: {
27
+ type: [String],
28
+ description: "Target specific resource (can be used multiple times)",
29
+ },
30
+ },
31
+ }, async (argv) => {
32
+ await destroy({
33
+ stack: argv._.stack,
34
+ app: argv.flags.app,
35
+ output: argv.flags.output,
36
+ skipSynth: argv.flags.skipSynth,
37
+ autoApprove: argv.flags.autoApprove,
38
+ target: argv.flags.target,
39
+ });
40
+ });
41
+ //# sourceMappingURL=destroy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../../src/cli/commands/destroy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CACnC;IACE,IAAI,EAAE,SAAS;IACf,IAAI,EAAE;QACJ,WAAW,EAAE,6CAA6C;KAC3D;IACD,UAAU,EAAE,CAAC,SAAS,CAAC;IACvB,KAAK,EAAE;QACL,GAAG,EAAE;YACH,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,wBAAwB;SACtC;QACD,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,uCAAuC;SACrD;QACD,SAAS,EAAE;YACT,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,+BAA+B;SAC7C;QACD,WAAW,EAAE;YACX,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,2BAA2B;SACzC;QACD,MAAM,EAAE;YACN,IAAI,EAAE,CAAC,MAAM,CAAC;YACd,WAAW,EAAE,uDAAuD;SACrE;KACF;CACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;IACb,MAAM,OAAO,CAAC;QACZ,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK;QACnB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG;QACnB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;QACzB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;QAC/B,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;QACnC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;KAC1B,CAAC,CAAC;AACL,CAAC,CACF,CAAC"}
@@ -18,6 +18,14 @@ export declare const diffCommand: import("cleye").Command<{
18
18
  type: BooleanConstructor;
19
19
  description: string;
20
20
  };
21
+ refreshOnly: {
22
+ type: BooleanConstructor;
23
+ description: string;
24
+ };
25
+ target: {
26
+ type: [StringConstructor];
27
+ description: string;
28
+ };
21
29
  };
22
30
  }, {
23
31
  command: "diff";
@@ -34,6 +42,14 @@ export declare const diffCommand: import("cleye").Command<{
34
42
  type: BooleanConstructor;
35
43
  description: string;
36
44
  };
45
+ refreshOnly: {
46
+ type: BooleanConstructor;
47
+ description: string;
48
+ };
49
+ target: {
50
+ type: [StringConstructor];
51
+ description: string;
52
+ };
37
53
  } & {
38
54
  help: BooleanConstructor;
39
55
  }> & {
@@ -1 +1 @@
1
- {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/diff.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAgCy7M,CAAC;;;;;;;;;;;;EADj9M,CAAC"}
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/diff.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA0CunM,CAAC;;;;;;;;;;;;EAD/oM,CAAC"}
@@ -20,6 +20,14 @@ export const diffCommand = command({
20
20
  type: Boolean,
21
21
  description: "Skip synthesis before diff",
22
22
  },
23
+ refreshOnly: {
24
+ type: Boolean,
25
+ description: "Check for drift without proposing changes",
26
+ },
27
+ target: {
28
+ type: [String],
29
+ description: "Target specific resource (can be used multiple times)",
30
+ },
23
31
  },
24
32
  }, async (argv) => {
25
33
  await diff({
@@ -27,6 +35,8 @@ export const diffCommand = command({
27
35
  app: argv.flags.app,
28
36
  output: argv.flags.output,
29
37
  skipSynth: argv.flags.skipSynth,
38
+ refreshOnly: argv.flags.refreshOnly,
39
+ target: argv.flags.target,
30
40
  });
31
41
  });
32
42
  //# sourceMappingURL=diff.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/cli/commands/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAChC;IACE,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,MAAM;IACb,IAAI,EAAE;QACJ,WAAW,EAAE,qDAAqD;KACnE;IACD,UAAU,EAAE,CAAC,SAAS,CAAC;IACvB,KAAK,EAAE;QACL,GAAG,EAAE;YACH,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,wBAAwB;SACtC;QACD,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,uCAAuC;SACrD;QACD,SAAS,EAAE;YACT,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,4BAA4B;SAC1C;KACF;CACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;IACb,MAAM,IAAI,CAAC;QACT,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK;QACnB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG;QACnB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;QACzB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;KAChC,CAAC,CAAC;AACL,CAAC,CACF,CAAC"}
1
+ {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/cli/commands/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAChC;IACE,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,MAAM;IACb,IAAI,EAAE;QACJ,WAAW,EAAE,qDAAqD;KACnE;IACD,UAAU,EAAE,CAAC,SAAS,CAAC;IACvB,KAAK,EAAE;QACL,GAAG,EAAE;YACH,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,wBAAwB;SACtC;QACD,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,uCAAuC;SACrD;QACD,SAAS,EAAE;YACT,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,4BAA4B;SAC1C;QACD,WAAW,EAAE;YACX,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,2CAA2C;SACzD;QACD,MAAM,EAAE;YACN,IAAI,EAAE,CAAC,MAAM,CAAC;YACd,WAAW,EAAE,uDAAuD;SACrE;KACF;CACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;IACb,MAAM,IAAI,CAAC;QACT,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK;QACnB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG;QACnB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;QACzB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;QAC/B,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;QACnC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;KAC1B,CAAC,CAAC;AACL,CAAC,CACF,CAAC"}
@@ -0,0 +1,50 @@
1
+ export declare const forceUnlockCommand: import("cleye").Command<{
2
+ name: "force-unlock";
3
+ help: {
4
+ description: string;
5
+ };
6
+ parameters: ("[stack]" | "<lockId>")[];
7
+ flags: {
8
+ output: {
9
+ type: StringConstructor;
10
+ description: string;
11
+ };
12
+ force: {
13
+ type: BooleanConstructor;
14
+ alias: string;
15
+ description: string;
16
+ };
17
+ };
18
+ }, {
19
+ command: "force-unlock";
20
+ } & import("cleye").TypeFlag<{
21
+ output: {
22
+ type: StringConstructor;
23
+ description: string;
24
+ };
25
+ force: {
26
+ type: BooleanConstructor;
27
+ alias: string;
28
+ description: string;
29
+ };
30
+ } & {
31
+ help: BooleanConstructor;
32
+ }> & {
33
+ _: {
34
+ stack: string | undefined;
35
+ lockId: string;
36
+ };
37
+ showHelp: (options?: {
38
+ version?: string;
39
+ description?: string;
40
+ usage?: false | string | string[];
41
+ examples?: string | string[];
42
+ render?: (nodes: {
43
+ id?: string;
44
+ type: keyof import("cleye").Renderers;
45
+ data: any;
46
+ }[], renderers: import("cleye").Renderers) => string;
47
+ }) => void;
48
+ showVersion: () => void;
49
+ }>;
50
+ //# sourceMappingURL=force-unlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"force-unlock.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/force-unlock.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA4Bk9M,CAAC;;;;;;;;;;;;EADj/M,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { command } from "cleye";
2
+ import { forceUnlock } from "../force-unlock.js";
3
+ export const forceUnlockCommand = command({
4
+ name: "force-unlock",
5
+ help: {
6
+ description: "Release a stuck lock on the current workspace (terraform force-unlock)",
7
+ },
8
+ parameters: ["[stack]", "<lockId>"],
9
+ flags: {
10
+ output: {
11
+ type: String,
12
+ description: "Output directory (default: cdktf.out)",
13
+ },
14
+ force: {
15
+ type: Boolean,
16
+ alias: "f",
17
+ description: "Don't ask for confirmation",
18
+ },
19
+ },
20
+ }, async (argv) => {
21
+ await forceUnlock({
22
+ stack: argv._.stack,
23
+ lockId: argv._.lockId,
24
+ output: argv.flags.output,
25
+ force: argv.flags.force,
26
+ });
27
+ });
28
+ //# sourceMappingURL=force-unlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"force-unlock.js","sourceRoot":"","sources":["../../../src/cli/commands/force-unlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CACvC;IACE,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE;QACJ,WAAW,EAAE,wEAAwE;KACtF;IACD,UAAU,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC;IACnC,KAAK,EAAE;QACL,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,uCAAuC;SACrD;QACD,KAAK,EAAE;YACL,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,GAAG;YACV,WAAW,EAAE,4BAA4B;SAC1C;KACF;CACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;IACb,MAAM,WAAW,CAAC;QAChB,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK;QACnB,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM;QACrB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;QACzB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;KACxB,CAAC,CAAC;AACL,CAAC,CACF,CAAC"}
@@ -0,0 +1,53 @@
1
+ export declare const listCommand: import("cleye").Command<{
2
+ name: "list";
3
+ alias: "ls";
4
+ help: {
5
+ description: string;
6
+ };
7
+ flags: {
8
+ app: {
9
+ type: StringConstructor;
10
+ description: string;
11
+ };
12
+ output: {
13
+ type: StringConstructor;
14
+ description: string;
15
+ };
16
+ skipSynth: {
17
+ type: BooleanConstructor;
18
+ description: string;
19
+ };
20
+ };
21
+ }, {
22
+ command: "list";
23
+ } & import("cleye").TypeFlag<{
24
+ app: {
25
+ type: StringConstructor;
26
+ description: string;
27
+ };
28
+ output: {
29
+ type: StringConstructor;
30
+ description: string;
31
+ };
32
+ skipSynth: {
33
+ type: BooleanConstructor;
34
+ description: string;
35
+ };
36
+ } & {
37
+ help: BooleanConstructor;
38
+ }> & {
39
+ _: {};
40
+ showHelp: (options?: {
41
+ version?: string;
42
+ description?: string;
43
+ usage?: false | string | string[];
44
+ examples?: string | string[];
45
+ render?: (nodes: {
46
+ id?: string;
47
+ type: keyof import("cleye").Renderers;
48
+ data: any;
49
+ }[], renderers: import("cleye").Renderers) => string;
50
+ }) => void;
51
+ showVersion: () => void;
52
+ }>;
53
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/list.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA8BygN,CAAC;;;;;;;;;;;;EADjiN,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { command } from "cleye";
2
+ import { list } from "../list.js";
3
+ export const listCommand = command({
4
+ name: "list",
5
+ alias: "ls",
6
+ help: {
7
+ description: "List all stacks in the app",
8
+ },
9
+ flags: {
10
+ app: {
11
+ type: String,
12
+ description: "Command to run the app",
13
+ },
14
+ output: {
15
+ type: String,
16
+ description: "Output directory (default: cdktf.out)",
17
+ },
18
+ skipSynth: {
19
+ type: Boolean,
20
+ description: "Skip synthesis before listing",
21
+ },
22
+ },
23
+ }, async (argv) => {
24
+ await list({
25
+ app: argv.flags.app,
26
+ output: argv.flags.output,
27
+ skipSynth: argv.flags.skipSynth,
28
+ });
29
+ });
30
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/cli/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAChC;IACE,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,IAAI;IACX,IAAI,EAAE;QACJ,WAAW,EAAE,4BAA4B;KAC1C;IACD,KAAK,EAAE;QACL,GAAG,EAAE;YACH,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,wBAAwB;SACtC;QACD,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,uCAAuC;SACrD;QACD,SAAS,EAAE;YACT,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,+BAA+B;SAC7C;KACF;CACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;IACb,MAAM,IAAI,CAAC;QACT,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG;QACnB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;QACzB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;KAChC,CAAC,CAAC;AACL,CAAC,CACF,CAAC"}
@@ -0,0 +1,63 @@
1
+ export declare const outputCommand: import("cleye").Command<{
2
+ name: "output";
3
+ help: {
4
+ description: string;
5
+ };
6
+ parameters: "[stack]"[];
7
+ flags: {
8
+ app: {
9
+ type: StringConstructor;
10
+ description: string;
11
+ };
12
+ output: {
13
+ type: StringConstructor;
14
+ description: string;
15
+ };
16
+ skipSynth: {
17
+ type: BooleanConstructor;
18
+ description: string;
19
+ };
20
+ json: {
21
+ type: BooleanConstructor;
22
+ description: string;
23
+ };
24
+ };
25
+ }, {
26
+ command: "output";
27
+ } & import("cleye").TypeFlag<{
28
+ app: {
29
+ type: StringConstructor;
30
+ description: string;
31
+ };
32
+ output: {
33
+ type: StringConstructor;
34
+ description: string;
35
+ };
36
+ skipSynth: {
37
+ type: BooleanConstructor;
38
+ description: string;
39
+ };
40
+ json: {
41
+ type: BooleanConstructor;
42
+ description: string;
43
+ };
44
+ } & {
45
+ help: BooleanConstructor;
46
+ }> & {
47
+ _: {
48
+ stack: string | undefined;
49
+ };
50
+ showHelp: (options?: {
51
+ version?: string;
52
+ description?: string;
53
+ usage?: false | string | string[];
54
+ examples?: string | string[];
55
+ render?: (nodes: {
56
+ id?: string;
57
+ type: keyof import("cleye").Renderers;
58
+ data: any;
59
+ }[], renderers: import("cleye").Renderers) => string;
60
+ }) => void;
61
+ showVersion: () => void;
62
+ }>;
63
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/output.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAoCk0M,CAAC;;;;;;;;;;;;EAD51M,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { command } from "cleye";
2
+ import { output } from "../output.js";
3
+ export const outputCommand = command({
4
+ name: "output",
5
+ help: {
6
+ description: "Print the output values for a stack (terraform output)",
7
+ },
8
+ parameters: ["[stack]"],
9
+ flags: {
10
+ app: {
11
+ type: String,
12
+ description: "Command to run the app",
13
+ },
14
+ output: {
15
+ type: String,
16
+ description: "Output directory (default: cdktf.out)",
17
+ },
18
+ skipSynth: {
19
+ type: Boolean,
20
+ description: "Skip synthesis before output",
21
+ },
22
+ json: {
23
+ type: Boolean,
24
+ description: "Output in JSON format",
25
+ },
26
+ },
27
+ }, async (argv) => {
28
+ await output({
29
+ stack: argv._.stack,
30
+ app: argv.flags.app,
31
+ output: argv.flags.output,
32
+ skipSynth: argv.flags.skipSynth,
33
+ json: argv.flags.json,
34
+ });
35
+ });
36
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../../src/cli/commands/output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAClC;IACE,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE;QACJ,WAAW,EAAE,wDAAwD;KACtE;IACD,UAAU,EAAE,CAAC,SAAS,CAAC;IACvB,KAAK,EAAE;QACL,GAAG,EAAE;YACH,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,wBAAwB;SACtC;QACD,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,uCAAuC;SACrD;QACD,SAAS,EAAE;YACT,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,8BAA8B;SAC5C;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,uBAAuB;SACrC;KACF;CACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;IACb,MAAM,MAAM,CAAC;QACX,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK;QACnB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG;QACnB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;QACzB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;QAC/B,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;KACtB,CAAC,CAAC;AACL,CAAC,CACF,CAAC"}
@@ -0,0 +1,11 @@
1
+ export type DeployOptions = {
2
+ stack?: string;
3
+ app?: string;
4
+ output?: string;
5
+ cwd?: string;
6
+ skipSynth?: boolean;
7
+ autoApprove?: boolean;
8
+ target?: string[];
9
+ };
10
+ export declare function deploy(options?: DeployOptions): Promise<void>;
11
+ //# sourceMappingURL=deploy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/cli/deploy.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAuBF,wBAAsB,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4DvE"}
@@ -0,0 +1,76 @@
1
+ import { spawn } from "node:child_process";
2
+ import { existsSync, readdirSync } from "node:fs";
3
+ import { synth } from "./synth.js";
4
+ async function runCommand(command, args, cwd) {
5
+ return new Promise((resolve, reject) => {
6
+ const proc = spawn(command, args, {
7
+ cwd,
8
+ stdio: "inherit",
9
+ });
10
+ proc.on("close", (code) => resolve(code ?? 1));
11
+ proc.on("error", reject);
12
+ });
13
+ }
14
+ function getStacks(outputDir) {
15
+ const stacksDir = `${outputDir}/stacks`;
16
+ if (!existsSync(stacksDir)) {
17
+ return [];
18
+ }
19
+ return readdirSync(stacksDir, { withFileTypes: true })
20
+ .filter((entry) => entry.isDirectory())
21
+ .map((entry) => entry.name);
22
+ }
23
+ export async function deploy(options = {}) {
24
+ const cwd = options.cwd ?? process.cwd();
25
+ const outputDir = options.output ?? "cdktf.out";
26
+ const outputPath = `${cwd}/${outputDir}`;
27
+ if (options.skipSynth !== true) {
28
+ await synth({
29
+ app: options.app,
30
+ output: outputDir,
31
+ cwd,
32
+ });
33
+ console.log();
34
+ }
35
+ const stacks = getStacks(outputPath);
36
+ if (stacks.length === 0) {
37
+ throw new Error(`No stacks found in ${outputDir}/stacks`);
38
+ }
39
+ let targetStack;
40
+ if (options.stack !== undefined) {
41
+ if (!stacks.includes(options.stack)) {
42
+ throw new Error(`Stack "${options.stack}" not found. Available stacks: ${stacks.join(", ")}`);
43
+ }
44
+ targetStack = options.stack;
45
+ }
46
+ else if (stacks.length === 1 && stacks[0] !== undefined) {
47
+ targetStack = stacks[0];
48
+ }
49
+ else {
50
+ throw new Error(`Found more than one stack, please specify a target stack. Run tfts deploy <stack> with one of these stacks: ${stacks.join(", ")}`);
51
+ }
52
+ const stackDir = `${outputPath}/stacks/${targetStack}`;
53
+ const needsInit = !existsSync(`${stackDir}/.terraform`);
54
+ if (needsInit) {
55
+ console.log("Running terraform init...\n");
56
+ const initCode = await runCommand("terraform", ["init"], stackDir);
57
+ if (initCode !== 0) {
58
+ throw new Error(`terraform init failed for stack ${targetStack}`);
59
+ }
60
+ console.log();
61
+ }
62
+ const applyArgs = ["apply"];
63
+ if (options.autoApprove === true) {
64
+ applyArgs.push("-auto-approve");
65
+ }
66
+ if (options.target !== undefined) {
67
+ for (const t of options.target) {
68
+ applyArgs.push("-target", t);
69
+ }
70
+ }
71
+ const applyCode = await runCommand("terraform", applyArgs, stackDir);
72
+ if (applyCode !== 0) {
73
+ throw new Error(`terraform apply failed for stack ${targetStack}`);
74
+ }
75
+ }
76
+ //# sourceMappingURL=deploy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/cli/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAYnC,KAAK,UAAU,UAAU,CAAC,OAAe,EAAE,IAAuB,EAAE,GAAW;IAC7E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;YAChC,GAAG;YACH,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,SAAS,CAAC,SAAiB;IAClC,MAAM,SAAS,GAAG,GAAG,SAAS,SAAS,CAAC;IACxC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,WAAW,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,IAAI,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AAC,CAAC;IACrE,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ export type DestroyOptions = {
2
+ stack?: string;
3
+ app?: string;
4
+ output?: string;
5
+ cwd?: string;
6
+ skipSynth?: boolean;
7
+ autoApprove?: boolean;
8
+ target?: string[];
9
+ };
10
+ export declare function destroy(options?: DestroyOptions): Promise<void>;
11
+ //# sourceMappingURL=destroy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../../src/cli/destroy.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAuBF,wBAAsB,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4DzE"}
@@ -0,0 +1,76 @@
1
+ import { spawn } from "node:child_process";
2
+ import { existsSync, readdirSync } from "node:fs";
3
+ import { synth } from "./synth.js";
4
+ async function runCommand(command, args, cwd) {
5
+ return new Promise((resolve, reject) => {
6
+ const proc = spawn(command, args, {
7
+ cwd,
8
+ stdio: "inherit",
9
+ });
10
+ proc.on("close", (code) => resolve(code ?? 1));
11
+ proc.on("error", reject);
12
+ });
13
+ }
14
+ function getStacks(outputDir) {
15
+ const stacksDir = `${outputDir}/stacks`;
16
+ if (!existsSync(stacksDir)) {
17
+ return [];
18
+ }
19
+ return readdirSync(stacksDir, { withFileTypes: true })
20
+ .filter((entry) => entry.isDirectory())
21
+ .map((entry) => entry.name);
22
+ }
23
+ export async function destroy(options = {}) {
24
+ const cwd = options.cwd ?? process.cwd();
25
+ const outputDir = options.output ?? "cdktf.out";
26
+ const outputPath = `${cwd}/${outputDir}`;
27
+ if (options.skipSynth !== true) {
28
+ await synth({
29
+ app: options.app,
30
+ output: outputDir,
31
+ cwd,
32
+ });
33
+ console.log();
34
+ }
35
+ const stacks = getStacks(outputPath);
36
+ if (stacks.length === 0) {
37
+ throw new Error(`No stacks found in ${outputDir}/stacks`);
38
+ }
39
+ let targetStack;
40
+ if (options.stack !== undefined) {
41
+ if (!stacks.includes(options.stack)) {
42
+ throw new Error(`Stack "${options.stack}" not found. Available stacks: ${stacks.join(", ")}`);
43
+ }
44
+ targetStack = options.stack;
45
+ }
46
+ else if (stacks.length === 1 && stacks[0] !== undefined) {
47
+ targetStack = stacks[0];
48
+ }
49
+ else {
50
+ throw new Error(`Found more than one stack, please specify a target stack. Run tfts destroy <stack> with one of these stacks: ${stacks.join(", ")}`);
51
+ }
52
+ const stackDir = `${outputPath}/stacks/${targetStack}`;
53
+ const needsInit = !existsSync(`${stackDir}/.terraform`);
54
+ if (needsInit) {
55
+ console.log("Running terraform init...\n");
56
+ const initCode = await runCommand("terraform", ["init"], stackDir);
57
+ if (initCode !== 0) {
58
+ throw new Error(`terraform init failed for stack ${targetStack}`);
59
+ }
60
+ console.log();
61
+ }
62
+ const destroyArgs = ["destroy"];
63
+ if (options.autoApprove === true) {
64
+ destroyArgs.push("-auto-approve");
65
+ }
66
+ if (options.target !== undefined) {
67
+ for (const t of options.target) {
68
+ destroyArgs.push("-target", t);
69
+ }
70
+ }
71
+ const destroyCode = await runCommand("terraform", destroyArgs, stackDir);
72
+ if (destroyCode !== 0) {
73
+ throw new Error(`terraform destroy failed for stack ${targetStack}`);
74
+ }
75
+ }
76
+ //# sourceMappingURL=destroy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../src/cli/destroy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,U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MAAM,UAAU,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;QACnE,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,WAAW,EAAE,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,CAAC;IAChB,CAAC;IAED,MAAM,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC;IAChC,IAAI,OAAO,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;QACjC,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACjC,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YAC/B,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IACzE,IAAI,WAAW,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,sCAAsC,WAAW,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC"}
@@ -4,6 +4,8 @@ export type DiffOptions = {
4
4
  output?: string;
5
5
  cwd?: string;
6
6
  skipSynth?: boolean;
7
+ refreshOnly?: boolean;
8
+ target?: string[];
7
9
  };
8
10
  export declare function diff(options?: DiffOptions): Promise<void>;
9
11
  //# sourceMappingURL=diff.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/cli/diff.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAuBF,wBAAsB,IAAI,CAAC,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkDnE"}
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/cli/diff.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAuBF,wBAAsB,IAAI,CAAC,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4DnE"}
package/dist/cli/diff.js CHANGED
@@ -59,7 +59,16 @@ export async function diff(options = {}) {
59
59
  }
60
60
  console.log();
61
61
  }
62
- const planCode = await runCommand("terraform", ["plan"], stackDir);
62
+ const planArgs = ["plan"];
63
+ if (options.refreshOnly === true) {
64
+ planArgs.push("-refresh-only");
65
+ }
66
+ if (options.target !== undefined) {
67
+ for (const t of options.target) {
68
+ planArgs.push("-target", t);
69
+ }
70
+ }
71
+ const planCode = await runCommand("terraform", planArgs, stackDir);
63
72
  if (planCode !== 0) {
64
73
  throw new Error(`terraform plan failed for stack ${targetStack}`);
65
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/cli/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC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,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,WAAW,EAAE,CAAC,CAAC;IACpE,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ export type ForceUnlockOptions = {
2
+ stack?: string;
3
+ lockId: string;
4
+ output?: string;
5
+ cwd?: string;
6
+ force?: boolean;
7
+ };
8
+ export declare function forceUnlock(options: ForceUnlockOptions): Promise<void>;
9
+ //# sourceMappingURL=force-unlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"force-unlock.d.ts","sourceRoot":"","sources":["../../src/cli/force-unlock.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAuBF,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqC5E"}
@@ -0,0 +1,54 @@
1
+ import { spawn } from "node:child_process";
2
+ import { existsSync, readdirSync } from "node:fs";
3
+ async function runCommand(command, args, cwd) {
4
+ return new Promise((resolve, reject) => {
5
+ const proc = spawn(command, args, {
6
+ cwd,
7
+ stdio: "inherit",
8
+ });
9
+ proc.on("close", (code) => resolve(code ?? 1));
10
+ proc.on("error", reject);
11
+ });
12
+ }
13
+ function getStacks(outputDir) {
14
+ const stacksDir = `${outputDir}/stacks`;
15
+ if (!existsSync(stacksDir)) {
16
+ return [];
17
+ }
18
+ return readdirSync(stacksDir, { withFileTypes: true })
19
+ .filter((entry) => entry.isDirectory())
20
+ .map((entry) => entry.name);
21
+ }
22
+ export async function forceUnlock(options) {
23
+ const cwd = options.cwd ?? process.cwd();
24
+ const outputDir = options.output ?? "cdktf.out";
25
+ const outputPath = `${cwd}/${outputDir}`;
26
+ const stacks = getStacks(outputPath);
27
+ if (stacks.length === 0) {
28
+ throw new Error(`No stacks found in ${outputDir}/stacks`);
29
+ }
30
+ let targetStack;
31
+ if (options.stack !== undefined) {
32
+ if (!stacks.includes(options.stack)) {
33
+ throw new Error(`Stack "${options.stack}" not found. Available stacks: ${stacks.join(", ")}`);
34
+ }
35
+ targetStack = options.stack;
36
+ }
37
+ else if (stacks.length === 1 && stacks[0] !== undefined) {
38
+ targetStack = stacks[0];
39
+ }
40
+ else {
41
+ throw new Error(`Found more than one stack, please specify a target stack. Run tfts force-unlock <stack> <lock-id> with one of these stacks: ${stacks.join(", ")}`);
42
+ }
43
+ const stackDir = `${outputPath}/stacks/${targetStack}`;
44
+ const unlockArgs = ["force-unlock"];
45
+ if (options.force === true) {
46
+ unlockArgs.push("-force");
47
+ }
48
+ unlockArgs.push(options.lockId);
49
+ const unlockCode = await runCommand("terraform", unlockArgs, stackDir);
50
+ if (unlockCode !== 0) {
51
+ throw new Error(`terraform force-unlock failed for stack ${targetStack}`);
52
+ }
53
+ }
54
+ //# sourceMappingURL=force-unlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"force-unlock.js","sourceRoot":"","sources":["../../src/cli/force-unlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAUlD,KAAK,UAAU,UAAU,CAAC,OAAe,EAAE,IAAuB,EAAE,GAAW;IAC7E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;YAChC,GAAG;YACH,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,C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AAC;QAChG,CAAC;QACD,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;IAC9B,CAAC;SAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QAC1D,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CACb,+HAA+H,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACnJ,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,GAAG,UAAU,WAAW,WAAW,EAAE,CAAC;IAEvD,MAAM,UAAU,GAAG,CAAC,cAAc,CAAC,CAAC;IACpC,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QAC3B,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IACD,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhC,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IACvE,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,2CAA2C,WAAW,EAAE,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ export type ListOptions = {
2
+ app?: string;
3
+ output?: string;
4
+ cwd?: string;
5
+ skipSynth?: boolean;
6
+ };
7
+ export declare function list(options?: ListOptions): Promise<void>;
8
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/cli/list.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAYF,wBAAsB,IAAI,CAAC,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBnE"}
@@ -0,0 +1,34 @@
1
+ import { existsSync, readdirSync } from "node:fs";
2
+ import { synth } from "./synth.js";
3
+ function getStacks(outputDir) {
4
+ const stacksDir = `${outputDir}/stacks`;
5
+ if (!existsSync(stacksDir)) {
6
+ return [];
7
+ }
8
+ return readdirSync(stacksDir, { withFileTypes: true })
9
+ .filter((entry) => entry.isDirectory())
10
+ .map((entry) => entry.name);
11
+ }
12
+ export async function list(options = {}) {
13
+ const cwd = options.cwd ?? process.cwd();
14
+ const outputDir = options.output ?? "cdktf.out";
15
+ const outputPath = `${cwd}/${outputDir}`;
16
+ if (options.skipSynth !== true) {
17
+ await synth({
18
+ app: options.app,
19
+ output: outputDir,
20
+ cwd,
21
+ });
22
+ console.log();
23
+ }
24
+ const stacks = getStacks(outputPath);
25
+ if (stacks.length === 0) {
26
+ console.log("No stacks found.");
27
+ return;
28
+ }
29
+ console.log("Stacks:");
30
+ for (const stack of stacks) {
31
+ console.log(` - ${stack}`);
32
+ }
33
+ }
34
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/cli/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AASnC,SAAS,SAAS,CAAC,SAAiB;IAClC,MAAM,SAAS,GAAG,GAAG,SAAS,SAAS,CAAC;IACxC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,WAAW,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;SACnD,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;SACtC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,UAAuB,EAAE;IAClD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,IAAI,WAAW,CAAC;IAChD,MAAM,UAAU,GAAG,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC;IAEzC,IAAI,OAAO,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;QAC/B,MAAM,KAAK,CAAC;YACV,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,MAAM,EAAE,SAAS;YACjB,GAAG;SACJ,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,EAAE,CAAC;IAChB,CAAC;IAED,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IACrC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QAChC,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACvB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
package/dist/cli/main.js CHANGED
@@ -1,15 +1,29 @@
1
1
  #!/usr/bin/env node
2
2
  import { cli } from "cleye";
3
+ import { deployCommand } from "./commands/deploy.js";
4
+ import { destroyCommand } from "./commands/destroy.js";
3
5
  import { diffCommand } from "./commands/diff.js";
6
+ import { forceUnlockCommand } from "./commands/force-unlock.js";
4
7
  import { getCommand } from "./commands/get.js";
8
+ import { listCommand } from "./commands/list.js";
9
+ import { outputCommand } from "./commands/output.js";
5
10
  import { synthCommand } from "./commands/synth.js";
6
11
  const parsed = cli({
7
12
  name: "tfts",
8
- version: "0.3.2",
13
+ version: "0.3.3",
9
14
  help: {
10
15
  description: "Terraform TypeScript SDK",
11
16
  },
12
- commands: [synthCommand, getCommand, diffCommand],
17
+ commands: [
18
+ synthCommand,
19
+ getCommand,
20
+ diffCommand,
21
+ deployCommand,
22
+ destroyCommand,
23
+ listCommand,
24
+ outputCommand,
25
+ forceUnlockCommand,
26
+ ],
13
27
  }, () => {
14
28
  console.log('Run "tfts --help" for usage information.');
15
29
  });
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,MAAM,GAAG,GAAG,CAChB;IACE,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE;QACJ,WAAW,EAAE,0BAA0B;KACxC;IACD,QAAQ,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,WAAW,CAAC;CAClD,EACD,GAAG,EAAE;IACH,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;AAC1D,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;IAC5B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,MAAM,GAAG,GAAG,CAChB;IACE,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE;QACJ,WAAW,EAAE,0BAA0B;KACxC;IACD,QAAQ,EAAE;QACR,YAAY;QACZ,UAAU;QACV,WAAW;QACX,aAAa;QACb,cAAc;QACd,WAAW;QACX,aAAa;QACb,kBAAkB;KACnB;CACF,EACD,GAAG,EAAE;IACH,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;AAC1D,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;IAC5B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ export type OutputOptions = {
2
+ stack?: string;
3
+ app?: string;
4
+ output?: string;
5
+ cwd?: string;
6
+ skipSynth?: boolean;
7
+ json?: boolean;
8
+ };
9
+ export declare function output(options?: OutputOptions): Promise<void>;
10
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAuBF,wBAAsB,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuDvE"}
@@ -0,0 +1,71 @@
1
+ import { spawn } from "node:child_process";
2
+ import { existsSync, readdirSync } from "node:fs";
3
+ import { synth } from "./synth.js";
4
+ async function runCommand(command, args, cwd) {
5
+ return new Promise((resolve, reject) => {
6
+ const proc = spawn(command, args, {
7
+ cwd,
8
+ stdio: "inherit",
9
+ });
10
+ proc.on("close", (code) => resolve(code ?? 1));
11
+ proc.on("error", reject);
12
+ });
13
+ }
14
+ function getStacks(outputDir) {
15
+ const stacksDir = `${outputDir}/stacks`;
16
+ if (!existsSync(stacksDir)) {
17
+ return [];
18
+ }
19
+ return readdirSync(stacksDir, { withFileTypes: true })
20
+ .filter((entry) => entry.isDirectory())
21
+ .map((entry) => entry.name);
22
+ }
23
+ export async function output(options = {}) {
24
+ const cwd = options.cwd ?? process.cwd();
25
+ const outputDir = options.output ?? "cdktf.out";
26
+ const outputPath = `${cwd}/${outputDir}`;
27
+ if (options.skipSynth !== true) {
28
+ await synth({
29
+ app: options.app,
30
+ output: outputDir,
31
+ cwd,
32
+ });
33
+ console.log();
34
+ }
35
+ const stacks = getStacks(outputPath);
36
+ if (stacks.length === 0) {
37
+ throw new Error(`No stacks found in ${outputDir}/stacks`);
38
+ }
39
+ let targetStack;
40
+ if (options.stack !== undefined) {
41
+ if (!stacks.includes(options.stack)) {
42
+ throw new Error(`Stack "${options.stack}" not found. Available stacks: ${stacks.join(", ")}`);
43
+ }
44
+ targetStack = options.stack;
45
+ }
46
+ else if (stacks.length === 1 && stacks[0] !== undefined) {
47
+ targetStack = stacks[0];
48
+ }
49
+ else {
50
+ throw new Error(`Found more than one stack, please specify a target stack. Run tfts output <stack> with one of these stacks: ${stacks.join(", ")}`);
51
+ }
52
+ const stackDir = `${outputPath}/stacks/${targetStack}`;
53
+ const needsInit = !existsSync(`${stackDir}/.terraform`);
54
+ if (needsInit) {
55
+ console.log("Running terraform init...\n");
56
+ const initCode = await runCommand("terraform", ["init"], stackDir);
57
+ if (initCode !== 0) {
58
+ throw new Error(`terraform init failed for stack ${targetStack}`);
59
+ }
60
+ console.log();
61
+ }
62
+ const outputArgs = ["output"];
63
+ if (options.json === true) {
64
+ outputArgs.push("-json");
65
+ }
66
+ const outputCode = await runCommand("terraform", outputArgs, stackDir);
67
+ if (outputCode !== 0) {
68
+ throw new Error(`terraform output failed for stack ${targetStack}`);
69
+ }
70
+ }
71
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAWnC,KAAK,UAAU,UAAU,CAAC,OAAe,EAAE,IAAuB,EAAE,GAAW;IAC7E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;YAChC,GAAG;YACH,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC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,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IACvE,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,qCAAqC,WAAW,EAAE,CAAC,CAAC;IACtE,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tfts",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "TypeScript-first infrastructure as code for Terraform",
5
5
  "type": "module",
6
6
  "workspaces": [