@platformatic/next 2.0.0-alpha.5 → 2.0.0-alpha.7
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 +7 -0
- package/index.js +27 -14
- package/lib/schema.js +1 -0
- package/package.json +7 -7
- package/schema.json +28 -1
- package/test/index.test.js +1 -0
package/config.d.ts
CHANGED
|
@@ -153,4 +153,11 @@ export interface PlatformaticNextJsStackable {
|
|
|
153
153
|
application?: {
|
|
154
154
|
basePath?: string;
|
|
155
155
|
};
|
|
156
|
+
deploy?: {
|
|
157
|
+
include?: string[];
|
|
158
|
+
buildCommand?: string;
|
|
159
|
+
installCommand?: string;
|
|
160
|
+
startCommand?: string;
|
|
161
|
+
[k: string]: unknown;
|
|
162
|
+
};
|
|
156
163
|
}
|
package/index.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BaseStackable,
|
|
3
|
+
transformConfig as basicTransformConfig,
|
|
4
|
+
ChildManager,
|
|
5
|
+
errors,
|
|
6
|
+
importFile,
|
|
7
|
+
schemaOptions
|
|
8
|
+
} from '@platformatic/basic'
|
|
2
9
|
import { ConfigManager } from '@platformatic/config'
|
|
3
10
|
import { once } from 'node:events'
|
|
4
11
|
import { readFile } from 'node:fs/promises'
|
|
@@ -20,8 +27,6 @@ export class NextStackable extends BaseStackable {
|
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
async init () {
|
|
23
|
-
globalThis[Symbol.for('plt.runtime.itc')].handle('getServiceMeta', this.getMeta.bind(this))
|
|
24
|
-
|
|
25
30
|
this.#next = pathResolve(dirname(createRequire(this.root).resolve('next')), '../..')
|
|
26
31
|
const nextPackage = JSON.parse(await readFile(pathResolve(this.#next, 'package.json'), 'utf-8'))
|
|
27
32
|
|
|
@@ -44,7 +49,7 @@ export class NextStackable extends BaseStackable {
|
|
|
44
49
|
const { hostname, port } = this.serverConfig ?? {}
|
|
45
50
|
const serverOptions = {
|
|
46
51
|
host: hostname || '127.0.0.1',
|
|
47
|
-
port: port || 0
|
|
52
|
+
port: port || 0
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
this.#basePath = config.application?.basePath
|
|
@@ -57,8 +62,8 @@ export class NextStackable extends BaseStackable {
|
|
|
57
62
|
// Always use URL to avoid serialization problem in Windows
|
|
58
63
|
root: pathToFileURL(this.root),
|
|
59
64
|
basePath: this.#basePath,
|
|
60
|
-
logger: { id: this.id, level: this.logger.level }
|
|
61
|
-
}
|
|
65
|
+
logger: { id: this.id, level: this.logger.level }
|
|
66
|
+
}
|
|
62
67
|
})
|
|
63
68
|
|
|
64
69
|
this.#manager.on('config', config => {
|
|
@@ -80,19 +85,24 @@ export class NextStackable extends BaseStackable {
|
|
|
80
85
|
/* c8 ignore next 5 */
|
|
81
86
|
async getWatchConfig () {
|
|
82
87
|
return {
|
|
83
|
-
enabled: false
|
|
88
|
+
enabled: false
|
|
84
89
|
}
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
getMeta () {
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
const deploy = this.configManager.current.deploy
|
|
94
|
+
let composer
|
|
95
|
+
|
|
96
|
+
if (this.url) {
|
|
97
|
+
composer = {
|
|
90
98
|
tcp: true,
|
|
91
99
|
url: this.url,
|
|
92
100
|
prefix: this.#basePath,
|
|
93
|
-
wantsAbsoluteUrls: true
|
|
94
|
-
}
|
|
101
|
+
wantsAbsoluteUrls: true
|
|
102
|
+
}
|
|
95
103
|
}
|
|
104
|
+
|
|
105
|
+
return { deploy, composer }
|
|
96
106
|
}
|
|
97
107
|
|
|
98
108
|
async #startNext (nextRoot, serverOptions) {
|
|
@@ -113,12 +123,14 @@ function transformConfig () {
|
|
|
113
123
|
if (typeof this.current.watch !== 'object') {
|
|
114
124
|
this.current.watch = { enabled: this.current.watch || false }
|
|
115
125
|
}
|
|
126
|
+
|
|
127
|
+
basicTransformConfig.call(this)
|
|
116
128
|
}
|
|
117
129
|
|
|
118
130
|
export async function buildStackable (opts) {
|
|
119
131
|
const root = opts.context.directory
|
|
120
132
|
|
|
121
|
-
const configManager = new ConfigManager({ schema, source: opts.config ?? {}, transformConfig })
|
|
133
|
+
const configManager = new ConfigManager({ schema, source: opts.config ?? {}, schemaOptions, transformConfig })
|
|
122
134
|
await configManager.parseAndValidate()
|
|
123
135
|
|
|
124
136
|
return new NextStackable(opts, root, configManager)
|
|
@@ -127,9 +139,10 @@ export async function buildStackable (opts) {
|
|
|
127
139
|
export default {
|
|
128
140
|
configType: 'next',
|
|
129
141
|
configManagerConfig: {
|
|
130
|
-
|
|
142
|
+
schemaOptions,
|
|
143
|
+
transformConfig
|
|
131
144
|
},
|
|
132
145
|
buildStackable,
|
|
133
146
|
schema,
|
|
134
|
-
version: packageJson.version
|
|
147
|
+
version: packageJson.version
|
|
135
148
|
}
|
package/lib/schema.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/next",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.7",
|
|
4
4
|
"description": "Platformatic Next.js Stackable",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -20,22 +20,22 @@
|
|
|
20
20
|
"@babel/traverse": "^7.25.3",
|
|
21
21
|
"@babel/types": "^7.25.2",
|
|
22
22
|
"semver": "^7.6.3",
|
|
23
|
-
"@platformatic/basic": "2.0.0-alpha.
|
|
24
|
-
"@platformatic/
|
|
25
|
-
"@platformatic/
|
|
23
|
+
"@platformatic/basic": "2.0.0-alpha.7",
|
|
24
|
+
"@platformatic/config": "2.0.0-alpha.7",
|
|
25
|
+
"@platformatic/utils": "2.0.0-alpha.7"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"borp": "^0.17.0",
|
|
29
29
|
"eslint": "9",
|
|
30
|
+
"json-schema-to-typescript": "^15.0.1",
|
|
30
31
|
"neostandard": "^0.11.1",
|
|
31
32
|
"next": "^14.2.5",
|
|
32
33
|
"react": "^18.3.1",
|
|
33
34
|
"react-dom": "^18.3.1",
|
|
34
|
-
"json-schema-to-typescript": "^15.0.0",
|
|
35
35
|
"typescript": "^5.5.4",
|
|
36
36
|
"ws": "^8.18.0",
|
|
37
|
-
"@platformatic/composer": "2.0.0-alpha.
|
|
38
|
-
"@platformatic/service": "2.0.0-alpha.
|
|
37
|
+
"@platformatic/composer": "2.0.0-alpha.7",
|
|
38
|
+
"@platformatic/service": "2.0.0-alpha.7"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"test": "npm run lint && borp --concurrency=1 --timeout=180000",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/next/2.0.0-alpha.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/next/2.0.0-alpha.7.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Next.js Stackable",
|
|
5
5
|
"type": "object",
|
|
@@ -500,6 +500,33 @@
|
|
|
500
500
|
}
|
|
501
501
|
},
|
|
502
502
|
"additionalProperties": false
|
|
503
|
+
},
|
|
504
|
+
"deploy": {
|
|
505
|
+
"type": "object",
|
|
506
|
+
"properties": {
|
|
507
|
+
"include": {
|
|
508
|
+
"type": "array",
|
|
509
|
+
"items": {
|
|
510
|
+
"type": "string"
|
|
511
|
+
},
|
|
512
|
+
"default": [
|
|
513
|
+
"dist"
|
|
514
|
+
]
|
|
515
|
+
},
|
|
516
|
+
"buildCommand": {
|
|
517
|
+
"type": "string",
|
|
518
|
+
"default": "npm run build"
|
|
519
|
+
},
|
|
520
|
+
"installCommand": {
|
|
521
|
+
"type": "string",
|
|
522
|
+
"default": "npm ci --omit-dev"
|
|
523
|
+
},
|
|
524
|
+
"startCommand": {
|
|
525
|
+
"type": "string",
|
|
526
|
+
"default": "npm run start"
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
"default": {}
|
|
503
530
|
}
|
|
504
531
|
},
|
|
505
532
|
"additionalProperties": false
|
package/test/index.test.js
CHANGED
|
@@ -123,6 +123,7 @@ test('can detect and start a Next application with working React Server Componen
|
|
|
123
123
|
await verifyJSONViaHTTP(url, '/plugin', 200, { ok: true })
|
|
124
124
|
await verifyJSONViaHTTP(url, '/frontend/plugin', 200, { ok: true })
|
|
125
125
|
await verifyJSONViaHTTP(url, '/service/direct', 200, { ok: true })
|
|
126
|
+
await verifyJSONViaHTTP(url, '/service/mesh', 200, { ok: true })
|
|
126
127
|
|
|
127
128
|
await verifyJSONViaInject(runtime, 'main', 'GET', 'plugin', 200, { ok: true })
|
|
128
129
|
await verifyJSONViaInject(runtime, 'main', 'GET', '/frontend/plugin', 200, { ok: true })
|