@platformatic/basic 2.68.0 → 2.70.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/index.js +9 -57
- package/lib/base.js +2 -7
- package/lib/utils.js +2 -2
- package/lib/worker/child-manager.js +2 -2
- package/package.json +6 -6
- package/schema.json +24 -17
package/config.d.ts
CHANGED
|
@@ -107,7 +107,7 @@ export interface PlatformaticStackable {
|
|
|
107
107
|
maxELU?: number | string;
|
|
108
108
|
maxHeapUsed?: number | string;
|
|
109
109
|
maxHeapTotal?: number | string;
|
|
110
|
-
maxYoungGeneration?: number;
|
|
110
|
+
maxYoungGeneration?: number | string;
|
|
111
111
|
};
|
|
112
112
|
undici?: {
|
|
113
113
|
agentOptions?: {
|
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ConfigManager } from '@platformatic/config'
|
|
2
|
-
import {
|
|
2
|
+
import { detectApplicationType } from '@platformatic/utils'
|
|
3
3
|
import jsonPatch from 'fast-json-patch'
|
|
4
|
-
import { existsSync } from 'node:fs'
|
|
5
4
|
import { readFile } from 'node:fs/promises'
|
|
5
|
+
import { createRequire } from 'node:module'
|
|
6
6
|
import { relative, resolve } from 'node:path'
|
|
7
7
|
import { workerData } from 'node:worker_threads'
|
|
8
8
|
import pino from 'pino'
|
|
@@ -11,28 +11,6 @@ import { importFile } from './lib/utils.js'
|
|
|
11
11
|
|
|
12
12
|
const importStackablePackageMarker = '__pltImportStackablePackage.js'
|
|
13
13
|
|
|
14
|
-
export const configCandidates = [
|
|
15
|
-
'platformatic.application.json',
|
|
16
|
-
'platformatic.json',
|
|
17
|
-
'watt.json',
|
|
18
|
-
'platformatic.application.yaml',
|
|
19
|
-
'platformatic.yaml',
|
|
20
|
-
'watt.yaml',
|
|
21
|
-
'platformatic.application.yml',
|
|
22
|
-
'platformatic.yml',
|
|
23
|
-
'watt.yml',
|
|
24
|
-
'platformatic.application.toml',
|
|
25
|
-
'platformatic.toml',
|
|
26
|
-
'watt.toml',
|
|
27
|
-
'platformatic.application.tml',
|
|
28
|
-
'platformatic.tml',
|
|
29
|
-
'watt.tml'
|
|
30
|
-
]
|
|
31
|
-
|
|
32
|
-
function hasDependency (packageJson, dependency) {
|
|
33
|
-
return packageJson.dependencies?.[dependency] || packageJson.devDependencies?.[dependency]
|
|
34
|
-
}
|
|
35
|
-
|
|
36
14
|
function isImportFailedError (error, pkg) {
|
|
37
15
|
if (error.code !== 'ERR_MODULE_NOT_FOUND' && error.code !== 'MODULE_NOT_FOUND') {
|
|
38
16
|
return false
|
|
@@ -70,31 +48,6 @@ async function importStackablePackage (directory, pkg) {
|
|
|
70
48
|
}
|
|
71
49
|
}
|
|
72
50
|
|
|
73
|
-
export async function detectStackable (root, packageJson) {
|
|
74
|
-
let name = '@platformatic/node'
|
|
75
|
-
let label = 'Node.js'
|
|
76
|
-
|
|
77
|
-
if (hasDependency(packageJson, '@nestjs/core')) {
|
|
78
|
-
name = '@platformatic/nest'
|
|
79
|
-
label = 'NestJS'
|
|
80
|
-
} else if (hasDependency(packageJson, 'next')) {
|
|
81
|
-
name = '@platformatic/next'
|
|
82
|
-
label = 'Next.js'
|
|
83
|
-
} else if (hasDependency(packageJson, '@remix-run/dev')) {
|
|
84
|
-
name = '@platformatic/remix'
|
|
85
|
-
label = 'Remix'
|
|
86
|
-
} else if (hasDependency(packageJson, 'astro')) {
|
|
87
|
-
name = '@platformatic/astro'
|
|
88
|
-
label = 'Astro'
|
|
89
|
-
// Since Vite is often used with other frameworks, we must check for Vite last
|
|
90
|
-
} else if (hasDependency(packageJson, 'vite')) {
|
|
91
|
-
name = '@platformatic/vite'
|
|
92
|
-
label = 'Vite'
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return { name, label }
|
|
96
|
-
}
|
|
97
|
-
|
|
98
51
|
export async function importStackableAndConfig (root, config, context) {
|
|
99
52
|
let rootPackageJson
|
|
100
53
|
try {
|
|
@@ -106,17 +59,16 @@ export async function importStackableAndConfig (root, config, context) {
|
|
|
106
59
|
const hadConfig = !!config
|
|
107
60
|
|
|
108
61
|
if (!config) {
|
|
109
|
-
|
|
110
|
-
|
|
62
|
+
config = await ConfigManager.findConfigFile(root, 'application')
|
|
63
|
+
}
|
|
111
64
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
65
|
+
const appType = await detectApplicationType(root, rootPackageJson)
|
|
66
|
+
|
|
67
|
+
if (!appType) {
|
|
68
|
+
throw new Error(`Unable to detect application type in ${root}.`)
|
|
117
69
|
}
|
|
118
70
|
|
|
119
|
-
const { label, name: moduleName } =
|
|
71
|
+
const { label, name: moduleName } = appType
|
|
120
72
|
|
|
121
73
|
if (context) {
|
|
122
74
|
const serviceRoot = relative(process.cwd(), root)
|
package/lib/base.js
CHANGED
|
@@ -46,8 +46,6 @@ export class BaseStackable extends EventEmitter {
|
|
|
46
46
|
this.#metricsCollected = false
|
|
47
47
|
this.customHealthCheck = null
|
|
48
48
|
this.customReadinessCheck = null
|
|
49
|
-
this.startHttpTimer = null
|
|
50
|
-
this.endHttpTimer = null
|
|
51
49
|
this.clientWs = null
|
|
52
50
|
this.runtimeConfig = deepmerge(options.context?.runtimeConfig ?? {}, workerData?.config ?? {})
|
|
53
51
|
this.stdout = standardStreams?.stdout ?? process.stdout
|
|
@@ -354,7 +352,7 @@ export class BaseStackable extends EventEmitter {
|
|
|
354
352
|
isEntrypoint: this.isEntrypoint,
|
|
355
353
|
runtimeBasePath: this.runtimeConfig?.basePath ?? null,
|
|
356
354
|
wantsAbsoluteUrls: meta.composer?.wantsAbsoluteUrls ?? false,
|
|
357
|
-
/* c8 ignore next 2 -
|
|
355
|
+
/* c8 ignore next 2 - else */
|
|
358
356
|
port: (this.isEntrypoint ? this.serverConfig?.port || 0 : undefined) ?? true,
|
|
359
357
|
host: (this.isEntrypoint ? this.serverConfig?.hostname : undefined) ?? true,
|
|
360
358
|
telemetryConfig: this.telemetryConfig
|
|
@@ -418,15 +416,12 @@ export class BaseStackable extends EventEmitter {
|
|
|
418
416
|
return
|
|
419
417
|
}
|
|
420
418
|
|
|
421
|
-
|
|
419
|
+
await collectMetrics(
|
|
422
420
|
this.serviceId,
|
|
423
421
|
this.workerId,
|
|
424
422
|
metricsConfig,
|
|
425
423
|
this.metricsRegistry
|
|
426
424
|
)
|
|
427
|
-
|
|
428
|
-
this.startHttpTimer = startHttpTimer
|
|
429
|
-
this.endHttpTimer = endHttpTimer
|
|
430
425
|
}
|
|
431
426
|
}
|
|
432
427
|
|
package/lib/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRequire } from '
|
|
1
|
+
import { createRequire } from 'node:module'
|
|
2
2
|
import { pathToFileURL } from 'node:url'
|
|
3
3
|
import { request } from 'undici'
|
|
4
4
|
|
|
@@ -65,7 +65,7 @@ export function resolvePackage (root, pkg) {
|
|
|
65
65
|
// We need to add the main module paths to the require.resolve call
|
|
66
66
|
// Note that `require.main` is not defined in `next` if we set sthe instrumentation hook reequired for ESM applications.
|
|
67
67
|
// see: https://github.com/open-telemetry/opentelemetry-js/blob/main/doc/esm-support.md#instrumentation-hook-required-for-esm
|
|
68
|
-
return require.resolve(pkg, { paths: [root, ...require.main?.paths || []] })
|
|
68
|
+
return require.resolve(pkg, { paths: [root, ...(require.main?.paths || [])] })
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export function cleanBasePath (basePath) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ITC } from '@platformatic/itc'
|
|
2
|
-
import { createDirectory,
|
|
2
|
+
import { createDirectory, ensureLoggableError } from '@platformatic/utils'
|
|
3
3
|
import { once } from 'node:events'
|
|
4
4
|
import { rm, writeFile } from 'node:fs/promises'
|
|
5
5
|
import { createServer } from 'node:http'
|
|
6
|
-
import { register } from 'node:module'
|
|
6
|
+
import { createRequire, register } from 'node:module'
|
|
7
7
|
import { platform, tmpdir } from 'node:os'
|
|
8
8
|
import { dirname, join, resolve } from 'node:path'
|
|
9
9
|
import { pathToFileURL } from 'node:url'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/basic",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.70.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"split2": "^4.2.0",
|
|
25
25
|
"undici": "^7.0.0",
|
|
26
26
|
"ws": "^8.18.0",
|
|
27
|
-
"@platformatic/config": "2.
|
|
28
|
-
"@platformatic/
|
|
29
|
-
"@platformatic/
|
|
30
|
-
"@platformatic/telemetry": "2.
|
|
31
|
-
"@platformatic/utils": "2.
|
|
27
|
+
"@platformatic/config": "2.70.0",
|
|
28
|
+
"@platformatic/metrics": "2.70.0",
|
|
29
|
+
"@platformatic/itc": "2.70.0",
|
|
30
|
+
"@platformatic/telemetry": "2.70.0",
|
|
31
|
+
"@platformatic/utils": "2.70.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"borp": "^0.20.0",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/basic/2.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/basic/2.70.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Stackable",
|
|
5
5
|
"type": "object",
|
|
@@ -367,7 +367,6 @@
|
|
|
367
367
|
"default": {},
|
|
368
368
|
"properties": {
|
|
369
369
|
"enabled": {
|
|
370
|
-
"default": true,
|
|
371
370
|
"anyOf": [
|
|
372
371
|
{
|
|
373
372
|
"type": "boolean"
|
|
@@ -375,10 +374,10 @@
|
|
|
375
374
|
{
|
|
376
375
|
"type": "string"
|
|
377
376
|
}
|
|
378
|
-
]
|
|
377
|
+
],
|
|
378
|
+
"default": true
|
|
379
379
|
},
|
|
380
380
|
"interval": {
|
|
381
|
-
"default": 30000,
|
|
382
381
|
"anyOf": [
|
|
383
382
|
{
|
|
384
383
|
"type": "number",
|
|
@@ -387,10 +386,10 @@
|
|
|
387
386
|
{
|
|
388
387
|
"type": "string"
|
|
389
388
|
}
|
|
390
|
-
]
|
|
389
|
+
],
|
|
390
|
+
"default": 30000
|
|
391
391
|
},
|
|
392
392
|
"gracePeriod": {
|
|
393
|
-
"default": 30000,
|
|
394
393
|
"anyOf": [
|
|
395
394
|
{
|
|
396
395
|
"type": "number",
|
|
@@ -399,10 +398,10 @@
|
|
|
399
398
|
{
|
|
400
399
|
"type": "string"
|
|
401
400
|
}
|
|
402
|
-
]
|
|
401
|
+
],
|
|
402
|
+
"default": 30000
|
|
403
403
|
},
|
|
404
404
|
"maxUnhealthyChecks": {
|
|
405
|
-
"default": 10,
|
|
406
405
|
"anyOf": [
|
|
407
406
|
{
|
|
408
407
|
"type": "number",
|
|
@@ -411,10 +410,10 @@
|
|
|
411
410
|
{
|
|
412
411
|
"type": "string"
|
|
413
412
|
}
|
|
414
|
-
]
|
|
413
|
+
],
|
|
414
|
+
"default": 10
|
|
415
415
|
},
|
|
416
416
|
"maxELU": {
|
|
417
|
-
"default": 0.99,
|
|
418
417
|
"anyOf": [
|
|
419
418
|
{
|
|
420
419
|
"type": "number",
|
|
@@ -424,10 +423,10 @@
|
|
|
424
423
|
{
|
|
425
424
|
"type": "string"
|
|
426
425
|
}
|
|
427
|
-
]
|
|
426
|
+
],
|
|
427
|
+
"default": 0.99
|
|
428
428
|
},
|
|
429
429
|
"maxHeapUsed": {
|
|
430
|
-
"default": 0.99,
|
|
431
430
|
"anyOf": [
|
|
432
431
|
{
|
|
433
432
|
"type": "number",
|
|
@@ -437,10 +436,10 @@
|
|
|
437
436
|
{
|
|
438
437
|
"type": "string"
|
|
439
438
|
}
|
|
440
|
-
]
|
|
439
|
+
],
|
|
440
|
+
"default": 0.99
|
|
441
441
|
},
|
|
442
442
|
"maxHeapTotal": {
|
|
443
|
-
"default": 4294967296,
|
|
444
443
|
"anyOf": [
|
|
445
444
|
{
|
|
446
445
|
"type": "number",
|
|
@@ -449,11 +448,19 @@
|
|
|
449
448
|
{
|
|
450
449
|
"type": "string"
|
|
451
450
|
}
|
|
452
|
-
]
|
|
451
|
+
],
|
|
452
|
+
"default": 4294967296
|
|
453
453
|
},
|
|
454
454
|
"maxYoungGeneration": {
|
|
455
|
-
"
|
|
456
|
-
|
|
455
|
+
"anyOf": [
|
|
456
|
+
{
|
|
457
|
+
"type": "number",
|
|
458
|
+
"minimum": 0
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
"type": "string"
|
|
462
|
+
}
|
|
463
|
+
]
|
|
457
464
|
}
|
|
458
465
|
},
|
|
459
466
|
"additionalProperties": false
|