@architect/destroy
Advanced tools
Comparing version 2.0.4-RC.0 to 3.0.0-RC.0
@@ -5,6 +5,7 @@ # Architect Destroy changelog | ||
## [next] 2022-01-23 | ||
## [3.0.0] 2022-01-23 | ||
### Changed | ||
- Breaking change: bare CLI arguments (e.g. `destroy force`) as aliases to flags are no longer used | ||
- Stop publishing to the GitHub Package registry | ||
@@ -11,0 +12,0 @@ - Updated dependencies |
{ | ||
"name": "@architect/destroy", | ||
"version": "2.0.4-RC.0", | ||
"version": "3.0.0-RC.0", | ||
"description": "Destroy projects created with Architect", | ||
@@ -29,2 +29,3 @@ "main": "src/index.js", | ||
"aws-sdk": "2.1001.0", | ||
"minimist": "~1.2.5", | ||
"run-parallel": "~1.2.0", | ||
@@ -31,0 +32,0 @@ "run-waterfall": "~1.1.7" |
#!/usr/bin/env node | ||
let minimist = require('minimist') | ||
let _inventory = require('@architect/inventory') | ||
@@ -9,40 +10,33 @@ let { banner, updater } = require('@architect/utils') | ||
if (require.main === module) { | ||
(async function () { | ||
try { | ||
await main(process.argv) | ||
} | ||
catch (err) { | ||
console.log(err) | ||
} | ||
})() | ||
} | ||
// TODO move CLI logic into CLI and turn other libs into stand alone pure modules | ||
async function main (args) { | ||
async function main (opts = {}) { | ||
let { inventory } = opts | ||
let appname | ||
try { | ||
let inventory = await _inventory({}) | ||
if (!inventory) inventory = await _inventory({}) | ||
appname = inventory.inv.app | ||
if (require.main === module) { | ||
banner({ inventory, version: `Destroy ${version}` }) | ||
let alias = { | ||
force: [ 'f' ], | ||
production: [ 'p' ], | ||
debug: [ 'd' ], | ||
verbose: [ 'v' ], | ||
} | ||
let boolean = [ 'debug', 'force', 'now', 'no-timeout', 'production', 'static', 'verbose' ] | ||
let def = { now: false, timeout: true } | ||
let args = minimist(process.argv.slice(2), { alias, boolean, default: def }) | ||
if (args._[0] === 'destroy') args._.splice(0, 1) | ||
let findApp = p => p === '--app' | ||
let app = args.includes('--app') && (args[args.findIndex(findApp) + 1] === appname) | ||
if (!app) throw Error('no_app_name') | ||
if (!args.app || args.app !== appname) throw Error('no_app_name') | ||
// User should supply --app $appname in the CLI, however if they only supply --name (the old destroy behavior) then interpret that as --app (and warn) | ||
let findName = p => p === '--name' | ||
let stackname = args.includes('--name') && args[args.findIndex(findName) + 1] | ||
let env = args.production ? 'production' : 'staging' | ||
let params = { | ||
appname: args.app, | ||
env, | ||
force: args.force, | ||
now: args.now, | ||
retries: args.timeout ? 15 : 999, | ||
stackname: args.name, | ||
update | ||
} | ||
let forces = p => [ '-f', '--force', 'force' ].includes(p) | ||
let force = args.some(forces) | ||
let production = args.includes('--production') | ||
let retries = args.includes('--no-timeout') ? 999 : 15 // how many times do we ping the CloudFormation API to check if the stack is deleted? | ||
let now = args.includes('--now') | ||
let env = production ? 'production' : 'staging' | ||
update.status(`Destroying ${env} environment`) | ||
@@ -52,3 +46,3 @@ if (env === 'staging') { | ||
} | ||
await destroy({ appname, stackname, env, force, now, retries, update }) | ||
return destroy(params) | ||
} | ||
@@ -77,1 +71,14 @@ catch (err) { | ||
module.exports = main | ||
if (require.main === module) { | ||
(async function () { | ||
try { | ||
let inventory = await _inventory({}) | ||
banner({ inventory, version: `Destroy ${version}` }) | ||
await main({ inventory }) | ||
} | ||
catch (err) { | ||
console.log(err) | ||
} | ||
})() | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
451
21521
6
+ Addedminimist@~1.2.5
+ Addedminimist@1.2.8(transitive)