claude-code-templates 1.4.1 → 1.4.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-templates",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "CLI tool to setup Claude Code configurations with framework-specific commands, automation hooks and MCP Servers for your projects",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -106,23 +106,23 @@ async function analyzeCommands(targetDir = process.cwd()) {
106
106
  */
107
107
  function displayCommandStats(analysis) {
108
108
  console.log(chalk.cyan('\nšŸ“Š Claude Code Command Analysis'));
109
- console.log(chalk.gray('═'.repeat(90)));
109
+ console.log(chalk.gray('═'.repeat(97)));
110
110
 
111
111
  if (!analysis.exists) {
112
112
  console.log(chalk.yellow('āš ļø ' + analysis.message));
113
113
  console.log(chalk.blue('\nšŸ’” Run the setup first: npx claude-code-templates'));
114
- return;
114
+ return false; // Indicate no .claude directory
115
115
  }
116
116
 
117
117
  if (analysis.error) {
118
118
  console.log(chalk.red('āŒ ' + analysis.error));
119
- return;
119
+ return false;
120
120
  }
121
121
 
122
122
  if (analysis.commands.length === 0) {
123
123
  console.log(chalk.yellow('āš ļø ' + analysis.message));
124
124
  console.log(chalk.blue('\nšŸ’” No commands found to analyze'));
125
- return;
125
+ return false; // Indicate no commands found
126
126
  }
127
127
 
128
128
  // Summary
@@ -137,18 +137,18 @@ function displayCommandStats(analysis) {
137
137
  'Size'.padEnd(7) +
138
138
  'Lines'.padEnd(6) +
139
139
  'Words'.padEnd(6) +
140
- 'Tokens'.padEnd(7) +
140
+ 'Tokens (aprox)'.padEnd(14) +
141
141
  'Last Modified'
142
142
  );
143
143
  console.log(header);
144
- console.log(chalk.gray('─'.repeat(90)));
144
+ console.log(chalk.gray('─'.repeat(97)));
145
145
 
146
146
  // Table rows
147
147
  analysis.commands.forEach(cmd => {
148
148
  const sizeFormatted = `${(cmd.size / 1024).toFixed(1)}KB`.padEnd(7);
149
149
  const linesFormatted = cmd.lines.toString().padEnd(6);
150
150
  const wordsFormatted = cmd.wordCount.toString().padEnd(6);
151
- const tokensFormatted = cmd.tokens.toString().padEnd(7);
151
+ const tokensFormatted = cmd.tokens.toString().padEnd(14);
152
152
  const dateFormatted = cmd.lastModified.toLocaleDateString();
153
153
 
154
154
  const row = chalk.white(cmd.name.padEnd(18)) +
@@ -161,8 +161,49 @@ function displayCommandStats(analysis) {
161
161
  console.log(row);
162
162
  });
163
163
 
164
- console.log(chalk.gray('─'.repeat(90)));
164
+ console.log(chalk.gray('─'.repeat(97)));
165
165
  console.log(chalk.bold(`Total: ${analysis.total} commands, ${totalSizeKB} KB, ~${totalTokens} tokens`));
166
+ return true; // Indicate commands were found and displayed
167
+ }
168
+
169
+ /**
170
+ * Prompts user to setup Claude Code Templates when no commands are found
171
+ * @param {string} targetDir - Project directory
172
+ */
173
+ async function promptSetupWhenNoCommands(targetDir) {
174
+ const inquirer = require('inquirer');
175
+
176
+ console.log(chalk.cyan('\nšŸš€ Claude Code Templates Setup'));
177
+ console.log(chalk.gray('No Claude Code commands found in this project. You can set up Claude Code Templates to get started.'));
178
+
179
+ try {
180
+ const { setupNow } = await inquirer.prompt([{
181
+ type: 'confirm',
182
+ name: 'setupNow',
183
+ message: 'Would you like to start the Claude Code Templates setup now?',
184
+ default: true,
185
+ prefix: chalk.blue('šŸ¤–')
186
+ }]);
187
+
188
+ if (!setupNow) {
189
+ console.log(chalk.yellow('ā­ļø Setup skipped. Run "npx claude-code-templates" anytime to set up your project.'));
190
+ return false;
191
+ }
192
+
193
+ console.log(chalk.blue('\nšŸš€ Starting Claude Code Templates setup...'));
194
+ console.log(chalk.gray('This will guide you through language and framework selection.\n'));
195
+
196
+ // Import and run the main setup function
197
+ const createClaudeConfig = require('./index');
198
+ await createClaudeConfig({ directory: targetDir });
199
+
200
+ return true;
201
+
202
+ } catch (error) {
203
+ console.error(chalk.red('Error during setup:'), error.message);
204
+ console.log(chalk.blue('šŸ’” You can run setup manually with: npx claude-code-templates'));
205
+ return false;
206
+ }
166
207
  }
167
208
 
168
209
  /**
@@ -269,7 +310,13 @@ async function runCommandStats(options = {}) {
269
310
  const analysis = await analyzeCommands(targetDir);
270
311
 
271
312
  // Display results
272
- displayCommandStats(analysis);
313
+ const hasCommands = displayCommandStats(analysis);
314
+
315
+ // If no commands found, offer to start setup
316
+ if (!hasCommands) {
317
+ await promptSetupWhenNoCommands(targetDir);
318
+ return;
319
+ }
273
320
 
274
321
  // Prompt for optimization
275
322
  await promptCommandOptimization(analysis, targetDir);
@@ -279,5 +326,6 @@ module.exports = {
279
326
  analyzeCommands,
280
327
  displayCommandStats,
281
328
  promptCommandOptimization,
329
+ promptSetupWhenNoCommands,
282
330
  runCommandStats
283
331
  };