Skip to content

Commit

Permalink
fix: tweak stderr output
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Oct 5, 2022
1 parent d54d9c4 commit 5405f07
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/Deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class Deployer {
constructor(cloudformationClient, { changesetPrefix } = {}) {
this._client = cloudformationClient
this.changesetPrefix =
changesetPrefix || 'awscli-cloudformation-package-deploy-'
changesetPrefix || 'jcoreio-cloudformation-tools-package-deploy-'
}

async hasStack(StackName) {
Expand Down Expand Up @@ -120,7 +120,7 @@ export default class Deployer {
StackName,
}): Promise<{ HasChanges: boolean }> {
process.stderr.write(
`\nWaiting for changeset to be created - ${StackName}...\n`
`Waiting for changeset to be created - ${StackName}...\n`
)
let retriesRemaining = 20
let done = false
Expand Down Expand Up @@ -193,7 +193,7 @@ export default class Deployer {

async waitForExecute({ StackName, ChangeSetType }) {
process.stderr.write(
`Waiting for stack create/update to complete - ${StackName}\n`
`Waiting for stack create/update to complete - ${StackName}...\n`
)
await this._client
.waitFor(
Expand Down
34 changes: 15 additions & 19 deletions src/deployCloudFormationStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ export default async function deployCloudFormationStack({
].includes(StackStatus)

if (StackPolicy && !createFailed) {
// eslint-disable-next-line no-console
console.error(`Setting policy on stack ${StackName}...`)
process.stderr.write(`Setting policy on stack ${StackName}...\n`)
await cloudformation
.setStackPolicy({
StackName,
Expand All @@ -182,8 +181,9 @@ export default async function deployCloudFormationStack({
)
}
}
// eslint-disable-next-line no-console
console.error(`Deleting existing ${StackStatus} stack: ${StackName}...`)
process.stderr.write(
`Deleting existing ${StackStatus} stack: ${StackName}...\n`
)
await watchDuring(() =>
Promise.all([
cloudformation
Expand All @@ -193,11 +193,10 @@ export default async function deployCloudFormationStack({
])
)
} else if (/_IN_PROGRESS$/.test(StackStatus)) {
// eslint-disable-next-line no-console
console.error(
process.stderr.write(
`Waiting for ${StackStatus.replace(/^(.*)_IN_PROGRESS$/, (m, a) =>
a.toLowerCase()
)} to complete on existing stack ${StackName}...`
)} to complete on existing stack ${StackName}...\n`
)
await watchDuring(() =>
cloudformation
Expand Down Expand Up @@ -229,12 +228,11 @@ export default async function deployCloudFormationStack({
ChangeSetName,
StackName,
})
// eslint-disable-next-line no-console
console.error(
process.stderr.write(
`Changes to stack ${StackName}:\n${inspect(changes, {
colors: true,
depth: 5,
})}`
})}\n`
)
const { approved } = await inquirer.prompt([
{
Expand All @@ -244,20 +242,19 @@ export default async function deployCloudFormationStack({
default: true,
},
])
// eslint-disable-next-line no-console
console.error(approved ? 'OK, deploying...' : 'OK, aborted deployment')
process.stderr.write(
approved ? 'OK, deploying...\n' : 'OK, aborted deployment\n'
)
if (!approved) {
if (ExistingStack) {
// eslint-disable-next-line no-console
console.error(
`Deleting aborted change set ${ChangeSetName} on stack ${StackName}...`
process.stderr.write(
`Deleting aborted change set ${ChangeSetName} on stack ${StackName}...\n`
)
await cloudformation
.deleteChangeSet({ StackName, ChangeSetName })
.promise()
} else {
// eslint-disable-next-line no-console
console.error(`Deleting aborted stack ${StackName}...`)
process.stderr.write(`Deleting aborted stack ${StackName}...\n`)
await Promise.all([
cloudformation
.waitFor('stackDeleteComplete', { StackName })
Expand All @@ -283,8 +280,7 @@ export default async function deployCloudFormationStack({
})
})
} else {
// eslint-disable-next-line no-console
console.error(`Stack ${StackName} is already in the desired state`)
process.stderr.write(`Stack ${StackName} is already in the desired state\n`)
}

if (StackPolicy && !ExistingStack) {
Expand Down

0 comments on commit 5405f07

Please sign in to comment.