claude-code-autoconfig 1.0.2 → 1.0.3
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/bin/cli.js +85 -7
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -43,10 +43,12 @@ if (!isClaudeInstalled()) {
|
|
|
43
43
|
|
|
44
44
|
console.log('\x1b[32m%s\x1b[0m', '✅ Claude Code detected');
|
|
45
45
|
|
|
46
|
-
// Step 2:
|
|
47
|
-
const
|
|
46
|
+
// Step 2: Backup existing .claude/ if present
|
|
47
|
+
const claudeDest = path.join(cwd, '.claude');
|
|
48
|
+
const SKIP_FILES = ['settings.local.json', 'retro', 'migration'];
|
|
49
|
+
let migrationPath = null;
|
|
48
50
|
|
|
49
|
-
function
|
|
51
|
+
function copyDirForBackup(src, dest) {
|
|
50
52
|
fs.mkdirSync(dest, { recursive: true });
|
|
51
53
|
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
52
54
|
|
|
@@ -57,16 +59,88 @@ function copyDir(src, dest) {
|
|
|
57
59
|
const destPath = path.join(dest, entry.name);
|
|
58
60
|
|
|
59
61
|
if (entry.isDirectory()) {
|
|
60
|
-
|
|
62
|
+
copyDirForBackup(srcPath, destPath);
|
|
61
63
|
} else {
|
|
62
64
|
fs.copyFileSync(srcPath, destPath);
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
if (fs.existsSync(claudeDest)) {
|
|
70
|
+
// Create timestamped backup
|
|
71
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
72
|
+
const migrationDir = path.join(claudeDest, 'migration');
|
|
73
|
+
migrationPath = path.join(migrationDir, timestamp);
|
|
74
|
+
|
|
75
|
+
fs.mkdirSync(migrationPath, { recursive: true });
|
|
76
|
+
|
|
77
|
+
// Copy existing files to backup (excluding migration folder itself)
|
|
78
|
+
const entries = fs.readdirSync(claudeDest, { withFileTypes: true });
|
|
79
|
+
for (const entry of entries) {
|
|
80
|
+
if (entry.name === 'migration') continue;
|
|
81
|
+
|
|
82
|
+
const srcPath = path.join(claudeDest, entry.name);
|
|
83
|
+
const destPath = path.join(migrationPath, entry.name);
|
|
84
|
+
|
|
85
|
+
if (entry.isDirectory()) {
|
|
86
|
+
copyDirForBackup(srcPath, destPath);
|
|
87
|
+
} else {
|
|
88
|
+
fs.copyFileSync(srcPath, destPath);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Create/update migration README
|
|
93
|
+
const readmePath = path.join(migrationDir, 'README.md');
|
|
94
|
+
const readmeContent = `# Migration Backups
|
|
95
|
+
|
|
96
|
+
This folder contains backups of previous .claude/ configurations created during autoconfig upgrades.
|
|
97
|
+
|
|
98
|
+
Each timestamped folder contains the files that existed before that migration.
|
|
99
|
+
|
|
100
|
+
## Backups
|
|
101
|
+
|
|
102
|
+
- \`${timestamp}/\` - Backup created during autoconfig install
|
|
103
|
+
|
|
104
|
+
## Restoring
|
|
105
|
+
|
|
106
|
+
To restore a previous configuration, copy files from the backup folder back to \`.claude/\`.
|
|
107
|
+
`;
|
|
108
|
+
|
|
109
|
+
// Append to existing README or create new
|
|
110
|
+
if (fs.existsSync(readmePath)) {
|
|
111
|
+
const existing = fs.readFileSync(readmePath, 'utf8');
|
|
112
|
+
const newEntry = `- \`${timestamp}/\` - Backup created during autoconfig install\n`;
|
|
113
|
+
if (!existing.includes(timestamp)) {
|
|
114
|
+
const updated = existing.replace('## Backups\n\n', `## Backups\n\n${newEntry}`);
|
|
115
|
+
fs.writeFileSync(readmePath, updated);
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
fs.writeFileSync(readmePath, readmeContent);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
console.log('\x1b[33m%s\x1b[0m', `⚠️ Existing .claude/ backed up to migration/${timestamp}/`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Step 3: Copy new files
|
|
68
125
|
const claudeSrc = path.join(packageDir, '.claude');
|
|
69
|
-
|
|
126
|
+
|
|
127
|
+
function copyDir(src, dest) {
|
|
128
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
129
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
130
|
+
|
|
131
|
+
for (const entry of entries) {
|
|
132
|
+
if (SKIP_FILES.includes(entry.name)) continue;
|
|
133
|
+
|
|
134
|
+
const srcPath = path.join(src, entry.name);
|
|
135
|
+
const destPath = path.join(dest, entry.name);
|
|
136
|
+
|
|
137
|
+
if (entry.isDirectory()) {
|
|
138
|
+
copyDir(srcPath, destPath);
|
|
139
|
+
} else {
|
|
140
|
+
fs.copyFileSync(srcPath, destPath);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
70
144
|
|
|
71
145
|
if (fs.existsSync(claudeSrc)) {
|
|
72
146
|
copyDir(claudeSrc, claudeDest);
|
|
@@ -81,6 +155,10 @@ const claudeMdSrc = path.join(packageDir, 'CLAUDE.md');
|
|
|
81
155
|
const claudeMdDest = path.join(cwd, 'CLAUDE.md');
|
|
82
156
|
|
|
83
157
|
if (fs.existsSync(claudeMdDest)) {
|
|
158
|
+
// Backup existing CLAUDE.md to migration folder if we have one
|
|
159
|
+
if (migrationPath) {
|
|
160
|
+
fs.copyFileSync(claudeMdDest, path.join(migrationPath, 'CLAUDE.md'));
|
|
161
|
+
}
|
|
84
162
|
console.log('\x1b[33m%s\x1b[0m', '⚠️ CLAUDE.md exists, saved template as CLAUDE.md.template');
|
|
85
163
|
fs.copyFileSync(claudeMdSrc, path.join(cwd, 'CLAUDE.md.template'));
|
|
86
164
|
} else if (fs.existsSync(claudeMdSrc)) {
|
|
@@ -88,7 +166,7 @@ if (fs.existsSync(claudeMdDest)) {
|
|
|
88
166
|
console.log('\x1b[32m%s\x1b[0m', '✅ Created CLAUDE.md');
|
|
89
167
|
}
|
|
90
168
|
|
|
91
|
-
// Step
|
|
169
|
+
// Step 4: Launch Claude Code
|
|
92
170
|
console.log();
|
|
93
171
|
console.log('\x1b[36m%s\x1b[0m', '🚀 Launching Claude Code...');
|
|
94
172
|
console.log('\x1b[33m%s\x1b[0m', ' Run /autoconfig to complete setup');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-autoconfig",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Intelligent, self-configuring setup for Claude Code. One command analyzes your project, configures Claude, and shows you what it did.",
|
|
5
5
|
"author": "ADAC 1001 <info@adac1001.com>",
|
|
6
6
|
"license": "MIT",
|