create-platformatic 2.67.0-alpha.2 → 2.67.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 +8 -8
- package/src/index.mjs +58 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-platformatic",
|
|
3
|
-
"version": "2.67.0
|
|
3
|
+
"version": "2.67.0",
|
|
4
4
|
"description": "Create platformatic application interactive tool",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"strip-ansi": "^7.1.0",
|
|
33
33
|
"undici": "^7.0.0",
|
|
34
34
|
"which": "^3.0.1",
|
|
35
|
-
"@platformatic/
|
|
36
|
-
"@platformatic/
|
|
37
|
-
"@platformatic/
|
|
35
|
+
"@platformatic/generators": "2.67.0",
|
|
36
|
+
"@platformatic/utils": "2.67.0",
|
|
37
|
+
"@platformatic/config": "2.67.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^22.5.0",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"neostandard": "^0.12.0",
|
|
50
50
|
"typescript": "~5.8.0",
|
|
51
51
|
"yaml": "^2.4.1",
|
|
52
|
-
"@platformatic/composer": "2.67.0
|
|
53
|
-
"@platformatic/
|
|
54
|
-
"@platformatic/service": "2.67.0
|
|
55
|
-
"@platformatic/
|
|
52
|
+
"@platformatic/composer": "2.67.0",
|
|
53
|
+
"@platformatic/runtime": "2.67.0",
|
|
54
|
+
"@platformatic/service": "2.67.0",
|
|
55
|
+
"@platformatic/db": "2.67.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"test:cli": "borp --pattern \"test/cli/*test.mjs\" --timeout=300000 --concurrency=1",
|
package/src/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ConfigManager, { findConfigurationFile, loadConfigurationFile } from '@platformatic/config'
|
|
2
|
+
import { ImportGenerator } from '@platformatic/generators'
|
|
2
3
|
import { createDirectory, executeWithTimeout, generateDashedName, getPkgManager } from '@platformatic/utils'
|
|
3
4
|
import { execa } from 'execa'
|
|
4
5
|
import { glob } from 'glob'
|
|
@@ -7,7 +8,7 @@ import parseArgs from 'minimist'
|
|
|
7
8
|
import { existsSync } from 'node:fs'
|
|
8
9
|
import { readFile, writeFile } from 'node:fs/promises'
|
|
9
10
|
import { basename, dirname, join, resolve } from 'node:path'
|
|
10
|
-
import { pathToFileURL } from 'node:url'
|
|
11
|
+
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
11
12
|
import ora from 'ora'
|
|
12
13
|
import pino from 'pino'
|
|
13
14
|
import pretty from 'pino-pretty'
|
|
@@ -54,6 +55,35 @@ export async function chooseStackable (inquirer, stackables) {
|
|
|
54
55
|
return options.type
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
async function getPackageVersion (pkg, projectDir) {
|
|
59
|
+
let main
|
|
60
|
+
try {
|
|
61
|
+
main = import.meta.resolve(pkg)
|
|
62
|
+
} catch {
|
|
63
|
+
main = resolveModule.sync(pkg, { basedir: projectDir })
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (main.startsWith('file:')) {
|
|
67
|
+
main = fileURLToPath(main)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let root = dirname(main)
|
|
71
|
+
|
|
72
|
+
while (!existsSync(join(root, 'package.json'))) {
|
|
73
|
+
const parent = dirname(root)
|
|
74
|
+
|
|
75
|
+
if (parent === root) {
|
|
76
|
+
// We reached the root of the filesystem
|
|
77
|
+
throw new Error(`Could not find package.json for ${pkg}.`)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
root = parent
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const packageJsonPath = JSON.parse(await readFile(join(root, 'package.json'), 'utf-8'))
|
|
84
|
+
return packageJsonPath.version
|
|
85
|
+
}
|
|
86
|
+
|
|
57
87
|
async function importOrLocal ({ pkgManager, name, projectDir, pkg }) {
|
|
58
88
|
try {
|
|
59
89
|
return await import(pkg)
|
|
@@ -79,8 +109,14 @@ async function importOrLocal ({ pkgManager, name, projectDir, pkg }) {
|
|
|
79
109
|
}
|
|
80
110
|
}
|
|
81
111
|
|
|
82
|
-
const spinner = ora(`Installing ${pkg + version}...`).start()
|
|
83
|
-
|
|
112
|
+
const spinner = ora(`Installing ${pkg + version} using ${pkgManager} ...`).start()
|
|
113
|
+
const args = []
|
|
114
|
+
|
|
115
|
+
if (pkgManager === 'pnpm' && existsSync(resolve(projectDir, 'pnpm-workspace.yaml'))) {
|
|
116
|
+
args.push('-w')
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
await execa(pkgManager, ['install', ...args, pkg + version], { cwd: projectDir })
|
|
84
120
|
spinner.succeed()
|
|
85
121
|
|
|
86
122
|
const fileToImport = resolveModule.sync(pkg, { basedir: projectDir })
|
|
@@ -349,13 +385,27 @@ export async function createApplication (
|
|
|
349
385
|
|
|
350
386
|
names.push(serviceName)
|
|
351
387
|
|
|
352
|
-
const stackableGenerator =
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
388
|
+
const stackableGenerator = stackable.Generator
|
|
389
|
+
? new stackable.Generator({
|
|
390
|
+
logger,
|
|
391
|
+
inquirer,
|
|
392
|
+
serviceName,
|
|
393
|
+
parent: generator,
|
|
394
|
+
...additionalGeneratorOptions
|
|
395
|
+
})
|
|
396
|
+
: new ImportGenerator({
|
|
397
|
+
logger,
|
|
398
|
+
inquirer,
|
|
399
|
+
serviceName,
|
|
400
|
+
module: stackableName,
|
|
401
|
+
version: await getPackageVersion(stackableName, projectDir),
|
|
402
|
+
parent: generator,
|
|
403
|
+
...additionalGeneratorOptions
|
|
404
|
+
})
|
|
356
405
|
|
|
357
406
|
stackableGenerator.setConfig({
|
|
358
407
|
...stackableGenerator.config,
|
|
408
|
+
...additionalGeneratorConfig,
|
|
359
409
|
serviceName
|
|
360
410
|
})
|
|
361
411
|
|
|
@@ -404,12 +454,7 @@ export async function createApplication (
|
|
|
404
454
|
await generator.prepare()
|
|
405
455
|
|
|
406
456
|
if (chooseEntrypoint) {
|
|
407
|
-
|
|
408
|
-
const configObject = generator.getFileObject(generator.runtimeConfig)
|
|
409
|
-
const config = configObject ? JSON.parse(configObject.contents) : generator.existingConfigRaw
|
|
410
|
-
config.entrypoint = entrypoint
|
|
411
|
-
|
|
412
|
-
generator.addFile({ path: '', file: generator.runtimeConfig, contents: JSON.stringify(config, null, 2) })
|
|
457
|
+
await generator.updateConfigEntryPoint(entrypoint)
|
|
413
458
|
}
|
|
414
459
|
|
|
415
460
|
await generator.writeFiles()
|