New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(AWS Deploy): Deprecate function
option in deploy
command
#9364
refactor(AWS Deploy): Deprecate function
option in deploy
command
#9364
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9364 +/- ##
==========================================
- Coverage 86.14% 86.14% -0.01%
==========================================
Files 326 326
Lines 12436 12439 +3
==========================================
+ Hits 10713 10715 +2
- Misses 1723 1724 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @jkklapp 🙇 It looks like a good start, but we should be more careful with removing functionalities that might break user workflows. In this case, we should just configure deprecation message, while keeping the old functionality and warn that it will be removed with next major version.
test/unit/lib/plugins/deploy.test.js
Outdated
deploy.options.package = false; | ||
deploy.options.function = 'myfunc'; | ||
deploy.serverless.service.package.path = false; | ||
|
||
return expect(deploy.hooks['before:deploy:deploy']()).to.be.fulfilled.then(() => | ||
BbPromise.all([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not change this test - we still want to keep testing the old behavior until we remove it.
test/unit/lib/plugins/deploy.test.js
Outdated
@@ -79,18 +79,14 @@ describe('Deploy', () => { | |||
); | |||
}); | |||
|
|||
it('should execute deploy function if a function option is given', () => { | |||
it('should log a deprecation message if a function option is given', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually don't test deprecation messages and I think we can skip test in this case as well. Otherwise, please configure the test with runServerless
lib/plugins/deploy.js
Outdated
'CLI_DEPLOY_FUNCTION_OPTION', | ||
'The `--function` or `-f` option for `deploy` command has been r' + | ||
'emoved. Please use `sls deploy function` command instead.' | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR should only implement a deprecation notice, without removing the functionality.
docs/deprecations.md
Outdated
|
||
<a name="CLI_DEPLOY_FUNCTION_OPTION"><div> </div></a> | ||
|
||
## CLI deploy command function option removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's phrase the whole message so it explains that the flag has been deprecated and will be removed with next major (3.0.0
).
3b43652
to
998274a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @jkklapp 🙇 I've added some suggestions to the deprecation message wording - please let me know what do you think 🙇
docs/deprecations.md
Outdated
@@ -363,3 +363,12 @@ Please use `onUnauthenticatedRequest` instead. `allowUnauthenticated` will be re | |||
Deprecation code: `BIN_SERVERLESS` | |||
|
|||
Please use `bin/serverless.js` instead. `bin/serverless` will be removed with v2.0.0 | |||
|
|||
<a name="CLI_DEPLOY_FUNCTION_OPTION"><div> </div></a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put it at the top of the file, right below instructions on how to disable specific deprecations
docs/deprecations.md
Outdated
|
||
Deprecation code: `CLI_DEPLOY_FUNCTION_OPTION'` | ||
|
||
The `--function` or `-f` option in `deploy` command has been deprecated and will be removed in the next major release (3.0.0). Please use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To follow the convention of other messages in deprecations, let's maybe go with
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.
lib/plugins/deploy.js
Outdated
@@ -39,6 +39,11 @@ class Deploy { | |||
throw new ServerlessError(errorMessage); | |||
} | |||
if (this.options.function) { | |||
this.serverless.logDeprecation( | |||
'CLI_DEPLOY_FUNCTION_OPTION', | |||
'The `--function` or `-f` option for `deploy` command has been' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the same message as suggested in the deprecation document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @jkklapp - I've reviewed the implementation proposal in the original ticket again and I have two questions as the implementation differs a bit from the suggested approach - I would appreciate clarification on these 🙇
lib/plugins/deploy.js
Outdated
@@ -36,6 +36,10 @@ class Deploy { | |||
throw new ServerlessError(errorMessage, 'INVALID_PROVIDER'); | |||
} | |||
if (this.options.function) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've consulted the implementation proposal in the ticket and I believe the suggestion was to implement it as a part of newly introduced initialize
hook. Was there a reason to not follow the proposal here? The general approach is to emit deprecations as a part of initialize
hooks
@@ -26,7 +26,7 @@ commands.set('deploy', { | |||
type: 'boolean', | |||
}, | |||
'function': { | |||
usage: "Function name. Deploys a single function (see 'deploy function')", | |||
usage: "Function name. Deploys a single function. DEPRECATED: use 'deploy function' instead.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to proposal, it was suggested to remove this option from the schema - what was the reason against doing so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs to stay in schema, otherwise it will not be properly recognized and the expected deprecation won't be reported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's probably right to keep it (same way as keep schema for deprecated config properties)
abba10f
to
58d7d51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks great
@@ -26,7 +26,7 @@ commands.set('deploy', { | |||
type: 'boolean', | |||
}, | |||
'function': { | |||
usage: "Function name. Deploys a single function (see 'deploy function')", | |||
usage: "Function name. Deploys a single function. DEPRECATED: use 'deploy function' instead.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's probably right to keep it (same way as keep schema for deprecated config properties)
function
option in deploy
command
closes #9312