platformatic 2.0.0-alpha.7 → 2.0.0-alpha.9

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 (2) hide show
  1. package/lib/build.js +14 -51
  2. package/package.json +22 -23
package/lib/build.js CHANGED
@@ -1,9 +1,7 @@
1
1
  import platformaticBasic from '@platformatic/basic'
2
2
  import { Store, loadConfig as pltConfigLoadConfig } from '@platformatic/config'
3
3
  import { buildRuntime, platformaticRuntime } from '@platformatic/runtime'
4
- import { execa, parseCommandString } from 'execa'
5
- import { once } from 'node:events'
6
- import split from 'split2'
4
+ import { errors } from '@platformatic/utils'
7
5
 
8
6
  async function loadConfig (minimistConfig, args, overrides, replaceEnv = true) {
9
7
  const store = new Store()
@@ -13,40 +11,6 @@ async function loadConfig (minimistConfig, args, overrides, replaceEnv = true) {
13
11
  return pltConfigLoadConfig(minimistConfig, args, store, overrides, replaceEnv)
14
12
  }
15
13
 
16
- async function buildService (logger, id, cwd, command) {
17
- const [executable, ...args] = parseCommandString(command)
18
- const subprocess = execa(executable, args, {
19
- all: true,
20
- lines: false,
21
- stripFinalNewline: false,
22
- reject: false,
23
- preferLocal: true,
24
- cwd
25
- })
26
-
27
- const exitPromise = once(subprocess, 'exit')
28
-
29
- const output = []
30
- for await (const line of subprocess.all.pipe(split())) {
31
- logger.debug(` ${line}`)
32
- output.push(line)
33
- }
34
- logger.debug('')
35
- output.push('')
36
-
37
- const [exitCode] = await exitPromise
38
-
39
- if (exitCode !== 0) {
40
- logger.error(`❌ Building service ${id} (${command}) failed with exit code ${exitCode}: `)
41
-
42
- for (const line of output) {
43
- logger.error(` ${line}`)
44
- }
45
-
46
- process.exit(1)
47
- }
48
- }
49
-
50
14
  export async function build (args) {
51
15
  const config = await loadConfig({}, args)
52
16
  config.configManager.args = config.args
@@ -56,25 +20,24 @@ export async function build (args) {
56
20
  const logger = runtime.logger
57
21
 
58
22
  // Gather informations for all services before starting
59
- const toBuild = new Map()
60
23
  const { services } = await runtime.getServices()
61
24
 
62
25
  for (const { id } of services) {
63
- const { path } = runtimeConfig.current.serviceMap.get(id)
64
- const meta = await runtime.getServiceMeta(id)
65
-
66
- if (meta?.deploy?.buildCommand) {
67
- toBuild.set(id, [path, meta.deploy.buildCommand])
26
+ logger.info(`Building service "${id}" ...`)
27
+
28
+ try {
29
+ await runtime.buildService(id)
30
+ } catch (error) {
31
+ if (error.code === 'PLT_BASIC_NON_ZERO_EXIT_CODE') {
32
+ logger.error(`Building service "${id}" has failed with exit code ${error.exitCode}.`)
33
+ } else {
34
+ logger.error({ err: errors.ensureLoggableError(error) }, `Building service "${id}" has throw an exception.`)
35
+ }
36
+
37
+ process.exit(1)
68
38
  }
69
39
  }
70
40
 
71
- // Build all services
72
- for (const [id, [cwd, command]] of toBuild) {
73
- logger.info(`Building service "${id}" (${command}) ...`)
74
-
75
- await buildService(logger, id, cwd, command)
76
- }
77
-
78
- logger.info('✅ All external services have been built.')
41
+ logger.info('✅ All services have been built.')
79
42
  await runtime.close(false, true)
80
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platformatic",
3
- "version": "2.0.0-alpha.7",
3
+ "version": "2.0.0-alpha.9",
4
4
  "description": "Platformatic CLI",
5
5
  "main": "cli.js",
6
6
  "type": "module",
@@ -31,24 +31,23 @@
31
31
  "borp": "^0.17.0",
32
32
  "c8": "^10.0.0",
33
33
  "eslint": "9",
34
- "fastify": "^4.26.2",
34
+ "fastify": "5.0.0-alpha.4",
35
35
  "license-checker": "^25.0.1",
36
36
  "mkdirp": "^2.1.6",
37
37
  "minimatch": "^10.0.1",
38
38
  "neostandard": "^0.11.1",
39
- "split2": "^4.2.0",
40
39
  "typescript": "^5.5.3",
41
- "@platformatic/astro": "2.0.0-alpha.7",
42
- "@platformatic/composer": "2.0.0-alpha.7",
43
- "@platformatic/db": "2.0.0-alpha.7",
44
- "@platformatic/next": "2.0.0-alpha.7",
45
- "@platformatic/remix": "2.0.0-alpha.7",
46
- "@platformatic/service": "2.0.0-alpha.7",
47
- "@platformatic/node": "2.0.0-alpha.7",
48
- "@platformatic/vite": "2.0.0-alpha.7"
40
+ "@platformatic/astro": "2.0.0-alpha.9",
41
+ "@platformatic/composer": "2.0.0-alpha.9",
42
+ "@platformatic/db": "2.0.0-alpha.9",
43
+ "@platformatic/node": "2.0.0-alpha.9",
44
+ "@platformatic/service": "2.0.0-alpha.9",
45
+ "@platformatic/remix": "2.0.0-alpha.9",
46
+ "@platformatic/next": "2.0.0-alpha.9",
47
+ "@platformatic/vite": "2.0.0-alpha.9"
49
48
  },
50
49
  "dependencies": {
51
- "@fastify/error": "^3.4.1",
50
+ "@fastify/error": "^4.0.0",
52
51
  "colorette": "^2.0.20",
53
52
  "commist": "^3.2.0",
54
53
  "desm": "^1.3.1",
@@ -59,22 +58,22 @@
59
58
  "help-me": "^5.0.0",
60
59
  "inquirer": "^9.2.16",
61
60
  "minimist": "^1.2.8",
62
- "pino": "^8.19.0",
61
+ "pino": "^9.0.0",
63
62
  "pino-pretty": "^11.0.0",
64
63
  "split2": "^4.2.0",
65
64
  "undici": "^6.9.0",
66
- "@platformatic/control": "2.0.0-alpha.7",
67
- "@platformatic/client-cli": "2.0.0-alpha.7",
68
- "@platformatic/db": "2.0.0-alpha.7",
69
- "@platformatic/config": "2.0.0-alpha.7",
70
- "@platformatic/frontend-template": "2.0.0-alpha.7",
71
- "@platformatic/basic": "2.0.0-alpha.7",
72
- "@platformatic/runtime": "2.0.0-alpha.7",
73
- "@platformatic/utils": "2.0.0-alpha.7",
74
- "create-platformatic": "2.0.0-alpha.7"
65
+ "@platformatic/client-cli": "2.0.0-alpha.9",
66
+ "@platformatic/config": "2.0.0-alpha.9",
67
+ "@platformatic/control": "2.0.0-alpha.9",
68
+ "@platformatic/db": "2.0.0-alpha.9",
69
+ "@platformatic/frontend-template": "2.0.0-alpha.9",
70
+ "@platformatic/basic": "2.0.0-alpha.9",
71
+ "@platformatic/runtime": "2.0.0-alpha.9",
72
+ "@platformatic/utils": "2.0.0-alpha.9",
73
+ "create-platformatic": "2.0.0-alpha.9"
75
74
  },
76
75
  "scripts": {
77
- "test": "pnpm run lint && borp --timeout=600000 --concurrency 1",
76
+ "test": "pnpm run lint && borp --no-timeout --concurrency 1",
78
77
  "lint": "eslint",
79
78
  "license": "license-checker --production --onlyAllow 'Apache-2.0;MIT;ISC;BSD-2-Clause;BSD-3-Clause;CC-BY-4.0'"
80
79
  }