@platformatic/runtime 0.46.1 → 0.47.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/fixtures/typescript/.env +4 -0
- package/fixtures/typescript-custom-flags/.env +4 -0
- package/fixtures/typescript-custom-flags/services/movies/platformatic.db.json +1 -1
- package/fixtures/typescript-custom-flags/services/movies/tsconfig.json +1 -2
- package/lib/compile.js +6 -2
- package/package.json +9 -9
- package/test/api.test.js +0 -356
- package/test/app.test.js +0 -358
- package/test/cli/compile-2.test.mjs +0 -69
- package/test/cli/compile.test.mjs +0 -104
- package/test/cli/helper.mjs +0 -68
- package/test/cli/start.test.mjs +0 -131
- package/test/cli/validations.test.mjs +0 -53
- package/test/cli/watch.test.mjs +0 -309
- package/test/config.test.js +0 -230
- package/test/schema.test.js +0 -13
- package/test/start.test.js +0 -187
- package/test/telemetry.test.js +0 -37
- package/test/unified-api.test.js +0 -255
package/test/unified-api.test.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
const assert = require('node:assert')
|
|
3
|
-
const { spawn } = require('node:child_process')
|
|
4
|
-
const { once } = require('node:events')
|
|
5
|
-
const { join } = require('node:path')
|
|
6
|
-
const { test } = require('node:test')
|
|
7
|
-
const {
|
|
8
|
-
buildServer,
|
|
9
|
-
loadConfig
|
|
10
|
-
} = require('..')
|
|
11
|
-
const fixturesDir = join(__dirname, '..', 'fixtures')
|
|
12
|
-
|
|
13
|
-
test('loadConfig()', async (t) => {
|
|
14
|
-
await t.test('can explicitly provide config type', async () => {
|
|
15
|
-
const configFile = join(fixturesDir, 'monorepo', 'serviceAppWithLogger', 'platformatic.service.json')
|
|
16
|
-
const config = await loadConfig({}, ['-c', configFile], undefined, 'service')
|
|
17
|
-
|
|
18
|
-
assert.strictEqual(config.args.config, configFile)
|
|
19
|
-
assert.strictEqual(config.configManager.fullPath, configFile)
|
|
20
|
-
assert.strictEqual(config.configManager.current.server.logger.name, 'service-with-logger')
|
|
21
|
-
assert.strictEqual(config.configManager.schemaOptions.useDefaults, true)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
await t.test('can load a platformatic service project', async () => {
|
|
25
|
-
const configFile = join(fixturesDir, 'monorepo', 'serviceAppWithLogger', 'platformatic.service.json')
|
|
26
|
-
const config = await loadConfig({}, ['-c', configFile])
|
|
27
|
-
|
|
28
|
-
assert.strictEqual(config.args.config, configFile)
|
|
29
|
-
assert.strictEqual(config.configManager.fullPath, configFile)
|
|
30
|
-
assert.strictEqual(config.configManager.current.server.logger.name, 'service-with-logger')
|
|
31
|
-
assert.strictEqual(config.configManager.schemaOptions.useDefaults, true)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
await t.test('can load a platformatic db project', async () => {
|
|
35
|
-
const configFile = join(fixturesDir, 'dbApp', 'platformatic.db.json')
|
|
36
|
-
const config = await loadConfig({}, ['-c', configFile])
|
|
37
|
-
|
|
38
|
-
assert.strictEqual(config.args.config, configFile)
|
|
39
|
-
assert.strictEqual(config.configManager.fullPath, configFile)
|
|
40
|
-
assert.strictEqual(config.configManager.current.db.graphql, true)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
await t.test('can load a platformatic composer project', async () => {
|
|
44
|
-
const configFile = join(fixturesDir, 'composerApp', 'platformatic.composer.json')
|
|
45
|
-
const config = await loadConfig({}, ['-c', configFile])
|
|
46
|
-
|
|
47
|
-
assert.strictEqual(config.args.config, configFile)
|
|
48
|
-
assert.strictEqual(config.configManager.fullPath, configFile)
|
|
49
|
-
assert.strictEqual(config.configManager.current.composer.refreshTimeout, 1000)
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
await t.test('can load a platformatic runtime project', async () => {
|
|
53
|
-
const configFile = join(fixturesDir, 'configs', 'monorepo.json')
|
|
54
|
-
const config = await loadConfig({}, ['-c', configFile])
|
|
55
|
-
|
|
56
|
-
assert.strictEqual(config.args.config, configFile)
|
|
57
|
-
assert.strictEqual(config.configManager.fullPath, configFile)
|
|
58
|
-
assert.strictEqual(config.configManager.current.entrypoint, 'serviceApp')
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
test('buildServer()', async (t) => {
|
|
63
|
-
await t.test('can build a service server', async (t) => {
|
|
64
|
-
const configFile = join(fixturesDir, 'monorepo', 'serviceAppWithLogger', 'platformatic.service.json')
|
|
65
|
-
const config = await loadConfig({}, ['-c', configFile])
|
|
66
|
-
const server = await buildServer({
|
|
67
|
-
app: config.app,
|
|
68
|
-
...config.configManager.current
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
t.after(async () => {
|
|
72
|
-
await server.close()
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
const address = await server.start()
|
|
76
|
-
// The address should be a valid URL.
|
|
77
|
-
new URL(address) // eslint-disable-line no-new
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
await t.test('can build a db server', async (t) => {
|
|
81
|
-
const configFile = join(fixturesDir, 'dbApp', 'platformatic.db.json')
|
|
82
|
-
const config = await loadConfig({}, ['-c', configFile])
|
|
83
|
-
const server = await buildServer({
|
|
84
|
-
app: config.app,
|
|
85
|
-
...config.configManager.current
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
t.after(async () => {
|
|
89
|
-
await server.close()
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
const address = await server.start()
|
|
93
|
-
// The address should be a valid URL.
|
|
94
|
-
new URL(address) // eslint-disable-line no-new
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
await t.test('can build a composer server', async (t) => {
|
|
98
|
-
const configFile = join(fixturesDir, 'composerApp', 'platformatic.composer.json')
|
|
99
|
-
const config = await loadConfig({}, ['-c', configFile])
|
|
100
|
-
const server = await buildServer({
|
|
101
|
-
app: config.app,
|
|
102
|
-
...config.configManager.current
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
t.after(async () => {
|
|
106
|
-
await server.close()
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
const address = await server.start()
|
|
110
|
-
// The address should be a valid URL.
|
|
111
|
-
new URL(address) // eslint-disable-line no-new
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
await t.test('can build a runtime application', async (t) => {
|
|
115
|
-
const configFile = join(fixturesDir, 'configs', 'monorepo.json')
|
|
116
|
-
const config = await loadConfig({}, ['-c', configFile])
|
|
117
|
-
const server = await buildServer({
|
|
118
|
-
app: config.app,
|
|
119
|
-
...config.configManager.current
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
t.after(async () => {
|
|
123
|
-
await server.close()
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
const address = await server.start()
|
|
127
|
-
// The address should be a valid URL.
|
|
128
|
-
new URL(address) // eslint-disable-line no-new
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
await t.test('input can be a filename', async (t) => {
|
|
132
|
-
const configFile = join(fixturesDir, 'monorepo', 'serviceAppWithLogger', 'platformatic.service.json')
|
|
133
|
-
const server = await buildServer(configFile)
|
|
134
|
-
|
|
135
|
-
t.after(async () => {
|
|
136
|
-
await server.close()
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
const address = await server.start()
|
|
140
|
-
|
|
141
|
-
assert.strictEqual(server.platformatic.configManager.fullPath, configFile)
|
|
142
|
-
|
|
143
|
-
// The address should be a valid URL.
|
|
144
|
-
new URL(address) // eslint-disable-line no-new
|
|
145
|
-
})
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
test('start()', async (t) => {
|
|
149
|
-
await t.test('can start a service server', async (t) => {
|
|
150
|
-
const scriptFile = join(fixturesDir, 'starter.js')
|
|
151
|
-
const configFile = join(fixturesDir, 'monorepo', 'serviceAppWithLogger', 'platformatic.service.json')
|
|
152
|
-
const child = spawn(process.execPath, [scriptFile, configFile])
|
|
153
|
-
child.stderr.pipe(process.stderr)
|
|
154
|
-
const [exitCode] = await once(child, 'exit')
|
|
155
|
-
|
|
156
|
-
assert.strictEqual(exitCode, 42)
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
await t.test('can start a db server', async (t) => {
|
|
160
|
-
const scriptFile = join(fixturesDir, 'starter.js')
|
|
161
|
-
const configFile = join(fixturesDir, 'dbApp', 'platformatic.db.json')
|
|
162
|
-
const child = spawn(process.execPath, [scriptFile, configFile])
|
|
163
|
-
const [exitCode] = await once(child, 'exit')
|
|
164
|
-
|
|
165
|
-
assert.strictEqual(exitCode, 42)
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
await t.test('can start a composer server', async () => {
|
|
169
|
-
const scriptFile = join(fixturesDir, 'starter.js')
|
|
170
|
-
const configFile = join(fixturesDir, 'composerApp', 'platformatic.composer.json')
|
|
171
|
-
const child = spawn(process.execPath, [scriptFile, configFile])
|
|
172
|
-
const [exitCode] = await once(child, 'exit')
|
|
173
|
-
|
|
174
|
-
assert.strictEqual(exitCode, 42)
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
await t.test('can start a runtime application', async () => {
|
|
178
|
-
const scriptFile = join(fixturesDir, 'starter.js')
|
|
179
|
-
const configFile = join(fixturesDir, 'configs', 'monorepo.json')
|
|
180
|
-
const child = spawn(process.execPath, [scriptFile, configFile])
|
|
181
|
-
const [exitCode] = await once(child, 'exit')
|
|
182
|
-
|
|
183
|
-
assert.strictEqual(exitCode, 42)
|
|
184
|
-
})
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
test('startCommand()', async (t) => {
|
|
188
|
-
await t.test('can start a server', async (t) => {
|
|
189
|
-
const scriptFile = join(fixturesDir, 'start-command.js')
|
|
190
|
-
const configFile = join(fixturesDir, 'monorepo', 'serviceAppWithLogger', 'platformatic.service.json')
|
|
191
|
-
const child = spawn(process.execPath, [scriptFile, configFile])
|
|
192
|
-
child.stderr.pipe(process.stderr)
|
|
193
|
-
const [exitCode] = await once(child, 'exit')
|
|
194
|
-
|
|
195
|
-
assert.strictEqual(exitCode, 42)
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
await t.test('exits on error', async (t) => {
|
|
199
|
-
const scriptFile = join(fixturesDir, 'start-command.js')
|
|
200
|
-
const configFile = join(fixturesDir, 'serviceApp', 'platformatic.not-found.json')
|
|
201
|
-
const child = spawn(process.execPath, [scriptFile, configFile])
|
|
202
|
-
const [exitCode] = await once(child, 'exit')
|
|
203
|
-
|
|
204
|
-
assert.strictEqual(exitCode, 1)
|
|
205
|
-
})
|
|
206
|
-
|
|
207
|
-
await t.test('can start a runtime application', async (t) => {
|
|
208
|
-
const scriptFile = join(fixturesDir, 'start-command.js')
|
|
209
|
-
const configFile = join(fixturesDir, 'configs', 'monorepo.json')
|
|
210
|
-
const child = spawn(process.execPath, [scriptFile, configFile])
|
|
211
|
-
child.stderr.pipe(process.stderr)
|
|
212
|
-
const [exitCode] = await once(child, 'exit')
|
|
213
|
-
|
|
214
|
-
assert.strictEqual(exitCode, 42)
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
await t.test('can start a non-runtime application', async (t) => {
|
|
218
|
-
const scriptFile = join(fixturesDir, 'start-command-in-runtime.js')
|
|
219
|
-
const configFile = join(fixturesDir, 'monorepo', 'serviceAppWithLogger', 'platformatic.service.json')
|
|
220
|
-
const child = spawn(process.execPath, [scriptFile, configFile])
|
|
221
|
-
child.stderr.pipe(process.stderr)
|
|
222
|
-
const [exitCode] = await once(child, 'exit')
|
|
223
|
-
|
|
224
|
-
assert.strictEqual(exitCode, 42)
|
|
225
|
-
})
|
|
226
|
-
|
|
227
|
-
await t.test('can start a runtime application', async (t) => {
|
|
228
|
-
const scriptFile = join(fixturesDir, 'start-command-in-runtime.js')
|
|
229
|
-
const configFile = join(fixturesDir, 'configs', 'monorepo.json')
|
|
230
|
-
const child = spawn(process.execPath, [scriptFile, configFile])
|
|
231
|
-
child.stderr.pipe(process.stderr)
|
|
232
|
-
const [exitCode] = await once(child, 'exit')
|
|
233
|
-
|
|
234
|
-
assert.strictEqual(exitCode, 42)
|
|
235
|
-
})
|
|
236
|
-
|
|
237
|
-
await t.test('exits on error', async (t) => {
|
|
238
|
-
const scriptFile = join(fixturesDir, 'start-command-in-runtime.js')
|
|
239
|
-
const configFile = join(fixturesDir, 'serviceApp', 'platformatic.not-found.json')
|
|
240
|
-
const child = spawn(process.execPath, [scriptFile, configFile])
|
|
241
|
-
const [exitCode] = await once(child, 'exit')
|
|
242
|
-
|
|
243
|
-
assert.strictEqual(exitCode, 1)
|
|
244
|
-
})
|
|
245
|
-
|
|
246
|
-
await t.test('can start an application with external clients', async (t) => {
|
|
247
|
-
const scriptFile = join(fixturesDir, 'start-command-in-runtime.js')
|
|
248
|
-
const configFile = join(fixturesDir, 'external-client', 'platformatic.service.json')
|
|
249
|
-
const child = spawn(process.execPath, [scriptFile, configFile])
|
|
250
|
-
child.stderr.pipe(process.stderr)
|
|
251
|
-
const [exitCode] = await once(child, 'exit')
|
|
252
|
-
|
|
253
|
-
assert.strictEqual(exitCode, 42)
|
|
254
|
-
})
|
|
255
|
-
})
|