@platformatic/basic 2.0.0-alpha.17 → 2.0.0-alpha.19
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/index.js +25 -5
- package/lib/base.js +3 -2
- package/lib/worker/child-process.js +8 -0
- package/package.json +7 -6
- package/schema.json +1 -1
package/index.js
CHANGED
|
@@ -8,6 +8,23 @@ import { packageJson, schema } from './lib/schema.js'
|
|
|
8
8
|
import { importFile } from './lib/utils.js'
|
|
9
9
|
|
|
10
10
|
const importStackablePackageMarker = '__pltImportStackablePackage.js'
|
|
11
|
+
const configCandidates = [
|
|
12
|
+
'platformatic.application.json',
|
|
13
|
+
'platformatic.json',
|
|
14
|
+
'watt.json',
|
|
15
|
+
'platformatic.application.yaml',
|
|
16
|
+
'platformatic.yaml',
|
|
17
|
+
'watt.yaml',
|
|
18
|
+
'platformatic.application.yml',
|
|
19
|
+
'platformatic.yml',
|
|
20
|
+
'watt.yml',
|
|
21
|
+
'platformatic.application.toml',
|
|
22
|
+
'platformatic.toml',
|
|
23
|
+
'watt.toml',
|
|
24
|
+
'platformatic.application.tml',
|
|
25
|
+
'platformatic.tml',
|
|
26
|
+
'watt.tml',
|
|
27
|
+
]
|
|
11
28
|
|
|
12
29
|
function isImportFailedError (error, pkg) {
|
|
13
30
|
if (error.code !== 'ERR_MODULE_NOT_FOUND' && error.code !== 'MODULE_NOT_FOUND') {
|
|
@@ -68,10 +85,13 @@ async function buildStackable (opts) {
|
|
|
68
85
|
const hadConfig = opts.config
|
|
69
86
|
|
|
70
87
|
if (!hadConfig) {
|
|
71
|
-
const candidate
|
|
88
|
+
for (const candidate of configCandidates) {
|
|
89
|
+
const candidatePath = resolve(root, candidate)
|
|
72
90
|
|
|
73
|
-
|
|
74
|
-
|
|
91
|
+
if (existsSync(candidatePath)) {
|
|
92
|
+
opts.config = candidatePath
|
|
93
|
+
break
|
|
94
|
+
}
|
|
75
95
|
}
|
|
76
96
|
}
|
|
77
97
|
|
|
@@ -94,7 +114,7 @@ async function buildStackable (opts) {
|
|
|
94
114
|
const imported = await importStackablePackage(opts, toImport, autodetectDescription)
|
|
95
115
|
|
|
96
116
|
const serviceRoot = relative(process.cwd(), opts.context.directory)
|
|
97
|
-
if (!hadConfig && !existsSync(resolve(serviceRoot, 'platformatic.
|
|
117
|
+
if (!hadConfig && !(existsSync(resolve(serviceRoot, 'platformatic.json') || existsSync(resolve(serviceRoot, 'watt.json'))))) {
|
|
98
118
|
const logger = pino({
|
|
99
119
|
level: opts.context.serverConfig?.logger?.level ?? 'warn',
|
|
100
120
|
name: opts.context.serviceId
|
|
@@ -103,7 +123,7 @@ async function buildStackable (opts) {
|
|
|
103
123
|
logger.warn(
|
|
104
124
|
[
|
|
105
125
|
`Platformatic has auto-detected that service ${opts.context.serviceId} ${autodetectDescription}.\n`,
|
|
106
|
-
`We suggest you create a platformatic.
|
|
126
|
+
`We suggest you create a platformatic.json or watt.json file in the folder ${serviceRoot} with the "$schema" `,
|
|
107
127
|
`property set to "https://schemas.platformatic.dev/${toImport}/${packageJson.version}.json".`
|
|
108
128
|
].join('')
|
|
109
129
|
)
|
package/lib/base.js
CHANGED
|
@@ -20,6 +20,7 @@ export class BaseStackable {
|
|
|
20
20
|
this.type = type
|
|
21
21
|
this.version = version
|
|
22
22
|
this.id = options.context.serviceId
|
|
23
|
+
this.telemetryConfig = options.context.telemetryConfig
|
|
23
24
|
this.options = options
|
|
24
25
|
this.root = root
|
|
25
26
|
this.configManager = configManager
|
|
@@ -180,7 +181,6 @@ export class BaseStackable {
|
|
|
180
181
|
async startWithCommand (command, loader) {
|
|
181
182
|
const config = this.configManager.current
|
|
182
183
|
const basePath = config.application?.basePath ? cleanBasePath(config.application?.basePath) : ''
|
|
183
|
-
|
|
184
184
|
this.#childManager = new ChildManager({
|
|
185
185
|
logger: this.logger,
|
|
186
186
|
loader,
|
|
@@ -190,7 +190,8 @@ export class BaseStackable {
|
|
|
190
190
|
root: pathToFileURL(this.root).toString(),
|
|
191
191
|
basePath,
|
|
192
192
|
logLevel: this.logger.level,
|
|
193
|
-
port: (this.isEntrypoint ? this.serverConfig?.port || 0 : undefined) ?? true
|
|
193
|
+
port: (this.isEntrypoint ? this.serverConfig?.port || 0 : undefined) ?? true,
|
|
194
|
+
telemetry: this.telemetryConfig
|
|
194
195
|
}
|
|
195
196
|
})
|
|
196
197
|
|
|
@@ -13,6 +13,7 @@ import { WebSocket } from 'ws'
|
|
|
13
13
|
import { exitCodes } from '../errors.js'
|
|
14
14
|
import { importFile } from '../utils.js'
|
|
15
15
|
import { getSocketPath, isWindows } from './child-manager.js'
|
|
16
|
+
import { setupNodeHTTPTelemetry } from '@platformatic/telemetry'
|
|
16
17
|
|
|
17
18
|
function createInterceptor (itc) {
|
|
18
19
|
return function (dispatch) {
|
|
@@ -90,6 +91,7 @@ export class ChildProcess extends ITC {
|
|
|
90
91
|
|
|
91
92
|
this.listen()
|
|
92
93
|
this.#setupLogger()
|
|
94
|
+
this.#setupTelemetry()
|
|
93
95
|
this.#setupHandlers()
|
|
94
96
|
this.#setupServer()
|
|
95
97
|
this.#setupInterceptors()
|
|
@@ -164,6 +166,12 @@ export class ChildProcess extends ITC {
|
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
168
|
|
|
169
|
+
#setupTelemetry () {
|
|
170
|
+
if (globalThis.platformatic.telemetry) {
|
|
171
|
+
setupNodeHTTPTelemetry(globalThis.platformatic.telemetry, this.#logger)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
167
175
|
#setupServer () {
|
|
168
176
|
const subscribers = {
|
|
169
177
|
asyncStart ({ options }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/basic",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.19",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,9 +23,10 @@
|
|
|
23
23
|
"split2": "^4.2.0",
|
|
24
24
|
"undici": "^6.19.5",
|
|
25
25
|
"ws": "^8.18.0",
|
|
26
|
-
"@platformatic/
|
|
27
|
-
"@platformatic/
|
|
28
|
-
"@platformatic/
|
|
26
|
+
"@platformatic/itc": "2.0.0-alpha.19",
|
|
27
|
+
"@platformatic/config": "2.0.0-alpha.19",
|
|
28
|
+
"@platformatic/telemetry": "2.0.0-alpha.19",
|
|
29
|
+
"@platformatic/utils": "2.0.0-alpha.19"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"borp": "^0.17.0",
|
|
@@ -39,8 +40,8 @@
|
|
|
39
40
|
"react-dom": "^18.3.1",
|
|
40
41
|
"typescript": "^5.5.4",
|
|
41
42
|
"vite": "^5.4.0",
|
|
42
|
-
"@platformatic/composer": "2.0.0-alpha.
|
|
43
|
-
"@platformatic/service": "2.0.0-alpha.
|
|
43
|
+
"@platformatic/composer": "2.0.0-alpha.19",
|
|
44
|
+
"@platformatic/service": "2.0.0-alpha.19"
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|
|
46
47
|
"gen-schema": "node lib/schema.js > schema.json",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/basic/2.0.0-alpha.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/basic/2.0.0-alpha.19.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Stackable",
|
|
5
5
|
"type": "object",
|