From 4fe52f49df466f52c92aa5a90b5c96bdbe0d3523 Mon Sep 17 00:00:00 2001 From: Bender Date: Thu, 13 Oct 2022 12:45:52 +0200 Subject: [PATCH] feat(cdk): bootstrap option added for deployments --- lib/cli.ts | 11 ++++++----- lib/cli/deploy.ts | 9 ++++++++- package-lock.json | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/cli.ts b/lib/cli.ts index ccc7478..bbc3cb4 100644 --- a/lib/cli.ts +++ b/lib/cli.ts @@ -40,8 +40,8 @@ program path.resolve(commandCwd, './next.out'), ) .action(async (options) => { - const { standaloneFolder, publicFolder, handlerPath, outputFolder } = options console.log('Our config is: ', options) + const { standaloneFolder, publicFolder, handlerPath, outputFolder } = options wrapProcess(packHandler({ commandCwd, handlerPath, outputFolder, publicFolder, standaloneFolder })) }) @@ -52,8 +52,8 @@ program .argument('', 'Your existing app version which should be used for calculation of next version.') .option('-t, --tagPrefix ', 'Prefix version with string of your choice', 'v') .action(async (commitMessage, latestVersion, options) => { - const { tagPrefix } = options console.log('Our config is: ', options) + const { tagPrefix } = options wrapProcess(guessHandler({ commitMessage, latestVersion, tagPrefix })) }) @@ -68,8 +68,8 @@ program .option('--gitUser ', 'User name to be used for commits.', 'Bender') .option('--gitEmail ', 'User email to be used for commits.', 'bender@bot.eu') .action(async (options) => { - const { tagPrefix, failOnMissingCommit, releaseBranchPrefix, forceBump, gitUser, gitEmail } = options console.log('Our config is: ', options) + const { tagPrefix, failOnMissingCommit, releaseBranchPrefix, forceBump, gitUser, gitEmail } = options wrapProcess(shipitHandler({ tagPrefix, gitEmail, gitUser, failOnMissingCommit, forceBump, releaseBranchPrefix })) }) @@ -78,10 +78,11 @@ program .description('Deploy Next application via CDK') .option('--stackName ', 'Name of the stack to be deployed.', 'StandaloneNextjsStack-Temporary') .option('--appPath ', 'Absolute path to app.', path.resolve(__dirname, '../dist/cdk-app.js')) + .option('--bootstrap', 'Bootstrap CDK stack.', false) .action(async (options) => { - const { stackName, appPath } = options console.log('Our config is: ', options) - wrapProcess(deployHandler({ stackName, appPath })) + const { stackName, appPath, bootstrap } = options + wrapProcess(deployHandler({ stackName, appPath, bootstrap })) }) program.parse(process.argv) diff --git a/lib/cli/deploy.ts b/lib/cli/deploy.ts index c79f7a2..88b7713 100644 --- a/lib/cli/deploy.ts +++ b/lib/cli/deploy.ts @@ -3,15 +3,22 @@ import { executeAsyncCmd } from '../utils' interface Props { stackName: string appPath: string + bootstrap: boolean } const cdkExecutable = require.resolve('aws-cdk/bin/cdk') -export const deployHandler = async ({ stackName, appPath }: Props) => { +export const deployHandler = async ({ stackName, appPath, bootstrap }: Props) => { // All paths are absolute. const cdkApp = `node ${appPath}` const cdkCiFlags = `--require-approval never --ci` + if (bootstrap) { + await executeAsyncCmd({ + cmd: `STACK_NAME=${stackName} ${cdkExecutable} bootstrap --app "${cdkApp}"`, + }) + } + await executeAsyncCmd({ cmd: `STACK_NAME=${stackName} ${cdkExecutable} deploy --app "${cdkApp}" ${cdkCiFlags}`, }) diff --git a/package-lock.json b/package-lock.json index 791537a..6ef6bad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@sladg/nextjs-lambda", - "version": "3.13.0", + "version": "3.14.0", "license": "MIT", "dependencies": { "@aws-cdk/aws-apigatewayv2-alpha": "^2.41.0-alpha.0",