platformatic 1.26.0 → 1.28.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/help/logs.txt CHANGED
@@ -10,7 +10,7 @@ Options:
10
10
  * `-n, --name <string>` - The name of the runtime.
11
11
  * `-l, --level <string>` - The pino log level to stream. Default is `info`.
12
12
  * `-s, --service <string>` - The name of the service to stream logs from.
13
- * `--pretty` <boolean> - Pretty print the logs. Default is `true`.
13
+ * `--pretty <boolean>` - Pretty print the logs. Default is `true`.
14
14
 
15
15
  If `--service` is not specified, the command will stream logs from all services.
16
16
 
package/lib/deploy.js CHANGED
@@ -22,11 +22,6 @@ const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12
22
22
  const CREATE_NEW_WORKSPACE_CHOICE = Symbol('CREATE_NEW_WORKSPACE_CHOICE')
23
23
  const CREATE_NEW_APPLICATION_CHOICE = Symbol('CREATE_NEW_APPLICATION_CHOICE')
24
24
 
25
- const logger = pino(pretty({
26
- translateTime: 'SYS:HH:MM:ss',
27
- ignore: 'hostname,pid'
28
- }))
29
-
30
25
  async function askMissingWorkspaceDetails (
31
26
  workspaceType,
32
27
  workspaceId,
@@ -439,7 +434,13 @@ async function getUserWorkspaceDetails (deployServiceHost, userApiKey) {
439
434
  }
440
435
 
441
436
  export async function deploy (argv) {
442
- console.log('This application will be deployed to ' + bold(green('Platformatic Cloud')) + '. To change the target use the --deploy-service-host flag')
437
+ const logger = pino(pretty({
438
+ translateTime: 'SYS:HH:MM:ss',
439
+ ignore: 'hostname,pid'
440
+ }))
441
+
442
+ logger.info('This application will be deployed to ' + bold(green('Platformatic Cloud')) + '. To change the target use the --deploy-service-host flag')
443
+
443
444
  try {
444
445
  const args = parseArgs(argv, {
445
446
  alias: {
package/lib/upgrade.js CHANGED
@@ -1,21 +1,12 @@
1
- import ConfigManager from '@platformatic/config'
2
- import { analyze, write, upgrade as upgradeConfig } from '@platformatic/metaconfig'
1
+ import { Store, getStringifier } from '@platformatic/config'
3
2
  import parseArgs from 'minimist'
4
- import { access } from 'fs/promises'
5
- import { resolve } from 'path'
6
- import { execa } from 'execa'
7
- import { getLatestNpmVersion } from '@platformatic/utils'
8
-
9
- const configFileNames = ConfigManager.listConfigFiles()
10
-
11
- async function isFileAccessible (filename) {
12
- try {
13
- await access(filename)
14
- return true
15
- } catch (err) {
16
- return false
17
- }
18
- }
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
+ import { platformaticRuntime } from '@platformatic/runtime'
8
+ import pino from 'pino'
9
+ import pretty from 'pino-pretty'
19
10
 
20
11
  export async function upgrade (argv) {
21
12
  const args = parseArgs(argv, {
@@ -23,79 +14,46 @@ export async function upgrade (argv) {
23
14
  config: 'c'
24
15
  }
25
16
  })
17
+
18
+ const logger = pino(pretty({
19
+ translateTime: 'SYS:HH:MM:ss',
20
+ ignore: 'hostname,pid'
21
+ }))
26
22
  try {
27
- await upgradeApp(args.config)
28
- await upgradeSystem()
23
+ await upgradeApp(args.config, logger)
29
24
  } catch (err) {
30
- // silently ignore errors
25
+ console.log(err)
26
+ process.exit(1)
31
27
  }
32
28
  }
33
29
 
34
- async function upgradeApp (config) {
35
- let accessibleConfigFilename = config
36
-
37
- if (!accessibleConfigFilename) {
38
- const configFilesAccessibility = await Promise.all(configFileNames.map((fileName) => isFileAccessible(fileName)))
39
- accessibleConfigFilename = configFileNames.find((value, index) => configFilesAccessibility[index])
40
- }
41
-
42
- if (!accessibleConfigFilename) {
43
- console.error('No config file found')
44
- process.exitCode = 1
45
- return
46
- }
47
-
48
- accessibleConfigFilename = resolve(accessibleConfigFilename)
49
-
50
- let meta = await analyze({ file: accessibleConfigFilename })
51
-
52
- console.log(`Found ${meta.version} for Platformatic ${meta.kind} in ${meta.format} format`)
53
-
54
- meta = upgradeConfig(meta)
55
-
56
- await write(meta)
57
- console.log('App Upgraded to', meta.version)
58
- }
59
-
60
- async function upgradeSystem () {
61
- console.log('Checking latest platformatic version on npm registry...')
62
- const currentRunningVersion = await checkSystemPlatformaticVersion()
63
- const latestNpmVersion = await getLatestNpmVersion('platformatic')
64
- if (latestNpmVersion) {
65
- const compareResult = compareVersions(currentRunningVersion, latestNpmVersion)
66
- switch (compareResult) {
67
- case 0:
68
- console.log(`✅ You are running the latest Platformatic version v${latestNpmVersion}!`)
69
- break
70
- case -1:
71
- console.log(`✨ Version ${latestNpmVersion} of Platformatic has been released, please update with "npm update -g platformatic"`)
72
- break
30
+ async function upgradeApp (config, logger) {
31
+ const store = new Store({
32
+ cwd: process.cwd(),
33
+ logger
34
+ })
35
+ store.add(platformaticService)
36
+ store.add(platformaticDB)
37
+ store.add(platformaticComposer)
38
+ store.add(platformaticRuntime)
39
+
40
+ const { configManager } = await store.loadConfig({
41
+ config,
42
+ overrides: {
43
+ fixPaths: false,
44
+ onMissingEnv (key) {
45
+ return ''
46
+ }
73
47
  }
74
- }
75
- }
76
-
77
- export function compareVersions (first, second) {
78
- const [firstMajor, firstMinor, firstPatch] = first.split('.')
79
- const [secondMajor, secondMinor, secondPatch] = second.split('.')
48
+ })
80
49
 
81
- if (firstMajor < secondMajor) return -1
82
- if (firstMajor > secondMajor) return 1
50
+ await configManager.parseAndValidate()
83
51
 
84
- // firstMajor === secondMajor
85
- if (firstMinor < secondMinor) return -1
86
- if (firstMinor > secondMinor) return 1
52
+ const stringify = getStringifier(configManager.fullPath)
87
53
 
88
- // firstMinor === secondMinor
89
- if (firstPatch < secondPatch) return -1
90
- if (firstPatch > secondPatch) return 1
54
+ const newConfig = stringify(configManager.current)
91
55
 
92
- return 0
93
- }
56
+ await writeFile(configManager.fullPath, newConfig, 'utf8')
94
57
 
95
- async function checkSystemPlatformaticVersion () {
96
- const { stdout } = await execa('platformatic', ['--version'])
97
- if (stdout.match(/v\d+\.\d+\.\d+/)) {
98
- return stdout.substring(1)
99
- }
100
- return '0.0.0'
58
+ logger.info(`✅ Updated ${configManager.fullPath}`)
101
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platformatic",
3
- "version": "1.26.0",
3
+ "version": "1.28.0",
4
4
  "description": "Platformatic CLI",
5
5
  "main": "cli.js",
6
6
  "type": "module",
@@ -27,9 +27,9 @@
27
27
  "mercurius"
28
28
  ],
29
29
  "devDependencies": {
30
- "borp": "^0.9.0",
30
+ "borp": "^0.10.0",
31
31
  "c8": "^9.1.0",
32
- "fastify": "^4.26.0",
32
+ "fastify": "^4.26.2",
33
33
  "license-checker": "^25.0.1",
34
34
  "mkdirp": "^2.1.6",
35
35
  "snazzy": "^9.0.0",
@@ -41,29 +41,28 @@
41
41
  "colorette": "^2.0.20",
42
42
  "commist": "^3.2.0",
43
43
  "desm": "^1.3.1",
44
- "dotenv": "^16.4.1",
44
+ "dotenv": "^16.4.5",
45
45
  "execa": "^8.0.1",
46
46
  "graphql": "^16.8.1",
47
47
  "help-me": "^5.0.0",
48
- "inquirer": "^9.2.13",
49
- "mercurius": "^13.3.3",
48
+ "inquirer": "^9.2.16",
49
+ "mercurius": "^13.4.0",
50
50
  "minimist": "^1.2.8",
51
- "pino": "^8.17.2",
51
+ "pino": "^8.19.0",
52
52
  "pino-pretty": "^10.3.1",
53
- "undici": "^6.6.0",
54
- "@platformatic/authenticate": "1.26.0",
55
- "@platformatic/composer": "1.26.0",
56
- "@platformatic/config": "1.26.0",
57
- "@platformatic/client-cli": "1.26.0",
58
- "@platformatic/control": "1.26.0",
59
- "@platformatic/db": "1.26.0",
60
- "@platformatic/deploy-client": "1.26.0",
61
- "@platformatic/frontend-template": "1.26.0",
62
- "@platformatic/metaconfig": "1.26.0",
63
- "@platformatic/runtime": "1.26.0",
64
- "@platformatic/utils": "1.26.0",
65
- "@platformatic/service": "1.26.0",
66
- "create-platformatic": "1.26.0"
53
+ "undici": "^6.9.0",
54
+ "@platformatic/authenticate": "1.28.0",
55
+ "@platformatic/config": "1.28.0",
56
+ "@platformatic/client-cli": "1.28.0",
57
+ "@platformatic/composer": "1.28.0",
58
+ "@platformatic/control": "1.28.0",
59
+ "@platformatic/db": "1.28.0",
60
+ "@platformatic/deploy-client": "1.28.0",
61
+ "@platformatic/frontend-template": "1.28.0",
62
+ "@platformatic/utils": "1.28.0",
63
+ "@platformatic/service": "1.28.0",
64
+ "@platformatic/runtime": "1.28.0",
65
+ "create-platformatic": "1.28.0"
67
66
  },
68
67
  "scripts": {
69
68
  "test": "pnpm run lint && borp --timeout 120000 --concurrency 1",