@platformatic/service 1.13.4 → 1.13.6

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.
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const { BaseGenerator } = require('@platformatic/generators')
3
+ const { BaseGenerator, addPrefixToEnv } = require('@platformatic/generators')
4
4
  const { getPackageConfigurationObject } = require('@platformatic/generators/lib/utils')
5
5
  const { readFile } = require('node:fs/promises')
6
6
  const { join } = require('node:path')
@@ -28,31 +28,31 @@ class ServiceGenerator extends BaseGenerator {
28
28
 
29
29
  getConfigFieldsDefinitions () {
30
30
  if (this.config.isRuntimeContext) {
31
- return [
32
- {
33
- var: 'PLT_SERVER_HOSTNAME',
34
- label: 'What is the hostname?',
35
- default: '0.0.0.0',
36
- type: 'string',
37
- configValue: 'hostname'
38
- },
39
- {
40
- var: 'PLT_SERVER_LOGGER_LEVEL',
41
- label: 'What is the logger level?',
42
- default: 'info',
43
- type: 'string',
44
- configValue: ''
45
- },
46
- {
47
- label: 'Which port do you want to use?',
48
- var: 'PORT',
49
- default: 3042,
50
- tyoe: 'number',
51
- configValue: 'port'
52
- }
53
- ]
31
+ return []
54
32
  }
55
- return []
33
+ return [
34
+ {
35
+ var: 'PLT_SERVER_HOSTNAME',
36
+ label: 'What is the hostname?',
37
+ default: '0.0.0.0',
38
+ type: 'string',
39
+ configValue: 'hostname'
40
+ },
41
+ {
42
+ var: 'PLT_SERVER_LOGGER_LEVEL',
43
+ label: 'What is the logger level?',
44
+ default: 'info',
45
+ type: 'string',
46
+ configValue: ''
47
+ },
48
+ {
49
+ label: 'Which port do you want to use?',
50
+ var: 'PORT',
51
+ default: 3042,
52
+ tyoe: 'number',
53
+ configValue: 'port'
54
+ }
55
+ ]
56
56
  }
57
57
 
58
58
  async _afterPrepare () {
@@ -68,8 +68,10 @@ declare module 'fastify' {
68
68
  `
69
69
  this.addFile({ path: '', file: 'global.d.ts', contents: GLOBAL_TYPES_TEMPLATE })
70
70
  if (this.config.isRuntimeContext) {
71
- // remove env variables since they are all for the config.server property
72
- this.config.env = {}
71
+ // remove env variables that are not for the plugins
72
+ delete this.config.env.PLT_SERVER_HOSTNAME
73
+ delete this.config.env.PORT
74
+ delete this.config.env.PLT_SERVER_LOGGER_LEVEL
73
75
  }
74
76
 
75
77
  this.addFile({ path: '', file: 'README.md', contents: await readFile(join(__dirname, 'README.md')) })
@@ -113,9 +115,22 @@ declare module 'fastify' {
113
115
  config.plugins = {}
114
116
  }
115
117
  config.plugins.packages = this.packages.map((packageDefinition) => {
118
+ const packageConfigOutput = getPackageConfigurationObject(packageDefinition.options, this.config.serviceName)
119
+ if (Object.keys(packageConfigOutput.env).length > 0) {
120
+ const envForPackages = {}
121
+ Object.entries(packageConfigOutput.env).forEach((kv) => {
122
+ envForPackages[kv[0]] = kv[1]
123
+ })
124
+ if (this.config.isRuntimeContext) {
125
+ this.config.env = {
126
+ ...this.config.env,
127
+ ...addPrefixToEnv(envForPackages, this.config.envPrefix)
128
+ }
129
+ }
130
+ }
116
131
  return {
117
132
  name: packageDefinition.name,
118
- options: getPackageConfigurationObject(packageDefinition.options)
133
+ options: packageConfigOutput.config
119
134
  }
120
135
  })
121
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/service",
3
- "version": "1.13.4",
3
+ "version": "1.13.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -69,12 +69,12 @@
69
69
  "pino-pretty": "^10.2.0",
70
70
  "rfdc": "^1.3.0",
71
71
  "ua-parser-js": "^1.0.36",
72
- "@platformatic/client": "1.13.4",
73
- "@platformatic/generators": "1.13.4",
74
- "@platformatic/swagger-ui-theme": "1.13.4",
75
- "@platformatic/config": "1.13.4",
76
- "@platformatic/telemetry": "1.13.4",
77
- "@platformatic/utils": "1.13.4"
72
+ "@platformatic/client": "1.13.6",
73
+ "@platformatic/config": "1.13.6",
74
+ "@platformatic/swagger-ui-theme": "1.13.6",
75
+ "@platformatic/utils": "1.13.6",
76
+ "@platformatic/generators": "1.13.6",
77
+ "@platformatic/telemetry": "1.13.6"
78
78
  },
79
79
  "standard": {
80
80
  "ignore": [