serverless-plugin-env-stage-config 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +3 -1
  2. package/index.js +12 -15
  3. package/package.json +10 -18
package/README.md CHANGED
@@ -72,7 +72,9 @@ SECRET_TOKEN: ${ssm:/my-service/prod/SECRET_TOKEN~true}
72
72
  Any variable that is not included in the `serverless.env.prod.yml` file will produce a warning and fallback to using `env:`.
73
73
  In this case, you will get the following warning:
74
74
 
75
- > Serverless: env-stage-config: WARNING: the MYSQL_PORT variable is not defined in serverless.env.prod.yml, defaulting to ${env:MYSQL_PORT}.
75
+ > Serverless: env-stage-config: WARNING: the MYSQL_PORT variable is not defined in serverless.env.prod.yml, defaulting to ${env:MYSQL_PORT, null}.
76
+
77
+ If a variable is not defined in the stage environment configuration file, or the environment (`process.env`), it will default to `null`.
76
78
 
77
79
  ## License
78
80
 
package/index.js CHANGED
@@ -6,7 +6,7 @@ const cloudformationSchema = require('@serverless/utils/cloudformation-schema')
6
6
  const developmentStages = new Set([
7
7
  'local',
8
8
  'development',
9
- 'dev'
9
+ 'dev',
10
10
  ])
11
11
 
12
12
  class EnvStageConfigServerlessPlugin {
@@ -17,19 +17,16 @@ class EnvStageConfigServerlessPlugin {
17
17
 
18
18
  this.configurationVariablesSources = {
19
19
  esc: {
20
- resolve: this.resolveConfigVariable.bind(this)
21
- }
20
+ resolve: this.resolveConfigVariable.bind(this),
21
+ },
22
22
  }
23
23
 
24
24
  if (!developmentStages.has(this.stage)) {
25
- this.stageVariables = yaml.load(
26
- readFileSync(
27
- path.join(this.serverless.serviceDir, `serverless.env.${this.stage}.yml`)
28
- ),
29
- {
30
- schema: cloudformationSchema
31
- }
32
- )
25
+ const stageConfigYaml = readFileSync(path.join(this.serverless.serviceDir, `serverless.env.${this.stage}.yml`))
26
+
27
+ this.stageVariables = yaml.load(stageConfigYaml, {
28
+ schema: cloudformationSchema,
29
+ })
33
30
  }
34
31
  }
35
32
 
@@ -37,19 +34,19 @@ class EnvStageConfigServerlessPlugin {
37
34
  if (this.stageVariables) {
38
35
  if (address in this.stageVariables) {
39
36
  return {
40
- value: this.stageVariables[address]
37
+ value: this.stageVariables[address],
41
38
  }
42
39
  }
43
40
 
44
41
  this.serverless.cli.log(
45
- `env-stage-config: WARNING: the ${address} variable is not defined in serverless.env.${this.stage}.yml, defaulting to \${env:${address}}.`,
42
+ `env-stage-config: WARNING: the ${address} variable is not defined in serverless.env.${this.stage}.yml, defaulting to \${env:${address}, null}.`,
46
43
  null,
47
- {color: 'orange'}
44
+ {color: 'orange'},
48
45
  )
49
46
  }
50
47
 
51
48
  return {
52
- value: `\${env:${address}}`
49
+ value: `\${env:${address}, null}`,
53
50
  }
54
51
  }
55
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serverless-plugin-env-stage-config",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "author": "Bertrand Marron <bertrand.marron@gmail.com>",
5
5
  "description": "Serverless plugin to define environment variables files for stages",
6
6
  "main": "index.js",
@@ -20,30 +20,22 @@
20
20
  "serverless-plugin"
21
21
  ],
22
22
  "dependencies": {
23
- "@serverless/utils": "^5.6.0",
23
+ "@serverless/utils": "^6.0.0",
24
24
  "js-yaml": "^4.1.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@semantic-release/git": "^9.0.0",
28
- "semantic-release": "^17.4.4",
29
- "xo": "^0.39.1"
27
+ "@bizon/semantic-release-config": "^1.0.1",
28
+ "semantic-release": "^19.0.2",
29
+ "xo": "^0.47.0"
30
30
  },
31
31
  "xo": {
32
32
  "semicolon": false,
33
- "space": 2
33
+ "space": 2,
34
+ "rules": {
35
+ "unicorn/prefer-module": "off"
36
+ }
34
37
  },
35
38
  "release": {
36
- "plugins": [
37
- "@semantic-release/commit-analyzer",
38
- "@semantic-release/release-notes-generator",
39
- "@semantic-release/github",
40
- "@semantic-release/npm",
41
- [
42
- "@semantic-release/git",
43
- {
44
- "message": "chore(release): ${nextRelease.gitTag}"
45
- }
46
- ]
47
- ]
39
+ "extends": "@bizon/semantic-release-config"
48
40
  }
49
41
  }