platformatic 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/package.json +12 -12
- package/fixtures/sqlite/migrations/001.do.sql +0 -4
- package/fixtures/sqlite/migrations/001.undo.sql +0 -1
- package/fixtures/sqlite/platformatic.db.json +0 -17
- package/test/deploy.test.js +0 -383
- package/test/fixtures/app-to-deploy/.env +0 -2
- package/test/fixtures/app-to-deploy/.secrets.env +0 -2
- package/test/fixtures/app-to-deploy/dynamic.txt +0 -2
- package/test/fixtures/app-to-deploy/package.json +0 -7
- package/test/fixtures/app-to-deploy/platformatic.db.json +0 -18
- package/test/fixtures/app-to-deploy/static.txt +0 -2
- package/test/fixtures/app-to-deploy/wrong.txt +0 -2
- package/test/fixtures/platformatic.runtime.json +0 -11
- package/test/fixtures/platformatic.service.json +0 -13
- package/test/fixtures/v0.16.0.db.json +0 -41
- package/test/gh.test.js +0 -92
- package/test/helper.js +0 -61
- package/test/platformatic.test.js +0 -189
- package/test/start.test.js +0 -84
- package/test/upgrade.test.js +0 -45
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "platformatic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "Platformatic CLI",
|
|
5
5
|
"main": "cli.js",
|
|
6
6
|
"type": "module",
|
|
@@ -48,17 +48,17 @@
|
|
|
48
48
|
"minimist": "^1.2.8",
|
|
49
49
|
"pino": "^8.14.1",
|
|
50
50
|
"pino-pretty": "^10.0.0",
|
|
51
|
-
"@platformatic/authenticate": "0.
|
|
52
|
-
"@platformatic/client-cli": "0.
|
|
53
|
-
"@platformatic/composer": "0.
|
|
54
|
-
"@platformatic/config": "0.
|
|
55
|
-
"@platformatic/db": "0.
|
|
56
|
-
"@platformatic/deploy-client": "0.
|
|
57
|
-
"@platformatic/frontend-template": "0.
|
|
58
|
-
"@platformatic/metaconfig": "0.
|
|
59
|
-
"@platformatic/runtime": "0.
|
|
60
|
-
"@platformatic/service": "0.
|
|
61
|
-
"create-platformatic": "0.
|
|
51
|
+
"@platformatic/authenticate": "0.47.0",
|
|
52
|
+
"@platformatic/client-cli": "0.47.0",
|
|
53
|
+
"@platformatic/composer": "0.47.0",
|
|
54
|
+
"@platformatic/config": "0.47.0",
|
|
55
|
+
"@platformatic/db": "0.47.0",
|
|
56
|
+
"@platformatic/deploy-client": "0.47.0",
|
|
57
|
+
"@platformatic/frontend-template": "0.47.0",
|
|
58
|
+
"@platformatic/metaconfig": "0.47.0",
|
|
59
|
+
"@platformatic/runtime": "0.47.0",
|
|
60
|
+
"@platformatic/service": "0.47.0",
|
|
61
|
+
"create-platformatic": "0.47.0"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"test": "standard | snazzy && tap --no-coverage test/*.test.js",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
DROP TABLE graphs;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"server": {
|
|
3
|
-
"hostname": "127.0.0.1",
|
|
4
|
-
"port": 0,
|
|
5
|
-
"logger": {
|
|
6
|
-
"level": "info"
|
|
7
|
-
}
|
|
8
|
-
},
|
|
9
|
-
"db": {
|
|
10
|
-
"connectionString": "sqlite://./db"
|
|
11
|
-
},
|
|
12
|
-
"migrations": {
|
|
13
|
-
"dir": "./migrations",
|
|
14
|
-
"table": "versions",
|
|
15
|
-
"autoApply": true
|
|
16
|
-
}
|
|
17
|
-
}
|
package/test/deploy.test.js
DELETED
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
import { test } from 'tap'
|
|
2
|
-
import { join } from 'desm'
|
|
3
|
-
import { execa } from 'execa'
|
|
4
|
-
|
|
5
|
-
import { cliPath, startDeployService, startMachine } from './helper.js'
|
|
6
|
-
|
|
7
|
-
test('should deploy to a static workspace to the cloud', async (t) => {
|
|
8
|
-
const workspaceType = 'static'
|
|
9
|
-
const workspaceId = 'b3d7f7e0-8c03-11e8-9eb6-529269fb1459'
|
|
10
|
-
const workspaceKey = 'b3d7f7e08c0311e89eb6529269fb1459'
|
|
11
|
-
const pathToConfig = join(import.meta.url, './fixtures/app-to-deploy/platformatic.db.json')
|
|
12
|
-
|
|
13
|
-
const machineHost = await startMachine(t)
|
|
14
|
-
const deployServiceHost = await startDeployService(t, {
|
|
15
|
-
createBundleCallback: (request, reply) => {
|
|
16
|
-
t.equal(request.headers['x-platformatic-workspace-id'], workspaceId)
|
|
17
|
-
t.equal(request.headers['x-platformatic-api-key'], workspaceKey)
|
|
18
|
-
t.match(request.body, {
|
|
19
|
-
bundle: {
|
|
20
|
-
appType: 'db',
|
|
21
|
-
configPath: 'platformatic.db.json'
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
t.ok(request.body.bundle.checksum)
|
|
25
|
-
},
|
|
26
|
-
createDeploymentCallback: (request, reply) => {
|
|
27
|
-
t.equal(request.headers['x-platformatic-workspace-id'], workspaceId)
|
|
28
|
-
t.equal(request.headers['x-platformatic-api-key'], workspaceKey)
|
|
29
|
-
t.same(
|
|
30
|
-
request.body,
|
|
31
|
-
{
|
|
32
|
-
metadata: {
|
|
33
|
-
appType: 'db'
|
|
34
|
-
},
|
|
35
|
-
variables: {
|
|
36
|
-
PLT_ENV_VARIABLE1: 'platformatic_variable1',
|
|
37
|
-
PLT_ENV_VARIABLE2: 'platformatic_variable2'
|
|
38
|
-
},
|
|
39
|
-
secrets: {
|
|
40
|
-
PLT_SECRET_1: 'platformatic_secret_1',
|
|
41
|
-
PLT_SECRET_2: 'platformatic_secret_2'
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
)
|
|
45
|
-
reply.code(200).send({ entryPointUrl: machineHost })
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
await execa('node', [
|
|
50
|
-
cliPath, 'deploy',
|
|
51
|
-
'--type', workspaceType,
|
|
52
|
-
'--config', pathToConfig,
|
|
53
|
-
'--workspace-id', workspaceId,
|
|
54
|
-
'--workspace-key', workspaceKey,
|
|
55
|
-
'--deploy-service-host', deployServiceHost
|
|
56
|
-
])
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
test('should deploy to a dynamic workspace to the cloud', async (t) => {
|
|
60
|
-
const workspaceType = 'dynamic'
|
|
61
|
-
const workspaceId = 'b3d7f7e0-8c03-11e8-9eb6-529269fb1459'
|
|
62
|
-
const workspaceKey = 'b3d7f7e08c0311e89eb6529269fb1459'
|
|
63
|
-
const pathToConfig = join(import.meta.url, './fixtures/app-to-deploy/platformatic.db.json')
|
|
64
|
-
const label = 'cli:deploy-2'
|
|
65
|
-
|
|
66
|
-
const machineHost = await startMachine(t)
|
|
67
|
-
const deployServiceHost = await startDeployService(t, {
|
|
68
|
-
createBundleCallback: (request, reply) => {
|
|
69
|
-
t.equal(request.headers['x-platformatic-workspace-id'], workspaceId)
|
|
70
|
-
t.equal(request.headers['x-platformatic-api-key'], workspaceKey)
|
|
71
|
-
t.match(request.body, {
|
|
72
|
-
bundle: {
|
|
73
|
-
appType: 'db',
|
|
74
|
-
configPath: 'platformatic.db.json'
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
t.ok(request.body.bundle.checksum)
|
|
78
|
-
},
|
|
79
|
-
createDeploymentCallback: (request, reply) => {
|
|
80
|
-
t.equal(request.headers['x-platformatic-workspace-id'], workspaceId)
|
|
81
|
-
t.equal(request.headers['x-platformatic-api-key'], workspaceKey)
|
|
82
|
-
t.same(
|
|
83
|
-
request.body,
|
|
84
|
-
{
|
|
85
|
-
label,
|
|
86
|
-
metadata: {
|
|
87
|
-
appType: 'db'
|
|
88
|
-
},
|
|
89
|
-
variables: {
|
|
90
|
-
PLT_ENV_VARIABLE1: 'platformatic_variable1',
|
|
91
|
-
PLT_ENV_VARIABLE2: 'platformatic_variable2'
|
|
92
|
-
},
|
|
93
|
-
secrets: {
|
|
94
|
-
PLT_SECRET_1: 'platformatic_secret_1',
|
|
95
|
-
PLT_SECRET_2: 'platformatic_secret_2'
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
)
|
|
99
|
-
reply.code(200).send({ entryPointUrl: machineHost })
|
|
100
|
-
}
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
await execa('node', [
|
|
104
|
-
cliPath, 'deploy',
|
|
105
|
-
'--type', workspaceType,
|
|
106
|
-
'--label', label,
|
|
107
|
-
'--config', pathToConfig,
|
|
108
|
-
'--workspace-id', workspaceId,
|
|
109
|
-
'--workspace-key', workspaceKey,
|
|
110
|
-
'--deploy-service-host', deployServiceHost
|
|
111
|
-
])
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
test('should fail if workspace id is not a uuid', async (t) => {
|
|
115
|
-
const workspaceType = 'static'
|
|
116
|
-
const workspaceId = 'not-a-uuid'
|
|
117
|
-
const workspaceKey = 'b3d7f7e08c0311e89eb6529269fb1459'
|
|
118
|
-
const pathToConfig = join(import.meta.url, './fixtures/app-to-deploy/platformatic.db.json')
|
|
119
|
-
|
|
120
|
-
try {
|
|
121
|
-
await execa('node', [
|
|
122
|
-
cliPath, 'deploy',
|
|
123
|
-
'--type', workspaceType,
|
|
124
|
-
'--config', pathToConfig,
|
|
125
|
-
'--workspace-id', workspaceId,
|
|
126
|
-
'--workspace-key', workspaceKey,
|
|
127
|
-
'--deploy-service-host', 'http://localhost:5555'
|
|
128
|
-
])
|
|
129
|
-
t.fail('should have failed')
|
|
130
|
-
} catch (err) {
|
|
131
|
-
t.ok(err.message.includes('Invalid workspace id provided. Workspace id must be a valid uuid.'))
|
|
132
|
-
}
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
test('should fail if invalid workspace type provided', async (t) => {
|
|
136
|
-
const workspaceType = 'wrong'
|
|
137
|
-
const workspaceId = 'b3d7f7e0-8c03-11e8-9eb6-529269fb1459'
|
|
138
|
-
const workspaceKey = 'b3d7f7e08c0311e89eb6529269fb1459'
|
|
139
|
-
const pathToConfig = join(import.meta.url, './fixtures/app-to-deploy/platformatic.db.json')
|
|
140
|
-
|
|
141
|
-
try {
|
|
142
|
-
await execa('node', [
|
|
143
|
-
cliPath, 'deploy',
|
|
144
|
-
'--type', workspaceType,
|
|
145
|
-
'--config', pathToConfig,
|
|
146
|
-
'--workspace-id', workspaceId,
|
|
147
|
-
'--workspace-key', workspaceKey,
|
|
148
|
-
'--deploy-service-host', 'http://localhost:5555'
|
|
149
|
-
])
|
|
150
|
-
t.fail('should have failed')
|
|
151
|
-
} catch (err) {
|
|
152
|
-
t.ok(err.message.includes('Invalid workspace type provided'))
|
|
153
|
-
}
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
test('should deploy to a dynamic workspace to the cloud', async (t) => {
|
|
157
|
-
const workspaceType = 'dynamic'
|
|
158
|
-
const workspaceId = 'b3d7f7e0-8c03-11e8-9eb6-529269fb1459'
|
|
159
|
-
const workspaceKey = 'b3d7f7e08c0311e89eb6529269fb1459'
|
|
160
|
-
const pathToConfig = join(import.meta.url, './fixtures/app-to-deploy/platformatic.db.json')
|
|
161
|
-
const label = 'cli:deploy-2'
|
|
162
|
-
|
|
163
|
-
const machineHost = await startMachine(t)
|
|
164
|
-
const deployServiceHost = await startDeployService(t, {
|
|
165
|
-
createBundleCallback: (request, reply) => {
|
|
166
|
-
t.equal(request.headers['x-platformatic-workspace-id'], workspaceId)
|
|
167
|
-
t.equal(request.headers['x-platformatic-api-key'], workspaceKey)
|
|
168
|
-
t.match(request.body, {
|
|
169
|
-
bundle: {
|
|
170
|
-
appType: 'db',
|
|
171
|
-
configPath: 'platformatic.db.json'
|
|
172
|
-
}
|
|
173
|
-
})
|
|
174
|
-
t.ok(request.body.bundle.checksum)
|
|
175
|
-
},
|
|
176
|
-
createDeploymentCallback: (request, reply) => {
|
|
177
|
-
t.equal(request.headers['x-platformatic-workspace-id'], workspaceId)
|
|
178
|
-
t.equal(request.headers['x-platformatic-api-key'], workspaceKey)
|
|
179
|
-
t.same(
|
|
180
|
-
request.body,
|
|
181
|
-
{
|
|
182
|
-
label,
|
|
183
|
-
metadata: {
|
|
184
|
-
appType: 'db'
|
|
185
|
-
},
|
|
186
|
-
variables: {
|
|
187
|
-
PLT_ENV_VARIABLE1: 'platformatic_variable1',
|
|
188
|
-
PLT_ENV_VARIABLE2: 'platformatic_variable2'
|
|
189
|
-
},
|
|
190
|
-
secrets: {
|
|
191
|
-
PLT_SECRET_1: 'platformatic_secret_1',
|
|
192
|
-
PLT_SECRET_2: 'platformatic_secret_2'
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
)
|
|
196
|
-
reply.code(200).send({ entryPointUrl: machineHost })
|
|
197
|
-
}
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
await execa('node', [
|
|
201
|
-
cliPath, 'deploy',
|
|
202
|
-
'--type', workspaceType,
|
|
203
|
-
'--label', 'deploy-2',
|
|
204
|
-
'--config', pathToConfig,
|
|
205
|
-
'--workspace-id', workspaceId,
|
|
206
|
-
'--workspace-key', workspaceKey,
|
|
207
|
-
'--deploy-service-host', deployServiceHost
|
|
208
|
-
])
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
test('should deploy to a static workspace with a keys option', async (t) => {
|
|
212
|
-
const workspaceId = 'b3d7f7e0-8c03-11e8-9eb6-529269fb1459'
|
|
213
|
-
const workspaceKey = 'b3d7f7e08c0311e89eb6529269fb1459'
|
|
214
|
-
|
|
215
|
-
const pathToConfig = join(import.meta.url, './fixtures/app-to-deploy/platformatic.db.json')
|
|
216
|
-
const pathToKeys = join(import.meta.url, './fixtures/app-to-deploy/static.txt')
|
|
217
|
-
|
|
218
|
-
const machineHost = await startMachine(t)
|
|
219
|
-
const deployServiceHost = await startDeployService(t, {
|
|
220
|
-
createBundleCallback: (request, reply) => {
|
|
221
|
-
t.equal(request.headers['x-platformatic-workspace-id'], workspaceId)
|
|
222
|
-
t.equal(request.headers['x-platformatic-api-key'], workspaceKey)
|
|
223
|
-
t.match(request.body, {
|
|
224
|
-
bundle: {
|
|
225
|
-
appType: 'db',
|
|
226
|
-
configPath: 'platformatic.db.json'
|
|
227
|
-
}
|
|
228
|
-
})
|
|
229
|
-
t.ok(request.body.bundle.checksum)
|
|
230
|
-
},
|
|
231
|
-
createDeploymentCallback: (request, reply) => {
|
|
232
|
-
t.equal(request.headers['x-platformatic-workspace-id'], workspaceId)
|
|
233
|
-
t.equal(request.headers['x-platformatic-api-key'], workspaceKey)
|
|
234
|
-
t.same(
|
|
235
|
-
request.body,
|
|
236
|
-
{
|
|
237
|
-
metadata: {
|
|
238
|
-
appType: 'db'
|
|
239
|
-
},
|
|
240
|
-
variables: {
|
|
241
|
-
PLT_ENV_VARIABLE1: 'platformatic_variable1',
|
|
242
|
-
PLT_ENV_VARIABLE2: 'platformatic_variable2'
|
|
243
|
-
},
|
|
244
|
-
secrets: {
|
|
245
|
-
PLT_SECRET_1: 'platformatic_secret_1',
|
|
246
|
-
PLT_SECRET_2: 'platformatic_secret_2'
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
)
|
|
250
|
-
reply.code(200).send({ entryPointUrl: machineHost })
|
|
251
|
-
}
|
|
252
|
-
})
|
|
253
|
-
|
|
254
|
-
await execa('node', [
|
|
255
|
-
cliPath, 'deploy',
|
|
256
|
-
'--keys', pathToKeys,
|
|
257
|
-
'--config', pathToConfig,
|
|
258
|
-
'--deploy-service-host', deployServiceHost
|
|
259
|
-
])
|
|
260
|
-
})
|
|
261
|
-
|
|
262
|
-
test('should deploy to a static workspace with a keys option', async (t) => {
|
|
263
|
-
const workspaceId = 'b3d7f7e0-8c03-11e8-9eb6-529269fb1459'
|
|
264
|
-
const workspaceKey = 'b3d7f7e08c0311e89eb6529269fb1459'
|
|
265
|
-
|
|
266
|
-
const pathToConfig = join(import.meta.url, './fixtures/app-to-deploy/platformatic.db.json')
|
|
267
|
-
const pathToKeys = './static.txt'
|
|
268
|
-
|
|
269
|
-
const machineHost = await startMachine(t)
|
|
270
|
-
const deployServiceHost = await startDeployService(t, {
|
|
271
|
-
createBundleCallback: (request, reply) => {
|
|
272
|
-
t.equal(request.headers['x-platformatic-workspace-id'], workspaceId)
|
|
273
|
-
t.equal(request.headers['x-platformatic-api-key'], workspaceKey)
|
|
274
|
-
t.match(request.body, {
|
|
275
|
-
bundle: {
|
|
276
|
-
appType: 'db',
|
|
277
|
-
configPath: 'platformatic.db.json'
|
|
278
|
-
}
|
|
279
|
-
})
|
|
280
|
-
t.ok(request.body.bundle.checksum)
|
|
281
|
-
},
|
|
282
|
-
createDeploymentCallback: (request, reply) => {
|
|
283
|
-
t.equal(request.headers['x-platformatic-workspace-id'], workspaceId)
|
|
284
|
-
t.equal(request.headers['x-platformatic-api-key'], workspaceKey)
|
|
285
|
-
t.same(
|
|
286
|
-
request.body,
|
|
287
|
-
{
|
|
288
|
-
metadata: {
|
|
289
|
-
appType: 'db'
|
|
290
|
-
},
|
|
291
|
-
variables: {
|
|
292
|
-
PLT_ENV_VARIABLE1: 'platformatic_variable1',
|
|
293
|
-
PLT_ENV_VARIABLE2: 'platformatic_variable2'
|
|
294
|
-
},
|
|
295
|
-
secrets: {
|
|
296
|
-
PLT_SECRET_1: 'platformatic_secret_1',
|
|
297
|
-
PLT_SECRET_2: 'platformatic_secret_2'
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
)
|
|
301
|
-
reply.code(200).send({ entryPointUrl: machineHost })
|
|
302
|
-
}
|
|
303
|
-
})
|
|
304
|
-
|
|
305
|
-
await execa('node', [
|
|
306
|
-
cliPath, 'deploy',
|
|
307
|
-
'--keys', pathToKeys,
|
|
308
|
-
'--config', pathToConfig,
|
|
309
|
-
'--deploy-service-host', deployServiceHost
|
|
310
|
-
], {
|
|
311
|
-
cwd: join(import.meta.url, './fixtures/app-to-deploy')
|
|
312
|
-
})
|
|
313
|
-
})
|
|
314
|
-
|
|
315
|
-
test('should deploy to a dynamic workspace with a keys option', async (t) => {
|
|
316
|
-
const workspaceId = 'b3d7f7e0-8c03-11e8-9eb6-529269fb1459'
|
|
317
|
-
const workspaceKey = 'b3d7f7e08c0311e89eb6529269fb1459'
|
|
318
|
-
const label = 'cli:deploy-2'
|
|
319
|
-
|
|
320
|
-
const pathToConfig = join(import.meta.url, './fixtures/app-to-deploy/platformatic.db.json')
|
|
321
|
-
const pathToKeys = join(import.meta.url, './fixtures/app-to-deploy/dynamic.txt')
|
|
322
|
-
|
|
323
|
-
const machineHost = await startMachine(t)
|
|
324
|
-
const deployServiceHost = await startDeployService(t, {
|
|
325
|
-
createBundleCallback: (request, reply) => {
|
|
326
|
-
t.equal(request.headers['x-platformatic-workspace-id'], workspaceId)
|
|
327
|
-
t.equal(request.headers['x-platformatic-api-key'], workspaceKey)
|
|
328
|
-
t.match(request.body, {
|
|
329
|
-
bundle: {
|
|
330
|
-
appType: 'db',
|
|
331
|
-
configPath: 'platformatic.db.json'
|
|
332
|
-
}
|
|
333
|
-
})
|
|
334
|
-
t.ok(request.body.bundle.checksum)
|
|
335
|
-
},
|
|
336
|
-
createDeploymentCallback: (request, reply) => {
|
|
337
|
-
t.equal(request.headers['x-platformatic-workspace-id'], workspaceId)
|
|
338
|
-
t.equal(request.headers['x-platformatic-api-key'], workspaceKey)
|
|
339
|
-
t.same(
|
|
340
|
-
request.body,
|
|
341
|
-
{
|
|
342
|
-
label,
|
|
343
|
-
metadata: {
|
|
344
|
-
appType: 'db'
|
|
345
|
-
},
|
|
346
|
-
variables: {
|
|
347
|
-
PLT_ENV_VARIABLE1: 'platformatic_variable1',
|
|
348
|
-
PLT_ENV_VARIABLE2: 'platformatic_variable2'
|
|
349
|
-
},
|
|
350
|
-
secrets: {
|
|
351
|
-
PLT_SECRET_1: 'platformatic_secret_1',
|
|
352
|
-
PLT_SECRET_2: 'platformatic_secret_2'
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
)
|
|
356
|
-
reply.code(200).send({ entryPointUrl: machineHost })
|
|
357
|
-
}
|
|
358
|
-
})
|
|
359
|
-
|
|
360
|
-
await execa('node', [
|
|
361
|
-
cliPath, 'deploy',
|
|
362
|
-
'--keys', pathToKeys,
|
|
363
|
-
'--config', pathToConfig,
|
|
364
|
-
'--label', label,
|
|
365
|
-
'--deploy-service-host', deployServiceHost
|
|
366
|
-
])
|
|
367
|
-
})
|
|
368
|
-
|
|
369
|
-
test('should throw if workspace env file is wrong', async (t) => {
|
|
370
|
-
const pathToConfig = join(import.meta.url, './fixtures/app-to-deploy/platformatic.db.json')
|
|
371
|
-
const pathToKeys = join(import.meta.url, './fixtures/app-to-deploy/wrong.txt')
|
|
372
|
-
|
|
373
|
-
try {
|
|
374
|
-
await execa('node', [
|
|
375
|
-
cliPath, 'deploy',
|
|
376
|
-
'--keys', pathToKeys,
|
|
377
|
-
'--config', pathToConfig
|
|
378
|
-
])
|
|
379
|
-
t.fail('should have failed')
|
|
380
|
-
} catch (err) {
|
|
381
|
-
t.ok(err.message.includes('Could not find workspace keys in provided file.'))
|
|
382
|
-
}
|
|
383
|
-
})
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://platformatic.dev/schemas/v0.23.2/db",
|
|
3
|
-
"server": {
|
|
4
|
-
"hostname": "127.0.0.1",
|
|
5
|
-
"port": 3042
|
|
6
|
-
},
|
|
7
|
-
"db": {
|
|
8
|
-
"connectionString": "sqlite://db.sqlite",
|
|
9
|
-
"graphql": true,
|
|
10
|
-
"ignore": {
|
|
11
|
-
"versions": true
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"migrations": {
|
|
15
|
-
"dir": "migrations",
|
|
16
|
-
"table": "versions"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "./platformatic.db.schema.json",
|
|
3
|
-
"server": {
|
|
4
|
-
"hostname": "{PLT_SERVER_HOSTNAME}",
|
|
5
|
-
"port": "{PORT}",
|
|
6
|
-
"logger": {
|
|
7
|
-
"level": "{PLT_SERVER_LOGGER_LEVEL}"
|
|
8
|
-
}
|
|
9
|
-
},
|
|
10
|
-
"core": {
|
|
11
|
-
"connectionString": "{DATABASE_URL}",
|
|
12
|
-
"graphql": true,
|
|
13
|
-
"openapi": true,
|
|
14
|
-
"events": false
|
|
15
|
-
},
|
|
16
|
-
"authorization": {
|
|
17
|
-
"adminSecret": "{PLT_ADMIN_SECRET}",
|
|
18
|
-
"rules": [{
|
|
19
|
-
"role": "anonymous",
|
|
20
|
-
"entity": "queue",
|
|
21
|
-
"find": false,
|
|
22
|
-
"save": false,
|
|
23
|
-
"delete": false
|
|
24
|
-
}, {
|
|
25
|
-
"role": "anonymous",
|
|
26
|
-
"entity": "message",
|
|
27
|
-
"find": false,
|
|
28
|
-
"save": false,
|
|
29
|
-
"delete": false
|
|
30
|
-
}]
|
|
31
|
-
},
|
|
32
|
-
"migrations": {
|
|
33
|
-
"dir": "migrations"
|
|
34
|
-
},
|
|
35
|
-
"plugin": {
|
|
36
|
-
"path": "plugin.js"
|
|
37
|
-
},
|
|
38
|
-
"types": {
|
|
39
|
-
"autogenerate": true
|
|
40
|
-
}
|
|
41
|
-
}
|
package/test/gh.test.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { test } from 'tap'
|
|
2
|
-
import { tmpdir } from 'os'
|
|
3
|
-
import { execa } from 'execa'
|
|
4
|
-
import { cp, readFile, writeFile } from 'fs/promises'
|
|
5
|
-
import { cliPath } from './helper.js'
|
|
6
|
-
import { fileURLToPath } from 'url'
|
|
7
|
-
import { dirname, join } from 'path'
|
|
8
|
-
import mkdirp from 'mkdirp'
|
|
9
|
-
|
|
10
|
-
let count = 0
|
|
11
|
-
|
|
12
|
-
test('creates a deploy config for static workspace', async (t) => {
|
|
13
|
-
const dest = join(tmpdir(), `test-cli-gh-${process.pid}-${count++}`)
|
|
14
|
-
|
|
15
|
-
t.comment(`working in ${dest}`)
|
|
16
|
-
await mkdirp(dest)
|
|
17
|
-
await cp(
|
|
18
|
-
join(dirname(fileURLToPath(import.meta.url)), 'fixtures', 'v0.16.0.db.json'),
|
|
19
|
-
join(dest, 'platformatic.db.json'))
|
|
20
|
-
|
|
21
|
-
await execa('node', [cliPath, 'gh'], {
|
|
22
|
-
cwd: dest
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
const deployWorkflow = await readFile(join(dest, '.github', 'workflows', 'platformatic-static-workspace-deploy.yml'), 'utf8')
|
|
26
|
-
t.ok(deployWorkflow.indexOf('PLATFORMATIC_STATIC_WORKSPACE_ID') !== -1)
|
|
27
|
-
t.ok(deployWorkflow.indexOf('PLATFORMATIC_STATIC_WORKSPACE_API_KEY') !== -1)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
test('creates a deploy config for dynamic workspace', async (t) => {
|
|
31
|
-
const dest = join(tmpdir(), `test-cli-gh-${process.pid}-${count++}`)
|
|
32
|
-
|
|
33
|
-
await mkdirp(dest)
|
|
34
|
-
await cp(
|
|
35
|
-
join(dirname(fileURLToPath(import.meta.url)), 'fixtures', 'v0.16.0.db.json'),
|
|
36
|
-
join(dest, 'platformatic.db.json'))
|
|
37
|
-
|
|
38
|
-
await execa('node', [cliPath, 'gh', '-t', 'dynamic'], {
|
|
39
|
-
cwd: dest
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
const deployWorkflow = await readFile(join(dest, '.github', 'workflows', 'platformatic-dynamic-workspace-deploy.yml'), 'utf8')
|
|
43
|
-
t.ok(deployWorkflow.indexOf('PLATFORMATIC_DYNAMIC_WORKSPACE_ID') !== -1)
|
|
44
|
-
t.ok(deployWorkflow.indexOf('PLATFORMATIC_DYNAMIC_WORKSPACE_API_KEY') !== -1)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
test('creation fails if workspace type is not static or dynamic', async (t) => {
|
|
48
|
-
const dest = join(tmpdir(), `test-cli-gh-${process.pid}-${count++}`)
|
|
49
|
-
|
|
50
|
-
await mkdirp(dest)
|
|
51
|
-
await cp(
|
|
52
|
-
join(dirname(fileURLToPath(import.meta.url)), 'fixtures', 'v0.16.0.db.json'),
|
|
53
|
-
join(dest, 'platformatic.db.json'))
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
await execa('node', [cliPath, 'gh', '-t', 'XXXXX'], {
|
|
57
|
-
cwd: dest
|
|
58
|
-
})
|
|
59
|
-
t.fail('should have failed')
|
|
60
|
-
} catch ({ stdout }) {
|
|
61
|
-
t.ok(stdout.indexOf('Type must be either static or dynamic') !== -1)
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
test('creation fails if no config file is found', async (t) => {
|
|
66
|
-
const dest = join(tmpdir(), `test-cli-gh-${process.pid}-${count++}`)
|
|
67
|
-
await mkdirp(dest)
|
|
68
|
-
try {
|
|
69
|
-
await execa('node', [cliPath, 'gh'], {
|
|
70
|
-
cwd: dest
|
|
71
|
-
})
|
|
72
|
-
t.fail('should have failed')
|
|
73
|
-
} catch ({ stdout }) {
|
|
74
|
-
t.ok(stdout.indexOf('No config file found') !== -1)
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
test('creates a deploy must warn that a .env exists', async (t) => {
|
|
79
|
-
const dest = join(tmpdir(), `test-cli-gh-${process.pid}-${count++}`)
|
|
80
|
-
|
|
81
|
-
await mkdirp(dest)
|
|
82
|
-
await cp(
|
|
83
|
-
join(dirname(fileURLToPath(import.meta.url)), 'fixtures', 'v0.16.0.db.json'),
|
|
84
|
-
join(dest, 'platformatic.db.json'))
|
|
85
|
-
|
|
86
|
-
await writeFile(join(dest, '.env'), 'TEST=1')
|
|
87
|
-
|
|
88
|
-
const { stdout } = await execa('node', [cliPath, 'gh'], {
|
|
89
|
-
cwd: dest
|
|
90
|
-
})
|
|
91
|
-
t.ok(stdout.indexOf('Found .env file') !== -1)
|
|
92
|
-
})
|
package/test/helper.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { join } from 'desm'
|
|
2
|
-
import fastify from 'fastify'
|
|
3
|
-
|
|
4
|
-
const cliPath = join(import.meta.url, '..', 'cli.js')
|
|
5
|
-
|
|
6
|
-
async function startDeployService (t, options = {}) {
|
|
7
|
-
const deployService = fastify({ keepAliveTimeout: 1 })
|
|
8
|
-
|
|
9
|
-
deployService.post('/bundles', async (request, reply) => {
|
|
10
|
-
const createBundleCallback = options.createBundleCallback || (() => {})
|
|
11
|
-
await createBundleCallback(request, reply)
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
id: 'default-bundle-id',
|
|
15
|
-
token: 'default-upload-token',
|
|
16
|
-
isBundleUploaded: false
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
deployService.post('/deployments', async (request, reply) => {
|
|
21
|
-
const createDeploymentCallback = options.createDeploymentCallback || (() => {})
|
|
22
|
-
await createDeploymentCallback(request, reply)
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
deployService.addContentTypeParser(
|
|
26
|
-
'application/x-tar',
|
|
27
|
-
{ bodyLimit: 1024 * 1024 * 1024 },
|
|
28
|
-
(request, payload, done) => done()
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
deployService.put('/upload', async (request, reply) => {
|
|
32
|
-
const uploadCallback = options.uploadCallback || (() => {})
|
|
33
|
-
await uploadCallback(request, reply)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
t.teardown(async () => {
|
|
37
|
-
await deployService.close()
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
return deployService.listen({ port: 3042 })
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async function startMachine (t, callback = () => {}) {
|
|
44
|
-
const machine = fastify({ keepAliveTimeout: 1 })
|
|
45
|
-
|
|
46
|
-
machine.get('/', async (request, reply) => {
|
|
47
|
-
await callback(request, reply)
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
t.teardown(async () => {
|
|
51
|
-
await machine.close()
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
return machine.listen({ port: 0 })
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export {
|
|
58
|
-
cliPath,
|
|
59
|
-
startDeployService,
|
|
60
|
-
startMachine
|
|
61
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { test } from 'tap'
|
|
2
|
-
import { join } from 'desm'
|
|
3
|
-
import { readFile } from 'fs/promises'
|
|
4
|
-
import { execa } from 'execa'
|
|
5
|
-
import { cliPath } from './helper.js'
|
|
6
|
-
import { EOL } from 'os'
|
|
7
|
-
import { Agent, setGlobalDispatcher, request } from 'undici'
|
|
8
|
-
import split from 'split2'
|
|
9
|
-
import { on } from 'events'
|
|
10
|
-
|
|
11
|
-
setGlobalDispatcher(new Agent({
|
|
12
|
-
keepAliveTimeout: 10,
|
|
13
|
-
keepAliveMaxTimeout: 10,
|
|
14
|
-
tls: {
|
|
15
|
-
rejectUnauthorized: false
|
|
16
|
-
}
|
|
17
|
-
}))
|
|
18
|
-
|
|
19
|
-
const version = JSON.parse(await readFile(join(import.meta.url, '..', 'package.json'))).version
|
|
20
|
-
const help = await readFile(join(import.meta.url, '..', 'help', 'help.txt'), 'utf8')
|
|
21
|
-
|
|
22
|
-
// This reads a file from packages/db
|
|
23
|
-
const helpDB = await readFile(join(import.meta.url, '..', '..', 'db', 'help', 'help.txt'), 'utf8')
|
|
24
|
-
|
|
25
|
-
// This reads a file from packages/runtime
|
|
26
|
-
const helpRuntime = await readFile(join(import.meta.url, '..', '..', 'runtime', 'help', 'help.txt'), 'utf8')
|
|
27
|
-
|
|
28
|
-
// This reads a file from packages/service
|
|
29
|
-
const helpService = await readFile(join(import.meta.url, '..', '..', 'service', 'help', 'help.txt'), 'utf8')
|
|
30
|
-
|
|
31
|
-
test('version', async (t) => {
|
|
32
|
-
const { stdout } = await execa('node', [cliPath, '--version'])
|
|
33
|
-
t.ok(stdout.includes('v' + version))
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
test('db', async (t) => {
|
|
37
|
-
try {
|
|
38
|
-
await execa('node', [cliPath, 'db', 'start'])
|
|
39
|
-
t.fail('bug')
|
|
40
|
-
} catch (err) {
|
|
41
|
-
t.ok(err.stderr.includes('Missing config file'))
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
test('runtime', async (t) => {
|
|
46
|
-
try {
|
|
47
|
-
await execa('node', [cliPath, 'runtime', 'start'])
|
|
48
|
-
t.fail('bug')
|
|
49
|
-
} catch (err) {
|
|
50
|
-
t.ok(err.stderr.includes('Missing config file'))
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
test('login', async (t) => {
|
|
55
|
-
try {
|
|
56
|
-
await execa('node', [cliPath, 'login'])
|
|
57
|
-
t.fail('bug')
|
|
58
|
-
} catch (err) {
|
|
59
|
-
t.ok(err.stderr.includes('Unable to authenticate:'))
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
test('command not found', async (t) => {
|
|
64
|
-
try {
|
|
65
|
-
await execa('node', [cliPath, 'foo'])
|
|
66
|
-
t.fail('bug')
|
|
67
|
-
} catch (err) {
|
|
68
|
-
t.ok(err.stdout.includes('Command not found: foo'))
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
test('subcommand not found', async (t) => {
|
|
73
|
-
try {
|
|
74
|
-
await execa('node', [cliPath, 'db', 'subfoo'])
|
|
75
|
-
t.fail('bug')
|
|
76
|
-
} catch (err) {
|
|
77
|
-
t.ok(err.stdout.includes('Command not found: subfoo'))
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
test('allows for minor typos in commands', async (t) => {
|
|
82
|
-
try {
|
|
83
|
-
await execa('node', [cliPath, 'dbx', 'start'])
|
|
84
|
-
t.fail('bug')
|
|
85
|
-
} catch (err) {
|
|
86
|
-
t.ok(err.stderr.includes('Missing config file'))
|
|
87
|
-
}
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
test('prints the help if command requires a subcommand', async (t) => {
|
|
91
|
-
try {
|
|
92
|
-
await execa('node', [cliPath, 'db'])
|
|
93
|
-
t.fail('bug')
|
|
94
|
-
} catch (err) {
|
|
95
|
-
t.equal(err.stdout + EOL, helpDB)
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
test('prints the help with help command', async (t) => {
|
|
100
|
-
const { stdout } = await execa('node', [cliPath, 'help'])
|
|
101
|
-
t.equal(stdout + EOL, help)
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
test('prints the help with help flag', async (t) => {
|
|
105
|
-
const { stdout } = await execa('node', [cliPath, '--help'])
|
|
106
|
-
t.equal(stdout + EOL, help)
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
test('prints the help of db', async (t) => {
|
|
110
|
-
const { stdout } = await execa('node', [cliPath, 'help', 'db'])
|
|
111
|
-
t.equal(stdout + EOL, helpDB)
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
test('prints the help if not commands are specified', async (t) => {
|
|
115
|
-
const { stdout } = await execa('node', [cliPath])
|
|
116
|
-
t.equal(stdout + EOL, help)
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
test('prints the help of runtime', async (t) => {
|
|
120
|
-
const { stdout } = await execa('node', [cliPath, 'help', 'runtime'])
|
|
121
|
-
t.equal(stdout + EOL, helpRuntime)
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
test('prints the help of service', async (t) => {
|
|
125
|
-
const { stdout } = await execa('node', [cliPath, 'help', 'service'])
|
|
126
|
-
t.equal(stdout + EOL, helpService)
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
async function start (...args) {
|
|
130
|
-
const { execa } = await import('execa')
|
|
131
|
-
const child = execa('node', [cliPath, ...args])
|
|
132
|
-
child.stderr.pipe(process.stdout)
|
|
133
|
-
const output = child.stdout.pipe(split(function (line) {
|
|
134
|
-
try {
|
|
135
|
-
const obj = JSON.parse(line)
|
|
136
|
-
return obj
|
|
137
|
-
} catch (err) {
|
|
138
|
-
console.log(line)
|
|
139
|
-
}
|
|
140
|
-
}))
|
|
141
|
-
child.ndj = output
|
|
142
|
-
|
|
143
|
-
const errorTimeout = setTimeout(() => {
|
|
144
|
-
throw new Error('Couldn\'t start server')
|
|
145
|
-
}, 10000)
|
|
146
|
-
|
|
147
|
-
for await (const messages of on(output, 'data')) {
|
|
148
|
-
for (const message of messages) {
|
|
149
|
-
const text = message.msg
|
|
150
|
-
if (text && text.includes('Server listening at')) {
|
|
151
|
-
const url = text.match(/Server listening at (.*)/)[1]
|
|
152
|
-
clearTimeout(errorTimeout)
|
|
153
|
-
return { child, url, output }
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
test('start the database and do a call', async ({ teardown, equal, match }) => {
|
|
160
|
-
const config = join(import.meta.url, '..', 'fixtures/sqlite/platformatic.db.json')
|
|
161
|
-
const { child, url } = await start('db', 'start', '-c', config)
|
|
162
|
-
teardown(() => {
|
|
163
|
-
child.kill('SIGINT')
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
const res = await request(`${url}/graphql`, {
|
|
167
|
-
method: 'POST',
|
|
168
|
-
headers: { 'Content-Type': 'application/json' },
|
|
169
|
-
body: JSON.stringify({
|
|
170
|
-
query: `
|
|
171
|
-
mutation {
|
|
172
|
-
saveGraph(input: { name: "Hello" }) {
|
|
173
|
-
id
|
|
174
|
-
name
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
`
|
|
178
|
-
})
|
|
179
|
-
})
|
|
180
|
-
equal(res.statusCode, 200, 'saveGraph status code')
|
|
181
|
-
const body = await res.body.json()
|
|
182
|
-
match(body, {
|
|
183
|
-
data: {
|
|
184
|
-
saveGraph: {
|
|
185
|
-
name: 'Hello'
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}, 'saveGraph response')
|
|
189
|
-
})
|
package/test/start.test.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert'
|
|
2
|
-
import { spawn } from 'node:child_process'
|
|
3
|
-
import { cp } from 'node:fs/promises'
|
|
4
|
-
import { tmpdir } from 'node:os'
|
|
5
|
-
import { dirname, join } from 'node:path'
|
|
6
|
-
import { fileURLToPath } from 'node:url'
|
|
7
|
-
import { test } from 'tap'
|
|
8
|
-
import { cliPath } from './helper.js'
|
|
9
|
-
|
|
10
|
-
let count = 0
|
|
11
|
-
|
|
12
|
-
test('starts a server', async ({ teardown }) => {
|
|
13
|
-
const src = join(dirname(fileURLToPath(import.meta.url)), 'fixtures', 'platformatic.service.json')
|
|
14
|
-
const destDir = join(tmpdir(), `test-cli-${process.pid}-${count++}`)
|
|
15
|
-
const dest = join(destDir, 'platformatic.service.json')
|
|
16
|
-
|
|
17
|
-
await cp(src, dest)
|
|
18
|
-
|
|
19
|
-
const child = spawn(process.execPath, [cliPath, 'start'], {
|
|
20
|
-
cwd: destDir,
|
|
21
|
-
timeout: 10_000
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
teardown(async () => {
|
|
25
|
-
try {
|
|
26
|
-
child.kill('SIGINT')
|
|
27
|
-
} catch {} // Ignore error.
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
let stdout = ''
|
|
31
|
-
|
|
32
|
-
child.stdout.setEncoding('utf8')
|
|
33
|
-
|
|
34
|
-
for await (const chunk of child.stdout) {
|
|
35
|
-
stdout += chunk
|
|
36
|
-
|
|
37
|
-
if (/server listening at/i.test(stdout)) {
|
|
38
|
-
break
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
test('starts a runtime application', async ({ teardown }) => {
|
|
44
|
-
const srcDir = join(dirname(fileURLToPath(import.meta.url)), 'fixtures')
|
|
45
|
-
const destDir = join(tmpdir(), `test-cli-${process.pid}-${count++}`)
|
|
46
|
-
let found = false
|
|
47
|
-
|
|
48
|
-
await cp(
|
|
49
|
-
join(srcDir, 'platformatic.runtime.json'),
|
|
50
|
-
join(destDir, 'platformatic.runtime.json')
|
|
51
|
-
)
|
|
52
|
-
await cp(
|
|
53
|
-
join(srcDir, 'platformatic.service.json'),
|
|
54
|
-
join(destDir, 'platformatic.service.json')
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
const child = spawn(process.execPath, [cliPath, 'start'], {
|
|
58
|
-
cwd: destDir,
|
|
59
|
-
timeout: 10_000
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
child.stderr.pipe(process.stderr)
|
|
63
|
-
|
|
64
|
-
teardown(async () => {
|
|
65
|
-
try {
|
|
66
|
-
child.kill('SIGKILL')
|
|
67
|
-
} catch {} // Ignore error.
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
let stdout = ''
|
|
71
|
-
|
|
72
|
-
child.stdout.setEncoding('utf8')
|
|
73
|
-
|
|
74
|
-
for await (const chunk of child.stdout) {
|
|
75
|
-
stdout += chunk
|
|
76
|
-
|
|
77
|
-
if (/server listening at/i.test(stdout)) {
|
|
78
|
-
found = true
|
|
79
|
-
break
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
assert(found)
|
|
84
|
-
})
|
package/test/upgrade.test.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { test } from 'tap'
|
|
2
|
-
import { tmpdir } from 'os'
|
|
3
|
-
import { execa } from 'execa'
|
|
4
|
-
import { cp, readFile } from 'fs/promises'
|
|
5
|
-
import { cliPath } from './helper.js'
|
|
6
|
-
import { fileURLToPath } from 'url'
|
|
7
|
-
import { dirname, join } from 'path'
|
|
8
|
-
|
|
9
|
-
let count = 0
|
|
10
|
-
|
|
11
|
-
/* eslint-disable prefer-regex-literals */
|
|
12
|
-
|
|
13
|
-
test('writes a config file', async (t) => {
|
|
14
|
-
const dest = join(tmpdir(), `test-cli-${process.pid}-${count++}`)
|
|
15
|
-
|
|
16
|
-
await cp(
|
|
17
|
-
join(dirname(fileURLToPath(import.meta.url)), 'fixtures', 'v0.16.0.db.json'),
|
|
18
|
-
join(dest, 'platformatic.db.json'))
|
|
19
|
-
|
|
20
|
-
await execa('node', [cliPath, 'upgrade'], {
|
|
21
|
-
cwd: dest
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const config = JSON.parse(await readFile(join(dest, 'platformatic.db.json'), 'utf8'))
|
|
25
|
-
|
|
26
|
-
t.match(config.$schema, new RegExp('https://platformatic.dev/schemas/v\\d+.\\d+.\\d+/db'))
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
test('writes a config file with a config option', async (t) => {
|
|
30
|
-
const dest = join(tmpdir(), `test-cli-${process.pid}-${count++}`)
|
|
31
|
-
|
|
32
|
-
await cp(
|
|
33
|
-
join(dirname(fileURLToPath(import.meta.url)), 'fixtures', 'v0.16.0.db.json'),
|
|
34
|
-
join(dest, 'platformatic.db.json'))
|
|
35
|
-
|
|
36
|
-
await execa('node', [cliPath, 'upgrade', '-c', join(dest, 'platformatic.db.json')])
|
|
37
|
-
|
|
38
|
-
const config = JSON.parse(await readFile(join(dest, 'platformatic.db.json'), 'utf8'))
|
|
39
|
-
|
|
40
|
-
t.match(config.$schema, new RegExp('https://platformatic.dev/schemas/v\\d+.\\d+.\\d+/db'))
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
test('no config file no party', async (t) => {
|
|
44
|
-
await t.rejects(execa('node', [cliPath, 'upgrade']))
|
|
45
|
-
})
|