serverless / components

The Serverless Framework's new infrastructure provisioning technology — Build, compose, & deploy serverless apps in seconds...
https://www.serverless.com
Apache License 2.0
2.31k stars 181 forks source link

Dependency analysing doesn't support square brackets in output reference expression #1036

Closed suerta-git closed 2 years ago

suerta-git commented 2 years ago

Expectation:

I have a project contains 2 components. Its structure looks like:

├── api-gateway
│   └── serverless.yml
└── functions
    ├── ...
    └── serverless.yml

And I have a reference expression in api-gateway which refers to functions component:

${output:${stage}:${app}:functions.fucntions[0].name}

Then I expect that when I run sls deploy command on root, its deploying order is:

  1. functions
  2. api-gateway

Because api-gateway depends on functions

Current behavior:

The order is:

  1. api-gateway
  2. functions

Cause:

https://github.com/serverless/components/blob/24d9123acf5e1680f7706b0891b4283a54c135b7/src/cli/utils.js#L630

The square brackets won't pass this regex, but they are necessary for me because I need to use them to select array elements.

Fix:

const regex = /\${output:(\w*[-_${}:\w.\[\]]+)}/g;