create-platformatic 0.13.0 → 0.14.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 +2 -2
- package/src/create-gitignore.mjs +6 -0
- package/src/index.mjs +2 -2
- package/src/utils.mjs +7 -14
- package/test/utils.test.mjs +44 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-platformatic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Create platformatic-db interactive tool",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"inquirer": "^9.1.4",
|
|
25
25
|
"log-update": "^5.0.1",
|
|
26
26
|
"minimist": "^1.2.7",
|
|
27
|
-
"mkdirp": "^
|
|
27
|
+
"mkdirp": "^2.0.0",
|
|
28
28
|
"ora": "^6.1.2",
|
|
29
29
|
"pino": "^8.8.0",
|
|
30
30
|
"pino-pretty": "^9.1.1",
|
package/src/create-gitignore.mjs
CHANGED
package/src/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import inquirer from 'inquirer'
|
|
|
5
5
|
import createPlatformaticDB from './db/create-db-cli.mjs'
|
|
6
6
|
import createPlatformaticService from './service/create-service-cli.mjs'
|
|
7
7
|
import commist from 'commist'
|
|
8
|
-
import { getUsername, getVersion,
|
|
8
|
+
import { getUsername, getVersion, minimumSupportedNodeVersions, isCurrentVersionSupported } from './utils.mjs'
|
|
9
9
|
|
|
10
10
|
const createPlatformatic = async (argv) => {
|
|
11
11
|
const help = helpMe({
|
|
@@ -33,7 +33,7 @@ const createPlatformatic = async (argv) => {
|
|
|
33
33
|
const currentVersion = process.versions.node
|
|
34
34
|
const supported = isCurrentVersionSupported(currentVersion)
|
|
35
35
|
if (!supported) {
|
|
36
|
-
const supportedVersions =
|
|
36
|
+
const supportedVersions = minimumSupportedNodeVersions.join(' or >= ')
|
|
37
37
|
await say(`Platformatic is not supported on Node.js v${currentVersion}.`)
|
|
38
38
|
await say(`Please use one of the following Node.js versions >= ${supportedVersions}.`)
|
|
39
39
|
}
|
package/src/utils.mjs
CHANGED
|
@@ -71,10 +71,7 @@ export const validatePath = async projectPath => {
|
|
|
71
71
|
// if the folder does not exist, check if the parent folder exists:
|
|
72
72
|
const parentDir = dirname(projectDir)
|
|
73
73
|
const canAccessParent = await isDirectoryWriteable(parentDir)
|
|
74
|
-
|
|
75
|
-
return true
|
|
76
|
-
}
|
|
77
|
-
return false
|
|
74
|
+
return canAccessParent
|
|
78
75
|
}
|
|
79
76
|
|
|
80
77
|
const findConfigFile = async (directory, type) => {
|
|
@@ -102,18 +99,14 @@ export const getDependencyVersion = async (dependencyName) => {
|
|
|
102
99
|
return packageJson.version
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
export const
|
|
106
|
-
return ['16.17.0', '18.8.0', '19.0.0']
|
|
107
|
-
}
|
|
102
|
+
export const minimumSupportedNodeVersions = ['16.17.0', '18.8.0', '19.0.0']
|
|
108
103
|
|
|
109
104
|
export const isCurrentVersionSupported = (currentVersion) => {
|
|
110
|
-
|
|
111
|
-
for (const version of
|
|
112
|
-
if (semver.
|
|
113
|
-
|
|
114
|
-
return false
|
|
105
|
+
// TODO: add try/catch if some unsupported node version is passed
|
|
106
|
+
for (const version of minimumSupportedNodeVersions) {
|
|
107
|
+
if (semver.major(currentVersion) === semver.major(version) && semver.gte(currentVersion, version)) {
|
|
108
|
+
return true
|
|
115
109
|
}
|
|
116
|
-
break
|
|
117
110
|
}
|
|
118
|
-
return
|
|
111
|
+
return false
|
|
119
112
|
}
|
package/test/utils.test.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test, beforeEach } from 'tap'
|
|
2
2
|
import { MockAgent, setGlobalDispatcher } from 'undici'
|
|
3
|
-
import { getVersion, randomBetween, sleep, validatePath, getDependencyVersion, findDBConfigFile, findServiceConfigFile, isFileAccessible, isCurrentVersionSupported,
|
|
3
|
+
import { getVersion, randomBetween, sleep, validatePath, getDependencyVersion, findDBConfigFile, findServiceConfigFile, isFileAccessible, isCurrentVersionSupported, minimumSupportedNodeVersions } from '../src/utils.mjs'
|
|
4
4
|
import { mkdtempSync, rmSync, writeFileSync } from 'fs'
|
|
5
5
|
import { tmpdir } from 'os'
|
|
6
6
|
import { join } from 'path'
|
|
@@ -220,28 +220,62 @@ test('isFileAccessible', async ({ end, equal, mock }) => {
|
|
|
220
220
|
rmSync(tmpDir1, { recursive: true, force: true })
|
|
221
221
|
})
|
|
222
222
|
|
|
223
|
-
test('
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
not(supportedVersions.length, 0)
|
|
223
|
+
test('minimumSupportedNodeVersions', async ({ equal, not }) => {
|
|
224
|
+
equal(Array.isArray(minimumSupportedNodeVersions), true)
|
|
225
|
+
not(minimumSupportedNodeVersions.length, 0)
|
|
227
226
|
})
|
|
228
227
|
|
|
229
228
|
test('isCurrentVersionSupported', async ({ equal }) => {
|
|
230
|
-
const
|
|
231
|
-
const { major, minor, patch } = semver.minVersion(supportedVersions[0])
|
|
229
|
+
const { major, minor, patch } = semver.minVersion(minimumSupportedNodeVersions[0])
|
|
232
230
|
{
|
|
233
|
-
// major not supported
|
|
231
|
+
// v15 major not supported
|
|
234
232
|
const nodeVersion = `${major - 1}.${minor}.${patch}`
|
|
235
233
|
const supported = isCurrentVersionSupported(nodeVersion)
|
|
236
234
|
equal(supported, false)
|
|
237
235
|
}
|
|
238
236
|
{
|
|
239
|
-
//
|
|
237
|
+
// v17 major not supported
|
|
238
|
+
const nodeVersion = `${major + 1}.${minor}.${patch}`
|
|
239
|
+
const supported = isCurrentVersionSupported(nodeVersion)
|
|
240
|
+
equal(supported, false)
|
|
241
|
+
}
|
|
242
|
+
{
|
|
243
|
+
// v16 minor not supported
|
|
240
244
|
const nodeVersion = `${major}.${minor - 1}.${patch}`
|
|
241
245
|
const supported = isCurrentVersionSupported(nodeVersion)
|
|
242
246
|
equal(supported, false)
|
|
243
247
|
}
|
|
244
|
-
|
|
248
|
+
{
|
|
249
|
+
// v16 more than minimum is supported
|
|
250
|
+
const supported = isCurrentVersionSupported(`${major}.${minor + 2}.${patch}`)
|
|
251
|
+
equal(supported, true)
|
|
252
|
+
}
|
|
253
|
+
// node version 18 test, to check greater and lesser major version
|
|
254
|
+
const { major: major18, minor: minor18, patch: patch18 } = semver.minVersion(minimumSupportedNodeVersions[1])
|
|
255
|
+
{
|
|
256
|
+
// v17 major not supported
|
|
257
|
+
const nodeVersion = `${major18 - 1}.${minor18}.${patch18}`
|
|
258
|
+
const supported = isCurrentVersionSupported(nodeVersion)
|
|
259
|
+
equal(supported, false)
|
|
260
|
+
}
|
|
261
|
+
{
|
|
262
|
+
// v19 is supported
|
|
263
|
+
const nodeVersion = `${major18 + 1}.${minor18}.${patch18}`
|
|
264
|
+
const supported = isCurrentVersionSupported(nodeVersion)
|
|
265
|
+
equal(supported, true)
|
|
266
|
+
}
|
|
267
|
+
{
|
|
268
|
+
// v18 minor not supported
|
|
269
|
+
const nodeVersion = `${major18}.${minor18 - 2}.${patch18}`
|
|
270
|
+
const supported = isCurrentVersionSupported(nodeVersion)
|
|
271
|
+
equal(supported, false)
|
|
272
|
+
}
|
|
273
|
+
{
|
|
274
|
+
// v18 supported
|
|
275
|
+
const supported = isCurrentVersionSupported(`${major18}.${minor18 + 1}.${patch18}`)
|
|
276
|
+
equal(supported, true)
|
|
277
|
+
}
|
|
278
|
+
for (const version of minimumSupportedNodeVersions) {
|
|
245
279
|
const supported = isCurrentVersionSupported(version)
|
|
246
280
|
equal(supported, true)
|
|
247
281
|
}
|