Skip to content

Commit

Permalink
feat(AWS Deploy): Ensure that deprecation is properly triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed Jun 29, 2021
1 parent 2367558 commit 58d7d51
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 8 additions & 0 deletions docs/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ Note:
- Configuration setting is ineffective for deprecations reported before service configuration is read.
- `SLS_DEPRECATION_DISABLE` env var and `disabledDeprecations` configuration setting remain respected, and no errors will be thrown for mentioned deprecation coodes.

<a name="CLI_DEPLOY_FUNCTION_OPTION"><div>&nbsp;</div></a>

## CLI `--function`/`-f` option for `deploy` command

Deprecation code: `CLI_DEPLOY_FUNCTION_OPTION'`

Starting with v3.0.0, `--function` or `-f` option for `deploy` command will be removed. In order to deploy a single function, please use `deploy function` command instead.

<a name="CHANGE_OF_DEFAULT_RUNTIME_TO_NODEJS14X"><div>&nbsp;</div></a>

## Change of default runtime to `nodejs14.x`
Expand Down
15 changes: 11 additions & 4 deletions lib/plugins/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,24 @@ class Deploy {
};

this.hooks = {
'initialize': () => {
const isDeployCommand =
this.serverless.processedInput.commands.length === 1 &&
this.serverless.processedInput.commands[0] === 'deploy';
if (isDeployCommand && this.options.function) {
this.serverless.logDeprecation(
'CLI_DEPLOY_FUNCTION_OPTION',
'Starting with v3.0.0, `--function` or `-f` option for `deploy` command will be removed. In order to deploy a single function, please use `deploy function` command instead.'
);
}
},
'before:deploy:deploy': async () => {
const provider = this.serverless.service.provider.name;
if (!this.serverless.getProvider(provider)) {
const errorMessage = `The specified provider "${provider}" does not exist.`;
throw new ServerlessError(errorMessage, 'INVALID_PROVIDER');
}
if (this.options.function) {
this.serverless.logDeprecation(
'CLI_DEPLOY_FUNCTION_OPTION',
'Starting with v3.0.0, `--function` or `-f` option for `deploy` command will be removed. In order to deploy a single function, please use `deploy function` command instead.'
);
// If the user has given a function parameter, spawn a function deploy
// and terminate execution right afterwards. We did not enter the
// deploy lifecycle yet, so nothing has to be cleaned up.
Expand Down

0 comments on commit 58d7d51

Please sign in to comment.