claude-code-templates 1.0.0
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 +291 -0
- package/bin/create-claude-config.js +59 -0
- package/package.json +51 -0
- package/src/file-operations.js +66 -0
- package/src/index.js +81 -0
- package/src/prompts.js +110 -0
- package/src/templates.js +134 -0
- package/src/utils.js +172 -0
- package/templates/common/CLAUDE.md +109 -0
- package/templates/common/README.md +96 -0
- package/templates/javascript-typescript/.claude/commands/api-endpoint.md +1 -0
- package/templates/javascript-typescript/.claude/commands/debug.md +1 -0
- package/templates/javascript-typescript/.claude/commands/lint.md +1 -0
- package/templates/javascript-typescript/.claude/commands/npm-scripts.md +1 -0
- package/templates/javascript-typescript/.claude/commands/react-component.md +1 -0
- package/templates/javascript-typescript/.claude/commands/refactor.md +1 -0
- package/templates/javascript-typescript/.claude/commands/test.md +1 -0
- package/templates/javascript-typescript/.claude/commands/typescript-migrate.md +1 -0
- package/templates/javascript-typescript/.claude/hooks/format-on-save.json +1 -0
- package/templates/javascript-typescript/.claude/hooks/lint-on-save.json +1 -0
- package/templates/javascript-typescript/.claude/hooks/typescript-check.json +1 -0
- package/templates/javascript-typescript/.claude/settings.json +103 -0
- package/templates/javascript-typescript/CLAUDE.md +185 -0
- package/templates/javascript-typescript/README.md +233 -0
- package/templates/javascript-typescript/examples/node-api/.claude/commands/middleware.md +1 -0
- package/templates/javascript-typescript/examples/node-api/.claude/commands/route.md +1 -0
- package/templates/javascript-typescript/examples/node-api/CLAUDE.md +1 -0
- package/templates/javascript-typescript/examples/react-app/.claude/commands/component.md +1 -0
- package/templates/javascript-typescript/examples/react-app/.claude/commands/hooks.md +1 -0
- package/templates/javascript-typescript/examples/react-app/CLAUDE.md +1 -0
- package/templates/python/CLAUDE.md +276 -0
package/README.md
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# Claude Code Templates Installer
|
|
2
|
+
|
|
3
|
+
A CLI tool to quickly setup Claude Code configurations for different programming languages and frameworks. No installation required - just use `npx`!
|
|
4
|
+
|
|
5
|
+
## đ Quick Start
|
|
6
|
+
|
|
7
|
+
The fastest way to get started is with `npx` (no installation required):
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Navigate to your project directory
|
|
11
|
+
cd your-project
|
|
12
|
+
|
|
13
|
+
# Run the installer
|
|
14
|
+
npx create-claude-config
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## đ How to Use
|
|
18
|
+
|
|
19
|
+
### Step 1: Navigate to Your Project
|
|
20
|
+
```bash
|
|
21
|
+
cd your-project-directory
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Step 2: Run the Installer
|
|
25
|
+
```bash
|
|
26
|
+
npx create-claude-config
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Step 3: Follow the Interactive Setup
|
|
30
|
+
The installer will:
|
|
31
|
+
1. đ **Auto-detect** your project type (JavaScript, Python, etc.)
|
|
32
|
+
2. đ¯ **Ask about frameworks** (React, Django, Flask, etc.)
|
|
33
|
+
3. âī¸ **Let you choose features** (testing, linting, debugging)
|
|
34
|
+
4. â
**Confirm before installing**
|
|
35
|
+
|
|
36
|
+
### Step 4: Start Using Claude Code
|
|
37
|
+
```bash
|
|
38
|
+
claude
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## đĄ Usage Examples
|
|
42
|
+
|
|
43
|
+
### Interactive Setup (Recommended)
|
|
44
|
+
```bash
|
|
45
|
+
cd my-react-app
|
|
46
|
+
npx create-claude-config
|
|
47
|
+
# Follow the prompts - it will detect React automatically!
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Quick Setup for Specific Languages
|
|
51
|
+
```bash
|
|
52
|
+
# React project
|
|
53
|
+
cd my-react-app
|
|
54
|
+
npx create-claude-config --language javascript-typescript --framework react
|
|
55
|
+
|
|
56
|
+
# Python Django project
|
|
57
|
+
cd my-django-app
|
|
58
|
+
npx create-claude-config --language python --framework django
|
|
59
|
+
|
|
60
|
+
# Node.js API
|
|
61
|
+
cd my-api
|
|
62
|
+
npx create-claude-config --language javascript-typescript --framework node
|
|
63
|
+
|
|
64
|
+
# Generic Python project
|
|
65
|
+
cd my-python-project
|
|
66
|
+
npx create-claude-config --language python
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Advanced Options
|
|
70
|
+
```bash
|
|
71
|
+
# Skip all prompts and use defaults
|
|
72
|
+
npx create-claude-config --yes
|
|
73
|
+
|
|
74
|
+
# See what would be installed without actually installing
|
|
75
|
+
npx create-claude-config --dry-run
|
|
76
|
+
|
|
77
|
+
# Install to a different directory
|
|
78
|
+
npx create-claude-config --directory /path/to/project
|
|
79
|
+
|
|
80
|
+
# Get help
|
|
81
|
+
npx create-claude-config --help
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## đ Alternative Commands
|
|
85
|
+
|
|
86
|
+
All these commands work exactly the same way:
|
|
87
|
+
```bash
|
|
88
|
+
npx create-claude-config # â
Recommended (follows npm convention)
|
|
89
|
+
npx claude-code-templates # Package name
|
|
90
|
+
npx claude-init # Short alias
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## ⥠No Installation Required
|
|
94
|
+
|
|
95
|
+
**Why use `npx`?**
|
|
96
|
+
- â
Always gets the latest version
|
|
97
|
+
- â
No global installation needed
|
|
98
|
+
- â
Works on any machine with Node.js
|
|
99
|
+
- â
Follows npm best practices
|
|
100
|
+
|
|
101
|
+
If you prefer global installation:
|
|
102
|
+
```bash
|
|
103
|
+
npm install -g claude-code-templates
|
|
104
|
+
create-claude-config
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Supported Languages
|
|
108
|
+
|
|
109
|
+
- **Common** - Universal configuration for any project
|
|
110
|
+
- **JavaScript/TypeScript** - Modern JS/TS development with frameworks
|
|
111
|
+
- **Python** - Python development with popular frameworks
|
|
112
|
+
- **Rust** - Coming soon
|
|
113
|
+
- **Go** - Coming soon
|
|
114
|
+
|
|
115
|
+
## Supported Frameworks
|
|
116
|
+
|
|
117
|
+
### JavaScript/TypeScript
|
|
118
|
+
- React
|
|
119
|
+
- Vue.js
|
|
120
|
+
- Angular
|
|
121
|
+
- Node.js
|
|
122
|
+
|
|
123
|
+
### Python
|
|
124
|
+
- Django
|
|
125
|
+
- Flask
|
|
126
|
+
- FastAPI
|
|
127
|
+
|
|
128
|
+
## Features
|
|
129
|
+
|
|
130
|
+
- đ **Auto-detection** - Automatically detects your project type
|
|
131
|
+
- đ¯ **Framework-specific** - Includes framework-specific commands and configurations
|
|
132
|
+
- đž **Backup existing files** - Safely backs up existing CLAUDE.md and .claude directories
|
|
133
|
+
- âī¸ **Customizable** - Interactive prompts for feature selection
|
|
134
|
+
- đ **Quick setup** - Get started with Claude Code in seconds
|
|
135
|
+
|
|
136
|
+
## What Gets Installed
|
|
137
|
+
|
|
138
|
+
### Core Files
|
|
139
|
+
- `CLAUDE.md` - Main configuration file for Claude Code
|
|
140
|
+
- `.claude/settings.json` - Language-specific settings
|
|
141
|
+
- `.claude/commands/` - Custom commands for common tasks
|
|
142
|
+
- `.claude/hooks/` - Automated hooks for development workflow
|
|
143
|
+
|
|
144
|
+
### Language-Specific Commands
|
|
145
|
+
Each language template includes optimized commands for:
|
|
146
|
+
- Testing
|
|
147
|
+
- Linting and formatting
|
|
148
|
+
- Building and deployment
|
|
149
|
+
- Debugging
|
|
150
|
+
- Framework-specific operations
|
|
151
|
+
|
|
152
|
+
## đą What Happens During Setup
|
|
153
|
+
|
|
154
|
+
### Interactive Experience
|
|
155
|
+
```bash
|
|
156
|
+
$ npx create-claude-config
|
|
157
|
+
|
|
158
|
+
ââââââââââ ââââââ âââ ââââââââââ ââââââââ
|
|
159
|
+
âââââââââââ âââââââââââ âââââââââââââââââââ
|
|
160
|
+
âââ âââ âââââââââââ ââââââ âââââââââ
|
|
161
|
+
âââ âââ âââââââââââ ââââââ âââââââââ
|
|
162
|
+
âââââââââââââââââââ ââââââââââââââââââââââââââââ
|
|
163
|
+
ââââââââââââââââââ âââ âââââââ âââââââ ââââââââ
|
|
164
|
+
|
|
165
|
+
âââââââ âââââââ âââââââ ââââââââ
|
|
166
|
+
âââââââââââââââââââââââââââââââââ
|
|
167
|
+
âââ âââ ââââââ âââââââââ
|
|
168
|
+
âââ âââ ââââââ âââââââââ
|
|
169
|
+
âââââââââââââââââââââââââââââââââ
|
|
170
|
+
âââââââ âââââââ âââââââ ââââââââ
|
|
171
|
+
|
|
172
|
+
âââââââââââââââââââââ âââââââââââ âââ ââââââ âââââââââââââââââââââââââ
|
|
173
|
+
ââââââââââââââââââââââ ââââââââââââââââ âââââââââââââââââââââââââââââââââ
|
|
174
|
+
âââ ââââââ ââââââââââââââââââââââ ââââââââ âââ ââââââ ââââââââ
|
|
175
|
+
âââ ââââââ ââââââââââââââââââ âââ ââââââââ âââ ââââââ ââââââââ
|
|
176
|
+
âââ âââââââââââ âââ ââââââ âââââââââââ âââ âââ ââââââââââââââââ
|
|
177
|
+
âââ âââââââââââ ââââââ âââââââââââ âââ âââ ââââââââââââââââ
|
|
178
|
+
|
|
179
|
+
đ Setup Claude Code for any project language đ
|
|
180
|
+
|
|
181
|
+
đ Setting up Claude Code configuration...
|
|
182
|
+
Target directory: /path/to/your/project
|
|
183
|
+
â Project detection complete
|
|
184
|
+
đ¤ Select your programming language: (Use arrow keys)
|
|
185
|
+
⯠JavaScript/TypeScript
|
|
186
|
+
Python
|
|
187
|
+
Common (Language-agnostic)
|
|
188
|
+
Rust (Coming Soon)
|
|
189
|
+
Go (Coming Soon)
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Step-by-Step Walkthrough
|
|
193
|
+
|
|
194
|
+
1. **Project Detection** đĄ
|
|
195
|
+
```
|
|
196
|
+
â Project detection complete
|
|
197
|
+
```
|
|
198
|
+
- Scans your project for `package.json`, `requirements.txt`, etc.
|
|
199
|
+
- Auto-suggests the best language template
|
|
200
|
+
|
|
201
|
+
2. **Language Selection** đ¤
|
|
202
|
+
```
|
|
203
|
+
đ¤ Select your programming language: JavaScript/TypeScript
|
|
204
|
+
```
|
|
205
|
+
- Choose from available languages
|
|
206
|
+
- Auto-selected based on detection
|
|
207
|
+
|
|
208
|
+
3. **Framework Selection** đ¯
|
|
209
|
+
```
|
|
210
|
+
đ¯ Select your framework (optional): React
|
|
211
|
+
```
|
|
212
|
+
- Shows relevant frameworks for your language
|
|
213
|
+
- Auto-detected from dependencies
|
|
214
|
+
|
|
215
|
+
4. **Feature Selection** âī¸
|
|
216
|
+
```
|
|
217
|
+
âī¸ Select additional features:
|
|
218
|
+
â Enhanced testing commands
|
|
219
|
+
â Code linting and formatting
|
|
220
|
+
⯠Git hooks integration
|
|
221
|
+
⯠Debugging helpers
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
5. **Final Confirmation** đ
|
|
225
|
+
```
|
|
226
|
+
đ Setup Claude Code for javascript-typescript with react? (Y/n)
|
|
227
|
+
```
|
|
228
|
+
- Review your choices
|
|
229
|
+
- Type 'n' to cancel, 'y' or Enter to proceed
|
|
230
|
+
|
|
231
|
+
6. **Installation** đ
|
|
232
|
+
```
|
|
233
|
+
đ Existing CLAUDE.md backed up to CLAUDE.md.backup
|
|
234
|
+
â Copied javascript-typescript/CLAUDE.md â CLAUDE.md
|
|
235
|
+
â Copied javascript-typescript/.claude â .claude
|
|
236
|
+
â Copied react-specific commands â .claude/commands
|
|
237
|
+
â
Claude Code configuration setup complete!
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## đĄī¸ Safe Installation
|
|
241
|
+
|
|
242
|
+
- **Backup Protection**: Existing files are safely backed up
|
|
243
|
+
- **Confirmation Required**: Always asks before making changes
|
|
244
|
+
- **Dry Run Option**: Preview changes with `--dry-run`
|
|
245
|
+
- **Cancel Anytime**: Press Ctrl+C or answer 'No' to cancel
|
|
246
|
+
|
|
247
|
+
## CLI Options
|
|
248
|
+
|
|
249
|
+
| Option | Description | Example |
|
|
250
|
+
|--------|-------------|---------|
|
|
251
|
+
| `-l, --language` | Specify programming language | `--language python` |
|
|
252
|
+
| `-f, --framework` | Specify framework | `--framework react` |
|
|
253
|
+
| `-d, --directory` | Target directory | `--directory /path/to/project` |
|
|
254
|
+
| `-y, --yes` | Skip prompts and use defaults | `--yes` |
|
|
255
|
+
| `--dry-run` | Show what would be copied | `--dry-run` |
|
|
256
|
+
| `--help` | Show help information | `--help` |
|
|
257
|
+
|
|
258
|
+
## Development
|
|
259
|
+
|
|
260
|
+
### Setup
|
|
261
|
+
```bash
|
|
262
|
+
git clone https://github.com/your-username/claude-code-templates.git
|
|
263
|
+
cd claude-code-templates/cli-tool
|
|
264
|
+
npm install
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Testing
|
|
268
|
+
```bash
|
|
269
|
+
# Test locally
|
|
270
|
+
npm start
|
|
271
|
+
|
|
272
|
+
# Test with specific options
|
|
273
|
+
npm start -- --language python --framework django
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Publishing
|
|
277
|
+
```bash
|
|
278
|
+
npm publish
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Contributing
|
|
282
|
+
|
|
283
|
+
1. Fork the repository
|
|
284
|
+
2. Create a feature branch
|
|
285
|
+
3. Make your changes
|
|
286
|
+
4. Test thoroughly
|
|
287
|
+
5. Submit a pull request
|
|
288
|
+
|
|
289
|
+
## License
|
|
290
|
+
|
|
291
|
+
MIT License
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { program } = require('commander');
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
const boxen = require('boxen');
|
|
6
|
+
const createClaudeConfig = require('../src/index');
|
|
7
|
+
|
|
8
|
+
// ASCII Art for Claude Code Templates
|
|
9
|
+
const banner = chalk.cyan(`
|
|
10
|
+
ââââââââââ ââââââ âââ ââââââââââ ââââââââ
|
|
11
|
+
âââââââââââ âââââââââââ âââââââââââââââââââ
|
|
12
|
+
âââ âââ âââââââââââ ââââââ âââââââââ
|
|
13
|
+
âââ âââ âââââââââââ ââââââ âââââââââ
|
|
14
|
+
âââââââââââââââââââ ââââââââââââââââââââââââââââ
|
|
15
|
+
ââââââââââââââââââ âââ âââââââ âââââââ ââââââââ
|
|
16
|
+
|
|
17
|
+
âââââââ âââââââ âââââââ ââââââââ
|
|
18
|
+
âââââââââââââââââââââââââââââââââ
|
|
19
|
+
âââ âââ ââââââ âââââââââ
|
|
20
|
+
âââ âââ ââââââ âââââââââ
|
|
21
|
+
âââââââââââââââââââââââââââââââââ
|
|
22
|
+
âââââââ âââââââ âââââââ ââââââââ
|
|
23
|
+
|
|
24
|
+
âââââââââââââââââââââ âââââââââââ âââ ââââââ âââââââââââââââââââââââââ
|
|
25
|
+
ââââââââââââââââââââââ ââââââââââââââââ âââââââââââââââââââââââââââââââââ
|
|
26
|
+
âââ ââââââ ââââââââââââââââââââââ ââââââââ âââ ââââââ ââââââââ
|
|
27
|
+
âââ ââââââ ââââââââââââââââââ âââ ââââââââ âââ ââââââ ââââââââ
|
|
28
|
+
âââ âââââââââââ âââ ââââââ âââââââââââ âââ âââ ââââââââââââââââ
|
|
29
|
+
âââ âââââââââââ ââââââ âââââââââââ âââ âââ ââââââââââââââââ
|
|
30
|
+
`) + chalk.yellow(`
|
|
31
|
+
đ Setup Claude Code for any project language đ
|
|
32
|
+
`);
|
|
33
|
+
|
|
34
|
+
console.log(banner);
|
|
35
|
+
|
|
36
|
+
program
|
|
37
|
+
.name('create-claude-config')
|
|
38
|
+
.description('Setup Claude Code configurations for different programming languages')
|
|
39
|
+
.version('1.0.0')
|
|
40
|
+
.option('-l, --language <language>', 'specify programming language')
|
|
41
|
+
.option('-f, --framework <framework>', 'specify framework')
|
|
42
|
+
.option('-d, --directory <directory>', 'target directory (default: current directory)')
|
|
43
|
+
.option('-y, --yes', 'skip prompts and use defaults')
|
|
44
|
+
.option('--dry-run', 'show what would be copied without actually copying')
|
|
45
|
+
.action(async (options) => {
|
|
46
|
+
try {
|
|
47
|
+
await createClaudeConfig(options);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error(chalk.red('Error:'), error.message);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
program.parse(process.argv);
|
|
55
|
+
|
|
56
|
+
// Show help if no arguments provided
|
|
57
|
+
if (!process.argv.slice(2).length) {
|
|
58
|
+
program.outputHelp();
|
|
59
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "claude-code-templates",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI tool to setup Claude Code configurations for different programming languages",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-claude-config": "bin/create-claude-config.js",
|
|
8
|
+
"claude-code-templates": "bin/create-claude-config.js",
|
|
9
|
+
"claude-init": "bin/create-claude-config.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"start": "node bin/create-claude-config.js",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"claude",
|
|
17
|
+
"claude-code",
|
|
18
|
+
"ai",
|
|
19
|
+
"configuration",
|
|
20
|
+
"template",
|
|
21
|
+
"setup",
|
|
22
|
+
"cli"
|
|
23
|
+
],
|
|
24
|
+
"author": "Claude Code Templates",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"inquirer": "^8.2.6",
|
|
28
|
+
"chalk": "^4.1.2",
|
|
29
|
+
"fs-extra": "^11.1.1",
|
|
30
|
+
"commander": "^11.1.0",
|
|
31
|
+
"ora": "^5.4.1",
|
|
32
|
+
"boxen": "^5.1.2"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=14.0.0"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/danipower/claude-code-templates.git"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/danipower/claude-code-templates/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/danipower/claude-code-templates#readme",
|
|
45
|
+
"files": [
|
|
46
|
+
"bin/",
|
|
47
|
+
"src/",
|
|
48
|
+
"templates/",
|
|
49
|
+
"README.md"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const fs = require('fs-extra');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
|
|
5
|
+
async function copyTemplateFiles(templateConfig, targetDir) {
|
|
6
|
+
const templateDir = path.join(__dirname, '../templates');
|
|
7
|
+
|
|
8
|
+
// Check if CLAUDE.md already exists
|
|
9
|
+
const claudeFile = path.join(targetDir, 'CLAUDE.md');
|
|
10
|
+
if (await fs.pathExists(claudeFile)) {
|
|
11
|
+
// Create backup
|
|
12
|
+
const backupFile = path.join(targetDir, 'CLAUDE.md.backup');
|
|
13
|
+
await fs.copy(claudeFile, backupFile);
|
|
14
|
+
console.log(chalk.yellow(`đ Existing CLAUDE.md backed up to CLAUDE.md.backup`));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Check if .claude directory already exists
|
|
18
|
+
const claudeDir = path.join(targetDir, '.claude');
|
|
19
|
+
if (await fs.pathExists(claudeDir)) {
|
|
20
|
+
// Create backup
|
|
21
|
+
const backupDir = path.join(targetDir, '.claude.backup');
|
|
22
|
+
await fs.copy(claudeDir, backupDir);
|
|
23
|
+
console.log(chalk.yellow(`đ Existing .claude directory backed up to .claude.backup`));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Copy files
|
|
27
|
+
for (const file of templateConfig.files) {
|
|
28
|
+
const sourcePath = path.join(templateDir, file.source);
|
|
29
|
+
const destPath = path.join(targetDir, file.destination);
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
await fs.copy(sourcePath, destPath, { overwrite: true });
|
|
33
|
+
console.log(chalk.green(`â Copied ${file.source} â ${file.destination}`));
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error(chalk.red(`â Failed to copy ${file.source}:`), error.message);
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function ensureDirectoryExists(dirPath) {
|
|
42
|
+
try {
|
|
43
|
+
await fs.ensureDir(dirPath);
|
|
44
|
+
return true;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error(chalk.red(`Failed to create directory ${dirPath}:`), error.message);
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function checkWritePermissions(targetDir) {
|
|
52
|
+
try {
|
|
53
|
+
const testFile = path.join(targetDir, '.claude-test-write');
|
|
54
|
+
await fs.writeFile(testFile, 'test');
|
|
55
|
+
await fs.remove(testFile);
|
|
56
|
+
return true;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = {
|
|
63
|
+
copyTemplateFiles,
|
|
64
|
+
ensureDirectoryExists,
|
|
65
|
+
checkWritePermissions
|
|
66
|
+
};
|
package/src/index.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const inquirer = require('inquirer');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
const fs = require('fs-extra');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const ora = require('ora');
|
|
6
|
+
const { detectProject } = require('./utils');
|
|
7
|
+
const { getTemplateConfig } = require('./templates');
|
|
8
|
+
const { createPrompts } = require('./prompts');
|
|
9
|
+
const { copyTemplateFiles } = require('./file-operations');
|
|
10
|
+
|
|
11
|
+
async function createClaudeConfig(options = {}) {
|
|
12
|
+
const targetDir = options.directory || process.cwd();
|
|
13
|
+
|
|
14
|
+
console.log(chalk.blue('đ Setting up Claude Code configuration...'));
|
|
15
|
+
console.log(chalk.gray(`Target directory: ${targetDir}`));
|
|
16
|
+
|
|
17
|
+
// Detect existing project
|
|
18
|
+
const spinner = ora('Detecting project type...').start();
|
|
19
|
+
const projectInfo = await detectProject(targetDir);
|
|
20
|
+
spinner.succeed('Project detection complete');
|
|
21
|
+
|
|
22
|
+
// Create interactive prompts
|
|
23
|
+
const prompts = createPrompts(projectInfo, options);
|
|
24
|
+
|
|
25
|
+
let config;
|
|
26
|
+
if (options.yes) {
|
|
27
|
+
// Use defaults
|
|
28
|
+
config = {
|
|
29
|
+
language: options.language || projectInfo.detectedLanguage || 'common',
|
|
30
|
+
framework: options.framework || projectInfo.detectedFramework || 'none',
|
|
31
|
+
features: []
|
|
32
|
+
};
|
|
33
|
+
} else {
|
|
34
|
+
// Interactive prompts
|
|
35
|
+
config = await inquirer.prompt(prompts);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Check if user confirmed the setup
|
|
39
|
+
if (config.confirm === false) {
|
|
40
|
+
console.log(chalk.yellow('âšī¸ Setup cancelled by user.'));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Get template configuration
|
|
45
|
+
const templateConfig = getTemplateConfig(config);
|
|
46
|
+
|
|
47
|
+
if (options.dryRun) {
|
|
48
|
+
console.log(chalk.yellow('đ Dry run - showing what would be copied:'));
|
|
49
|
+
templateConfig.files.forEach(file => {
|
|
50
|
+
console.log(chalk.gray(` - ${file.source} â ${file.destination}`));
|
|
51
|
+
});
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Copy template files
|
|
56
|
+
const copySpinner = ora('Copying template files...').start();
|
|
57
|
+
try {
|
|
58
|
+
await copyTemplateFiles(templateConfig, targetDir);
|
|
59
|
+
copySpinner.succeed('Template files copied successfully');
|
|
60
|
+
} catch (error) {
|
|
61
|
+
copySpinner.fail('Failed to copy template files');
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Show success message
|
|
66
|
+
console.log(chalk.green('â
Claude Code configuration setup complete!'));
|
|
67
|
+
console.log(chalk.cyan('đ Next steps:'));
|
|
68
|
+
console.log(chalk.white(' 1. Review the generated CLAUDE.md file'));
|
|
69
|
+
console.log(chalk.white(' 2. Customize the configuration for your project'));
|
|
70
|
+
console.log(chalk.white(' 3. Start using Claude Code with: claude'));
|
|
71
|
+
|
|
72
|
+
if (config.language !== 'common') {
|
|
73
|
+
console.log(chalk.yellow(`đĄ Language-specific features for ${config.language} have been configured`));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (config.framework !== 'none') {
|
|
77
|
+
console.log(chalk.yellow(`đ¯ Framework-specific commands for ${config.framework} are available`));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
module.exports = createClaudeConfig;
|
package/src/prompts.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const { getAvailableLanguages, getFrameworksForLanguage } = require('./templates');
|
|
3
|
+
|
|
4
|
+
function createPrompts(projectInfo, options = {}) {
|
|
5
|
+
const prompts = [];
|
|
6
|
+
|
|
7
|
+
// Language selection
|
|
8
|
+
if (!options.language) {
|
|
9
|
+
const languages = getAvailableLanguages();
|
|
10
|
+
prompts.push({
|
|
11
|
+
type: 'list',
|
|
12
|
+
name: 'language',
|
|
13
|
+
message: 'Select your programming language:',
|
|
14
|
+
choices: languages,
|
|
15
|
+
default: projectInfo.detectedLanguage || 'common',
|
|
16
|
+
prefix: chalk.blue('đ¤')
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Framework selection (conditional)
|
|
21
|
+
if (!options.framework) {
|
|
22
|
+
prompts.push({
|
|
23
|
+
type: 'list',
|
|
24
|
+
name: 'framework',
|
|
25
|
+
message: 'Select your framework (optional):',
|
|
26
|
+
choices: (answers) => {
|
|
27
|
+
const selectedLanguage = answers.language || options.language;
|
|
28
|
+
const frameworks = getFrameworksForLanguage(selectedLanguage);
|
|
29
|
+
return [
|
|
30
|
+
{ value: 'none', name: 'None / Generic' },
|
|
31
|
+
...frameworks
|
|
32
|
+
];
|
|
33
|
+
},
|
|
34
|
+
default: projectInfo.detectedFramework || 'none',
|
|
35
|
+
prefix: chalk.green('đ¯'),
|
|
36
|
+
when: (answers) => {
|
|
37
|
+
const selectedLanguage = answers.language || options.language;
|
|
38
|
+
const frameworks = getFrameworksForLanguage(selectedLanguage);
|
|
39
|
+
return frameworks.length > 0;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Features selection
|
|
45
|
+
prompts.push({
|
|
46
|
+
type: 'checkbox',
|
|
47
|
+
name: 'features',
|
|
48
|
+
message: 'Select additional features:',
|
|
49
|
+
choices: [
|
|
50
|
+
{
|
|
51
|
+
value: 'git-hooks',
|
|
52
|
+
name: 'Git hooks integration',
|
|
53
|
+
checked: false
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
value: 'testing',
|
|
57
|
+
name: 'Enhanced testing commands',
|
|
58
|
+
checked: true
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
value: 'linting',
|
|
62
|
+
name: 'Code linting and formatting',
|
|
63
|
+
checked: true
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
value: 'debugging',
|
|
67
|
+
name: 'Debugging helpers',
|
|
68
|
+
checked: false
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
prefix: chalk.yellow('âī¸')
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Confirmation
|
|
75
|
+
prompts.push({
|
|
76
|
+
type: 'confirm',
|
|
77
|
+
name: 'confirm',
|
|
78
|
+
message: (answers) => {
|
|
79
|
+
const language = answers.language || options.language || 'common';
|
|
80
|
+
const framework = answers.framework || options.framework || 'none';
|
|
81
|
+
return `Setup Claude Code for ${chalk.cyan(language)}${framework !== 'none' ? ` with ${chalk.green(framework)}` : ''}?`;
|
|
82
|
+
},
|
|
83
|
+
default: true,
|
|
84
|
+
prefix: chalk.red('đ')
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return prompts;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function createProjectTypePrompt(detectedTypes) {
|
|
91
|
+
if (detectedTypes.length === 0) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
type: 'list',
|
|
97
|
+
name: 'projectType',
|
|
98
|
+
message: 'We detected multiple project types. Which one should we prioritize?',
|
|
99
|
+
choices: detectedTypes.map(type => ({
|
|
100
|
+
value: type.language,
|
|
101
|
+
name: `${type.language} (${type.confidence}% confidence)`
|
|
102
|
+
})),
|
|
103
|
+
prefix: chalk.magenta('đ')
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
module.exports = {
|
|
108
|
+
createPrompts,
|
|
109
|
+
createProjectTypePrompt
|
|
110
|
+
};
|