@platformatic/runtime 2.63.4 → 2.64.0
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/lib/generator/runtime-generator.js +24 -14
- package/package.json +14 -14
- 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 HttpsSchemasPlatformaticDevPlatformaticRuntime2640Json = {
|
|
9
9
|
[k: string]: unknown;
|
|
10
10
|
} & {
|
|
11
11
|
$schema?: string;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { BaseGenerator } = require('@platformatic/generators')
|
|
4
4
|
const { NoEntryPointError, NoServiceNamedError } = require('./errors')
|
|
5
|
+
const { existsSync } = require('node:fs')
|
|
5
6
|
const { join } = require('node:path')
|
|
6
7
|
const { envObjectToString } = require('@platformatic/generators/lib/utils')
|
|
7
8
|
const { readFile, readdir, stat } = require('node:fs/promises')
|
|
@@ -20,7 +21,9 @@ class RuntimeGenerator extends BaseGenerator {
|
|
|
20
21
|
module: '@platformatic/runtime'
|
|
21
22
|
})
|
|
22
23
|
this.runtimeName = opts.name
|
|
24
|
+
this.servicesFolder = opts.servicesFolder ?? 'services'
|
|
23
25
|
this.services = []
|
|
26
|
+
this.existingServices = []
|
|
24
27
|
this.entryPoint = null
|
|
25
28
|
}
|
|
26
29
|
|
|
@@ -47,7 +50,7 @@ class RuntimeGenerator extends BaseGenerator {
|
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
setEntryPoint (entryPoint) {
|
|
50
|
-
const service = this.services.find(svc => svc.name === entryPoint)
|
|
53
|
+
const service = this.existingServices.includes(entryPoint) || this.services.find(svc => svc.name === entryPoint)
|
|
51
54
|
if (!service) {
|
|
52
55
|
throw new NoServiceNamedError(entryPoint)
|
|
53
56
|
}
|
|
@@ -57,7 +60,7 @@ class RuntimeGenerator extends BaseGenerator {
|
|
|
57
60
|
async generatePackageJson () {
|
|
58
61
|
const template = {
|
|
59
62
|
name: `${this.runtimeName}`,
|
|
60
|
-
workspaces: ['
|
|
63
|
+
workspaces: [this.servicesFolder + '/*'],
|
|
61
64
|
scripts: {
|
|
62
65
|
start: 'platformatic start'
|
|
63
66
|
},
|
|
@@ -68,6 +71,7 @@ class RuntimeGenerator extends BaseGenerator {
|
|
|
68
71
|
dependencies: {
|
|
69
72
|
'@platformatic/runtime': `^${this.platformaticVersion}`,
|
|
70
73
|
platformatic: `^${this.platformaticVersion}`,
|
|
74
|
+
wattpm: `^${this.platformaticVersion}`,
|
|
71
75
|
...this.config.dependencies
|
|
72
76
|
},
|
|
73
77
|
engines: {
|
|
@@ -115,17 +119,20 @@ class RuntimeGenerator extends BaseGenerator {
|
|
|
115
119
|
return
|
|
116
120
|
}
|
|
117
121
|
this._hasCheckedForExistingConfig = true
|
|
118
|
-
const existingConfigFile = await ConfigManager.findConfigFile(this.targetDirectory, 'runtime')
|
|
119
|
-
if (existingConfigFile) {
|
|
122
|
+
const existingConfigFile = this.runtimeConfig ?? await ConfigManager.findConfigFile(this.targetDirectory, 'runtime')
|
|
123
|
+
if (existingConfigFile && existsSync(join(this.targetDirectory, existingConfigFile))) {
|
|
120
124
|
const configManager = new ConfigManager({
|
|
121
125
|
...platformaticRuntime.configManagerConfig,
|
|
122
126
|
source: join(this.targetDirectory, existingConfigFile)
|
|
123
127
|
})
|
|
124
128
|
await configManager.parse()
|
|
129
|
+
|
|
125
130
|
this.existingConfig = configManager.current
|
|
131
|
+
this.existingConfigRaw = configManager.currentRaw
|
|
126
132
|
this.config.env = configManager.env
|
|
127
133
|
this.config.port = configManager.env.PORT
|
|
128
134
|
this.entryPoint = configManager.current.services.find(svc => svc.entrypoint)
|
|
135
|
+
this.existingServices = configManager.current.services.map(s => s.id)
|
|
129
136
|
}
|
|
130
137
|
}
|
|
131
138
|
|
|
@@ -160,7 +167,7 @@ class RuntimeGenerator extends BaseGenerator {
|
|
|
160
167
|
entrypoint: this.entryPoint.name,
|
|
161
168
|
watch: true,
|
|
162
169
|
autoload: {
|
|
163
|
-
path: this.config.autoload ||
|
|
170
|
+
path: this.config.autoload || this.servicesFolder,
|
|
164
171
|
exclude: ['docs']
|
|
165
172
|
},
|
|
166
173
|
logger: {
|
|
@@ -256,7 +263,7 @@ class RuntimeGenerator extends BaseGenerator {
|
|
|
256
263
|
if (this.existingConfig) {
|
|
257
264
|
basePath = this.existingConfig.autoload.path
|
|
258
265
|
} else {
|
|
259
|
-
basePath = join(this.targetDirectory, this.config.autoload ||
|
|
266
|
+
basePath = join(this.targetDirectory, this.config.autoload || this.servicesFolder)
|
|
260
267
|
}
|
|
261
268
|
service.setTargetDirectory(join(basePath, service.config.serviceName))
|
|
262
269
|
})
|
|
@@ -320,7 +327,7 @@ class RuntimeGenerator extends BaseGenerator {
|
|
|
320
327
|
services: []
|
|
321
328
|
}
|
|
322
329
|
const runtimePkgConfigFileData = JSON.parse(
|
|
323
|
-
await readFile(join(this.targetDirectory,
|
|
330
|
+
await readFile(join(this.targetDirectory, this.runtimeConfig), 'utf-8')
|
|
324
331
|
)
|
|
325
332
|
const servicesPath = join(this.targetDirectory, runtimePkgConfigFileData.autoload.path)
|
|
326
333
|
|
|
@@ -331,8 +338,9 @@ class RuntimeGenerator extends BaseGenerator {
|
|
|
331
338
|
const currentServicePath = join(servicesPath, s)
|
|
332
339
|
const dirStat = await stat(currentServicePath)
|
|
333
340
|
if (dirStat.isDirectory()) {
|
|
334
|
-
// load the
|
|
335
|
-
const
|
|
341
|
+
// load the service config
|
|
342
|
+
const configFile = await ConfigManager.findConfigFile(currentServicePath)
|
|
343
|
+
const servicePltJson = JSON.parse(await readFile(join(currentServicePath, configFile), 'utf-8'))
|
|
336
344
|
// get module to load
|
|
337
345
|
const template = servicePltJson.module || getServiceTemplateFromSchemaUrl(servicePltJson.$schema)
|
|
338
346
|
const Generator = await this._getGeneratorForTemplate(currentServicePath, template)
|
|
@@ -378,8 +386,10 @@ class RuntimeGenerator extends BaseGenerator {
|
|
|
378
386
|
})
|
|
379
387
|
|
|
380
388
|
// delete dependencies
|
|
389
|
+
const servicePath = join(this.targetDirectory, this.servicesFolder, s.name)
|
|
390
|
+
const configFile = await ConfigManager.findConfigFile(servicePath)
|
|
381
391
|
const servicePackageJson = JSON.parse(
|
|
382
|
-
await readFile(join(
|
|
392
|
+
await readFile(join(servicePath, configFile), 'utf-8')
|
|
383
393
|
)
|
|
384
394
|
if (servicePackageJson.plugins && servicePackageJson.plugins.packages) {
|
|
385
395
|
servicePackageJson.plugins.packages.forEach(p => {
|
|
@@ -387,7 +397,7 @@ class RuntimeGenerator extends BaseGenerator {
|
|
|
387
397
|
})
|
|
388
398
|
}
|
|
389
399
|
// delete directory
|
|
390
|
-
await safeRemove(join(this.targetDirectory,
|
|
400
|
+
await safeRemove(join(this.targetDirectory, this.servicesFolder, s.name))
|
|
391
401
|
}
|
|
392
402
|
// throw new CannotRemoveServiceOnUpdateError(removedServices.join(', '))
|
|
393
403
|
}
|
|
@@ -404,7 +414,7 @@ class RuntimeGenerator extends BaseGenerator {
|
|
|
404
414
|
})
|
|
405
415
|
const baseConfig = {
|
|
406
416
|
isRuntimeContext: true,
|
|
407
|
-
targetDirectory: join(this.targetDirectory,
|
|
417
|
+
targetDirectory: join(this.targetDirectory, this.servicesFolder, newService.name),
|
|
408
418
|
serviceName: newService.name,
|
|
409
419
|
plugin: true
|
|
410
420
|
}
|
|
@@ -475,14 +485,14 @@ class RuntimeGenerator extends BaseGenerator {
|
|
|
475
485
|
if (newEntrypoint) {
|
|
476
486
|
// load platformatic.json runtime config
|
|
477
487
|
const runtimePkgConfigFileData = JSON.parse(
|
|
478
|
-
await readFile(join(this.targetDirectory,
|
|
488
|
+
await readFile(join(this.targetDirectory, this.runtimeConfig), 'utf-8')
|
|
479
489
|
)
|
|
480
490
|
|
|
481
491
|
this.setEntryPoint(newEntrypoint)
|
|
482
492
|
runtimePkgConfigFileData.entrypoint = newEntrypoint
|
|
483
493
|
this.addFile({
|
|
484
494
|
path: '',
|
|
485
|
-
file:
|
|
495
|
+
file: this.runtimeConfig,
|
|
486
496
|
contents: JSON.stringify(runtimePkgConfigFileData, null, 2)
|
|
487
497
|
})
|
|
488
498
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.64.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"typescript": "^5.5.4",
|
|
38
38
|
"undici-oidc-interceptor": "^0.5.0",
|
|
39
39
|
"why-is-node-running": "^2.2.2",
|
|
40
|
-
"@platformatic/composer": "2.
|
|
41
|
-
"@platformatic/
|
|
42
|
-
"@platformatic/
|
|
43
|
-
"@platformatic/service": "2.
|
|
44
|
-
"@platformatic/sql-graphql": "2.
|
|
45
|
-
"@platformatic/sql-mapper": "2.
|
|
40
|
+
"@platformatic/composer": "2.64.0",
|
|
41
|
+
"@platformatic/db": "2.64.0",
|
|
42
|
+
"@platformatic/node": "2.64.0",
|
|
43
|
+
"@platformatic/service": "2.64.0",
|
|
44
|
+
"@platformatic/sql-graphql": "2.64.0",
|
|
45
|
+
"@platformatic/sql-mapper": "2.64.0"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@fastify/accepts": "^5.0.0",
|
|
@@ -76,13 +76,13 @@
|
|
|
76
76
|
"undici": "^7.0.0",
|
|
77
77
|
"undici-thread-interceptor": "^0.13.1",
|
|
78
78
|
"ws": "^8.16.0",
|
|
79
|
-
"@platformatic/basic": "2.
|
|
80
|
-
"@platformatic/
|
|
81
|
-
"@platformatic/
|
|
82
|
-
"@platformatic/
|
|
83
|
-
"@platformatic/telemetry": "2.
|
|
84
|
-
"@platformatic/
|
|
85
|
-
"@platformatic/
|
|
79
|
+
"@platformatic/basic": "2.64.0",
|
|
80
|
+
"@platformatic/generators": "2.64.0",
|
|
81
|
+
"@platformatic/itc": "2.64.0",
|
|
82
|
+
"@platformatic/ts-compiler": "2.64.0",
|
|
83
|
+
"@platformatic/telemetry": "2.64.0",
|
|
84
|
+
"@platformatic/utils": "2.64.0",
|
|
85
|
+
"@platformatic/config": "2.64.0"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
88
|
"test": "pnpm run lint && borp --concurrency=1 --timeout=300000 && tsd",
|
package/schema.json
CHANGED