platformatic 0.22.0 → 0.23.1
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/cli.js +2 -0
- package/help/help.txt +1 -0
- package/help/start.txt +5 -0
- package/lib/deploy.js +1 -4
- package/package.json +10 -9
- package/test/deploy.test.js +45 -19
- package/test/fixtures/platformatic.service.json +13 -0
- package/test/start.test.js +40 -0
package/cli.js
CHANGED
|
@@ -4,6 +4,7 @@ import commist from 'commist'
|
|
|
4
4
|
import minimist from 'minimist'
|
|
5
5
|
import { runDB } from '@platformatic/db/db.mjs'
|
|
6
6
|
import { runService } from '@platformatic/service/service.mjs'
|
|
7
|
+
import { startCommand } from '@platformatic/start'
|
|
7
8
|
import { login } from '@platformatic/authenticate/authenticate.js'
|
|
8
9
|
import { command as client } from '@platformatic/client-cli'
|
|
9
10
|
import { readFile } from 'fs/promises'
|
|
@@ -38,6 +39,7 @@ const ensureCommand = async ({ output, help }) => {
|
|
|
38
39
|
|
|
39
40
|
program.register('db', async (args) => ensureCommand(await runDB(args)))
|
|
40
41
|
program.register('service', async (args) => ensureCommand(await runService(args)))
|
|
42
|
+
program.register('start', startCommand)
|
|
41
43
|
program.register('upgrade', upgrade)
|
|
42
44
|
program.register('client', client)
|
|
43
45
|
program.register('help', help.toStdout)
|
package/help/help.txt
CHANGED
|
@@ -7,3 +7,4 @@ Welcome to Platformatic. Available commands are:
|
|
|
7
7
|
* upgrade - upgrade the Platformatic configuration to the latest version.
|
|
8
8
|
* gh - creates a new gh action for Platformatic deployments
|
|
9
9
|
* deploy - deploy a Platformatic application to the cloud
|
|
10
|
+
* start - start a Platformatic application
|
package/help/start.txt
ADDED
package/lib/deploy.js
CHANGED
|
@@ -104,10 +104,7 @@ export async function deploy (argv) {
|
|
|
104
104
|
const labelPrefix = label.split(':')[0]
|
|
105
105
|
const labelPrefixes = ['cli', 'github-pr']
|
|
106
106
|
if (!labelPrefix || !labelPrefixes.includes(labelPrefix)) {
|
|
107
|
-
|
|
108
|
-
`Invalid deploy label provided: "${label}". ` +
|
|
109
|
-
`Label must be prefixed with one of: ${labelPrefixes.join(', ')}.`
|
|
110
|
-
)
|
|
107
|
+
label = `cli:${label}`
|
|
111
108
|
}
|
|
112
109
|
}
|
|
113
110
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "platformatic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "Platformatic CLI",
|
|
5
5
|
"main": "cli.js",
|
|
6
6
|
"type": "module",
|
|
@@ -46,15 +46,16 @@
|
|
|
46
46
|
"help-me": "^4.2.0",
|
|
47
47
|
"inquirer": "^9.2.0",
|
|
48
48
|
"minimist": "^1.2.8",
|
|
49
|
-
"pino": "^8.
|
|
49
|
+
"pino": "^8.12.0",
|
|
50
50
|
"pino-pretty": "^10.0.0",
|
|
51
|
-
"@platformatic/authenticate": "0.
|
|
52
|
-
"@platformatic/client-cli": "0.
|
|
53
|
-
"@platformatic/config": "0.
|
|
54
|
-
"@platformatic/db": "0.
|
|
55
|
-
"@platformatic/metaconfig": "0.
|
|
56
|
-
"@platformatic/service": "0.
|
|
57
|
-
"
|
|
51
|
+
"@platformatic/authenticate": "0.23.1",
|
|
52
|
+
"@platformatic/client-cli": "0.23.1",
|
|
53
|
+
"@platformatic/config": "0.23.1",
|
|
54
|
+
"@platformatic/db": "0.23.1",
|
|
55
|
+
"@platformatic/metaconfig": "0.23.1",
|
|
56
|
+
"@platformatic/service": "0.23.1",
|
|
57
|
+
"@platformatic/start": "0.23.1",
|
|
58
|
+
"create-platformatic": "0.23.1"
|
|
58
59
|
},
|
|
59
60
|
"scripts": {
|
|
60
61
|
"test": "standard | snazzy && c8 --100 tap --no-coverage test/*.test.js",
|
package/test/deploy.test.js
CHANGED
|
@@ -147,28 +147,54 @@ test('should fail if invalid workspace type provided', async (t) => {
|
|
|
147
147
|
}
|
|
148
148
|
})
|
|
149
149
|
|
|
150
|
-
test('should
|
|
150
|
+
test('should deploy to a dynamic workspace to the cloud', async (t) => {
|
|
151
151
|
const workspaceType = 'dynamic'
|
|
152
152
|
const workspaceId = 'b3d7f7e0-8c03-11e8-9eb6-529269fb1459'
|
|
153
153
|
const workspaceKey = 'b3d7f7e08c0311e89eb6529269fb1459'
|
|
154
154
|
const pathToConfig = join(import.meta.url, './fixtures/app-to-deploy/platformatic.db.json')
|
|
155
|
-
const label = '
|
|
155
|
+
const label = 'cli:deploy-2'
|
|
156
156
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
'
|
|
161
|
-
'
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
'
|
|
172
|
-
|
|
173
|
-
|
|
157
|
+
const machineHost = await startMachine(t)
|
|
158
|
+
const deployServiceHost = await startDeployService(t, {
|
|
159
|
+
createBundleCallback: (request, reply) => {
|
|
160
|
+
t.equal(request.headers['x-platformatic-workspace-id'], workspaceId)
|
|
161
|
+
t.equal(request.headers['x-platformatic-api-key'], workspaceKey)
|
|
162
|
+
t.match(request.body, {
|
|
163
|
+
bundle: {
|
|
164
|
+
appType: 'db',
|
|
165
|
+
configPath: 'platformatic.db.json'
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
t.ok(request.body.bundle.checksum)
|
|
169
|
+
},
|
|
170
|
+
createDeploymentCallback: (request, reply) => {
|
|
171
|
+
t.equal(request.headers['x-platformatic-workspace-id'], workspaceId)
|
|
172
|
+
t.equal(request.headers['x-platformatic-api-key'], workspaceKey)
|
|
173
|
+
t.same(
|
|
174
|
+
request.body,
|
|
175
|
+
{
|
|
176
|
+
label,
|
|
177
|
+
variables: {
|
|
178
|
+
PLT_ENV_VARIABLE1: 'platformatic_variable1',
|
|
179
|
+
PLT_ENV_VARIABLE2: 'platformatic_variable2'
|
|
180
|
+
},
|
|
181
|
+
secrets: {
|
|
182
|
+
PLT_SECRET_1: 'platformatic_secret_1',
|
|
183
|
+
PLT_SECRET_2: 'platformatic_secret_2'
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
reply.code(200).send({ entryPointUrl: machineHost })
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
await execa('node', [
|
|
192
|
+
cliPath, 'deploy',
|
|
193
|
+
'--type', workspaceType,
|
|
194
|
+
'--label', 'deploy-2',
|
|
195
|
+
'--config', pathToConfig,
|
|
196
|
+
'--workspace-id', workspaceId,
|
|
197
|
+
'--workspace-key', workspaceKey,
|
|
198
|
+
'--deploy-service-host', deployServiceHost
|
|
199
|
+
])
|
|
174
200
|
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process'
|
|
2
|
+
import { cp } from 'node:fs/promises'
|
|
3
|
+
import { tmpdir } from 'node:os'
|
|
4
|
+
import { dirname, join } from 'node:path'
|
|
5
|
+
import { fileURLToPath } from 'node:url'
|
|
6
|
+
import { test } from 'tap'
|
|
7
|
+
import { cliPath } from './helper.js'
|
|
8
|
+
|
|
9
|
+
let count = 0
|
|
10
|
+
|
|
11
|
+
test('starts a server', async ({ teardown }) => {
|
|
12
|
+
const src = join(dirname(fileURLToPath(import.meta.url)), 'fixtures', 'platformatic.service.json')
|
|
13
|
+
const destDir = join(tmpdir(), `test-cli-${process.pid}-${count++}`)
|
|
14
|
+
const dest = join(destDir, 'platformatic.service.json')
|
|
15
|
+
|
|
16
|
+
await cp(src, dest)
|
|
17
|
+
|
|
18
|
+
const child = spawn(process.execPath, [cliPath, 'start'], {
|
|
19
|
+
cwd: destDir,
|
|
20
|
+
timeout: 10_000
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
teardown(async () => {
|
|
24
|
+
try {
|
|
25
|
+
child.kill('SIGINT')
|
|
26
|
+
} catch {} // Ignore error.
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
let stdout = ''
|
|
30
|
+
|
|
31
|
+
child.stdout.setEncoding('utf8')
|
|
32
|
+
|
|
33
|
+
for await (const chunk of child.stdout) {
|
|
34
|
+
stdout += chunk
|
|
35
|
+
|
|
36
|
+
if (/server listening at/i.test(stdout)) {
|
|
37
|
+
break
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
})
|