@platformatic/watt-extra 1.14.2 → 1.14.3

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/cli.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import commist from 'commist'
3
- import minimist from 'minimist'
4
- import { resolve, join, dirname } from 'node:path'
5
- import { fileURLToPath, pathToFileURL } from 'node:url'
3
+ import { join, dirname } from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
6
5
  import helpMeInit from 'help-me'
7
6
  import { readFileSync } from 'node:fs'
8
7
  import { start, logger } from './index.js'
9
8
  import { getSimpleBanner } from './lib/banner.js'
9
+ import { applyStartArgs } from './lib/start-args.js'
10
10
 
11
11
  const __filename = fileURLToPath(import.meta.url)
12
12
  const __dirname = dirname(__filename)
@@ -27,51 +27,6 @@ function version () {
27
27
  }
28
28
  }
29
29
 
30
- // Parse start command argv and apply CLI options to env.
31
- // Precedence for PLT_LOG_LEVEL: --log-level flag > pre-set env > 'info' default.
32
- // Do NOT add a minimist default for `log-level`: that would make args['log-level']
33
- // always truthy and unconditionally clobber an env-provided value.
34
- export function applyStartArgs (argv, env = process.env) {
35
- const args = minimist(argv, {
36
- alias: {
37
- h: 'help',
38
- l: 'log-level',
39
- i: 'icc-url',
40
- a: 'app-name',
41
- d: 'app-dir'
42
- },
43
- boolean: ['help'],
44
- string: ['log-level', 'icc-url', 'app-name', 'app-dir'],
45
- default: {
46
- 'app-dir': process.cwd()
47
- }
48
- })
49
-
50
- if (args.help) {
51
- return { args, help: true }
52
- }
53
-
54
- if (args['log-level']) {
55
- env.PLT_LOG_LEVEL = args['log-level']
56
- } else if (!env.PLT_LOG_LEVEL) {
57
- env.PLT_LOG_LEVEL = 'info'
58
- }
59
-
60
- if (args['icc-url']) {
61
- env.PLT_ICC_URL = args['icc-url']
62
- }
63
-
64
- if (args['app-name']) {
65
- env.PLT_APP_NAME = args['app-name']
66
- }
67
-
68
- if (args['app-dir']) {
69
- env.PLT_APP_DIR = resolve(args['app-dir']) // Ensure the path is absolute
70
- }
71
-
72
- return { args, help: false }
73
- }
74
-
75
30
  // Handle start command
76
31
  async function startCommand (argv) {
77
32
  if (process.stdout.isTTY) {
@@ -158,6 +113,4 @@ async function run () {
158
113
  }
159
114
  }
160
115
 
161
- if (import.meta.url === pathToFileURL(process.argv[1]).href) {
162
- run()
163
- }
116
+ run()
@@ -0,0 +1,47 @@
1
+ import minimist from 'minimist'
2
+ import { resolve } from 'node:path'
3
+
4
+ // Parse start command argv and apply CLI options to env.
5
+ // Precedence for PLT_LOG_LEVEL: --log-level flag > pre-set env > 'info' default.
6
+ // Do NOT add a minimist default for `log-level`: that would make args['log-level']
7
+ // always truthy and unconditionally clobber an env-provided value.
8
+ export function applyStartArgs (argv, env = process.env) {
9
+ const args = minimist(argv, {
10
+ alias: {
11
+ h: 'help',
12
+ l: 'log-level',
13
+ i: 'icc-url',
14
+ a: 'app-name',
15
+ d: 'app-dir'
16
+ },
17
+ boolean: ['help'],
18
+ string: ['log-level', 'icc-url', 'app-name', 'app-dir'],
19
+ default: {
20
+ 'app-dir': process.cwd()
21
+ }
22
+ })
23
+
24
+ if (args.help) {
25
+ return { args, help: true }
26
+ }
27
+
28
+ if (args['log-level']) {
29
+ env.PLT_LOG_LEVEL = args['log-level']
30
+ } else if (!env.PLT_LOG_LEVEL) {
31
+ env.PLT_LOG_LEVEL = 'info'
32
+ }
33
+
34
+ if (args['icc-url']) {
35
+ env.PLT_ICC_URL = args['icc-url']
36
+ }
37
+
38
+ if (args['app-name']) {
39
+ env.PLT_APP_NAME = args['app-name']
40
+ }
41
+
42
+ if (args['app-dir']) {
43
+ env.PLT_APP_DIR = resolve(args['app-dir']) // Ensure the path is absolute
44
+ }
45
+
46
+ return { args, help: false }
47
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/watt-extra",
3
- "version": "1.14.2",
3
+ "version": "1.14.3",
4
4
  "description": "The Platformatic runtime manager",
5
5
  "type": "module",
6
6
  "scripts": {
package/test/cli.test.js CHANGED
@@ -3,7 +3,7 @@ import { test } from 'node:test'
3
3
  import { spawn } from 'node:child_process'
4
4
  import { join, resolve, dirname } from 'node:path'
5
5
  import { fileURLToPath } from 'node:url'
6
- import { applyStartArgs } from '../cli.js'
6
+ import { applyStartArgs } from '../lib/start-args.js'
7
7
 
8
8
  const __filename = fileURLToPath(import.meta.url)
9
9
  const __dirname = dirname(__filename)