ccman 3.0.17 → 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.
- package/dist/index.js +123 -91
- 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.
|
|
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
|
|
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 (
|
|
3007
|
-
|
|
3008
|
-
} else if (
|
|
3009
|
-
|
|
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
|
-
|
|
3013
|
+
path12.splice(i2, 1);
|
|
3014
3014
|
up--;
|
|
3015
3015
|
}
|
|
3016
3016
|
}
|
|
3017
|
-
if (unshift)
|
|
3018
|
-
if (last === "." || last === "..")
|
|
3019
|
-
return
|
|
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
|
|
3446
|
-
if (!isString(
|
|
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 (!
|
|
3448
|
+
} else if (!path12) {
|
|
3449
3449
|
continue;
|
|
3450
3450
|
}
|
|
3451
|
-
resolvedPath =
|
|
3452
|
-
resolvedAbsolute =
|
|
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(
|
|
3461
|
-
var isAbsolute = posix.isAbsolute(
|
|
3462
|
-
|
|
3463
|
-
if (!
|
|
3464
|
-
|
|
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 (
|
|
3467
|
-
|
|
3466
|
+
if (path12 && trailingSlash) {
|
|
3467
|
+
path12 += "/";
|
|
3468
3468
|
}
|
|
3469
|
-
return (isAbsolute ? "/" : "") +
|
|
3469
|
+
return (isAbsolute ? "/" : "") + path12;
|
|
3470
3470
|
};
|
|
3471
|
-
posix.isAbsolute = function(
|
|
3472
|
-
return
|
|
3471
|
+
posix.isAbsolute = function(path12) {
|
|
3472
|
+
return path12.charAt(0) === "/";
|
|
3473
3473
|
};
|
|
3474
3474
|
posix.join = function() {
|
|
3475
|
-
var
|
|
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 (!
|
|
3483
|
-
|
|
3482
|
+
if (!path12) {
|
|
3483
|
+
path12 += segment;
|
|
3484
3484
|
} else {
|
|
3485
|
-
|
|
3485
|
+
path12 += "/" + segment;
|
|
3486
3486
|
}
|
|
3487
3487
|
}
|
|
3488
3488
|
}
|
|
3489
|
-
return posix.normalize(
|
|
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(
|
|
3524
|
-
return
|
|
3523
|
+
posix._makeLong = function(path12) {
|
|
3524
|
+
return path12;
|
|
3525
3525
|
};
|
|
3526
|
-
posix.dirname = function(
|
|
3527
|
-
var result = posixSplitPath(
|
|
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(
|
|
3537
|
-
var f3 = posixSplitPath(
|
|
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(
|
|
3544
|
-
return posixSplitPath(
|
|
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,
|
|
14942
|
+
function traverse(object, path12) {
|
|
14943
14943
|
var callback = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : function() {
|
|
14944
14944
|
};
|
|
14945
|
-
var segments =
|
|
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(
|
|
15188
|
-
if (!
|
|
15189
|
-
return
|
|
15187
|
+
function ensureCollectionPath(path12) {
|
|
15188
|
+
if (!path12.endsWith("/")) {
|
|
15189
|
+
return path12 + "/";
|
|
15190
15190
|
}
|
|
15191
|
-
return
|
|
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,
|
|
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(
|
|
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,
|
|
15596
|
+
async function unlock(context, path12, token, options = {}) {
|
|
15597
15597
|
const requestOptions = prepareRequestOptions({
|
|
15598
|
-
url: joinURL(context.remoteURL, encodePath(
|
|
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
|
|
15648
|
+
const path12 = options.path || "/";
|
|
15649
15649
|
const requestOptions = prepareRequestOptions({
|
|
15650
|
-
url: joinURL(context.remoteURL,
|
|
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: (
|
|
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: (
|
|
15993
|
+
customRequest: (path12, requestOptions) => customRequest(context, path12, requestOptions),
|
|
15994
15994
|
deleteFile: (filename, options2) => deleteFile(context, filename, options2),
|
|
15995
|
-
exists: (
|
|
15996
|
-
getDirectoryContents: (
|
|
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: (
|
|
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: (
|
|
16007
|
-
search: (
|
|
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: (
|
|
16012
|
-
unlock: (
|
|
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;
|
|
@@ -16182,20 +16182,52 @@ var init_webdav_client = __esm({
|
|
|
16182
16182
|
});
|
|
16183
16183
|
|
|
16184
16184
|
// ../core/dist/sync/merge.js
|
|
16185
|
-
function backupConfig(configPath) {
|
|
16185
|
+
function backupConfig(configPath, keepCount = 3) {
|
|
16186
16186
|
if (!import_fs.default.existsSync(configPath)) {
|
|
16187
16187
|
throw new Error(`\u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728: ${configPath}`);
|
|
16188
16188
|
}
|
|
16189
16189
|
const timestamp = Date.now();
|
|
16190
16190
|
const backupPath = `${configPath}.backup.${timestamp}`;
|
|
16191
16191
|
import_fs.default.copyFileSync(configPath, backupPath);
|
|
16192
|
+
cleanupOldBackups(configPath, keepCount);
|
|
16192
16193
|
return backupPath;
|
|
16193
16194
|
}
|
|
16194
|
-
|
|
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;
|
|
16195
16226
|
var init_merge2 = __esm({
|
|
16196
16227
|
"../core/dist/sync/merge.js"() {
|
|
16197
16228
|
"use strict";
|
|
16198
16229
|
import_fs = __toESM(require("fs"), 1);
|
|
16230
|
+
import_path17 = __toESM(require("path"), 1);
|
|
16199
16231
|
}
|
|
16200
16232
|
});
|
|
16201
16233
|
|
|
@@ -16372,8 +16404,8 @@ var init_merge_advanced = __esm({
|
|
|
16372
16404
|
// ../core/dist/sync/sync-v2.js
|
|
16373
16405
|
async function uploadToCloud(config, password) {
|
|
16374
16406
|
const ccmanDir2 = getCcmanDir();
|
|
16375
|
-
const codexConfigPath =
|
|
16376
|
-
const claudeConfigPath =
|
|
16407
|
+
const codexConfigPath = import_path18.default.join(ccmanDir2, "codex.json");
|
|
16408
|
+
const claudeConfigPath = import_path18.default.join(ccmanDir2, "claude.json");
|
|
16377
16409
|
const codexConfig = readJSON(codexConfigPath);
|
|
16378
16410
|
const claudeConfig = readJSON(claudeConfigPath);
|
|
16379
16411
|
const encryptedCodexProviders = encryptProviders(codexConfig.providers, password);
|
|
@@ -16416,8 +16448,8 @@ async function downloadFromCloud(config, password) {
|
|
|
16416
16448
|
}
|
|
16417
16449
|
const backupPaths = [];
|
|
16418
16450
|
const ccmanDir2 = getCcmanDir();
|
|
16419
|
-
const codexConfigPath =
|
|
16420
|
-
const claudeConfigPath =
|
|
16451
|
+
const codexConfigPath = import_path18.default.join(ccmanDir2, "codex.json");
|
|
16452
|
+
const claudeConfigPath = import_path18.default.join(ccmanDir2, "claude.json");
|
|
16421
16453
|
try {
|
|
16422
16454
|
if (import_fs2.default.existsSync(codexConfigPath)) {
|
|
16423
16455
|
backupPaths.push(backupConfig(codexConfigPath));
|
|
@@ -16489,8 +16521,8 @@ async function mergeSync(config, password) {
|
|
|
16489
16521
|
throw new Error("\u89E3\u5BC6\u5931\u8D25\uFF1A\u5BC6\u7801\u9519\u8BEF\u6216\u6570\u636E\u635F\u574F");
|
|
16490
16522
|
}
|
|
16491
16523
|
const ccmanDir2 = getCcmanDir();
|
|
16492
|
-
const codexConfigPath =
|
|
16493
|
-
const claudeConfigPath =
|
|
16524
|
+
const codexConfigPath = import_path18.default.join(ccmanDir2, "codex.json");
|
|
16525
|
+
const claudeConfigPath = import_path18.default.join(ccmanDir2, "claude.json");
|
|
16494
16526
|
const localCodexConfig = readJSON(codexConfigPath);
|
|
16495
16527
|
const localClaudeConfig = readJSON(claudeConfigPath);
|
|
16496
16528
|
const codexMergeResult = mergeProviders(localCodexConfig.providers, remoteCodexProviders);
|
|
@@ -16556,12 +16588,12 @@ async function mergeSync(config, password) {
|
|
|
16556
16588
|
throw new Error(`\u5408\u5E76\u914D\u7F6E\u5931\u8D25\uFF0C\u5DF2\u6062\u590D\u5907\u4EFD: ${error.message}`);
|
|
16557
16589
|
}
|
|
16558
16590
|
}
|
|
16559
|
-
var import_fs2,
|
|
16591
|
+
var import_fs2, import_path18, CODEX_REMOTE_PATH, CLAUDE_REMOTE_PATH;
|
|
16560
16592
|
var init_sync_v2 = __esm({
|
|
16561
16593
|
"../core/dist/sync/sync-v2.js"() {
|
|
16562
16594
|
"use strict";
|
|
16563
16595
|
import_fs2 = __toESM(require("fs"), 1);
|
|
16564
|
-
|
|
16596
|
+
import_path18 = __toESM(require("path"), 1);
|
|
16565
16597
|
init_webdav_client();
|
|
16566
16598
|
init_crypto2();
|
|
16567
16599
|
init_merge_advanced();
|
|
@@ -16576,8 +16608,8 @@ var init_sync_v2 = __esm({
|
|
|
16576
16608
|
// ../core/dist/export.js
|
|
16577
16609
|
function validateExport() {
|
|
16578
16610
|
const ccmanDir2 = getCcmanDir();
|
|
16579
|
-
const codexPath =
|
|
16580
|
-
const claudePath =
|
|
16611
|
+
const codexPath = path9.join(ccmanDir2, CODEX_CONFIG_FILE);
|
|
16612
|
+
const claudePath = path9.join(ccmanDir2, CLAUDE_CONFIG_FILE);
|
|
16581
16613
|
const missingFiles = [];
|
|
16582
16614
|
if (!fileExists(codexPath)) {
|
|
16583
16615
|
missingFiles.push(CODEX_CONFIG_FILE);
|
|
@@ -16610,8 +16642,8 @@ function validateImportDir(sourceDir) {
|
|
|
16610
16642
|
foundFiles: []
|
|
16611
16643
|
};
|
|
16612
16644
|
}
|
|
16613
|
-
const codexPath =
|
|
16614
|
-
const claudePath =
|
|
16645
|
+
const codexPath = path9.join(sourceDir, CODEX_CONFIG_FILE);
|
|
16646
|
+
const claudePath = path9.join(sourceDir, CLAUDE_CONFIG_FILE);
|
|
16615
16647
|
const foundFiles = [];
|
|
16616
16648
|
if (fileExists(codexPath)) {
|
|
16617
16649
|
foundFiles.push(CODEX_CONFIG_FILE);
|
|
@@ -16639,14 +16671,14 @@ function exportConfig(targetDir) {
|
|
|
16639
16671
|
ensureDir(targetDir);
|
|
16640
16672
|
const ccmanDir2 = getCcmanDir();
|
|
16641
16673
|
const exportedFiles = [];
|
|
16642
|
-
const codexSrc =
|
|
16643
|
-
const codexDst =
|
|
16674
|
+
const codexSrc = path9.join(ccmanDir2, CODEX_CONFIG_FILE);
|
|
16675
|
+
const codexDst = path9.join(targetDir, CODEX_CONFIG_FILE);
|
|
16644
16676
|
if (fileExists(codexSrc)) {
|
|
16645
16677
|
fs8.copyFileSync(codexSrc, codexDst);
|
|
16646
16678
|
exportedFiles.push(CODEX_CONFIG_FILE);
|
|
16647
16679
|
}
|
|
16648
|
-
const claudeSrc =
|
|
16649
|
-
const claudeDst =
|
|
16680
|
+
const claudeSrc = path9.join(ccmanDir2, CLAUDE_CONFIG_FILE);
|
|
16681
|
+
const claudeDst = path9.join(targetDir, CLAUDE_CONFIG_FILE);
|
|
16650
16682
|
if (fileExists(claudeSrc)) {
|
|
16651
16683
|
fs8.copyFileSync(claudeSrc, claudeDst);
|
|
16652
16684
|
exportedFiles.push(CLAUDE_CONFIG_FILE);
|
|
@@ -16668,22 +16700,22 @@ function importConfig(sourceDir) {
|
|
|
16668
16700
|
ensureDir(ccmanDir2);
|
|
16669
16701
|
try {
|
|
16670
16702
|
if (validation.foundFiles.includes(CODEX_CONFIG_FILE)) {
|
|
16671
|
-
const codexDst =
|
|
16703
|
+
const codexDst = path9.join(ccmanDir2, CODEX_CONFIG_FILE);
|
|
16672
16704
|
if (fileExists(codexDst)) {
|
|
16673
16705
|
const backupPath = backupConfig(codexDst);
|
|
16674
16706
|
backupPaths.push(backupPath);
|
|
16675
16707
|
}
|
|
16676
|
-
const codexSrc =
|
|
16708
|
+
const codexSrc = path9.join(sourceDir, CODEX_CONFIG_FILE);
|
|
16677
16709
|
fs8.copyFileSync(codexSrc, codexDst);
|
|
16678
16710
|
importedFiles.push(CODEX_CONFIG_FILE);
|
|
16679
16711
|
}
|
|
16680
16712
|
if (validation.foundFiles.includes(CLAUDE_CONFIG_FILE)) {
|
|
16681
|
-
const claudeDst =
|
|
16713
|
+
const claudeDst = path9.join(ccmanDir2, CLAUDE_CONFIG_FILE);
|
|
16682
16714
|
if (fileExists(claudeDst)) {
|
|
16683
16715
|
const backupPath = backupConfig(claudeDst);
|
|
16684
16716
|
backupPaths.push(backupPath);
|
|
16685
16717
|
}
|
|
16686
|
-
const claudeSrc =
|
|
16718
|
+
const claudeSrc = path9.join(sourceDir, CLAUDE_CONFIG_FILE);
|
|
16687
16719
|
fs8.copyFileSync(claudeSrc, claudeDst);
|
|
16688
16720
|
importedFiles.push(CLAUDE_CONFIG_FILE);
|
|
16689
16721
|
}
|
|
@@ -16702,12 +16734,12 @@ function importConfig(sourceDir) {
|
|
|
16702
16734
|
throw new Error(`\u5BFC\u5165\u5931\u8D25\uFF0C\u5DF2\u6062\u590D\u5907\u4EFD: ${error.message}`);
|
|
16703
16735
|
}
|
|
16704
16736
|
}
|
|
16705
|
-
var fs8,
|
|
16737
|
+
var fs8, path9, CODEX_CONFIG_FILE, CLAUDE_CONFIG_FILE;
|
|
16706
16738
|
var init_export = __esm({
|
|
16707
16739
|
"../core/dist/export.js"() {
|
|
16708
16740
|
"use strict";
|
|
16709
16741
|
fs8 = __toESM(require("fs"), 1);
|
|
16710
|
-
|
|
16742
|
+
path9 = __toESM(require("path"), 1);
|
|
16711
16743
|
init_paths();
|
|
16712
16744
|
init_file();
|
|
16713
16745
|
init_merge2();
|
|
@@ -17185,8 +17217,8 @@ function downloadCommand(program2) {
|
|
|
17185
17217
|
console.log();
|
|
17186
17218
|
if (backupPaths.length > 0) {
|
|
17187
17219
|
console.log(import_chalk6.default.gray("\u672C\u5730\u5907\u4EFD:"));
|
|
17188
|
-
backupPaths.forEach((
|
|
17189
|
-
console.log(import_chalk6.default.gray(` ${
|
|
17220
|
+
backupPaths.forEach((path12) => {
|
|
17221
|
+
console.log(import_chalk6.default.gray(` ${path12}`));
|
|
17190
17222
|
});
|
|
17191
17223
|
console.log();
|
|
17192
17224
|
}
|
|
@@ -17250,8 +17282,8 @@ function mergeCommand(program2) {
|
|
|
17250
17282
|
console.log();
|
|
17251
17283
|
if (result.backupPaths.length > 0) {
|
|
17252
17284
|
console.log(import_chalk7.default.gray("\u5907\u4EFD:"));
|
|
17253
|
-
result.backupPaths.forEach((
|
|
17254
|
-
console.log(import_chalk7.default.gray(` ${
|
|
17285
|
+
result.backupPaths.forEach((path12) => {
|
|
17286
|
+
console.log(import_chalk7.default.gray(` ${path12}`));
|
|
17255
17287
|
});
|
|
17256
17288
|
console.log();
|
|
17257
17289
|
}
|
|
@@ -18893,7 +18925,7 @@ init_sync2();
|
|
|
18893
18925
|
|
|
18894
18926
|
// src/commands/export.ts
|
|
18895
18927
|
var import_chalk25 = __toESM(require("chalk"));
|
|
18896
|
-
var
|
|
18928
|
+
var import_path19 = __toESM(require("path"));
|
|
18897
18929
|
init_dist4();
|
|
18898
18930
|
function exportCommand(program2) {
|
|
18899
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) => {
|
|
@@ -18905,7 +18937,7 @@ function exportCommand(program2) {
|
|
|
18905
18937
|
`));
|
|
18906
18938
|
process.exit(1);
|
|
18907
18939
|
}
|
|
18908
|
-
const resolvedPath = targetDir.startsWith("~") ?
|
|
18940
|
+
const resolvedPath = targetDir.startsWith("~") ? import_path19.default.join(process.env.HOME || "", targetDir.slice(1)) : import_path19.default.resolve(targetDir);
|
|
18909
18941
|
console.log("\u5BFC\u51FA\u6587\u4EF6:");
|
|
18910
18942
|
console.log(` ${import_chalk25.default.cyan("codex.json")} - Codex \u914D\u7F6E`);
|
|
18911
18943
|
console.log(` ${import_chalk25.default.cyan("claude.json")} - Claude \u914D\u7F6E`);
|
|
@@ -18936,12 +18968,12 @@ function exportCommand(program2) {
|
|
|
18936
18968
|
// src/commands/import.ts
|
|
18937
18969
|
var import_chalk26 = __toESM(require("chalk"));
|
|
18938
18970
|
var import_inquirer17 = __toESM(require("inquirer"));
|
|
18939
|
-
var
|
|
18971
|
+
var import_path20 = __toESM(require("path"));
|
|
18940
18972
|
init_dist4();
|
|
18941
18973
|
function importCommand(program2) {
|
|
18942
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) => {
|
|
18943
18975
|
try {
|
|
18944
|
-
const resolvedPath = sourceDir.startsWith("~") ?
|
|
18976
|
+
const resolvedPath = sourceDir.startsWith("~") ? import_path20.default.join(process.env.HOME || "", sourceDir.slice(1)) : import_path20.default.resolve(sourceDir);
|
|
18945
18977
|
console.log(import_chalk26.default.bold("\n\u{1F4E5} \u5BFC\u5165\u914D\u7F6E\n"));
|
|
18946
18978
|
const validation = validateImportDir(resolvedPath);
|
|
18947
18979
|
if (!validation.valid) {
|