@platformatic/basic 2.0.0-alpha.4 → 2.0.0-alpha.6
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/NOTICE +13 -0
- package/README.md +13 -0
- package/config.d.ts +1 -149
- package/index.js +78 -88
- package/lib/base.js +13 -9
- package/lib/schema.js +26 -33
- package/lib/utils.js +1 -5
- package/lib/worker/child-manager.js +21 -6
- package/lib/worker/child-process.js +66 -0
- package/package.json +6 -13
- package/schema.json +2 -512
- package/test/helper.js +43 -13
- package/lib/next.js +0 -105
- package/lib/server.js +0 -134
- package/lib/vite.js +0 -105
- package/lib/worker/next-loader.js +0 -137
- package/test/express.test.js +0 -34
- package/test/fastify.test.js +0 -34
- package/test/fixtures/express/no-build/index.js +0 -16
- package/test/fixtures/express/no-build/package.json +0 -7
- package/test/fixtures/express/no-build/platformatic.app.json +0 -3
- package/test/fixtures/express/no-build/platformatic.as-entrypoint.runtime.json +0 -19
- package/test/fixtures/express/no-build/platformatic.no-entrypoint.runtime.json +0 -16
- package/test/fixtures/express/with-build/index.js +0 -17
- package/test/fixtures/express/with-build/package.json +0 -7
- package/test/fixtures/express/with-build/platformatic.app.json +0 -3
- package/test/fixtures/express/with-build/platformatic.as-entrypoint.runtime.json +0 -19
- package/test/fixtures/express/with-build/platformatic.no-entrypoint.runtime.json +0 -16
- package/test/fixtures/fastify/no-build/index.js +0 -14
- package/test/fixtures/fastify/no-build/package.json +0 -7
- package/test/fixtures/fastify/no-build/platformatic.app.json +0 -3
- package/test/fixtures/fastify/no-build/platformatic.as-entrypoint.runtime.json +0 -19
- package/test/fixtures/fastify/no-build/platformatic.no-entrypoint.runtime.json +0 -16
- package/test/fixtures/fastify/with-build/index.js +0 -15
- package/test/fixtures/fastify/with-build/package.json +0 -7
- package/test/fixtures/fastify/with-build/platformatic.app.json +0 -3
- package/test/fixtures/fastify/with-build/platformatic.as-entrypoint.runtime.json +0 -19
- package/test/fixtures/fastify/with-build/platformatic.no-entrypoint.runtime.json +0 -16
- package/test/fixtures/next/composer-autodetect-prefix/next.config.mjs +0 -5
- package/test/fixtures/next/composer-autodetect-prefix/package.json +0 -15
- package/test/fixtures/next/composer-autodetect-prefix/platformatic.application.json +0 -8
- package/test/fixtures/next/composer-autodetect-prefix/platformatic.runtime.json +0 -21
- package/test/fixtures/next/composer-autodetect-prefix/src/app/layout.js +0 -7
- package/test/fixtures/next/composer-autodetect-prefix/src/app/page.js +0 -5
- package/test/fixtures/next/composer-with-prefix/next.config.js +0 -1
- package/test/fixtures/next/composer-with-prefix/package.json +0 -15
- package/test/fixtures/next/composer-with-prefix/platformatic.application.json +0 -11
- package/test/fixtures/next/composer-with-prefix/platformatic.runtime.json +0 -21
- package/test/fixtures/next/composer-with-prefix/src/app/layout.js +0 -7
- package/test/fixtures/next/composer-with-prefix/src/app/page.js +0 -5
- package/test/fixtures/next/composer-without-prefix/next.config.mjs +0 -3
- package/test/fixtures/next/composer-without-prefix/package.json +0 -15
- package/test/fixtures/next/composer-without-prefix/platformatic.application.json +0 -8
- package/test/fixtures/next/composer-without-prefix/platformatic.runtime.json +0 -21
- package/test/fixtures/next/composer-without-prefix/src/app/layout.js +0 -7
- package/test/fixtures/next/composer-without-prefix/src/app/page.js +0 -5
- package/test/fixtures/next/standalone/next.config.mjs +0 -3
- package/test/fixtures/next/standalone/package.json +0 -15
- package/test/fixtures/next/standalone/platformatic.runtime.json +0 -18
- package/test/fixtures/next/standalone/src/app/layout.js +0 -7
- package/test/fixtures/next/standalone/src/app/page.js +0 -5
- package/test/fixtures/nodejs/no-build/index.js +0 -21
- package/test/fixtures/nodejs/no-build/package.json +0 -7
- package/test/fixtures/nodejs/no-build/platformatic.app.json +0 -3
- package/test/fixtures/nodejs/no-build/platformatic.as-entrypoint.runtime.json +0 -19
- package/test/fixtures/nodejs/no-build/platformatic.no-entrypoint.runtime.json +0 -16
- package/test/fixtures/nodejs/no-configuration/index.js +0 -21
- package/test/fixtures/nodejs/no-configuration/platformatic.as-entrypoint.runtime.json +0 -18
- package/test/fixtures/nodejs/no-configuration/platformatic.no-entrypoint.runtime.json +0 -16
- package/test/fixtures/nodejs/with-build/index.js +0 -20
- package/test/fixtures/nodejs/with-build/package.json +0 -7
- package/test/fixtures/nodejs/with-build/platformatic.app.json +0 -3
- package/test/fixtures/nodejs/with-build/platformatic.as-entrypoint.runtime.json +0 -19
- package/test/fixtures/nodejs/with-build/platformatic.no-entrypoint.runtime.json +0 -16
- package/test/fixtures/platformatic-composer/platformatic.composer.json +0 -20
- package/test/fixtures/platformatic-composer/platformatic.no-prefix.composer.json +0 -23
- package/test/fixtures/platformatic-composer/plugin.js +0 -9
- package/test/fixtures/platformatic-service/platformatic.service.json +0 -15
- package/test/fixtures/platformatic-service/plugin.js +0 -12
- package/test/fixtures/vite/composer-autodetect-prefix/custom.vite.config.js +0 -3
- package/test/fixtures/vite/composer-autodetect-prefix/index.html +0 -13
- package/test/fixtures/vite/composer-autodetect-prefix/main.js +0 -3
- package/test/fixtures/vite/composer-autodetect-prefix/package.json +0 -14
- package/test/fixtures/vite/composer-autodetect-prefix/platformatic.application.json +0 -11
- package/test/fixtures/vite/composer-autodetect-prefix/platformatic.runtime.json +0 -21
- package/test/fixtures/vite/composer-with-prefix/index.html +0 -13
- package/test/fixtures/vite/composer-with-prefix/main.js +0 -3
- package/test/fixtures/vite/composer-with-prefix/package.json +0 -14
- package/test/fixtures/vite/composer-with-prefix/platformatic.application.json +0 -11
- package/test/fixtures/vite/composer-with-prefix/platformatic.runtime.json +0 -21
- package/test/fixtures/vite/composer-without-prefix/index.html +0 -13
- package/test/fixtures/vite/composer-without-prefix/main.js +0 -3
- package/test/fixtures/vite/composer-without-prefix/package.json +0 -14
- package/test/fixtures/vite/composer-without-prefix/platformatic.application.json +0 -8
- package/test/fixtures/vite/composer-without-prefix/platformatic.runtime.json +0 -21
- package/test/fixtures/vite/standalone/custom.vite.config.js +0 -3
- package/test/fixtures/vite/standalone/index.html +0 -13
- package/test/fixtures/vite/standalone/main.js +0 -3
- package/test/fixtures/vite/standalone/package.json +0 -14
- package/test/fixtures/vite/standalone/platformatic.runtime.json +0 -18
- package/test/next.test.js +0 -85
- package/test/node.test.js +0 -66
- package/test/vite.test.js +0 -89
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.platformatic.dev/@platformatic/composer/1.52.0.json",
|
|
3
|
-
"composer": {
|
|
4
|
-
"services": [
|
|
5
|
-
{
|
|
6
|
-
"id": "frontend",
|
|
7
|
-
"proxy": {
|
|
8
|
-
"prefix": ""
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"id": "service"
|
|
13
|
-
}
|
|
14
|
-
]
|
|
15
|
-
},
|
|
16
|
-
"plugins": {
|
|
17
|
-
"paths": [
|
|
18
|
-
{
|
|
19
|
-
"path": "./plugin.js"
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Vite App</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="app"></div>
|
|
11
|
-
<script type="module" src="/main.js"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
|
|
3
|
-
"entrypoint": "main",
|
|
4
|
-
"watch": false,
|
|
5
|
-
"managementApi": false,
|
|
6
|
-
"metrics": false,
|
|
7
|
-
"server": {
|
|
8
|
-
"logger": {
|
|
9
|
-
"level": "error"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"services": [
|
|
13
|
-
{
|
|
14
|
-
"id": "frontend",
|
|
15
|
-
"path": ".",
|
|
16
|
-
"config": "platformatic.application.json"
|
|
17
|
-
},
|
|
18
|
-
{ "id": "service", "config": "platformatic.service.json", "path": "../../platformatic-service" },
|
|
19
|
-
{ "id": "main", "config": "platformatic.no-prefix.composer.json", "path": "../../platformatic-composer" }
|
|
20
|
-
]
|
|
21
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Vite App</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="app"></div>
|
|
11
|
-
<script type="module" src="/main.js"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
|
|
3
|
-
"entrypoint": "main",
|
|
4
|
-
"watch": false,
|
|
5
|
-
"managementApi": false,
|
|
6
|
-
"metrics": false,
|
|
7
|
-
"server": {
|
|
8
|
-
"logger": {
|
|
9
|
-
"level": "error"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"services": [
|
|
13
|
-
{
|
|
14
|
-
"id": "frontend",
|
|
15
|
-
"path": ".",
|
|
16
|
-
"config": "platformatic.application.json"
|
|
17
|
-
},
|
|
18
|
-
{ "id": "service", "config": "platformatic.service.json", "path": "../../platformatic-service" },
|
|
19
|
-
{ "id": "main", "config": "platformatic.composer.json", "path": "../../platformatic-composer" }
|
|
20
|
-
]
|
|
21
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Vite App</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="app"></div>
|
|
11
|
-
<script type="module" src="/main.js"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
|
|
3
|
-
"entrypoint": "main",
|
|
4
|
-
"watch": false,
|
|
5
|
-
"managementApi": false,
|
|
6
|
-
"metrics": false,
|
|
7
|
-
"server": {
|
|
8
|
-
"logger": {
|
|
9
|
-
"level": "error"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"services": [
|
|
13
|
-
{
|
|
14
|
-
"id": "frontend",
|
|
15
|
-
"path": ".",
|
|
16
|
-
"config": "platformatic.application.json"
|
|
17
|
-
},
|
|
18
|
-
{ "id": "service", "config": "platformatic.service.json", "path": "../../platformatic-service" },
|
|
19
|
-
{ "id": "main", "config": "platformatic.no-prefix.composer.json", "path": "../../platformatic-composer" }
|
|
20
|
-
]
|
|
21
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Vite App</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="app"></div>
|
|
11
|
-
<script type="module" src="/main.js"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
|
|
3
|
-
"entrypoint": "main",
|
|
4
|
-
"watch": false,
|
|
5
|
-
"managementApi": false,
|
|
6
|
-
"metrics": false,
|
|
7
|
-
"server": {
|
|
8
|
-
"logger": {
|
|
9
|
-
"level": "error"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"services": [
|
|
13
|
-
{
|
|
14
|
-
"id": "main",
|
|
15
|
-
"path": "."
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
}
|
package/test/next.test.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { test } from 'node:test'
|
|
2
|
-
import {
|
|
3
|
-
createRuntime,
|
|
4
|
-
updateHMRVersion,
|
|
5
|
-
verifyHMR,
|
|
6
|
-
verifyHTMLViaHTTP,
|
|
7
|
-
verifyHTMLViaInject,
|
|
8
|
-
verifyJSONViaHTTP,
|
|
9
|
-
verifyJSONViaInject,
|
|
10
|
-
} from './helper.js'
|
|
11
|
-
|
|
12
|
-
function websocketHMRHandler (message, resolveConnection, resolveReload) {
|
|
13
|
-
switch (message.action) {
|
|
14
|
-
case 'sync':
|
|
15
|
-
resolveConnection()
|
|
16
|
-
break
|
|
17
|
-
case 'serverComponentChanges':
|
|
18
|
-
resolveReload()
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
test('can detect and start a Next application', async t => {
|
|
23
|
-
const versionFile = await updateHMRVersion()
|
|
24
|
-
const { url } = await createRuntime(t, 'next/standalone/platformatic.runtime.json')
|
|
25
|
-
|
|
26
|
-
await verifyHTMLViaHTTP(url, '/', ['<script src="/_next/static/chunks/main-app.js'])
|
|
27
|
-
await verifyHMR(url, '/_next/webpack-hmr', versionFile, undefined, websocketHMRHandler)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
test('can detect and start a Next application when exposed in a composer with a prefix', async t => {
|
|
31
|
-
const versionFile = await updateHMRVersion()
|
|
32
|
-
const { runtime, url } = await createRuntime(t, 'next/composer-with-prefix/platformatic.runtime.json')
|
|
33
|
-
|
|
34
|
-
const htmlContents = ['<script src="/frontend/_next/static/chunks/main-app.js']
|
|
35
|
-
|
|
36
|
-
await verifyHTMLViaHTTP(url, '/frontend/', htmlContents)
|
|
37
|
-
await verifyHTMLViaInject(runtime, 'main', '/frontend', htmlContents)
|
|
38
|
-
await verifyHMR(url, '/frontend/_next/webpack-hmr', versionFile, undefined, websocketHMRHandler)
|
|
39
|
-
|
|
40
|
-
await verifyJSONViaHTTP(url, '/plugin', 200, { ok: true })
|
|
41
|
-
await verifyJSONViaHTTP(url, '/frontend/plugin', 200, { ok: true })
|
|
42
|
-
await verifyJSONViaHTTP(url, '/service/direct', 200, { ok: true })
|
|
43
|
-
|
|
44
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', 'plugin', 200, { ok: true })
|
|
45
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/frontend/plugin', 200, { ok: true })
|
|
46
|
-
await verifyJSONViaInject(runtime, 'service', 'GET', '/direct', 200, { ok: true })
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
test('can detect and start a Next application when exposed in a composer without a prefix', async t => {
|
|
50
|
-
const versionFile = await updateHMRVersion()
|
|
51
|
-
const { runtime, url } = await createRuntime(t, 'next/composer-without-prefix/platformatic.runtime.json')
|
|
52
|
-
|
|
53
|
-
const htmlContents = ['<script src="/_next/static/chunks/main-app.js']
|
|
54
|
-
|
|
55
|
-
await verifyHTMLViaHTTP(url, '/', htmlContents)
|
|
56
|
-
await verifyHTMLViaInject(runtime, 'main', '/', htmlContents)
|
|
57
|
-
await verifyHMR(url, '/_next/webpack-hmr', versionFile, undefined, websocketHMRHandler)
|
|
58
|
-
|
|
59
|
-
await verifyJSONViaHTTP(url, '/plugin', 200, { ok: true })
|
|
60
|
-
await verifyJSONViaHTTP(url, '/frontend/plugin', 200, { ok: true })
|
|
61
|
-
await verifyJSONViaHTTP(url, '/service/direct', 200, { ok: true })
|
|
62
|
-
|
|
63
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', 'plugin', 200, { ok: true })
|
|
64
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/frontend/plugin', 200, { ok: true })
|
|
65
|
-
await verifyJSONViaInject(runtime, 'service', 'GET', '/direct', 200, { ok: true })
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
test('can detect and start a Next application when exposed in a composer with a custom config and by autodetecting the prefix', async t => {
|
|
69
|
-
const versionFile = await updateHMRVersion()
|
|
70
|
-
const { runtime, url } = await createRuntime(t, 'next/composer-autodetect-prefix/platformatic.runtime.json')
|
|
71
|
-
|
|
72
|
-
const htmlContents = ['<script src="/nested/base/dir/_next/static/chunks/main-app.js']
|
|
73
|
-
|
|
74
|
-
await verifyHTMLViaHTTP(url, '/nested/base/dir/', htmlContents)
|
|
75
|
-
await verifyHTMLViaInject(runtime, 'main', '/nested/base/dir', htmlContents)
|
|
76
|
-
await verifyHMR(url, '/nested/base/dir/_next/webpack-hmr', versionFile, undefined, websocketHMRHandler)
|
|
77
|
-
|
|
78
|
-
await verifyJSONViaHTTP(url, '/plugin', 200, { ok: true })
|
|
79
|
-
await verifyJSONViaHTTP(url, '/frontend/plugin', 200, { ok: true })
|
|
80
|
-
await verifyJSONViaHTTP(url, '/service/direct', 200, { ok: true })
|
|
81
|
-
|
|
82
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', 'plugin', 200, { ok: true })
|
|
83
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/frontend/plugin', 200, { ok: true })
|
|
84
|
-
await verifyJSONViaInject(runtime, 'service', 'GET', '/direct', 200, { ok: true })
|
|
85
|
-
})
|
package/test/node.test.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { deepStrictEqual, ifError } from 'node:assert'
|
|
2
|
-
import { test } from 'node:test'
|
|
3
|
-
import { createRuntime, getLogs, verifyJSONViaHTTP, verifyJSONViaInject } from './helper.js'
|
|
4
|
-
|
|
5
|
-
test('can detect and start a Node.js application with no configuration files', async t => {
|
|
6
|
-
const { runtime, url } = await createRuntime(t, 'nodejs/no-configuration/platformatic.as-entrypoint.runtime.json')
|
|
7
|
-
|
|
8
|
-
await verifyJSONViaHTTP(url, '/direct', 200, { ok: true })
|
|
9
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/direct', 200, { ok: true })
|
|
10
|
-
|
|
11
|
-
const logs = await getLogs(runtime)
|
|
12
|
-
deepStrictEqual(
|
|
13
|
-
logs.map(m => m.msg),
|
|
14
|
-
['The service main had no valid entrypoint defined in the package.json file. Falling back to the file index.js.']
|
|
15
|
-
)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('can detect and start a Node.js application with no configuration files and when not the entrypoint', async t => {
|
|
19
|
-
const { runtime, url } = await createRuntime(t, 'nodejs/no-configuration/platformatic.no-entrypoint.runtime.json')
|
|
20
|
-
|
|
21
|
-
await verifyJSONViaHTTP(url, '/mesh', 200, { ok: true })
|
|
22
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/mesh', 200, { ok: true })
|
|
23
|
-
|
|
24
|
-
const logs = await getLogs(runtime)
|
|
25
|
-
|
|
26
|
-
deepStrictEqual(
|
|
27
|
-
logs.map(m => m.msg),
|
|
28
|
-
[
|
|
29
|
-
'The service internal had no valid entrypoint defined in the package.json file. Falling back to the file index.js.',
|
|
30
|
-
]
|
|
31
|
-
)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
test('can detect and start a Node.js application with no build function defined', async t => {
|
|
35
|
-
const { runtime, url } = await createRuntime(t, 'nodejs/no-build/platformatic.as-entrypoint.runtime.json')
|
|
36
|
-
|
|
37
|
-
await verifyJSONViaHTTP(url, '/direct', 200, { ok: true })
|
|
38
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/direct', 200, { ok: true })
|
|
39
|
-
|
|
40
|
-
const logs = await getLogs(runtime)
|
|
41
|
-
deepStrictEqual(logs, [])
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
test('can detect and start a Node.js application with no build function and when not the entrypoint', async t => {
|
|
45
|
-
const { runtime, url } = await createRuntime(t, 'nodejs/no-build/platformatic.no-entrypoint.runtime.json')
|
|
46
|
-
|
|
47
|
-
await verifyJSONViaHTTP(url, '/mesh', 200, { ok: true })
|
|
48
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/mesh', 200, { ok: true })
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
test('can detect and start a Node.js application with build function defined', async t => {
|
|
52
|
-
const { runtime, url } = await createRuntime(t, 'nodejs/with-build/platformatic.as-entrypoint.runtime.json')
|
|
53
|
-
|
|
54
|
-
await verifyJSONViaHTTP(url, '/direct', 200, { ok: true })
|
|
55
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/direct', 200, { ok: true })
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
test('can detect and start a Node.js application with build function defined and when not the entrypoint', async t => {
|
|
59
|
-
const { runtime, url } = await createRuntime(t, 'nodejs/no-build/platformatic.no-entrypoint.runtime.json')
|
|
60
|
-
|
|
61
|
-
await verifyJSONViaHTTP(url, '/mesh', 200, { ok: true })
|
|
62
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/mesh', 200, { ok: true })
|
|
63
|
-
|
|
64
|
-
const details = await runtime.getServiceDetails('internal')
|
|
65
|
-
ifError(details.url)
|
|
66
|
-
})
|
package/test/vite.test.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { test } from 'node:test'
|
|
4
|
-
import {
|
|
5
|
-
createRuntime,
|
|
6
|
-
updateHMRVersion,
|
|
7
|
-
verifyHMR,
|
|
8
|
-
verifyHTMLViaHTTP,
|
|
9
|
-
verifyHTMLViaInject,
|
|
10
|
-
verifyJSONViaHTTP,
|
|
11
|
-
verifyJSONViaInject,
|
|
12
|
-
} from './helper.js'
|
|
13
|
-
|
|
14
|
-
function websocketHMRHandler (message, resolveConnection, resolveReload) {
|
|
15
|
-
switch (message.type) {
|
|
16
|
-
case 'connected':
|
|
17
|
-
resolveConnection()
|
|
18
|
-
break
|
|
19
|
-
case 'full-reload':
|
|
20
|
-
resolveReload()
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
test('can detect and start a Vite application', async t => {
|
|
25
|
-
const versionFile = await updateHMRVersion()
|
|
26
|
-
const { url } = await createRuntime(t, 'vite/standalone/platformatic.runtime.json')
|
|
27
|
-
|
|
28
|
-
const htmlContents = ['<title>Vite App</title>', '<script type="module" src="/main.js"></script>']
|
|
29
|
-
|
|
30
|
-
await verifyHTMLViaHTTP(url, '/', htmlContents)
|
|
31
|
-
await verifyHMR(url, '/', versionFile, 'vite-hmr', websocketHMRHandler)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
test('can detect and start a Vite application when exposed in a composer with a prefix', async t => {
|
|
35
|
-
const versionFile = await updateHMRVersion()
|
|
36
|
-
const { runtime, url } = await createRuntime(t, 'vite/composer-with-prefix/platformatic.runtime.json')
|
|
37
|
-
|
|
38
|
-
const htmlContents = ['<title>Vite App</title>', '<script type="module" src="/frontend/main.js"></script>']
|
|
39
|
-
|
|
40
|
-
await verifyHTMLViaHTTP(url, '/frontend/', htmlContents)
|
|
41
|
-
await verifyHTMLViaInject(runtime, 'main', '/frontend', htmlContents)
|
|
42
|
-
await verifyHMR(url, '/frontend/', versionFile, 'vite-hmr', websocketHMRHandler)
|
|
43
|
-
|
|
44
|
-
await verifyJSONViaHTTP(url, '/plugin', 200, { ok: true })
|
|
45
|
-
await verifyJSONViaHTTP(url, '/frontend/plugin', 200, { ok: true })
|
|
46
|
-
await verifyJSONViaHTTP(url, '/service/direct', 200, { ok: true })
|
|
47
|
-
|
|
48
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', 'plugin', 200, { ok: true })
|
|
49
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/frontend/plugin', 200, { ok: true })
|
|
50
|
-
await verifyJSONViaInject(runtime, 'service', 'GET', '/direct', 200, { ok: true })
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
test('can detect and start a Vite application when exposed in a composer without a prefix', async t => {
|
|
54
|
-
const versionFile = await updateHMRVersion()
|
|
55
|
-
const { runtime, url } = await createRuntime(t, 'vite/composer-without-prefix/platformatic.runtime.json')
|
|
56
|
-
|
|
57
|
-
const htmlContents = ['<title>Vite App</title>', '<script type="module" src="/main.js"></script>']
|
|
58
|
-
|
|
59
|
-
await verifyHTMLViaHTTP(url, '/', htmlContents)
|
|
60
|
-
await verifyHTMLViaInject(runtime, 'main', '/', htmlContents)
|
|
61
|
-
await verifyHMR(url, '/', versionFile, 'vite-hmr', websocketHMRHandler)
|
|
62
|
-
|
|
63
|
-
await verifyJSONViaHTTP(url, '/plugin', 200, { ok: true })
|
|
64
|
-
await verifyJSONViaHTTP(url, '/frontend/plugin', 200, { ok: true })
|
|
65
|
-
await verifyJSONViaHTTP(url, '/service/direct', 200, { ok: true })
|
|
66
|
-
|
|
67
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', 'plugin', 200, { ok: true })
|
|
68
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/frontend/plugin', 200, { ok: true })
|
|
69
|
-
await verifyJSONViaInject(runtime, 'service', 'GET', '/direct', 200, { ok: true })
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
test('can detect and start a Vite application when exposed in a composer with a custom config and by autodetecting the prefix', async t => {
|
|
73
|
-
const versionFile = await updateHMRVersion()
|
|
74
|
-
const { runtime, url } = await createRuntime(t, 'vite/composer-autodetect-prefix/platformatic.runtime.json')
|
|
75
|
-
|
|
76
|
-
const htmlContents = ['<title>Vite App</title>', '<script type="module" src="/nested/base/dir/main.js"></script>']
|
|
77
|
-
|
|
78
|
-
await verifyHTMLViaHTTP(url, '/nested/base/dir/', htmlContents)
|
|
79
|
-
await verifyHTMLViaInject(runtime, 'main', '/nested/base/dir', htmlContents)
|
|
80
|
-
await verifyHMR(url, '/nested/base/dir/', versionFile, 'vite-hmr', websocketHMRHandler)
|
|
81
|
-
|
|
82
|
-
await verifyJSONViaHTTP(url, '/plugin', 200, { ok: true })
|
|
83
|
-
await verifyJSONViaHTTP(url, '/frontend/plugin', 200, { ok: true })
|
|
84
|
-
await verifyJSONViaHTTP(url, '/service/direct', 200, { ok: true })
|
|
85
|
-
|
|
86
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', 'plugin', 200, { ok: true })
|
|
87
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/frontend/plugin', 200, { ok: true })
|
|
88
|
-
await verifyJSONViaInject(runtime, 'service', 'GET', '/direct', 200, { ok: true })
|
|
89
|
-
})
|