Skip to content

Commit a93b42d

Browse files
Merge branch 'main' into 4.x
2 parents b30610c + 115b6f1 commit a93b42d

4 files changed

Lines changed: 36 additions & 3 deletions

File tree

docs/guides/deprecations.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,24 @@ Note:
3030
- The `serverless.yml` setting is ineffective for deprecations reported before the configuration is read.
3131
- `SLS_DEPRECATION_DISABLE` and `disabledDeprecations` remain respected, and no errors will be thrown for mentioned deprecation codes.
3232

33+
<a name="STANDALONE_UNINSTALL_COMMAND_DEPRECATED"><div>&nbsp;</div></a>
34+
35+
## Command `sls uninstall`
36+
37+
Deprecation code: `STANDALONE_UNINSTALL_COMMAND_DEPRECATED`
38+
39+
Removal target: osls v4.0.0
40+
41+
The top-level standalone `sls uninstall` command is deprecated and scheduled for removal in osls v4.0.0. It only removes the legacy standalone binary directory and does not uninstall npm-installed osls.
42+
43+
Use your package manager to uninstall npm-installed osls instead:
44+
45+
```sh
46+
npm uninstall -g osls
47+
```
48+
49+
This does not affect `serverless plugin uninstall`.
50+
3351
<a name="VARIABLES_RESOLUTION_MODE"><div>&nbsp;</div></a>
3452

3553
## Property `variablesResolutionMode`

lib/cli/commands-schema/no-service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ commands.set('plugin search', {
143143
'in non Windows environment.';
144144

145145
commands.set('uninstall', {
146-
usage: 'Uninstall osls',
146+
usage: 'Deprecated: uninstall standalone osls binary',
147147
isHidden,
148148
noSupportNotice,
149149
lifecycleEvents: ['uninstall'],

lib/plugins/standalone.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ const { log, progress, style } = require('../utils/serverless-utils/log');
55
const standaloneUtils = require('../utils/standalone');
66
const { remove } = require('../utils/fs/remove');
77
const cliCommandsSchema = require('../cli/commands-schema');
8+
const logDeprecation = require('../utils/log-deprecation');
89

910
const BINARY_PATH = standaloneUtils.path;
1011
const mainProgress = progress.get('main');
12+
const uninstallCommandDeprecationMessage = [
13+
'The top-level standalone `sls uninstall` command is deprecated and scheduled for removal in osls v4.0.0.',
14+
'It only removes the legacy standalone binary directory and does not uninstall npm-installed osls.',
15+
'Use your package manager to uninstall npm-installed osls. This does not affect `serverless plugin uninstall`.',
16+
].join('\n');
1117

1218
module.exports = class Standalone {
1319
constructor(serverless, cliOptions) {
@@ -26,6 +32,7 @@ module.exports = class Standalone {
2632
}
2733

2834
async uninstall() {
35+
logDeprecation('STANDALONE_UNINSTALL_COMMAND_DEPRECATED', uninstallCommandDeprecationMessage);
2936
mainProgress.notice('Uninstalling standalone binary', { isMainEvent: true });
3037
await remove(path.dirname(BINARY_PATH));
3138
log.notice();

test/unit/lib/plugins/standalone.test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ const fsp = fs.promises;
55
const os = require('os');
66
const path = require('path');
77
const proxyquire = require('proxyquire');
8+
const sinon = require('sinon');
89
const { expect } = require('chai');
910

1011
const { remove } = require('../../../../lib/utils/fs/remove');
1112

12-
const loadStandalone = ({ binaryPath, removeStub } = {}) =>
13+
const loadStandalone = ({ binaryPath, logDeprecationStub, removeStub } = {}) =>
1314
proxyquire('../../../../lib/plugins/standalone', {
1415
'../utils/standalone': {
1516
path: binaryPath,
1617
},
18+
'../utils/log-deprecation': logDeprecationStub || sinon.stub(),
1719
'../utils/fs/remove': { remove: removeStub || remove },
1820
});
1921

@@ -30,14 +32,20 @@ describe('test/unit/lib/plugins/standalone.test.js', () => {
3032

3133
it('recursively removes the standalone install directory on uninstall', async () => {
3234
const binaryPath = path.join(tmpDir, 'install', 'bin', 'serverless');
35+
const logDeprecationStub = sinon.stub();
3336
await fsp.mkdir(path.dirname(binaryPath), { recursive: true });
3437
await fsp.writeFile(binaryPath, 'binary');
3538
await fsp.writeFile(path.join(tmpDir, 'install', 'config.json'), '{}');
36-
const Standalone = loadStandalone({ binaryPath });
39+
const Standalone = loadStandalone({ binaryPath, logDeprecationStub });
3740
const standalone = new Standalone({ pluginManager: { commandRunStartTime: Date.now() } }, {});
3841

3942
await standalone.uninstall();
4043

44+
expect(logDeprecationStub).to.have.been.calledOnce;
45+
expect(logDeprecationStub.firstCall.args[0]).to.equal(
46+
'STANDALONE_UNINSTALL_COMMAND_DEPRECATED'
47+
);
48+
expect(logDeprecationStub.firstCall.args[1]).to.include('npm-installed osls');
4149
expect(fs.existsSync(path.dirname(binaryPath))).to.equal(false);
4250
});
4351
});

0 commit comments

Comments
 (0)