claude-settings-cli 1.0.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/LICENSE +21 -0
- package/README.md +142 -0
- package/bin/ccc.mjs +2 -0
- package/dist/commands/backup.d.ts +3 -0
- package/dist/commands/backup.d.ts.map +1 -0
- package/dist/commands/backup.js +55 -0
- package/dist/commands/backup.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +135 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/io.d.ts +4 -0
- package/dist/commands/io.d.ts.map +1 -0
- package/dist/commands/io.js +69 -0
- package/dist/commands/io.js.map +1 -0
- package/dist/commands/plugin.d.ts +3 -0
- package/dist/commands/plugin.d.ts.map +1 -0
- package/dist/commands/plugin.js +77 -0
- package/dist/commands/plugin.js.map +1 -0
- package/dist/commands/preset.d.ts +3 -0
- package/dist/commands/preset.d.ts.map +1 -0
- package/dist/commands/preset.js +118 -0
- package/dist/commands/preset.js.map +1 -0
- package/dist/commands/project.d.ts +3 -0
- package/dist/commands/project.d.ts.map +1 -0
- package/dist/commands/project.js +61 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/core/diff.d.ts +3 -0
- package/dist/core/diff.d.ts.map +1 -0
- package/dist/core/diff.js +45 -0
- package/dist/core/diff.js.map +1 -0
- package/dist/core/paths.d.ts +12 -0
- package/dist/core/paths.d.ts.map +1 -0
- package/dist/core/paths.js +34 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/reader.d.ts +13 -0
- package/dist/core/reader.d.ts.map +1 -0
- package/dist/core/reader.js +65 -0
- package/dist/core/reader.js.map +1 -0
- package/dist/core/switcher.d.ts +12 -0
- package/dist/core/switcher.d.ts.map +1 -0
- package/dist/core/switcher.js +37 -0
- package/dist/core/switcher.js.map +1 -0
- package/dist/core/writer.d.ts +11 -0
- package/dist/core/writer.d.ts.map +1 -0
- package/dist/core/writer.js +34 -0
- package/dist/core/writer.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -0
- package/dist/schema/plugins.d.ts +70 -0
- package/dist/schema/plugins.d.ts.map +1 -0
- package/dist/schema/plugins.js +15 -0
- package/dist/schema/plugins.js.map +1 -0
- package/dist/schema/project.d.ts +37 -0
- package/dist/schema/project.d.ts.map +1 -0
- package/dist/schema/project.js +16 -0
- package/dist/schema/project.js.map +1 -0
- package/dist/schema/settings.d.ts +37 -0
- package/dist/schema/settings.d.ts.map +1 -0
- package/dist/schema/settings.js +30 -0
- package/dist/schema/settings.js.map +1 -0
- package/dist/types/index.d.ts +37 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/backup.d.ts +6 -0
- package/dist/utils/backup.d.ts.map +1 -0
- package/dist/utils/backup.js +34 -0
- package/dist/utils/backup.js.map +1 -0
- package/dist/utils/errors.d.ts +18 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +42 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +18 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/safe-json.d.ts +3 -0
- package/dist/utils/safe-json.d.ts.map +1 -0
- package/dist/utils/safe-json.js +25 -0
- package/dist/utils/safe-json.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# claude-settings-cli
|
|
2
|
+
|
|
3
|
+
CLI tool to manage Claude Code configuration presets. Switch between different API providers, manage plugins, and export/import your settings.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g claude-settings-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or use directly with npx:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx claude-settings-cli preset list
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Commands
|
|
18
|
+
|
|
19
|
+
### Preset Management
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# List all presets (mark current active)
|
|
23
|
+
ccc preset list
|
|
24
|
+
|
|
25
|
+
# Switch to a preset
|
|
26
|
+
ccc preset use deepseek
|
|
27
|
+
|
|
28
|
+
# Save current settings as a preset
|
|
29
|
+
ccc preset save my-preset
|
|
30
|
+
|
|
31
|
+
# Delete a preset
|
|
32
|
+
ccc preset delete my-preset
|
|
33
|
+
|
|
34
|
+
# Rename a preset
|
|
35
|
+
ccc preset rename old-name new-name
|
|
36
|
+
|
|
37
|
+
# Compare two presets
|
|
38
|
+
ccc preset diff deepseek glm
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Configuration
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Show current config (sensitive values masked)
|
|
45
|
+
ccc config show
|
|
46
|
+
|
|
47
|
+
# Show full config without masking
|
|
48
|
+
ccc config show --full
|
|
49
|
+
|
|
50
|
+
# Get a config value
|
|
51
|
+
ccc config get env.ANTHROPIC_BASE_URL
|
|
52
|
+
|
|
53
|
+
# Set a config value
|
|
54
|
+
ccc config set env.ANTHROPIC_BASE_URL "https://api.example.com"
|
|
55
|
+
ccc config set language English
|
|
56
|
+
ccc config set alwaysThinkingEnabled true
|
|
57
|
+
|
|
58
|
+
# Remove a config value
|
|
59
|
+
ccc config unset env.CUSTOM_VAR
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Plugins
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# List installed plugins
|
|
66
|
+
ccc plugin list
|
|
67
|
+
|
|
68
|
+
# Enable/disable a plugin
|
|
69
|
+
ccc plugin enable swift-lsp@claude-plugins-official
|
|
70
|
+
ccc plugin disable clangd-lsp@claude-plugins-official
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Projects
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# List projects with configuration
|
|
77
|
+
ccc project list
|
|
78
|
+
|
|
79
|
+
# Show a project's configuration
|
|
80
|
+
ccc project show /path/to/project
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Export/Import
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Export all config to a file
|
|
87
|
+
ccc export
|
|
88
|
+
|
|
89
|
+
# Export with plugins data
|
|
90
|
+
ccc export --include-plugins --output my-config.json
|
|
91
|
+
|
|
92
|
+
# Import config (merge mode by default)
|
|
93
|
+
ccc import my-config.json
|
|
94
|
+
|
|
95
|
+
# Import with replace mode
|
|
96
|
+
ccc import my-config.json --mode replace
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Backup
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# List backups
|
|
103
|
+
ccc backup list
|
|
104
|
+
|
|
105
|
+
# Restore a backup (interactive selection)
|
|
106
|
+
ccc backup restore
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Current Status
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Show current active preset and key settings
|
|
113
|
+
ccc current
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## How It Works
|
|
117
|
+
|
|
118
|
+
Claude Code reads its global configuration from `~/.claude/settings.json`. This tool manages preset files named `settings-{name}.json` in the same directory.
|
|
119
|
+
|
|
120
|
+
- `ccc preset use deepseek` copies `settings-deepseek.json` → `settings.json`
|
|
121
|
+
- `ccc preset save my-preset` copies `settings.json` → `settings-my-preset.json`
|
|
122
|
+
- Every write to `settings.json` creates an automatic backup first
|
|
123
|
+
|
|
124
|
+
## Development
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
git clone <repo-url>
|
|
128
|
+
cd claude-settings-cli
|
|
129
|
+
npm install
|
|
130
|
+
npm run build
|
|
131
|
+
npm run dev -- preset list
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Run Tests
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
npm test
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
|
|
142
|
+
MIT
|
package/bin/ccc.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["../../src/commands/backup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,eAAO,MAAM,aAAa,SACM,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { BackupManager } from '../utils/backup.js';
|
|
5
|
+
import { SETTINGS_FILE } from '../core/paths.js';
|
|
6
|
+
import { success } from '../utils/logger.js';
|
|
7
|
+
import { handleError } from '../utils/errors.js';
|
|
8
|
+
export const backupCommand = new Command('backup')
|
|
9
|
+
.description('Manage backups');
|
|
10
|
+
backupCommand
|
|
11
|
+
.command('list')
|
|
12
|
+
.description('List available backups')
|
|
13
|
+
.action(() => {
|
|
14
|
+
const backups = BackupManager.listBackups();
|
|
15
|
+
console.log('');
|
|
16
|
+
if (backups.length === 0) {
|
|
17
|
+
console.log(chalk.dim(' No backups found.'));
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
for (const b of backups) {
|
|
21
|
+
console.log(` ${b}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
console.log('');
|
|
25
|
+
});
|
|
26
|
+
backupCommand
|
|
27
|
+
.command('restore [name]')
|
|
28
|
+
.description('Restore a backup (interactive if no name provided)')
|
|
29
|
+
.action(async (name) => {
|
|
30
|
+
try {
|
|
31
|
+
const backups = BackupManager.listBackups();
|
|
32
|
+
if (backups.length === 0) {
|
|
33
|
+
console.log(chalk.dim(' No backups found.'));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
let selected = name;
|
|
37
|
+
if (!selected) {
|
|
38
|
+
const answer = await inquirer.prompt([
|
|
39
|
+
{
|
|
40
|
+
type: 'list',
|
|
41
|
+
name: 'backup',
|
|
42
|
+
message: 'Select a backup to restore:',
|
|
43
|
+
choices: backups,
|
|
44
|
+
},
|
|
45
|
+
]);
|
|
46
|
+
selected = answer.backup;
|
|
47
|
+
}
|
|
48
|
+
await BackupManager.restoreBackup(selected, SETTINGS_FILE);
|
|
49
|
+
success(`Restored backup "${selected}"`);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
handleError(err);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=backup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backup.js","sourceRoot":"","sources":["../../src/commands/backup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,gBAAgB,CAAC,CAAC;AAEjC,aAAa;KACV,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,wBAAwB,CAAC;KACrC,MAAM,CAAC,GAAG,EAAE;IACX,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;IAC5C,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAChD,CAAC;SAAM,CAAC;QACN,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;YACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEL,aAAa;KACV,OAAO,CAAC,gBAAgB,CAAC;KACzB,WAAW,CAAC,oDAAoD,CAAC;KACjE,MAAM,CAAC,KAAK,EAAE,IAAa,EAAE,EAAE;IAC9B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QAC5C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC;YAC9C,OAAO;QACT,CAAC;QAED,IAAI,QAAQ,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;gBACnC;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,6BAA6B;oBACtC,OAAO,EAAE,OAAO;iBACjB;aACF,CAAC,CAAC;YACH,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;QAC3B,CAAC;QAED,MAAM,aAAa,CAAC,aAAa,CAAC,QAAS,EAAE,aAAa,CAAC,CAAC;QAC5D,OAAO,CAAC,oBAAoB,QAAQ,GAAG,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,WAAW,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,eAAO,MAAM,aAAa,SACyB,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { ConfigReader } from '../core/reader.js';
|
|
4
|
+
import { ConfigWriter } from '../core/writer.js';
|
|
5
|
+
import { maskValue } from '../schema/settings.js';
|
|
6
|
+
import { success } from '../utils/logger.js';
|
|
7
|
+
import { handleError } from '../utils/errors.js';
|
|
8
|
+
export const configCommand = new Command('config')
|
|
9
|
+
.description('Get/set/show configuration values');
|
|
10
|
+
configCommand
|
|
11
|
+
.command('show')
|
|
12
|
+
.description('Show current configuration')
|
|
13
|
+
.option('--full', 'Show sensitive values without masking')
|
|
14
|
+
.action((opts) => {
|
|
15
|
+
try {
|
|
16
|
+
const settings = ConfigReader.readSettings();
|
|
17
|
+
console.log('');
|
|
18
|
+
printConfig(settings, '', !opts.full);
|
|
19
|
+
console.log('');
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
handleError(err);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
configCommand
|
|
26
|
+
.command('get <path>')
|
|
27
|
+
.description('Get a configuration value (e.g., env.ANTHROPIC_BASE_URL)')
|
|
28
|
+
.action((pathStr) => {
|
|
29
|
+
try {
|
|
30
|
+
const settings = ConfigReader.readSettings();
|
|
31
|
+
const value = getNestedValue(settings, pathStr);
|
|
32
|
+
if (value === undefined) {
|
|
33
|
+
console.log(chalk.dim(` ${pathStr} is not set`));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
console.log(JSON.stringify(value, null, 2));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
handleError(err);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
configCommand
|
|
44
|
+
.command('set <path> <value>')
|
|
45
|
+
.description('Set a configuration value')
|
|
46
|
+
.action(async (pathStr, value) => {
|
|
47
|
+
try {
|
|
48
|
+
const settings = ConfigReader.readSettings();
|
|
49
|
+
const parsed = inferType(value);
|
|
50
|
+
setNestedValue(settings, pathStr, parsed);
|
|
51
|
+
await ConfigWriter.writeSettings(settings);
|
|
52
|
+
success(`Set ${pathStr} = ${JSON.stringify(parsed)}`);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
handleError(err);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
configCommand
|
|
59
|
+
.command('unset <path>')
|
|
60
|
+
.description('Remove a configuration value')
|
|
61
|
+
.action(async (pathStr) => {
|
|
62
|
+
try {
|
|
63
|
+
const settings = ConfigReader.readSettings();
|
|
64
|
+
unsetNestedValue(settings, pathStr);
|
|
65
|
+
await ConfigWriter.writeSettings(settings);
|
|
66
|
+
success(`Removed ${pathStr}`);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
handleError(err);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
function printConfig(obj, prefix, mask) {
|
|
73
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
74
|
+
const fullPath = prefix ? `${prefix}.${key}` : key;
|
|
75
|
+
if (typeof value === 'object' &&
|
|
76
|
+
value !== null &&
|
|
77
|
+
!Array.isArray(value)) {
|
|
78
|
+
if (prefix) {
|
|
79
|
+
console.log(chalk.cyan(` ${fullPath}:`));
|
|
80
|
+
}
|
|
81
|
+
printConfig(value, fullPath, mask);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const displayValue = mask && prefix === 'env'
|
|
85
|
+
? maskValue(key, String(value))
|
|
86
|
+
: JSON.stringify(value);
|
|
87
|
+
console.log(` ${chalk.dim(fullPath)}: ${displayValue}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function getNestedValue(obj, pathStr) {
|
|
92
|
+
const parts = pathStr.split('.');
|
|
93
|
+
let current = obj;
|
|
94
|
+
for (const part of parts) {
|
|
95
|
+
if (current === null || current === undefined || typeof current !== 'object') {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
current = current[part];
|
|
99
|
+
}
|
|
100
|
+
return current;
|
|
101
|
+
}
|
|
102
|
+
function setNestedValue(obj, pathStr, value) {
|
|
103
|
+
const parts = pathStr.split('.');
|
|
104
|
+
let current = obj;
|
|
105
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
106
|
+
if (!(parts[i] in current) || typeof current[parts[i]] !== 'object') {
|
|
107
|
+
current[parts[i]] = {};
|
|
108
|
+
}
|
|
109
|
+
current = current[parts[i]];
|
|
110
|
+
}
|
|
111
|
+
current[parts[parts.length - 1]] = value;
|
|
112
|
+
}
|
|
113
|
+
function unsetNestedValue(obj, pathStr) {
|
|
114
|
+
const parts = pathStr.split('.');
|
|
115
|
+
let current = obj;
|
|
116
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
117
|
+
if (!(parts[i] in current))
|
|
118
|
+
return;
|
|
119
|
+
current = current[parts[i]];
|
|
120
|
+
}
|
|
121
|
+
delete current[parts[parts.length - 1]];
|
|
122
|
+
}
|
|
123
|
+
function inferType(value) {
|
|
124
|
+
if (value === 'true')
|
|
125
|
+
return true;
|
|
126
|
+
if (value === 'false')
|
|
127
|
+
return false;
|
|
128
|
+
if (value === 'null')
|
|
129
|
+
return null;
|
|
130
|
+
const num = Number(value);
|
|
131
|
+
if (!isNaN(num) && value.trim() !== '')
|
|
132
|
+
return num;
|
|
133
|
+
return value;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MA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AE,OAAO,IAAI,CAAC;IAClC,IAAI,KAAK,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IACpC,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAClC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,GAAG,CAAC;IACnD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../../src/commands/io.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,eAAO,MAAM,SAAS,SAqClB,CAAC;AAEL,eAAO,MAAM,aAAa,SA8BtB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import { ConfigReader } from '../core/reader.js';
|
|
4
|
+
import { ConfigWriter } from '../core/writer.js';
|
|
5
|
+
import { readJsonSafe } from '../utils/safe-json.js';
|
|
6
|
+
import { spinner } from '../utils/logger.js';
|
|
7
|
+
import { handleError } from '../utils/errors.js';
|
|
8
|
+
export const ioCommand = new Command('export')
|
|
9
|
+
.description('Export configuration to a file')
|
|
10
|
+
.option('-o, --output <file>', 'Output file path')
|
|
11
|
+
.option('--include-plugins', 'Include plugin data')
|
|
12
|
+
.action(async (opts) => {
|
|
13
|
+
try {
|
|
14
|
+
const s = spinner('Exporting configuration...');
|
|
15
|
+
const settings = ConfigReader.readSettings();
|
|
16
|
+
const presets = ConfigReader.listPresets();
|
|
17
|
+
const presetData = {};
|
|
18
|
+
for (const name of presets) {
|
|
19
|
+
presetData[name] = ConfigReader.readPreset(name);
|
|
20
|
+
}
|
|
21
|
+
const exportData = {
|
|
22
|
+
version: '1.0.0',
|
|
23
|
+
exportedAt: new Date().toISOString(),
|
|
24
|
+
settings,
|
|
25
|
+
presets: presetData,
|
|
26
|
+
};
|
|
27
|
+
if (opts.includePlugins) {
|
|
28
|
+
exportData.plugins = {
|
|
29
|
+
installed: ConfigReader.readInstalledPlugins() ?? { version: 2, plugins: {} },
|
|
30
|
+
blocklist: ConfigReader.readBlocklist(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const date = new Date().toISOString().slice(0, 10);
|
|
34
|
+
const outputPath = opts.output ?? `ccc-export-${date}.json`;
|
|
35
|
+
await fs.writeJson(outputPath, exportData, { spaces: 2 });
|
|
36
|
+
s.succeed(`Configuration exported to ${outputPath}`);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
handleError(err);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
export const importCommand = new Command('import')
|
|
43
|
+
.description('Import configuration from a file')
|
|
44
|
+
.argument('<file>', 'Configuration file to import')
|
|
45
|
+
.option('-m, --mode <mode>', 'Import mode: merge or replace', 'merge')
|
|
46
|
+
.action(async (file, opts) => {
|
|
47
|
+
try {
|
|
48
|
+
const s = spinner('Importing configuration...');
|
|
49
|
+
const data = (await readJsonSafe(file));
|
|
50
|
+
if (opts.mode === 'replace') {
|
|
51
|
+
await ConfigWriter.writeSettings(data.settings);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const current = ConfigReader.readSettings();
|
|
55
|
+
const merged = { ...current, ...data.settings };
|
|
56
|
+
await ConfigWriter.writeSettings(merged);
|
|
57
|
+
}
|
|
58
|
+
if (data.presets) {
|
|
59
|
+
for (const [name, preset] of Object.entries(data.presets)) {
|
|
60
|
+
await ConfigWriter.savePreset(name, preset);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
s.succeed(`Configuration imported from ${file}`);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
handleError(err);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|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C;QAClD,CAAC;aAAM,CAAC;YACN,MAAM,OAAO,GAAG,YAAY,CAAC,YAAY,EAAE,CAAC;YAC5C,MAAM,MAAM,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChD,MAAM,YAAY,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC1D,MAAM,YAAY,CAAC,UAAU,CAC3B,IAAI,EACJ,MAAuC,CACxC,CAAC;YACJ,CAAC;QACH,CAAC;QAED,CAAC,CAAC,OAAO,CAAC,+BAA+B,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,WAAW,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/commands/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,eAAO,MAAM,aAAa,SACM,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { ConfigReader } from '../core/reader.js';
|
|
4
|
+
import { ConfigWriter } from '../core/writer.js';
|
|
5
|
+
import { success } from '../utils/logger.js';
|
|
6
|
+
import { handleError } from '../utils/errors.js';
|
|
7
|
+
export const pluginCommand = new Command('plugin')
|
|
8
|
+
.description('Manage plugins');
|
|
9
|
+
pluginCommand
|
|
10
|
+
.command('list')
|
|
11
|
+
.description('List all installed plugins')
|
|
12
|
+
.action(() => {
|
|
13
|
+
try {
|
|
14
|
+
const pluginsData = ConfigReader.readInstalledPlugins();
|
|
15
|
+
if (!pluginsData) {
|
|
16
|
+
console.log(chalk.dim(' No plugins installed.'));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const settings = ConfigReader.readSettings();
|
|
20
|
+
const enabledPlugins = settings.enabledPlugins ?? {};
|
|
21
|
+
const blocklist = ConfigReader.readBlocklist();
|
|
22
|
+
console.log('');
|
|
23
|
+
const entries = Object.entries(pluginsData.plugins);
|
|
24
|
+
if (entries.length === 0) {
|
|
25
|
+
console.log(chalk.dim(' No plugins installed.'));
|
|
26
|
+
}
|
|
27
|
+
for (const [pluginId, versions] of entries) {
|
|
28
|
+
const isBlocked = pluginId in blocklist;
|
|
29
|
+
const isEnabled = enabledPlugins[pluginId] === true;
|
|
30
|
+
const status = isBlocked
|
|
31
|
+
? chalk.red('blocked')
|
|
32
|
+
: isEnabled
|
|
33
|
+
? chalk.green('enabled')
|
|
34
|
+
: chalk.dim('disabled');
|
|
35
|
+
const latest = versions[versions.length - 1];
|
|
36
|
+
console.log(` ${pluginId} v${latest.version} (${status})`);
|
|
37
|
+
}
|
|
38
|
+
console.log('');
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
handleError(err);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
pluginCommand
|
|
45
|
+
.command('enable <pluginId>')
|
|
46
|
+
.description('Enable a plugin')
|
|
47
|
+
.action(async (pluginId) => {
|
|
48
|
+
try {
|
|
49
|
+
const settings = ConfigReader.readSettings();
|
|
50
|
+
if (!settings.enabledPlugins) {
|
|
51
|
+
settings.enabledPlugins = {};
|
|
52
|
+
}
|
|
53
|
+
settings.enabledPlugins[pluginId] = true;
|
|
54
|
+
await ConfigWriter.writeSettings(settings);
|
|
55
|
+
success(`Enabled plugin "${pluginId}"`);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
handleError(err);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
pluginCommand
|
|
62
|
+
.command('disable <pluginId>')
|
|
63
|
+
.description('Disable a plugin')
|
|
64
|
+
.action(async (pluginId) => {
|
|
65
|
+
try {
|
|
66
|
+
const settings = ConfigReader.readSettings();
|
|
67
|
+
if (settings.enabledPlugins) {
|
|
68
|
+
settings.enabledPlugins[pluginId] = false;
|
|
69
|
+
}
|
|
70
|
+
await ConfigWriter.writeSettings(settings);
|
|
71
|
+
success(`Disabled plugin "${pluginId}"`);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
handleError(err);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/commands/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,gBAAgB,CAAC,CAAC;AAEjC,aAAa;KACV,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,4BAA4B,CAAC;KACzC,MAAM,CAAC,GAAG,EAAE;IACX,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,YAAY,CAAC,oBAAoB,EAAE,CAAC;QACxD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC;YAClD,OAAO;QACT,CAAC;QAED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