@zrhsh/wukong-cli 0.1.12 → 0.2.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.
package/README.md CHANGED
@@ -10,6 +10,8 @@ TypeScript CLI tool for Oceanet/NRP system with OAuth Device PKCE Flow authentic
10
10
  - 🐛 **Debug Mode** - Show HTTP requests and responses with `--debug` flag
11
11
  - 💾 **Secure Storage** - Platform native credential managers with file fallback
12
12
  - 🛠️ **HTTP Client** - Built-in HTTP client with automatic authentication
13
+ - ⚙️ **Smart Configuration** - Built-in defaults with fallback to user configuration
14
+ - 🔍 **Structured Errors** - Clear error messages with actionable fix suggestions
13
15
 
14
16
  ## Quick Start
15
17
 
@@ -80,6 +82,61 @@ set WUKONG_CLI_ENV=beta
80
82
  wukong-cli auth login
81
83
  ```
82
84
 
85
+ ## Configuration
86
+
87
+ Wukong CLI uses intelligent configuration with built-in defaults:
88
+
89
+ - **No Configuration Required**: CLI works out of the box with built-in environment defaults
90
+ - **Custom Configuration**: Optional `wukong-cli.json` for custom endpoints
91
+ - **Smart Fallback**: Uses built-in defaults when environments are not configured
92
+ - **Clear Errors**: Structured error messages guide you to fix configuration issues
93
+
94
+ ### Configuration File Location
95
+
96
+ ```bash
97
+ ~/wukong-cli.json # User home directory
98
+ ```
99
+
100
+ ### Initialize Configuration
101
+
102
+ ```bash
103
+ wukong-cli init # Creates or resets configuration file
104
+ ```
105
+
106
+ ### Example Configuration
107
+
108
+ ```json
109
+ {
110
+ "defaultEnv": "prod",
111
+ "environments": {
112
+ "prod": {
113
+ "authBaseUrl": "https://portal.zrhsh.com",
114
+ "apiBaseUrl": "https://nrp.zrhsh.com",
115
+ "clientId": "wukong-cli-prod"
116
+ },
117
+ "dev": {
118
+ "authBaseUrl": "https://portal-dev.zrhsh.com",
119
+ "apiBaseUrl": "https://nrp-recode-dev.zrhsh.com",
120
+ "clientId": "wukong-cli-dev"
121
+ }
122
+ }
123
+ }
124
+ ```
125
+
126
+ ### Configuration Errors
127
+
128
+ If your configuration is incomplete, you'll see structured error messages:
129
+
130
+ ```
131
+ [ERROR] Configuration Error
132
+
133
+ Incomplete configuration for environment 'prod'
134
+ Environment: prod
135
+ Missing fields: apiBaseUrl, clientId
136
+
137
+ Edit your wukong-cli.json or run 'wukong-cli init' to reset
138
+ ```
139
+
83
140
  ## Documentation
84
141
 
85
142
  ### Getting Started
@@ -109,7 +166,7 @@ wukong-cli auth login
109
166
 
110
167
  ## Project Information
111
168
 
112
- - **Version**: 0.1.6
169
+ - **Version**: 0.1.12
113
170
  - **Package**: @zrhsh/wukong-cli
114
171
  - **Organization**: @zrhsh
115
172
  - **License**: MIT
@@ -189,4 +246,4 @@ See [Release Notes](docs/publishing/release-notes.md) for version history and ch
189
246
 
190
247
  ---
191
248
 
192
- **Current Version**: 0.1.6 | **Package**: @zrhsh/wukong-cli | **Organization**: @zrhsh
249
+ **Current Version**: 0.1.12 | **Package**: @zrhsh/wukong-cli | **Organization**: @zrhsh
package/dist/cli.js CHANGED
@@ -3,6 +3,12 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
7
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
8
+ }) : x)(function(x) {
9
+ if (typeof require !== "undefined") return require.apply(this, arguments);
10
+ throw Error('Dynamic require of "' + x + '" is not supported');
11
+ });
6
12
  var __esm = (fn, res) => function __init() {
7
13
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
14
  };
@@ -88,6 +94,235 @@ var init_debug = __esm({
88
94
  }
89
95
  });
90
96
 
97
+ // src/utils/version/cache.ts
98
+ var VersionCache;
99
+ var init_cache = __esm({
100
+ "src/utils/version/cache.ts"() {
101
+ "use strict";
102
+ init_esm_shims();
103
+ VersionCache = class {
104
+ lastCheckTime = 0;
105
+ cachedVersion = null;
106
+ checkInterval;
107
+ /**
108
+ * Constructor
109
+ * @param checkInterval - Check interval in milliseconds (default: 24 hours)
110
+ */
111
+ constructor(checkInterval = 24 * 60 * 60 * 1e3) {
112
+ this.checkInterval = checkInterval;
113
+ }
114
+ /**
115
+ * Check if a new version check should be performed
116
+ */
117
+ shouldCheck() {
118
+ const now = Date.now();
119
+ return now - this.lastCheckTime >= this.checkInterval;
120
+ }
121
+ /**
122
+ * Get cached version
123
+ */
124
+ get() {
125
+ return this.cachedVersion;
126
+ }
127
+ /**
128
+ * Set cached version with timestamp
129
+ */
130
+ set(version) {
131
+ this.cachedVersion = version;
132
+ this.lastCheckTime = Date.now();
133
+ }
134
+ /**
135
+ * Clear cache
136
+ */
137
+ clear() {
138
+ this.lastCheckTime = 0;
139
+ this.cachedVersion = null;
140
+ }
141
+ /**
142
+ * Get time since last check
143
+ */
144
+ getTimeSinceLastCheck() {
145
+ if (this.lastCheckTime === 0) {
146
+ return 0;
147
+ }
148
+ return Date.now() - this.lastCheckTime;
149
+ }
150
+ };
151
+ }
152
+ });
153
+
154
+ // src/utils/version/provider.ts
155
+ var provider_exports = {};
156
+ __export(provider_exports, {
157
+ NpmVersionProvider: () => NpmVersionProvider
158
+ });
159
+ var NpmVersionProvider;
160
+ var init_provider = __esm({
161
+ "src/utils/version/provider.ts"() {
162
+ "use strict";
163
+ init_esm_shims();
164
+ NpmVersionProvider = class {
165
+ constructor(packageName, registryUrl) {
166
+ this.packageName = packageName;
167
+ this.registryUrl = registryUrl;
168
+ this.timeout = 5e3;
169
+ }
170
+ timeout;
171
+ /**
172
+ * Get latest version from npm
173
+ */
174
+ async getLatestVersion() {
175
+ try {
176
+ const controller = new AbortController();
177
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
178
+ const response = await fetch(`${this.registryUrl}/${this.packageName}`, {
179
+ signal: controller.signal
180
+ });
181
+ clearTimeout(timeoutId);
182
+ if (!response.ok) {
183
+ return null;
184
+ }
185
+ const data = await response.json();
186
+ return data["dist-tags"]?.latest || null;
187
+ } catch (error) {
188
+ return null;
189
+ }
190
+ }
191
+ };
192
+ }
193
+ });
194
+
195
+ // src/utils/version/checker.ts
196
+ var checker_exports = {};
197
+ __export(checker_exports, {
198
+ VersionChecker: () => VersionChecker
199
+ });
200
+ var VersionChecker;
201
+ var init_checker = __esm({
202
+ "src/utils/version/checker.ts"() {
203
+ "use strict";
204
+ init_esm_shims();
205
+ init_cache();
206
+ VersionChecker = class {
207
+ constructor(provider, currentVersion, cache) {
208
+ this.provider = provider;
209
+ this.currentVersion = currentVersion;
210
+ this.cache = cache || new VersionCache();
211
+ }
212
+ cache;
213
+ /**
214
+ * Compare two version strings
215
+ * Returns: 1 if v1 > v2, -1 if v1 < v2, 0 if equal
216
+ */
217
+ compareVersions(v1, v2) {
218
+ const parts1 = v1.split(".").map(Number);
219
+ const parts2 = v2.split(".").map(Number);
220
+ for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
221
+ const part1 = parts1[i] || 0;
222
+ const part2 = parts2[i] || 0;
223
+ if (part1 > part2) return 1;
224
+ if (part1 < part2) return -1;
225
+ }
226
+ return 0;
227
+ }
228
+ /**
229
+ * Check for update (cached or fresh)
230
+ */
231
+ async checkForUpdate() {
232
+ if (!this.cache.shouldCheck()) {
233
+ const cached = this.cache.get();
234
+ if (cached) {
235
+ return {
236
+ hasUpdate: this.compareVersions(cached, this.currentVersion) > 0,
237
+ currentVersion: this.currentVersion,
238
+ latestVersion: cached
239
+ };
240
+ }
241
+ }
242
+ const latestVersion = await this.provider.getLatestVersion();
243
+ if (!latestVersion) {
244
+ return {
245
+ hasUpdate: false,
246
+ currentVersion: this.currentVersion,
247
+ latestVersion: null
248
+ };
249
+ }
250
+ this.cache.set(latestVersion);
251
+ return {
252
+ hasUpdate: this.compareVersions(latestVersion, this.currentVersion) > 0,
253
+ currentVersion: this.currentVersion,
254
+ latestVersion
255
+ };
256
+ }
257
+ /**
258
+ * Check in background (for async execution)
259
+ */
260
+ async checkInBackground() {
261
+ try {
262
+ await this.checkForUpdate();
263
+ } catch (error) {
264
+ }
265
+ }
266
+ /**
267
+ * Clear cached data
268
+ */
269
+ clearCache() {
270
+ this.cache.clear();
271
+ }
272
+ /**
273
+ * Get current cache info
274
+ */
275
+ getCacheInfo() {
276
+ return {
277
+ lastCheckTime: this.cache.lastCheckTime,
278
+ cachedVersion: this.cache.cachedVersion
279
+ };
280
+ }
281
+ };
282
+ }
283
+ });
284
+
285
+ // src/config/errors/config-file-error.ts
286
+ var ConfigFileError;
287
+ var init_config_file_error = __esm({
288
+ "src/config/errors/config-file-error.ts"() {
289
+ "use strict";
290
+ init_esm_shims();
291
+ ConfigFileError = class extends Error {
292
+ constructor(type, message, environment, missingFields, fixSuggestion) {
293
+ super(message);
294
+ this.type = type;
295
+ this.environment = environment;
296
+ this.missingFields = missingFields;
297
+ this.fixSuggestion = fixSuggestion;
298
+ this.name = "ConfigFileError";
299
+ }
300
+ /**
301
+ * Format error message for user display
302
+ */
303
+ toUserMessage() {
304
+ let message = `
305
+ ${this.message}
306
+ `;
307
+ if (this.environment) {
308
+ message += `Environment: ${this.environment}
309
+ `;
310
+ }
311
+ if (this.missingFields && this.missingFields.length > 0) {
312
+ message += `Missing fields: ${this.missingFields.join(", ")}
313
+ `;
314
+ }
315
+ if (this.fixSuggestion) {
316
+ message += `
317
+ ${this.fixSuggestion}
318
+ `;
319
+ }
320
+ return message;
321
+ }
322
+ };
323
+ }
324
+ });
325
+
91
326
  // src/constants/config.ts
92
327
  var API_ENDPOINTS, POLL_CONFIG;
93
328
  var init_config = __esm({
@@ -226,28 +461,38 @@ function loadConfig() {
226
461
  }
227
462
  function getMergedEnvironmentConfig(env) {
228
463
  const config = loadConfig();
229
- if (!config.environments || !(env in config.environments)) {
230
- throw new Error(
231
- `Environment '${env}' not found in configuration. Please run 'wukong-cli init' to create a valid configuration file.`
464
+ const defaultEnvConfig = ENVIRONMENTS[env];
465
+ if (!defaultEnvConfig) {
466
+ throw new ConfigFileError(
467
+ "ENVIRONMENT_MISSING" /* ENVIRONMENT_MISSING */,
468
+ `Unknown environment: '${env}'`,
469
+ env,
470
+ void 0,
471
+ `Valid environments: ${Object.keys(ENVIRONMENTS).join(", ")}`
232
472
  );
233
473
  }
234
- const envConfig = config.environments[env];
235
- const requiredFields = ["authBaseUrl", "apiBaseUrl", "clientId"];
236
- const missingFields = requiredFields.filter((field) => !(field in envConfig));
237
- if (missingFields.length > 0) {
238
- throw new Error(
239
- `Missing required configuration fields for environment '${env}': ${missingFields.join(", ")}. Please run 'wukong-cli init' to create a valid configuration file.`
240
- );
474
+ if (config.environments && env in config.environments) {
475
+ const envConfig = config.environments[env];
476
+ const requiredFields = ["authBaseUrl", "apiBaseUrl", "clientId"];
477
+ const missingFields = requiredFields.filter((field) => !(field in envConfig));
478
+ if (missingFields.length > 0) {
479
+ throw new ConfigFileError(
480
+ "REQUIRED_FIELD_MISSING" /* REQUIRED_FIELD_MISSING */,
481
+ `Incomplete configuration for environment '${env}'`,
482
+ env,
483
+ missingFields,
484
+ `Edit your wukong-cli.json or run 'wukong-cli init' to reset`
485
+ );
486
+ }
487
+ return {
488
+ name: env,
489
+ displayName: defaultEnvConfig.displayName,
490
+ authBaseUrl: envConfig.authBaseUrl,
491
+ apiBaseUrl: envConfig.apiBaseUrl,
492
+ clientId: envConfig.clientId
493
+ };
241
494
  }
242
- const defaultConfig = ENVIRONMENTS[env];
243
- const displayName = defaultConfig?.displayName || env;
244
- return {
245
- name: env,
246
- displayName,
247
- authBaseUrl: envConfig.authBaseUrl,
248
- apiBaseUrl: envConfig.apiBaseUrl,
249
- clientId: envConfig.clientId
250
- };
495
+ return defaultEnvConfig;
251
496
  }
252
497
  function getAllEnvironments() {
253
498
  const config = loadConfig();
@@ -282,6 +527,7 @@ var init_config_loader = __esm({
282
527
  "use strict";
283
528
  init_esm_shims();
284
529
  init_environments();
530
+ init_config_file_error();
285
531
  CONFIG_FILENAMES = [
286
532
  "wukong-cli.json",
287
533
  ".wukong-cli.json",
@@ -499,7 +745,7 @@ var init_ora_ui_callbacks = __esm({
499
745
  });
500
746
 
501
747
  // src/core/auth/keytar-adapter.ts
502
- import { createRequire as createRequire2 } from "module";
748
+ import { createRequire } from "module";
503
749
  function isKeytarAvailable() {
504
750
  return keytarModule !== null;
505
751
  }
@@ -521,15 +767,15 @@ async function deletePassword(service, account) {
521
767
  }
522
768
  return await keytarModule.deletePassword(service, account);
523
769
  }
524
- var require3, keytarModule;
770
+ var require2, keytarModule;
525
771
  var init_keytar_adapter = __esm({
526
772
  "src/core/auth/keytar-adapter.ts"() {
527
773
  "use strict";
528
774
  init_esm_shims();
529
- require3 = createRequire2(import.meta.url);
775
+ require2 = createRequire(import.meta.url);
530
776
  keytarModule = null;
531
777
  try {
532
- keytarModule = require3("keytar");
778
+ keytarModule = require2("keytar");
533
779
  } catch (error) {
534
780
  keytarModule = null;
535
781
  }
@@ -717,91 +963,29 @@ init_esm_shims();
717
963
  init_debug();
718
964
  import { Command as Command4 } from "commander";
719
965
 
720
- // src/utils/version-check.ts
966
+ // src/utils/version/index.ts
721
967
  init_esm_shims();
722
- import { createRequire } from "module";
723
- var require2 = createRequire(import.meta.url);
724
- var packageJson = require2("../package.json");
725
- var PACKAGE_NAME = "@zrhsh/wukong-cli";
726
- var NPM_REGISTRY_URL = "https://registry.npmjs.org";
727
- var CHECK_INTERVAL = 24 * 60 * 60 * 1e3;
728
- var lastCheckTime = 0;
729
- var cachedLatestVersion = null;
730
- function compareVersions(v1, v2) {
731
- const parts1 = v1.split(".").map(Number);
732
- const parts2 = v2.split(".").map(Number);
733
- for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
734
- const part1 = parts1[i] || 0;
735
- const part2 = parts2[i] || 0;
736
- if (part1 > part2) return 1;
737
- if (part1 < part2) return -1;
738
- }
739
- return 0;
740
- }
741
- async function getLatestVersion() {
742
- try {
743
- const controller = new AbortController();
744
- const timeoutId = setTimeout(() => controller.abort(), 5e3);
745
- const response = await fetch(`${NPM_REGISTRY_URL}/${PACKAGE_NAME}`, {
746
- signal: controller.signal
747
- });
748
- clearTimeout(timeoutId);
749
- const data = await response.json();
750
- return data["dist-tags"]?.latest || null;
751
- } catch (error) {
752
- return null;
753
- }
754
- }
755
- async function checkForUpdate() {
756
- const now = Date.now();
757
- const currentVersion = packageJson.version;
758
- if (now - lastCheckTime < CHECK_INTERVAL && cachedLatestVersion) {
759
- return {
760
- hasUpdate: compareVersions(cachedLatestVersion, currentVersion) > 0,
761
- currentVersion,
762
- latestVersion: cachedLatestVersion
763
- };
764
- }
765
- const latestVersion = await getLatestVersion();
766
- if (!latestVersion) {
767
- return {
768
- hasUpdate: false,
769
- currentVersion,
770
- latestVersion: null
771
- };
772
- }
773
- lastCheckTime = now;
774
- cachedLatestVersion = latestVersion;
775
- return {
776
- hasUpdate: compareVersions(latestVersion, currentVersion) > 0,
777
- currentVersion,
778
- latestVersion
779
- };
780
- }
781
- async function showUpdateNotification() {
782
- const { hasUpdate, currentVersion, latestVersion } = await checkForUpdate();
783
- if (!hasUpdate || !latestVersion) {
784
- return;
785
- }
786
- console.log("");
787
- console.log("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557");
788
- console.log("\u2551" + " ".repeat(58) + "\u2551");
789
- console.log("\u2551" + " \u{1F389} New version available!".padEnd(60) + "\u2551");
790
- console.log("\u2551" + " ".repeat(58) + "\u2551");
791
- console.log(`\u2551 Current: ${currentVersion.padEnd(10)} Latest: ${latestVersion.padEnd(10)} \u2551`);
792
- console.log("\u2551" + " ".repeat(58) + "\u2551");
793
- console.log("\u2551" + " Update command:".padEnd(60) + "\u2551");
794
- console.log(`\u2551 npm install -g ${PACKAGE_NAME}@latest`.padEnd(60) + "\u2551");
795
- console.log("\u2551" + " ".repeat(58) + "\u2551");
796
- console.log("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D");
797
- console.log("");
798
- }
799
- async function checkAndUpdate(silent = false) {
800
- if (!silent) {
801
- await showUpdateNotification();
802
- } else {
803
- await checkForUpdate();
968
+ init_cache();
969
+ init_provider();
970
+ init_checker();
971
+ var versionCheckerInstance = null;
972
+ function getVersionChecker() {
973
+ if (!versionCheckerInstance) {
974
+ const { createRequire: createRequire2 } = __require("module");
975
+ const nodeRequire = createRequire2(import.meta.url);
976
+ const packageJson = nodeRequire("../../package.json");
977
+ const { NpmVersionProvider: NpmVersionProvider2 } = (init_provider(), __toCommonJS(provider_exports));
978
+ const { VersionChecker: VersionChecker2 } = (init_checker(), __toCommonJS(checker_exports));
979
+ const provider = new NpmVersionProvider2(
980
+ "@zrhsh/wukong-cli",
981
+ "https://registry.npmjs.org"
982
+ );
983
+ versionCheckerInstance = new VersionChecker2(
984
+ provider,
985
+ packageJson.version
986
+ );
804
987
  }
988
+ return versionCheckerInstance;
805
989
  }
806
990
 
807
991
  // src/commands/auth.ts
@@ -826,6 +1010,9 @@ function printEnvironmentInfo(env, displayName) {
826
1010
  }
827
1011
  }
828
1012
 
1013
+ // src/commands/auth.ts
1014
+ init_config_file_error();
1015
+
829
1016
  // src/core/auth/device-flow.ts
830
1017
  init_esm_shims();
831
1018
  init_oceanet();
@@ -1711,6 +1898,14 @@ authCommands.command("login").description("Login using Device Authorization Flow
1711
1898
  console.log(chalk5.dim("Next:"), chalk5.cyan("wukong-cli auth status"));
1712
1899
  console.log("");
1713
1900
  } catch (error) {
1901
+ if (error instanceof ConfigFileError) {
1902
+ console.log("");
1903
+ console.log(chalk5.red(`[ERROR] Configuration Error`));
1904
+ console.log("");
1905
+ console.log(chalk5.red(error.toUserMessage()));
1906
+ console.log("");
1907
+ return;
1908
+ }
1714
1909
  console.log("");
1715
1910
  console.log(chalk5.red(`[ERROR] ${error instanceof Error ? error.message : "Unknown error"}`));
1716
1911
  console.log("");
@@ -1739,8 +1934,8 @@ authCommands.command("refresh").description("Manually refresh access token").act
1739
1934
  const env = getCurrentEnvironment();
1740
1935
  const allEnvs = getAllEnvironments();
1741
1936
  const envConfig = allEnvs[env];
1742
- const config = getOceanetConfig();
1743
1937
  try {
1938
+ const config = getOceanetConfig();
1744
1939
  const accessToken = await getAccessToken();
1745
1940
  if (!accessToken) {
1746
1941
  console.log("");
@@ -1765,6 +1960,14 @@ authCommands.command("refresh").description("Manually refresh access token").act
1765
1960
  throw error;
1766
1961
  }
1767
1962
  } catch (error) {
1963
+ if (error instanceof ConfigFileError) {
1964
+ console.log("");
1965
+ console.log(chalk5.red(`[ERROR] Configuration Error`));
1966
+ console.log("");
1967
+ console.log(chalk5.red(error.toUserMessage()));
1968
+ console.log("");
1969
+ return;
1970
+ }
1768
1971
  console.log("");
1769
1972
  console.log(chalk5.red(`[ERROR] ${error instanceof Error ? error.message : "Unknown error"}`));
1770
1973
  console.log("");
@@ -1780,8 +1983,8 @@ authCommands.command("status").description("Show authentication status").action(
1780
1983
  const allEnvs = getAllEnvironments();
1781
1984
  setCurrentEnvironment(env);
1782
1985
  const envConfig = allEnvs[env];
1783
- const config = getOceanetConfig();
1784
1986
  try {
1987
+ const config = getOceanetConfig();
1785
1988
  const accessToken = await getAccessToken();
1786
1989
  if (!accessToken) {
1787
1990
  console.log(chalk5.yellow(`[ERROR] Not authenticated`));
@@ -1815,6 +2018,13 @@ authCommands.command("status").description("Show authentication status").action(
1815
2018
  console.log("");
1816
2019
  }
1817
2020
  } catch (error) {
2021
+ if (error instanceof ConfigFileError) {
2022
+ console.log(chalk5.red(`[ERROR] Configuration Error`));
2023
+ console.log("");
2024
+ console.log(chalk5.red(error.toUserMessage()));
2025
+ console.log("");
2026
+ return;
2027
+ }
1818
2028
  console.log(chalk5.yellow(`\u2717 Not authenticated`));
1819
2029
  console.log("");
1820
2030
  printEnvironmentInfo(env, envConfig.displayName);
@@ -1830,6 +2040,7 @@ import ora4 from "ora";
1830
2040
  import chalk6 from "chalk";
1831
2041
  init_oceanet();
1832
2042
  init_debug();
2043
+ init_config_file_error();
1833
2044
  function fixGitBashPath(url) {
1834
2045
  if (url.includes(":") && !url.startsWith("http")) {
1835
2046
  const oceanetIndex = url.indexOf("/oceanet-");
@@ -1902,6 +2113,14 @@ async function executeRequest(method, url, options) {
1902
2113
  console.log(JSON.stringify(data, null, 2));
1903
2114
  } catch (error) {
1904
2115
  spinner.fail("Request failed");
2116
+ if (error instanceof ConfigFileError) {
2117
+ console.log("");
2118
+ console.log(chalk6.red(`[ERROR] Configuration Error`));
2119
+ console.log("");
2120
+ console.log(chalk6.red(error.toUserMessage()));
2121
+ console.log("");
2122
+ process.exit(1);
2123
+ }
1905
2124
  if (error instanceof Error) {
1906
2125
  console.error(chalk6.red(error.message));
1907
2126
  }
@@ -1980,7 +2199,7 @@ var initCommand = new Command3("init").description("Initialize configuration fil
1980
2199
 
1981
2200
  // src/cli.ts
1982
2201
  var program = new Command4();
1983
- program.name("wukong-cli").description("Wukong CLI - TypeScript implementation").version("0.1.12").option("--debug", "Enable debug mode (show HTTP requests)").hook("preAction", (thisCommand) => {
2202
+ program.name("wukong-cli").description("Wukong CLI - TypeScript implementation").version("0.2.0").option("--debug", "Enable debug mode (show HTTP requests)").hook("preAction", (thisCommand) => {
1984
2203
  const options = thisCommand.opts();
1985
2204
  if (options.debug === true) {
1986
2205
  setDebugMode(true, true);
@@ -1994,7 +2213,13 @@ program.addCommand(initCommand);
1994
2213
  if (process.argv.length === 2) {
1995
2214
  program.help();
1996
2215
  }
1997
- checkAndUpdate().catch(() => {
1998
- });
1999
2216
  program.parse();
2217
+ setImmediate(() => {
2218
+ try {
2219
+ const versionChecker = getVersionChecker();
2220
+ versionChecker.checkInBackground().catch(() => {
2221
+ });
2222
+ } catch {
2223
+ }
2224
+ });
2000
2225
  //# sourceMappingURL=cli.js.map