Skip to content

Commit

Permalink
feat(cdk): bootstrap option added for deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
Bender committed Oct 13, 2022
1 parent 4c818e4 commit 4fe52f4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
11 changes: 6 additions & 5 deletions lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }))
})

Expand All @@ -52,8 +52,8 @@ program
.argument('<latestVersion>', 'Your existing app version which should be used for calculation of next version.')
.option('-t, --tagPrefix <prefix>', '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 }))
})

Expand All @@ -68,8 +68,8 @@ program
.option('--gitUser <user>', 'User name to be used for commits.', 'Bender')
.option('--gitEmail <email>', '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 }))
})

Expand All @@ -78,10 +78,11 @@ program
.description('Deploy Next application via CDK')
.option('--stackName <name>', 'Name of the stack to be deployed.', 'StandaloneNextjsStack-Temporary')
.option('--appPath <path>', '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)
9 changes: 8 additions & 1 deletion lib/cli/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
})
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4fe52f4

Please sign in to comment.