@platformatic/service 0.26.1 → 0.27.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/lib/compile.js +16 -14
- package/lib/gen-schema.js +1 -0
- package/lib/plugins/openapi.js +1 -0
- package/lib/plugins/typescript.js +2 -2
- package/lib/root-endpoint/public/index.html +12 -2
- package/lib/start.js +0 -3
- package/lib/utils.js +8 -0
- package/package.json +16 -16
- package/test/cli/helper.mjs +3 -2
- package/test/fixtures/nested-directories/modules/inventory/routes/product.js +0 -1
- package/test/utils.test.js +7 -0
package/lib/compile.js
CHANGED
|
@@ -28,16 +28,18 @@ async function getTSCExecutablePath (cwd) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
async function setup (cwd, config) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
async function setup (cwd, config, logger) {
|
|
32
|
+
if (!logger) {
|
|
33
|
+
logger = pino(
|
|
34
|
+
pretty({
|
|
35
|
+
translateTime: 'SYS:HH:MM:ss',
|
|
36
|
+
ignore: 'hostname,pid'
|
|
37
|
+
})
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
if (config?.server.logger) {
|
|
41
|
+
logger.level = config.server.logger.level
|
|
42
|
+
}
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
const { execa } = await import('execa')
|
|
@@ -60,8 +62,8 @@ async function setup (cwd, config) {
|
|
|
60
62
|
return { execa, logger, tscExecutablePath }
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
async function compile (cwd, config) {
|
|
64
|
-
const { execa, logger, tscExecutablePath } = await setup(cwd, config)
|
|
65
|
+
async function compile (cwd, config, originalLogger) {
|
|
66
|
+
const { execa, logger, tscExecutablePath } = await setup(cwd, config, originalLogger)
|
|
65
67
|
/* c8 ignore next 3 */
|
|
66
68
|
if (!tscExecutablePath) {
|
|
67
69
|
return false
|
|
@@ -80,8 +82,8 @@ async function compile (cwd, config) {
|
|
|
80
82
|
// This path is tested but C8 does not see it that way given it needs to work
|
|
81
83
|
// through execa.
|
|
82
84
|
/* c8 ignore next 20 */
|
|
83
|
-
async function compileWatch (cwd, config) {
|
|
84
|
-
const { execa, logger, tscExecutablePath } = await setup(cwd, config)
|
|
85
|
+
async function compileWatch (cwd, config, originalLogger) {
|
|
86
|
+
const { execa, logger, tscExecutablePath } = await setup(cwd, config, originalLogger)
|
|
85
87
|
if (!tscExecutablePath) {
|
|
86
88
|
return false
|
|
87
89
|
}
|
package/lib/gen-schema.js
CHANGED
package/lib/plugins/openapi.js
CHANGED
|
@@ -23,13 +23,13 @@ async function setupTsCompiler (app) {
|
|
|
23
23
|
let tsCompilerWatcher = persistentRef.tsCompilerWatcher
|
|
24
24
|
if (!tsCompilerWatcher) {
|
|
25
25
|
/* c8 ignore next 5 */
|
|
26
|
-
const { child } = await compiler.compileWatch(workingDir, config)
|
|
26
|
+
const { child } = await compiler.compileWatch(workingDir, config, app.log)
|
|
27
27
|
app.log.debug('start watching typescript files')
|
|
28
28
|
tsCompilerWatcher = child
|
|
29
29
|
}
|
|
30
30
|
app.decorate('tsCompilerWatcher', tsCompilerWatcher)
|
|
31
31
|
} else {
|
|
32
|
-
await compiler.compile(workingDir, config)
|
|
32
|
+
await compiler.compile(workingDir, config, app.log)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
app.addHook('onClose', async () => {
|
|
@@ -94,8 +94,18 @@
|
|
|
94
94
|
<img height="256" src="logo-512x512.png"/>
|
|
95
95
|
<h1>Welcome to Platformatic Service</h1>
|
|
96
96
|
<h2><a href="https://oss.platformatic.dev" target="_blank">Documentation</a></h2>
|
|
97
|
-
<h2><a
|
|
98
|
-
<h2><a
|
|
97
|
+
<h2><a id="openapi-link" target="_blank">OpenAPI Documentation</a></h2>
|
|
98
|
+
<h2><a id="graphql-link" target="_blank">GraphiQL</a></h2>
|
|
99
99
|
</div>
|
|
100
|
+
|
|
101
|
+
<script>
|
|
102
|
+
const currentPath = window.location.pathname
|
|
103
|
+
|
|
104
|
+
const openApiLink = document.getElementById('openapi-link')
|
|
105
|
+
openApiLink.href = currentPath + 'documentation/static/index.html'
|
|
106
|
+
|
|
107
|
+
const graphqlLink = document.getElementById('graphql-link')
|
|
108
|
+
graphqlLink.href = currentPath + 'graphiql'
|
|
109
|
+
</script>
|
|
100
110
|
</body>
|
|
101
111
|
</html>
|
package/lib/start.js
CHANGED
|
@@ -136,10 +136,7 @@ async function start (appType, _args) {
|
|
|
136
136
|
try {
|
|
137
137
|
// Set the location of the config
|
|
138
138
|
app = await buildServer({ ...config, configManager }, appType)
|
|
139
|
-
|
|
140
139
|
await app.start()
|
|
141
|
-
// TODO: this log is used in the start command. Should be replaced
|
|
142
|
-
app.log.info({ url: app.url })
|
|
143
140
|
} catch (err) {
|
|
144
141
|
// TODO route this to a logger
|
|
145
142
|
console.error(err)
|
package/lib/utils.js
CHANGED
|
@@ -39,6 +39,13 @@ function getJSPluginPath (workingDir, tsPluginPath, compileDir) {
|
|
|
39
39
|
return tsPluginPath
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
if (tsPluginPath.indexOf(compileDir) === 0) {
|
|
43
|
+
// In this case, we passed through this function before and we have adjusted
|
|
44
|
+
// the path of the plugin to point to the dist/ folder. Then we restarted.
|
|
45
|
+
// Therefore, we can just return the path as is.
|
|
46
|
+
return tsPluginPath
|
|
47
|
+
}
|
|
48
|
+
|
|
42
49
|
const isTs = tsPluginPath.endsWith('ts')
|
|
43
50
|
let newBaseName
|
|
44
51
|
|
|
@@ -55,6 +62,7 @@ function getJSPluginPath (workingDir, tsPluginPath, compileDir) {
|
|
|
55
62
|
dirname(tsPluginRelativePath),
|
|
56
63
|
newBaseName
|
|
57
64
|
)
|
|
65
|
+
|
|
58
66
|
return join(compileDir, jsPluginRelativePath)
|
|
59
67
|
}
|
|
60
68
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -20,30 +20,30 @@
|
|
|
20
20
|
"@fastify/aws-lambda": "^3.2.0",
|
|
21
21
|
"@matteo.collina/worker": "^3.1.0",
|
|
22
22
|
"bindings": "^1.5.0",
|
|
23
|
-
"c8": "^
|
|
23
|
+
"c8": "^8.0.0",
|
|
24
24
|
"self-cert": "^2.0.0",
|
|
25
25
|
"snazzy": "^9.0.0",
|
|
26
26
|
"split2": "^4.2.0",
|
|
27
|
-
"standard": "^17.
|
|
28
|
-
"strip-ansi": "^7.0
|
|
29
|
-
"tap": "^16.3.
|
|
27
|
+
"standard": "^17.1.0",
|
|
28
|
+
"strip-ansi": "^7.1.0",
|
|
29
|
+
"tap": "^16.3.6",
|
|
30
30
|
"tsd": "^0.28.1",
|
|
31
|
-
"typescript": "^5.
|
|
31
|
+
"typescript": "^5.1.3",
|
|
32
32
|
"undici": "^5.22.1",
|
|
33
33
|
"vscode-json-languageservice": "^5.3.5",
|
|
34
34
|
"why-is-node-running": "^2.2.2",
|
|
35
|
-
"yaml": "^2.
|
|
35
|
+
"yaml": "^2.3.1"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@fastify/accepts": "^4.
|
|
38
|
+
"@fastify/accepts": "^4.2.0",
|
|
39
39
|
"@fastify/autoload": "^5.7.1",
|
|
40
40
|
"@fastify/basic-auth": "^5.0.0",
|
|
41
|
-
"@fastify/cors": "^8.
|
|
41
|
+
"@fastify/cors": "^8.3.0",
|
|
42
42
|
"@fastify/deepmerge": "^1.3.0",
|
|
43
43
|
"@fastify/restartable": "^2.1.0",
|
|
44
|
-
"@fastify/static": "^6.10.
|
|
44
|
+
"@fastify/static": "^6.10.2",
|
|
45
45
|
"@fastify/swagger": "^8.5.1",
|
|
46
|
-
"@fastify/swagger-ui": "^1.
|
|
46
|
+
"@fastify/swagger-ui": "^1.9.0",
|
|
47
47
|
"@fastify/under-pressure": "^8.2.0",
|
|
48
48
|
"@mercuriusjs/federation": "^2.0.0",
|
|
49
49
|
"close-with-grace": "^1.2.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"env-schema": "^5.2.0",
|
|
53
53
|
"es-main": "^1.2.0",
|
|
54
54
|
"execa": "^7.1.1",
|
|
55
|
-
"fastify": "^4.
|
|
55
|
+
"fastify": "^4.18.0",
|
|
56
56
|
"fastify-metrics": "^10.3.0",
|
|
57
57
|
"fastify-plugin": "^4.5.0",
|
|
58
58
|
"fastify-sandbox": "^0.13.1",
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"pino-pretty": "^10.0.0",
|
|
65
65
|
"rfdc": "^1.3.0",
|
|
66
66
|
"ua-parser-js": "^1.0.35",
|
|
67
|
-
"@platformatic/client": "0.
|
|
68
|
-
"@platformatic/
|
|
69
|
-
"@platformatic/
|
|
70
|
-
"@platformatic/utils": "0.
|
|
67
|
+
"@platformatic/client": "0.27.0",
|
|
68
|
+
"@platformatic/config": "0.27.0",
|
|
69
|
+
"@platformatic/swagger-ui-theme": "0.27.0",
|
|
70
|
+
"@platformatic/utils": "0.27.0"
|
|
71
71
|
},
|
|
72
72
|
"standard": {
|
|
73
73
|
"ignore": [
|
package/test/cli/helper.mjs
CHANGED
|
@@ -41,8 +41,9 @@ export async function start (commandOpts, exacaOpts = {}) {
|
|
|
41
41
|
|
|
42
42
|
for await (const messages of on(output, 'data')) {
|
|
43
43
|
for (const message of messages) {
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
44
|
+
const text = message.msg
|
|
45
|
+
if (text && text.includes('Server listening at')) {
|
|
46
|
+
const url = text.match(/Server listening at (.*)/)[1]
|
|
46
47
|
clearTimeout(errorTimeout)
|
|
47
48
|
return { child, url, output }
|
|
48
49
|
}
|
package/test/utils.test.js
CHANGED
|
@@ -28,3 +28,10 @@ test('isFileAccessible no dir', async (t) => {
|
|
|
28
28
|
const file = resolve(join(__dirname, '..', 'fixtures', 'hello', 'platformatic.service.json'))
|
|
29
29
|
t.equal(await isFileAccessible(file), true)
|
|
30
30
|
})
|
|
31
|
+
|
|
32
|
+
test('should return the same plugin folder if it\'s already the compiled one', (t) => {
|
|
33
|
+
t.plan(1)
|
|
34
|
+
|
|
35
|
+
const result = getJSPluginPath('/something', '/something/dist/plugins', '/something/dist')
|
|
36
|
+
t.equal(result, '/something/dist/plugins')
|
|
37
|
+
})
|