diff --git a/docs/deprecations.md b/docs/deprecations.md index 39cebc6fd7e..c9683114b3c 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 service local `serverless` installation diff --git a/lib/Serverless.js b/lib/Serverless.js index ae58d896ff0..c27ba0b8ce5 100644 --- a/lib/Serverless.js +++ b/lib/Serverless.js @@ -117,24 +117,28 @@ 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' + ); + } return resolve(process.cwd(), 'serverless').then( ({ realPath }) => { if (realPath === __filename) { 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 a1271f5ce83..445048d230f 100644 --- a/lib/Serverless.test.js +++ b/lib/Serverless.test.js @@ -307,28 +307,37 @@ describe('Serverless [new tests]', () => { after(() => fse.remove(path.resolve(fixtures.map.aws, 'node_modules'))); 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({ cwd: fixtures.map.aws, cliArgs: ['-v'] }).then(({ serverless }) => { - expect(Array.from(serverless.triggeredDeprecations)).to.deep.equal([ - 'LOCAL_INSTALLATION_FALLBACK', - ]); - expect(serverless.invokedInstance).to.not.exist; + expect(Array.from(serverless.triggeredDeprecations)).to.deep.equal([]); + expect(serverless.invokedInstance.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', () => fixtures.extend('aws', { enableLocalInstallationFallback: false }).then(fixturePath => runServerless({ cwd: fixturePath, cliArgs: ['-v'] }).then(({ serverless }) => { - expect(Array.from(serverless.triggeredDeprecations)).to.deep.equal([]); - expect(serverless.invokedInstance).to.not.exist; + serverlessWithDisabledLocalInstallationFallback = serverless; + expect(Array.from(serverless.triggeredDeprecations)).to.deep.equal([ + 'DISABLE_LOCAL_INSTALLATION_FALLBACK_SETTING', + ]); }) )); + + 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', () => fixtures.extend('aws', { enableLocalInstallationFallback: true }).then(fixturePath => runServerless({ cwd: fixturePath, 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.invokedInstance.isLocalStub).to.be.true; }) )); }); + describe('When running local version', () => { it('Should run without notice', () => runServerless({