fix(migration): run migration during install, not on first execution (v3.1.1)

Fixed:

- Migration now runs during installation across all methods (npm, bash, PowerShell)

- Guarantees ~/.ccs/shared/ populated immediately with ~/.claude/ content

- Users no longer need to run ccs command to trigger migration

Changed:

- Refactored SharedManager with _needsMigration() and _performMigration() methods

- _copyDirectory() returns {copied, skipped} stats and preserves existing files

- Shows detailed migration output: '[OK] Migrated 5 commands, 19 skills'

- Removed lazy migration from bin/ccs.js, lib/ccs, lib/ccs.ps1

Implementation:

- npm: Migration in scripts/postinstall.js

- bash: Migration in installers/install.sh (migrate_shared_data function)

- PowerShell: Migration in installers/install.ps1 (Invoke-SharedDataMigration)

- Fixed arithmetic expansion with set -e (changed ((var++)) to var=$((var + 1)))

Cross-platform parity maintained across all installation methods.
This commit is contained in:
kaitranntt
2025-11-10 21:05:55 -05:00
parent d925dfc169
commit 70471af1f8
10 changed files with 310 additions and 56 deletions
+12
View File
@@ -89,6 +89,18 @@ function createConfigFiles() {
}
}
// Migrate from ~/.claude/ to ~/.ccs/shared/ (v3.1.1)
console.log('');
try {
const SharedManager = require('../bin/shared-manager');
const sharedManager = new SharedManager();
sharedManager.migrateToSharedStructure();
} catch (err) {
console.warn('[!] Migration warning:', err.message);
console.warn(' You can manually copy files from ~/.claude/ to ~/.ccs/shared/');
}
console.log('');
// Create config.json if missing
const configPath = path.join(ccsDir, 'config.json');
if (!fs.existsSync(configPath)) {