create-platformatic 2.72.0 → 3.0.0-alpha.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.
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { checkNodeVersionForServices } from '@platformatic/utils'
3
- import { join } from 'desm'
4
3
  import isMain from 'es-main'
5
4
  import { readFile } from 'fs/promises'
6
5
  import parseArgs from 'minimist'
7
- import { createPlatformatic } from './src/index.mjs'
6
+ import { join } from 'node:path'
7
+ import { createPlatformatic } from '../src/index.mjs'
8
8
 
9
9
  if (isMain(import.meta)) {
10
10
  checkNodeVersionForServices()
@@ -17,11 +17,11 @@ if (isMain(import.meta)) {
17
17
  })
18
18
 
19
19
  if (args.version) {
20
- console.log('v' + JSON.parse(await readFile(join(import.meta.url, 'package.json'), 'utf8')).version)
20
+ console.log('v' + JSON.parse(await readFile(join(import.meta.dirname, 'package.json'), 'utf8')).version)
21
21
  process.exit(0)
22
22
  }
23
23
  await createPlatformatic(_args)
24
24
  }
25
25
 
26
- export * from './src/index.mjs'
27
- export * from './src/utils.mjs'
26
+ export * from '../src/index.mjs'
27
+ export * from '../src/utils.mjs'
package/package.json CHANGED
@@ -1,23 +1,22 @@
1
1
  {
2
2
  "name": "create-platformatic",
3
- "version": "2.72.0",
3
+ "version": "3.0.0-alpha.1",
4
4
  "description": "Create platformatic application interactive tool",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/platformatic/platformatic.git"
8
8
  },
9
9
  "exports": {
10
- ".": "./create-platformatic.mjs"
10
+ ".": "./bin/create-platformatic.mjs"
11
11
  },
12
12
  "bin": {
13
- "create-platformatic": "./create-platformatic.mjs"
13
+ "create-platformatic": "./bin/create-platformatic.mjs"
14
14
  },
15
15
  "license": "Apache-2.0",
16
16
  "author": "Platformatic Inc. <oss@platformatic.dev> (https://platformatic.dev)",
17
17
  "dependencies": {
18
18
  "columnify": "^1.6.0",
19
19
  "commist": "^3.2.0",
20
- "desm": "^1.3.1",
21
20
  "es-main": "^1.3.0",
22
21
  "execa": "^9.0.0",
23
22
  "help-me": "^5.0.0",
@@ -31,9 +30,8 @@
31
30
  "strip-ansi": "^7.1.0",
32
31
  "undici": "^7.0.0",
33
32
  "which": "^3.0.1",
34
- "@platformatic/generators": "2.72.0",
35
- "@platformatic/utils": "2.72.0",
36
- "@platformatic/config": "2.72.0"
33
+ "@platformatic/generators": "3.0.0-alpha.1",
34
+ "@platformatic/utils": "3.0.0-alpha.1"
37
35
  },
38
36
  "devDependencies": {
39
37
  "@types/node": "^22.5.0",
@@ -48,10 +46,10 @@
48
46
  "neostandard": "^0.12.0",
49
47
  "typescript": "~5.8.0",
50
48
  "yaml": "^2.4.1",
51
- "@platformatic/composer": "2.72.0",
52
- "@platformatic/db": "2.72.0",
53
- "@platformatic/runtime": "2.72.0",
54
- "@platformatic/service": "2.72.0"
49
+ "@platformatic/composer": "3.0.0-alpha.1",
50
+ "@platformatic/db": "3.0.0-alpha.1",
51
+ "@platformatic/service": "3.0.0-alpha.1",
52
+ "@platformatic/runtime": "3.0.0-alpha.1"
55
53
  },
56
54
  "scripts": {
57
55
  "test:cli": "borp --pattern \"test/cli/*test.mjs\" --timeout=1200000 --concurrency=1",
package/src/index.mjs CHANGED
@@ -1,15 +1,14 @@
1
- import ConfigManager, { findConfigurationFile, loadConfigurationFile } from '@platformatic/config'
2
1
  import { ImportGenerator } from '@platformatic/generators'
3
2
  import {
4
- getPackageManager, DEFAULT_PACKAGE_MANAGER,
5
3
  createDirectory,
6
4
  detectApplicationType,
7
5
  executeWithTimeout,
6
+ findConfigurationFileRecursive,
8
7
  generateDashedName,
9
8
  getPkgManager,
9
+ loadConfigurationFile,
10
10
  searchJavascriptFiles
11
11
  } from '@platformatic/utils'
12
-
13
12
  import { execa } from 'execa'
14
13
  import defaultInquirer from 'inquirer'
15
14
  import parseArgs from 'minimist'
@@ -23,8 +22,7 @@ import pretty from 'pino-pretty'
23
22
  import resolveModule from 'resolve'
24
23
  import { request } from 'undici'
25
24
  import { createGitRepository } from './create-git-repository.mjs'
26
- import { getUsername, getVersion, say } from './utils.mjs'
27
-
25
+ import { findComposerConfigFile, getUsername, getVersion, say } from './utils.mjs'
28
26
  const MARKETPLACE_HOST = 'https://marketplace.platformatic.dev'
29
27
  const defaultStackables = ['@platformatic/service', '@platformatic/composer', '@platformatic/db']
30
28
 
@@ -234,7 +232,7 @@ export async function createApplication (
234
232
  // Check in the directory and its parents if there is a config file
235
233
  let shouldChooseProjectDir = true
236
234
  let projectDir = process.cwd()
237
- const runtimeConfigFile = await findConfigurationFile(projectDir, null, 'runtime')
235
+ const runtimeConfigFile = await findConfigurationFileRecursive(projectDir, null, '@platformatic/runtime')
238
236
 
239
237
  if (runtimeConfigFile) {
240
238
  shouldChooseProjectDir = false
@@ -249,11 +247,11 @@ export async function createApplication (
249
247
 
250
248
  // Check if the file belongs to a Watt application, this can happen for instance if we executed watt create
251
249
  // in the services folder
252
- const existingRuntime = await findConfigurationFile(applicationRoot, null, 'runtime')
250
+ const existingRuntime = await findConfigurationFileRecursive(applicationRoot, null, '@platformatic/runtime')
253
251
 
254
252
  if (!existingRuntime) {
255
253
  // If there is a watt.json file with a runtime property, we assume we already executed watt create and we exit.
256
- const existingService = await ConfigManager.findConfigFile(projectDir)
254
+ const existingService = await findComposerConfigFile(projectDir)
257
255
 
258
256
  if (existingService) {
259
257
  const serviceConfig = await loadConfigurationFile(existingService)
@@ -276,10 +274,6 @@ export async function createApplication (
276
274
  })
277
275
 
278
276
  if (shouldWrap) {
279
- if (!packageManager) {
280
- packageManager = getPackageManager(projectDir, DEFAULT_PACKAGE_MANAGER)
281
- }
282
-
283
277
  return wrapApplication(
284
278
  logger,
285
279
  inquirer,
@@ -313,26 +307,6 @@ export async function createApplication (
313
307
 
314
308
  const projectName = basename(projectDir)
315
309
 
316
- if (!packageManager) {
317
- packageManager = getPackageManager(projectDir, null, true)
318
-
319
- if (!packageManager) {
320
- const p = await inquirer.prompt({
321
- type: 'list',
322
- name: 'packageManager',
323
- message: 'Which package manager do you want to use?',
324
- default: DEFAULT_PACKAGE_MANAGER,
325
- choices: [
326
- { name: 'npm', value: 'npm' },
327
- { name: 'pnpm', value: 'pnpm' },
328
- { name: 'yarn', value: 'yarn' }
329
- ]
330
- })
331
-
332
- packageManager = p.packageManager
333
- }
334
- }
335
-
336
310
  const runtime = await importOrLocal({
337
311
  pkgManager: packageManager,
338
312
  name: projectName,
@@ -344,7 +318,6 @@ export async function createApplication (
344
318
  logger,
345
319
  name: projectName,
346
320
  inquirer,
347
- packageManager,
348
321
  ...additionalGeneratorOptions
349
322
  })
350
323
 
package/src/utils.mjs CHANGED
@@ -1,12 +1,10 @@
1
- import * as desm from 'desm'
1
+ import { findConfigurationFile } from '@platformatic/utils'
2
2
  import { execa } from 'execa'
3
3
  import { access, constants, readFile } from 'fs/promises'
4
4
  import { createRequire } from 'module'
5
5
  import { dirname, join, resolve } from 'path'
6
6
  import * as url from 'url'
7
7
 
8
- import ConfigManager from '@platformatic/config'
9
-
10
8
  export const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
11
9
  export const randomBetween = (min, max) => Math.floor(Math.random() * (max - min + 1) + min)
12
10
  const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
@@ -16,7 +14,7 @@ const ansiCodes = {
16
14
  pltGreen: '\u001B[38;2;33;250;144m',
17
15
  bell: '\u0007',
18
16
  reset: '\u001b[0m',
19
- erasePreviousLine: '\u001b[1K',
17
+ erasePreviousLine: '\u001b[1K'
20
18
  }
21
19
 
22
20
  export async function isFileAccessible (filename, directory) {
@@ -58,7 +56,7 @@ export const getUsername = async () => {
58
56
  */
59
57
  /* c8 ignore next 4 */
60
58
  export const getVersion = async () => {
61
- const data = await readFile(desm.join(import.meta.url, '..', 'package.json'), 'utf8')
59
+ const data = await readFile(join(import.meta.dirname, '..', 'package.json'), 'utf8')
62
60
  return JSON.parse(data).version
63
61
  }
64
62
 
@@ -71,11 +69,11 @@ export async function isDirectoryWriteable (directory) {
71
69
  }
72
70
  }
73
71
 
74
- export const findConfigFile = async directory => ConfigManager.findConfigFile(directory)
75
- export const findDBConfigFile = async directory => ConfigManager.findConfigFile(directory, 'db')
76
- export const findServiceConfigFile = async directory => ConfigManager.findConfigFile(directory, 'service')
77
- export const findComposerConfigFile = async directory => ConfigManager.findConfigFile(directory, 'composer')
78
- export const findRuntimeConfigFile = async directory => ConfigManager.findConfigFile(directory, 'runtime')
72
+ export const findConfigFile = async directory => findConfigurationFile(directory)
73
+ export const findDBConfigFile = async directory => findConfigurationFile(directory, 'db')
74
+ export const findServiceConfigFile = async directory => findConfigurationFile(directory, 'service')
75
+ export const findComposerConfigFile = async directory => findConfigurationFile(directory, 'composer')
76
+ export const findRuntimeConfigFile = async directory => findConfigurationFile(directory, 'runtime')
79
77
 
80
78
  /**
81
79
  * Gets the version of the specified dependency package from package.json