@payfit/iac 0.1.0-ephemeral-nx-common-packages-migration.0
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/README.md +85 -0
- package/dist/executors/stack-migration/README.md +79 -0
- package/dist/executors/stack-migration/lib/constants.d.ts +33 -0
- package/dist/executors/stack-migration/lib/constants.js +44 -0
- package/dist/executors/stack-migration/lib/constants.js.map +1 -0
- package/dist/executors/stack-migration/lib/file-operations.d.ts +23 -0
- package/dist/executors/stack-migration/lib/file-operations.js +121 -0
- package/dist/executors/stack-migration/lib/file-operations.js.map +1 -0
- package/dist/executors/stack-migration/lib/git-operations.d.ts +19 -0
- package/dist/executors/stack-migration/lib/git-operations.js +90 -0
- package/dist/executors/stack-migration/lib/git-operations.js.map +1 -0
- package/dist/executors/stack-migration/lib/index.d.ts +10 -0
- package/dist/executors/stack-migration/lib/index.js +14 -0
- package/dist/executors/stack-migration/lib/index.js.map +1 -0
- package/dist/executors/stack-migration/lib/logger.d.ts +9 -0
- package/dist/executors/stack-migration/lib/logger.js +33 -0
- package/dist/executors/stack-migration/lib/logger.js.map +1 -0
- package/dist/executors/stack-migration/lib/migration-helper.d.ts +40 -0
- package/dist/executors/stack-migration/lib/migration-helper.js +209 -0
- package/dist/executors/stack-migration/lib/migration-helper.js.map +1 -0
- package/dist/executors/stack-migration/lib/migration-tool.d.ts +71 -0
- package/dist/executors/stack-migration/lib/migration-tool.js +857 -0
- package/dist/executors/stack-migration/lib/migration-tool.js.map +1 -0
- package/dist/executors/stack-migration/lib/path-builder.d.ts +20 -0
- package/dist/executors/stack-migration/lib/path-builder.js +58 -0
- package/dist/executors/stack-migration/lib/path-builder.js.map +1 -0
- package/dist/executors/stack-migration/lib/spacelift-client.d.ts +25 -0
- package/dist/executors/stack-migration/lib/spacelift-client.js +117 -0
- package/dist/executors/stack-migration/lib/spacelift-client.js.map +1 -0
- package/dist/executors/stack-migration/lib/templates/index.d.ts +7 -0
- package/dist/executors/stack-migration/lib/templates/index.js +11 -0
- package/dist/executors/stack-migration/lib/templates/index.js.map +1 -0
- package/dist/executors/stack-migration/lib/templates/mermaid-diagram.d.ts +13 -0
- package/dist/executors/stack-migration/lib/templates/mermaid-diagram.js +45 -0
- package/dist/executors/stack-migration/lib/templates/mermaid-diagram.js.map +1 -0
- package/dist/executors/stack-migration/lib/templates/message-templates.d.ts +16 -0
- package/dist/executors/stack-migration/lib/templates/message-templates.js +42 -0
- package/dist/executors/stack-migration/lib/templates/message-templates.js.map +1 -0
- package/dist/executors/stack-migration/lib/templates/pr-templates.d.ts +32 -0
- package/dist/executors/stack-migration/lib/templates/pr-templates.js +108 -0
- package/dist/executors/stack-migration/lib/templates/pr-templates.js.map +1 -0
- package/dist/executors/stack-migration/lib/templates/procedure-template.d.ts +6 -0
- package/dist/executors/stack-migration/lib/templates/procedure-template.js +62 -0
- package/dist/executors/stack-migration/lib/templates/procedure-template.js.map +1 -0
- package/dist/executors/stack-migration/lib/types.d.ts +53 -0
- package/dist/executors/stack-migration/lib/types.js +3 -0
- package/dist/executors/stack-migration/lib/types.js.map +1 -0
- package/dist/executors/stack-migration/schema.d.ts +20 -0
- package/dist/executors/stack-migration/schema.json +60 -0
- package/dist/executors/stack-migration/stack-migration.d.ts +4 -0
- package/dist/executors/stack-migration/stack-migration.js +79 -0
- package/dist/executors/stack-migration/stack-migration.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +155 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/terraform-detection.d.ts +2 -0
- package/dist/utils/terraform-detection.js +10 -0
- package/dist/utils/terraform-detection.js.map +1 -0
- package/executors.json +9 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @payfit/iac
|
|
2
|
+
|
|
3
|
+
Nx plugin for infrastructure as code operations.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx nx add @payfit/iac
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
### OpenTofu/Terraform Module Management
|
|
14
|
+
|
|
15
|
+
The plugin provides automatic formatting and linting for OpenTofu/Terraform modules:
|
|
16
|
+
|
|
17
|
+
- Running `tofu fmt` to format code
|
|
18
|
+
- Running `tflint` for linting
|
|
19
|
+
- Running `tofu validate` for validation
|
|
20
|
+
- Automatic version management for modules
|
|
21
|
+
|
|
22
|
+
#### OpenTofu/Terraform Detection
|
|
23
|
+
|
|
24
|
+
The plugin automatically detects OpenTofu/Terraform modules by looking for both:
|
|
25
|
+
|
|
26
|
+
- A `.spacelift/config.yml` file
|
|
27
|
+
- A `main.tf` file in your project root
|
|
28
|
+
|
|
29
|
+
When these files are present, the plugin will automatically configure the following targets:
|
|
30
|
+
|
|
31
|
+
- `tofu-format`: Format OpenTofu code (with `check` and `write` configurations)
|
|
32
|
+
- `lint`: Lint and validate OpenTofu code using tflint and tofu validate
|
|
33
|
+
- `nx-release-publish`: Configured as noop (Spacelift handles deployment from Git tags)
|
|
34
|
+
- `build`: Configured as noop (Spacelift handles building artifacts)
|
|
35
|
+
|
|
36
|
+
#### NamedInputs for Optimal Caching
|
|
37
|
+
|
|
38
|
+
The plugin expects a `terraform` namedInput to be defined in your workspace `nx.json` for optimal caching and affected detection:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"namedInputs": {
|
|
43
|
+
"terraform": ["{projectRoot}/**/*.tf", "{projectRoot}/**/*.tpl", "{projectRoot}/.terraform-docs.yml", "{projectRoot}/README.md.tpl", "{projectRoot}/.spacelift/**/*", "{projectRoot}/project.json", "sharedGlobals"]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
All Terraform targets (`build`, `tofu-format`, `lint`) use this namedInput, ensuring they only run when relevant files change.
|
|
49
|
+
|
|
50
|
+
**Note**: If the `terraform` namedInput is not defined in your workspace, the plugin will fall back to using the `production` namedInput.
|
|
51
|
+
|
|
52
|
+
#### Usage
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Format terraform code (check mode)
|
|
56
|
+
nx run <terraform-project>:tofu-format
|
|
57
|
+
|
|
58
|
+
# Format terraform code (write mode)
|
|
59
|
+
nx run <terraform-project>:tofu-format:write
|
|
60
|
+
|
|
61
|
+
# Lint terraform code
|
|
62
|
+
nx run <terraform-project>:lint
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Executors
|
|
66
|
+
|
|
67
|
+
### Stack Migration
|
|
68
|
+
|
|
69
|
+
Migrate Spacelift stacks from iac-deploy to repository-level metastacks.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
nx run <project>:stack-migration --command=run
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
See [Stack Migration README](./src/executors/stack-migration/README.md) for detailed documentation.
|
|
76
|
+
|
|
77
|
+
## Development
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Build
|
|
81
|
+
npx nx build iac
|
|
82
|
+
|
|
83
|
+
# Test
|
|
84
|
+
npx nx test iac
|
|
85
|
+
```
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Stack Migration Executor
|
|
2
|
+
|
|
3
|
+
Migrate Spacelift stacks from iac-deploy to repository-level metastacks.
|
|
4
|
+
|
|
5
|
+
## Migration Flow
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
flowchart TD
|
|
9
|
+
subgraph Phase1["📦 1: Setup"]
|
|
10
|
+
A[init] --> B[Create PRs + Scripts]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
subgraph Phase2["🔒 2: Safety & Enrollment"]
|
|
14
|
+
B --> C[Merge Safety Net PR]
|
|
15
|
+
C --> D[Merge Domain Enrollment PR]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
subgraph Phase3["🧹 3: State Management"]
|
|
19
|
+
D --> E[Run State Removal]
|
|
20
|
+
E --> F[Merge iac-deploy Cleanup PR]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
subgraph Phase4["✅ 4: Complete"]
|
|
24
|
+
F --> G[Merge Service Repo PR]
|
|
25
|
+
G --> H[Run Cleanup]
|
|
26
|
+
H --> I[Merge Post-Migration Cleanup PR]
|
|
27
|
+
end
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Full migration (recommended)
|
|
34
|
+
nx run <project>:stack-migration --command=run
|
|
35
|
+
|
|
36
|
+
# Preview changes first
|
|
37
|
+
nx run <project>:stack-migration --command=run --dry-run
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Commands
|
|
41
|
+
|
|
42
|
+
| Command | Description |
|
|
43
|
+
| ----------------------- | --------------------------------------------- |
|
|
44
|
+
| `run` | Execute full migration workflow |
|
|
45
|
+
| `init` | Clone repos, load config |
|
|
46
|
+
| `state` | Show migration state |
|
|
47
|
+
| `enroll` | Create domain enrollment PR |
|
|
48
|
+
| `generate-tf-migration` | Create service PR + state removal script |
|
|
49
|
+
| `iac-deploy-cleanup` | Create iac-deploy cleanup PR |
|
|
50
|
+
| `generate-procedure` | Generate procedure doc |
|
|
51
|
+
| `cleanup` | Create post-migration PR + remove local files |
|
|
52
|
+
| `help` | Show usage information |
|
|
53
|
+
|
|
54
|
+
## Execution Order
|
|
55
|
+
|
|
56
|
+
| Step | Action | Type |
|
|
57
|
+
| ---- | ----------------------------------- | --------- |
|
|
58
|
+
| 1 | Merge **Safety Net** PR | 🔀 PR |
|
|
59
|
+
| 2 | Merge **Domain Enrollment** PR | 🔀 PR |
|
|
60
|
+
| 3 | Run state removal script | 🔧 Manual |
|
|
61
|
+
| 4 | Merge **iac-deploy Cleanup** PR | 🔀 PR |
|
|
62
|
+
| 5 | Merge **Service Repo** PR | 🔀 PR |
|
|
63
|
+
| 6 | Run cleanup | 🔧 Manual |
|
|
64
|
+
| 7 | Merge **Post-Migration Cleanup** PR | 🔀 PR |
|
|
65
|
+
|
|
66
|
+
## Files Generated
|
|
67
|
+
|
|
68
|
+
| File | Purpose |
|
|
69
|
+
| ------------------------------------- | -------------------------------- |
|
|
70
|
+
| `.migration-state.json` | Migration state (resume anytime) |
|
|
71
|
+
| `METASTACK_MIGRATION_PROCEDURE.md` | Checklist & instructions |
|
|
72
|
+
| `METASTACK_STATE_REMOVAL_COMMANDS.sh` | State removal commands |
|
|
73
|
+
| `.metastack/import.tf` | Terraform import blocks |
|
|
74
|
+
| `spacelift.yaml` | Stack definitions |
|
|
75
|
+
|
|
76
|
+
## Notes
|
|
77
|
+
|
|
78
|
+
- State saved in `.migration-state.json`, you can resume at any time
|
|
79
|
+
- Run state removal before merging iac-deploy cleanup PR to avoid actually deleting the stacks
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const REPO_URLS: {
|
|
2
|
+
readonly domainEnrollment: "git@github.com:PayFit/domain-enrollment.git";
|
|
3
|
+
readonly iacDeploy: "git@github.com:PayFit/iac-deploy.git";
|
|
4
|
+
};
|
|
5
|
+
export declare const FILE_NAMES: {
|
|
6
|
+
readonly migrationState: ".migration-state.json";
|
|
7
|
+
readonly tempDir: ".migration-tmp";
|
|
8
|
+
readonly stateRemovalCommands: "METASTACK_STATE_REMOVAL_COMMANDS.sh";
|
|
9
|
+
readonly migrationProcedure: "METASTACK_MIGRATION_PROCEDURE.md";
|
|
10
|
+
readonly spaceliftYaml: "spacelift.yaml";
|
|
11
|
+
readonly gitignore: ".gitignore";
|
|
12
|
+
};
|
|
13
|
+
export declare const GITIGNORE_ENTRIES: string;
|
|
14
|
+
export declare const IAC_DEPLOY_PATHS: {
|
|
15
|
+
readonly projectsConfigs: "projects/configs";
|
|
16
|
+
};
|
|
17
|
+
export declare const DOMAIN_ENROLLMENT_PATHS: {
|
|
18
|
+
readonly domains: "domains";
|
|
19
|
+
readonly spaceliftDir: "spacelift";
|
|
20
|
+
readonly spaceliftYaml: "spacelift/domain-spacelift.yaml";
|
|
21
|
+
};
|
|
22
|
+
export declare const SPACELIFT_API: {
|
|
23
|
+
readonly endpoint: "https://payfit.app.spacelift.io/graphql";
|
|
24
|
+
};
|
|
25
|
+
export declare const SPACELIFT_INTEGRATIONS_ENV_IDS: {
|
|
26
|
+
readonly DEV: "01GMN9SZKWZ7865CNSHY7B1NXY";
|
|
27
|
+
readonly PROD: "01GMN9SZEGBXRGKSC8K43Y9X9E";
|
|
28
|
+
readonly SHARED: "01GMN9T0G289G811A802GV7FN9";
|
|
29
|
+
readonly STAGING: "01GMN9SZQ1750KR5TH5W6XKQB0";
|
|
30
|
+
};
|
|
31
|
+
export declare const STACK_MANAGERS: {
|
|
32
|
+
readonly projectsManager: "projects-manager";
|
|
33
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STACK_MANAGERS = exports.SPACELIFT_INTEGRATIONS_ENV_IDS = exports.SPACELIFT_API = exports.DOMAIN_ENROLLMENT_PATHS = exports.IAC_DEPLOY_PATHS = exports.GITIGNORE_ENTRIES = exports.FILE_NAMES = exports.REPO_URLS = void 0;
|
|
4
|
+
exports.REPO_URLS = {
|
|
5
|
+
domainEnrollment: 'git@github.com:PayFit/domain-enrollment.git',
|
|
6
|
+
iacDeploy: 'git@github.com:PayFit/iac-deploy.git',
|
|
7
|
+
};
|
|
8
|
+
exports.FILE_NAMES = {
|
|
9
|
+
migrationState: '.migration-state.json',
|
|
10
|
+
tempDir: '.migration-tmp',
|
|
11
|
+
stateRemovalCommands: 'METASTACK_STATE_REMOVAL_COMMANDS.sh',
|
|
12
|
+
migrationProcedure: 'METASTACK_MIGRATION_PROCEDURE.md',
|
|
13
|
+
spaceliftYaml: 'spacelift.yaml',
|
|
14
|
+
gitignore: '.gitignore',
|
|
15
|
+
};
|
|
16
|
+
exports.GITIGNORE_ENTRIES = [
|
|
17
|
+
'',
|
|
18
|
+
'# Migration temporary files',
|
|
19
|
+
`${exports.FILE_NAMES.tempDir}/`,
|
|
20
|
+
exports.FILE_NAMES.migrationState,
|
|
21
|
+
exports.FILE_NAMES.stateRemovalCommands,
|
|
22
|
+
exports.FILE_NAMES.migrationProcedure,
|
|
23
|
+
].join('\n');
|
|
24
|
+
exports.IAC_DEPLOY_PATHS = {
|
|
25
|
+
projectsConfigs: 'projects/configs',
|
|
26
|
+
};
|
|
27
|
+
exports.DOMAIN_ENROLLMENT_PATHS = {
|
|
28
|
+
domains: 'domains',
|
|
29
|
+
spaceliftDir: 'spacelift',
|
|
30
|
+
spaceliftYaml: 'spacelift/domain-spacelift.yaml',
|
|
31
|
+
};
|
|
32
|
+
exports.SPACELIFT_API = {
|
|
33
|
+
endpoint: 'https://payfit.app.spacelift.io/graphql',
|
|
34
|
+
};
|
|
35
|
+
exports.SPACELIFT_INTEGRATIONS_ENV_IDS = {
|
|
36
|
+
DEV: '01GMN9SZKWZ7865CNSHY7B1NXY',
|
|
37
|
+
PROD: '01GMN9SZEGBXRGKSC8K43Y9X9E',
|
|
38
|
+
SHARED: '01GMN9T0G289G811A802GV7FN9',
|
|
39
|
+
STAGING: '01GMN9SZQ1750KR5TH5W6XKQB0',
|
|
40
|
+
};
|
|
41
|
+
exports.STACK_MANAGERS = {
|
|
42
|
+
projectsManager: 'projects-manager',
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/executors/stack-migration/lib/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG;IACvB,gBAAgB,EAAE,6CAA6C;IAC/D,SAAS,EAAE,sCAAsC;CACzC,CAAA;AAEG,QAAA,UAAU,GAAG;IACxB,cAAc,EAAE,uBAAuB;IACvC,OAAO,EAAE,gBAAgB;IACzB,oBAAoB,EAAE,qCAAqC;IAC3D,kBAAkB,EAAE,kCAAkC;IACtD,aAAa,EAAE,gBAAgB;IAC/B,SAAS,EAAE,YAAY;CACf,CAAA;AAEG,QAAA,iBAAiB,GAAG;IAC/B,EAAE;IACF,6BAA6B;IAC7B,GAAG,kBAAU,CAAC,OAAO,GAAG;IACxB,kBAAU,CAAC,cAAc;IACzB,kBAAU,CAAC,oBAAoB;IAC/B,kBAAU,CAAC,kBAAkB;CAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAEC,QAAA,gBAAgB,GAAG;IAC9B,eAAe,EAAE,kBAAkB;CAC3B,CAAA;AAEG,QAAA,uBAAuB,GAAG;IACrC,OAAO,EAAE,SAAS;IAClB,YAAY,EAAE,WAAW;IACzB,aAAa,EAAE,iCAAiC;CACxC,CAAA;AAEG,QAAA,aAAa,GAAG;IAC3B,QAAQ,EAAE,yCAAyC;CAC3C,CAAA;AAEG,QAAA,8BAA8B,GAAG;IAC5C,GAAG,EAAE,4BAA4B;IACjC,IAAI,EAAE,4BAA4B;IAClC,MAAM,EAAE,4BAA4B;IACpC,OAAO,EAAE,4BAA4B;CAC7B,CAAA;AAEG,QAAA,cAAc,GAAG;IAC5B,eAAe,EAAE,kBAAkB;CAC3B,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Logger } from './git-operations';
|
|
2
|
+
export declare class FileOperations {
|
|
3
|
+
private dryRun;
|
|
4
|
+
private logger;
|
|
5
|
+
constructor(dryRun: boolean, logger: Logger);
|
|
6
|
+
readYaml(filePath: string): Record<string, unknown>;
|
|
7
|
+
writeYaml(filePath: string, data: Record<string, unknown>): void;
|
|
8
|
+
writeFile(filePath: string, content: string): void;
|
|
9
|
+
readFile(filePath: string): string;
|
|
10
|
+
mkdir(dirPath: string, options?: {
|
|
11
|
+
recursive?: boolean;
|
|
12
|
+
}): void;
|
|
13
|
+
deleteFile(filePath: string): void;
|
|
14
|
+
deleteDirectory(dirPath: string): void;
|
|
15
|
+
copyFile(source: string, destination: string): void;
|
|
16
|
+
exists(filePath: string): boolean;
|
|
17
|
+
isDirectory(filePath: string): boolean;
|
|
18
|
+
readDir(dirPath: string): Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
isDirectory: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
updateAutodeployInYaml(filePath: string, value: boolean): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileOperations = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
+
const yaml = tslib_1.__importStar(require("js-yaml"));
|
|
7
|
+
class FileOperations {
|
|
8
|
+
constructor(dryRun, logger) {
|
|
9
|
+
this.dryRun = dryRun;
|
|
10
|
+
this.logger = logger;
|
|
11
|
+
}
|
|
12
|
+
readYaml(filePath) {
|
|
13
|
+
try {
|
|
14
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
15
|
+
return yaml.load(content);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
this.logger.error('failed to read yaml file: ' + error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
writeYaml(filePath, data) {
|
|
23
|
+
const content = yaml.dump(data, {
|
|
24
|
+
lineWidth: -1,
|
|
25
|
+
quotingType: '"',
|
|
26
|
+
noRefs: false,
|
|
27
|
+
});
|
|
28
|
+
if (this.dryRun) {
|
|
29
|
+
this.logger.info(`[DRY RUN] Would write YAML to: ${filePath}`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
fs.writeFileSync(filePath, content);
|
|
33
|
+
}
|
|
34
|
+
writeFile(filePath, content) {
|
|
35
|
+
if (this.dryRun) {
|
|
36
|
+
this.logger.info(`[DRY RUN] Would write file to: ${filePath}`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
fs.writeFileSync(filePath, content);
|
|
40
|
+
}
|
|
41
|
+
readFile(filePath) {
|
|
42
|
+
try {
|
|
43
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
this.logger.error('failed to read file: ' + error);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
mkdir(dirPath, options) {
|
|
51
|
+
if (this.dryRun) {
|
|
52
|
+
this.logger.info(`[DRY RUN] Would create directory: ${dirPath}`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
fs.mkdirSync(dirPath, options);
|
|
56
|
+
}
|
|
57
|
+
deleteFile(filePath) {
|
|
58
|
+
if (this.dryRun) {
|
|
59
|
+
this.logger.info(`[DRY RUN] Would delete file: ${filePath}`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (fs.existsSync(filePath)) {
|
|
63
|
+
fs.unlinkSync(filePath);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
deleteDirectory(dirPath) {
|
|
67
|
+
if (this.dryRun) {
|
|
68
|
+
this.logger.info(`[DRY RUN] Would delete directory: ${dirPath}`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (fs.existsSync(dirPath)) {
|
|
72
|
+
fs.rmSync(dirPath, { recursive: true, force: true });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
copyFile(source, destination) {
|
|
76
|
+
if (this.dryRun) {
|
|
77
|
+
this.logger.info(`[DRY RUN] Would copy ${source} -> ${destination}`);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
fs.copyFileSync(source, destination);
|
|
81
|
+
}
|
|
82
|
+
exists(filePath) {
|
|
83
|
+
return fs.existsSync(filePath);
|
|
84
|
+
}
|
|
85
|
+
isDirectory(filePath) {
|
|
86
|
+
return fs.existsSync(filePath) && fs.statSync(filePath).isDirectory();
|
|
87
|
+
}
|
|
88
|
+
readDir(dirPath) {
|
|
89
|
+
if (!fs.existsSync(dirPath)) {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
93
|
+
return entries.map(entry => ({
|
|
94
|
+
name: entry.name,
|
|
95
|
+
isDirectory: entry.isDirectory(),
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
updateAutodeployInYaml(filePath, value) {
|
|
99
|
+
if (this.dryRun) {
|
|
100
|
+
this.logger.info(`[DRY RUN] Would set autodeploy=${value} in ${filePath}`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const content = this.readFile(filePath);
|
|
104
|
+
const lines = content.split('\n');
|
|
105
|
+
const result = [];
|
|
106
|
+
for (let i = 0; i < lines.length; i++) {
|
|
107
|
+
const line = lines[i];
|
|
108
|
+
const autodeployMatch = line.match(/^(\s*)autodeploy:\s*(true|false)(.*)$/);
|
|
109
|
+
if (autodeployMatch) {
|
|
110
|
+
const [, indent, , rest] = autodeployMatch;
|
|
111
|
+
result.push(`${indent}autodeploy: ${value}${rest}`);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
result.push(line);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
this.writeFile(filePath, result.join('\n'));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.FileOperations = FileOperations;
|
|
121
|
+
//# sourceMappingURL=file-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-operations.js","sourceRoot":"","sources":["../../../../src/executors/stack-migration/lib/file-operations.ts"],"names":[],"mappings":";;;;AAAA,+CAAwB;AAIxB,sDAA+B;AAE/B,MAAa,cAAc;IACzB,YACU,MAAe,EACf,MAAc;QADd,WAAM,GAAN,MAAM,CAAS;QACf,WAAM,GAAN,MAAM,CAAQ;IACrB,CAAC;IAEJ,QAAQ,CAAC,QAAgB;QACvB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,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,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,eAAe,KAAK,GAAG,IAAI,EAAE,CAAC,CAAA;YACrD,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACnB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAC7C,CAAC;CACF;AArID,wCAqIC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface Logger {
|
|
2
|
+
info(message: string): void;
|
|
3
|
+
success(message: string): void;
|
|
4
|
+
warn(message: string): void;
|
|
5
|
+
error(message: string): void;
|
|
6
|
+
}
|
|
7
|
+
export declare class GitOperations {
|
|
8
|
+
private dryRun;
|
|
9
|
+
private logger;
|
|
10
|
+
constructor(dryRun: boolean, logger: Logger);
|
|
11
|
+
private exec;
|
|
12
|
+
clone(repoUrl: string, targetPath: string, cwd: string): Promise<void>;
|
|
13
|
+
pull(cwd: string): Promise<void>;
|
|
14
|
+
createBranch(branchName: string, cwd: string): Promise<void>;
|
|
15
|
+
add(files: string[], cwd: string): Promise<void>;
|
|
16
|
+
commit(message: string, cwd: string): Promise<void>;
|
|
17
|
+
push(branchName: string, cwd: string): Promise<void>;
|
|
18
|
+
createPR(branchName: string, title: string, body: string, cwd: string): Promise<string>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GitOperations = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
class GitOperations {
|
|
6
|
+
constructor(dryRun, logger) {
|
|
7
|
+
this.dryRun = dryRun;
|
|
8
|
+
this.logger = logger;
|
|
9
|
+
}
|
|
10
|
+
exec(command, cwd) {
|
|
11
|
+
if (this.dryRun) {
|
|
12
|
+
this.logger.info(`[DRY RUN] Would run git command: ${command}`);
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
return (0, child_process_1.execSync)(command, {
|
|
17
|
+
cwd,
|
|
18
|
+
encoding: 'utf8',
|
|
19
|
+
timeout: 300000, // 5 minutes
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
this.logger.error(`Git command failed: ${command} - ` + error);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async clone(repoUrl, targetPath, cwd) {
|
|
28
|
+
if (this.dryRun) {
|
|
29
|
+
this.logger.info(`[DRY RUN] Would clone ${repoUrl} to ${targetPath}`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
this.logger.info(`Cloning ${repoUrl}...`);
|
|
33
|
+
const repoName = targetPath.split('/').pop() || targetPath;
|
|
34
|
+
this.exec(`git clone ${repoUrl} ${repoName}`, cwd);
|
|
35
|
+
}
|
|
36
|
+
async pull(cwd) {
|
|
37
|
+
if (this.dryRun) {
|
|
38
|
+
this.logger.info(`[DRY RUN] Would pull latest changes`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.exec('git pull origin main', cwd);
|
|
42
|
+
}
|
|
43
|
+
async createBranch(branchName, cwd) {
|
|
44
|
+
if (this.dryRun) {
|
|
45
|
+
this.logger.info(`[DRY RUN] Would create branch: ${branchName}`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.exec(`git checkout -b ${branchName}`, cwd);
|
|
49
|
+
}
|
|
50
|
+
async add(files, cwd) {
|
|
51
|
+
if (this.dryRun) {
|
|
52
|
+
this.logger.info(`[DRY RUN] Would add files: ${files.join(' ')}`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.exec(`git add ${files.join(' ')}`, cwd);
|
|
56
|
+
}
|
|
57
|
+
async commit(message, cwd) {
|
|
58
|
+
if (this.dryRun) {
|
|
59
|
+
this.logger.info(`[DRY RUN] Would commit with message:`);
|
|
60
|
+
message.split('\n').forEach(line => this.logger.info(` ${line}`));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const escapedMessage = message.replace(/'/g, "'\\''");
|
|
64
|
+
this.exec(`git commit -m '${escapedMessage}'`, cwd);
|
|
65
|
+
}
|
|
66
|
+
async push(branchName, cwd) {
|
|
67
|
+
if (this.dryRun) {
|
|
68
|
+
this.logger.info(`[DRY RUN] Would push branch: ${branchName}`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.exec(`git push -u origin ${branchName}`, cwd);
|
|
72
|
+
}
|
|
73
|
+
async createPR(branchName, title, body, cwd) {
|
|
74
|
+
if (this.dryRun) {
|
|
75
|
+
this.logger.info('[DRY RUN] Would create draft PR:');
|
|
76
|
+
this.logger.info(` Branch: ${branchName}`);
|
|
77
|
+
this.logger.info(` Title: ${title}`);
|
|
78
|
+
this.logger.info(` Body:`);
|
|
79
|
+
body.split('\n').forEach(line => this.logger.info(` ${line}`));
|
|
80
|
+
return 'https://github.com/example/repo/pull/0 (dry-run)';
|
|
81
|
+
}
|
|
82
|
+
await this.push(branchName, cwd);
|
|
83
|
+
const escapedTitle = title.replace(/'/g, "'\\''");
|
|
84
|
+
const prUrl = this.exec(`gh pr create --draft --title '${escapedTitle}' --body "$(cat <<'EOF'\n${body}\nEOF\n)"`, cwd);
|
|
85
|
+
this.logger.success(`Draft PR created: ${prUrl}`);
|
|
86
|
+
return prUrl;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.GitOperations = GitOperations;
|
|
90
|
+
//# sourceMappingURL=git-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-operations.js","sourceRoot":"","sources":["../../../../src/executors/stack-migration/lib/git-operations.ts"],"names":[],"mappings":";;;AAAA,iDAAwC;AASxC,MAAa,aAAa;IACxB,YACU,MAAe,EACf,MAAc;QADd,WAAM,GAAN,MAAM,CAAS;QACf,WAAM,GAAN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ants';
|
|
5
|
+
export * from './types';
|
|
6
|
+
export * from './path-builder';
|
|
7
|
+
export * from './git-operations';
|
|
8
|
+
export * from './file-operations';
|
|
9
|
+
export * from './spacelift-client';
|
|
10
|
+
export * from './logger';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Stack migration library exports
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
tslib_1.__exportStar(require("./constants"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./path-builder"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./git-operations"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./file-operations"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./spacelift-client"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./logger"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/executors/stack-migration/lib/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,sDAA2B;AAC3B,kDAAuB;AACvB,yDAA8B;AAC9B,2DAAgC;AAChC,4DAAiC;AACjC,6DAAkC;AAClC,mDAAwB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const consola: import("consola").ConsolaInstance;
|
|
2
|
+
export declare class MigrationLogger {
|
|
3
|
+
info(message: string): void;
|
|
4
|
+
success(message: string): void;
|
|
5
|
+
warn(message: string): void;
|
|
6
|
+
error(message: string): void;
|
|
7
|
+
section(title: string): void;
|
|
8
|
+
step(current: number, total: number, description: string): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MigrationLogger = exports.consola = void 0;
|
|
4
|
+
const consola_1 = require("consola");
|
|
5
|
+
exports.consola = (0, consola_1.createConsola)({
|
|
6
|
+
fancy: true,
|
|
7
|
+
});
|
|
8
|
+
class MigrationLogger {
|
|
9
|
+
info(message) {
|
|
10
|
+
exports.consola.info(message);
|
|
11
|
+
}
|
|
12
|
+
success(message) {
|
|
13
|
+
exports.consola.success(message);
|
|
14
|
+
}
|
|
15
|
+
warn(message) {
|
|
16
|
+
exports.consola.warn(message);
|
|
17
|
+
}
|
|
18
|
+
error(message) {
|
|
19
|
+
exports.consola.error(message);
|
|
20
|
+
}
|
|
21
|
+
section(title) {
|
|
22
|
+
exports.consola.log('');
|
|
23
|
+
exports.consola.box(title);
|
|
24
|
+
exports.consola.log('');
|
|
25
|
+
}
|
|
26
|
+
step(current, total, description) {
|
|
27
|
+
exports.consola.log('');
|
|
28
|
+
exports.consola.start(`[Step ${current}/${total}] ${description}`);
|
|
29
|
+
exports.consola.log('');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.MigrationLogger = MigrationLogger;
|
|
33
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../src/executors/stack-migration/lib/logger.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAE1B,QAAA,OAAO,GAAG,IAAA,uBAAa,EAAC;IACnC,KAAK,EAAE,IAAI;CACZ,CAAC,CAAA;AAEF,MAAa,eAAe;IAC1B,IAAI,CAAC,OAAe;QAClB,eAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACvB,CAAC;IAED,OAAO,CAAC,OAAe;QACrB,eAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC1B,CAAC;IAED,IAAI,CAAC,OAAe;QAClB,eAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACvB,CAAC;IAED,KAAK,CAAC,OAAe;QACnB,eAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACxB,CAAC;IAED,OAAO,CAAC,KAAa;QACnB,eAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACf,eAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAClB,eAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACjB,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,KAAa,EAAE,WAAmB;QACtD,eAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACf,eAAO,CAAC,KAAK,CAAC,SAAS,OAAO,IAAI,KAAK,KAAK,WAAW,EAAE,CAAC,CAAA;QAC1D,eAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACjB,CAAC;CACF;AA5BD,0CA4BC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { MigrationConfig } from './types';
|
|
2
|
+
import { FileOperations } from './file-operations';
|
|
3
|
+
import { GitOperations } from './git-operations';
|
|
4
|
+
import { MigrationLogger } from './logger';
|
|
5
|
+
import { MigrationPaths } from './path-builder';
|
|
6
|
+
export declare class MigrationHelper {
|
|
7
|
+
logger: MigrationLogger;
|
|
8
|
+
config: MigrationConfig;
|
|
9
|
+
dryRun: boolean;
|
|
10
|
+
paths: MigrationPaths;
|
|
11
|
+
git: GitOperations;
|
|
12
|
+
files: FileOperations;
|
|
13
|
+
constructor(dryRun?: boolean, serviceRepoPath?: string);
|
|
14
|
+
ask(question: string): Promise<string>;
|
|
15
|
+
confirm(question: string, defaultYes?: boolean): Promise<boolean>;
|
|
16
|
+
getOrAskConfig(optionValue: string | string[] | undefined, promptText: string, defaultValue?: string): Promise<string>;
|
|
17
|
+
generateBranchName(prefix: string): string;
|
|
18
|
+
exitWithMessage(message: string): never;
|
|
19
|
+
exec(command: string, options?: {
|
|
20
|
+
cwd?: string;
|
|
21
|
+
silent?: boolean;
|
|
22
|
+
}): string;
|
|
23
|
+
execSilent(command: string, cwd?: string): string;
|
|
24
|
+
isSpacectlInstalled(): boolean;
|
|
25
|
+
ensureSpacectlInstalled(): Promise<void>;
|
|
26
|
+
isSpacectlAuthenticated(): boolean;
|
|
27
|
+
ensureSpacectlAuthentication(): Promise<void>;
|
|
28
|
+
getStacksGeneratorModuleKey(stack: {
|
|
29
|
+
identifier: string;
|
|
30
|
+
environment: string;
|
|
31
|
+
region?: string;
|
|
32
|
+
}): string;
|
|
33
|
+
getStackModuleKey(stack: {
|
|
34
|
+
identifier: string;
|
|
35
|
+
environment: string;
|
|
36
|
+
region?: string;
|
|
37
|
+
}): string;
|
|
38
|
+
saveMigrationState(): void;
|
|
39
|
+
loadMigrationState(): boolean;
|
|
40
|
+
}
|