Skip to content

Commit 5ff4bb3

Browse files
committed
feat: use verbose from serverless cli options
1 parent 7f2e622 commit 5ff4bb3

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,12 @@ custom:
8686
serverless-aws-secrets:
8787
secretId: ...
8888
secretPrefix: ...
89-
verbose: ...
9089
```
9190

9291
* `secretId`: Location of the secret in AWS Secrets Manager. Default: `${provider.stage}/${app}-${service}`
9392

9493
* `secretPrefix`: Prefix of the secret name in AWS Secrets Manager. Default: `secret:`
9594

96-
* `verbose`: Enable verbose logging. Default: `false`
97-
9895
## Local Development
9996

10097
These instructions will help you to run the project in your local.

src/index.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { SecretsManagerClient, GetSecretValueCommand } from '@aws-sdk/client-secrets-manager';
22

3-
import type { Serverless, ServerlessSecretHooks, ServerlessSecretOptions, ServerlessOptions } from './index.types';
3+
import type {
4+
Serverless,
5+
ServerlessSecretHooks,
6+
ServerlessSecretOptions,
7+
ServerlessOptions,
8+
ServerlessCliOptions,
9+
} from './index.types';
410

511
class ServerlessAWSSecret {
612
Error: ErrorConstructor;
@@ -9,9 +15,9 @@ class ServerlessAWSSecret {
915
options: ServerlessSecretOptions;
1016
serverless: Serverless;
1117

12-
constructor(serverless: Serverless, cliOptions: unknown, options: ServerlessOptions) {
18+
constructor(serverless: Serverless, cliOptions: ServerlessCliOptions, options: ServerlessOptions) {
1319
this.setOptions(serverless);
14-
this.setLogger(options);
20+
this.setLogger(options, cliOptions);
1521

1622
this.serverless = serverless;
1723
this.Error = serverless.classes?.Error ?? Error;
@@ -59,12 +65,11 @@ class ServerlessAWSSecret {
5965

6066
this.options.secretId = this.getSecretId(serverless);
6167
this.options.secretPrefix = this.getSecretPrefix();
62-
this.options.verbose = this.options.verbose ?? false;
6368
}
6469

65-
setLogger(options?: ServerlessOptions) {
70+
setLogger(options?: ServerlessOptions, cliOptions?: ServerlessCliOptions) {
6671
this.log = {
67-
verbose: options?.log?.verbose ?? this.options.verbose ? console.log : () => {},
72+
verbose: options?.log?.verbose ?? cliOptions?.verbose ? console.log : () => {},
6873
success: options?.log?.success ?? console.log,
6974
};
7075
}

src/index.types.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export interface Serverless {
1818
};
1919
}
2020

21+
export interface ServerlessCliOptions {
22+
verbose?: boolean;
23+
}
24+
2125
export interface ServerlessSecretHooks {
2226
[key: string]: () => void;
2327
}
@@ -41,10 +45,4 @@ export interface ServerlessSecretOptions {
4145
* @default `${stage}/${app}-${service}`
4246
*/
4347
secretId?: string;
44-
45-
/**
46-
* @dev Enable verbose logging.
47-
* @default false
48-
*/
49-
verbose?: boolean;
5048
}

0 commit comments

Comments
 (0)