@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.
- package/LICENSE +22 -0
- package/README.md +278 -0
- package/RELEASE_SUMMARY.md +53 -0
- package/STANDARDS_COMPLIANCE.md +85 -0
- package/bin/terraflow.js +3 -0
- package/bin/tf.js +3 -0
- package/dist/commands/apply.d.ts +7 -0
- package/dist/commands/apply.js +12 -0
- package/dist/commands/base.d.ts +7 -0
- package/dist/commands/base.js +12 -0
- package/dist/commands/config.d.ts +25 -0
- package/dist/commands/config.js +354 -0
- package/dist/commands/destroy.d.ts +7 -0
- package/dist/commands/destroy.js +12 -0
- package/dist/commands/init.d.ts +68 -0
- package/dist/commands/init.js +131 -0
- package/dist/commands/plan.d.ts +7 -0
- package/dist/commands/plan.js +12 -0
- package/dist/core/backend-state.d.ts +25 -0
- package/dist/core/backend-state.js +77 -0
- package/dist/core/config.d.ts +83 -0
- package/dist/core/config.js +295 -0
- package/dist/core/context.d.ts +52 -0
- package/dist/core/context.js +192 -0
- package/dist/core/environment.d.ts +62 -0
- package/dist/core/environment.js +205 -0
- package/dist/core/errors.d.ts +22 -0
- package/dist/core/errors.js +36 -0
- package/dist/core/plugin-loader.d.ts +21 -0
- package/dist/core/plugin-loader.js +136 -0
- package/dist/core/terraform.d.ts +45 -0
- package/dist/core/terraform.js +247 -0
- package/dist/core/validator.d.ts +103 -0
- package/dist/core/validator.js +304 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +184 -0
- package/dist/plugins/auth/aws-assume-role.d.ts +10 -0
- package/dist/plugins/auth/aws-assume-role.js +110 -0
- package/dist/plugins/auth/azure-service-principal.d.ts +10 -0
- package/dist/plugins/auth/azure-service-principal.js +99 -0
- package/dist/plugins/auth/gcp-service-account.d.ts +10 -0
- package/dist/plugins/auth/gcp-service-account.js +105 -0
- package/dist/plugins/backends/azurerm.d.ts +10 -0
- package/dist/plugins/backends/azurerm.js +117 -0
- package/dist/plugins/backends/gcs.d.ts +10 -0
- package/dist/plugins/backends/gcs.js +75 -0
- package/dist/plugins/backends/local.d.ts +11 -0
- package/dist/plugins/backends/local.js +37 -0
- package/dist/plugins/backends/s3.d.ts +10 -0
- package/dist/plugins/backends/s3.js +185 -0
- package/dist/plugins/secrets/aws-secrets.d.ts +12 -0
- package/dist/plugins/secrets/aws-secrets.js +125 -0
- package/dist/plugins/secrets/azure-keyvault.d.ts +12 -0
- package/dist/plugins/secrets/azure-keyvault.js +178 -0
- package/dist/plugins/secrets/env.d.ts +24 -0
- package/dist/plugins/secrets/env.js +62 -0
- package/dist/plugins/secrets/gcp-secret-manager.d.ts +12 -0
- package/dist/plugins/secrets/gcp-secret-manager.js +157 -0
- package/dist/templates/application/go/go.mod.template +4 -0
- package/dist/templates/application/go/main.template +8 -0
- package/dist/templates/application/go/test.template +11 -0
- package/dist/templates/application/javascript/main.template +14 -0
- package/dist/templates/application/javascript/test.template +8 -0
- package/dist/templates/application/python/main.template +13 -0
- package/dist/templates/application/python/requirements.txt.template +3 -0
- package/dist/templates/application/python/test.template +8 -0
- package/dist/templates/application/typescript/main.template +14 -0
- package/dist/templates/application/typescript/test.template +8 -0
- package/dist/templates/application/typescript/tsconfig.json.template +20 -0
- package/dist/templates/config/README.md.template +82 -0
- package/dist/templates/config/env.example.template +22 -0
- package/dist/templates/config/gitignore.template +40 -0
- package/dist/templates/config/tfwconfig.yml.template +69 -0
- package/dist/templates/templates/application/go/go.mod.template +4 -0
- package/dist/templates/templates/application/go/main.template +8 -0
- package/dist/templates/templates/application/go/test.template +11 -0
- package/dist/templates/templates/application/javascript/main.template +14 -0
- package/dist/templates/templates/application/javascript/test.template +8 -0
- package/dist/templates/templates/application/python/main.template +13 -0
- package/dist/templates/templates/application/python/requirements.txt.template +3 -0
- package/dist/templates/templates/application/python/test.template +8 -0
- package/dist/templates/templates/application/typescript/main.template +14 -0
- package/dist/templates/templates/application/typescript/test.template +8 -0
- package/dist/templates/templates/application/typescript/tsconfig.json.template +20 -0
- package/dist/templates/templates/config/README.md.template +82 -0
- package/dist/templates/templates/config/env.example.template +22 -0
- package/dist/templates/templates/config/gitignore.template +40 -0
- package/dist/templates/templates/config/tfwconfig.yml.template +69 -0
- package/dist/templates/templates/terraform/aws/_init.tf.template +24 -0
- package/dist/templates/templates/terraform/aws/inputs.tf.template +11 -0
- package/dist/templates/templates/terraform/azure/_init.tf.template +19 -0
- package/dist/templates/templates/terraform/azure/inputs.tf.template +11 -0
- package/dist/templates/templates/terraform/gcp/_init.tf.template +20 -0
- package/dist/templates/templates/terraform/gcp/inputs.tf.template +16 -0
- package/dist/templates/templates/terraform/locals.tf.template +9 -0
- package/dist/templates/templates/terraform/main.tf.template +8 -0
- package/dist/templates/templates/terraform/modules/inputs.tf.template +5 -0
- package/dist/templates/templates/terraform/modules/main.tf.template +2 -0
- package/dist/templates/templates/terraform/modules/outputs.tf.template +2 -0
- package/dist/templates/templates/terraform/outputs.tf.template +6 -0
- package/dist/templates/terraform/aws/_init.tf.template +24 -0
- package/dist/templates/terraform/aws/inputs.tf.template +11 -0
- package/dist/templates/terraform/azure/_init.tf.template +19 -0
- package/dist/templates/terraform/azure/inputs.tf.template +11 -0
- package/dist/templates/terraform/gcp/_init.tf.template +20 -0
- package/dist/templates/terraform/gcp/inputs.tf.template +16 -0
- package/dist/templates/terraform/locals.tf.template +9 -0
- package/dist/templates/terraform/main.tf.template +8 -0
- package/dist/templates/terraform/modules/inputs.tf.template +5 -0
- package/dist/templates/terraform/modules/main.tf.template +2 -0
- package/dist/templates/terraform/modules/outputs.tf.template +2 -0
- package/dist/templates/terraform/outputs.tf.template +6 -0
- package/dist/types/config.d.ts +92 -0
- package/dist/types/config.js +6 -0
- package/dist/types/context.d.ts +59 -0
- package/dist/types/context.js +6 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.js +23 -0
- package/dist/types/plugins.d.ts +77 -0
- package/dist/types/plugins.js +6 -0
- package/dist/utils/cloud.d.ts +43 -0
- package/dist/utils/cloud.js +150 -0
- package/dist/utils/git.d.ts +88 -0
- package/dist/utils/git.js +258 -0
- package/dist/utils/logger.d.ts +67 -0
- package/dist/utils/logger.js +121 -0
- package/dist/utils/scaffolding.d.ts +92 -0
- package/dist/utils/scaffolding.js +338 -0
- package/dist/utils/templates.d.ts +25 -0
- package/dist/utils/templates.js +70 -0
- package/package.json +60 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution context type definitions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Cloud provider information
|
|
6
|
+
*/
|
|
7
|
+
export interface CloudInfo {
|
|
8
|
+
/** Detected cloud provider: aws | azure | gcp | none */
|
|
9
|
+
provider: 'aws' | 'azure' | 'gcp' | 'none';
|
|
10
|
+
/** AWS account ID (if AWS) */
|
|
11
|
+
awsAccountId?: string;
|
|
12
|
+
/** AWS region */
|
|
13
|
+
awsRegion?: string;
|
|
14
|
+
/** Azure subscription ID (if Azure) */
|
|
15
|
+
azureSubscriptionId?: string;
|
|
16
|
+
/** Azure tenant ID (if Azure) */
|
|
17
|
+
azureTenantId?: string;
|
|
18
|
+
/** GCP project ID (if GCP) */
|
|
19
|
+
gcpProjectId?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Git/VCS information
|
|
23
|
+
*/
|
|
24
|
+
export interface VcsInfo {
|
|
25
|
+
/** Current git branch */
|
|
26
|
+
branch?: string;
|
|
27
|
+
/** Current git tag */
|
|
28
|
+
tag?: string;
|
|
29
|
+
/** Full git commit SHA */
|
|
30
|
+
commitSha?: string;
|
|
31
|
+
/** Short git commit SHA */
|
|
32
|
+
shortSha?: string;
|
|
33
|
+
/** GitHub repository (owner/repo) */
|
|
34
|
+
githubRepository?: string;
|
|
35
|
+
/** GitLab project path */
|
|
36
|
+
gitlabProjectPath?: string;
|
|
37
|
+
/** Whether working directory is clean */
|
|
38
|
+
isClean?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Execution context passed to plugins and commands
|
|
42
|
+
*/
|
|
43
|
+
export interface ExecutionContext {
|
|
44
|
+
/** Resolved workspace name */
|
|
45
|
+
workspace: string;
|
|
46
|
+
/** Working directory path */
|
|
47
|
+
workingDir: string;
|
|
48
|
+
/** Cloud provider information */
|
|
49
|
+
cloud: CloudInfo;
|
|
50
|
+
/** VCS information */
|
|
51
|
+
vcs: VcsInfo;
|
|
52
|
+
/** Machine hostname */
|
|
53
|
+
hostname: string;
|
|
54
|
+
/** Environment variables (sanitized, no secrets) */
|
|
55
|
+
env: Record<string, string>;
|
|
56
|
+
/** Template variables for config resolution */
|
|
57
|
+
templateVars: Record<string, string>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Type exports for Terraflow CLI
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./config"), exports);
|
|
21
|
+
__exportStar(require("./context"), exports);
|
|
22
|
+
__exportStar(require("./plugins"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin system interfaces for Terraflow CLI
|
|
3
|
+
*/
|
|
4
|
+
import type { ExecutionContext } from './context';
|
|
5
|
+
import type { BackendConfig, SecretsConfig, AuthConfig } from './config';
|
|
6
|
+
/**
|
|
7
|
+
* Backend plugin interface
|
|
8
|
+
* Handles Terraform backend configuration
|
|
9
|
+
*/
|
|
10
|
+
export interface BackendPlugin {
|
|
11
|
+
/** Plugin name (must match the plugin file name) */
|
|
12
|
+
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* Validate backend configuration
|
|
15
|
+
* @param config - Backend configuration to validate
|
|
16
|
+
* @throws {Error} If configuration is invalid
|
|
17
|
+
*/
|
|
18
|
+
validate(config: BackendConfig): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Generate Terraform backend configuration arguments
|
|
21
|
+
* @param config - Backend configuration
|
|
22
|
+
* @param context - Execution context
|
|
23
|
+
* @returns Array of backend-config arguments for terraform init
|
|
24
|
+
*/
|
|
25
|
+
getBackendConfig(config: BackendConfig, context: ExecutionContext): Promise<string[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Optional setup hook for backend initialization
|
|
28
|
+
* Called before terraform init
|
|
29
|
+
* @param config - Backend configuration
|
|
30
|
+
* @param context - Execution context
|
|
31
|
+
*/
|
|
32
|
+
setup?(config: BackendConfig, context: ExecutionContext): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Secrets plugin interface
|
|
36
|
+
* Retrieves secrets and converts them to TF_VAR_* environment variables
|
|
37
|
+
*/
|
|
38
|
+
export interface SecretsPlugin {
|
|
39
|
+
/** Plugin name (must match the plugin file name) */
|
|
40
|
+
name: string;
|
|
41
|
+
/**
|
|
42
|
+
* Validate secrets configuration
|
|
43
|
+
* @param config - Secrets configuration to validate
|
|
44
|
+
* @throws {Error} If configuration is invalid
|
|
45
|
+
*/
|
|
46
|
+
validate(config: SecretsConfig): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Retrieve secrets and return as TF_VAR_* environment variables
|
|
49
|
+
* All keys are automatically prefixed with TF_VAR_
|
|
50
|
+
* @param config - Secrets configuration
|
|
51
|
+
* @param context - Execution context
|
|
52
|
+
* @returns Record of environment variable key-value pairs (already prefixed with TF_VAR_)
|
|
53
|
+
*/
|
|
54
|
+
getSecrets(config: SecretsConfig, context: ExecutionContext): Promise<Record<string, string>>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Auth plugin interface
|
|
58
|
+
* Handles authentication and returns temporary credentials as environment variables
|
|
59
|
+
*/
|
|
60
|
+
export interface AuthPlugin {
|
|
61
|
+
/** Plugin name (must match the plugin file name) */
|
|
62
|
+
name: string;
|
|
63
|
+
/**
|
|
64
|
+
* Validate auth configuration
|
|
65
|
+
* @param config - Auth configuration to validate
|
|
66
|
+
* @throws {Error} If configuration is invalid
|
|
67
|
+
*/
|
|
68
|
+
validate(config: AuthConfig): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Authenticate and return credentials as environment variables
|
|
71
|
+
* @param config - Auth configuration
|
|
72
|
+
* @param context - Execution context
|
|
73
|
+
* @returns Record of environment variable key-value pairs for credentials
|
|
74
|
+
*/
|
|
75
|
+
authenticate(config: AuthConfig, context: ExecutionContext): Promise<Record<string, string>>;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=plugins.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud provider detection utility
|
|
3
|
+
* Detects and retrieves cloud provider information
|
|
4
|
+
*/
|
|
5
|
+
import type { CloudInfo } from '../types/context.js';
|
|
6
|
+
/**
|
|
7
|
+
* Cloud provider detection utilities
|
|
8
|
+
*/
|
|
9
|
+
export declare class CloudUtils {
|
|
10
|
+
/**
|
|
11
|
+
* Detect cloud provider from environment
|
|
12
|
+
* @returns Cloud information
|
|
13
|
+
*/
|
|
14
|
+
static detectCloud(): Promise<CloudInfo>;
|
|
15
|
+
/**
|
|
16
|
+
* Get AWS account ID via `aws sts get-caller-identity`
|
|
17
|
+
* @returns AWS account ID or undefined
|
|
18
|
+
*/
|
|
19
|
+
static getAwsAccountId(): Promise<string | undefined>;
|
|
20
|
+
/**
|
|
21
|
+
* Get AWS region from environment variables
|
|
22
|
+
* Syncs AWS_REGION and AWS_DEFAULT_REGION
|
|
23
|
+
* Defaults to us-east-1 if not set
|
|
24
|
+
* @returns AWS region
|
|
25
|
+
*/
|
|
26
|
+
static getAwsRegion(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Get Azure subscription ID via `az account show`
|
|
29
|
+
* @returns Azure subscription ID or undefined
|
|
30
|
+
*/
|
|
31
|
+
static getAzureSubscriptionId(): Promise<string | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Get Azure tenant ID via `az account show`
|
|
34
|
+
* @returns Azure tenant ID or undefined
|
|
35
|
+
*/
|
|
36
|
+
static getAzureTenantId(): Promise<string | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Get GCP project ID via `gcloud config get-value project`
|
|
39
|
+
* @returns GCP project ID or undefined
|
|
40
|
+
*/
|
|
41
|
+
static getGcpProjectId(): Promise<string | undefined>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=cloud.d.ts.map
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cloud provider detection utility
|
|
4
|
+
* Detects and retrieves cloud provider information
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.CloudUtils = void 0;
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
/**
|
|
10
|
+
* Cloud provider detection utilities
|
|
11
|
+
*/
|
|
12
|
+
class CloudUtils {
|
|
13
|
+
/**
|
|
14
|
+
* Detect cloud provider from environment
|
|
15
|
+
* @returns Cloud information
|
|
16
|
+
*/
|
|
17
|
+
static async detectCloud() {
|
|
18
|
+
const cloud = {
|
|
19
|
+
provider: 'none',
|
|
20
|
+
};
|
|
21
|
+
// Check for AWS
|
|
22
|
+
if (process.env.AWS_ACCESS_KEY_ID || process.env.AWS_PROFILE || process.env.AWS_REGION) {
|
|
23
|
+
cloud.provider = 'aws';
|
|
24
|
+
cloud.awsRegion = CloudUtils.getAwsRegion();
|
|
25
|
+
try {
|
|
26
|
+
cloud.awsAccountId = await CloudUtils.getAwsAccountId();
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// Account ID fetch failed, continue without it
|
|
30
|
+
}
|
|
31
|
+
return cloud;
|
|
32
|
+
}
|
|
33
|
+
// Check for Azure
|
|
34
|
+
if (process.env.AZURE_CLIENT_ID || process.env.ARM_CLIENT_ID) {
|
|
35
|
+
cloud.provider = 'azure';
|
|
36
|
+
try {
|
|
37
|
+
cloud.azureSubscriptionId = await CloudUtils.getAzureSubscriptionId();
|
|
38
|
+
cloud.azureTenantId = await CloudUtils.getAzureTenantId();
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Subscription/Tenant ID fetch failed, continue without it
|
|
42
|
+
}
|
|
43
|
+
return cloud;
|
|
44
|
+
}
|
|
45
|
+
// Check for GCP
|
|
46
|
+
if (process.env.GOOGLE_APPLICATION_CREDENTIALS || process.env.GCLOUD_PROJECT) {
|
|
47
|
+
cloud.provider = 'gcp';
|
|
48
|
+
try {
|
|
49
|
+
cloud.gcpProjectId = await CloudUtils.getGcpProjectId();
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// Project ID fetch failed, continue without it
|
|
53
|
+
}
|
|
54
|
+
return cloud;
|
|
55
|
+
}
|
|
56
|
+
return cloud;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get AWS account ID via `aws sts get-caller-identity`
|
|
60
|
+
* @returns AWS account ID or undefined
|
|
61
|
+
*/
|
|
62
|
+
static async getAwsAccountId() {
|
|
63
|
+
try {
|
|
64
|
+
const result = (0, child_process_1.execSync)('aws sts get-caller-identity --output json', {
|
|
65
|
+
encoding: 'utf8',
|
|
66
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
67
|
+
});
|
|
68
|
+
const identity = JSON.parse(result);
|
|
69
|
+
return identity.Account;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get AWS region from environment variables
|
|
77
|
+
* Syncs AWS_REGION and AWS_DEFAULT_REGION
|
|
78
|
+
* Defaults to us-east-1 if not set
|
|
79
|
+
* @returns AWS region
|
|
80
|
+
*/
|
|
81
|
+
static getAwsRegion() {
|
|
82
|
+
let region = process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION;
|
|
83
|
+
// Sync AWS_REGION and AWS_DEFAULT_REGION
|
|
84
|
+
if (process.env.AWS_REGION && !process.env.AWS_DEFAULT_REGION) {
|
|
85
|
+
process.env.AWS_DEFAULT_REGION = process.env.AWS_REGION;
|
|
86
|
+
}
|
|
87
|
+
else if (process.env.AWS_DEFAULT_REGION && !process.env.AWS_REGION) {
|
|
88
|
+
process.env.AWS_REGION = process.env.AWS_DEFAULT_REGION;
|
|
89
|
+
}
|
|
90
|
+
// Default to us-east-1 if not set
|
|
91
|
+
if (!region) {
|
|
92
|
+
region = 'us-east-1';
|
|
93
|
+
process.env.AWS_REGION = region;
|
|
94
|
+
process.env.AWS_DEFAULT_REGION = region;
|
|
95
|
+
}
|
|
96
|
+
return region;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get Azure subscription ID via `az account show`
|
|
100
|
+
* @returns Azure subscription ID or undefined
|
|
101
|
+
*/
|
|
102
|
+
static async getAzureSubscriptionId() {
|
|
103
|
+
try {
|
|
104
|
+
const result = (0, child_process_1.execSync)('az account show --output json', {
|
|
105
|
+
encoding: 'utf8',
|
|
106
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
107
|
+
});
|
|
108
|
+
const account = JSON.parse(result);
|
|
109
|
+
return account.id;
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get Azure tenant ID via `az account show`
|
|
117
|
+
* @returns Azure tenant ID or undefined
|
|
118
|
+
*/
|
|
119
|
+
static async getAzureTenantId() {
|
|
120
|
+
try {
|
|
121
|
+
const result = (0, child_process_1.execSync)('az account show --output json', {
|
|
122
|
+
encoding: 'utf8',
|
|
123
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
124
|
+
});
|
|
125
|
+
const account = JSON.parse(result);
|
|
126
|
+
return account.tenantId;
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get GCP project ID via `gcloud config get-value project`
|
|
134
|
+
* @returns GCP project ID or undefined
|
|
135
|
+
*/
|
|
136
|
+
static async getGcpProjectId() {
|
|
137
|
+
try {
|
|
138
|
+
const result = (0, child_process_1.execSync)('gcloud config get-value project', {
|
|
139
|
+
encoding: 'utf8',
|
|
140
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
141
|
+
});
|
|
142
|
+
return result.trim() || undefined;
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.CloudUtils = CloudUtils;
|
|
150
|
+
//# sourceMappingURL=cloud.js.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git operations utility
|
|
3
|
+
* Provides git-related functionality for workspace derivation
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Git utilities for workspace derivation and VCS information
|
|
7
|
+
*/
|
|
8
|
+
export declare class GitUtils {
|
|
9
|
+
/**
|
|
10
|
+
* Check if current directory is in a git repository
|
|
11
|
+
* @param cwd - Working directory to check
|
|
12
|
+
* @returns True if in a git repository
|
|
13
|
+
*/
|
|
14
|
+
static isGitRepository(cwd?: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Get current git branch name
|
|
17
|
+
* @param cwd - Working directory
|
|
18
|
+
* @returns Branch name or undefined if not in git repo or not on a branch
|
|
19
|
+
*/
|
|
20
|
+
static getBranch(cwd?: string): Promise<string | undefined>;
|
|
21
|
+
/**
|
|
22
|
+
* Get current git tag if HEAD is on a tag
|
|
23
|
+
* @param cwd - Working directory
|
|
24
|
+
* @returns Tag name or undefined if not on a tag
|
|
25
|
+
*/
|
|
26
|
+
static getTag(cwd?: string): Promise<string | undefined>;
|
|
27
|
+
/**
|
|
28
|
+
* Get git commit SHA (full)
|
|
29
|
+
* @param cwd - Working directory
|
|
30
|
+
* @returns Full commit SHA or undefined
|
|
31
|
+
*/
|
|
32
|
+
static getCommitSha(cwd?: string): Promise<string | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* Get short git commit SHA (7 characters)
|
|
35
|
+
* @param cwd - Working directory
|
|
36
|
+
* @returns Short commit SHA or undefined
|
|
37
|
+
*/
|
|
38
|
+
static getShortSha(cwd?: string): Promise<string | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Check if git working directory is clean (no uncommitted changes)
|
|
41
|
+
* @param cwd - Working directory
|
|
42
|
+
* @returns True if working directory is clean
|
|
43
|
+
*/
|
|
44
|
+
static isClean(cwd?: string): Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Get GitHub repository name from git remote (format: owner/repo)
|
|
47
|
+
* @param cwd - Working directory
|
|
48
|
+
* @returns Repository name in format "owner/repo" or undefined
|
|
49
|
+
*/
|
|
50
|
+
static getGithubRepository(cwd?: string): Promise<string | undefined>;
|
|
51
|
+
/**
|
|
52
|
+
* Get GitLab project path from git remote
|
|
53
|
+
* @param cwd - Working directory
|
|
54
|
+
* @returns GitLab project path or undefined
|
|
55
|
+
*/
|
|
56
|
+
static getGitlabProjectPath(cwd?: string): Promise<string | undefined>;
|
|
57
|
+
/**
|
|
58
|
+
* Parse GitHub URL to extract owner/repo
|
|
59
|
+
* Supports https://, git@, and git:// formats
|
|
60
|
+
* @param url - Git remote URL
|
|
61
|
+
* @returns Repository name in format "owner/repo" or undefined
|
|
62
|
+
*/
|
|
63
|
+
static parseGithubUrl(url: string): string | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Parse GitLab URL to extract project path
|
|
66
|
+
* Supports https:// and git@ formats
|
|
67
|
+
* @param url - Git remote URL
|
|
68
|
+
* @returns GitLab project path or undefined
|
|
69
|
+
*/
|
|
70
|
+
static parseGitlabUrl(url: string): string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Check if a branch name is ephemeral (has a prefix like "feature/")
|
|
73
|
+
* Uses regex: /^[^/]+\//
|
|
74
|
+
* @param branchName - Branch name to check
|
|
75
|
+
* @returns True if branch is ephemeral
|
|
76
|
+
*/
|
|
77
|
+
static isEphemeralBranch(branchName: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Sanitize workspace name according to spec
|
|
80
|
+
* - Remove refs/heads/ or refs/tags/ prefix
|
|
81
|
+
* - Replace invalid characters (/ and spaces) with hyphens
|
|
82
|
+
* - Result must match /^[a-zA-Z0-9_-]+$/
|
|
83
|
+
* @param name - Workspace name to sanitize
|
|
84
|
+
* @returns Sanitized workspace name
|
|
85
|
+
*/
|
|
86
|
+
static sanitizeWorkspaceName(name: string): string;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=git.d.ts.map
|