@claude-sync/cli 0.1.11 → 0.1.13
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 +136 -0
- package/dist/bin/claude-sync.js +42 -5
- package/dist/bin/claude-sync.js.map +1 -1
- package/dist/src/index.js +42 -5
- package/dist/src/index.js.map +1 -1
- package/package.json +10 -8
package/dist/src/index.js
CHANGED
|
@@ -5165,7 +5165,7 @@ __export(sync_exports, {
|
|
|
5165
5165
|
});
|
|
5166
5166
|
import { Command as Command4 } from "commander";
|
|
5167
5167
|
import { select as select2, isCancel as isCancel3 } from "@clack/prompts";
|
|
5168
|
-
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, lstat as lstat2, symlink, unlink } from "fs/promises";
|
|
5168
|
+
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, lstat as lstat2, symlink, unlink, rename } from "fs/promises";
|
|
5169
5169
|
import { join as join3, dirname as dirname2 } from "path";
|
|
5170
5170
|
import { homedir as homedir4 } from "os";
|
|
5171
5171
|
async function runSync(options) {
|
|
@@ -5329,6 +5329,10 @@ async function handleFirstRun(client, config, cwd, ctx, manifest, projectDir, pr
|
|
|
5329
5329
|
});
|
|
5330
5330
|
if (isCancel3(projectChoice)) return "cancelled";
|
|
5331
5331
|
const selectedProject = projects.find((p) => p.id === projectChoice);
|
|
5332
|
+
const existingCheck = await handleExistingSessionDir(projectsDir, ctx.encodedPath);
|
|
5333
|
+
if (existingCheck === "cancelled") {
|
|
5334
|
+
return "cancelled";
|
|
5335
|
+
}
|
|
5332
5336
|
const downloaded = await crossMachinePull(
|
|
5333
5337
|
client,
|
|
5334
5338
|
config.deviceId,
|
|
@@ -5355,6 +5359,43 @@ async function handleFirstRun(client, config, cwd, ctx, manifest, projectDir, pr
|
|
|
5355
5359
|
}
|
|
5356
5360
|
return "pulled";
|
|
5357
5361
|
}
|
|
5362
|
+
async function handleExistingSessionDir(projectsDir, localEncoded) {
|
|
5363
|
+
const symlinkPath = join3(projectsDir, localEncoded);
|
|
5364
|
+
try {
|
|
5365
|
+
const stats = await lstat2(symlinkPath);
|
|
5366
|
+
if (stats.isSymbolicLink()) {
|
|
5367
|
+
return "continue";
|
|
5368
|
+
}
|
|
5369
|
+
if (stats.isDirectory()) {
|
|
5370
|
+
printInfo(brand("Local session directory already exists"));
|
|
5371
|
+
printInfo(dim(symlinkPath));
|
|
5372
|
+
const choice = await select2({
|
|
5373
|
+
message: brand("What would you like to do?"),
|
|
5374
|
+
options: [
|
|
5375
|
+
{
|
|
5376
|
+
value: "backup",
|
|
5377
|
+
label: "Backup and continue",
|
|
5378
|
+
hint: dim("Move existing to .bak and sync from remote")
|
|
5379
|
+
},
|
|
5380
|
+
{
|
|
5381
|
+
value: "cancel",
|
|
5382
|
+
label: "Stop sync",
|
|
5383
|
+
hint: dim("Keep existing local sessions")
|
|
5384
|
+
}
|
|
5385
|
+
]
|
|
5386
|
+
});
|
|
5387
|
+
if (isCancel3(choice) || choice === "cancel") {
|
|
5388
|
+
return "cancelled";
|
|
5389
|
+
}
|
|
5390
|
+
const backupPath = `${symlinkPath}.bak.${Date.now()}`;
|
|
5391
|
+
await rename(symlinkPath, backupPath);
|
|
5392
|
+
printSuccess(`Backed up to: ${dim(backupPath)}`);
|
|
5393
|
+
return "continue";
|
|
5394
|
+
}
|
|
5395
|
+
} catch {
|
|
5396
|
+
}
|
|
5397
|
+
return "continue";
|
|
5398
|
+
}
|
|
5358
5399
|
async function createProjectSymlink(projectsDir, localEncoded, foreignEncoded) {
|
|
5359
5400
|
const symlinkPath = join3(projectsDir, localEncoded);
|
|
5360
5401
|
await mkdir2(projectsDir, { recursive: true });
|
|
@@ -5362,10 +5403,6 @@ async function createProjectSymlink(projectsDir, localEncoded, foreignEncoded) {
|
|
|
5362
5403
|
const stats = await lstat2(symlinkPath);
|
|
5363
5404
|
if (stats.isSymbolicLink()) {
|
|
5364
5405
|
await unlink(symlinkPath);
|
|
5365
|
-
} else if (stats.isDirectory()) {
|
|
5366
|
-
printError(`Local session directory already exists. Back it up first:
|
|
5367
|
-
mv "${symlinkPath}" "${symlinkPath}.bak"`);
|
|
5368
|
-
return;
|
|
5369
5406
|
}
|
|
5370
5407
|
} catch {
|
|
5371
5408
|
}
|