create-platformatic 0.23.1 → 0.24.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 +6 -5
- package/src/db/create-db.mjs +1 -0
- package/src/service/create-service.mjs +1 -0
- package/test/create-gitignore.test.mjs +2 -2
- package/test/create-package-json.test.mjs +4 -4
- package/test/db/create-db.test.mjs +2 -1
- package/test/ghaction-dynamic.test.mjs +1 -1
- package/test/ghaction-static.test.mjs +1 -1
- package/test/service/create-service.test.mjs +2 -1
- package/test/utils.test.mjs +13 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-platformatic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Create platformatic-db interactive tool",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,22 +32,23 @@
|
|
|
32
32
|
"pupa": "^3.1.0",
|
|
33
33
|
"semver": "^7.5.0",
|
|
34
34
|
"undici": "^5.22.0",
|
|
35
|
-
"@platformatic/config": "0.
|
|
35
|
+
"@platformatic/config": "0.24.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"ajv": "^8.12.0",
|
|
39
39
|
"c8": "^7.13.0",
|
|
40
|
+
"cross-env": "^7.0.3",
|
|
40
41
|
"dotenv": "^16.0.3",
|
|
41
42
|
"esmock": "^2.2.1",
|
|
42
43
|
"snazzy": "^9.0.0",
|
|
43
44
|
"standard": "^17.0.0",
|
|
44
45
|
"tap": "^16.3.4",
|
|
45
46
|
"yaml": "^2.2.2",
|
|
46
|
-
"@platformatic/db": "0.
|
|
47
|
-
"@platformatic/service": "0.
|
|
47
|
+
"@platformatic/db": "0.24.0",
|
|
48
|
+
"@platformatic/service": "0.24.0"
|
|
48
49
|
},
|
|
49
50
|
"scripts": {
|
|
50
|
-
"test": "standard | snazzy && NODE_OPTIONS
|
|
51
|
+
"test": "standard | snazzy && cross-env NODE_OPTIONS=\"--loader=esmock --no-warnings\" c8 --100 tap --no-coverage test/*test.mjs test/*/*test.mjs",
|
|
51
52
|
"lint": "standard | snazzy"
|
|
52
53
|
}
|
|
53
54
|
}
|
package/src/db/create-db.mjs
CHANGED
|
@@ -144,6 +144,7 @@ async function createDB ({ hostname, database = 'sqlite', port, migrations = 'mi
|
|
|
144
144
|
const envFileExists = await isFileAccessible('.env', currentDir)
|
|
145
145
|
await appendFile(join(currentDir, '.env'), env)
|
|
146
146
|
await writeFile(join(currentDir, '.env.sample'), env)
|
|
147
|
+
/* c8 ignore next 5 */
|
|
147
148
|
if (envFileExists) {
|
|
148
149
|
logger.info('Environment file .env found, appending new environment variables to existing .env file.')
|
|
149
150
|
} else {
|
|
@@ -145,6 +145,7 @@ async function createService ({ hostname, port, typescript = false }, logger, cu
|
|
|
145
145
|
const envFileExists = await isFileAccessible('.env', currentDir)
|
|
146
146
|
await appendFile(join(currentDir, '.env'), env)
|
|
147
147
|
await writeFile(join(currentDir, '.env.sample'), env)
|
|
148
|
+
/* c8 ignore next 5 */
|
|
148
149
|
if (envFileExists) {
|
|
149
150
|
logger.info('Environment file .env found, appending new environment variables to existing .env file.')
|
|
150
151
|
} else {
|
|
@@ -22,7 +22,7 @@ afterEach(() => {
|
|
|
22
22
|
|
|
23
23
|
test('creates gitignore file', async ({ end, equal }) => {
|
|
24
24
|
await createGitignore(fakeLogger, tmpDir)
|
|
25
|
-
equal(log, `Gitignore file ${tmpDir}
|
|
25
|
+
equal(log, `Gitignore file ${join(tmpDir, '.gitignore')} successfully created.`)
|
|
26
26
|
const accessible = await isFileAccessible(join(tmpDir, '.gitignore'))
|
|
27
27
|
equal(accessible, true)
|
|
28
28
|
})
|
|
@@ -31,5 +31,5 @@ test('do not create gitignore file because already present', async ({ end, equal
|
|
|
31
31
|
const gitignore = join(tmpDir, '.gitignore')
|
|
32
32
|
writeFileSync(gitignore, 'TEST')
|
|
33
33
|
await createGitignore(fakeLogger, tmpDir)
|
|
34
|
-
equal(log, `Gitignore file ${tmpDir}
|
|
34
|
+
equal(log, `Gitignore file ${join(tmpDir, '.gitignore')} found, skipping creation of gitignore file.`)
|
|
35
35
|
})
|
|
@@ -24,7 +24,7 @@ test('creates package.json file for db project', async ({ equal }) => {
|
|
|
24
24
|
const version = '1.2.3'
|
|
25
25
|
const fastifyVersion = '4.5.6'
|
|
26
26
|
await createPackageJson('db', version, fastifyVersion, fakeLogger, tmpDir, false)
|
|
27
|
-
equal(log, `${tmpDir
|
|
27
|
+
equal(log, `${join(tmpDir, 'package.json')} successfully created.`)
|
|
28
28
|
const accessible = await isFileAccessible(join(tmpDir, 'package.json'))
|
|
29
29
|
equal(accessible, true)
|
|
30
30
|
const packageJson = JSON.parse(readFileSync(join(tmpDir, 'package.json')))
|
|
@@ -38,7 +38,7 @@ test('creates package.json file for service project', async ({ equal }) => {
|
|
|
38
38
|
const version = '1.2.3'
|
|
39
39
|
const fastifyVersion = '4.5.6'
|
|
40
40
|
await createPackageJson('service', version, fastifyVersion, fakeLogger, tmpDir, false)
|
|
41
|
-
equal(log, `${tmpDir
|
|
41
|
+
equal(log, `${join(tmpDir, 'package.json')} successfully created.`)
|
|
42
42
|
const accessible = await isFileAccessible(join(tmpDir, 'package.json'))
|
|
43
43
|
equal(accessible, true)
|
|
44
44
|
const packageJson = JSON.parse(readFileSync(join(tmpDir, 'package.json')))
|
|
@@ -53,14 +53,14 @@ test('do not create package.json file because already present', async ({ equal }
|
|
|
53
53
|
const packagejson = join(tmpDir, 'package.json')
|
|
54
54
|
writeFileSync(packagejson, 'TEST')
|
|
55
55
|
await createPackageJson('db', version, fastifyVersion, fakeLogger, tmpDir, false)
|
|
56
|
-
equal(log, `${tmpDir
|
|
56
|
+
equal(log, `${join(tmpDir, 'package.json')} found, skipping creation of package.json file.`)
|
|
57
57
|
})
|
|
58
58
|
|
|
59
59
|
test('creates package.json file with TS build', async ({ equal }) => {
|
|
60
60
|
const version = '1.2.3'
|
|
61
61
|
const fastifyVersion = '4.5.6'
|
|
62
62
|
await createPackageJson('db', version, fastifyVersion, fakeLogger, tmpDir, true)
|
|
63
|
-
equal(log, `${tmpDir
|
|
63
|
+
equal(log, `${join(tmpDir, 'package.json')} successfully created.`)
|
|
64
64
|
const accessible = await isFileAccessible(join(tmpDir, 'package.json'))
|
|
65
65
|
equal(accessible, true)
|
|
66
66
|
const packageJson = JSON.parse(readFileSync(join(tmpDir, 'package.json')))
|
|
@@ -21,10 +21,11 @@ const moviesMigrationUndo = `
|
|
|
21
21
|
DROP TABLE movies;
|
|
22
22
|
`
|
|
23
23
|
|
|
24
|
+
const base = tmpdir()
|
|
24
25
|
let tmpDir
|
|
25
26
|
let log = []
|
|
26
27
|
beforeEach(() => {
|
|
27
|
-
tmpDir = mkdtempSync(join(
|
|
28
|
+
tmpDir = mkdtempSync(join(base, 'test-create-platformatic-'))
|
|
28
29
|
})
|
|
29
30
|
|
|
30
31
|
afterEach(() => {
|
|
@@ -77,7 +77,7 @@ test('do not create gitignore file because already present', async ({ end, equal
|
|
|
77
77
|
await writeFile(ghaction, 'TEST')
|
|
78
78
|
const workspaceId = '29aa2d07-e1c5-440f-bf3a-cd654d91f7ed'
|
|
79
79
|
await createDynamicWorkspaceGHAction(fakeLogger, workspaceId, env, 'db', tmpDir)
|
|
80
|
-
equal(log[0], `Github action file ${tmpDir
|
|
80
|
+
equal(log[0], `Github action file ${join(tmpDir, '.github', 'workflows', 'platformatic-dynamic-workspace-deploy.yml')} found, skipping creation of github action file.`)
|
|
81
81
|
})
|
|
82
82
|
|
|
83
83
|
test('creates gh action with a warn if a .git folder is not present', async ({ end, equal }) => {
|
|
@@ -75,7 +75,7 @@ test('do not create gitignore file because already present', async ({ end, equal
|
|
|
75
75
|
await writeFile(ghaction, 'TEST')
|
|
76
76
|
const workspaceId = '29aa2d07-e1c5-440f-bf3a-cd654d91f7ed'
|
|
77
77
|
await createStaticWorkspaceGHAction(fakeLogger, workspaceId, env, 'db', tmpDir)
|
|
78
|
-
equal(log[0], `Github action file ${tmpDir
|
|
78
|
+
equal(log[0], `Github action file ${join(tmpDir, '.github', 'workflows', 'platformatic-static-workspace-deploy.yml')} found, skipping creation of github action file.`)
|
|
79
79
|
})
|
|
80
80
|
|
|
81
81
|
test('creates gh action with a warn if a .git folder is not present', async ({ end, equal }) => {
|
|
@@ -8,10 +8,11 @@ import dotenv from 'dotenv'
|
|
|
8
8
|
import Ajv from 'ajv'
|
|
9
9
|
import { schema } from '@platformatic/service'
|
|
10
10
|
|
|
11
|
+
const base = tmpdir()
|
|
11
12
|
let tmpDir
|
|
12
13
|
let log = []
|
|
13
14
|
beforeEach(() => {
|
|
14
|
-
tmpDir = mkdtempSync(join(
|
|
15
|
+
tmpDir = mkdtempSync(join(base, 'test-create-platformatic-'))
|
|
15
16
|
})
|
|
16
17
|
|
|
17
18
|
afterEach(() => {
|
package/test/utils.test.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { test } from 'tap'
|
|
2
2
|
import { randomBetween, sleep, validatePath, getDependencyVersion, findDBConfigFile, findServiceConfigFile, isFileAccessible, isCurrentVersionSupported, minimumSupportedNodeVersions } from '../src/utils.mjs'
|
|
3
3
|
import { mkdtempSync, rmSync, writeFileSync } from 'fs'
|
|
4
|
-
import { tmpdir } from 'os'
|
|
4
|
+
import { tmpdir, platform } from 'os'
|
|
5
5
|
import { join } from 'path'
|
|
6
6
|
import esmock from 'esmock'
|
|
7
7
|
import semver from 'semver'
|
|
@@ -122,7 +122,7 @@ test('validatePath', async ({ end, equal, rejects, ok }) => {
|
|
|
122
122
|
ok(valid)
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
{
|
|
125
|
+
if (platform().indexOf('win') < 0) {
|
|
126
126
|
// not writeable folder
|
|
127
127
|
const valid = await validatePath('/')
|
|
128
128
|
ok(!valid)
|
|
@@ -176,19 +176,13 @@ test('minimumSupportedNodeVersions', async ({ equal, not }) => {
|
|
|
176
176
|
test('isCurrentVersionSupported', async ({ equal }) => {
|
|
177
177
|
const { major, minor, patch } = semver.minVersion(minimumSupportedNodeVersions[0])
|
|
178
178
|
{
|
|
179
|
-
//
|
|
179
|
+
// major - 1 not supported
|
|
180
180
|
const nodeVersion = `${major - 1}.${minor}.${patch}`
|
|
181
181
|
const supported = isCurrentVersionSupported(nodeVersion)
|
|
182
182
|
equal(supported, false)
|
|
183
183
|
}
|
|
184
184
|
{
|
|
185
|
-
//
|
|
186
|
-
const nodeVersion = `${major + 1}.${minor}.${patch}`
|
|
187
|
-
const supported = isCurrentVersionSupported(nodeVersion)
|
|
188
|
-
equal(supported, false)
|
|
189
|
-
}
|
|
190
|
-
{
|
|
191
|
-
// v16 minor not supported
|
|
185
|
+
// minor - 1 not supported
|
|
192
186
|
const nodeVersion = `${major}.${minor - 1}.${patch}`
|
|
193
187
|
const supported = isCurrentVersionSupported(nodeVersion)
|
|
194
188
|
equal(supported, false)
|
|
@@ -198,29 +192,24 @@ test('isCurrentVersionSupported', async ({ equal }) => {
|
|
|
198
192
|
const supported = isCurrentVersionSupported(`${major}.${minor + 2}.${patch}`)
|
|
199
193
|
equal(supported, true)
|
|
200
194
|
}
|
|
201
|
-
|
|
202
|
-
|
|
195
|
+
|
|
196
|
+
// node version 19 test, to check greater and lesser major version
|
|
197
|
+
const { major: major19, minor: minor19, patch: patch19 } = semver.minVersion(minimumSupportedNodeVersions[1])
|
|
203
198
|
{
|
|
204
|
-
//
|
|
205
|
-
const nodeVersion = `${
|
|
199
|
+
// v18.0.0 is not supported
|
|
200
|
+
const nodeVersion = `${major19 - 1}.${minor19}.${patch19}`
|
|
206
201
|
const supported = isCurrentVersionSupported(nodeVersion)
|
|
207
202
|
equal(supported, false)
|
|
208
203
|
}
|
|
209
204
|
{
|
|
210
|
-
//
|
|
211
|
-
const nodeVersion = `${
|
|
212
|
-
const supported = isCurrentVersionSupported(nodeVersion)
|
|
213
|
-
equal(supported, true)
|
|
214
|
-
}
|
|
215
|
-
{
|
|
216
|
-
// v18 minor not supported
|
|
217
|
-
const nodeVersion = `${major18}.${minor18 - 2}.${patch18}`
|
|
205
|
+
// v20 is not supported
|
|
206
|
+
const nodeVersion = `${major19 + 1}.${minor19}.${patch19}`
|
|
218
207
|
const supported = isCurrentVersionSupported(nodeVersion)
|
|
219
208
|
equal(supported, false)
|
|
220
209
|
}
|
|
221
210
|
{
|
|
222
|
-
//
|
|
223
|
-
const supported = isCurrentVersionSupported(`${
|
|
211
|
+
// v19 supported
|
|
212
|
+
const supported = isCurrentVersionSupported(`${major19}.${minor19 + 1}.${patch19}`)
|
|
224
213
|
equal(supported, true)
|
|
225
214
|
}
|
|
226
215
|
for (const version of minimumSupportedNodeVersions) {
|