ccman 3.0.16 → 3.0.18

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 +159 -124
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ var init_package = __esm({
39
39
  "../core/package.json"() {
40
40
  package_default = {
41
41
  name: "@ccman/core",
42
- version: "3.0.16",
42
+ version: "3.0.18",
43
43
  type: "module",
44
44
  description: "Core business logic for ccman",
45
45
  main: "./dist/index.js",
@@ -3001,22 +3001,22 @@ var require_url_parse = __commonJS({
3001
3001
  }
3002
3002
  function resolve(relative, base) {
3003
3003
  if (relative === "") return base;
3004
- var path11 = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i2 = path11.length, last = path11[i2 - 1], unshift = false, up = 0;
3004
+ var path12 = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i2 = path12.length, last = path12[i2 - 1], unshift = false, up = 0;
3005
3005
  while (i2--) {
3006
- if (path11[i2] === ".") {
3007
- path11.splice(i2, 1);
3008
- } else if (path11[i2] === "..") {
3009
- path11.splice(i2, 1);
3006
+ if (path12[i2] === ".") {
3007
+ path12.splice(i2, 1);
3008
+ } else if (path12[i2] === "..") {
3009
+ path12.splice(i2, 1);
3010
3010
  up++;
3011
3011
  } else if (up) {
3012
3012
  if (i2 === 0) unshift = true;
3013
- path11.splice(i2, 1);
3013
+ path12.splice(i2, 1);
3014
3014
  up--;
3015
3015
  }
3016
3016
  }
3017
- if (unshift) path11.unshift("");
3018
- if (last === "." || last === "..") path11.push("");
3019
- return path11.join("/");
3017
+ if (unshift) path12.unshift("");
3018
+ if (last === "." || last === "..") path12.push("");
3019
+ return path12.join("/");
3020
3020
  }
3021
3021
  function Url(address, location, parser) {
3022
3022
  address = trimLeft(address);
@@ -3442,14 +3442,14 @@ var require_path_posix = __commonJS({
3442
3442
  posix.resolve = function() {
3443
3443
  var resolvedPath = "", resolvedAbsolute = false;
3444
3444
  for (var i2 = arguments.length - 1; i2 >= -1 && !resolvedAbsolute; i2--) {
3445
- var path11 = i2 >= 0 ? arguments[i2] : process.cwd();
3446
- if (!isString(path11)) {
3445
+ var path12 = i2 >= 0 ? arguments[i2] : process.cwd();
3446
+ if (!isString(path12)) {
3447
3447
  throw new TypeError("Arguments to path.resolve must be strings");
3448
- } else if (!path11) {
3448
+ } else if (!path12) {
3449
3449
  continue;
3450
3450
  }
3451
- resolvedPath = path11 + "/" + resolvedPath;
3452
- resolvedAbsolute = path11.charAt(0) === "/";
3451
+ resolvedPath = path12 + "/" + resolvedPath;
3452
+ resolvedAbsolute = path12.charAt(0) === "/";
3453
3453
  }
3454
3454
  resolvedPath = normalizeArray(
3455
3455
  resolvedPath.split("/"),
@@ -3457,36 +3457,36 @@ var require_path_posix = __commonJS({
3457
3457
  ).join("/");
3458
3458
  return (resolvedAbsolute ? "/" : "") + resolvedPath || ".";
3459
3459
  };
3460
- posix.normalize = function(path11) {
3461
- var isAbsolute = posix.isAbsolute(path11), trailingSlash = path11.substr(-1) === "/";
3462
- path11 = normalizeArray(path11.split("/"), !isAbsolute).join("/");
3463
- if (!path11 && !isAbsolute) {
3464
- path11 = ".";
3460
+ posix.normalize = function(path12) {
3461
+ var isAbsolute = posix.isAbsolute(path12), trailingSlash = path12.substr(-1) === "/";
3462
+ path12 = normalizeArray(path12.split("/"), !isAbsolute).join("/");
3463
+ if (!path12 && !isAbsolute) {
3464
+ path12 = ".";
3465
3465
  }
3466
- if (path11 && trailingSlash) {
3467
- path11 += "/";
3466
+ if (path12 && trailingSlash) {
3467
+ path12 += "/";
3468
3468
  }
3469
- return (isAbsolute ? "/" : "") + path11;
3469
+ return (isAbsolute ? "/" : "") + path12;
3470
3470
  };
3471
- posix.isAbsolute = function(path11) {
3472
- return path11.charAt(0) === "/";
3471
+ posix.isAbsolute = function(path12) {
3472
+ return path12.charAt(0) === "/";
3473
3473
  };
3474
3474
  posix.join = function() {
3475
- var path11 = "";
3475
+ var path12 = "";
3476
3476
  for (var i2 = 0; i2 < arguments.length; i2++) {
3477
3477
  var segment = arguments[i2];
3478
3478
  if (!isString(segment)) {
3479
3479
  throw new TypeError("Arguments to path.join must be strings");
3480
3480
  }
3481
3481
  if (segment) {
3482
- if (!path11) {
3483
- path11 += segment;
3482
+ if (!path12) {
3483
+ path12 += segment;
3484
3484
  } else {
3485
- path11 += "/" + segment;
3485
+ path12 += "/" + segment;
3486
3486
  }
3487
3487
  }
3488
3488
  }
3489
- return posix.normalize(path11);
3489
+ return posix.normalize(path12);
3490
3490
  };
3491
3491
  posix.relative = function(from, to) {
3492
3492
  from = posix.resolve(from).substr(1);
@@ -3520,11 +3520,11 @@ var require_path_posix = __commonJS({
3520
3520
  outputParts = outputParts.concat(toParts.slice(samePartsLength));
3521
3521
  return outputParts.join("/");
3522
3522
  };
3523
- posix._makeLong = function(path11) {
3524
- return path11;
3523
+ posix._makeLong = function(path12) {
3524
+ return path12;
3525
3525
  };
3526
- posix.dirname = function(path11) {
3527
- var result = posixSplitPath(path11), root = result[0], dir = result[1];
3526
+ posix.dirname = function(path12) {
3527
+ var result = posixSplitPath(path12), root = result[0], dir = result[1];
3528
3528
  if (!root && !dir) {
3529
3529
  return ".";
3530
3530
  }
@@ -3533,15 +3533,15 @@ var require_path_posix = __commonJS({
3533
3533
  }
3534
3534
  return root + dir;
3535
3535
  };
3536
- posix.basename = function(path11, ext2) {
3537
- var f3 = posixSplitPath(path11)[2];
3536
+ posix.basename = function(path12, ext2) {
3537
+ var f3 = posixSplitPath(path12)[2];
3538
3538
  if (ext2 && f3.substr(-1 * ext2.length) === ext2) {
3539
3539
  f3 = f3.substr(0, f3.length - ext2.length);
3540
3540
  }
3541
3541
  return f3;
3542
3542
  };
3543
- posix.extname = function(path11) {
3544
- return posixSplitPath(path11)[3];
3543
+ posix.extname = function(path12) {
3544
+ return posixSplitPath(path12)[3];
3545
3545
  };
3546
3546
  posix.format = function(pathObject) {
3547
3547
  if (!util.isObject(pathObject)) {
@@ -14939,10 +14939,10 @@ var require_nested_property = __commonJS({
14939
14939
  return false;
14940
14940
  }
14941
14941
  }
14942
- function traverse(object, path11) {
14942
+ function traverse(object, path12) {
14943
14943
  var callback = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : function() {
14944
14944
  };
14945
- var segments = path11.split(PATH_DELIMITER);
14945
+ var segments = path12.split(PATH_DELIMITER);
14946
14946
  var length = segments.length;
14947
14947
  var _loop = function _loop2(idx2) {
14948
14948
  var currentSegment = segments[idx2];
@@ -15184,11 +15184,11 @@ async function createDirectory(context, dirPath, options = {}) {
15184
15184
  const response = await request(requestOptions, context);
15185
15185
  handleResponseCode(context, response);
15186
15186
  }
15187
- function ensureCollectionPath(path11) {
15188
- if (!path11.endsWith("/")) {
15189
- return path11 + "/";
15187
+ function ensureCollectionPath(path12) {
15188
+ if (!path12.endsWith("/")) {
15189
+ return path12 + "/";
15190
15190
  }
15191
- return path11;
15191
+ return path12;
15192
15192
  }
15193
15193
  async function createDirectoryRecursively(context, dirPath, options = {}) {
15194
15194
  const paths = getAllDirectories(normalisePath(dirPath));
@@ -15563,7 +15563,7 @@ var init_xml = __esm({
15563
15563
  });
15564
15564
 
15565
15565
  // ../../node_modules/.pnpm/webdav@5.8.0/node_modules/webdav/dist/node/operations/lock.js
15566
- async function lock(context, path11, options = {}) {
15566
+ async function lock(context, path12, options = {}) {
15567
15567
  const { refreshToken, timeout = DEFAULT_TIMEOUT } = options;
15568
15568
  const headers = {
15569
15569
  Accept: "text/plain,application/xml",
@@ -15573,7 +15573,7 @@ async function lock(context, path11, options = {}) {
15573
15573
  headers.If = refreshToken;
15574
15574
  }
15575
15575
  const requestOptions = prepareRequestOptions({
15576
- url: joinURL(context.remoteURL, encodePath(path11)),
15576
+ url: joinURL(context.remoteURL, encodePath(path12)),
15577
15577
  method: "LOCK",
15578
15578
  headers,
15579
15579
  data: generateLockXML(context.contactHref)
@@ -15593,9 +15593,9 @@ async function lock(context, path11, options = {}) {
15593
15593
  serverTimeout
15594
15594
  };
15595
15595
  }
15596
- async function unlock(context, path11, token, options = {}) {
15596
+ async function unlock(context, path12, token, options = {}) {
15597
15597
  const requestOptions = prepareRequestOptions({
15598
- url: joinURL(context.remoteURL, encodePath(path11)),
15598
+ url: joinURL(context.remoteURL, encodePath(path12)),
15599
15599
  method: "UNLOCK",
15600
15600
  headers: {
15601
15601
  "Lock-Token": token
@@ -15645,9 +15645,9 @@ var init_quota = __esm({
15645
15645
 
15646
15646
  // ../../node_modules/.pnpm/webdav@5.8.0/node_modules/webdav/dist/node/operations/getQuota.js
15647
15647
  async function getQuota(context, options = {}) {
15648
- const path11 = options.path || "/";
15648
+ const path12 = options.path || "/";
15649
15649
  const requestOptions = prepareRequestOptions({
15650
- url: joinURL(context.remoteURL, path11),
15650
+ url: joinURL(context.remoteURL, path12),
15651
15651
  method: "PROPFIND",
15652
15652
  headers: {
15653
15653
  Accept: "text/plain,application/xml",
@@ -15987,29 +15987,29 @@ function createClient(remoteURL, options = {}) {
15987
15987
  setupAuth(context, username, password, token, ha1);
15988
15988
  return {
15989
15989
  copyFile: (filename, destination, options2) => copyFile(context, filename, destination, options2),
15990
- createDirectory: (path11, options2) => createDirectory(context, path11, options2),
15990
+ createDirectory: (path12, options2) => createDirectory(context, path12, options2),
15991
15991
  createReadStream: (filename, options2) => createReadStream2(context, filename, options2),
15992
15992
  createWriteStream: (filename, options2, callback) => createWriteStream(context, filename, options2, callback),
15993
- customRequest: (path11, requestOptions) => customRequest(context, path11, requestOptions),
15993
+ customRequest: (path12, requestOptions) => customRequest(context, path12, requestOptions),
15994
15994
  deleteFile: (filename, options2) => deleteFile(context, filename, options2),
15995
- exists: (path11, options2) => exists(context, path11, options2),
15996
- getDirectoryContents: (path11, options2) => getDirectoryContents(context, path11, options2),
15995
+ exists: (path12, options2) => exists(context, path12, options2),
15996
+ getDirectoryContents: (path12, options2) => getDirectoryContents(context, path12, options2),
15997
15997
  getFileContents: (filename, options2) => getFileContents(context, filename, options2),
15998
15998
  getFileDownloadLink: (filename) => getFileDownloadLink(context, filename),
15999
15999
  getFileUploadLink: (filename) => getFileUploadLink(context, filename),
16000
16000
  getHeaders: () => Object.assign({}, context.headers),
16001
16001
  getQuota: (options2) => getQuota(context, options2),
16002
- lock: (path11, options2) => lock(context, path11, options2),
16002
+ lock: (path12, options2) => lock(context, path12, options2),
16003
16003
  moveFile: (filename, destinationFilename, options2) => moveFile(context, filename, destinationFilename, options2),
16004
16004
  putFileContents: (filename, data, options2) => putFileContents(context, filename, data, options2),
16005
16005
  partialUpdateFileContents: (filePath, start, end, data, options2) => partialUpdateFileContents(context, filePath, start, end, data, options2),
16006
- getDAVCompliance: (path11) => getDAVCompliance(context, path11),
16007
- search: (path11, options2) => getSearch2(context, path11, options2),
16006
+ getDAVCompliance: (path12) => getDAVCompliance(context, path12),
16007
+ search: (path12, options2) => getSearch2(context, path12, options2),
16008
16008
  setHeaders: (headers2) => {
16009
16009
  context.headers = Object.assign({}, headers2);
16010
16010
  },
16011
- stat: (path11, options2) => getStat(context, path11, options2),
16012
- unlock: (path11, token2, options2) => unlock(context, path11, token2, options2)
16011
+ stat: (path12, options2) => getStat(context, path12, options2),
16012
+ unlock: (path12, token2, options2) => unlock(context, path12, token2, options2)
16013
16013
  };
16014
16014
  }
16015
16015
  var DEFAULT_CONTACT_HREF;
@@ -16083,32 +16083,10 @@ function createWebDAVClient(config) {
16083
16083
  async function testWebDAVConnection(config) {
16084
16084
  try {
16085
16085
  const client = createWebDAVClient(config);
16086
- try {
16087
- await client.exists("/");
16088
- return true;
16089
- } catch (error1) {
16090
- console.log("\u65B9\u6CD51\u5931\u8D25\uFF0C\u5C1D\u8BD5\u65B9\u6CD52:", error1);
16091
- try {
16092
- await client.getDirectoryContents("/");
16093
- return true;
16094
- } catch (error2) {
16095
- console.log("\u65B9\u6CD52\u5931\u8D25\uFF0C\u5C1D\u8BD5\u65B9\u6CD53:", error2);
16096
- try {
16097
- const testDir = "/.ccman-test";
16098
- await client.createDirectory(testDir);
16099
- try {
16100
- await client.deleteFile(testDir);
16101
- } catch (e2) {
16102
- }
16103
- return true;
16104
- } catch (error3) {
16105
- console.error("\u6240\u6709\u6D4B\u8BD5\u65B9\u6CD5\u90FD\u5931\u8D25");
16106
- throw error3;
16107
- }
16108
- }
16109
- }
16086
+ await client.exists("/");
16087
+ return true;
16110
16088
  } catch (error) {
16111
- console.error("WebDAV \u8FDE\u63A5\u5931\u8D25:", error);
16089
+ console.error("WebDAV \u8FDE\u63A5\u5931\u8D25:", error.message);
16112
16090
  return false;
16113
16091
  }
16114
16092
  }
@@ -16134,20 +16112,45 @@ async function ensureDirectory(config, dirPath) {
16134
16112
  return false;
16135
16113
  }
16136
16114
  }
16115
+ function isPathNotFoundError(error) {
16116
+ const msg = error.message.toLowerCase();
16117
+ return msg.includes("404") || msg.includes("409") || msg.includes("not found") || msg.includes("conflict");
16118
+ }
16137
16119
  async function uploadToWebDAV(config, filename, data) {
16138
16120
  const client = createWebDAVClient(config);
16139
16121
  const remoteDir = normalizePath(config.remoteDir || "/");
16140
16122
  const fullPath = joinPath(remoteDir, filename);
16141
16123
  try {
16142
- const dirPath = fullPath.substring(0, fullPath.lastIndexOf("/"));
16143
- if (dirPath && dirPath !== "/") {
16144
- await ensureDirectory(config, dirPath);
16124
+ await client.putFileContents(fullPath, data, { overwrite: true });
16125
+ } catch (firstError) {
16126
+ if (isPathNotFoundError(firstError)) {
16127
+ const dirPath = fullPath.substring(0, fullPath.lastIndexOf("/"));
16128
+ if (dirPath && dirPath !== "/") {
16129
+ await ensureDirectory(config, dirPath);
16130
+ await client.putFileContents(fullPath, data, { overwrite: true });
16131
+ } else {
16132
+ throw firstError;
16133
+ }
16134
+ } else {
16135
+ throw firstError;
16145
16136
  }
16146
- await client.putFileContents(fullPath, data, {
16147
- overwrite: true
16148
- });
16149
- } catch (error) {
16150
- throw new Error(`\u4E0A\u4F20\u5931\u8D25: ${error.message}`);
16137
+ }
16138
+ try {
16139
+ const exists2 = await client.exists(fullPath);
16140
+ if (!exists2) {
16141
+ throw new Error(`\u6587\u4EF6\u4E0A\u4F20\u540E\u672A\u5728\u670D\u52A1\u5668\u4E0A\u627E\u5230: ${fullPath}`);
16142
+ }
16143
+ } catch (verifyError) {
16144
+ const errorMsg = verifyError.message;
16145
+ if (errorMsg.includes("multistatus") || errorMsg.includes("Invalid response")) {
16146
+ throw new Error(`WebDAV \u914D\u7F6E\u9519\u8BEF\uFF0C\u8BF7\u68C0\u67E5\uFF1A
16147
+ 1. URL \u662F\u5426\u4E3A WebDAV \u7AEF\u70B9\uFF08\u4E0D\u662F\u7F51\u9875\u5730\u5740\uFF09
16148
+ 2. \u7528\u6237\u540D\u548C\u5BC6\u7801\u662F\u5426\u6B63\u786E
16149
+ 3. \u8BA4\u8BC1\u7C7B\u578B\u662F\u5426\u5339\u914D
16150
+
16151
+ \u8BE6\u7EC6\uFF1A${errorMsg}`);
16152
+ }
16153
+ throw verifyError;
16151
16154
  }
16152
16155
  }
16153
16156
  async function downloadFromWebDAV(config, filename) {
@@ -16179,20 +16182,52 @@ var init_webdav_client = __esm({
16179
16182
  });
16180
16183
 
16181
16184
  // ../core/dist/sync/merge.js
16182
- function backupConfig(configPath) {
16185
+ function backupConfig(configPath, keepCount = 3) {
16183
16186
  if (!import_fs.default.existsSync(configPath)) {
16184
16187
  throw new Error(`\u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728: ${configPath}`);
16185
16188
  }
16186
16189
  const timestamp = Date.now();
16187
16190
  const backupPath = `${configPath}.backup.${timestamp}`;
16188
16191
  import_fs.default.copyFileSync(configPath, backupPath);
16192
+ cleanupOldBackups(configPath, keepCount);
16189
16193
  return backupPath;
16190
16194
  }
16191
- var import_fs;
16195
+ function cleanupOldBackups(configPath, keepCount) {
16196
+ const dir = import_path17.default.dirname(configPath);
16197
+ const basename2 = import_path17.default.basename(configPath);
16198
+ const backupPrefix = `${basename2}.backup.`;
16199
+ try {
16200
+ const files = import_fs.default.readdirSync(dir);
16201
+ const backups = files.filter((f3) => f3.startsWith(backupPrefix)).map((f3) => {
16202
+ const timestampStr = f3.substring(backupPrefix.length);
16203
+ const timestamp = parseInt(timestampStr, 10);
16204
+ if (isNaN(timestamp)) {
16205
+ return null;
16206
+ }
16207
+ return {
16208
+ name: f3,
16209
+ path: import_path17.default.join(dir, f3),
16210
+ timestamp
16211
+ };
16212
+ }).filter((backup) => backup !== null).sort((a, b) => b.timestamp - a.timestamp);
16213
+ const toDelete = backups.slice(keepCount);
16214
+ for (const backup of toDelete) {
16215
+ try {
16216
+ import_fs.default.unlinkSync(backup.path);
16217
+ } catch (error) {
16218
+ console.warn(`\u65E0\u6CD5\u5220\u9664\u65E7\u5907\u4EFD\u6587\u4EF6 ${backup.name}: ${error.message}`);
16219
+ }
16220
+ }
16221
+ } catch (error) {
16222
+ console.warn(`\u6E05\u7406\u65E7\u5907\u4EFD\u65F6\u51FA\u9519: ${error.message}`);
16223
+ }
16224
+ }
16225
+ var import_fs, import_path17;
16192
16226
  var init_merge2 = __esm({
16193
16227
  "../core/dist/sync/merge.js"() {
16194
16228
  "use strict";
16195
16229
  import_fs = __toESM(require("fs"), 1);
16230
+ import_path17 = __toESM(require("path"), 1);
16196
16231
  }
16197
16232
  });
16198
16233
 
@@ -16369,8 +16404,8 @@ var init_merge_advanced = __esm({
16369
16404
  // ../core/dist/sync/sync-v2.js
16370
16405
  async function uploadToCloud(config, password) {
16371
16406
  const ccmanDir2 = getCcmanDir();
16372
- const codexConfigPath = import_path17.default.join(ccmanDir2, "codex.json");
16373
- const claudeConfigPath = import_path17.default.join(ccmanDir2, "claude.json");
16407
+ const codexConfigPath = import_path18.default.join(ccmanDir2, "codex.json");
16408
+ const claudeConfigPath = import_path18.default.join(ccmanDir2, "claude.json");
16374
16409
  const codexConfig = readJSON(codexConfigPath);
16375
16410
  const claudeConfig = readJSON(claudeConfigPath);
16376
16411
  const encryptedCodexProviders = encryptProviders(codexConfig.providers, password);
@@ -16413,8 +16448,8 @@ async function downloadFromCloud(config, password) {
16413
16448
  }
16414
16449
  const backupPaths = [];
16415
16450
  const ccmanDir2 = getCcmanDir();
16416
- const codexConfigPath = import_path17.default.join(ccmanDir2, "codex.json");
16417
- const claudeConfigPath = import_path17.default.join(ccmanDir2, "claude.json");
16451
+ const codexConfigPath = import_path18.default.join(ccmanDir2, "codex.json");
16452
+ const claudeConfigPath = import_path18.default.join(ccmanDir2, "claude.json");
16418
16453
  try {
16419
16454
  if (import_fs2.default.existsSync(codexConfigPath)) {
16420
16455
  backupPaths.push(backupConfig(codexConfigPath));
@@ -16486,8 +16521,8 @@ async function mergeSync(config, password) {
16486
16521
  throw new Error("\u89E3\u5BC6\u5931\u8D25\uFF1A\u5BC6\u7801\u9519\u8BEF\u6216\u6570\u636E\u635F\u574F");
16487
16522
  }
16488
16523
  const ccmanDir2 = getCcmanDir();
16489
- const codexConfigPath = import_path17.default.join(ccmanDir2, "codex.json");
16490
- const claudeConfigPath = import_path17.default.join(ccmanDir2, "claude.json");
16524
+ const codexConfigPath = import_path18.default.join(ccmanDir2, "codex.json");
16525
+ const claudeConfigPath = import_path18.default.join(ccmanDir2, "claude.json");
16491
16526
  const localCodexConfig = readJSON(codexConfigPath);
16492
16527
  const localClaudeConfig = readJSON(claudeConfigPath);
16493
16528
  const codexMergeResult = mergeProviders(localCodexConfig.providers, remoteCodexProviders);
@@ -16553,12 +16588,12 @@ async function mergeSync(config, password) {
16553
16588
  throw new Error(`\u5408\u5E76\u914D\u7F6E\u5931\u8D25\uFF0C\u5DF2\u6062\u590D\u5907\u4EFD: ${error.message}`);
16554
16589
  }
16555
16590
  }
16556
- var import_fs2, import_path17, CODEX_REMOTE_PATH, CLAUDE_REMOTE_PATH;
16591
+ var import_fs2, import_path18, CODEX_REMOTE_PATH, CLAUDE_REMOTE_PATH;
16557
16592
  var init_sync_v2 = __esm({
16558
16593
  "../core/dist/sync/sync-v2.js"() {
16559
16594
  "use strict";
16560
16595
  import_fs2 = __toESM(require("fs"), 1);
16561
- import_path17 = __toESM(require("path"), 1);
16596
+ import_path18 = __toESM(require("path"), 1);
16562
16597
  init_webdav_client();
16563
16598
  init_crypto2();
16564
16599
  init_merge_advanced();
@@ -16573,8 +16608,8 @@ var init_sync_v2 = __esm({
16573
16608
  // ../core/dist/export.js
16574
16609
  function validateExport() {
16575
16610
  const ccmanDir2 = getCcmanDir();
16576
- const codexPath = path8.join(ccmanDir2, CODEX_CONFIG_FILE);
16577
- const claudePath = path8.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16611
+ const codexPath = path9.join(ccmanDir2, CODEX_CONFIG_FILE);
16612
+ const claudePath = path9.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16578
16613
  const missingFiles = [];
16579
16614
  if (!fileExists(codexPath)) {
16580
16615
  missingFiles.push(CODEX_CONFIG_FILE);
@@ -16607,8 +16642,8 @@ function validateImportDir(sourceDir) {
16607
16642
  foundFiles: []
16608
16643
  };
16609
16644
  }
16610
- const codexPath = path8.join(sourceDir, CODEX_CONFIG_FILE);
16611
- const claudePath = path8.join(sourceDir, CLAUDE_CONFIG_FILE);
16645
+ const codexPath = path9.join(sourceDir, CODEX_CONFIG_FILE);
16646
+ const claudePath = path9.join(sourceDir, CLAUDE_CONFIG_FILE);
16612
16647
  const foundFiles = [];
16613
16648
  if (fileExists(codexPath)) {
16614
16649
  foundFiles.push(CODEX_CONFIG_FILE);
@@ -16636,14 +16671,14 @@ function exportConfig(targetDir) {
16636
16671
  ensureDir(targetDir);
16637
16672
  const ccmanDir2 = getCcmanDir();
16638
16673
  const exportedFiles = [];
16639
- const codexSrc = path8.join(ccmanDir2, CODEX_CONFIG_FILE);
16640
- const codexDst = path8.join(targetDir, CODEX_CONFIG_FILE);
16674
+ const codexSrc = path9.join(ccmanDir2, CODEX_CONFIG_FILE);
16675
+ const codexDst = path9.join(targetDir, CODEX_CONFIG_FILE);
16641
16676
  if (fileExists(codexSrc)) {
16642
16677
  fs8.copyFileSync(codexSrc, codexDst);
16643
16678
  exportedFiles.push(CODEX_CONFIG_FILE);
16644
16679
  }
16645
- const claudeSrc = path8.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16646
- const claudeDst = path8.join(targetDir, CLAUDE_CONFIG_FILE);
16680
+ const claudeSrc = path9.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16681
+ const claudeDst = path9.join(targetDir, CLAUDE_CONFIG_FILE);
16647
16682
  if (fileExists(claudeSrc)) {
16648
16683
  fs8.copyFileSync(claudeSrc, claudeDst);
16649
16684
  exportedFiles.push(CLAUDE_CONFIG_FILE);
@@ -16665,22 +16700,22 @@ function importConfig(sourceDir) {
16665
16700
  ensureDir(ccmanDir2);
16666
16701
  try {
16667
16702
  if (validation.foundFiles.includes(CODEX_CONFIG_FILE)) {
16668
- const codexDst = path8.join(ccmanDir2, CODEX_CONFIG_FILE);
16703
+ const codexDst = path9.join(ccmanDir2, CODEX_CONFIG_FILE);
16669
16704
  if (fileExists(codexDst)) {
16670
16705
  const backupPath = backupConfig(codexDst);
16671
16706
  backupPaths.push(backupPath);
16672
16707
  }
16673
- const codexSrc = path8.join(sourceDir, CODEX_CONFIG_FILE);
16708
+ const codexSrc = path9.join(sourceDir, CODEX_CONFIG_FILE);
16674
16709
  fs8.copyFileSync(codexSrc, codexDst);
16675
16710
  importedFiles.push(CODEX_CONFIG_FILE);
16676
16711
  }
16677
16712
  if (validation.foundFiles.includes(CLAUDE_CONFIG_FILE)) {
16678
- const claudeDst = path8.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16713
+ const claudeDst = path9.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16679
16714
  if (fileExists(claudeDst)) {
16680
16715
  const backupPath = backupConfig(claudeDst);
16681
16716
  backupPaths.push(backupPath);
16682
16717
  }
16683
- const claudeSrc = path8.join(sourceDir, CLAUDE_CONFIG_FILE);
16718
+ const claudeSrc = path9.join(sourceDir, CLAUDE_CONFIG_FILE);
16684
16719
  fs8.copyFileSync(claudeSrc, claudeDst);
16685
16720
  importedFiles.push(CLAUDE_CONFIG_FILE);
16686
16721
  }
@@ -16699,12 +16734,12 @@ function importConfig(sourceDir) {
16699
16734
  throw new Error(`\u5BFC\u5165\u5931\u8D25\uFF0C\u5DF2\u6062\u590D\u5907\u4EFD: ${error.message}`);
16700
16735
  }
16701
16736
  }
16702
- var fs8, path8, CODEX_CONFIG_FILE, CLAUDE_CONFIG_FILE;
16737
+ var fs8, path9, CODEX_CONFIG_FILE, CLAUDE_CONFIG_FILE;
16703
16738
  var init_export = __esm({
16704
16739
  "../core/dist/export.js"() {
16705
16740
  "use strict";
16706
16741
  fs8 = __toESM(require("fs"), 1);
16707
- path8 = __toESM(require("path"), 1);
16742
+ path9 = __toESM(require("path"), 1);
16708
16743
  init_paths();
16709
16744
  init_file();
16710
16745
  init_merge2();
@@ -17182,8 +17217,8 @@ function downloadCommand(program2) {
17182
17217
  console.log();
17183
17218
  if (backupPaths.length > 0) {
17184
17219
  console.log(import_chalk6.default.gray("\u672C\u5730\u5907\u4EFD:"));
17185
- backupPaths.forEach((path11) => {
17186
- console.log(import_chalk6.default.gray(` ${path11}`));
17220
+ backupPaths.forEach((path12) => {
17221
+ console.log(import_chalk6.default.gray(` ${path12}`));
17187
17222
  });
17188
17223
  console.log();
17189
17224
  }
@@ -17247,8 +17282,8 @@ function mergeCommand(program2) {
17247
17282
  console.log();
17248
17283
  if (result.backupPaths.length > 0) {
17249
17284
  console.log(import_chalk7.default.gray("\u5907\u4EFD:"));
17250
- result.backupPaths.forEach((path11) => {
17251
- console.log(import_chalk7.default.gray(` ${path11}`));
17285
+ result.backupPaths.forEach((path12) => {
17286
+ console.log(import_chalk7.default.gray(` ${path12}`));
17252
17287
  });
17253
17288
  console.log();
17254
17289
  }
@@ -18890,7 +18925,7 @@ init_sync2();
18890
18925
 
18891
18926
  // src/commands/export.ts
18892
18927
  var import_chalk25 = __toESM(require("chalk"));
18893
- var import_path18 = __toESM(require("path"));
18928
+ var import_path19 = __toESM(require("path"));
18894
18929
  init_dist4();
18895
18930
  function exportCommand(program2) {
18896
18931
  program2.command("export <\u76EE\u6807\u76EE\u5F55>").description("\u5BFC\u51FA\u914D\u7F6E\u5230\u672C\u5730\u76EE\u5F55\uFF08\u5305\u542B API Key\uFF09").action(async (targetDir) => {
@@ -18902,7 +18937,7 @@ function exportCommand(program2) {
18902
18937
  `));
18903
18938
  process.exit(1);
18904
18939
  }
18905
- const resolvedPath = targetDir.startsWith("~") ? import_path18.default.join(process.env.HOME || "", targetDir.slice(1)) : import_path18.default.resolve(targetDir);
18940
+ const resolvedPath = targetDir.startsWith("~") ? import_path19.default.join(process.env.HOME || "", targetDir.slice(1)) : import_path19.default.resolve(targetDir);
18906
18941
  console.log("\u5BFC\u51FA\u6587\u4EF6:");
18907
18942
  console.log(` ${import_chalk25.default.cyan("codex.json")} - Codex \u914D\u7F6E`);
18908
18943
  console.log(` ${import_chalk25.default.cyan("claude.json")} - Claude \u914D\u7F6E`);
@@ -18933,12 +18968,12 @@ function exportCommand(program2) {
18933
18968
  // src/commands/import.ts
18934
18969
  var import_chalk26 = __toESM(require("chalk"));
18935
18970
  var import_inquirer17 = __toESM(require("inquirer"));
18936
- var import_path19 = __toESM(require("path"));
18971
+ var import_path20 = __toESM(require("path"));
18937
18972
  init_dist4();
18938
18973
  function importCommand(program2) {
18939
18974
  program2.command("import <\u6E90\u76EE\u5F55>").description("\u4ECE\u672C\u5730\u76EE\u5F55\u5BFC\u5165\u914D\u7F6E\uFF08\u4F1A\u8986\u76D6\u5F53\u524D\u914D\u7F6E\uFF09").action(async (sourceDir) => {
18940
18975
  try {
18941
- const resolvedPath = sourceDir.startsWith("~") ? import_path19.default.join(process.env.HOME || "", sourceDir.slice(1)) : import_path19.default.resolve(sourceDir);
18976
+ const resolvedPath = sourceDir.startsWith("~") ? import_path20.default.join(process.env.HOME || "", sourceDir.slice(1)) : import_path20.default.resolve(sourceDir);
18942
18977
  console.log(import_chalk26.default.bold("\n\u{1F4E5} \u5BFC\u5165\u914D\u7F6E\n"));
18943
18978
  const validation = validateImportDir(resolvedPath);
18944
18979
  if (!validation.valid) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccman",
3
- "version": "3.0.16",
3
+ "version": "3.0.18",
4
4
  "description": "Manage Codex and Claude Code API service provider configurations",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {