Skip to content

Commit 16a1d2f

Browse files
feat: Add approval required option (#95)
* feat: Add approval required option * fix: approval setting in wizard * fix: remove all parameter * Add version * Handle user canceling the input * Fix exit
1 parent 39b27c0 commit 16a1d2f

File tree

6 files changed

+257
-94
lines changed

6 files changed

+257
-94
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ The configuration is saved to `lldebugger.config.ts`.
101101

102102
```
103103
-V, --version output the version number
104-
-r, --remove [option] Remove Lambda Live Debugger infrastructure. Options: 'keep-layer' (default), 'remove-all'. The latest also removes the Lambda Layer
104+
-r, --remove [option] Remove Lambda Live Debugger infrastructure. Options: 'keep-layer' (default), 'all'. The latest also removes the Lambda Layer
105105
-w, --wizard Program interactively asks for each parameter and saves it to lldebugger.config.ts
106106
-v, --verbose Verbose logging
107107
-c, --context <context> AWS CDK context (default: [])
@@ -110,6 +110,7 @@ The configuration is saved to `lldebugger.config.ts`.
110110
-m, --subfolder <subfolder> Monorepo subfolder
111111
-o, --observable Observability mode
112112
-i --interval <interval> Observability mode interval (default: "3000")
113+
-a --approval User approval required for AWS infrastructure changes, like adding a Lambda layer
113114
--config-env <evironment> SAM environment
114115
--sam-config-file <file> SAM configuration file
115116
--sam-template-file <file> SAM template file

src/configuration/getConfigFromCliArgs.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export async function getConfigFromCliArgs(
2020
program.name('lld').description('Lambda Live Debugger').version(version);
2121
program.option(
2222
'-r, --remove [option]',
23-
"Remove Lambda Live Debugger infrastructure. Options: 'keep-layer' (default), 'remove-all'. The latest also removes the Lambda Layer",
23+
"Remove Lambda Live Debugger infrastructure. Options: 'keep-layer' (default), 'all'. The latest also removes the Lambda Layer",
2424
//validateRemoveOption,
2525
//"keep-layer"
2626
);
@@ -47,6 +47,10 @@ export async function getConfigFromCliArgs(
4747
'Observability mode interval',
4848
defaultObservableInterval.toString(),
4949
);
50+
program.option(
51+
'-a, --approval',
52+
'User approval required for AWS infrastructure changes, like adding a Lambda layer',
53+
);
5054
program.option('--config-env <evironment>', 'SAM environment');
5155
program.option('--sam-config-file <file>', 'SAM configuration file');
5256
program.option('--sam-template-file <file>', 'SAM template file');

src/configuration/getConfigFromWizard.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,19 @@ export async function getConfigFromWizard({
199199
};
200200
}
201201

202+
// do you want to manually approve AWS infrastructure changes?
203+
const answersApproval = await inquirer.prompt([
204+
{
205+
type: 'confirm',
206+
name: 'approval',
207+
message:
208+
'Before debugging, do you want to review and manually approve AWS infrastructure changes, like adding a Lambda layer?',
209+
default: currentConfig?.approval === true,
210+
},
211+
]);
212+
213+
answers = { ...answers, ...answersApproval };
214+
202215
const answersAws = await inquirer.prompt([
203216
{
204217
type: 'input',
@@ -388,6 +401,8 @@ export default {
388401
observable: ${config.observable},
389402
// Observable mode interval
390403
interval: ${config.interval === defaultObservableInterval ? undefined : config.interval},
404+
// Approval required for AWS infrastructure changes
405+
approval: ${config.approval},
391406
// Verbose logging
392407
verbose: ${config.verbose},
393408
// Modify Lambda function list or support custom framework
@@ -434,6 +449,7 @@ function getConfigFromAnswers(answers: any): LldConfigCliArgs {
434449
answers.interval !== undefined
435450
? answers.interval
436451
: defaultObservableInterval,
452+
approval: answers.approval,
437453
verbose: answers.verbose,
438454
interactive: answers.interactive,
439455
gitignore: answers.gitignore,

0 commit comments

Comments
 (0)