@platformatic/watt-extra 1.9.1 → 1.10.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/.claude/settings.local.json +2 -1
- package/cli.js +10 -4
- package/index.js +8 -6
- package/lib/watt.js +1 -1
- package/package.json +1 -1
- package/test/cli.test.js +17 -0
package/cli.js
CHANGED
|
@@ -20,14 +20,20 @@ const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url),
|
|
|
20
20
|
const commistInstance = commist()
|
|
21
21
|
|
|
22
22
|
function version () {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
if (process.stdout.isTTY) {
|
|
24
|
+
console.log(getSimpleBanner(pkg.version))
|
|
25
|
+
} else {
|
|
26
|
+
logger.info(`WattExtra v${pkg.version}`)
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
// Handle start command
|
|
28
31
|
async function startCommand (argv) {
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
if (process.stdout.isTTY) {
|
|
33
|
+
console.log(getSimpleBanner(pkg.version))
|
|
34
|
+
} else {
|
|
35
|
+
logger.info(`WattExtra v${pkg.version}`)
|
|
36
|
+
}
|
|
31
37
|
|
|
32
38
|
const args = minimist(argv, {
|
|
33
39
|
alias: {
|
package/index.js
CHANGED
|
@@ -4,13 +4,15 @@ import { fileURLToPath } from 'node:url'
|
|
|
4
4
|
|
|
5
5
|
const logger = pino({
|
|
6
6
|
level: process.env.PLT_LOG_LEVEL || 'info',
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
...(process.stdout.isTTY && {
|
|
8
|
+
transport: {
|
|
9
|
+
target: 'pino-pretty',
|
|
10
|
+
options: {
|
|
11
|
+
colorize: true,
|
|
12
|
+
translateTime: true
|
|
13
|
+
}
|
|
12
14
|
}
|
|
13
|
-
}
|
|
15
|
+
})
|
|
14
16
|
})
|
|
15
17
|
|
|
16
18
|
// This starts the app and sends the info to ICC, so it's the main entry point
|
package/lib/watt.js
CHANGED
|
@@ -156,7 +156,7 @@ class Watt {
|
|
|
156
156
|
this.#logger.info('Creating runtime')
|
|
157
157
|
const { create, transform } = this.#require('@platformatic/runtime')
|
|
158
158
|
|
|
159
|
-
this.#logger.info('
|
|
159
|
+
this.#logger.info('Creating runtime')
|
|
160
160
|
|
|
161
161
|
const runtime = await create(this.#appDir, null, {
|
|
162
162
|
isProduction: true,
|
package/package.json
CHANGED
package/test/cli.test.js
CHANGED
|
@@ -73,3 +73,20 @@ test('CLI should show version with version command', async (t) => {
|
|
|
73
73
|
'Version output should include version number'
|
|
74
74
|
)
|
|
75
75
|
})
|
|
76
|
+
|
|
77
|
+
test('CLI should output JSON log without banner in non-TTY mode (version command)', async (t) => {
|
|
78
|
+
const { code, stdout } = await runCLI(['version'])
|
|
79
|
+
assert.strictEqual(code, 0, 'Process should exit with code 0')
|
|
80
|
+
|
|
81
|
+
// In non-TTY mode, should NOT have the banner box characters
|
|
82
|
+
assert.ok(
|
|
83
|
+
!stdout.includes('+======'),
|
|
84
|
+
'Non-TTY output should not include banner box'
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
// Should have JSON log with version
|
|
88
|
+
assert.ok(
|
|
89
|
+
stdout.includes('"msg":"WattExtra v'),
|
|
90
|
+
'Non-TTY output should include JSON log with version'
|
|
91
|
+
)
|
|
92
|
+
})
|