create-platformatic 2.0.0-alpha.8 → 2.0.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 +11 -11
- package/src/index.mjs +25 -57
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-platformatic",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Create platformatic application interactive tool",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
".": "./create-platformatic.mjs"
|
|
11
11
|
},
|
|
12
12
|
"bin": {
|
|
13
|
-
"create-platformatic
|
|
13
|
+
"create-platformatic": "./create-platformatic.mjs"
|
|
14
14
|
},
|
|
15
15
|
"license": "Apache-2.0",
|
|
16
16
|
"author": "Matteo Collina <hello@matteocollina.com>",
|
|
@@ -27,16 +27,16 @@
|
|
|
27
27
|
"log-update": "^6.0.0",
|
|
28
28
|
"minimist": "^1.2.8",
|
|
29
29
|
"ora": "^6.3.1",
|
|
30
|
-
"pino": "^
|
|
30
|
+
"pino": "^9.0.0",
|
|
31
31
|
"pino-pretty": "^11.0.0",
|
|
32
32
|
"resolve": "^1.22.8",
|
|
33
33
|
"semver": "^7.6.0",
|
|
34
34
|
"strip-ansi": "^7.1.0",
|
|
35
35
|
"undici": "^6.9.0",
|
|
36
36
|
"which": "^3.0.1",
|
|
37
|
-
"@platformatic/config": "2.0.0
|
|
38
|
-
"@platformatic/
|
|
39
|
-
"@platformatic/
|
|
37
|
+
"@platformatic/config": "2.0.0",
|
|
38
|
+
"@platformatic/utils": "2.0.0",
|
|
39
|
+
"@platformatic/generators": "2.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^22.5.0",
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"dotenv": "^16.4.5",
|
|
48
48
|
"eslint": "9",
|
|
49
49
|
"esmock": "^2.6.4",
|
|
50
|
-
"fastify": "^
|
|
50
|
+
"fastify": "^5.0.0",
|
|
51
51
|
"neostandard": "^0.11.1",
|
|
52
52
|
"typescript": "~5.6.0",
|
|
53
53
|
"yaml": "^2.4.1",
|
|
54
|
-
"@platformatic/composer": "2.0.0
|
|
55
|
-
"@platformatic/db": "2.0.0
|
|
56
|
-
"@platformatic/runtime": "2.0.0
|
|
57
|
-
"@platformatic/service": "2.0.0
|
|
54
|
+
"@platformatic/composer": "2.0.0",
|
|
55
|
+
"@platformatic/db": "2.0.0",
|
|
56
|
+
"@platformatic/runtime": "2.0.0",
|
|
57
|
+
"@platformatic/service": "2.0.0"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"test:cli": "borp --pattern \"test/cli/*test.mjs\" --timeout=180000 --concurrency=1",
|
package/src/index.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { StackableGenerator } from '@platformatic/generators'
|
|
2
1
|
import { createDirectory, getPkgManager } from '@platformatic/utils'
|
|
3
2
|
import generateName from 'boring-name-generator'
|
|
4
3
|
import { execa } from 'execa'
|
|
5
4
|
import inquirer from 'inquirer'
|
|
6
5
|
import parseArgs from 'minimist'
|
|
7
|
-
import { writeFile } from 'node:fs/promises'
|
|
6
|
+
import { writeFile, readFile } from 'node:fs/promises'
|
|
8
7
|
import path, { basename, join } from 'node:path'
|
|
9
8
|
import { setTimeout } from 'node:timers/promises'
|
|
10
9
|
import { pathToFileURL } from 'node:url'
|
|
@@ -18,8 +17,14 @@ import { say } from './say.mjs'
|
|
|
18
17
|
import { getUsername, getVersion, isCurrentVersionSupported, minimumSupportedNodeVersions } from './utils.mjs'
|
|
19
18
|
|
|
20
19
|
const MARKETPLACE_HOST = 'https://marketplace.platformatic.dev'
|
|
20
|
+
const defaultStackables = ['@platformatic/composer', '@platformatic/db', '@platformatic/service']
|
|
21
21
|
|
|
22
22
|
export async function fetchStackables (marketplaceHost) {
|
|
23
|
+
// Skip the remote network request if we are running tests
|
|
24
|
+
if (process.env.MARKETPLACE_TEST) {
|
|
25
|
+
return [...defaultStackables]
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
marketplaceHost = marketplaceHost || MARKETPLACE_HOST
|
|
24
29
|
|
|
25
30
|
const stackablesRequest = request(marketplaceHost + '/templates')
|
|
@@ -32,7 +37,7 @@ export async function fetchStackables (marketplaceHost) {
|
|
|
32
37
|
}
|
|
33
38
|
} catch (err) {}
|
|
34
39
|
|
|
35
|
-
return [
|
|
40
|
+
return [...defaultStackables]
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
export async function chooseStackable (stackables) {
|
|
@@ -56,8 +61,22 @@ async function importOrLocal ({ pkgManager, name, projectDir, pkg }) {
|
|
|
56
61
|
return await import(pathToFileURL(fileToImport))
|
|
57
62
|
} catch {}
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
let version = ''
|
|
65
|
+
|
|
66
|
+
if (defaultStackables.includes(pkg) || pkg === '@platformatic/runtime') {
|
|
67
|
+
// Let's find if we are using one of the default stackables
|
|
68
|
+
// If we are, we have to use the "local" version of the package
|
|
69
|
+
|
|
70
|
+
const meta = await JSON.parse(await readFile(join(import.meta.dirname, '..', 'package.json'), 'utf-8'))
|
|
71
|
+
if (meta.version.includes('-')) {
|
|
72
|
+
version = `@${meta.version}`
|
|
73
|
+
} else {
|
|
74
|
+
version = `@^${meta.version}`
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const spinner = ora(`Installing ${pkg + version}...`).start()
|
|
79
|
+
await execa(pkgManager, ['install', pkg + version], { cwd: projectDir })
|
|
61
80
|
spinner.succeed()
|
|
62
81
|
|
|
63
82
|
const fileToImport = resolve.sync(pkg, { basedir: projectDir })
|
|
@@ -95,23 +114,7 @@ export const createPlatformatic = async argv => {
|
|
|
95
114
|
)
|
|
96
115
|
|
|
97
116
|
const pkgManager = getPkgManager()
|
|
98
|
-
|
|
99
|
-
const { projectType } = await inquirer.prompt({
|
|
100
|
-
type: 'list',
|
|
101
|
-
name: 'projectType',
|
|
102
|
-
message: 'What kind of project do you want to create?',
|
|
103
|
-
default: 'application',
|
|
104
|
-
choices: [
|
|
105
|
-
{ name: 'Application', value: 'application' },
|
|
106
|
-
{ name: 'Stackable', value: 'stackable' },
|
|
107
|
-
],
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
if (projectType === 'application') {
|
|
111
|
-
await createApplication(args, logger, pkgManager)
|
|
112
|
-
} else {
|
|
113
|
-
await createStackable(args, logger, pkgManager)
|
|
114
|
-
}
|
|
117
|
+
await createApplication(args, logger, pkgManager)
|
|
115
118
|
}
|
|
116
119
|
|
|
117
120
|
async function createApplication (args, logger, pkgManager) {
|
|
@@ -277,38 +280,3 @@ async function createApplication (args, logger, pkgManager) {
|
|
|
277
280
|
await generator.postInstallActions()
|
|
278
281
|
logger.info('You are all set! Run `npm start` to start your project.')
|
|
279
282
|
}
|
|
280
|
-
|
|
281
|
-
async function createStackable (args, logger, pkgManager) {
|
|
282
|
-
logger.info('Creating a stackable project...')
|
|
283
|
-
|
|
284
|
-
const generator = new StackableGenerator({ logger, inquirer })
|
|
285
|
-
await generator.ask()
|
|
286
|
-
await generator.prepare()
|
|
287
|
-
await generator.writeFiles()
|
|
288
|
-
|
|
289
|
-
const projectDir = path.resolve(process.cwd(), generator.config.targetDirectory)
|
|
290
|
-
|
|
291
|
-
const { initGitRepository } = await inquirer.prompt({
|
|
292
|
-
type: 'list',
|
|
293
|
-
name: 'initGitRepository',
|
|
294
|
-
message: 'Do you want to init the git repository?',
|
|
295
|
-
default: false,
|
|
296
|
-
choices: [
|
|
297
|
-
{ name: 'yes', value: true },
|
|
298
|
-
{ name: 'no', value: false },
|
|
299
|
-
],
|
|
300
|
-
})
|
|
301
|
-
|
|
302
|
-
if (initGitRepository) {
|
|
303
|
-
await createGitRepository(logger, projectDir)
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if (args.install) {
|
|
307
|
-
const spinner = ora('Installing dependencies...').start()
|
|
308
|
-
await execa(pkgManager, ['install'], { cwd: projectDir })
|
|
309
|
-
spinner.succeed()
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
await generator.postInstallActions()
|
|
313
|
-
logger.info('Stackable created successfully! Run `npm run create` to create an application.')
|
|
314
|
-
}
|