@payfit/iac 1.0.0-ephemeral-migration-scripts.7 → 1.0.0-ephemeral-migration-scripts.8
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 +97 -4
- package/dist/executors/stack-migration/README.md +111 -11
- package/dist/executors/stack-migration/lib/constants.d.ts +0 -11
- package/dist/executors/stack-migration/lib/constants.js +1 -12
- package/dist/executors/stack-migration/lib/constants.js.map +1 -1
- package/dist/executors/stack-migration/lib/file-operations.d.ts +0 -43
- package/dist/executors/stack-migration/lib/file-operations.js +0 -88
- package/dist/executors/stack-migration/lib/file-operations.js.map +1 -1
- package/dist/executors/stack-migration/lib/git-operations.d.ts +0 -27
- package/dist/executors/stack-migration/lib/git-operations.js +2 -35
- package/dist/executors/stack-migration/lib/git-operations.js.map +1 -1
- package/dist/executors/stack-migration/lib/logger.d.ts +0 -3
- package/dist/executors/stack-migration/lib/logger.js +3 -6
- package/dist/executors/stack-migration/lib/logger.js.map +1 -1
- package/dist/executors/stack-migration/lib/migration-helper.d.ts +8 -44
- package/dist/executors/stack-migration/lib/migration-helper.js +23 -67
- package/dist/executors/stack-migration/lib/migration-helper.js.map +1 -1
- package/dist/executors/stack-migration/lib/migration-tool.d.ts +4 -15
- package/dist/executors/stack-migration/lib/migration-tool.js +77 -212
- package/dist/executors/stack-migration/lib/migration-tool.js.map +1 -1
- package/dist/executors/stack-migration/lib/path-builder.d.ts +0 -8
- package/dist/executors/stack-migration/lib/path-builder.js +2 -28
- package/dist/executors/stack-migration/lib/path-builder.js.map +1 -1
- package/dist/executors/stack-migration/lib/templates/index.d.ts +1 -0
- package/dist/executors/stack-migration/lib/templates/index.js +1 -0
- package/dist/executors/stack-migration/lib/templates/index.js.map +1 -1
- package/dist/executors/stack-migration/lib/templates/message-templates.d.ts +25 -0
- package/dist/executors/stack-migration/lib/templates/message-templates.js +107 -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 +0 -4
- package/dist/executors/stack-migration/lib/templates/pr-templates.js +3 -24
- package/dist/executors/stack-migration/lib/templates/pr-templates.js.map +1 -1
- package/dist/executors/stack-migration/lib/templates/procedure-template.js +5 -40
- package/dist/executors/stack-migration/lib/templates/procedure-template.js.map +1 -1
- package/dist/executors/stack-migration/lib/types.d.ts +0 -9
- package/dist/executors/stack-migration/lib/types.js +0 -3
- package/dist/executors/stack-migration/lib/types.js.map +1 -1
- package/dist/executors/stack-migration/schema.d.ts +2 -1
- package/dist/executors/stack-migration/schema.json +4 -3
- package/dist/executors/stack-migration/stack-migration.js +30 -60
- package/dist/executors/stack-migration/stack-migration.js.map +1 -1
- package/package.json +3 -2
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for stack migration
|
|
3
|
-
*/
|
|
4
1
|
export interface MigrationConfig {
|
|
5
2
|
serviceRepository: {
|
|
6
3
|
name: string;
|
|
@@ -12,17 +9,14 @@ export interface MigrationConfig {
|
|
|
12
9
|
repositories: {
|
|
13
10
|
domainEnrollment: string;
|
|
14
11
|
iacDeploy: string;
|
|
15
|
-
ecrDeploy: string;
|
|
16
12
|
};
|
|
17
13
|
stacks: Stack[];
|
|
18
|
-
ecrRepositories: ECRRepository[];
|
|
19
14
|
generatedFiles: {
|
|
20
15
|
safetyNetPR?: PullRequestInfo;
|
|
21
16
|
domainEnrollmentPR?: PullRequestInfo;
|
|
22
17
|
domainEnrollmentAlreadyDone?: boolean;
|
|
23
18
|
serviceRepoPR?: PullRequestInfo;
|
|
24
19
|
iacDeployPR?: PullRequestInfo;
|
|
25
|
-
ecrDeployPR?: PullRequestInfo;
|
|
26
20
|
stateRemovalCommands?: string;
|
|
27
21
|
migrationProcedure?: string;
|
|
28
22
|
};
|
|
@@ -35,9 +29,6 @@ export interface Stack {
|
|
|
35
29
|
region?: string;
|
|
36
30
|
autodeploy?: boolean;
|
|
37
31
|
}
|
|
38
|
-
export interface ECRRepository {
|
|
39
|
-
name: string;
|
|
40
|
-
}
|
|
41
32
|
export interface PullRequestInfo {
|
|
42
33
|
branch: string;
|
|
43
34
|
url: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/executors/stack-migration/lib/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/executors/stack-migration/lib/types.ts"],"names":[],"mappings":""}
|
|
@@ -3,12 +3,13 @@ export interface StackMigrationExecutorSchema {
|
|
|
3
3
|
| 'init'
|
|
4
4
|
| 'state'
|
|
5
5
|
| 'enroll'
|
|
6
|
-
| 'generate-
|
|
6
|
+
| 'generate-tf-migration'
|
|
7
7
|
| 'migrate-spaces'
|
|
8
8
|
| 'cleanup-pr'
|
|
9
9
|
| 'generate-procedure'
|
|
10
10
|
| 'migration-cleanup'
|
|
11
11
|
| 'run'
|
|
12
|
+
| 'help'
|
|
12
13
|
dryRun?: boolean
|
|
13
14
|
serviceRepository?: {
|
|
14
15
|
name?: string
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"version": 2,
|
|
4
4
|
"title": "Stack Migration to Metastack executor",
|
|
5
|
-
"description": "Migrate Spacelift stacks from iac-deploy
|
|
5
|
+
"description": "Migrate Spacelift stacks from iac-deploy to repository-level metastacks",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
8
8
|
"command": {
|
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
"init",
|
|
13
13
|
"state",
|
|
14
14
|
"enroll",
|
|
15
|
-
"generate-
|
|
15
|
+
"generate-tf-migration",
|
|
16
16
|
"migrate-spaces",
|
|
17
17
|
"cleanup-pr",
|
|
18
18
|
"generate-procedure",
|
|
19
19
|
"migration-cleanup",
|
|
20
|
-
"run"
|
|
20
|
+
"run",
|
|
21
|
+
"help"
|
|
21
22
|
],
|
|
22
23
|
"default": "run"
|
|
23
24
|
},
|
|
@@ -1,102 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const migration_tool_1 = require("./lib/migration-tool");
|
|
4
|
+
const templates_1 = require("./lib/templates");
|
|
4
5
|
const runExecutor = async (options, context) => {
|
|
5
6
|
const { command = 'run', dryRun = false, serviceRepository } = options;
|
|
6
7
|
try {
|
|
7
|
-
// Get the project root path
|
|
8
8
|
const projectRoot = context.projectsConfigurations?.projects[context.projectName]?.root ||
|
|
9
9
|
context.root;
|
|
10
|
-
// Create migration tool instance
|
|
11
10
|
const tool = new migration_tool_1.MigrationTool(dryRun, projectRoot);
|
|
12
|
-
|
|
11
|
+
const requireState = async (action) => {
|
|
12
|
+
if (!tool.loadMigrationState()) {
|
|
13
|
+
tool.logger.error('No migration state found');
|
|
14
|
+
tool.logger.info('Run: nx run <project>:stack-migration --command=init');
|
|
15
|
+
return { success: false };
|
|
16
|
+
}
|
|
17
|
+
await tool.loadConfiguration();
|
|
18
|
+
await action();
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
let result = null;
|
|
13
22
|
switch (command) {
|
|
14
23
|
case 'init':
|
|
15
24
|
await tool.setupRepositories(serviceRepository);
|
|
25
|
+
await tool.loadConfiguration();
|
|
16
26
|
tool.logger.success('\nMigration initialized successfully!');
|
|
17
27
|
tool.logger.info('\nNext steps: Run individual steps or full workflow');
|
|
28
|
+
tool.logger.info(' nx run <project>:stack-migration --command=help');
|
|
18
29
|
tool.logger.info(' nx run <project>:stack-migration --command=state');
|
|
19
30
|
break;
|
|
20
31
|
case 'state':
|
|
21
32
|
await tool.checkMigrationState();
|
|
22
33
|
break;
|
|
23
34
|
case 'enroll':
|
|
24
|
-
|
|
25
|
-
const hasState = tool.loadMigrationState();
|
|
26
|
-
if (!hasState) {
|
|
27
|
-
tool.logger.error('No migration state found');
|
|
28
|
-
tool.logger.info('Run: nx run <project>:stack-migration --command=init');
|
|
29
|
-
return { success: false };
|
|
30
|
-
}
|
|
31
|
-
await tool.loadConfiguration();
|
|
32
|
-
await tool.createDomainEnrollmentPR();
|
|
33
|
-
}
|
|
35
|
+
result = await requireState(() => tool.createDomainEnrollmentPR());
|
|
34
36
|
break;
|
|
35
|
-
case 'generate-
|
|
36
|
-
{
|
|
37
|
-
const hasState = tool.loadMigrationState();
|
|
38
|
-
if (!hasState) {
|
|
39
|
-
tool.logger.error('No migration state found');
|
|
40
|
-
tool.logger.info('Run: nx run <project>:stack-migration --command=init');
|
|
41
|
-
return { success: false };
|
|
42
|
-
}
|
|
43
|
-
await tool.loadConfiguration();
|
|
37
|
+
case 'generate-tf-migration':
|
|
38
|
+
result = await requireState(async () => {
|
|
44
39
|
await tool.createServiceRepositoryPR();
|
|
45
|
-
|
|
40
|
+
await tool.generateStateRemovalCommands();
|
|
41
|
+
});
|
|
46
42
|
break;
|
|
47
43
|
case 'migrate-spaces':
|
|
48
|
-
|
|
49
|
-
const hasState = tool.loadMigrationState();
|
|
50
|
-
if (!hasState) {
|
|
51
|
-
tool.logger.error('No migration state found');
|
|
52
|
-
tool.logger.info('Run: nx run <project>:stack-migration --command=init');
|
|
53
|
-
return { success: false };
|
|
54
|
-
}
|
|
55
|
-
await tool.loadConfiguration();
|
|
56
|
-
await tool.updateStackSpaces();
|
|
57
|
-
}
|
|
44
|
+
result = await requireState(() => tool.updateStackSpaces());
|
|
58
45
|
break;
|
|
59
46
|
case 'cleanup-pr':
|
|
60
|
-
|
|
61
|
-
const hasState = tool.loadMigrationState();
|
|
62
|
-
if (!hasState) {
|
|
63
|
-
tool.logger.error('No migration state found');
|
|
64
|
-
tool.logger.info('Run: nx run <project>:stack-migration --command=init');
|
|
65
|
-
return { success: false };
|
|
66
|
-
}
|
|
67
|
-
await tool.loadConfiguration();
|
|
68
|
-
await tool.createCleanupPRs();
|
|
69
|
-
}
|
|
47
|
+
result = await requireState(() => tool.createCleanupPRs());
|
|
70
48
|
break;
|
|
71
49
|
case 'generate-procedure':
|
|
72
|
-
|
|
73
|
-
const hasState = tool.loadMigrationState();
|
|
74
|
-
if (!hasState) {
|
|
75
|
-
tool.logger.error('No migration state found');
|
|
76
|
-
tool.logger.info('Run: nx run <project>:stack-migration --command=init');
|
|
77
|
-
return { success: false };
|
|
78
|
-
}
|
|
79
|
-
await tool.loadConfiguration();
|
|
80
|
-
await tool.generateMigrationProcedure();
|
|
81
|
-
}
|
|
50
|
+
result = await requireState(() => tool.generateMigrationProcedure());
|
|
82
51
|
break;
|
|
83
52
|
case 'migration-cleanup':
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
tool.loadMigrationState();
|
|
87
|
-
await tool.cleanupMigration();
|
|
88
|
-
}
|
|
53
|
+
tool.loadMigrationState();
|
|
54
|
+
await tool.cleanupMigration();
|
|
89
55
|
break;
|
|
90
56
|
case 'run':
|
|
91
57
|
await tool.run();
|
|
92
58
|
break;
|
|
59
|
+
case 'help':
|
|
60
|
+
tool.logger.section('Stack Migration Tool - Help');
|
|
61
|
+
tool.logger.info(templates_1.MessageTemplates.HELP_TEXT);
|
|
62
|
+
break;
|
|
93
63
|
default:
|
|
94
64
|
tool.logger.error(`Unknown command: ${command}`);
|
|
65
|
+
tool.logger.info('\nRun --command=help for usage information');
|
|
95
66
|
return { success: false };
|
|
96
67
|
}
|
|
97
|
-
// Close readline interface if it was opened
|
|
98
68
|
tool.closeReadline();
|
|
99
|
-
return { success: true };
|
|
69
|
+
return result || { success: true };
|
|
100
70
|
}
|
|
101
71
|
catch (error) {
|
|
102
72
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack-migration.js","sourceRoot":"","sources":["../../../src/executors/stack-migration/stack-migration.ts"],"names":[],"mappings":";;AAEA,yDAAoD;
|
|
1
|
+
{"version":3,"file":"stack-migration.js","sourceRoot":"","sources":["../../../src/executors/stack-migration/stack-migration.ts"],"names":[],"mappings":";;AAEA,yDAA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AM,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAA;gBAChD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAA;gBAC9D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;QAC7B,CAAC;QAED,IAAI,CAAC,aAAa,EAAE,CAAA;QAEpB,OAAO,MAAM,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC3E,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAA;QAClD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;IAC3B,CAAC;AACH,CAAC,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payfit/iac",
|
|
3
|
-
"version": "1.0.0-ephemeral-migration-scripts.
|
|
3
|
+
"version": "1.0.0-ephemeral-migration-scripts.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "restricted"
|
|
6
6
|
},
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"chalk": "^4.1.2",
|
|
20
20
|
"js-yaml": "^4.1.0",
|
|
21
|
-
"tslib": "^2.3.0"
|
|
21
|
+
"tslib": "^2.3.0",
|
|
22
|
+
"vitest": "4.0.16"
|
|
22
23
|
},
|
|
23
24
|
"peerDependencies": {
|
|
24
25
|
"@nx/devkit": "^22"
|