platformatic 0.23.2 → 0.25.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/gh.js +7 -13
- package/package.json +13 -13
- package/test/fixtures/app-to-deploy/platformatic.db.json +2 -1
- package/test/gh.test.js +8 -26
package/lib/gh.js
CHANGED
|
@@ -9,12 +9,12 @@ import pino from 'pino'
|
|
|
9
9
|
import pretty from 'pino-pretty'
|
|
10
10
|
import ConfigManager from '@platformatic/config'
|
|
11
11
|
|
|
12
|
-
export const createGHAction = async (logger,
|
|
12
|
+
export const createGHAction = async (logger, env, config, buildTS, type, projectDir = process.cwd()) => {
|
|
13
13
|
if (type === 'static') {
|
|
14
|
-
await createStaticWorkspaceGHAction(logger,
|
|
14
|
+
await createStaticWorkspaceGHAction(logger, env, config, projectDir, buildTS)
|
|
15
15
|
return
|
|
16
16
|
}
|
|
17
|
-
await createDynamicWorkspaceGHAction(logger,
|
|
17
|
+
await createDynamicWorkspaceGHAction(logger, env, config, projectDir, buildTS)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const logger = pino(pretty({
|
|
@@ -43,18 +43,11 @@ export const gh = async (argv) => {
|
|
|
43
43
|
config: 'c',
|
|
44
44
|
type: 't',
|
|
45
45
|
help: 'h',
|
|
46
|
-
build: 'b'
|
|
47
|
-
workspace: 'w'
|
|
46
|
+
build: 'b'
|
|
48
47
|
},
|
|
49
48
|
boolean: ['build']
|
|
50
49
|
})
|
|
51
50
|
|
|
52
|
-
// Validations:
|
|
53
|
-
if (!args.workspace) {
|
|
54
|
-
logger.error('Workspace ID is required')
|
|
55
|
-
process.exit(1)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
51
|
if (!['static', 'dynamic'].includes(args.type)) {
|
|
59
52
|
logger.error(`Invalid type: [${args.type}]. Type must be either static or dynamic`)
|
|
60
53
|
process.exit(1)
|
|
@@ -80,8 +73,9 @@ export const gh = async (argv) => {
|
|
|
80
73
|
plt_custom_variable: 'change-me',
|
|
81
74
|
custom_variable1: 'change-me'
|
|
82
75
|
}
|
|
83
|
-
await createGHAction(logger,
|
|
76
|
+
await createGHAction(logger, env, configFilename, args.build, args.type)
|
|
84
77
|
|
|
78
|
+
const workspaceName = args.type === 'static' ? 'PLATFORMATIC_STATIC_WORKSPACE_ID ' : 'PLATFORMATIC_DYNAMIC_WORKSPACE_ID'
|
|
85
79
|
const secretName = args.type === 'static' ? 'PLATFORMATIC_STATIC_WORKSPACE_API_KEY' : 'PLATFORMATIC_DYNAMIC_WORKSPACE_API_KEY'
|
|
86
|
-
logger.info(`Github action successfully created
|
|
80
|
+
logger.info(`Github action successfully created please add ${workspaceName} and ${secretName} as repository secrets.`)
|
|
87
81
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "platformatic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "Platformatic CLI",
|
|
5
5
|
"main": "cli.js",
|
|
6
6
|
"type": "module",
|
|
@@ -36,26 +36,26 @@
|
|
|
36
36
|
"split2": "^4.2.0",
|
|
37
37
|
"standard": "^17.0.0",
|
|
38
38
|
"tap": "^16.3.4",
|
|
39
|
-
"undici": "^5.22.
|
|
39
|
+
"undici": "^5.22.1"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@platformatic/deploy-client": "^0.1.2",
|
|
43
42
|
"colorette": "^2.0.20",
|
|
44
43
|
"commist": "^3.2.0",
|
|
45
44
|
"desm": "^1.3.0",
|
|
46
45
|
"help-me": "^4.2.0",
|
|
47
|
-
"inquirer": "^9.2.
|
|
46
|
+
"inquirer": "^9.2.6",
|
|
48
47
|
"minimist": "^1.2.8",
|
|
49
|
-
"pino": "^8.
|
|
48
|
+
"pino": "^8.14.1",
|
|
50
49
|
"pino-pretty": "^10.0.0",
|
|
51
|
-
"@platformatic/authenticate": "0.
|
|
52
|
-
"@platformatic/client-cli": "0.
|
|
53
|
-
"@platformatic/config": "0.
|
|
54
|
-
"@platformatic/db": "0.
|
|
55
|
-
"@platformatic/
|
|
56
|
-
"@platformatic/
|
|
57
|
-
"@platformatic/
|
|
58
|
-
"
|
|
50
|
+
"@platformatic/authenticate": "0.25.0",
|
|
51
|
+
"@platformatic/client-cli": "0.25.0",
|
|
52
|
+
"@platformatic/config": "0.25.0",
|
|
53
|
+
"@platformatic/db": "0.25.0",
|
|
54
|
+
"@platformatic/deploy-client": "0.25.0",
|
|
55
|
+
"@platformatic/metaconfig": "0.25.0",
|
|
56
|
+
"@platformatic/service": "0.25.0",
|
|
57
|
+
"@platformatic/start": "0.25.0",
|
|
58
|
+
"create-platformatic": "0.25.0"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"test": "standard | snazzy && c8 --100 tap --no-coverage test/*.test.js",
|
package/test/gh.test.js
CHANGED
|
@@ -8,23 +8,23 @@ import { dirname, join } from 'path'
|
|
|
8
8
|
import mkdirp from 'mkdirp'
|
|
9
9
|
|
|
10
10
|
let count = 0
|
|
11
|
-
const workspaceId = 'WORKSPACE-ID-TEST'
|
|
12
11
|
|
|
13
12
|
test('creates a deploy config for static workspace', async (t) => {
|
|
14
13
|
const dest = join(tmpdir(), `test-cli-gh-${process.pid}-${count++}`)
|
|
15
14
|
|
|
15
|
+
t.comment(`working in ${dest}`)
|
|
16
16
|
await mkdirp(dest)
|
|
17
17
|
await cp(
|
|
18
18
|
join(dirname(fileURLToPath(import.meta.url)), 'fixtures', 'v0.16.0.db.json'),
|
|
19
19
|
join(dest, 'platformatic.db.json'))
|
|
20
20
|
|
|
21
|
-
await execa('node', [cliPath, 'gh'
|
|
21
|
+
await execa('node', [cliPath, 'gh'], {
|
|
22
22
|
cwd: dest
|
|
23
23
|
})
|
|
24
24
|
|
|
25
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)
|
|
26
27
|
t.ok(deployWorkflow.indexOf('PLATFORMATIC_STATIC_WORKSPACE_API_KEY') !== -1)
|
|
27
|
-
t.ok(deployWorkflow.indexOf('WORKSPACE-ID-TEST') !== -1)
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
test('creates a deploy config for dynamic workspace', async (t) => {
|
|
@@ -35,31 +35,13 @@ test('creates a deploy config for dynamic workspace', async (t) => {
|
|
|
35
35
|
join(dirname(fileURLToPath(import.meta.url)), 'fixtures', 'v0.16.0.db.json'),
|
|
36
36
|
join(dest, 'platformatic.db.json'))
|
|
37
37
|
|
|
38
|
-
await execa('node', [cliPath, 'gh', '-
|
|
38
|
+
await execa('node', [cliPath, 'gh', '-t', 'dynamic'], {
|
|
39
39
|
cwd: dest
|
|
40
40
|
})
|
|
41
41
|
|
|
42
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)
|
|
43
44
|
t.ok(deployWorkflow.indexOf('PLATFORMATIC_DYNAMIC_WORKSPACE_API_KEY') !== -1)
|
|
44
|
-
t.ok(deployWorkflow.indexOf('WORKSPACE-ID-TEST') !== -1)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
test('creation fails if workspace is missing', 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'], {
|
|
57
|
-
cwd: dest
|
|
58
|
-
})
|
|
59
|
-
t.fail('should have failed')
|
|
60
|
-
} catch ({ stdout }) {
|
|
61
|
-
t.ok(stdout.indexOf('Workspace ID is required') !== -1)
|
|
62
|
-
}
|
|
63
45
|
})
|
|
64
46
|
|
|
65
47
|
test('creation fails if workspace type is not static or dynamic', async (t) => {
|
|
@@ -71,7 +53,7 @@ test('creation fails if workspace type is not static or dynamic', async (t) => {
|
|
|
71
53
|
join(dest, 'platformatic.db.json'))
|
|
72
54
|
|
|
73
55
|
try {
|
|
74
|
-
await execa('node', [cliPath, 'gh', '-
|
|
56
|
+
await execa('node', [cliPath, 'gh', '-t', 'XXXXX'], {
|
|
75
57
|
cwd: dest
|
|
76
58
|
})
|
|
77
59
|
t.fail('should have failed')
|
|
@@ -84,7 +66,7 @@ test('creation fails if no config file is found', async (t) => {
|
|
|
84
66
|
const dest = join(tmpdir(), `test-cli-gh-${process.pid}-${count++}`)
|
|
85
67
|
await mkdirp(dest)
|
|
86
68
|
try {
|
|
87
|
-
await execa('node', [cliPath, 'gh'
|
|
69
|
+
await execa('node', [cliPath, 'gh'], {
|
|
88
70
|
cwd: dest
|
|
89
71
|
})
|
|
90
72
|
t.fail('should have failed')
|
|
@@ -103,7 +85,7 @@ test('creates a deploy must warn that a .env exists', async (t) => {
|
|
|
103
85
|
|
|
104
86
|
await writeFile(join(dest, '.env'), 'TEST=1')
|
|
105
87
|
|
|
106
|
-
const { stdout } = await execa('node', [cliPath, 'gh'
|
|
88
|
+
const { stdout } = await execa('node', [cliPath, 'gh'], {
|
|
107
89
|
cwd: dest
|
|
108
90
|
})
|
|
109
91
|
t.ok(stdout.indexOf('Found .env file') !== -1)
|