@platformatic/basic 2.0.0-alpha.4 → 2.0.0-alpha.5

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.
Files changed (103) hide show
  1. package/NOTICE +13 -0
  2. package/README.md +13 -0
  3. package/config.d.ts +1 -149
  4. package/index.js +60 -87
  5. package/lib/base.js +4 -4
  6. package/lib/schema.js +26 -33
  7. package/lib/utils.js +1 -5
  8. package/lib/worker/child-manager.js +12 -0
  9. package/lib/worker/child-process.js +66 -0
  10. package/package.json +6 -13
  11. package/schema.json +2 -512
  12. package/test/helper.js +38 -9
  13. package/lib/next.js +0 -105
  14. package/lib/server.js +0 -134
  15. package/lib/vite.js +0 -105
  16. package/lib/worker/next-loader.js +0 -137
  17. package/test/express.test.js +0 -34
  18. package/test/fastify.test.js +0 -34
  19. package/test/fixtures/express/no-build/index.js +0 -16
  20. package/test/fixtures/express/no-build/package.json +0 -7
  21. package/test/fixtures/express/no-build/platformatic.app.json +0 -3
  22. package/test/fixtures/express/no-build/platformatic.as-entrypoint.runtime.json +0 -19
  23. package/test/fixtures/express/no-build/platformatic.no-entrypoint.runtime.json +0 -16
  24. package/test/fixtures/express/with-build/index.js +0 -17
  25. package/test/fixtures/express/with-build/package.json +0 -7
  26. package/test/fixtures/express/with-build/platformatic.app.json +0 -3
  27. package/test/fixtures/express/with-build/platformatic.as-entrypoint.runtime.json +0 -19
  28. package/test/fixtures/express/with-build/platformatic.no-entrypoint.runtime.json +0 -16
  29. package/test/fixtures/fastify/no-build/index.js +0 -14
  30. package/test/fixtures/fastify/no-build/package.json +0 -7
  31. package/test/fixtures/fastify/no-build/platformatic.app.json +0 -3
  32. package/test/fixtures/fastify/no-build/platformatic.as-entrypoint.runtime.json +0 -19
  33. package/test/fixtures/fastify/no-build/platformatic.no-entrypoint.runtime.json +0 -16
  34. package/test/fixtures/fastify/with-build/index.js +0 -15
  35. package/test/fixtures/fastify/with-build/package.json +0 -7
  36. package/test/fixtures/fastify/with-build/platformatic.app.json +0 -3
  37. package/test/fixtures/fastify/with-build/platformatic.as-entrypoint.runtime.json +0 -19
  38. package/test/fixtures/fastify/with-build/platformatic.no-entrypoint.runtime.json +0 -16
  39. package/test/fixtures/next/composer-autodetect-prefix/next.config.mjs +0 -5
  40. package/test/fixtures/next/composer-autodetect-prefix/package.json +0 -15
  41. package/test/fixtures/next/composer-autodetect-prefix/platformatic.application.json +0 -8
  42. package/test/fixtures/next/composer-autodetect-prefix/platformatic.runtime.json +0 -21
  43. package/test/fixtures/next/composer-autodetect-prefix/src/app/layout.js +0 -7
  44. package/test/fixtures/next/composer-autodetect-prefix/src/app/page.js +0 -5
  45. package/test/fixtures/next/composer-with-prefix/next.config.js +0 -1
  46. package/test/fixtures/next/composer-with-prefix/package.json +0 -15
  47. package/test/fixtures/next/composer-with-prefix/platformatic.application.json +0 -11
  48. package/test/fixtures/next/composer-with-prefix/platformatic.runtime.json +0 -21
  49. package/test/fixtures/next/composer-with-prefix/src/app/layout.js +0 -7
  50. package/test/fixtures/next/composer-with-prefix/src/app/page.js +0 -5
  51. package/test/fixtures/next/composer-without-prefix/next.config.mjs +0 -3
  52. package/test/fixtures/next/composer-without-prefix/package.json +0 -15
  53. package/test/fixtures/next/composer-without-prefix/platformatic.application.json +0 -8
  54. package/test/fixtures/next/composer-without-prefix/platformatic.runtime.json +0 -21
  55. package/test/fixtures/next/composer-without-prefix/src/app/layout.js +0 -7
  56. package/test/fixtures/next/composer-without-prefix/src/app/page.js +0 -5
  57. package/test/fixtures/next/standalone/next.config.mjs +0 -3
  58. package/test/fixtures/next/standalone/package.json +0 -15
  59. package/test/fixtures/next/standalone/platformatic.runtime.json +0 -18
  60. package/test/fixtures/next/standalone/src/app/layout.js +0 -7
  61. package/test/fixtures/next/standalone/src/app/page.js +0 -5
  62. package/test/fixtures/nodejs/no-build/index.js +0 -21
  63. package/test/fixtures/nodejs/no-build/package.json +0 -7
  64. package/test/fixtures/nodejs/no-build/platformatic.app.json +0 -3
  65. package/test/fixtures/nodejs/no-build/platformatic.as-entrypoint.runtime.json +0 -19
  66. package/test/fixtures/nodejs/no-build/platformatic.no-entrypoint.runtime.json +0 -16
  67. package/test/fixtures/nodejs/no-configuration/index.js +0 -21
  68. package/test/fixtures/nodejs/no-configuration/platformatic.as-entrypoint.runtime.json +0 -18
  69. package/test/fixtures/nodejs/no-configuration/platformatic.no-entrypoint.runtime.json +0 -16
  70. package/test/fixtures/nodejs/with-build/index.js +0 -20
  71. package/test/fixtures/nodejs/with-build/package.json +0 -7
  72. package/test/fixtures/nodejs/with-build/platformatic.app.json +0 -3
  73. package/test/fixtures/nodejs/with-build/platformatic.as-entrypoint.runtime.json +0 -19
  74. package/test/fixtures/nodejs/with-build/platformatic.no-entrypoint.runtime.json +0 -16
  75. package/test/fixtures/platformatic-composer/platformatic.composer.json +0 -20
  76. package/test/fixtures/platformatic-composer/platformatic.no-prefix.composer.json +0 -23
  77. package/test/fixtures/platformatic-composer/plugin.js +0 -9
  78. package/test/fixtures/platformatic-service/platformatic.service.json +0 -15
  79. package/test/fixtures/platformatic-service/plugin.js +0 -12
  80. package/test/fixtures/vite/composer-autodetect-prefix/custom.vite.config.js +0 -3
  81. package/test/fixtures/vite/composer-autodetect-prefix/index.html +0 -13
  82. package/test/fixtures/vite/composer-autodetect-prefix/main.js +0 -3
  83. package/test/fixtures/vite/composer-autodetect-prefix/package.json +0 -14
  84. package/test/fixtures/vite/composer-autodetect-prefix/platformatic.application.json +0 -11
  85. package/test/fixtures/vite/composer-autodetect-prefix/platformatic.runtime.json +0 -21
  86. package/test/fixtures/vite/composer-with-prefix/index.html +0 -13
  87. package/test/fixtures/vite/composer-with-prefix/main.js +0 -3
  88. package/test/fixtures/vite/composer-with-prefix/package.json +0 -14
  89. package/test/fixtures/vite/composer-with-prefix/platformatic.application.json +0 -11
  90. package/test/fixtures/vite/composer-with-prefix/platformatic.runtime.json +0 -21
  91. package/test/fixtures/vite/composer-without-prefix/index.html +0 -13
  92. package/test/fixtures/vite/composer-without-prefix/main.js +0 -3
  93. package/test/fixtures/vite/composer-without-prefix/package.json +0 -14
  94. package/test/fixtures/vite/composer-without-prefix/platformatic.application.json +0 -8
  95. package/test/fixtures/vite/composer-without-prefix/platformatic.runtime.json +0 -21
  96. package/test/fixtures/vite/standalone/custom.vite.config.js +0 -3
  97. package/test/fixtures/vite/standalone/index.html +0 -13
  98. package/test/fixtures/vite/standalone/main.js +0 -3
  99. package/test/fixtures/vite/standalone/package.json +0 -14
  100. package/test/fixtures/vite/standalone/platformatic.runtime.json +0 -18
  101. package/test/next.test.js +0 -85
  102. package/test/node.test.js +0 -66
  103. 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,9 +0,0 @@
1
- export default async function (app) {
2
- app.get('/plugin', async () => {
3
- return { ok: true }
4
- })
5
-
6
- app.get('/frontend/plugin', async () => {
7
- return { ok: true }
8
- })
9
- }
@@ -1,15 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/service/1.52.0.json",
3
- "server": {
4
- "logger": {
5
- "level": "error"
6
- }
7
- },
8
- "plugins": {
9
- "paths": [
10
- {
11
- "path": "./plugin.js"
12
- }
13
- ]
14
- }
15
- }
@@ -1,12 +0,0 @@
1
- 'use strict'
2
-
3
- export default async function (app) {
4
- app.get('/mesh', async () => {
5
- const response = await fetch('http://internal.plt.local/direct')
6
- return response.json()
7
- })
8
-
9
- app.get('/direct', async () => {
10
- return { ok: true }
11
- })
12
- }
@@ -1,3 +0,0 @@
1
- export default {
2
- base: '/nested/base/dir',
3
- }
@@ -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,3 +0,0 @@
1
- import { version } from '../../../tmp/version.js'
2
-
3
- document.querySelector('#app').innerHTML = `<div>Hello from ${version}</div>`
@@ -1,14 +0,0 @@
1
- {
2
- "name": "vite",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "vite build",
9
- "preview": "vite preview"
10
- },
11
- "devDependencies": {
12
- "vite": "^5.3.4"
13
- }
14
- }
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/basic/1.52.0.json",
3
- "server": {
4
- "logger": {
5
- "level": "error"
6
- }
7
- },
8
- "vite": {
9
- "configFile": "custom.vite.config.js"
10
- }
11
- }
@@ -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,3 +0,0 @@
1
- import { version } from '../../../tmp/version.js'
2
-
3
- document.querySelector('#app').innerHTML = `<div>Hello from ${version}</div>`
@@ -1,14 +0,0 @@
1
- {
2
- "name": "vite",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "vite build",
9
- "preview": "vite preview"
10
- },
11
- "devDependencies": {
12
- "vite": "^5.3.4"
13
- }
14
- }
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/basic/1.52.0.json",
3
- "server": {
4
- "logger": {
5
- "level": "error"
6
- }
7
- },
8
- "application": {
9
- "base": "/frontend"
10
- }
11
- }
@@ -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,3 +0,0 @@
1
- import { version } from '../../../tmp/version.js'
2
-
3
- document.querySelector('#app').innerHTML = `<div>Hello from ${version}</div>`
@@ -1,14 +0,0 @@
1
- {
2
- "name": "vite",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "vite build",
9
- "preview": "vite preview"
10
- },
11
- "devDependencies": {
12
- "vite": "^5.3.4"
13
- }
14
- }
@@ -1,8 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/basic/1.52.0.json",
3
- "server": {
4
- "logger": {
5
- "level": "error"
6
- }
7
- }
8
- }
@@ -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,3 +0,0 @@
1
- export default {
2
- base: '/nested/base/dir',
3
- }
@@ -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,3 +0,0 @@
1
- import { version } from '../../../tmp/version.js'
2
-
3
- document.querySelector('#app').innerHTML = `<div>Hello from ${version}</div>`
@@ -1,14 +0,0 @@
1
- {
2
- "name": "vite",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "vite build",
9
- "preview": "vite preview"
10
- },
11
- "devDependencies": {
12
- "vite": "^5.3.4"
13
- }
14
- }
@@ -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
- })