@synapsync/cli 0.1.3 → 0.1.4

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 CHANGED
@@ -28,7 +28,7 @@ var init_version = __esm({
28
28
  "src/version.ts"() {
29
29
  "use strict";
30
30
  init_esm_shims();
31
- version = "0.1.3";
31
+ version = "0.1.4";
32
32
  }
33
33
  });
34
34
 
@@ -5447,7 +5447,7 @@ function executePurgeCommand(options) {
5447
5447
  }
5448
5448
  let removedCount = 0;
5449
5449
  try {
5450
- removedCount += removeProviderContent(projectRoot);
5450
+ removedCount += removeProviderSymlinks(projectRoot, synapSyncDir);
5451
5451
  if (fs14.existsSync(synapSyncDir)) {
5452
5452
  fs14.rmSync(synapSyncDir, { recursive: true, force: true });
5453
5453
  logger.log(` ${pc16.red("\u2717")} Removed ${path16.relative(projectRoot, synapSyncDir)}/`);
@@ -5481,14 +5481,9 @@ function executePurgeCommand(options) {
5481
5481
  }
5482
5482
  function collectItemsToRemove(projectRoot, synapSyncDir) {
5483
5483
  const items = [];
5484
- for (const provider of SUPPORTED_PROVIDERS) {
5485
- const providerPaths = PROVIDER_PATHS[provider];
5486
- for (const type of COGNITIVE_TYPES) {
5487
- const typePath = path16.join(projectRoot, providerPaths[type]);
5488
- if (fs14.existsSync(typePath)) {
5489
- items.push(path16.relative(projectRoot, typePath) + "/");
5490
- }
5491
- }
5484
+ const symlinks = findSynapSyncSymlinks(projectRoot, synapSyncDir);
5485
+ for (const link of symlinks) {
5486
+ items.push(`${path16.relative(projectRoot, link)} (symlink)`);
5492
5487
  }
5493
5488
  if (fs14.existsSync(synapSyncDir)) {
5494
5489
  items.push(path16.relative(projectRoot, synapSyncDir) + "/");
@@ -5506,33 +5501,38 @@ function collectItemsToRemove(projectRoot, synapSyncDir) {
5506
5501
  }
5507
5502
  return items;
5508
5503
  }
5509
- function removeProviderContent(projectRoot) {
5510
- let removed = 0;
5504
+ function findSynapSyncSymlinks(projectRoot, synapSyncDir) {
5505
+ const symlinks = [];
5506
+ const resolvedSynapSync = path16.resolve(synapSyncDir);
5511
5507
  for (const provider of SUPPORTED_PROVIDERS) {
5512
5508
  const providerPaths = PROVIDER_PATHS[provider];
5513
5509
  for (const type of COGNITIVE_TYPES) {
5514
5510
  const typePath = path16.join(projectRoot, providerPaths[type]);
5515
- if (fs14.existsSync(typePath)) {
5516
- fs14.rmSync(typePath, { recursive: true, force: true });
5517
- logger.log(` ${pc16.red("\u2717")} Removed ${path16.relative(projectRoot, typePath)}/`);
5518
- removed++;
5519
- }
5520
- }
5521
- const providerDir = path16.join(projectRoot, providerPaths[COGNITIVE_TYPES[0]], "..");
5522
- const resolvedDir = path16.resolve(providerDir);
5523
- if (fs14.existsSync(resolvedDir)) {
5511
+ if (!fs14.existsSync(typePath)) continue;
5524
5512
  try {
5525
- const remaining = fs14.readdirSync(resolvedDir);
5526
- if (remaining.length === 0) {
5527
- fs14.rmdirSync(resolvedDir);
5528
- logger.log(` ${pc16.red("\u2717")} Removed empty ${path16.relative(projectRoot, resolvedDir)}/`);
5529
- removed++;
5513
+ const entries = fs14.readdirSync(typePath, { withFileTypes: true });
5514
+ for (const entry of entries) {
5515
+ const fullPath = path16.join(typePath, entry.name);
5516
+ if (entry.isSymbolicLink()) {
5517
+ const target = path16.resolve(typePath, fs14.readlinkSync(fullPath));
5518
+ if (target.startsWith(resolvedSynapSync)) {
5519
+ symlinks.push(fullPath);
5520
+ }
5521
+ }
5530
5522
  }
5531
5523
  } catch {
5532
5524
  }
5533
5525
  }
5534
5526
  }
5535
- return removed;
5527
+ return symlinks;
5528
+ }
5529
+ function removeProviderSymlinks(projectRoot, synapSyncDir) {
5530
+ const symlinks = findSynapSyncSymlinks(projectRoot, synapSyncDir);
5531
+ for (const link of symlinks) {
5532
+ fs14.unlinkSync(link);
5533
+ logger.log(` ${pc16.red("\u2717")} Removed symlink ${path16.relative(projectRoot, link)}`);
5534
+ }
5535
+ return symlinks.length;
5536
5536
  }
5537
5537
  function cleanGitignore(projectRoot) {
5538
5538
  const gitignorePath = path16.join(projectRoot, ".gitignore");