@platformatic/runtime 2.0.0-alpha.20 → 2.0.0-alpha.22
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.
- package/config.d.ts +1 -1
- package/fixtures/sample-runtime/package.json +1 -1
- package/fixtures/sample-runtime-with-2-services/package.json +1 -1
- package/lib/config.js +23 -6
- package/lib/generator/runtime-generator.js +8 -2
- package/lib/runtime.js +9 -1
- package/lib/start.js +2 -2
- package/lib/utils.js +5 -5
- package/package.json +13 -13
- package/schema.json +1 -1
package/config.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* and run json-schema-to-typescript to regenerate this file.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export type
|
|
8
|
+
export type HttpsSchemasPlatformaticDevPlatformaticRuntime200Alpha22Json = {
|
|
9
9
|
[k: string]: unknown;
|
|
10
10
|
} & {
|
|
11
11
|
$schema?: string;
|
package/lib/config.js
CHANGED
|
@@ -8,8 +8,9 @@ const ConfigManager = require('@platformatic/config')
|
|
|
8
8
|
const errors = require('./errors')
|
|
9
9
|
const { schema } = require('./schema')
|
|
10
10
|
const upgrade = require('./upgrade')
|
|
11
|
+
const { parseArgs } = require('node:util')
|
|
11
12
|
|
|
12
|
-
async function _transformConfig (configManager) {
|
|
13
|
+
async function _transformConfig (configManager, args) {
|
|
13
14
|
const config = configManager.current
|
|
14
15
|
|
|
15
16
|
let services
|
|
@@ -23,6 +24,19 @@ async function _transformConfig (configManager) {
|
|
|
23
24
|
services = config.services ?? []
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
const watchType = typeof config.watch
|
|
28
|
+
if (watchType === 'string') {
|
|
29
|
+
config.watch = config.watch === 'true'
|
|
30
|
+
} else if (watchType === 'undefined') {
|
|
31
|
+
const { values } = parseArgs({
|
|
32
|
+
args,
|
|
33
|
+
strict: false,
|
|
34
|
+
options: { production: { type: 'boolean', short: 'p', default: false } }
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
config.watch = !values.production
|
|
38
|
+
}
|
|
39
|
+
|
|
26
40
|
if (config.autoload) {
|
|
27
41
|
const { exclude = [], mappings = {} } = config.autoload
|
|
28
42
|
let { path } = config.autoload
|
|
@@ -76,11 +90,14 @@ async function _transformConfig (configManager) {
|
|
|
76
90
|
service.config = pathResolve(service.path, service.config)
|
|
77
91
|
}
|
|
78
92
|
service.entrypoint = service.id === config.entrypoint
|
|
79
|
-
service.watch = !!config.watch
|
|
80
93
|
service.dependencies = []
|
|
81
94
|
service.localServiceEnvVars = new Map()
|
|
82
95
|
service.localUrl = `http://${service.id}.plt.local`
|
|
83
96
|
|
|
97
|
+
if (typeof service.watch === 'undefined') {
|
|
98
|
+
service.watch = config.watch
|
|
99
|
+
}
|
|
100
|
+
|
|
84
101
|
if (service.entrypoint) {
|
|
85
102
|
hasValidEntrypoint = true
|
|
86
103
|
}
|
|
@@ -117,8 +134,8 @@ platformaticRuntime.configManagerConfig = {
|
|
|
117
134
|
allErrors: true,
|
|
118
135
|
strict: false
|
|
119
136
|
},
|
|
120
|
-
async transformConfig () {
|
|
121
|
-
await _transformConfig(this)
|
|
137
|
+
async transformConfig (args) {
|
|
138
|
+
await _transformConfig(this, args)
|
|
122
139
|
},
|
|
123
140
|
upgrade
|
|
124
141
|
}
|
|
@@ -157,8 +174,8 @@ async function wrapConfigInRuntimeConfig ({ configManager, args }) {
|
|
|
157
174
|
allErrors: true,
|
|
158
175
|
strict: false
|
|
159
176
|
},
|
|
160
|
-
transformConfig () {
|
|
161
|
-
return _transformConfig(this)
|
|
177
|
+
transformConfig (args) {
|
|
178
|
+
return _transformConfig(this, args)
|
|
162
179
|
}
|
|
163
180
|
})
|
|
164
181
|
|
|
@@ -162,7 +162,7 @@ class RuntimeGenerator extends BaseGenerator {
|
|
|
162
162
|
entrypoint: this.entryPoint.name,
|
|
163
163
|
watch: true,
|
|
164
164
|
autoload: {
|
|
165
|
-
path: 'services',
|
|
165
|
+
path: this.config.autoload || 'services',
|
|
166
166
|
exclude: ['docs'],
|
|
167
167
|
},
|
|
168
168
|
logger: {
|
|
@@ -254,7 +254,13 @@ class RuntimeGenerator extends BaseGenerator {
|
|
|
254
254
|
// set default config
|
|
255
255
|
service.setConfig()
|
|
256
256
|
}
|
|
257
|
-
|
|
257
|
+
let basePath
|
|
258
|
+
if (this.existingConfig) {
|
|
259
|
+
basePath = this.existingConfig.autoload.path
|
|
260
|
+
} else {
|
|
261
|
+
basePath = join(this.targetDirectory, this.config.autoload || 'services')
|
|
262
|
+
}
|
|
263
|
+
service.setTargetDirectory(join(basePath, service.config.serviceName))
|
|
258
264
|
})
|
|
259
265
|
}
|
|
260
266
|
|
package/lib/runtime.js
CHANGED
|
@@ -147,7 +147,7 @@ class Runtime extends EventEmitter {
|
|
|
147
147
|
this.startCollectingMetrics()
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
this
|
|
150
|
+
this.#showUrl()
|
|
151
151
|
return this.#url
|
|
152
152
|
}
|
|
153
153
|
|
|
@@ -729,6 +729,10 @@ class Runtime extends EventEmitter {
|
|
|
729
729
|
this.emit(status)
|
|
730
730
|
}
|
|
731
731
|
|
|
732
|
+
#showUrl () {
|
|
733
|
+
this.logger.info(`Platformatic is now listening at ${this.#url}`)
|
|
734
|
+
}
|
|
735
|
+
|
|
732
736
|
async #setupService (serviceConfig) {
|
|
733
737
|
if (this.#status === 'stopping' || this.#status === 'closed') return
|
|
734
738
|
|
|
@@ -829,6 +833,10 @@ class Runtime extends EventEmitter {
|
|
|
829
833
|
}
|
|
830
834
|
|
|
831
835
|
this.logger?.info(`Service ${id} has been successfully reloaded ...`)
|
|
836
|
+
|
|
837
|
+
if (serviceConfig.entrypoint) {
|
|
838
|
+
this.#showUrl()
|
|
839
|
+
}
|
|
832
840
|
} catch (e) {
|
|
833
841
|
this.logger?.error(e)
|
|
834
842
|
}
|
package/lib/start.js
CHANGED
|
@@ -114,7 +114,7 @@ async function setupAndStartRuntime (config) {
|
|
|
114
114
|
return { address, runtime }
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
async function startCommand (args, throwAllErrors = false) {
|
|
117
|
+
async function startCommand (args, throwAllErrors = false, returnRuntime = false) {
|
|
118
118
|
try {
|
|
119
119
|
const config = await loadConfig(
|
|
120
120
|
{
|
|
@@ -138,7 +138,7 @@ async function startCommand (args, throwAllErrors = false) {
|
|
|
138
138
|
await runtime.close()
|
|
139
139
|
})
|
|
140
140
|
|
|
141
|
-
return res
|
|
141
|
+
return returnRuntime ? runtime : res
|
|
142
142
|
} catch (err) {
|
|
143
143
|
if (throwAllErrors) {
|
|
144
144
|
throw err
|
package/lib/utils.js
CHANGED
|
@@ -7,7 +7,7 @@ const { join } = require('node:path')
|
|
|
7
7
|
const {
|
|
8
8
|
Store,
|
|
9
9
|
loadConfig: pltConfigLoadConfig,
|
|
10
|
-
loadEmptyConfig: pltConfigLoadEmptyConfig
|
|
10
|
+
loadEmptyConfig: pltConfigLoadEmptyConfig
|
|
11
11
|
} = require('@platformatic/config')
|
|
12
12
|
|
|
13
13
|
const { platformaticRuntime } = require('./config')
|
|
@@ -41,16 +41,16 @@ async function loadConfig (minimistConfig, args, overrides, replaceEnv = true) {
|
|
|
41
41
|
const id = platformaticRuntime.schema.$id.replace('@platformatic/runtime', 'wattpm')
|
|
42
42
|
const schema = {
|
|
43
43
|
...platformaticRuntime.schema,
|
|
44
|
-
$id: id
|
|
44
|
+
$id: id
|
|
45
45
|
}
|
|
46
46
|
const configManagerConfig = {
|
|
47
47
|
...platformaticRuntime.configManagerConfig,
|
|
48
|
-
schema
|
|
48
|
+
schema
|
|
49
49
|
}
|
|
50
50
|
const wattpm = {
|
|
51
51
|
...platformaticRuntime,
|
|
52
52
|
schema,
|
|
53
|
-
configManagerConfig
|
|
53
|
+
configManagerConfig
|
|
54
54
|
}
|
|
55
55
|
store.add(wattpm)
|
|
56
56
|
store.add(platformaticBasic)
|
|
@@ -70,5 +70,5 @@ module.exports = {
|
|
|
70
70
|
getRuntimeTmpDir,
|
|
71
71
|
getServiceUrl,
|
|
72
72
|
loadConfig,
|
|
73
|
-
loadEmptyConfig
|
|
73
|
+
loadEmptyConfig
|
|
74
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.22",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"typescript": "^5.5.4",
|
|
35
35
|
"undici-oidc-interceptor": "^0.5.0",
|
|
36
36
|
"why-is-node-running": "^2.2.2",
|
|
37
|
-
"@platformatic/composer": "2.0.0-alpha.
|
|
38
|
-
"@platformatic/
|
|
39
|
-
"@platformatic/sql-graphql": "2.0.0-alpha.
|
|
40
|
-
"@platformatic/
|
|
41
|
-
"@platformatic/
|
|
37
|
+
"@platformatic/composer": "2.0.0-alpha.22",
|
|
38
|
+
"@platformatic/service": "2.0.0-alpha.22",
|
|
39
|
+
"@platformatic/sql-graphql": "2.0.0-alpha.22",
|
|
40
|
+
"@platformatic/sql-mapper": "2.0.0-alpha.22",
|
|
41
|
+
"@platformatic/db": "2.0.0-alpha.22"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@fastify/error": "^4.0.0",
|
|
@@ -68,13 +68,13 @@
|
|
|
68
68
|
"undici": "^6.9.0",
|
|
69
69
|
"undici-thread-interceptor": "^0.6.1",
|
|
70
70
|
"ws": "^8.16.0",
|
|
71
|
-
"@platformatic/basic": "2.0.0-alpha.
|
|
72
|
-
"@platformatic/generators": "2.0.0-alpha.
|
|
73
|
-
"@platformatic/
|
|
74
|
-
"@platformatic/
|
|
75
|
-
"@platformatic/telemetry": "2.0.0-alpha.
|
|
76
|
-
"@platformatic/ts-compiler": "2.0.0-alpha.
|
|
77
|
-
"@platformatic/utils": "2.0.0-alpha.
|
|
71
|
+
"@platformatic/basic": "2.0.0-alpha.22",
|
|
72
|
+
"@platformatic/generators": "2.0.0-alpha.22",
|
|
73
|
+
"@platformatic/config": "2.0.0-alpha.22",
|
|
74
|
+
"@platformatic/itc": "2.0.0-alpha.22",
|
|
75
|
+
"@platformatic/telemetry": "2.0.0-alpha.22",
|
|
76
|
+
"@platformatic/ts-compiler": "2.0.0-alpha.22",
|
|
77
|
+
"@platformatic/utils": "2.0.0-alpha.22"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"test": "npm run lint && borp --concurrency=1 --timeout=180000 && tsd",
|
package/schema.json
CHANGED