feat(user): 注册 14 个新 user 子命令 + 修 delete exit code

- index.ts: 注册 14 个新子命令 (update/unlock/batch-state/batch-delete/
  get-position/set-position/batch-set-position/workHandover/socials-unbind/
  online-kick/changepwd/baseinfo/auth-groups/auth-list)
- delete.ts: exit(2) → exit(1) 避免 AI 误判为崩溃
- 14 个占位 .ts 文件 (后续 Task 逐个实现)
This commit is contained in:
ssw committed 2026-06-15 09:39:32 +08:00
1 parent 707c3fbb50
commit 60bbe2f68f
16 files changed
+267 -7

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
/**
* commands/user/auth-groups.ts — 占位, Task 16 实现
*/
import { Command } from 'commander'
import { log } from '../../core/log.ts'
import { installAiHelpHook } from '../../core/help.ts'
export function buildUserAuthGroupsCommand(): Command {
const cmd = new Command('auth-groups').description('TODO: implement in Task 16')
cmd.action(async () => {
log.warn('TODO: implement in Task 16')
process.exit(1)
})
installAiHelpHook(cmd, { purpose: 'TODO' })
return cmd
}
+16
View File
@@ -0,0 +1,16 @@
/**
* commands/user/auth-list.ts — 占位, Task 17 实现
*/
import { Command } from 'commander'
import { log } from '../../core/log.ts'
import { installAiHelpHook } from '../../core/help.ts'
export function buildUserAuthListCommand(): Command {
const cmd = new Command('auth-list').description('TODO: implement in Task 17')
cmd.action(async () => {
log.warn('TODO: implement in Task 17')
process.exit(1)
})
installAiHelpHook(cmd, { purpose: 'TODO' })
return cmd
}
+16
View File
@@ -0,0 +1,16 @@
/**
* commands/user/baseinfo.ts — 占位, Task 15 实现
*/
import { Command } from 'commander'
import { log } from '../../core/log.ts'
import { installAiHelpHook } from '../../core/help.ts'
export function buildUserBaseinfoCommand(): Command {
const cmd = new Command('baseinfo').description('TODO: implement in Task 15')
cmd.action(async () => {
log.warn('TODO: implement in Task 15')
process.exit(1)
})
installAiHelpHook(cmd, { purpose: 'TODO' })
return cmd
}
+16
View File
@@ -0,0 +1,16 @@
/**
* commands/user/batch-delete.ts — 占位, Task 7 实现
*/
import { Command } from 'commander'
import { log } from '../../core/log.ts'
import { installAiHelpHook } from '../../core/help.ts'
export function buildUserBatchDeleteCommand(): Command {
const cmd = new Command('batch-delete').description('TODO: implement in Task 7')
cmd.action(async () => {
log.warn('TODO: implement in Task 7')
process.exit(1)
})
installAiHelpHook(cmd, { purpose: 'TODO' })
return cmd
}
+16
View File
@@ -0,0 +1,16 @@
/**
* commands/user/batch-set-position.ts — 占位, Task 10 实现
*/
import { Command } from 'commander'
import { log } from '../../core/log.ts'
import { installAiHelpHook } from '../../core/help.ts'
export function buildUserBatchSetPositionCommand(): Command {
const cmd = new Command('batch-set-position').description('TODO: implement in Task 10')
cmd.action(async () => {
log.warn('TODO: implement in Task 10')
process.exit(1)
})
installAiHelpHook(cmd, { purpose: 'TODO' })
return cmd
}
+16
View File
@@ -0,0 +1,16 @@
/**
* commands/user/batch-state.ts — 占位, Task 6 实现
*/
import { Command } from 'commander'
import { log } from '../../core/log.ts'
import { installAiHelpHook } from '../../core/help.ts'
export function buildUserBatchStateCommand(): Command {
const cmd = new Command('batch-state').description('TODO: implement in Task 6')
cmd.action(async () => {
log.warn('TODO: implement in Task 6')
process.exit(1)
})
installAiHelpHook(cmd, { purpose: 'TODO' })
return cmd
}
+16
View File
@@ -0,0 +1,16 @@
/**
* commands/user/changepwd.ts — 占位, Task 14 实现
*/
import { Command } from 'commander'
import { log } from '../../core/log.ts'
import { installAiHelpHook } from '../../core/help.ts'
export function buildUserChangepwdCommand(): Command {
const cmd = new Command('changepwd').description('TODO: implement in Task 14')
cmd.action(async () => {
log.warn('TODO: implement in Task 14')
process.exit(1)
})
installAiHelpHook(cmd, { purpose: 'TODO' })
return cmd
}
+1 -1
View File
@@ -21,7 +21,7 @@ export function buildUserDeleteCommand(): Command {
.action(async (opts: DeleteOpts) => {
if (!opts.yes) {
log.warn(`即将删除用户 id=${opts.id}, 加 --yes 跳过确认`)
process.exit(2)
process.exit(1)
}
const c = await JnpfClient.fromToken()
const r = await c.del(`/permission/Users/${opts.id}`)
+16
View File
@@ -0,0 +1,16 @@
/**
* commands/user/get-position.ts — 占位, Task 8 实现
*/
import { Command } from 'commander'
import { log } from '../../core/log.ts'
import { installAiHelpHook } from '../../core/help.ts'
export function buildUserGetPositionCommand(): Command {
const cmd = new Command('get-position').description('TODO: implement in Task 8')
cmd.action(async () => {
log.warn('TODO: implement in Task 8')
process.exit(1)
})
installAiHelpHook(cmd, { purpose: 'TODO' })
return cmd
}
+42 -6
View File
@@ -5,23 +5,59 @@
*
* 决策 7: 用户是 P1 权限三角 2 号 (必须绑组织)
*
* 子命令:
* list 列表
* create 新建
* delete 删除
* resetpwd 重置密码
* 子命令 (v18):
* 基础: list / create / update / delete / resetpwd / unlock
* 批量: batch-state / batch-delete / batch-set-position
* 岗位: get-position / set-position
* 高级: workHandover / socials-unbind / online-kick
* self: changepwd / baseinfo
* auth: auth-groups / auth-list
*/
import { Command } from 'commander'
import { buildUserListCommand } from './list.ts'
import { buildUserCreateCommand } from './create.ts'
import { buildUserUpdateCommand } from './update.ts'
import { buildUserDeleteCommand } from './delete.ts'
import { buildUserResetPwdCommand } from './resetpwd.ts'
import { buildUserUnlockCommand } from './unlock.ts'
import { buildUserBatchStateCommand } from './batch-state.ts'
import { buildUserBatchDeleteCommand } from './batch-delete.ts'
import { buildUserGetPositionCommand } from './get-position.ts'
import { buildUserSetPositionCommand } from './set-position.ts'
import { buildUserBatchSetPositionCommand } from './batch-set-position.ts'
import { buildUserWorkHandoverCommand } from './workHandover.ts'
import { buildUserSocialsUnbindCommand } from './socials-unbind.ts'
import { buildUserOnlineKickCommand } from './online-kick.ts'
import { buildUserChangepwdCommand } from './changepwd.ts'
import { buildUserBaseinfoCommand } from './baseinfo.ts'
import { buildUserAuthGroupsCommand } from './auth-groups.ts'
import { buildUserAuthListCommand } from './auth-list.ts'
export function buildUserCommand(): Command {
const cmd = new Command('user').description('用户 (P1 权限三角 2 号, 登录主体)')
// 基础
cmd.addCommand(buildUserListCommand())
cmd.addCommand(buildUserCreateCommand())
cmd.addCommand(buildUserUpdateCommand())
cmd.addCommand(buildUserDeleteCommand())
cmd.addCommand(buildUserResetPwdCommand())
cmd.addCommand(buildUserUnlockCommand())
// 批量
cmd.addCommand(buildUserBatchStateCommand())
cmd.addCommand(buildUserBatchDeleteCommand())
cmd.addCommand(buildUserBatchSetPositionCommand())
// 岗位
cmd.addCommand(buildUserGetPositionCommand())
cmd.addCommand(buildUserSetPositionCommand())
// 高级
cmd.addCommand(buildUserWorkHandoverCommand())
cmd.addCommand(buildUserSocialsUnbindCommand())
cmd.addCommand(buildUserOnlineKickCommand())
// self
cmd.addCommand(buildUserChangepwdCommand())
cmd.addCommand(buildUserBaseinfoCommand())
// auth
cmd.addCommand(buildUserAuthGroupsCommand())
cmd.addCommand(buildUserAuthListCommand())
return cmd
}
}
+16
View File
@@ -0,0 +1,16 @@
/**
* commands/user/online-kick.ts — 占位, Task 13 实现
*/
import { Command } from 'commander'
import { log } from '../../core/log.ts'
import { installAiHelpHook } from '../../core/help.ts'
export function buildUserOnlineKickCommand(): Command {
const cmd = new Command('online-kick').description('TODO: implement in Task 13')
cmd.action(async () => {
log.warn('TODO: implement in Task 13')
process.exit(1)
})
installAiHelpHook(cmd, { purpose: 'TODO' })
return cmd
}
+16
View File
@@ -0,0 +1,16 @@
/**
* commands/user/set-position.ts — 占位, Task 9 实现
*/
import { Command } from 'commander'
import { log } from '../../core/log.ts'
import { installAiHelpHook } from '../../core/help.ts'
export function buildUserSetPositionCommand(): Command {
const cmd = new Command('set-position').description('TODO: implement in Task 9')
cmd.action(async () => {
log.warn('TODO: implement in Task 9')
process.exit(1)
})
installAiHelpHook(cmd, { purpose: 'TODO' })
return cmd
}
+16
View File
@@ -0,0 +1,16 @@
/**
* commands/user/socials-unbind.ts — 占位, Task 12 实现
*/
import { Command } from 'commander'
import { log } from '../../core/log.ts'
import { installAiHelpHook } from '../../core/help.ts'
export function buildUserSocialsUnbindCommand(): Command {
const cmd = new Command('socials-unbind').description('TODO: implement in Task 12')
cmd.action(async () => {
log.warn('TODO: implement in Task 12')
process.exit(1)
})
installAiHelpHook(cmd, { purpose: 'TODO' })
return cmd
}
+16
View File
@@ -0,0 +1,16 @@
/**
* commands/user/unlock.ts — 占位, Task 5 实现
*/
import { Command } from 'commander'
import { log } from '../../core/log.ts'
import { installAiHelpHook } from '../../core/help.ts'
export function buildUserUnlockCommand(): Command {
const cmd = new Command('unlock').description('TODO: implement in Task 5')
cmd.action(async () => {
log.warn('TODO: implement in Task 5')
process.exit(1)
})
installAiHelpHook(cmd, { purpose: 'TODO' })
return cmd
}
+16
View File
@@ -0,0 +1,16 @@
/**
* commands/user/update.ts — 占位, Task 4 实现
*/
import { Command } from 'commander'
import { log } from '../../core/log.ts'
import { installAiHelpHook } from '../../core/help.ts'
export function buildUserUpdateCommand(): Command {
const cmd = new Command('update').description('TODO: implement in Task 4')
cmd.action(async () => {
log.warn('TODO: implement in Task 4')
process.exit(1)
})
installAiHelpHook(cmd, { purpose: 'TODO' })
return cmd
}
+16
View File
@@ -0,0 +1,16 @@
/**
* commands/user/workHandover.ts — 占位, Task 11 实现
*/
import { Command } from 'commander'
import { log } from '../../core/log.ts'
import { installAiHelpHook } from '../../core/help.ts'
export function buildUserWorkHandoverCommand(): Command {
const cmd = new Command('workHandover').description('TODO: implement in Task 11')
cmd.action(async () => {
log.warn('TODO: implement in Task 11')
process.exit(1)
})
installAiHelpHook(cmd, { purpose: 'TODO' })
return cmd
}