52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
/**
|
|
* commands/app/info.ts — 应用详情
|
|
*
|
|
* API: GET /api/system/System/{id}
|
|
*/
|
|
import { Command } from 'commander'
|
|
import { JnpfClient } from '../../core/client.ts'
|
|
import { installAiHelpHook } from '../../core/help.ts'
|
|
import { log, printJson } from '../../core/log.ts'
|
|
|
|
interface InfoOpts {
|
|
id: string
|
|
json?: boolean
|
|
}
|
|
|
|
export function buildAppInfoCommand(): Command {
|
|
const cmd = new Command('info')
|
|
.description('查看应用详情 (含 systemId/系统配置等)')
|
|
.requiredOption('--id <id>', '应用 id')
|
|
.option('--json', '原始 JSON 输出', false)
|
|
.action(async (opts: InfoOpts) => {
|
|
const c = await JnpfClient.fromToken()
|
|
const r = await c.get<Record<string, unknown>>(`/system/System/${opts.id}`)
|
|
if (r.code !== 200) {
|
|
log.error(`app info 失败 (code=${r.code}): ${r.msg}`)
|
|
process.exit(1)
|
|
}
|
|
if (opts.json) {
|
|
printJson(r.data)
|
|
return
|
|
}
|
|
const d = r.data as Record<string, unknown>
|
|
log.info(`应用 id=${opts.id} 名称=${d.fullName} 编码=${d.enCode}`)
|
|
console.log(`icon: ${d.icon || '-'}`)
|
|
console.log(`sortCode: ${d.sortCode}`)
|
|
console.log(`backgroundColor: ${d.backgroundColor || '-'}`)
|
|
console.log(`creatorTime: ${d.creatorTime || '-'}`)
|
|
if (d.propertyJson) console.log(`propertyJson: ${d.propertyJson}`)
|
|
})
|
|
installAiHelpHook(cmd, {
|
|
purpose: '查看应用详情 (含 systemId/系统配置等)',
|
|
required: { '--id': '应用 id' },
|
|
example: 'dacli app info --id=835128640063677381',
|
|
source: {
|
|
web: 'web/apps/jnpf-web-apps-main/src/views/appCenter/Form.vue',
|
|
api: 'GET /api/system/System/{id}',
|
|
ref: 'doc/v0.8-endpoints.md §1.6',
|
|
},
|
|
})
|
|
return cmd
|
|
}
|