claude-switch-profile 1.4.0 → 1.4.2
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/.cocoindex_code/cocoindex.db/mdb/data.mdb +0 -0
- package/.cocoindex_code/cocoindex.db/mdb/lock.mdb +0 -0
- package/.cocoindex_code/settings.yml +41 -0
- package/.cocoindex_code/target_sqlite.db +0 -0
- package/CHANGELOG.md +19 -0
- package/README.md +112 -50
- package/package.json +1 -1
- package/src/commands/create.js +9 -26
- package/src/commands/current.js +13 -2
- package/src/commands/deactivate.js +6 -8
- package/src/commands/diff.js +6 -4
- package/src/commands/export.js +7 -4
- package/src/commands/import.js +47 -2
- package/src/commands/init.js +29 -9
- package/src/commands/launch.js +10 -5
- package/src/commands/save.js +8 -4
- package/src/commands/uninstall.js +19 -22
- package/src/commands/use.js +55 -50
- package/src/constants.js +1 -1
- package/src/file-operations.js +13 -11
- package/src/item-manager.js +10 -16
- package/src/profile-store.js +37 -14
- package/src/runtime-instance-manager.js +29 -29
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
existsSync,
|
|
3
|
+
mkdirSync,
|
|
4
|
+
cpSync,
|
|
5
|
+
rmSync,
|
|
6
|
+
lstatSync,
|
|
7
|
+
statSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
writeFileSync,
|
|
10
|
+
readdirSync,
|
|
11
|
+
readlinkSync,
|
|
12
|
+
} from 'node:fs';
|
|
2
13
|
import { join, dirname } from 'node:path';
|
|
3
|
-
import { MANAGED_ITEMS, COPY_ITEMS, COPY_DIRS, CLAUDE_DIR
|
|
14
|
+
import { MANAGED_ITEMS, COPY_ITEMS, COPY_DIRS, CLAUDE_DIR } from './constants.js';
|
|
4
15
|
import {
|
|
5
16
|
getActive,
|
|
6
17
|
getProfileDir,
|
|
@@ -37,6 +48,12 @@ const shouldSyncDir = (src, dest) => {
|
|
|
37
48
|
const srcPath = join(srcDir, srcEntry.name);
|
|
38
49
|
const destPath = join(destDir, srcEntry.name);
|
|
39
50
|
|
|
51
|
+
if (srcEntry.isSymbolicLink()) {
|
|
52
|
+
if (!destEntry.isSymbolicLink()) return true;
|
|
53
|
+
if (readlinkSync(srcPath) !== readlinkSync(destPath)) return true;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
|
|
40
57
|
if (srcEntry.isDirectory()) {
|
|
41
58
|
if (!destEntry.isDirectory()) return true;
|
|
42
59
|
pending.push([srcPath, destPath]);
|
|
@@ -99,36 +116,24 @@ const getStaticItems = () => {
|
|
|
99
116
|
};
|
|
100
117
|
|
|
101
118
|
const resolveSourceDir = (profileName) => {
|
|
102
|
-
if (profileName === DEFAULT_PROFILE) {
|
|
103
|
-
return CLAUDE_DIR;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
119
|
const active = getActive();
|
|
107
|
-
|
|
108
|
-
return CLAUDE_DIR;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return getProfileDir(profileName);
|
|
120
|
+
return active === profileName ? CLAUDE_DIR : getProfileDir(profileName);
|
|
112
121
|
};
|
|
113
122
|
|
|
114
123
|
const resolveItemSource = (profileName, item) => {
|
|
115
|
-
const profileDir =
|
|
124
|
+
const profileDir = getProfileDir(profileName);
|
|
116
125
|
const active = getActive();
|
|
117
126
|
const profileIsActive = active === profileName;
|
|
118
127
|
|
|
119
|
-
|
|
120
|
-
if (profileIsActive || profileName === DEFAULT_PROFILE) {
|
|
128
|
+
if (profileIsActive) {
|
|
121
129
|
const claudePath = join(CLAUDE_DIR, item);
|
|
122
130
|
if (existsSync(claudePath)) return claudePath;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (existsSync(profilePath)) return profilePath;
|
|
127
|
-
}
|
|
131
|
+
|
|
132
|
+
const profilePath = join(profileDir, item);
|
|
133
|
+
if (existsSync(profilePath)) return profilePath;
|
|
128
134
|
return null;
|
|
129
135
|
}
|
|
130
136
|
|
|
131
|
-
// Profile is NOT active — items should be in profileDir
|
|
132
137
|
const profilePath = join(profileDir, item);
|
|
133
138
|
if (existsSync(profilePath)) return profilePath;
|
|
134
139
|
|
|
@@ -146,23 +151,18 @@ export const syncStaticConfig = (profileName, runtimeDir) => {
|
|
|
146
151
|
const dest = join(runtimeDir, item);
|
|
147
152
|
|
|
148
153
|
if (!src) {
|
|
149
|
-
// Source doesn't exist anywhere — skip (don't delete existing runtime items)
|
|
150
154
|
continue;
|
|
151
155
|
}
|
|
152
156
|
|
|
153
157
|
const stat = lstatSync(src);
|
|
154
158
|
|
|
155
|
-
if (stat.isDirectory()) {
|
|
159
|
+
if (stat.isDirectory() && !stat.isSymbolicLink()) {
|
|
156
160
|
if (!shouldSyncDir(src, dest)) continue;
|
|
157
|
-
removePath(dest);
|
|
158
|
-
cpSync(src, dest, { recursive: true });
|
|
159
|
-
continue;
|
|
160
161
|
}
|
|
161
162
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
163
|
+
removePath(dest);
|
|
164
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
165
|
+
cpSync(src, dest, { recursive: true, verbatimSymlinks: true });
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
rewriteSettingsForRuntime(runtimeDir, sourceDir);
|