diff --git a/docs/deprecations.md b/docs/deprecations.md
index 5cc2bd7da05..70e6ee71639 100644
--- a/docs/deprecations.md
+++ b/docs/deprecations.md
@@ -6,6 +6,12 @@ layout: Doc
# Serverless Framework Deprecations
+
+
+## Support for `enableLocalInstallationFallback` setting is to be removed
+
+Starting with v3.0.0, framework will unconditionally run service local installation of `serverless` if its found.
+
## Fallback to a service local `serverless` installation
diff --git a/lib/Serverless.js b/lib/Serverless.js
index 1fdf9f876af..195ee5fca14 100644
--- a/lib/Serverless.js
+++ b/lib/Serverless.js
@@ -97,6 +97,17 @@ class Serverless {
});
}
eventuallyFallbackToLocal() {
+ if (
+ this.pluginManager.serverlessConfigFile &&
+ this.pluginManager.serverlessConfigFile.enableLocalInstallationFallback != null
+ ) {
+ this._logDeprecation(
+ 'DISABLE_LOCAL_INSTALLATION_FALLBACK_SETTING',
+ 'Starting with next major version, "enableLocalInstallationFallback" setting will no longer be supported.' +
+ 'CLI will unconditionally fallback to service local installation when its found.\n' +
+ 'Remove this setting to clear this deprecation warning'
+ );
+ }
if (this.isLocallyInstalled) return null;
return resolve(process.cwd(), 'serverless').then(
({ realPath }) => {
@@ -104,18 +115,11 @@ class Serverless {
this.isLocallyInstalled = true;
return null;
}
- if (!this.pluginManager.serverlessConfigFile) return null;
- if (this.pluginManager.serverlessConfigFile.enableLocalInstallationFallback == null) {
- this._logDeprecation(
- 'LOCAL_INSTALLATION_FALLBACK',
- 'Local installation of Serverless detected. Starting with next major version, CLI ' +
- 'will run it instead of globally installed version.\n' +
- 'Set "enableLocalInstallationFallback" to "true" to switch to new behavior now, ' +
- 'set to "false" to keep current behavior and hide this message'
- );
- return null;
- }
- if (!this.pluginManager.serverlessConfigFile.enableLocalInstallationFallback) {
+ if (
+ this.pluginManager.serverlessConfigFile &&
+ this.pluginManager.serverlessConfigFile.enableLocalInstallationFallback != null &&
+ !this.pluginManager.serverlessConfigFile.enableLocalInstallationFallback
+ ) {
return null;
}
this.cli.log('Running "serverless" installed locally (in service node_modules)');
diff --git a/lib/Serverless.test.js b/lib/Serverless.test.js
index 1d2fab4faa0..7111c370fea 100644
--- a/lib/Serverless.test.js
+++ b/lib/Serverless.test.js
@@ -288,41 +288,50 @@ describe('Serverless', () => {
describe('Serverless [new tests]', () => {
describe('When local version available', () => {
describe('When running global version', () => {
- it('Should report deprecation notice when "enableLocalInstallationFallback" not set', () =>
+ it('Should fallback to local version when it is found and "enableLocalInstallationFallback" is not set', () =>
runServerless({ fixture: 'locallyInstalledServerless', cliArgs: ['-v'] }).then(
({ serverless }) => {
- expect(Array.from(serverless.triggeredDeprecations)).to.deep.equal([
- 'LOCAL_INSTALLATION_FALLBACK',
- ]);
- expect(serverless.isInvokedByGlobalInstallation).to.be.false;
- expect(serverless.isLocallyInstalled).to.be.false;
- expect(serverless.isLocalStub).to.not.exist;
+ expect(Array.from(serverless.triggeredDeprecations)).to.deep.equal([]);
+ expect(serverless.isInvokedByGlobalInstallation).to.be.true;
+ expect(serverless.isLocallyInstalled).to.be.true;
+ expect(serverless.isLocalStub).to.be.true;
}
));
- it('Should run without notice when "enableLocalInstallationFallback" set to false', () =>
+
+ let serverlessWithDisabledLocalInstallationFallback;
+ it('Should report deprecation notice when "enableLocalInstallationFallback" is set', () =>
runServerless({
fixture: 'locallyInstalledServerless',
configExt: { enableLocalInstallationFallback: false },
cliArgs: ['-v'],
}).then(({ serverless }) => {
- expect(Array.from(serverless.triggeredDeprecations)).to.deep.equal([]);
+ serverlessWithDisabledLocalInstallationFallback = serverless;
+ expect(Array.from(serverless.triggeredDeprecations)).to.deep.equal([
+ 'DISABLE_LOCAL_INSTALLATION_FALLBACK_SETTING',
+ ]);
expect(serverless.isInvokedByGlobalInstallation).to.be.false;
expect(serverless.isLocallyInstalled).to.be.false;
expect(serverless.isLocalStub).to.not.exist;
}));
+ it('Should not fallback to local when "enableLocalInstallationFallback" set to false', () =>
+ expect(serverlessWithDisabledLocalInstallationFallback.invokedInstance).to.not.exist);
+
it('Should fallback to local version when "enableLocalInstallationFallback" set to true', () =>
runServerless({
fixture: 'locallyInstalledServerless',
configExt: { enableLocalInstallationFallback: true },
cliArgs: ['-v'],
}).then(({ serverless }) => {
- expect(Array.from(serverless.triggeredDeprecations)).to.deep.equal([]);
+ expect(Array.from(serverless.triggeredDeprecations)).to.deep.equal([
+ 'DISABLE_LOCAL_INSTALLATION_FALLBACK_SETTING',
+ ]);
expect(serverless.isInvokedByGlobalInstallation).to.be.true;
expect(serverless.isLocallyInstalled).to.be.true;
expect(serverless.isLocalStub).to.be.true;
}));
});
+
describe('When running local version', () => {
it('Should run without notice', () =>
fixtures.setup('locallyInstalledServerless').then(({ servicePath }) =>
diff --git a/lib/utils/analytics/generatePayload.test.js b/lib/utils/analytics/generatePayload.test.js
index 0db33222484..f3d3c17d1da 100644
--- a/lib/utils/analytics/generatePayload.test.js
+++ b/lib/utils/analytics/generatePayload.test.js
@@ -97,7 +97,6 @@ describe('lib/utils/analytics/generatePayload', () => {
it('Should recognize local fallback', () =>
runServerless({
fixture: 'locallyInstalledServerless',
- configExt: { enableLocalInstallationFallback: true },
cliArgs: ['config'],
}).then(({ serverless }) => {
const payload = generatePayload(serverless);