Skip to content

Commit

Permalink
feat(CLI): Deprecate missing options schema
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Jan 27, 2022
1 parent 6bfdc0c commit 0db9c49
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
14 changes: 14 additions & 0 deletions docs/deprecations.md
Expand Up @@ -38,6 +38,20 @@ Note:
- The `serverless.yml` setting is ineffective for deprecations reported before the configuration is read.
- `SLS_DEPRECATION_DISABLE` and `disabledDeprecations` remain respected, and no errors will be thrown for mentioned deprecation codes.

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

## CLI Options extensions, `type` requirement

Deprecation code: `CLI_OPTIONS_SCHEMA_V3`

Internal handling of CLI arguments was improved with type awareness for options. Now each option definition is expected have `type` defined in its settings.

Possible values are `string`, `boolean` and `multiple`. Check [Defining options](/framework/docs/providers/aws/guide/plugins#defining-options) documentation for more info.

If you rely on a plugin which does not set types (yet) please report the issue at its issue tracker.

Starting with v4.0.0 any option extensions which does not have `type` defined will be communicated with a thrown error

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

## Grouping IAM settings under `provider.iam`
Expand Down
24 changes: 8 additions & 16 deletions lib/cli/commands-schema/resolve-final.js
Expand Up @@ -8,10 +8,9 @@ const serviceCommands = require('./service');
const awsServiceCommands = require('./aws-service');
const serviceOptions = require('./common-options/service');
const awsServiceOptions = require('./common-options/aws-service');
const { logWarning } = require('../../classes/Error');
const { log } = require('@serverless/utils/log');
const logDeprecation = require('../../utils/logDeprecation');

module.exports = (loadedPlugins, { providerName }) => {
module.exports = (loadedPlugins, { providerName, configuration }) => {
const commands = new Map(providerName === 'aws' ? awsServiceCommands : serviceCommands);

if (providerName !== 'aws') {
Expand Down Expand Up @@ -108,25 +107,18 @@ module.exports = (loadedPlugins, { providerName }) => {
for (const loadedPlugin of loadedPlugins) resolveCommands(loadedPlugin, loadedPlugin);

if (missingOptionTypes.size) {
logWarning(
logDeprecation(
'CLI_OPTIONS_SCHEMA_V3',
'CLI options definitions were upgraded with "type" property (which could be one of "string", "boolean", "multiple"). ' +
'Below listed plugins do not predefine type for introduced options:\n' +
` - ${Array.from(
missingOptionTypes,
([plugin, optionNames]) =>
`${plugin.constructor.name} for "${Array.from(optionNames).join('", "')}"`
).join('\n - ')}\n\n` +
'Please report this issue in plugin issue tracker.'
);
log.warning(
'CLI options definitions were upgraded with "type" property (which could be one of "string", "boolean", "multiple"). ' +
'Plugins listed below do not predefine type for introduced options:\n' +
` - ${Array.from(
missingOptionTypes,
([plugin, optionNames]) =>
`${plugin.constructor.name} for "${Array.from(optionNames).join('", "')}"`
).join('\n - ')}\n\n` +
'Please report this issue in issue tracker of the corresponding plugin.\n'
).join('\n - ')}\n` +
'Please report this issue in plugin issue tracker.\n' +
'Starting with next major release, this will be communicated with a thrown error.',
{ serviceConfig: configuration }
);
}

Expand Down

0 comments on commit 0db9c49

Please sign in to comment.