Skip to content

Commit c832eba

Browse files
authored
Merge pull request #28 from oss-serverless/fix-compose
Fix support for Serverless Compose
2 parents 0665e63 + ae3b9a4 commit c832eba

File tree

24 files changed

+19
-48
lines changed

24 files changed

+19
-48
lines changed

bin/serverless.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ require('../lib/cli/triage')().then((cliName) => {
4141
case 'serverless':
4242
require('../scripts/serverless');
4343
return;
44-
case '@serverless/compose':
44+
case '@osls/compose':
4545
require('../lib/cli/run-compose')().catch((error) => {
4646
// Expose eventual resolution error as regular crash, and not unhandled rejection
4747
process.nextTick(() => {

docs/guides/compose.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ The `serverless-compose.yml` and `serverless.yml` files have different syntaxes
215215

216216
Unless documented here, expect `serverless.yml` features to not be supported in `serverless-compose.yml`. For example, it is not possible to include plugins or use most `serverless.yml` variables (like `${self:`, `${opt:`, etc.) inside `serverless-compose.yml`.
217217

218-
You can [open feature requests](https://github.com/serverless/compose) if you need features that aren't supported in `serverless-compose.yml`.
219-
220218
## Refreshing outputs
221219

222220
The outputs of a service are stored locally (in the `.serverless/` directory). If a colleague deployed changes that changed the outputs of a service, you can refresh your local state via the `refresh-outputs` command:

lib/cli/run-compose.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const fsp = require('fs').promises;
77
const spawn = require('child-process-ext/spawn');
88
const inquirer = require('@serverless/utils/inquirer');
99

10-
const relativeBinPath = '@serverless/compose/bin/serverless-compose';
10+
const relativeBinPath = '@osls/compose/bin/serverless-compose';
1111

1212
// Logic inspired by `@serverless/utils` which is not used as it currently
1313
// requires logger setup which is not needed when running Compose CLI
@@ -73,7 +73,7 @@ module.exports = async () => {
7373
)}\n`
7474
);
7575

76-
// In this situation, we want to ask user for installing the `@serverless/compose`
76+
// In this situation, we want to ask user for installing the `@osls/compose`
7777
// and adding it to `devDependencies` of `package.json`
7878

7979
let promptMessage = 'Do you want to install Serverless Compose locally with "npm"?';
@@ -116,13 +116,13 @@ module.exports = async () => {
116116
}
117117

118118
try {
119-
await spawn('npm', ['install', '--save-dev', '@serverless/compose']);
119+
await spawn('npm', ['install', '--save-dev', '@osls/compose']);
120120
} catch {
121121
process.stdout.write(
122122
`${[
123123
'',
124124
'Could not install Serverless Compose CLI locally.',
125-
'Please install it manually with "npm i --save-dev @serverless/compose" and run this command again.',
125+
'Please install it manually with "npm i --save-dev @osls/compose" and run this command again.',
126126
].join('\n')}\n`
127127
);
128128
return;
@@ -135,28 +135,28 @@ module.exports = async () => {
135135
process.stdout.write(
136136
`${[
137137
'',
138-
'Please install it manually with "npm i --save-dev @serverless/compose" and run this command again.',
138+
'Please install it manually with "npm i --save-dev @osls/compose" and run this command again.',
139139
].join('\n')}\n`
140140
);
141141
return;
142142
}
143143
} else {
144144
// Non-interactive scenario
145145

146-
// Here, we want to check if user has `@serverless/compose` in `devDependencies` of `package.json`
146+
// Here, we want to check if user has `@osls/compose` in `devDependencies` of `package.json`
147147
// If that is the case, we want to run `npm install` to ensure it's installed
148-
// In all other scenarios, we want to inform user that `@serverless/compose` needs to be installed first (and/or added to "package.json")
148+
// In all other scenarios, we want to inform user that `@osls/compose` needs to be installed first (and/or added to "package.json")
149149
process.stdout.write(`${['', 'Installing Serverless Compose CLI via NPM'].join('\n')}\n`);
150150

151151
const failedInstallationErrorMessage = `${[
152152
'',
153-
'Installation failed. Make sure the "@serverless/compose" package is required in "package.json" in the current directory so that Serverless Framework installs Compose automatically.',
154-
'Alternatively you can install the "@serverless/compose" package manually via NPM.',
153+
'Installation failed. Make sure the "@osls/compose" package is required in "package.json" in the current directory so that Serverless Framework installs Compose automatically.',
154+
'Alternatively you can install the "@osls/compose" package manually via NPM.',
155155
].join('\n')}\n`;
156156

157-
if (_.get(packageJsonContent, 'devDependencies.@serverless/compose')) {
157+
if (_.get(packageJsonContent, 'devDependencies.@osls/compose')) {
158158
try {
159-
await spawn('npm', ['install', '--no-save', '--no-package-lock', '@serverless/compose']);
159+
await spawn('npm', ['install', '--no-save', '--no-package-lock', '@osls/compose']);
160160
hasInstalledCompose = true;
161161
} catch {
162162
process.stdout.write(failedInstallationErrorMessage);

lib/cli/triage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = async () => {
5353
)
5454
).some(Boolean)
5555
) {
56-
return '@serverless/compose';
56+
return '@osls/compose';
5757
}
5858
}
5959

test/unit/lib/cli/triage/fixtures/@serverless/cli/js/component/serverless.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/unit/lib/cli/triage/fixtures/@serverless/cli/js/function/serverless.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/unit/lib/cli/triage/fixtures/@serverless/cli/json/component/serverless.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/unit/lib/cli/triage/fixtures/@serverless/cli/yml/component/serverless.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

test/unit/lib/cli/triage/fixtures/platform/js/template/foo/instance/serverless.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/unit/lib/cli/triage/fixtures/platform/js/template/foo/serverless.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/unit/lib/cli/triage/fixtures/platform/json/component/serverless.component.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/unit/lib/cli/triage/fixtures/platform/json/instance/serverless.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/unit/lib/cli/triage/fixtures/platform/json/template/foo/serverless.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/unit/lib/cli/triage/fixtures/platform/yml/component/serverless.component.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/unit/lib/cli/triage/fixtures/platform/yml/instance/serverless.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/unit/lib/cli/triage/fixtures/platform/yml/template-with-root-config/foo/serverless.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/unit/lib/cli/triage/fixtures/platform/yml/template-with-root-config/serverless.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/unit/lib/cli/triage/fixtures/platform/yml/template/foo/serverless.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/unit/lib/cli/triage/index.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('test/unit/lib/cli/triage/index.test.js', () => {
3737
});
3838
after(() => restoreArgv());
3939

40-
for (const cliName of ['serverless', '@serverless/compose']) {
40+
for (const cliName of ['serverless', '@osls/compose']) {
4141
for (const extension of fs.readdirSync(path.resolve(fixturesDirname, cliName))) {
4242
for (const fixtureName of fs.readdirSync(
4343
path.resolve(fixturesDirname, cliName, extension)
@@ -64,9 +64,9 @@ describe('test/unit/lib/cli/triage/index.test.js', () => {
6464
});
6565
after(() => restoreArgv());
6666

67-
it('should not resolve to `@serverless/compose` with compose config present when command should be ignored', async () => {
67+
it('should not resolve to `@osls/compose` with compose config present when command should be ignored', async () => {
6868
await overrideCwd(
69-
path.resolve(fixturesDirname, '@serverless/compose', 'yml', 'project'),
69+
path.resolve(fixturesDirname, '@osls/compose', 'yml', 'project'),
7070
async () => {
7171
expect(await triage()).to.equal('serverless');
7272
}
@@ -81,11 +81,11 @@ describe('test/unit/lib/cli/triage/index.test.js', () => {
8181
});
8282
after(() => restoreArgv());
8383

84-
it('should resolve to `@serverless/compose` with `--help` when compose config present', async () => {
84+
it('should resolve to `@osls/compose` with `--help` when compose config present', async () => {
8585
await overrideCwd(
86-
path.resolve(fixturesDirname, '@serverless/compose', 'yml', 'project'),
86+
path.resolve(fixturesDirname, '@osls/compose', 'yml', 'project'),
8787
async () => {
88-
expect(await triage()).to.equal('@serverless/compose');
88+
expect(await triage()).to.equal('@osls/compose');
8989
}
9090
);
9191
});

0 commit comments

Comments
 (0)