@meet-im/lxcli 0.0.12 → 0.0.13

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.
@@ -138,6 +138,7 @@ export function registerUsersCommand(program) {
138
138
  .description('Update user configuration (id: name or name@tenant)')
139
139
  .option('--token <token>', 'Update authentication token')
140
140
  .option('-e, --env <env>', `Update environment (${ENVIRONMENTS.join(', ')})`)
141
+ .option('--name <name>', 'Update user name (changes id to name@tenant)')
141
142
  .action((id, options) => {
142
143
  if (!id.includes('@')) {
143
144
  const matches = findUsersByName(id);
@@ -164,13 +165,23 @@ export function registerUsersCommand(program) {
164
165
  validEnvs: [...ENVIRONMENTS],
165
166
  });
166
167
  }
168
+ if (options.name !== undefined) {
169
+ if (!options.name.trim()) {
170
+ outputCliError('PARAM_INVALID', 'Name cannot be empty', { value: options.name });
171
+ }
172
+ if (options.name.includes('@')) {
173
+ outputCliError('PARAM_INVALID', 'Name cannot contain "@"', { value: options.name });
174
+ }
175
+ }
167
176
  const updates = {};
168
177
  if (options.token !== undefined)
169
178
  updates.token = options.token;
170
179
  if (options.env !== undefined)
171
180
  updates.env = options.env;
181
+ if (options.name !== undefined)
182
+ updates.name = options.name;
172
183
  if (Object.keys(updates).length === 0) {
173
- outputCliError('PARAM_MISSING', 'No update options provided. Use --token or --env', {});
184
+ outputCliError('PARAM_MISSING', 'No update options provided. Use --token, --env, or --name', {});
174
185
  }
175
186
  const updated = updateUser(user.id, updates);
176
187
  outputJson({
@@ -65,6 +65,7 @@ export declare function enableUser(id: string): boolean;
65
65
  export declare function updateUser(id: string, updates: {
66
66
  token?: string;
67
67
  env?: string;
68
+ name?: string;
68
69
  }): UserConfig | null;
69
70
  /**
70
71
  * 列出所有用户
@@ -228,6 +228,19 @@ export function updateUser(id, updates) {
228
228
  const user = config.users.find(u => u.id === id);
229
229
  if (!user)
230
230
  return null;
231
+ if (updates.name !== undefined) {
232
+ const newId = getUserId(updates.name, user.tenant);
233
+ const existing = config.users.find(u => u.id === newId);
234
+ if (existing) {
235
+ outputCliError('USER_ALREADY_EXISTS', `User "${newId}" already exists`, { id: newId });
236
+ }
237
+ const oldId = user.id;
238
+ user.name = updates.name;
239
+ user.id = newId;
240
+ if (config.currentUser === oldId) {
241
+ config.currentUser = newId;
242
+ }
243
+ }
231
244
  if (updates.token !== undefined) {
232
245
  user.token = updates.token;
233
246
  }
@@ -37,6 +37,11 @@ export declare const CLI_ERROR_CODES: {
37
37
  readonly reason: "userDisabled";
38
38
  readonly exitCode: 3;
39
39
  };
40
+ readonly USER_ALREADY_EXISTS: {
41
+ readonly code: 20003;
42
+ readonly reason: "userAlreadyExists";
43
+ readonly exitCode: 2;
44
+ };
40
45
  readonly TENANT_NOT_FOUND: {
41
46
  readonly code: 30001;
42
47
  readonly reason: "tenantNotFound";
@@ -94,6 +99,10 @@ export declare function getErrorMeta(key: CliErrorKey): {
94
99
  readonly code: 20002;
95
100
  readonly reason: "userDisabled";
96
101
  readonly exitCode: 3;
102
+ } | {
103
+ readonly code: 20003;
104
+ readonly reason: "userAlreadyExists";
105
+ readonly exitCode: 2;
97
106
  } | {
98
107
  readonly code: 30001;
99
108
  readonly reason: "tenantNotFound";
@@ -18,6 +18,7 @@ export const CLI_ERROR_CODES = {
18
18
  PARAM_INVALID: { code: 10002, reason: 'paramInvalid', exitCode: CLI_EXIT_CODES.PARAM },
19
19
  USER_NOT_FOUND: { code: 20001, reason: 'userNotFound', exitCode: CLI_EXIT_CODES.NOT_FOUND },
20
20
  USER_DISABLED: { code: 20002, reason: 'userDisabled', exitCode: CLI_EXIT_CODES.AUTH },
21
+ USER_ALREADY_EXISTS: { code: 20003, reason: 'userAlreadyExists', exitCode: CLI_EXIT_CODES.PARAM },
21
22
  TENANT_NOT_FOUND: { code: 30001, reason: 'tenantNotFound', exitCode: CLI_EXIT_CODES.NOT_FOUND },
22
23
  SERVICE_NOT_FOUND: { code: 30002, reason: 'serviceNotFound', exitCode: CLI_EXIT_CODES.NOT_FOUND },
23
24
  CONFIG_READ_ERROR: { code: 40001, reason: 'configReadError', exitCode: CLI_EXIT_CODES.INTERNAL },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meet-im/lxcli",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "连续科技命令行工具",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",