@isvbytes.com/cli 1.0.1 → 1.1.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.
Files changed (2) hide show
  1. package/dist/index.js +7 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -98,28 +98,22 @@ function parseJwtExpiry(token) {
98
98
  // src/index.ts
99
99
  var program = new Command();
100
100
  program.name("isvbytes").description("\u751F\u6210 xCloud authToken\uFF0C\u4F9B AI agent \u548C CLI \u5DE5\u5177\u4F7F\u7528").version("1.0.0");
101
- program.command("generate").description("\u751F\u6210\u6307\u5B9A\u7528\u6237\u7684 authToken").requiredOption("-e, --env <env>", `\u76EE\u6807\u73AF\u5883 (${SUPPORTED_ENVS.join("/")})`, "prod").requiredOption("-c, --code <code>", "\u7528\u6237 IT code (\u5982 zhangys36)").option("-o, --org-id <orgId>", "\u7EC4\u7EC7 ID", "88").option("--json", "\u4EE5 JSON \u683C\u5F0F\u8F93\u51FA\uFF08\u9002\u5408\u7A0B\u5E8F\u6D88\u8D39\uFF09", false).option("--quiet", "\u53EA\u8F93\u51FA token \u503C\uFF0C\u9002\u5408\u7BA1\u9053\u4F20\u9012", false).action(async (opts) => {
101
+ program.command("generate").description("\u751F\u6210\u6307\u5B9A\u7528\u6237\u7684 authToken").requiredOption("-e, --env <env>", `\u76EE\u6807\u73AF\u5883 (${SUPPORTED_ENVS.join("/")})`, "prod").requiredOption("-c, --code <code>", "\u7528\u6237 IT code (\u5982 zhangys36)").option("-o, --org-id <orgId>", "\u7EC4\u7EC7 ID", "88").option("--json", "\u8F93\u51FA\u5B8C\u6574 JSON\uFF08\u542B env\u3001expiresAt \u7B49\uFF09", false).option("-v, --verbose", "\u663E\u793A\u8BE6\u7EC6\u4FE1\u606F\uFF08\u73AF\u5883\u3001\u7528\u6237\u3001\u8FC7\u671F\u65F6\u95F4\uFF09", false).action(async (opts) => {
102
102
  const result = await generateToken({
103
103
  env: opts.env,
104
104
  code: opts.code,
105
105
  orgId: Number(opts.orgId)
106
106
  });
107
- if (opts.quiet) {
108
- if (result.success) {
109
- process.stdout.write(result.authToken);
110
- } else {
111
- process.stderr.write(`Error: ${result.error}
107
+ if (!result.success) {
108
+ process.stderr.write(`Error: ${result.error}
112
109
  `);
113
- process.exit(1);
114
- }
115
- return;
110
+ process.exit(1);
116
111
  }
117
112
  if (opts.json) {
118
113
  console.log(JSON.stringify(result, null, 2));
119
- if (!result.success) process.exit(1);
120
114
  return;
121
115
  }
122
- if (result.success) {
116
+ if (opts.verbose) {
123
117
  console.log(`\u2705 authToken \u751F\u6210\u6210\u529F`);
124
118
  console.log(` \u73AF\u5883: ${result.env}`);
125
119
  console.log(` \u7528\u6237: ${result.code}`);
@@ -128,10 +122,9 @@ program.command("generate").description("\u751F\u6210\u6307\u5B9A\u7528\u6237\u7
128
122
  }
129
123
  console.log(`
130
124
  ${result.authToken}`);
131
- } else {
132
- console.error(`\u274C \u751F\u6210\u5931\u8D25: ${result.error}`);
133
- process.exit(1);
125
+ return;
134
126
  }
127
+ process.stdout.write(result.authToken);
135
128
  });
136
129
  program.command("envs").description("\u5217\u51FA\u6240\u6709\u652F\u6301\u7684\u73AF\u5883").action(() => {
137
130
  console.log("\u652F\u6301\u7684\u73AF\u5883:\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isvbytes.com/cli",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "CLI tool to generate xCloud authToken for AI agents",
5
5
  "type": "module",
6
6
  "bin": {