@salte-common/terraflow 0.1.0-alpha.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.
Files changed (131) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +278 -0
  3. package/RELEASE_SUMMARY.md +53 -0
  4. package/STANDARDS_COMPLIANCE.md +85 -0
  5. package/bin/terraflow.js +3 -0
  6. package/bin/tf.js +3 -0
  7. package/dist/commands/apply.d.ts +7 -0
  8. package/dist/commands/apply.js +12 -0
  9. package/dist/commands/base.d.ts +7 -0
  10. package/dist/commands/base.js +12 -0
  11. package/dist/commands/config.d.ts +25 -0
  12. package/dist/commands/config.js +354 -0
  13. package/dist/commands/destroy.d.ts +7 -0
  14. package/dist/commands/destroy.js +12 -0
  15. package/dist/commands/init.d.ts +68 -0
  16. package/dist/commands/init.js +131 -0
  17. package/dist/commands/plan.d.ts +7 -0
  18. package/dist/commands/plan.js +12 -0
  19. package/dist/core/backend-state.d.ts +25 -0
  20. package/dist/core/backend-state.js +77 -0
  21. package/dist/core/config.d.ts +83 -0
  22. package/dist/core/config.js +295 -0
  23. package/dist/core/context.d.ts +52 -0
  24. package/dist/core/context.js +192 -0
  25. package/dist/core/environment.d.ts +62 -0
  26. package/dist/core/environment.js +205 -0
  27. package/dist/core/errors.d.ts +22 -0
  28. package/dist/core/errors.js +36 -0
  29. package/dist/core/plugin-loader.d.ts +21 -0
  30. package/dist/core/plugin-loader.js +136 -0
  31. package/dist/core/terraform.d.ts +45 -0
  32. package/dist/core/terraform.js +247 -0
  33. package/dist/core/validator.d.ts +103 -0
  34. package/dist/core/validator.js +304 -0
  35. package/dist/index.d.ts +7 -0
  36. package/dist/index.js +184 -0
  37. package/dist/plugins/auth/aws-assume-role.d.ts +10 -0
  38. package/dist/plugins/auth/aws-assume-role.js +110 -0
  39. package/dist/plugins/auth/azure-service-principal.d.ts +10 -0
  40. package/dist/plugins/auth/azure-service-principal.js +99 -0
  41. package/dist/plugins/auth/gcp-service-account.d.ts +10 -0
  42. package/dist/plugins/auth/gcp-service-account.js +105 -0
  43. package/dist/plugins/backends/azurerm.d.ts +10 -0
  44. package/dist/plugins/backends/azurerm.js +117 -0
  45. package/dist/plugins/backends/gcs.d.ts +10 -0
  46. package/dist/plugins/backends/gcs.js +75 -0
  47. package/dist/plugins/backends/local.d.ts +11 -0
  48. package/dist/plugins/backends/local.js +37 -0
  49. package/dist/plugins/backends/s3.d.ts +10 -0
  50. package/dist/plugins/backends/s3.js +185 -0
  51. package/dist/plugins/secrets/aws-secrets.d.ts +12 -0
  52. package/dist/plugins/secrets/aws-secrets.js +125 -0
  53. package/dist/plugins/secrets/azure-keyvault.d.ts +12 -0
  54. package/dist/plugins/secrets/azure-keyvault.js +178 -0
  55. package/dist/plugins/secrets/env.d.ts +24 -0
  56. package/dist/plugins/secrets/env.js +62 -0
  57. package/dist/plugins/secrets/gcp-secret-manager.d.ts +12 -0
  58. package/dist/plugins/secrets/gcp-secret-manager.js +157 -0
  59. package/dist/templates/application/go/go.mod.template +4 -0
  60. package/dist/templates/application/go/main.template +8 -0
  61. package/dist/templates/application/go/test.template +11 -0
  62. package/dist/templates/application/javascript/main.template +14 -0
  63. package/dist/templates/application/javascript/test.template +8 -0
  64. package/dist/templates/application/python/main.template +13 -0
  65. package/dist/templates/application/python/requirements.txt.template +3 -0
  66. package/dist/templates/application/python/test.template +8 -0
  67. package/dist/templates/application/typescript/main.template +14 -0
  68. package/dist/templates/application/typescript/test.template +8 -0
  69. package/dist/templates/application/typescript/tsconfig.json.template +20 -0
  70. package/dist/templates/config/README.md.template +82 -0
  71. package/dist/templates/config/env.example.template +22 -0
  72. package/dist/templates/config/gitignore.template +40 -0
  73. package/dist/templates/config/tfwconfig.yml.template +69 -0
  74. package/dist/templates/templates/application/go/go.mod.template +4 -0
  75. package/dist/templates/templates/application/go/main.template +8 -0
  76. package/dist/templates/templates/application/go/test.template +11 -0
  77. package/dist/templates/templates/application/javascript/main.template +14 -0
  78. package/dist/templates/templates/application/javascript/test.template +8 -0
  79. package/dist/templates/templates/application/python/main.template +13 -0
  80. package/dist/templates/templates/application/python/requirements.txt.template +3 -0
  81. package/dist/templates/templates/application/python/test.template +8 -0
  82. package/dist/templates/templates/application/typescript/main.template +14 -0
  83. package/dist/templates/templates/application/typescript/test.template +8 -0
  84. package/dist/templates/templates/application/typescript/tsconfig.json.template +20 -0
  85. package/dist/templates/templates/config/README.md.template +82 -0
  86. package/dist/templates/templates/config/env.example.template +22 -0
  87. package/dist/templates/templates/config/gitignore.template +40 -0
  88. package/dist/templates/templates/config/tfwconfig.yml.template +69 -0
  89. package/dist/templates/templates/terraform/aws/_init.tf.template +24 -0
  90. package/dist/templates/templates/terraform/aws/inputs.tf.template +11 -0
  91. package/dist/templates/templates/terraform/azure/_init.tf.template +19 -0
  92. package/dist/templates/templates/terraform/azure/inputs.tf.template +11 -0
  93. package/dist/templates/templates/terraform/gcp/_init.tf.template +20 -0
  94. package/dist/templates/templates/terraform/gcp/inputs.tf.template +16 -0
  95. package/dist/templates/templates/terraform/locals.tf.template +9 -0
  96. package/dist/templates/templates/terraform/main.tf.template +8 -0
  97. package/dist/templates/templates/terraform/modules/inputs.tf.template +5 -0
  98. package/dist/templates/templates/terraform/modules/main.tf.template +2 -0
  99. package/dist/templates/templates/terraform/modules/outputs.tf.template +2 -0
  100. package/dist/templates/templates/terraform/outputs.tf.template +6 -0
  101. package/dist/templates/terraform/aws/_init.tf.template +24 -0
  102. package/dist/templates/terraform/aws/inputs.tf.template +11 -0
  103. package/dist/templates/terraform/azure/_init.tf.template +19 -0
  104. package/dist/templates/terraform/azure/inputs.tf.template +11 -0
  105. package/dist/templates/terraform/gcp/_init.tf.template +20 -0
  106. package/dist/templates/terraform/gcp/inputs.tf.template +16 -0
  107. package/dist/templates/terraform/locals.tf.template +9 -0
  108. package/dist/templates/terraform/main.tf.template +8 -0
  109. package/dist/templates/terraform/modules/inputs.tf.template +5 -0
  110. package/dist/templates/terraform/modules/main.tf.template +2 -0
  111. package/dist/templates/terraform/modules/outputs.tf.template +2 -0
  112. package/dist/templates/terraform/outputs.tf.template +6 -0
  113. package/dist/types/config.d.ts +92 -0
  114. package/dist/types/config.js +6 -0
  115. package/dist/types/context.d.ts +59 -0
  116. package/dist/types/context.js +6 -0
  117. package/dist/types/index.d.ts +7 -0
  118. package/dist/types/index.js +23 -0
  119. package/dist/types/plugins.d.ts +77 -0
  120. package/dist/types/plugins.js +6 -0
  121. package/dist/utils/cloud.d.ts +43 -0
  122. package/dist/utils/cloud.js +150 -0
  123. package/dist/utils/git.d.ts +88 -0
  124. package/dist/utils/git.js +258 -0
  125. package/dist/utils/logger.d.ts +67 -0
  126. package/dist/utils/logger.js +121 -0
  127. package/dist/utils/scaffolding.d.ts +92 -0
  128. package/dist/utils/scaffolding.js +338 -0
  129. package/dist/utils/templates.d.ts +25 -0
  130. package/dist/utils/templates.js +70 -0
  131. package/package.json +60 -0
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Environment setup
3
+ * Sets up cloud, VCS, and Terraform environment
4
+ */
5
+ import type { TerraflowConfig } from '../types/config';
6
+ import type { ExecutionContext } from '../types/context';
7
+ /**
8
+ * Environment setup utilities
9
+ */
10
+ export declare class EnvironmentSetup {
11
+ /**
12
+ * Load .env file from working directory
13
+ * Does NOT auto-convert to TF_VAR_* - only loads general environment variables
14
+ * @param workingDir - Working directory path
15
+ * @returns Record of environment variables from .env file
16
+ */
17
+ static loadEnvFile(workingDir: string): Record<string, string>;
18
+ /**
19
+ * Setup cloud provider environment (AWS, Azure, GCP)
20
+ * - Syncs AWS_REGION and AWS_DEFAULT_REGION
21
+ * - Fetches account/subscription/project IDs
22
+ * @returns Updated cloud info
23
+ */
24
+ static setupCloud(): Promise<ExecutionContext['cloud']>;
25
+ /**
26
+ * Setup VCS environment (git variables)
27
+ * Sets GitHub Actions and GitLab CI compatible variables
28
+ * @param context - Execution context
29
+ * @returns Updated context with VCS environment variables
30
+ */
31
+ static setupVcs(context: ExecutionContext): Promise<void>;
32
+ /**
33
+ * Setup Terraform variables from config
34
+ * Converts config.variables to TF_VAR_* environment variables
35
+ * Does NOT convert .env file variables to TF_VAR_*
36
+ * @param config - Terraflow configuration
37
+ */
38
+ static setupTerraformVariables(config: TerraflowConfig): void;
39
+ /**
40
+ * Setup logging configuration
41
+ * Sets Terraform log level if configured
42
+ * @param config - Terraflow configuration
43
+ */
44
+ static setupLogging(config: TerraflowConfig): void;
45
+ /**
46
+ * Resolve template variables in config recursively
47
+ * Uses template vars from context
48
+ * @param config - Terraflow configuration to resolve templates in
49
+ * @param context - Execution context with template variables
50
+ * @returns Configuration with templates resolved
51
+ */
52
+ static resolveTemplateVars(config: TerraflowConfig, context: ExecutionContext): TerraflowConfig;
53
+ /**
54
+ * Setup complete environment
55
+ * Executes all environment setup steps in order
56
+ * @param config - Terraflow configuration
57
+ * @param context - Execution context
58
+ * @returns Updated context with environment setup complete
59
+ */
60
+ static setup(config: TerraflowConfig, context: ExecutionContext): Promise<ExecutionContext>;
61
+ }
62
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ /**
3
+ * Environment setup
4
+ * Sets up cloud, VCS, and Terraform environment
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.EnvironmentSetup = void 0;
8
+ const fs_1 = require("fs");
9
+ const path_1 = require("path");
10
+ const dotenv_1 = require("dotenv");
11
+ const cloud_1 = require("../utils/cloud");
12
+ const logger_1 = require("../utils/logger");
13
+ const templates_1 = require("../utils/templates");
14
+ /**
15
+ * Environment setup utilities
16
+ */
17
+ class EnvironmentSetup {
18
+ /**
19
+ * Load .env file from working directory
20
+ * Does NOT auto-convert to TF_VAR_* - only loads general environment variables
21
+ * @param workingDir - Working directory path
22
+ * @returns Record of environment variables from .env file
23
+ */
24
+ static loadEnvFile(workingDir) {
25
+ const envPath = (0, path_1.join)(workingDir, '.env');
26
+ if (!(0, fs_1.existsSync)(envPath)) {
27
+ return {};
28
+ }
29
+ try {
30
+ const envContent = (0, fs_1.readFileSync)(envPath, 'utf8');
31
+ const parsed = (0, dotenv_1.parse)(envContent);
32
+ // Set environment variables in process.env (but don't convert to TF_VAR_*)
33
+ for (const key in parsed) {
34
+ if (Object.prototype.hasOwnProperty.call(parsed, key)) {
35
+ const value = parsed[key];
36
+ if (value !== undefined && process.env[key] === undefined) {
37
+ // Only set if not already in process.env (env takes precedence)
38
+ process.env[key] = value;
39
+ }
40
+ }
41
+ }
42
+ return parsed;
43
+ }
44
+ catch (error) {
45
+ logger_1.Logger.warn(`Failed to load .env file from ${workingDir}: ${error instanceof Error ? error.message : String(error)}`);
46
+ return {};
47
+ }
48
+ }
49
+ /**
50
+ * Setup cloud provider environment (AWS, Azure, GCP)
51
+ * - Syncs AWS_REGION and AWS_DEFAULT_REGION
52
+ * - Fetches account/subscription/project IDs
53
+ * @returns Updated cloud info
54
+ */
55
+ static async setupCloud() {
56
+ const cloud = await cloud_1.CloudUtils.detectCloud();
57
+ // Sync AWS region if AWS provider detected
58
+ if (cloud.provider === 'aws') {
59
+ const region = cloud_1.CloudUtils.getAwsRegion();
60
+ cloud.awsRegion = region;
61
+ }
62
+ return cloud;
63
+ }
64
+ /**
65
+ * Setup VCS environment (git variables)
66
+ * Sets GitHub Actions and GitLab CI compatible variables
67
+ * @param context - Execution context
68
+ * @returns Updated context with VCS environment variables
69
+ */
70
+ static async setupVcs(context) {
71
+ const { vcs } = context;
72
+ // Set basic git variables
73
+ if (vcs.branch) {
74
+ process.env.GIT_BRANCH = vcs.branch;
75
+ }
76
+ if (vcs.tag) {
77
+ process.env.GIT_TAG = vcs.tag;
78
+ }
79
+ if (vcs.commitSha) {
80
+ process.env.GIT_COMMIT_SHA = vcs.commitSha;
81
+ process.env.GIT_SHORT_SHA = vcs.shortSha || vcs.commitSha.substring(0, 7);
82
+ }
83
+ // Simulate GitHub Actions variables
84
+ if (vcs.githubRepository) {
85
+ process.env.GITHUB_REPOSITORY = vcs.githubRepository;
86
+ if (vcs.branch) {
87
+ process.env.GITHUB_REF = `refs/heads/${vcs.branch}`;
88
+ }
89
+ else if (vcs.tag) {
90
+ process.env.GITHUB_REF = `refs/tags/${vcs.tag}`;
91
+ }
92
+ if (vcs.commitSha) {
93
+ process.env.GITHUB_SHA = vcs.commitSha;
94
+ }
95
+ }
96
+ // Simulate GitLab CI variables
97
+ if (vcs.gitlabProjectPath) {
98
+ process.env.GITLAB_PROJECT_PATH = vcs.gitlabProjectPath;
99
+ if (vcs.branch) {
100
+ process.env.CI_COMMIT_REF_NAME = vcs.branch;
101
+ }
102
+ else if (vcs.tag) {
103
+ process.env.CI_COMMIT_REF_NAME = vcs.tag;
104
+ }
105
+ if (vcs.commitSha) {
106
+ process.env.CI_COMMIT_SHA = vcs.commitSha;
107
+ process.env.CI_COMMIT_SHORT_SHA = vcs.shortSha || vcs.commitSha.substring(0, 7);
108
+ }
109
+ }
110
+ }
111
+ /**
112
+ * Setup Terraform variables from config
113
+ * Converts config.variables to TF_VAR_* environment variables
114
+ * Does NOT convert .env file variables to TF_VAR_*
115
+ * @param config - Terraflow configuration
116
+ */
117
+ static setupTerraformVariables(config) {
118
+ if (!config.variables || typeof config.variables !== 'object') {
119
+ return;
120
+ }
121
+ for (const key in config.variables) {
122
+ if (Object.prototype.hasOwnProperty.call(config.variables, key)) {
123
+ const value = config.variables[key];
124
+ const envVarName = `TF_VAR_${key}`;
125
+ // Only set if not already in environment (env takes precedence)
126
+ if (process.env[envVarName] === undefined) {
127
+ if (value === null || value === undefined) {
128
+ process.env[envVarName] = '';
129
+ }
130
+ else if (typeof value === 'string') {
131
+ process.env[envVarName] = value;
132
+ }
133
+ else {
134
+ // Convert objects/arrays to JSON string
135
+ process.env[envVarName] = JSON.stringify(value);
136
+ }
137
+ }
138
+ }
139
+ }
140
+ }
141
+ /**
142
+ * Setup logging configuration
143
+ * Sets Terraform log level if configured
144
+ * @param config - Terraflow configuration
145
+ */
146
+ static setupLogging(config) {
147
+ const logging = config.logging;
148
+ if (!logging) {
149
+ return;
150
+ }
151
+ // Set Terraform log level
152
+ if (logging.terraform_log_level) {
153
+ process.env.TF_LOG = logging.terraform_log_level;
154
+ }
155
+ // Enable/disable Terraform log
156
+ if (logging.terraform_log !== undefined) {
157
+ if (!logging.terraform_log) {
158
+ // Disable terraform logging
159
+ delete process.env.TF_LOG;
160
+ }
161
+ else if (!process.env.TF_LOG) {
162
+ // Enable with default level if not set
163
+ process.env.TF_LOG = logging.terraform_log_level || 'INFO';
164
+ }
165
+ }
166
+ }
167
+ /**
168
+ * Resolve template variables in config recursively
169
+ * Uses template vars from context
170
+ * @param config - Terraflow configuration to resolve templates in
171
+ * @param context - Execution context with template variables
172
+ * @returns Configuration with templates resolved
173
+ */
174
+ static resolveTemplateVars(config, context) {
175
+ // Cast to Record<string, unknown> for template resolution
176
+ const configRecord = config;
177
+ const resolved = templates_1.TemplateUtils.resolveObject(configRecord, context.templateVars);
178
+ return resolved;
179
+ }
180
+ /**
181
+ * Setup complete environment
182
+ * Executes all environment setup steps in order
183
+ * @param config - Terraflow configuration
184
+ * @param context - Execution context
185
+ * @returns Updated context with environment setup complete
186
+ */
187
+ static async setup(config, context) {
188
+ // 1. Load .env file (bootstrap credentials)
189
+ EnvironmentSetup.loadEnvFile(context.workingDir);
190
+ // 2. Setup cloud environment (detect account IDs, regions)
191
+ const cloud = await EnvironmentSetup.setupCloud();
192
+ context.cloud = cloud;
193
+ // 3. Setup VCS environment (git branch, commit, repository)
194
+ await EnvironmentSetup.setupVcs(context);
195
+ // 4. Resolve template variables in config
196
+ const resolvedConfig = EnvironmentSetup.resolveTemplateVars(config, context);
197
+ // 5. Setup Terraform variables from config
198
+ EnvironmentSetup.setupTerraformVariables(resolvedConfig);
199
+ // 6. Setup logging configuration
200
+ EnvironmentSetup.setupLogging(resolvedConfig);
201
+ return context;
202
+ }
203
+ }
204
+ exports.EnvironmentSetup = EnvironmentSetup;
205
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Custom error classes for Terraflow
3
+ */
4
+ /**
5
+ * Base error class for Terraflow errors
6
+ */
7
+ export declare class TerraflowError extends Error {
8
+ constructor(message: string);
9
+ }
10
+ /**
11
+ * Validation error - thrown when validation fails
12
+ */
13
+ export declare class ValidationError extends TerraflowError {
14
+ constructor(message: string);
15
+ }
16
+ /**
17
+ * Configuration error - thrown when configuration is invalid
18
+ */
19
+ export declare class ConfigError extends TerraflowError {
20
+ constructor(message: string);
21
+ }
22
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /**
3
+ * Custom error classes for Terraflow
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ConfigError = exports.ValidationError = exports.TerraflowError = void 0;
7
+ /**
8
+ * Base error class for Terraflow errors
9
+ */
10
+ class TerraflowError extends Error {
11
+ constructor(message) {
12
+ super(message);
13
+ this.name = this.constructor.name;
14
+ Error.captureStackTrace(this, this.constructor);
15
+ }
16
+ }
17
+ exports.TerraflowError = TerraflowError;
18
+ /**
19
+ * Validation error - thrown when validation fails
20
+ */
21
+ class ValidationError extends TerraflowError {
22
+ constructor(message) {
23
+ super(message);
24
+ }
25
+ }
26
+ exports.ValidationError = ValidationError;
27
+ /**
28
+ * Configuration error - thrown when configuration is invalid
29
+ */
30
+ class ConfigError extends TerraflowError {
31
+ constructor(message) {
32
+ super(message);
33
+ }
34
+ }
35
+ exports.ConfigError = ConfigError;
36
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Plugin loader
3
+ * Convention-based plugin discovery and loading
4
+ */
5
+ import type { BackendPlugin, SecretsPlugin, AuthPlugin } from '../types/plugins';
6
+ /**
7
+ * Load backend plugin by name
8
+ * Convention: src/plugins/backends/{name}.ts exports {name}Backend
9
+ */
10
+ export declare function loadBackendPlugin(name: string): Promise<BackendPlugin>;
11
+ /**
12
+ * Load secrets plugin by name
13
+ * Convention: src/plugins/secrets/{name}.ts exports {name}Secrets or {name}SecretManager
14
+ */
15
+ export declare function loadSecretsPlugin(name: string): Promise<SecretsPlugin>;
16
+ /**
17
+ * Load auth plugin by name
18
+ * Convention: src/plugins/auth/{name}.ts exports {name}Auth or camelCase version
19
+ */
20
+ export declare function loadAuthPlugin(name: string): Promise<AuthPlugin>;
21
+ //# sourceMappingURL=plugin-loader.d.ts.map
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ /**
3
+ * Plugin loader
4
+ * Convention-based plugin discovery and loading
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.loadBackendPlugin = loadBackendPlugin;
41
+ exports.loadSecretsPlugin = loadSecretsPlugin;
42
+ exports.loadAuthPlugin = loadAuthPlugin;
43
+ /**
44
+ * Load backend plugin by name
45
+ * Convention: src/plugins/backends/{name}.ts exports {name}Backend
46
+ */
47
+ async function loadBackendPlugin(name) {
48
+ try {
49
+ // Try to load the plugin module
50
+ const pluginModule = await Promise.resolve(`${`../plugins/backends/${name}.js`}`).then(s => __importStar(require(s)));
51
+ const pluginName = `${name}Backend`;
52
+ const plugin = pluginModule[pluginName];
53
+ if (!plugin) {
54
+ throw new Error(`Backend plugin "${name}" not found. Expected export "${pluginName}" from src/plugins/backends/${name}.ts`);
55
+ }
56
+ return plugin;
57
+ }
58
+ catch (error) {
59
+ throw new Error(`Failed to load backend plugin "${name}": ${error instanceof Error ? error.message : String(error)}`);
60
+ }
61
+ }
62
+ /**
63
+ * Load secrets plugin by name
64
+ * Convention: src/plugins/secrets/{name}.ts exports {name}Secrets or {name}SecretManager
65
+ */
66
+ async function loadSecretsPlugin(name) {
67
+ try {
68
+ const pluginModule = await Promise.resolve(`${`../plugins/secrets/${name}.js`}`).then(s => __importStar(require(s)));
69
+ // Try common naming patterns based on actual plugin exports
70
+ // env -> envSecrets, aws-secrets -> awsSecrets, gcp-secret-manager -> gcpSecretManager
71
+ const pluginName1 = name === 'env'
72
+ ? 'envSecrets'
73
+ : name === 'aws-secrets'
74
+ ? 'awsSecrets'
75
+ : name === 'gcp-secret-manager'
76
+ ? 'gcpSecretManager'
77
+ : name === 'azure-keyvault'
78
+ ? 'azureKeyvault'
79
+ : `${name}Secrets`;
80
+ const plugin = pluginModule[pluginName1];
81
+ if (!plugin) {
82
+ // Try to find any exported object with a 'name' property matching our plugin name
83
+ for (const key in pluginModule) {
84
+ const exported = pluginModule[key];
85
+ if (exported &&
86
+ typeof exported === 'object' &&
87
+ 'name' in exported &&
88
+ exported.name === name) {
89
+ return exported;
90
+ }
91
+ }
92
+ throw new Error(`Secrets plugin "${name}" not found. Expected export "${pluginName1}" from src/plugins/secrets/${name}.ts`);
93
+ }
94
+ return plugin;
95
+ }
96
+ catch (error) {
97
+ throw new Error(`Failed to load secrets plugin "${name}": ${error instanceof Error ? error.message : String(error)}`);
98
+ }
99
+ }
100
+ /**
101
+ * Load auth plugin by name
102
+ * Convention: src/plugins/auth/{name}.ts exports {name}Auth or camelCase version
103
+ */
104
+ async function loadAuthPlugin(name) {
105
+ try {
106
+ const pluginModule = await Promise.resolve(`${`../plugins/auth/${name}.js`}`).then(s => __importStar(require(s)));
107
+ // Try common naming patterns based on actual plugin exports
108
+ // aws-assume-role -> awsAssumeRole
109
+ const pluginName1 = name === 'aws-assume-role'
110
+ ? 'awsAssumeRole'
111
+ : name === 'azure-service-principal'
112
+ ? 'azureServicePrincipal'
113
+ : name === 'gcp-service-account'
114
+ ? 'gcpServiceAccount'
115
+ : `${name}Auth`;
116
+ const plugin = pluginModule[pluginName1];
117
+ if (!plugin) {
118
+ // Try to find any exported object with a 'name' property matching our plugin name
119
+ for (const key in pluginModule) {
120
+ const exported = pluginModule[key];
121
+ if (exported &&
122
+ typeof exported === 'object' &&
123
+ 'name' in exported &&
124
+ exported.name === name) {
125
+ return exported;
126
+ }
127
+ }
128
+ throw new Error(`Auth plugin "${name}" not found. Expected export "${pluginName1}" from src/plugins/auth/${name}.ts`);
129
+ }
130
+ return plugin;
131
+ }
132
+ catch (error) {
133
+ throw new Error(`Failed to load auth plugin "${name}": ${error instanceof Error ? error.message : String(error)}`);
134
+ }
135
+ }
136
+ //# sourceMappingURL=plugin-loader.js.map
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Terraform executor
3
+ * Executes terraform commands with proper environment setup
4
+ */
5
+ import type { TerraflowConfig } from '../types/config';
6
+ import type { ExecutionContext } from '../types/context';
7
+ /**
8
+ * Terraform executor for running terraform commands
9
+ */
10
+ export declare class TerraformExecutor {
11
+ /**
12
+ * Execute full terraform workflow
13
+ * @param command - Terraform command (e.g., 'plan', 'apply', 'destroy')
14
+ * @param args - Additional terraform arguments
15
+ * @param config - Terraflow configuration
16
+ * @param context - Execution context
17
+ * @param options - Execution options
18
+ */
19
+ static execute(command: string, args: string[], config: TerraflowConfig, context: ExecutionContext, options?: {
20
+ skipCommitCheck?: boolean;
21
+ dryRun?: boolean;
22
+ }): Promise<void>;
23
+ /**
24
+ * Initialize terraform with backend configuration
25
+ * For local backend, runs terraform init without backend-config flags
26
+ * @param backendType - Backend type (e.g., 'local', 's3', 'azurerm', 'gcs')
27
+ * @param backendArgs - Backend configuration arguments (-backend-config flags)
28
+ * @param workingDir - Terraform working directory
29
+ */
30
+ static init(backendType: string, backendArgs: string[], workingDir: string): Promise<void>;
31
+ /**
32
+ * Select or create workspace
33
+ * @param workspaceName - Workspace name
34
+ * @param workingDir - Terraform working directory
35
+ */
36
+ static workspace(workspaceName: string, workingDir: string): Promise<void>;
37
+ /**
38
+ * Execute terraform command
39
+ * @param command - Terraform command (e.g., 'plan', 'apply', 'destroy')
40
+ * @param args - Additional terraform arguments
41
+ * @param workingDir - Terraform working directory
42
+ */
43
+ static runCommand(command: string, args: string[], workingDir: string): Promise<void>;
44
+ }
45
+ //# sourceMappingURL=terraform.d.ts.map