@platformatic/runtime 1.6.0 → 1.7.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/fixtures/dbApp/package.json +5 -0
- package/fixtures/dbAppWithMigrationError/package.json +5 -0
- package/fixtures/empty/hello.js +7 -0
- package/help/start.txt +17 -1
- package/lib/config.js +14 -4
- package/lib/start.js +26 -1
- package/package.json +9 -9
package/help/start.txt
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
Start the Platformatic Runtime with the following command:
|
|
2
2
|
|
|
3
|
-
```
|
|
3
|
+
```bash
|
|
4
4
|
$ platformatic runtime start
|
|
5
5
|
```
|
|
6
|
+
|
|
7
|
+
You can also specify a custom routes file, for example:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
$ platformatic runtime start routes.js
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Where `routes.js` is:
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
module.exports = async function (app) {
|
|
17
|
+
app.get('/hello', async () => {
|
|
18
|
+
return { hello: 'hello123' }
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
```
|
package/lib/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const { readFile, readdir } = require('node:fs/promises')
|
|
3
|
-
const {
|
|
3
|
+
const { join, resolve: pathResolve } = require('node:path')
|
|
4
4
|
const { closest } = require('fastest-levenshtein')
|
|
5
5
|
const Topo = require('@hapi/topo')
|
|
6
6
|
const ConfigManager = require('@platformatic/config')
|
|
@@ -253,16 +253,26 @@ platformaticRuntime.configManagerConfig = {
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
async function wrapConfigInRuntimeConfig ({ configManager, args }) {
|
|
256
|
+
let serviceId = 'main'
|
|
257
|
+
try {
|
|
258
|
+
const packageJson = join(configManager.dirname, 'package.json')
|
|
259
|
+
serviceId = require(packageJson).name
|
|
260
|
+
if (serviceId.startsWith('@')) {
|
|
261
|
+
serviceId = serviceId.split('/')[1]
|
|
262
|
+
}
|
|
263
|
+
} catch (err) {
|
|
264
|
+
// on purpose, the package.json might be missing
|
|
265
|
+
}
|
|
266
|
+
|
|
256
267
|
/* c8 ignore next */
|
|
257
|
-
const id = basename(configManager.dirname) || 'main'
|
|
258
268
|
const wrapperConfig = {
|
|
259
269
|
$schema: schema.$id,
|
|
260
|
-
entrypoint:
|
|
270
|
+
entrypoint: serviceId,
|
|
261
271
|
allowCycles: false,
|
|
262
272
|
hotReload: true,
|
|
263
273
|
services: [
|
|
264
274
|
{
|
|
265
|
-
id,
|
|
275
|
+
id: serviceId,
|
|
266
276
|
path: configManager.dirname,
|
|
267
277
|
config: configManager.fullPath
|
|
268
278
|
}
|
package/lib/start.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const { once } = require('node:events')
|
|
3
3
|
const inspector = require('node:inspector')
|
|
4
|
-
const { join } = require('node:path')
|
|
4
|
+
const { join, resolve, dirname } = require('node:path')
|
|
5
|
+
const fs = require('node:fs/promises')
|
|
5
6
|
const { pathToFileURL } = require('node:url')
|
|
6
7
|
const { Worker } = require('node:worker_threads')
|
|
7
8
|
const closeWithGrace = require('close-with-grace')
|
|
@@ -11,6 +12,7 @@ const { parseInspectorOptions, wrapConfigInRuntimeConfig } = require('./config')
|
|
|
11
12
|
const RuntimeApiClient = require('./api-client.js')
|
|
12
13
|
const { printConfigValidationErrors } = require('@platformatic/config')
|
|
13
14
|
const errors = require('./errors')
|
|
15
|
+
const pkg = require('../package.json')
|
|
14
16
|
|
|
15
17
|
const kLoaderFile = pathToFileURL(join(__dirname, 'loader.mjs')).href
|
|
16
18
|
const kWorkerFile = join(__dirname, 'worker.js')
|
|
@@ -114,6 +116,29 @@ async function startCommand (args) {
|
|
|
114
116
|
|
|
115
117
|
return await runtime.start()
|
|
116
118
|
} catch (err) {
|
|
119
|
+
if (err.code === 'PLT_CONFIG_NO_CONFIG_FILE_FOUND' && args.length === 1) {
|
|
120
|
+
const config = {
|
|
121
|
+
$schema: `https://platformatic.dev/schemas/v${pkg.version}/service`,
|
|
122
|
+
server: {
|
|
123
|
+
hostname: '127.0.0.1',
|
|
124
|
+
port: 3042,
|
|
125
|
+
logger: {
|
|
126
|
+
level: 'info'
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
plugins: {
|
|
130
|
+
paths: [args[0]]
|
|
131
|
+
},
|
|
132
|
+
service: {
|
|
133
|
+
openapi: true
|
|
134
|
+
},
|
|
135
|
+
watch: true
|
|
136
|
+
}
|
|
137
|
+
const toWrite = join(dirname(resolve(args[0])), 'platformatic.service.json')
|
|
138
|
+
console.log(`No config file found, creating ${join(dirname(args[0]), 'platformatic.service.json')}`)
|
|
139
|
+
await fs.writeFile(toWrite, JSON.stringify(config, null, 2))
|
|
140
|
+
return startCommand(['--config', toWrite])
|
|
141
|
+
}
|
|
117
142
|
logErrorAndExit(err)
|
|
118
143
|
}
|
|
119
144
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"standard": "^17.1.0",
|
|
29
29
|
"tsd": "^0.29.0",
|
|
30
30
|
"typescript": "^5.2.2",
|
|
31
|
-
"@platformatic/sql-graphql": "1.
|
|
32
|
-
"@platformatic/sql-mapper": "1.
|
|
31
|
+
"@platformatic/sql-graphql": "1.7.0",
|
|
32
|
+
"@platformatic/sql-mapper": "1.7.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@fastify/error": "^3.4.0",
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"pino": "^8.16.0",
|
|
49
49
|
"pino-pretty": "^10.2.3",
|
|
50
50
|
"undici": "^5.26.3",
|
|
51
|
-
"@platformatic/composer": "1.
|
|
52
|
-
"@platformatic/
|
|
53
|
-
"@platformatic/
|
|
54
|
-
"@platformatic/
|
|
55
|
-
"@platformatic/
|
|
56
|
-
"@platformatic/utils": "1.
|
|
51
|
+
"@platformatic/composer": "1.7.0",
|
|
52
|
+
"@platformatic/config": "1.7.0",
|
|
53
|
+
"@platformatic/db": "1.7.0",
|
|
54
|
+
"@platformatic/telemetry": "1.7.0",
|
|
55
|
+
"@platformatic/service": "1.7.0",
|
|
56
|
+
"@platformatic/utils": "1.7.0"
|
|
57
57
|
},
|
|
58
58
|
"standard": {
|
|
59
59
|
"ignore": [
|