@fnd-platform/cli 1.0.0-alpha.1 → 1.0.0-alpha.10

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.
@@ -0,0 +1,367 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toPascalCase = toPascalCase;
4
+ exports.getProjectName = getProjectName;
5
+ exports.getStackOutput = getStackOutput;
6
+ exports.getStackOutputs = getStackOutputs;
7
+ exports.hasPackage = hasPackage;
8
+ exports.findBuildDirectory = findBuildDirectory;
9
+ exports.promptConfirmation = promptConfirmation;
10
+ exports.buildStackName = buildStackName;
11
+ exports.syncToS3 = syncToS3;
12
+ exports.invalidateCloudFront = invalidateCloudFront;
13
+ exports.buildPackage = buildPackage;
14
+ exports.validateAwsCli = validateAwsCli;
15
+ exports.listProjectStacks = listProjectStacks;
16
+ const child_process_1 = require("child_process");
17
+ const fs_1 = require("fs");
18
+ const path_1 = require("path");
19
+ const readline_1 = require("readline");
20
+ const logger_js_1 = require("./logger.js");
21
+ /**
22
+ * Converts a string to PascalCase.
23
+ *
24
+ * @param str - String to convert
25
+ * @returns PascalCase string
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * toPascalCase('my-project-name'); // 'MyProjectName'
30
+ * toPascalCase('hello_world'); // 'HelloWorld'
31
+ * ```
32
+ */
33
+ function toPascalCase(str) {
34
+ return str
35
+ .split(/[-_\s]+/)
36
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
37
+ .join('');
38
+ }
39
+ /**
40
+ * Extracts the project name from .projenrc.ts.
41
+ *
42
+ * @param projectRoot - Path to project root
43
+ * @returns Project name
44
+ * @throws Error if .projenrc.ts is not found or name cannot be extracted
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const name = getProjectName('/path/to/project');
49
+ * // Returns 'my-app'
50
+ * ```
51
+ */
52
+ function getProjectName(projectRoot) {
53
+ const projenrcPath = (0, path_1.join)(projectRoot, '.projenrc.ts');
54
+ if (!(0, fs_1.existsSync)(projenrcPath)) {
55
+ throw new Error(`.projenrc.ts not found at ${projenrcPath}`);
56
+ }
57
+ const content = (0, fs_1.readFileSync)(projenrcPath, 'utf-8');
58
+ // Try to match: name: 'project-name' or name: "project-name"
59
+ const nameMatch = content.match(/name:\s*['"]([^'"]+)['"]/);
60
+ if (nameMatch) {
61
+ return nameMatch[1];
62
+ }
63
+ // Fallback: try to get from package.json
64
+ const packageJsonPath = (0, path_1.join)(projectRoot, 'package.json');
65
+ if ((0, fs_1.existsSync)(packageJsonPath)) {
66
+ const packageJson = JSON.parse((0, fs_1.readFileSync)(packageJsonPath, 'utf-8'));
67
+ if (packageJson.name) {
68
+ return packageJson.name;
69
+ }
70
+ }
71
+ throw new Error('Could not extract project name from .projenrc.ts or package.json');
72
+ }
73
+ /**
74
+ * Gets a CloudFormation stack output value using AWS CLI.
75
+ *
76
+ * @param stackName - Name of the CloudFormation stack
77
+ * @param outputKey - Key of the output to retrieve
78
+ * @returns Output value, or null if not found
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const apiUrl = getStackOutput('MyAppApiStack-dev', 'ApiUrl');
83
+ * // Returns 'https://abc123.execute-api.us-east-1.amazonaws.com/dev'
84
+ * ```
85
+ */
86
+ function getStackOutput(stackName, outputKey) {
87
+ try {
88
+ const result = (0, child_process_1.execSync)(`aws cloudformation describe-stacks --stack-name "${stackName}" --query "Stacks[0].Outputs[?OutputKey=='${outputKey}'].OutputValue" --output text`, { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
89
+ return result && result !== 'None' ? result : null;
90
+ }
91
+ catch {
92
+ logger_js_1.logger.debug(`Failed to get output ${outputKey} from stack ${stackName}`);
93
+ return null;
94
+ }
95
+ }
96
+ /**
97
+ * Gets all relevant stack outputs for deployment.
98
+ *
99
+ * @param projectRoot - Path to project root
100
+ * @param stage - Deployment stage
101
+ * @returns Stack outputs
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * const outputs = getStackOutputs('/path/to/project', 'dev');
106
+ * console.log(outputs.apiUrl);
107
+ * ```
108
+ */
109
+ function getStackOutputs(projectRoot, stage) {
110
+ const projectName = getProjectName(projectRoot);
111
+ const pascalName = toPascalCase(projectName);
112
+ const outputs = {};
113
+ // API Stack outputs
114
+ const apiStackName = `${pascalName}ApiStack-${stage}`;
115
+ outputs.apiUrl = getStackOutput(apiStackName, 'ApiUrl') ?? undefined;
116
+ // Frontend Stack outputs
117
+ const frontendStackName = `${pascalName}FrontendStack-${stage}`;
118
+ outputs.frontendBucket = getStackOutput(frontendStackName, 'FrontendBucketName') ?? undefined;
119
+ outputs.frontendDistributionId =
120
+ getStackOutput(frontendStackName, 'FrontendDistributionId') ?? undefined;
121
+ outputs.frontendUrl = getStackOutput(frontendStackName, 'FrontendUrl') ?? undefined;
122
+ // CMS Stack outputs
123
+ const cmsStackName = `${pascalName}CmsStack-${stage}`;
124
+ outputs.cmsBucket = getStackOutput(cmsStackName, 'CmsBucketName') ?? undefined;
125
+ outputs.cmsDistributionId = getStackOutput(cmsStackName, 'CmsDistributionId') ?? undefined;
126
+ outputs.cmsUrl = getStackOutput(cmsStackName, 'CmsUrl') ?? undefined;
127
+ return outputs;
128
+ }
129
+ /**
130
+ * Checks if a package exists in the project.
131
+ *
132
+ * @param projectRoot - Path to project root
133
+ * @param packageName - Name of the package to check
134
+ * @returns True if package exists
135
+ *
136
+ * @example
137
+ * ```typescript
138
+ * if (hasPackage('/path/to/project', 'frontend')) {
139
+ * console.log('Frontend package exists');
140
+ * }
141
+ * ```
142
+ */
143
+ function hasPackage(projectRoot, packageName) {
144
+ const packagePath = (0, path_1.join)(projectRoot, 'packages', packageName);
145
+ return (0, fs_1.existsSync)(packagePath);
146
+ }
147
+ /**
148
+ * Finds the build output directory for a package.
149
+ * Checks common build output directories: build/client, build, dist.
150
+ *
151
+ * @param packagePath - Path to the package
152
+ * @returns Path to build directory, or null if not found
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * const buildDir = findBuildDirectory('/path/to/project/packages/frontend');
157
+ * // Returns '/path/to/project/packages/frontend/build/client'
158
+ * ```
159
+ */
160
+ function findBuildDirectory(packagePath) {
161
+ // Check for Remix/Vite SPA build output (build/client)
162
+ const buildClientDir = (0, path_1.join)(packagePath, 'build', 'client');
163
+ if ((0, fs_1.existsSync)(buildClientDir)) {
164
+ return buildClientDir;
165
+ }
166
+ // Check for standard build directory
167
+ const buildDir = (0, path_1.join)(packagePath, 'build');
168
+ if ((0, fs_1.existsSync)(buildDir)) {
169
+ // If build exists but we need client assets, look for index.html
170
+ const hasIndex = (0, fs_1.existsSync)((0, path_1.join)(buildDir, 'index.html'));
171
+ if (hasIndex) {
172
+ return buildDir;
173
+ }
174
+ }
175
+ // Check for dist directory (some build tools use this)
176
+ const distDir = (0, path_1.join)(packagePath, 'dist');
177
+ if ((0, fs_1.existsSync)(distDir)) {
178
+ return distDir;
179
+ }
180
+ return null;
181
+ }
182
+ /**
183
+ * Prompts the user for confirmation.
184
+ *
185
+ * @param message - Message to display
186
+ * @returns True if user confirms
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * const confirmed = await promptConfirmation('Are you sure you want to destroy dev?');
191
+ * if (!confirmed) {
192
+ * console.log('Operation cancelled');
193
+ * }
194
+ * ```
195
+ */
196
+ async function promptConfirmation(message) {
197
+ const rl = (0, readline_1.createInterface)({
198
+ input: process.stdin,
199
+ output: process.stdout,
200
+ });
201
+ return new Promise((resolve) => {
202
+ rl.question(`${message} (y/N): `, (answer) => {
203
+ rl.close();
204
+ resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');
205
+ });
206
+ });
207
+ }
208
+ /**
209
+ * Builds a stack name following the project convention.
210
+ *
211
+ * @param projectName - Name of the project
212
+ * @param stackType - Type of stack (e.g., 'Api', 'Frontend', 'Cms')
213
+ * @param stage - Deployment stage
214
+ * @returns Full stack name
215
+ *
216
+ * @example
217
+ * ```typescript
218
+ * const stackName = buildStackName('my-app', 'Frontend', 'dev');
219
+ * // Returns 'MyAppFrontendStack-dev'
220
+ * ```
221
+ */
222
+ function buildStackName(projectName, stackType, stage) {
223
+ const pascalName = toPascalCase(projectName);
224
+ return `${pascalName}${stackType}Stack-${stage}`;
225
+ }
226
+ /**
227
+ * Syncs a local directory to an S3 bucket.
228
+ *
229
+ * @param localDir - Local directory path
230
+ * @param bucket - S3 bucket name
231
+ * @param verbose - Show verbose output
232
+ *
233
+ * @example
234
+ * ```typescript
235
+ * syncToS3('/path/to/build', 'my-app-frontend-dev-123456789', true);
236
+ * ```
237
+ */
238
+ function syncToS3(localDir, bucket, verbose = false) {
239
+ logger_js_1.logger.info(`Syncing ${localDir} to s3://${bucket}/`);
240
+ const command = `aws s3 sync "${localDir}" "s3://${bucket}/" --delete`;
241
+ logger_js_1.logger.debug(`Running: ${command}`);
242
+ try {
243
+ (0, child_process_1.execSync)(command, {
244
+ stdio: verbose ? 'inherit' : ['pipe', 'pipe', 'pipe'],
245
+ });
246
+ logger_js_1.logger.success(`Synced assets to s3://${bucket}/`);
247
+ }
248
+ catch (error) {
249
+ throw new Error(`Failed to sync to S3: ${error.message}`);
250
+ }
251
+ }
252
+ /**
253
+ * Creates a CloudFront invalidation for all paths.
254
+ *
255
+ * @param distributionId - CloudFront distribution ID
256
+ * @param verbose - Show verbose output
257
+ *
258
+ * @example
259
+ * ```typescript
260
+ * invalidateCloudFront('E1234567890ABC', true);
261
+ * ```
262
+ */
263
+ function invalidateCloudFront(distributionId, verbose = false) {
264
+ logger_js_1.logger.info(`Invalidating CloudFront distribution ${distributionId}`);
265
+ const command = `aws cloudfront create-invalidation --distribution-id "${distributionId}" --paths "/*"`;
266
+ logger_js_1.logger.debug(`Running: ${command}`);
267
+ try {
268
+ const result = (0, child_process_1.execSync)(command, {
269
+ encoding: 'utf-8',
270
+ stdio: verbose ? 'inherit' : ['pipe', 'pipe', 'pipe'],
271
+ });
272
+ if (!verbose) {
273
+ // Extract invalidation ID from response
274
+ const invalidationMatch = result.match(/"Id":\s*"([^"]+)"/);
275
+ if (invalidationMatch) {
276
+ logger_js_1.logger.info(`CloudFront invalidation created: ${invalidationMatch[1]}`);
277
+ }
278
+ }
279
+ logger_js_1.logger.success('CloudFront invalidation initiated (runs asynchronously)');
280
+ }
281
+ catch (error) {
282
+ throw new Error(`Failed to invalidate CloudFront: ${error.message}`);
283
+ }
284
+ }
285
+ /**
286
+ * Builds a frontend or CMS package with the API URL set.
287
+ *
288
+ * @param packagePath - Path to the package
289
+ * @param apiUrl - API URL to set as environment variable
290
+ * @param verbose - Show verbose output
291
+ *
292
+ * @example
293
+ * ```typescript
294
+ * buildPackage('/path/to/frontend', 'https://api.example.com', true);
295
+ * ```
296
+ */
297
+ function buildPackage(packagePath, apiUrl, verbose = false) {
298
+ const packageName = packagePath.split('/').pop();
299
+ logger_js_1.logger.info(`Building ${packageName} with API URL: ${apiUrl}`);
300
+ const command = 'pnpm build';
301
+ logger_js_1.logger.debug(`Running: ${command} in ${packagePath}`);
302
+ try {
303
+ (0, child_process_1.execSync)(command, {
304
+ cwd: packagePath,
305
+ stdio: verbose ? 'inherit' : ['pipe', 'pipe', 'pipe'],
306
+ env: {
307
+ ...process.env,
308
+ VITE_API_URL: apiUrl,
309
+ API_URL: apiUrl,
310
+ },
311
+ });
312
+ logger_js_1.logger.success(`Built ${packageName}`);
313
+ }
314
+ catch (error) {
315
+ throw new Error(`Failed to build ${packageName}: ${error.message}`);
316
+ }
317
+ }
318
+ /**
319
+ * Validates that AWS CLI is available and configured.
320
+ *
321
+ * @throws Error if AWS CLI is not available or not configured
322
+ */
323
+ function validateAwsCli() {
324
+ try {
325
+ (0, child_process_1.execSync)('aws --version', { stdio: ['pipe', 'pipe', 'pipe'] });
326
+ }
327
+ catch {
328
+ throw new Error('AWS CLI is not installed or not in PATH. ' +
329
+ 'Install it from https://aws.amazon.com/cli/ and run `aws configure`.');
330
+ }
331
+ try {
332
+ (0, child_process_1.execSync)('aws sts get-caller-identity', { stdio: ['pipe', 'pipe', 'pipe'] });
333
+ }
334
+ catch {
335
+ throw new Error('AWS credentials not configured. Run `aws configure` or set AWS environment variables.');
336
+ }
337
+ }
338
+ /**
339
+ * Lists all stacks in a project for a given stage.
340
+ *
341
+ * @param projectRoot - Path to project root
342
+ * @param stage - Deployment stage
343
+ * @returns Array of stack names
344
+ */
345
+ function listProjectStacks(projectRoot, stage) {
346
+ const projectName = getProjectName(projectRoot);
347
+ const pascalName = toPascalCase(projectName);
348
+ const stacks = [];
349
+ // Check for infrastructure stacks directory
350
+ const stacksDir = (0, path_1.join)(projectRoot, 'packages', 'infra', 'src', 'stacks');
351
+ if ((0, fs_1.existsSync)(stacksDir)) {
352
+ const files = (0, fs_1.readdirSync)(stacksDir);
353
+ for (const file of files) {
354
+ if (file.endsWith('-stack.ts')) {
355
+ // Extract stack name from file (e.g., 'api-stack.ts' -> 'Api')
356
+ const stackType = file
357
+ .replace('-stack.ts', '')
358
+ .split('-')
359
+ .map((w) => w.charAt(0).toUpperCase() + w.slice(1))
360
+ .join('');
361
+ stacks.push(`${pascalName}${stackType}Stack-${stage}`);
362
+ }
363
+ }
364
+ }
365
+ return stacks;
366
+ }
367
+ //# sourceMappingURL=deploy-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy-utils.js","sourceRoot":"","sources":["../../src/lib/deploy-utils.ts"],"names":[],"mappings":";;AAkBA,oCAKC;AAeD,wCAyBC;AAeD,wCAYC;AAmCD,0CAwBC;AAgBD,gCAGC;AAeD,gDAwBC;AAgBD,gDAYC;AAgBD,wCAGC;AAcD,4BAcC;AAaD,oDAwBC;AAcD,oCAqBC;AAOD,wCAiBC;AASD,8CAwBC;AA3ZD,iDAAyC;AACzC,2BAA2D;AAC3D,+BAA4B;AAC5B,uCAA2C;AAC3C,2CAAqC;AAErC;;;;;;;;;;;GAWG;AACH,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,GAAG;SACP,KAAK,CAAC,SAAS,CAAC;SAChB,GAAG,CAAC,CAAC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display name of the stack (e.g., 'Frontend' or 'Cms').
7
+ */
8
+ name: string;
9
+ /**
10
+ * Class name of the stack (e.g., 'FrontendStack' or 'CmsStack').
11
+ */
12
+ className: string;
13
+ /**
14
+ * Import path for the stack (e.g., './stacks/frontend-stack').
15
+ */
16
+ importPath: string;
17
+ /**
18
+ * Variable name for the stack instance (e.g., 'frontendStack' or 'cmsStack').
19
+ */
20
+ variableName: string;
21
+ /**
22
+ * Array of stack variable names this stack depends on.
23
+ */
24
+ dependsOn: string[];
25
+ /**
26
+ * Props string to pass to stack constructor (e.g., '{ env, stage, apiUrl: apiStack.apiUrl }').
27
+ */
28
+ props: string;
29
+ /**
30
+ * Description for the stack comment.
31
+ */
32
+ description: string;
33
+ }
34
+ /**
35
+ * Options for generating a frontend stack.
36
+ */
37
+ export interface GenerateFrontendStackOptions {
38
+ /**
39
+ * Path to the project root.
40
+ */
41
+ projectPath: string;
42
+ /**
43
+ * Name of the project.
44
+ */
45
+ projectName: string;
46
+ /**
47
+ * Name of the API package.
48
+ */
49
+ apiName: string;
50
+ }
51
+ /**
52
+ * Options for generating a CMS stack.
53
+ */
54
+ export interface GenerateCmsStackOptions {
55
+ /**
56
+ * Path to the project root.
57
+ */
58
+ projectPath: string;
59
+ /**
60
+ * Name of the project.
61
+ */
62
+ projectName: string;
63
+ /**
64
+ * Name of the API package.
65
+ */
66
+ apiName: string;
67
+ }
1
68
  /**
2
69
  * Options for generating the infrastructure package.
3
70
  */
@@ -21,4 +88,45 @@ export interface InfraGeneratorOptions {
21
88
  * @param options - Generation options
22
89
  */
23
90
  export declare function generateInfraPackage(options: InfraGeneratorOptions): void;
91
+ /**
92
+ * Returns the frontend-stack.ts template.
93
+ *
94
+ * @param projectName - Name of the project
95
+ * @returns Generated TypeScript code for frontend stack
96
+ */
97
+ export declare function getFrontendStackTemplate(projectName: string): string;
98
+ /**
99
+ * Returns the cms-stack.ts template.
100
+ *
101
+ * @param projectName - Name of the project
102
+ * @returns Generated TypeScript code for CMS stack
103
+ */
104
+ export declare function getCmsStackTemplate(projectName: string): string;
105
+ /**
106
+ * Updates app.ts to add a new stack.
107
+ *
108
+ * This function performs incremental updates to the existing app.ts file:
109
+ * 1. Adds import statement for the new stack
110
+ * 2. Adds stack instantiation code
111
+ * 3. Adds dependency declarations
112
+ * 4. Updates the output summary if present
113
+ *
114
+ * @param appTsPath - Path to the app.ts file
115
+ * @param config - Stack configuration
116
+ * @param projectName - Name of the project (for console output)
117
+ * @returns true if update was successful, false if stack already exists
118
+ */
119
+ export declare function updateAppTsForStack(appTsPath: string, config: StackConfig, projectName: string): boolean;
120
+ /**
121
+ * Generates the frontend stack and updates app.ts.
122
+ *
123
+ * @param options - Generation options
124
+ */
125
+ export declare function generateFrontendStack(options: GenerateFrontendStackOptions): Promise<void>;
126
+ /**
127
+ * Generates the CMS stack and updates app.ts.
128
+ *
129
+ * @param options - Generation options
130
+ */
131
+ export declare function generateCmsStack(options: GenerateCmsStackOptions): Promise<void>;
24
132
  //# sourceMappingURL=infra-generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"infra-generator.d.ts","sourceRoot":"","sources":["../../src/lib/infra-generator.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CA2BzE"}
1
+ {"version":3,"file":"infra-generator.d.ts","sourceRoot":"","sources":["../../src/lib/infra-generator.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;I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