serverless / compose

Orchestrate Serverless Framework in monorepos
https://serverless.com/framework/docs/guides/compose
MIT License
110 stars 15 forks source link

NPM packages of serverless plugins are installed in the compose root-folder instead of the services folders #191

Closed jimmyorpheus closed 6 months ago

jimmyorpheus commented 6 months ago

Are you certain it's a bug?

Are you using the latest version?

Is there an existing issue for this?

Issue description

When executing the following command

sls plugin install --name=serverless-somePlugin --service=someService

from the serverless-compose root-folder (the folder with the serverless-compose.yml file), the plugin is correctly added to the configuration at ./someService/serverless.yml):

plugins:
  - serverless-somePlugin

But the npm package of the plugin is installed directly at the compose level

./package.json
./package-lock.json
./node_modules/serverless-somePlugin

instead of being installed to the subfolder of the specific service which the plugin is meant for.


./someService/package.json
./someService/package-lock.json
./someService/node_modules/serverless-somePlugin

Service configuration (serverless-compose.yml) content

# BEFORE COMMAND EXECUTION
service: someService
frameworkVersion: '3'

provider:
  name: aws
  runtime: nodejs18.x
  region: eu-central-1
  stage: dev
  profile: someProfile

functions:
  someFunction:
    handler: index.handler

# AFTER COMMAND EXECUTION
service: someService
frameworkVersion: '3'

provider:
  name: aws
  runtime: nodejs18.x
  region: eu-central-1
  stage: dev
  profile: someProfile

functions:
  someFunction:
    handler: index.handler

plugins:
  - serverless-somePlugin

Command name and used flags

sls plugin install --name=serverless-somePlugin --service=someService

Command output

Installing plugin "serverless-somePlugin"

✔ Plugin "serverless-somePlugin" installed  (14s)
jimmyorpheus commented 6 months ago

Sorry, my mistake. There was no package.json in my service folder, therefore the plugin's npm-package was installed to the compose root-folder, which already had a package.json containing the @serverless/compose dev dependency. I just had to initialize an npm package in the service folder and then the sls plugin install --name=serverless-somePlugin --service=someService command would work as expected.