chore(cli): rename test files from .mts to .ts

This commit is contained in:
Mohamed Boudra
2026-01-28 23:34:22 +07:00
parent d51d70a6fd
commit d78c7d5e07
17 changed files with 264 additions and 94 deletions
+10
View File
@@ -16,7 +16,17 @@ export function renderJson<T>(
// Apply custom serializer if provided
if (schema.serialize) {
if (result.type === 'list') {
// If all items serialize to the same object, return just one
// This handles the case where a list of key-value rows should serialize
// to a single structured object
const serialized = result.data.map((item) => schema.serialize!(item))
if (serialized.length > 0) {
const first = JSON.stringify(serialized[0])
const allSame = serialized.every((s) => JSON.stringify(s) === first)
if (allSame) {
return JSON.stringify(serialized[0], null, 2)
}
}
return JSON.stringify(serialized, null, 2)
} else {
const serialized = schema.serialize(result.data)
+2 -2
View File
@@ -97,7 +97,7 @@ function renderRow<T>(
}
}
return padCell(cell, width, col.align ?? 'left')
return padCell(cell, width ?? 0, col.align ?? 'left')
})
.join(' ')
}
@@ -109,7 +109,7 @@ function renderHeader<T>(
options: OutputOptions
): string {
const headerRow = columns
.map((col, i) => padCell(col.header, widths[i], col.align ?? 'left'))
.map((col, i) => padCell(col.header, widths[i] ?? 0, col.align ?? 'left'))
.join(' ')
return options.noColor ? headerRow : chalk.bold(headerRow)
+3 -1
View File
@@ -47,7 +47,9 @@ export function withOutput<T, Args extends unknown[]>(
): (...args: [...Args, CommandOptions, Command]) => Promise<void> {
return async (...args) => {
// Last two args are options and command
const options = args[args.length - 2] as CommandOptions
const command = args[args.length - 1] as Command
// Use optsWithGlobals() to get both local and global options
const options = command.optsWithGlobals() as CommandOptions
const outputOptions = extractOutputOptions(options)
try {
+10
View File
@@ -17,7 +17,17 @@ export function renderYaml<T>(
// Apply custom serializer if provided
if (schema.serialize) {
if (result.type === 'list') {
// If all items serialize to the same object, return just one
// This handles the case where a list of key-value rows should serialize
// to a single structured object
const serialized = result.data.map((item) => schema.serialize!(item))
if (serialized.length > 0) {
const first = JSON.stringify(serialized[0])
const allSame = serialized.every((s) => JSON.stringify(s) === first)
if (allSame) {
return YAML.stringify(serialized[0])
}
}
return YAML.stringify(serialized)
} else {
const serialized = schema.serialize(result.data)