@architect/destroy
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -5,2 +5,17 @@ # Architect Sandbox changelog | ||
## [1.2.0] 2021-04-30 | ||
### Added | ||
- Added support for custom stage names (aka stack names), fixes #1055; thanks @filmaj + @ryanbethel! | ||
- Added `--now` CLI flag in case you just like really need to destroy stuff right. now. | ||
### Changed | ||
- Specifying the app to destroy, formerly the `--name` CLI flag, should now be used as `--app` | ||
- `--app` and `--name` can now be used together | ||
--- | ||
## [1.1.1] 2021-04-12 | ||
@@ -7,0 +22,0 @@ |
{ | ||
"name": "@architect/destroy", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Destroy projects created with Architect", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -15,3 +15,3 @@ [<img src="https://s3-us-west-2.amazonaws.com/arc.codes/architect-logo-500b@2x.png" width=500>](https://www.npmjs.com/package/@architect/destroy) | ||
### `destroy({ appname, env, force }, callback)` | ||
### `destroy({ appname, stackname, env, force, now }, callback)` | ||
@@ -21,3 +21,5 @@ Destroys all infrastructure associated to your Architect app. | ||
- `appname`: the name of the Architect app in question as defined in your `app.arc` file. | ||
- `env`: the stage or environment name to destroy. Typical values are `staging` or `production`. | ||
- `stackname`: the custom stack name (if specified during deployment, e.g. `arc deploy --name foo`) | ||
- `env`: the stage or environment name to destroy, typical values are `staging` or `production` | ||
- `force` proceeds to destroy your app even if it contains DynamoDB tables and / or an S3 bucket containing `@static` assets. | ||
- `now`: (boolean) immeditely destroy the app (instead of waiting the requisite 5 seconds) |
@@ -27,4 +27,20 @@ #!/usr/bin/env node | ||
if (require.main === module) { | ||
banner({ inventory, version: `Destroy ${version}` }) | ||
} | ||
let findApp = p => p === '--app' | ||
let app = args.includes('--app') && (args[args.findIndex(findApp) + 1] === appname) | ||
// 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 named = args.includes('--name') && (args[args.findIndex(findName) + 1] === appname) | ||
let stackname | ||
if (!app && args.includes('--name')) { | ||
app = (args[args.findIndex(findName) + 1] === appname) | ||
update.warn(`--name flag has been updated to support custom stack names, you should specify the app to destroy with: --app ${appname}`) | ||
} | ||
else { | ||
stackname = args.includes('--name') && args[args.findIndex(findName) + 1] | ||
} | ||
let forces = p => [ '-f', '--force', 'force' ].includes(p) | ||
@@ -34,8 +50,7 @@ let force = args.some(forces) | ||
if (require.main === module) { | ||
banner({ inventory, version: `Destroy ${version}` }) | ||
let now = args.includes('--now') | ||
if (!app) { | ||
throw Error('no_app_name') | ||
} | ||
if (!named) { | ||
throw Error('no_name') | ||
} | ||
let env = production ? 'production' : 'staging' | ||
@@ -46,3 +61,3 @@ update.status(`Destroying ${env} environment`) | ||
} | ||
await destroy({ appname, env, force, update }) | ||
await destroy({ appname, stackname, env, force, now, update }) | ||
} | ||
@@ -52,4 +67,4 @@ catch (err) { | ||
let msg = 'To destroy this app (and any static assets and database tables that belong to it), run destroy with: --force' | ||
if (message === 'no_name') { | ||
update.warn(`If you're really sure you want to destroy this app, run destroy with: --name ${appname}`) | ||
if (message === 'no_app_name') { | ||
update.warn(`If you're really sure you want to destroy this app, run destroy with: --app ${appname}`) | ||
} | ||
@@ -56,0 +71,0 @@ else if (message === 'bucket_exists') { |
@@ -15,3 +15,3 @@ let aws = require('aws-sdk') | ||
module.exports = function destroy (params, callback) { | ||
let { appname, env, force = false, update } = params | ||
let { appname, stackname, env, force = false, now, update } = params | ||
if (!update) update = updater('Destroy') | ||
@@ -27,3 +27,7 @@ | ||
// StackName → AWS, stackname → user-specified | ||
let StackName = toLogicalID(`${appname}-${env}`) | ||
if (stackname) { | ||
StackName += toLogicalID(stackname) | ||
} | ||
@@ -48,7 +52,12 @@ // hack around no native promise in aws-sdk | ||
function (callback) { | ||
update.status(`Destroying ${StackName} in 5 seconds...`) | ||
setTimeout(() => { | ||
update.status(`Destroying ${StackName}`) | ||
if (now) { | ||
update.status(`Destroying ${StackName} immediately, hope you know what you're doing!`) | ||
callback() | ||
}, process.env.FUSE ? parseInt(process.env.FUSE) : 5000) // provide an override (mostly for testing) | ||
} | ||
else { | ||
update.status(`Destroying ${StackName} in 5 seconds...`) | ||
setTimeout(() => { | ||
callback() | ||
}, 5000) | ||
} | ||
}, | ||
@@ -58,2 +67,3 @@ | ||
function (callback) { | ||
update.status(`Destroying ${StackName}`) | ||
cloudformation.describeStacks({ | ||
@@ -60,0 +70,0 @@ StackName |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
17983
424
24
4