@majordigital/create-acorn 1.7.0 → 1.7.1

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 CHANGED
@@ -84,11 +84,39 @@ Every Acorn project ships with 10 specialised audit slash commands for Claude Co
84
84
 
85
85
  ### Adding audit commands to an existing project
86
86
 
87
+ The commands are included automatically in every new project. For existing projects:
88
+
87
89
  ```bash
90
+ # Full new project — audit commands included automatically
91
+ npx @majordigital/create-acorn@latest
92
+
93
+ # Add audit commands to an existing project (also refreshes outdated ones)
88
94
  npx @majordigital/create-acorn@latest --add-audit
95
+
96
+ # Check if installed audit commands are up to date (read-only)
97
+ npx @majordigital/create-acorn@latest --check-audit
98
+ ```
99
+
100
+ The `--add-audit` flag copies all 10 audit commands into the project's `.claude/commands/`. Re-running it refreshes any commands that changed in a newer package version — files that match the latest version are left untouched.
101
+
102
+ ### Checking if audit commands are up to date
103
+
104
+ Coming back to a project months later? Check whether the installed audit commands still match the latest package before running an audit:
105
+
106
+ ```bash
107
+ npx @majordigital/create-acorn@latest --check-audit
89
108
  ```
90
109
 
91
- The `--add-audit` flag copies all 10 audit commands into the project's `.claude/commands/`. It skips if they are already installed.
110
+ This is read-only it reports each command as missing, outdated, or up to date, and tells you to run `--add-audit` if anything needs updating:
111
+
112
+ ```
113
+ missing /audit-performance-metrics
114
+ outdated /audit-seo-semantic
115
+ Audit commands: 1 missing, 1 outdated, 8 up to date.
116
+
117
+ Run the following to update them:
118
+ npx @majordigital/create-acorn@latest --add-audit
119
+ ```
92
120
 
93
121
  ## Acorn Component Architecture
94
122
 
@@ -147,31 +147,72 @@ async function setupPreDeploy() {
147
147
  console.log('');
148
148
  }
149
149
 
150
- function setupAuditCommands() {
150
+ function compareAuditCommands() {
151
151
  const __dirname = dirname(fileURLToPath(import.meta.url));
152
152
  const commandsSrc = join(__dirname, '..', 'template', '.claude', 'commands');
153
153
  const commandsDest = join(process.cwd(), '.claude', 'commands');
154
154
 
155
155
  const auditFiles = readdirSync(commandsSrc).filter((f) => f.startsWith('audit-') && f.endsWith('.md'));
156
- if (auditFiles.length === 0) {
157
- console.log('Warning: No audit commands found in the package — skipping.');
156
+
157
+ const missing = [];
158
+ const outdated = [];
159
+ const current = [];
160
+ for (const file of auditFiles) {
161
+ const srcContent = readFileSync(join(commandsSrc, file), 'utf8');
162
+ const destPath = join(commandsDest, file);
163
+ if (!existsSync(destPath)) {
164
+ missing.push({ file, srcContent });
165
+ } else if (readFileSync(destPath, 'utf8') !== srcContent) {
166
+ outdated.push({ file, srcContent });
167
+ } else {
168
+ current.push({ file, srcContent });
169
+ }
170
+ }
171
+ return { commandsDest, missing, outdated, current, total: auditFiles.length };
172
+ }
173
+
174
+ function checkAuditCommands() {
175
+ const { missing, outdated, current, total } = compareAuditCommands();
176
+ if (total === 0) {
177
+ console.log('Warning: No audit commands found in the package.');
158
178
  return;
159
179
  }
160
180
 
161
- const alreadyInstalled = auditFiles.every((f) => existsSync(join(commandsDest, f)));
162
- if (alreadyInstalled) {
163
- console.log('Audit commands already installed — skipping.');
181
+ for (const { file } of missing) console.log(` missing /${file.replace(/\.md$/, '')}`);
182
+ for (const { file } of outdated) console.log(` outdated /${file.replace(/\.md$/, '')}`);
183
+
184
+ if (missing.length === 0 && outdated.length === 0) {
185
+ console.log(`All ${current.length} audit commands are up to date.`);
186
+ } else {
187
+ console.log(`Audit commands: ${missing.length} missing, ${outdated.length} outdated, ${current.length} up to date.`);
164
188
  console.log('');
189
+ console.log('Run the following to update them:');
190
+ console.log(' npx @majordigital/create-acorn@latest --add-audit');
191
+ }
192
+ console.log('');
193
+ }
194
+
195
+ function setupAuditCommands() {
196
+ const { commandsDest, missing, outdated, current, total } = compareAuditCommands();
197
+ if (total === 0) {
198
+ console.log('Warning: No audit commands found in the package — skipping.');
165
199
  return;
166
200
  }
167
201
 
168
202
  mkdirSync(commandsDest, { recursive: true });
169
- for (const file of auditFiles) {
170
- cpSync(join(commandsSrc, file), join(commandsDest, file), { force: true });
203
+
204
+ // Refresh behaviour: compare contents and overwrite stale files, so re-running
205
+ // `--add-audit` against a newer package version updates existing projects.
206
+ for (const { file, srcContent } of [...missing, ...outdated]) {
207
+ writeFileSync(join(commandsDest, file), srcContent);
171
208
  }
172
- console.log(`Copied ${auditFiles.length} audit commands to .claude/commands/:`);
173
- for (const file of auditFiles) {
174
- console.log(` /${file.replace(/\.md$/, '')}`);
209
+
210
+ if (missing.length === 0 && outdated.length === 0) {
211
+ console.log(`Audit commands already up to date (${current.length} unchanged).`);
212
+ } else {
213
+ for (const { file } of missing) console.log(` added /${file.replace(/\.md$/, '')}`);
214
+ for (const { file } of outdated) console.log(` updated /${file.replace(/\.md$/, '')}`);
215
+ console.log(`Audit commands: ${missing.length} added, ${outdated.length} updated, ${current.length} unchanged.`);
175
216
  }
176
217
  console.log('');
177
218
  }
@@ -1157,6 +1198,14 @@ async function main() {
1157
1198
  return;
1158
1199
  }
1159
1200
 
1201
+ // Read-only check — report whether installed audit commands match this package version
1202
+ if (argv.includes('--check-audit')) {
1203
+ console.log('Checking audit commands in the current project...');
1204
+ console.log('');
1205
+ checkAuditCommands();
1206
+ return;
1207
+ }
1208
+
1160
1209
  // Prompt for project name first
1161
1210
  const nameFromFlag = parseFlag('name');
1162
1211
  let projectDir = nameFromFlag;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@majordigital/create-acorn",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "Interactive starter CLI for Acorn with Storyblok/Prismic/DatoCMS, TypeScript, and Tailwind.",
5
5
  "bin": {
6
6
  "create-acorn": "bin/create-acorn.mjs",