create-platformatic 1.11.0 → 1.12.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/package.json +7 -8
- package/src/cli-options.mjs +0 -10
- package/src/composer/create-composer-cli.mjs +6 -8
- package/src/db/create-db-cli.mjs +8 -10
- package/src/db/create-db.mjs +0 -1
- package/src/index.mjs +1 -0
- package/src/runtime/create-runtime-cli.mjs +10 -8
- package/src/service/create-service-cli.mjs +6 -9
- package/src/service/create-service.mjs +0 -1
- package/.taprc +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-platformatic",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"description": "Create platformatic-db interactive tool",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"strip-ansi": "^7.1.0",
|
|
37
37
|
"undici": "^5.25.4",
|
|
38
38
|
"which": "^3.0.1",
|
|
39
|
-
"@platformatic/config": "1.
|
|
39
|
+
"@platformatic/config": "1.12.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"ajv": "^8.12.0",
|
|
@@ -46,15 +46,14 @@
|
|
|
46
46
|
"esmock": "^2.5.1",
|
|
47
47
|
"snazzy": "^9.0.0",
|
|
48
48
|
"standard": "^17.1.0",
|
|
49
|
-
"
|
|
50
|
-
"typescript": "~5.2.2",
|
|
49
|
+
"typescript": "~5.3.0",
|
|
51
50
|
"yaml": "^2.3.2",
|
|
52
|
-
"@platformatic/db": "1.
|
|
53
|
-
"@platformatic/service": "1.
|
|
51
|
+
"@platformatic/db": "1.12.1",
|
|
52
|
+
"@platformatic/service": "1.12.1"
|
|
54
53
|
},
|
|
55
54
|
"scripts": {
|
|
56
|
-
"test:cli": "
|
|
57
|
-
"test:unit": "standard | snazzy && cross-env NODE_OPTIONS=\"--loader=esmock --no-warnings\" c8
|
|
55
|
+
"test:cli": "node --test ./test/cli",
|
|
56
|
+
"test:unit": "standard | snazzy && cross-env NODE_OPTIONS=\"--loader=esmock --no-warnings\" c8 node --test ./test/unit",
|
|
58
57
|
"test": "npm run test:unit && npm run test:cli",
|
|
59
58
|
"lint": "standard | snazzy"
|
|
60
59
|
}
|
package/src/cli-options.mjs
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
export const getRunPackageManagerInstall = pkgManager => {
|
|
2
|
-
return {
|
|
3
|
-
type: 'list',
|
|
4
|
-
name: 'runPackageManagerInstall',
|
|
5
|
-
message: `Do you want to run ${pkgManager} install?`,
|
|
6
|
-
default: true,
|
|
7
|
-
choices: [{ name: 'yes', value: true }, { name: 'no', value: false }]
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
1
|
export const getUseTypescript = typescript => {
|
|
12
2
|
return {
|
|
13
3
|
type: 'list',
|
|
@@ -10,7 +10,7 @@ import { execa } from 'execa'
|
|
|
10
10
|
import ora from 'ora'
|
|
11
11
|
import createComposer from './create-composer.mjs'
|
|
12
12
|
import askDir from '../ask-dir.mjs'
|
|
13
|
-
import {
|
|
13
|
+
import { getPort, getUseTypescript, getInitGitRepository } from '../cli-options.mjs'
|
|
14
14
|
import { createReadme } from '../create-readme.mjs'
|
|
15
15
|
import { join } from 'path'
|
|
16
16
|
|
|
@@ -32,12 +32,14 @@ const createPlatformaticComposer = async (_args, opts) => {
|
|
|
32
32
|
|
|
33
33
|
const args = parseArgs(_args, {
|
|
34
34
|
default: {
|
|
35
|
-
hostname: '127.0.0.1'
|
|
35
|
+
hostname: '127.0.0.1',
|
|
36
|
+
install: true
|
|
36
37
|
},
|
|
37
38
|
alias: {
|
|
38
39
|
h: 'hostname',
|
|
39
40
|
p: 'port'
|
|
40
|
-
}
|
|
41
|
+
},
|
|
42
|
+
boolean: ['install']
|
|
41
43
|
})
|
|
42
44
|
|
|
43
45
|
const version = await getVersion()
|
|
@@ -63,9 +65,6 @@ const createPlatformaticComposer = async (_args, opts) => {
|
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
if (!opts.skipPackageJson) {
|
|
67
|
-
toAsk.push(getRunPackageManagerInstall(pkgManager))
|
|
68
|
-
}
|
|
69
68
|
if (!opts.skipGitHubActions) {
|
|
70
69
|
toAsk.push({
|
|
71
70
|
type: 'list',
|
|
@@ -87,7 +86,6 @@ const createPlatformaticComposer = async (_args, opts) => {
|
|
|
87
86
|
toAsk.push(getInitGitRepository())
|
|
88
87
|
}
|
|
89
88
|
const {
|
|
90
|
-
runPackageManagerInstall,
|
|
91
89
|
servicesToCompose,
|
|
92
90
|
port,
|
|
93
91
|
staticWorkspaceGitHubAction,
|
|
@@ -130,7 +128,7 @@ const createPlatformaticComposer = async (_args, opts) => {
|
|
|
130
128
|
}
|
|
131
129
|
await createReadme(logger, projectDir, 'composer')
|
|
132
130
|
|
|
133
|
-
if (
|
|
131
|
+
if (args.install && !opts.skipPackageJson) {
|
|
134
132
|
const spinner = ora('Installing dependencies...').start()
|
|
135
133
|
await execa(pkgManager, ['install'], { cwd: projectDir })
|
|
136
134
|
spinner.succeed()
|
package/src/db/create-db-cli.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { execa } from 'execa'
|
|
|
11
11
|
import ora from 'ora'
|
|
12
12
|
import { getConnectionString, createDB } from './create-db.mjs'
|
|
13
13
|
import askDir from '../ask-dir.mjs'
|
|
14
|
-
import {
|
|
14
|
+
import { getUseTypescript, getPort, getInitGitRepository } from '../cli-options.mjs'
|
|
15
15
|
import { createReadme } from '../create-readme.mjs'
|
|
16
16
|
import { join } from 'node:path'
|
|
17
17
|
|
|
@@ -34,7 +34,8 @@ export function parseDBArgs (_args) {
|
|
|
34
34
|
default: {
|
|
35
35
|
hostname: '127.0.0.1',
|
|
36
36
|
database: 'sqlite',
|
|
37
|
-
migrations: 'migrations'
|
|
37
|
+
migrations: 'migrations',
|
|
38
|
+
install: true
|
|
38
39
|
},
|
|
39
40
|
alias: {
|
|
40
41
|
h: 'hostname',
|
|
@@ -45,7 +46,7 @@ export function parseDBArgs (_args) {
|
|
|
45
46
|
t: 'types',
|
|
46
47
|
ts: 'typescript'
|
|
47
48
|
},
|
|
48
|
-
boolean: ['plugin', 'types', 'typescript']
|
|
49
|
+
boolean: ['plugin', 'types', 'typescript', 'install']
|
|
49
50
|
})
|
|
50
51
|
}
|
|
51
52
|
|
|
@@ -68,11 +69,6 @@ const createPlatformaticDB = async (_args, opts) => {
|
|
|
68
69
|
portQuestion.when = !isRuntimeContext
|
|
69
70
|
toAsk.push(portQuestion)
|
|
70
71
|
|
|
71
|
-
// Ask to install deps
|
|
72
|
-
const installDepsQuestion = getRunPackageManagerInstall(pkgManager)
|
|
73
|
-
installDepsQuestion.when = !opts.skipPackageJson
|
|
74
|
-
toAsk.push(installDepsQuestion)
|
|
75
|
-
|
|
76
72
|
const { database } = await inquirer.prompt({
|
|
77
73
|
type: 'list',
|
|
78
74
|
name: 'database',
|
|
@@ -208,7 +204,7 @@ const createPlatformaticDB = async (_args, opts) => {
|
|
|
208
204
|
await createReadme(logger, projectDir, 'db')
|
|
209
205
|
|
|
210
206
|
let hasPlatformaticInstalled = false
|
|
211
|
-
if (
|
|
207
|
+
if (args.install && !opts.skipPackageJson) {
|
|
212
208
|
const spinner = ora('Installing dependencies...').start()
|
|
213
209
|
await execa(pkgManager, ['install'], { cwd: projectDir })
|
|
214
210
|
spinner.succeed()
|
|
@@ -234,18 +230,20 @@ const createPlatformaticDB = async (_args, opts) => {
|
|
|
234
230
|
// - run the migrations
|
|
235
231
|
// - generate types
|
|
236
232
|
// if we don't generate migrations, we don't ask to apply them (the folder might not exist)
|
|
233
|
+
let migrationApplied = false
|
|
237
234
|
if (wizardOptions.defaultMigrations && wizardOptions.applyMigrations) {
|
|
238
235
|
const spinner = ora('Applying migrations...').start()
|
|
239
236
|
// We need to apply migrations using the platformatic installed in the project
|
|
240
237
|
try {
|
|
241
238
|
await execa(pkgManager, ['exec', 'platformatic', 'db', 'migrations', 'apply'], { cwd: projectDir })
|
|
242
239
|
spinner.succeed()
|
|
240
|
+
migrationApplied = true
|
|
243
241
|
} catch (err) {
|
|
244
242
|
logger.trace({ err })
|
|
245
243
|
spinner.fail('Failed applying migrations! Try again by running "platformatic db migrations apply"')
|
|
246
244
|
}
|
|
247
245
|
}
|
|
248
|
-
if (generatePlugin) {
|
|
246
|
+
if (generatePlugin && migrationApplied) {
|
|
249
247
|
const spinner = ora('Generating types...').start()
|
|
250
248
|
try {
|
|
251
249
|
await execa(pkgManager, ['exec', 'platformatic', 'db', 'types'], { cwd: projectDir })
|
package/src/db/create-db.mjs
CHANGED
|
@@ -376,7 +376,6 @@ export async function createDB (params, logger, currentDir, version) {
|
|
|
376
376
|
const envSample = generateEnv(isRuntimeContext, hostname, port, getConnectionString(database), typescript, envPrefix)
|
|
377
377
|
await appendFile(join(currentDir, '.env'), env)
|
|
378
378
|
await writeFile(join(currentDir, '.env.sample'), envSample)
|
|
379
|
-
logger.info('Environment file .env found, appending new environment variables to existing .env file.')
|
|
380
379
|
|
|
381
380
|
const migrationsFolderName = migrations
|
|
382
381
|
if (createMigrations) {
|
package/src/index.mjs
CHANGED
|
@@ -8,9 +8,10 @@ import pino from 'pino'
|
|
|
8
8
|
import pretty from 'pino-pretty'
|
|
9
9
|
import { execa } from 'execa'
|
|
10
10
|
import ora from 'ora'
|
|
11
|
+
import parseArgs from 'minimist'
|
|
11
12
|
import createRuntime from './create-runtime.mjs'
|
|
12
13
|
import askDir from '../ask-dir.mjs'
|
|
13
|
-
import { getInitGitRepository, getPort
|
|
14
|
+
import { getInitGitRepository, getPort } from '../cli-options.mjs'
|
|
14
15
|
import generateName from 'boring-name-generator'
|
|
15
16
|
import { chooseKind } from '../index.mjs'
|
|
16
17
|
import { createReadme } from '../create-readme.mjs'
|
|
@@ -21,6 +22,13 @@ export async function createPlatformaticRuntime (_args) {
|
|
|
21
22
|
ignore: 'hostname,pid'
|
|
22
23
|
}))
|
|
23
24
|
|
|
25
|
+
const args = parseArgs(_args, {
|
|
26
|
+
default: {
|
|
27
|
+
install: true
|
|
28
|
+
},
|
|
29
|
+
boolean: ['install']
|
|
30
|
+
})
|
|
31
|
+
|
|
24
32
|
const version = await getVersion()
|
|
25
33
|
const pkgManager = getPkgManager()
|
|
26
34
|
|
|
@@ -40,11 +48,6 @@ export async function createPlatformaticRuntime (_args) {
|
|
|
40
48
|
process.exit(1)
|
|
41
49
|
}
|
|
42
50
|
|
|
43
|
-
toAsk.push(getRunPackageManagerInstall(pkgManager))
|
|
44
|
-
// const { runPackageManagerInstall } = await inquirer.prompt([
|
|
45
|
-
// getRunPackageManagerInstall(pkgManager)
|
|
46
|
-
// ])
|
|
47
|
-
|
|
48
51
|
toAsk.push({
|
|
49
52
|
type: 'list',
|
|
50
53
|
name: 'staticWorkspaceGitHubAction',
|
|
@@ -62,7 +65,6 @@ export async function createPlatformaticRuntime (_args) {
|
|
|
62
65
|
|
|
63
66
|
toAsk.push(getInitGitRepository())
|
|
64
67
|
const {
|
|
65
|
-
runPackageManagerInstall,
|
|
66
68
|
staticWorkspaceGitHubAction,
|
|
67
69
|
dynamicWorkspaceGitHubAction,
|
|
68
70
|
initGitRepository
|
|
@@ -138,7 +140,7 @@ export async function createPlatformaticRuntime (_args) {
|
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
await createRuntime(params, logger, projectDir, version)
|
|
141
|
-
if (
|
|
143
|
+
if (args.install) {
|
|
142
144
|
const spinner = ora('Installing dependencies...').start()
|
|
143
145
|
await execa(pkgManager, ['install'], { cwd: projectDir })
|
|
144
146
|
spinner.succeed()
|
|
@@ -11,7 +11,7 @@ import { execa } from 'execa'
|
|
|
11
11
|
import ora from 'ora'
|
|
12
12
|
import createService from './create-service.mjs'
|
|
13
13
|
import askDir from '../ask-dir.mjs'
|
|
14
|
-
import {
|
|
14
|
+
import { getUseTypescript, getPort, getInitGitRepository } from '../cli-options.mjs'
|
|
15
15
|
import { createReadme } from '../create-readme.mjs'
|
|
16
16
|
|
|
17
17
|
const createPlatformaticService = async (_args, opts = {}) => {
|
|
@@ -22,12 +22,14 @@ const createPlatformaticService = async (_args, opts = {}) => {
|
|
|
22
22
|
|
|
23
23
|
const args = parseArgs(_args, {
|
|
24
24
|
default: {
|
|
25
|
-
hostname: '127.0.0.1'
|
|
25
|
+
hostname: '127.0.0.1',
|
|
26
|
+
install: true
|
|
26
27
|
},
|
|
27
28
|
alias: {
|
|
28
29
|
h: 'hostname',
|
|
29
30
|
p: 'port'
|
|
30
|
-
}
|
|
31
|
+
},
|
|
32
|
+
boolean: ['install']
|
|
31
33
|
})
|
|
32
34
|
|
|
33
35
|
const version = await getVersion()
|
|
@@ -43,10 +45,6 @@ const createPlatformaticService = async (_args, opts = {}) => {
|
|
|
43
45
|
toAsk.push(getPort(args.port))
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
if (!opts.skipPackageJson) {
|
|
47
|
-
toAsk.unshift(getRunPackageManagerInstall(pkgManager))
|
|
48
|
-
}
|
|
49
|
-
|
|
50
48
|
if (!opts.skipGitHubActions) {
|
|
51
49
|
toAsk.push({
|
|
52
50
|
type: 'list',
|
|
@@ -67,7 +65,6 @@ const createPlatformaticService = async (_args, opts = {}) => {
|
|
|
67
65
|
toAsk.push(getInitGitRepository())
|
|
68
66
|
}
|
|
69
67
|
const {
|
|
70
|
-
runPackageManagerInstall,
|
|
71
68
|
useTypescript,
|
|
72
69
|
port,
|
|
73
70
|
staticWorkspaceGitHubAction,
|
|
@@ -106,7 +103,7 @@ const createPlatformaticService = async (_args, opts = {}) => {
|
|
|
106
103
|
}
|
|
107
104
|
await createReadme(logger, projectDir, 'service')
|
|
108
105
|
|
|
109
|
-
if (
|
|
106
|
+
if (args.install && !opts.skipPackageJson) {
|
|
110
107
|
const spinner = ora('Installing dependencies...').start()
|
|
111
108
|
await execa(pkgManager, ['install'], { cwd: projectDir })
|
|
112
109
|
spinner.succeed()
|
|
@@ -99,7 +99,6 @@ async function createService (params, logger, currentDir = process.cwd(), versio
|
|
|
99
99
|
const env = generateEnv(isRuntimeContext, hostname, port, typescript, envPrefix)
|
|
100
100
|
await appendFile(join(currentDir, '.env'), env)
|
|
101
101
|
await writeFile(join(currentDir, '.env.sample'), env)
|
|
102
|
-
logger.info('Environment file .env found, appending new environment variables to existing .env file.')
|
|
103
102
|
|
|
104
103
|
if (typescript === true) {
|
|
105
104
|
const tsConfigFileName = join(currentDir, 'tsconfig.json')
|
package/.taprc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
jobs: 1
|