create-platformatic 0.21.1 → 0.22.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-platformatic",
3
- "version": "0.21.1",
3
+ "version": "0.22.0",
4
4
  "description": "Create platformatic-db interactive tool",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,31 +19,32 @@
19
19
  "commist": "^3.2.0",
20
20
  "desm": "^1.3.0",
21
21
  "es-main": "^1.2.0",
22
- "execa": "^7.0.0",
23
- "fastify": "^4.13.0",
22
+ "execa": "^7.1.1",
23
+ "fastify": "^4.17.0",
24
24
  "help-me": "^4.2.0",
25
- "inquirer": "^9.1.4",
25
+ "inquirer": "^9.2.0",
26
26
  "log-update": "^5.0.1",
27
27
  "minimist": "^1.2.8",
28
- "mkdirp": "^2.1.3",
29
- "ora": "^6.1.2",
28
+ "mkdirp": "^2.1.6",
29
+ "ora": "^6.3.0",
30
30
  "pino": "^8.11.0",
31
31
  "pino-pretty": "^10.0.0",
32
32
  "pupa": "^3.1.0",
33
- "semver": "^7.3.8",
34
- "undici": "^5.20.0"
33
+ "semver": "^7.5.0",
34
+ "undici": "^5.22.0",
35
+ "@platformatic/config": "0.22.0"
35
36
  },
36
37
  "devDependencies": {
37
38
  "ajv": "^8.12.0",
38
39
  "c8": "^7.13.0",
39
40
  "dotenv": "^16.0.3",
40
- "esmock": "^2.1.0",
41
+ "esmock": "^2.2.1",
41
42
  "snazzy": "^9.0.0",
42
43
  "standard": "^17.0.0",
43
44
  "tap": "^16.3.4",
44
- "yaml": "^2.2.1",
45
- "@platformatic/db": "0.21.1",
46
- "@platformatic/service": "0.21.1"
45
+ "yaml": "^2.2.2",
46
+ "@platformatic/db": "0.22.0",
47
+ "@platformatic/service": "0.22.0"
47
48
  },
48
49
  "scripts": {
49
50
  "test": "standard | snazzy && NODE_OPTIONS=--loader=esmock c8 --100 tap --no-coverage test/*test.mjs test/*/*test.mjs",
@@ -61,8 +61,13 @@ function generateConfig (migrations, plugin, types, typescript, version) {
61
61
  connectionString: '{DATABASE_URL}',
62
62
  graphql: true,
63
63
  openapi: true
64
- },
65
- migrations: { dir: migrations }
64
+ }
65
+ }
66
+
67
+ if (migrations) {
68
+ config.migrations = {
69
+ dir: migrations
70
+ }
66
71
  }
67
72
 
68
73
  if (plugin === true) {
package/src/utils.mjs CHANGED
@@ -4,6 +4,7 @@ import { resolve, join, dirname } from 'path'
4
4
  import { createRequire } from 'module'
5
5
  import semver from 'semver'
6
6
  import * as desm from 'desm'
7
+ import ConfigManager from '@platformatic/config'
7
8
 
8
9
  export const sleep = ms => new Promise((resolve) => setTimeout(resolve, ms))
9
10
  export const randomBetween = (min, max) => Math.floor(Math.random() * (max - min + 1) + min)
@@ -67,22 +68,8 @@ export const validatePath = async projectPath => {
67
68
  return canAccessParent
68
69
  }
69
70
 
70
- const findConfigFile = async (directory, type) => {
71
- const configFileNames = [
72
- `platformatic.${type}.json`,
73
- `platformatic.${type}.json5`,
74
- `platformatic.${type}.yaml`,
75
- `platformatic.${type}.yml`,
76
- `platformatic.${type}.toml`,
77
- `platformatic.${type}.tml`
78
- ]
79
- const configFilesAccessibility = await Promise.all(configFileNames.map((fileName) => isFileAccessible(fileName, directory)))
80
- const accessibleConfigFilename = configFileNames.find((value, index) => configFilesAccessibility[index])
81
- return accessibleConfigFilename
82
- }
83
-
84
- export const findDBConfigFile = async (directory) => (findConfigFile(directory, 'db'))
85
- export const findServiceConfigFile = async (directory) => (findConfigFile(directory, 'service'))
71
+ export const findDBConfigFile = async (directory) => (ConfigManager.findConfigFile(directory, 'db'))
72
+ export const findServiceConfigFile = async (directory) => (ConfigManager.findConfigFile(directory, 'service'))
86
73
 
87
74
  export const getDependencyVersion = async (dependencyName) => {
88
75
  const require = createRequire(import.meta.url)
@@ -136,6 +136,23 @@ test('creates project with no typescript and no plugin', async ({ equal }) => {
136
136
  equal(await isFileAccessible(join(tmpDir, 'plugin.js')), false)
137
137
  })
138
138
 
139
+ test('creates project with no migrations', async ({ equal }) => {
140
+ const params = {
141
+ hostname: 'myhost',
142
+ port: 6666,
143
+ migrations: ''
144
+ }
145
+
146
+ await createDB(params, fakeLogger, tmpDir)
147
+
148
+ const pathToDbConfigFile = join(tmpDir, 'platformatic.db.json')
149
+ const dbConfigFile = readFileSync(pathToDbConfigFile, 'utf8')
150
+ const dbConfig = JSON.parse(dbConfigFile)
151
+ const { migrations } = dbConfig
152
+
153
+ equal(migrations, undefined)
154
+ })
155
+
139
156
  test('creates project with typescript', async ({ equal, same }) => {
140
157
  const params = {
141
158
  hostname: 'myhost',