@pikecode/api-key-manager 1.0.32 → 1.0.34
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 +8 -2
- package/bin/akm.js +5 -3
- package/package.json +1 -1
- package/src/commands/add.js +19 -33
- package/src/commands/backup.js +2 -2
- package/src/commands/current.js +14 -12
- package/src/commands/edit.js +51 -7
- package/src/commands/list.js +11 -9
- package/src/commands/remove.js +2 -2
- package/src/commands/switch.js +38 -71
- package/src/config.js +84 -23
- package/src/utils/codex-launcher.js +1 -42
- package/src/utils/env-launcher.js +7 -43
- package/src/utils/env-utils.js +52 -0
- package/src/utils/error-handler.js +1 -1
- package/src/utils/launch-args.js +96 -0
- package/src/utils/provider-status-checker.js +87 -26
- package/src/utils/secrets.js +22 -0
- package/src/utils/update-checker.js +8 -2
- package/src/utils/validator.js +3 -68
- package/src/utils/storage.js +0 -55
package/src/utils/storage.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const fs = require('fs-extra');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const os = require('os');
|
|
4
|
-
|
|
5
|
-
class Storage {
|
|
6
|
-
static async ensureConfigDir() {
|
|
7
|
-
const configDir = path.join(os.homedir(), '.akm-config');
|
|
8
|
-
await fs.ensureDir(configDir);
|
|
9
|
-
return configDir;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static async readConfig() {
|
|
13
|
-
const configPath = path.join(os.homedir(), '.akm-config.json');
|
|
14
|
-
try {
|
|
15
|
-
if (await fs.pathExists(configPath)) {
|
|
16
|
-
return await fs.readJSON(configPath);
|
|
17
|
-
}
|
|
18
|
-
return null;
|
|
19
|
-
} catch (error) {
|
|
20
|
-
throw new Error(`读取配置文件失败: ${error.message}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static async writeConfig(config) {
|
|
25
|
-
const configPath = path.join(os.homedir(), '.akm-config.json');
|
|
26
|
-
try {
|
|
27
|
-
await fs.writeJSON(configPath, config, { spaces: 2 });
|
|
28
|
-
return true;
|
|
29
|
-
} catch (error) {
|
|
30
|
-
throw new Error(`写入配置文件失败: ${error.message}`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static async backupConfig() {
|
|
35
|
-
const configPath = path.join(os.homedir(), '.akm-config.json');
|
|
36
|
-
const backupPath = path.join(os.homedir(), '.akm-config.backup.json');
|
|
37
|
-
|
|
38
|
-
if (await fs.pathExists(configPath)) {
|
|
39
|
-
await fs.copy(configPath, backupPath);
|
|
40
|
-
return backupPath;
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static async restoreConfig(backupPath) {
|
|
46
|
-
const configPath = path.join(os.homedir(), '.akm-config.json');
|
|
47
|
-
if (await fs.pathExists(backupPath)) {
|
|
48
|
-
await fs.copy(backupPath, configPath);
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
module.exports = { Storage };
|