platformatic 1.51.8 → 2.0.0-alpha.2

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.
Files changed (3) hide show
  1. package/cli.js +31 -10
  2. package/lib/upgrade.js +0 -6
  3. package/package.json +14 -12
package/cli.js CHANGED
@@ -1,14 +1,14 @@
1
1
  #! /usr/bin/env node
2
2
 
3
+ import { createRequire } from 'node:module'
4
+ import path from 'node:path'
5
+ import { pathToFileURL } from 'node:url'
6
+ import { readFile } from 'node:fs/promises'
3
7
  import commist from 'commist'
4
8
  import minimist from 'minimist'
5
- import { runDB } from '@platformatic/db/db.mjs'
6
9
  import { run as runRuntime, compile } from '@platformatic/runtime/runtime.mjs'
7
10
  import { startCommand } from '@platformatic/runtime'
8
- import { runService } from '@platformatic/service/service.mjs'
9
- import { runComposer } from '@platformatic/composer/composer.mjs'
10
11
  import { command as client } from '@platformatic/client-cli'
11
- import { readFile } from 'fs/promises'
12
12
  import { join } from 'desm'
13
13
  import { isColorSupported } from 'colorette'
14
14
  import helpMe from 'help-me'
@@ -28,6 +28,12 @@ const help = helpMe({
28
28
  ext: '.txt'
29
29
  })
30
30
 
31
+ async function load (moduleName) {
32
+ const require = createRequire(path.join(process.cwd(), 'package.json'))
33
+ const file = require.resolve(moduleName)
34
+ return import(pathToFileURL(file))
35
+ }
36
+
31
37
  const ensureCommand = async ({ output, help }) => {
32
38
  if (!output) {
33
39
  return
@@ -41,10 +47,19 @@ const ensureCommand = async ({ output, help }) => {
41
47
  process.exit(1)
42
48
  }
43
49
 
44
- program.register('db', async (args) => ensureCommand(await runDB(args)))
50
+ program.register('db', async (args) => {
51
+ const { runDB } = await load('@platformatic/db/db.mjs')
52
+ return ensureCommand(await runDB(args))
53
+ })
45
54
  program.register('runtime', async (args) => ensureCommand(await runRuntime(args)))
46
- program.register('service', async (args) => ensureCommand(await runService(args)))
47
- program.register('composer', async (args) => ensureCommand(await runComposer(args)))
55
+ program.register('service', async (args) => {
56
+ const { runService } = await load('@platformatic/service/service.mjs')
57
+ return ensureCommand(await runService(args))
58
+ })
59
+ program.register('composer', async (args) => {
60
+ const { runComposer } = await load('@platformatic/composer/composer.mjs')
61
+ return ensureCommand(await runComposer(args))
62
+ })
48
63
  program.register('start', async (args) => ensureCommand(await startCommand(args)))
49
64
  program.register('ctl', async (args) => ensureCommand(await runControl(args)))
50
65
  program.register('ps', async (args) => getRuntimesCommand(args))
@@ -54,10 +69,16 @@ program.register('upgrade', upgrade)
54
69
  program.register('client', client)
55
70
  program.register('compile', async (args) => await compile(args) ? null : process.exit(1))
56
71
  program.register('help', help.toStdout)
57
- program.register('help db', async (args) => runDB(['help', ...args]))
72
+ program.register('help db', async (args) => {
73
+ const { runDB } = await load('@platformatic/db/db.mjs')
74
+ return runDB(['help', ...args])
75
+ })
58
76
  program.register('help client', () => client([]))
59
77
  program.register('help runtime', async (args) => runRuntime(['help', ...args]))
60
- program.register('help service', async (args) => runService(['help', ...args]))
78
+ program.register('help service', async (args) => {
79
+ const { runService } = await load('@platformatic/service/service.mjs')
80
+ return runService(['help', ...args])
81
+ })
61
82
 
62
83
  const args = minimist(process.argv.slice(2), {
63
84
  boolean: ['help', 'version'],
@@ -67,7 +88,7 @@ const args = minimist(process.argv.slice(2), {
67
88
  }
68
89
  })
69
90
 
70
- if (args.version && !args._.includes('versions') && !args._.includes('inject')) {
91
+ if (args.version && !args._.includes('inject')) {
71
92
  const version = JSON.parse(await readFile(join(import.meta.url, 'package.json'))).version
72
93
  console.log('v' + version)
73
94
  process.exit(0)
package/lib/upgrade.js CHANGED
@@ -1,9 +1,6 @@
1
1
  import { Store, getStringifier } from '@platformatic/config'
2
2
  import parseArgs from 'minimist'
3
3
  import { writeFile } from 'fs/promises'
4
- import { platformaticService } from '@platformatic/service'
5
- import { platformaticDB } from '@platformatic/db'
6
- import { platformaticComposer } from '@platformatic/composer'
7
4
  import { platformaticRuntime } from '@platformatic/runtime'
8
5
  import pino from 'pino'
9
6
  import pretty from 'pino-pretty'
@@ -33,9 +30,6 @@ async function upgradeApp (config, logger) {
33
30
  cwd: process.cwd(),
34
31
  logger
35
32
  })
36
- store.add(platformaticService)
37
- store.add(platformaticDB)
38
- store.add(platformaticComposer)
39
33
  store.add(platformaticRuntime)
40
34
 
41
35
  const { configManager } = await store.loadConfig({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platformatic",
3
- "version": "1.51.8",
3
+ "version": "2.0.0-alpha.2",
4
4
  "description": "Platformatic CLI",
5
5
  "main": "cli.js",
6
6
  "type": "module",
@@ -34,7 +34,11 @@
34
34
  "mkdirp": "^2.1.6",
35
35
  "snazzy": "^9.0.0",
36
36
  "split2": "^4.2.0",
37
- "standard": "^17.1.0"
37
+ "standard": "^17.1.0",
38
+ "typescript": "^5.5.3",
39
+ "@platformatic/db": "2.0.0-alpha.2",
40
+ "@platformatic/composer": "2.0.0-alpha.2",
41
+ "@platformatic/service": "2.0.0-alpha.2"
38
42
  },
39
43
  "dependencies": {
40
44
  "@fastify/error": "^3.4.1",
@@ -51,16 +55,14 @@
51
55
  "pino": "^8.19.0",
52
56
  "pino-pretty": "^11.0.0",
53
57
  "undici": "^6.9.0",
54
- "@platformatic/client-cli": "1.51.8",
55
- "@platformatic/config": "1.51.8",
56
- "@platformatic/composer": "1.51.8",
57
- "@platformatic/control": "1.51.8",
58
- "@platformatic/frontend-template": "1.51.8",
59
- "@platformatic/db": "1.51.8",
60
- "@platformatic/runtime": "1.51.8",
61
- "@platformatic/utils": "1.51.8",
62
- "create-platformatic": "1.51.8",
63
- "@platformatic/service": "1.51.8"
58
+ "@platformatic/config": "2.0.0-alpha.2",
59
+ "@platformatic/control": "2.0.0-alpha.2",
60
+ "@platformatic/db": "2.0.0-alpha.2",
61
+ "@platformatic/frontend-template": "2.0.0-alpha.2",
62
+ "@platformatic/client-cli": "2.0.0-alpha.2",
63
+ "create-platformatic": "2.0.0-alpha.2",
64
+ "@platformatic/utils": "2.0.0-alpha.2",
65
+ "@platformatic/runtime": "2.0.0-alpha.2"
64
66
  },
65
67
  "scripts": {
66
68
  "test": "pnpm run lint && borp --timeout 120000 --concurrency 1",