@fnd-platform/cli 1.0.0-alpha.8 → 1.0.0-alpha.9
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/lib/commands/add.d.ts.map +1 -1
- package/lib/commands/add.js +31 -6
- package/lib/commands/add.js.map +1 -1
- package/lib/commands/deploy.d.ts +22 -5
- package/lib/commands/deploy.d.ts.map +1 -1
- package/lib/commands/deploy.js +170 -15
- package/lib/commands/deploy.js.map +1 -1
- package/lib/commands/destroy.d.ts +69 -0
- package/lib/commands/destroy.d.ts.map +1 -0
- package/lib/commands/destroy.js +177 -0
- package/lib/commands/destroy.js.map +1 -0
- package/lib/commands/index.d.ts +1 -0
- package/lib/commands/index.d.ts.map +1 -1
- package/lib/commands/index.js +3 -1
- package/lib/commands/index.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/lib/deploy-utils.d.ts +186 -0
- package/lib/lib/deploy-utils.d.ts.map +1 -0
- package/lib/lib/deploy-utils.js +367 -0
- package/lib/lib/deploy-utils.js.map +1 -0
- package/lib/lib/infra-generator.d.ts +108 -0
- package/lib/lib/infra-generator.d.ts.map +1 -1
- package/lib/lib/infra-generator.js +909 -38
- package/lib/lib/infra-generator.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.destroyCommand = destroyCommand;
|
|
4
|
+
exports.runDestroy = runDestroy;
|
|
5
|
+
exports.buildCdkDestroyCommand = buildCdkDestroyCommand;
|
|
6
|
+
const commander_1 = require("commander");
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const project_js_1 = require("../lib/project.js");
|
|
11
|
+
const logger_js_1 = require("../lib/logger.js");
|
|
12
|
+
const deploy_utils_js_1 = require("../lib/deploy-utils.js");
|
|
13
|
+
/**
|
|
14
|
+
* Creates the `fnd destroy` command.
|
|
15
|
+
*
|
|
16
|
+
* @returns Commander command instance
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import { destroyCommand } from '@fnd-platform/cli';
|
|
21
|
+
*
|
|
22
|
+
* const program = new Command();
|
|
23
|
+
* program.addCommand(destroyCommand());
|
|
24
|
+
*
|
|
25
|
+
* // Destroy dev environment (with confirmation prompt)
|
|
26
|
+
* program.parse(['node', 'fnd', 'destroy', '--stage=dev']);
|
|
27
|
+
*
|
|
28
|
+
* // Force destroy without confirmation (for CI/CD)
|
|
29
|
+
* program.parse(['node', 'fnd', 'destroy', '--stage=dev', '--force']);
|
|
30
|
+
*
|
|
31
|
+
* // Destroy specific stack
|
|
32
|
+
* program.parse(['node', 'fnd', 'destroy', '--stage=dev', '--stack=Frontend']);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function destroyCommand() {
|
|
36
|
+
return new commander_1.Command('destroy')
|
|
37
|
+
.description('Destroy AWS resources created by fnd-platform')
|
|
38
|
+
.requiredOption('--stage <stage>', 'Deployment stage to destroy (e.g., dev, staging, prod)')
|
|
39
|
+
.option('--stack <stack>', 'Destroy specific stack only (e.g., Api, Frontend, Cms)')
|
|
40
|
+
.option('--force', 'Skip confirmation prompt (required for CI/CD)')
|
|
41
|
+
.option('-v, --verbose', 'Verbose output')
|
|
42
|
+
.action(async (options) => {
|
|
43
|
+
await runDestroy(options);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Runs the CDK destroy operation.
|
|
48
|
+
*
|
|
49
|
+
* @param options - Command options
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* // Destroy dev environment (with confirmation)
|
|
54
|
+
* await runDestroy({ stage: 'dev' });
|
|
55
|
+
*
|
|
56
|
+
* // Force destroy (no confirmation)
|
|
57
|
+
* await runDestroy({ stage: 'dev', force: true });
|
|
58
|
+
*
|
|
59
|
+
* // Destroy specific stack
|
|
60
|
+
* await runDestroy({ stage: 'dev', stack: 'Frontend' });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
async function runDestroy(options) {
|
|
64
|
+
let projectRoot;
|
|
65
|
+
try {
|
|
66
|
+
projectRoot = (0, project_js_1.requireProjectRoot)();
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
logger_js_1.logger.error(error.message);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
// Validate infra package exists
|
|
73
|
+
const infraDir = (0, path_1.join)(projectRoot, 'packages', 'infra');
|
|
74
|
+
if (!(0, fs_1.existsSync)(infraDir)) {
|
|
75
|
+
logger_js_1.logger.error('Infrastructure package not found at packages/infra. ' +
|
|
76
|
+
'Make sure you have added an API package with `fnd add api`, ' +
|
|
77
|
+
'which generates the infrastructure package.');
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
// Validate AWS CLI
|
|
81
|
+
try {
|
|
82
|
+
(0, deploy_utils_js_1.validateAwsCli)();
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
logger_js_1.logger.error(error.message);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
const { stage, stack, force } = options;
|
|
89
|
+
const projectName = (0, deploy_utils_js_1.getProjectName)(projectRoot);
|
|
90
|
+
// Build confirmation message
|
|
91
|
+
let confirmMessage;
|
|
92
|
+
if (stack) {
|
|
93
|
+
confirmMessage = `Are you sure you want to destroy the ${stack} stack in ${stage} for ${projectName}?`;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
confirmMessage = `Are you sure you want to destroy ALL resources in ${stage} for ${projectName}?`;
|
|
97
|
+
}
|
|
98
|
+
// Prompt for confirmation unless --force is used
|
|
99
|
+
if (!force) {
|
|
100
|
+
logger_js_1.logger.warn('This action is destructive and cannot be undone!');
|
|
101
|
+
logger_js_1.logger.warn('Data in DynamoDB and S3 will be deleted unless retention policies are configured.');
|
|
102
|
+
const confirmed = await (0, deploy_utils_js_1.promptConfirmation)(confirmMessage);
|
|
103
|
+
if (!confirmed) {
|
|
104
|
+
logger_js_1.logger.info('Destroy operation cancelled.');
|
|
105
|
+
process.exit(0);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// List stacks that will be destroyed
|
|
109
|
+
if (!stack) {
|
|
110
|
+
const stacks = (0, deploy_utils_js_1.listProjectStacks)(projectRoot, stage);
|
|
111
|
+
if (stacks.length > 0) {
|
|
112
|
+
logger_js_1.logger.info('Stacks to be destroyed:');
|
|
113
|
+
for (const stackName of stacks) {
|
|
114
|
+
logger_js_1.logger.info(` - ${stackName}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Run CDK destroy
|
|
119
|
+
logger_js_1.logger.info(`Destroying ${stack ? `${stack} stack` : 'all stacks'} in stage: ${stage}`);
|
|
120
|
+
await runCdkDestroy(infraDir, stage, stack, options.verbose);
|
|
121
|
+
logger_js_1.logger.success(`Destroy operation for ${stage} complete`);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Runs CDK destroy.
|
|
125
|
+
*
|
|
126
|
+
* @param infraDir - Path to the infrastructure package
|
|
127
|
+
* @param stage - Deployment stage
|
|
128
|
+
* @param stack - Optional specific stack to destroy
|
|
129
|
+
* @param verbose - Show verbose output
|
|
130
|
+
*/
|
|
131
|
+
async function runCdkDestroy(infraDir, stage, stack, verbose) {
|
|
132
|
+
logger_js_1.logger.debug(`Running CDK destroy in: ${infraDir}`);
|
|
133
|
+
const command = buildCdkDestroyCommand(stage, stack);
|
|
134
|
+
logger_js_1.logger.debug(`Command: ${command}`);
|
|
135
|
+
try {
|
|
136
|
+
(0, child_process_1.execSync)(command, {
|
|
137
|
+
cwd: infraDir,
|
|
138
|
+
stdio: 'inherit',
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
logger_js_1.logger.error('CDK destroy failed');
|
|
143
|
+
logger_js_1.logger.debug(`Error: ${error.message}`);
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Builds the CDK destroy command.
|
|
149
|
+
*
|
|
150
|
+
* @param stage - Deployment stage
|
|
151
|
+
* @param stack - Optional specific stack to destroy
|
|
152
|
+
* @returns Command string
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* buildCdkDestroyCommand('dev');
|
|
157
|
+
* // Returns: 'pnpm exec cdk destroy --all -c stage=dev --force'
|
|
158
|
+
*
|
|
159
|
+
* buildCdkDestroyCommand('dev', 'Frontend');
|
|
160
|
+
* // Returns: 'pnpm exec cdk destroy "*Frontend*" -c stage=dev --force'
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
function buildCdkDestroyCommand(stage, stack) {
|
|
164
|
+
const args = ['pnpm', 'exec', 'cdk', 'destroy'];
|
|
165
|
+
if (stack) {
|
|
166
|
+
args.push(`"*${stack}*"`);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
args.push('--all');
|
|
170
|
+
}
|
|
171
|
+
args.push(`-c stage=${stage}`);
|
|
172
|
+
// Always use --force for CDK destroy to skip its internal confirmation
|
|
173
|
+
// (we handle confirmation at the CLI level)
|
|
174
|
+
args.push('--force');
|
|
175
|
+
return args.join(' ');
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=destroy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../src/commands/destroy.ts"],"names":[],"mappings":";;AA6CA,wCAUC;AAmBD,gCAsEC;AAiDD,wDAgBC;AAjND,yCAAoC;AACpC,iDAAyC;AACzC,2BAAgC;AAChC,+BAA4B;AAC5B,kDAAu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AAI,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC,CAAC;IAE/B,uEAAuE;IACvE,4CAA4C;IAC5C,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAErB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC"}
|
package/lib/commands/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
package/lib/commands/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deployCommand = exports.addCommand = exports.buildCommand = exports.synthCommand = exports.newCommand = void 0;
|
|
3
|
+
exports.destroyCommand = exports.deployCommand = exports.addCommand = exports.buildCommand = exports.synthCommand = exports.newCommand = void 0;
|
|
4
4
|
var new_js_1 = require("./new.js");
|
|
5
5
|
Object.defineProperty(exports, "newCommand", { enumerable: true, get: function () { return new_js_1.newCommand; } });
|
|
6
6
|
var synth_js_1 = require("./synth.js");
|
|
@@ -11,4 +11,6 @@ var add_js_1 = require("./add.js");
|
|
|
11
11
|
Object.defineProperty(exports, "addCommand", { enumerable: true, get: function () { return add_js_1.addCommand; } });
|
|
12
12
|
var deploy_js_1 = require("./deploy.js");
|
|
13
13
|
Object.defineProperty(exports, "deployCommand", { enumerable: true, get: function () { return deploy_js_1.deployCommand; } });
|
|
14
|
+
var destroy_js_1 = require("./destroy.js");
|
|
15
|
+
Object.defineProperty(exports, "destroyCommand", { enumerable: true, get: function () { return destroy_js_1.destroyCommand; } });
|
|
14
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AACnB,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AACrB,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AACrB,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AACnB,yCAA4C;AAAnC,0GAAA,aAAa,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AACnB,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AACrB,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AACrB,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AACnB,yCAA4C;AAAnC,0GAAA,aAAa,OAAA;AACtB,2CAA8C;AAArC,4GAAA,cAAc,OAAA"}
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsBH;;;;;GAKG;AACH,wBAAsB,GAAG,CAAC,IAAI,GAAE,MAAM,EAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BtE"}
|
package/lib/index.js
CHANGED
|
@@ -36,6 +36,7 @@ async function run(args = process.argv) {
|
|
|
36
36
|
program.addCommand((0, index_js_1.buildCommand)());
|
|
37
37
|
program.addCommand((0, index_js_1.addCommand)());
|
|
38
38
|
program.addCommand((0, index_js_1.deployCommand)());
|
|
39
|
+
program.addCommand((0, index_js_1.destroyCommand)());
|
|
39
40
|
// Handle unknown commands
|
|
40
41
|
program.on('command:*', () => {
|
|
41
42
|
console.error(`Invalid command: ${program.args.join(' ')}\n` +
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AA4BH,kBA0BC;AApDD,yCAAoC;AACpC,2BAAkC;AAClC,+BAAqC;AAErC,kDAO6B;AAE7B;;GAEG;AACH,iEAAiE;AACjE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AACrF,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;AAE5B;;;;;GAKG;AACI,KAAK,UAAU,GAAG,CAAC,OAAiB,OAAO,CAAC,IAAI;IACrD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,KAAK,CAAC;SACX,WAAW,CAAC,qEAAqE,CAAC;SAClF,OAAO,CAAC,OAAO,EAAE,eAAe,EAAE,wBAAwB,CAAC,CAAC;IAE/D,oBAAoB;IACpB,OAAO,CAAC,UAAU,CAAC,IAAA,qBAAU,GAAE,CAAC,CAAC;IACjC,OAAO,CAAC,UAAU,CAAC,IAAA,uBAAY,GAAE,CAAC,CAAC;IACnC,OAAO,CAAC,UAAU,CAAC,IAAA,uBAAY,GAAE,CAAC,CAAC;IACnC,OAAO,CAAC,UAAU,CAAC,IAAA,qBAAU,GAAE,CAAC,CAAC;IACjC,OAAO,CAAC,UAAU,CAAC,IAAA,wBAAa,GAAE,CAAC,CAAC;IACpC,OAAO,CAAC,UAAU,CAAC,IAAA,yBAAc,GAAE,CAAC,CAAC;IAErC,0BAA0B;IAC1B,OAAO,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE;QAC3B,OAAO,CAAC,KAAK,CACX,oBAAoB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI;YAC5C,8CAA8C,CACjD,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a string to PascalCase.
|
|
3
|
+
*
|
|
4
|
+
* @param str - String to convert
|
|
5
|
+
* @returns PascalCase string
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* toPascalCase('my-project-name'); // 'MyProjectName'
|
|
10
|
+
* toPascalCase('hello_world'); // 'HelloWorld'
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function toPascalCase(str: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Extracts the project name from .projenrc.ts.
|
|
16
|
+
*
|
|
17
|
+
* @param projectRoot - Path to project root
|
|
18
|
+
* @returns Project name
|
|
19
|
+
* @throws Error if .projenrc.ts is not found or name cannot be extracted
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const name = getProjectName('/path/to/project');
|
|
24
|
+
* // Returns 'my-app'
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function getProjectName(projectRoot: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Gets a CloudFormation stack output value using AWS CLI.
|
|
30
|
+
*
|
|
31
|
+
* @param stackName - Name of the CloudFormation stack
|
|
32
|
+
* @param outputKey - Key of the output to retrieve
|
|
33
|
+
* @returns Output value, or null if not found
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const apiUrl = getStackOutput('MyAppApiStack-dev', 'ApiUrl');
|
|
38
|
+
* // Returns 'https://abc123.execute-api.us-east-1.amazonaws.com/dev'
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function getStackOutput(stackName: string, outputKey: string): string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Stack outputs retrieved from CloudFormation.
|
|
44
|
+
*/
|
|
45
|
+
export interface StackOutputs {
|
|
46
|
+
/** API Gateway URL */
|
|
47
|
+
apiUrl?: string;
|
|
48
|
+
/** Frontend S3 bucket name */
|
|
49
|
+
frontendBucket?: string;
|
|
50
|
+
/** Frontend CloudFront distribution ID */
|
|
51
|
+
frontendDistributionId?: string;
|
|
52
|
+
/** Frontend URL */
|
|
53
|
+
frontendUrl?: string;
|
|
54
|
+
/** CMS S3 bucket name */
|
|
55
|
+
cmsBucket?: string;
|
|
56
|
+
/** CMS CloudFront distribution ID */
|
|
57
|
+
cmsDistributionId?: string;
|
|
58
|
+
/** CMS URL */
|
|
59
|
+
cmsUrl?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Gets all relevant stack outputs for deployment.
|
|
63
|
+
*
|
|
64
|
+
* @param projectRoot - Path to project root
|
|
65
|
+
* @param stage - Deployment stage
|
|
66
|
+
* @returns Stack outputs
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const outputs = getStackOutputs('/path/to/project', 'dev');
|
|
71
|
+
* console.log(outputs.apiUrl);
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function getStackOutputs(projectRoot: string, stage: string): StackOutputs;
|
|
75
|
+
/**
|
|
76
|
+
* Checks if a package exists in the project.
|
|
77
|
+
*
|
|
78
|
+
* @param projectRoot - Path to project root
|
|
79
|
+
* @param packageName - Name of the package to check
|
|
80
|
+
* @returns True if package exists
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* if (hasPackage('/path/to/project', 'frontend')) {
|
|
85
|
+
* console.log('Frontend package exists');
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function hasPackage(projectRoot: string, packageName: string): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Finds the build output directory for a package.
|
|
92
|
+
* Checks common build output directories: build/client, build, dist.
|
|
93
|
+
*
|
|
94
|
+
* @param packagePath - Path to the package
|
|
95
|
+
* @returns Path to build directory, or null if not found
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const buildDir = findBuildDirectory('/path/to/project/packages/frontend');
|
|
100
|
+
* // Returns '/path/to/project/packages/frontend/build/client'
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function findBuildDirectory(packagePath: string): string | null;
|
|
104
|
+
/**
|
|
105
|
+
* Prompts the user for confirmation.
|
|
106
|
+
*
|
|
107
|
+
* @param message - Message to display
|
|
108
|
+
* @returns True if user confirms
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const confirmed = await promptConfirmation('Are you sure you want to destroy dev?');
|
|
113
|
+
* if (!confirmed) {
|
|
114
|
+
* console.log('Operation cancelled');
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare function promptConfirmation(message: string): Promise<boolean>;
|
|
119
|
+
/**
|
|
120
|
+
* Builds a stack name following the project convention.
|
|
121
|
+
*
|
|
122
|
+
* @param projectName - Name of the project
|
|
123
|
+
* @param stackType - Type of stack (e.g., 'Api', 'Frontend', 'Cms')
|
|
124
|
+
* @param stage - Deployment stage
|
|
125
|
+
* @returns Full stack name
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const stackName = buildStackName('my-app', 'Frontend', 'dev');
|
|
130
|
+
* // Returns 'MyAppFrontendStack-dev'
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare function buildStackName(projectName: string, stackType: string, stage: string): string;
|
|
134
|
+
/**
|
|
135
|
+
* Syncs a local directory to an S3 bucket.
|
|
136
|
+
*
|
|
137
|
+
* @param localDir - Local directory path
|
|
138
|
+
* @param bucket - S3 bucket name
|
|
139
|
+
* @param verbose - Show verbose output
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* syncToS3('/path/to/build', 'my-app-frontend-dev-123456789', true);
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export declare function syncToS3(localDir: string, bucket: string, verbose?: boolean): void;
|
|
147
|
+
/**
|
|
148
|
+
* Creates a CloudFront invalidation for all paths.
|
|
149
|
+
*
|
|
150
|
+
* @param distributionId - CloudFront distribution ID
|
|
151
|
+
* @param verbose - Show verbose output
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* invalidateCloudFront('E1234567890ABC', true);
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
export declare function invalidateCloudFront(distributionId: string, verbose?: boolean): void;
|
|
159
|
+
/**
|
|
160
|
+
* Builds a frontend or CMS package with the API URL set.
|
|
161
|
+
*
|
|
162
|
+
* @param packagePath - Path to the package
|
|
163
|
+
* @param apiUrl - API URL to set as environment variable
|
|
164
|
+
* @param verbose - Show verbose output
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* buildPackage('/path/to/frontend', 'https://api.example.com', true);
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export declare function buildPackage(packagePath: string, apiUrl: string, verbose?: boolean): void;
|
|
172
|
+
/**
|
|
173
|
+
* Validates that AWS CLI is available and configured.
|
|
174
|
+
*
|
|
175
|
+
* @throws Error if AWS CLI is not available or not configured
|
|
176
|
+
*/
|
|
177
|
+
export declare function validateAwsCli(): void;
|
|
178
|
+
/**
|
|
179
|
+
* Lists all stacks in a project for a given stage.
|
|
180
|
+
*
|
|
181
|
+
* @param projectRoot - Path to project root
|
|
182
|
+
* @param stage - Deployment stage
|
|
183
|
+
* @returns Array of stack names
|
|
184
|
+
*/
|
|
185
|
+
export declare function listProjectStacks(projectRoot: string, stage: string): string[];
|
|
186
|
+
//# sourceMappingURL=deploy-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy-utils.d.ts","sourceRoot":"","sources":["../../src/lib/deploy-utils.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKhD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAyB1D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYlF;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IA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