Skip to content

Commit

Permalink
refactor: Remove evaluation of deprecated lifecycle events
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
Lifecycle events marked as deprecated (in context of v1) are no longer evaluated
  • Loading branch information
medikoo committed Jan 27, 2022
1 parent 8229812 commit 34bb51e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 27 deletions.
12 changes: 1 addition & 11 deletions lib/classes/PluginManager.js
Expand Up @@ -352,17 +352,7 @@ class PluginManager {
if (pluginInstance.commands) {
Object.entries(pluginInstance.commands).forEach(([key, details]) => {
const command = this.loadCommand(pluginName, details, key);
// Grab and extract deprecated events
command.lifecycleEvents = (command.lifecycleEvents || []).map((event) => {
if (event.startsWith('deprecated#')) {
// Extract event and optional redirect
const transformedEvent = /^deprecated#(.*?)(?:->(.*?))?$/.exec(event);
this.deprecatedEvents[`${command.key}:${transformedEvent[1]}`] =
transformedEvent[2] || null;
return transformedEvent[1];
}
return event;
});
if (!command.lifecycleEvents) command.lifecycleEvents = [];
this.commands[key] = mergeCommands(
this.commands[key],
_.merge({}, command, {
Expand Down
12 changes: 1 addition & 11 deletions lib/cli/commands-schema/aws-service.js
Expand Up @@ -35,17 +35,7 @@ commands.set('deploy', {
type: 'boolean',
},
},
// TODO: Remove deprecated events with v3
lifecycleEvents: [
'deprecated#cleanup->package:cleanup',
'deprecated#initialize->package:initialize',
'deprecated#setupProviderConfiguration->package:setupProviderConfiguration',
'deprecated#createDeploymentArtifacts->package:createDeploymentArtifacts',
'deprecated#compileFunctions->package:compileFunctions',
'deprecated#compileEvents->package:compileEvents',
'deploy',
'finalize',
],
lifecycleEvents: ['deploy', 'finalize'],
});

commands.set('deploy function', {
Expand Down
5 changes: 0 additions & 5 deletions lib/cli/commands-schema/resolve-final.js
Expand Up @@ -11,8 +11,6 @@ const awsServiceOptions = require('./common-options/aws-service');
const { logWarning } = require('../../classes/Error');
const { log } = require('@serverless/utils/log');

const deprecatedEventPattern = /^deprecated#(.*?)(?:->(.*?))?$/;

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

Expand All @@ -28,9 +26,6 @@ module.exports = (loadedPlugins, { providerName }) => {
.map(([name, schema]) => {
const lifecycleEventNamePrefix = name.split(' ').join(':');
return (schema.lifecycleEvents || []).map((lifecycleEventBaseName) => {
if (lifecycleEventBaseName.startsWith('deprecated#')) {
lifecycleEventBaseName = lifecycleEventBaseName.match(deprecatedEventPattern)[1];
}
const lifecycleEventName = `${lifecycleEventNamePrefix}:${lifecycleEventBaseName}`;
return [
[`before:${lifecycleEventName}`, name],
Expand Down

0 comments on commit 34bb51e

Please sign in to comment.