tsc-app 3.2.6 → 4.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/LICENSE +21 -0
- package/README.md +350 -37
- package/dist/bin/cli.d.ts +3 -0
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +150 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/src/createApp.d.ts +4 -0
- package/dist/src/createApp.d.ts.map +1 -0
- package/dist/src/createApp.js +145 -0
- package/dist/src/createApp.js.map +1 -0
- package/dist/src/features/eslint.d.ts +4 -0
- package/dist/src/features/eslint.d.ts.map +1 -0
- package/dist/src/features/eslint.js +70 -0
- package/dist/src/features/eslint.js.map +1 -0
- package/dist/src/features/git.d.ts +5 -0
- package/dist/src/features/git.d.ts.map +1 -0
- package/dist/src/features/git.js +68 -0
- package/dist/src/features/git.js.map +1 -0
- package/dist/src/features/index.d.ts +8 -0
- package/dist/src/features/index.d.ts.map +1 -0
- package/dist/src/features/index.js +8 -0
- package/dist/src/features/index.js.map +1 -0
- package/dist/src/features/packageJson.d.ts +8 -0
- package/dist/src/features/packageJson.d.ts.map +1 -0
- package/dist/src/features/packageJson.js +164 -0
- package/dist/src/features/packageJson.js.map +1 -0
- package/dist/src/features/prettier.d.ts +4 -0
- package/dist/src/features/prettier.d.ts.map +1 -0
- package/dist/src/features/prettier.js +37 -0
- package/dist/src/features/prettier.js.map +1 -0
- package/dist/src/features/sourceFiles.d.ts +5 -0
- package/dist/src/features/sourceFiles.d.ts.map +1 -0
- package/dist/src/features/sourceFiles.js +145 -0
- package/dist/src/features/sourceFiles.js.map +1 -0
- package/dist/src/features/testing.d.ts +4 -0
- package/dist/src/features/testing.d.ts.map +1 -0
- package/dist/src/features/testing.js +143 -0
- package/dist/src/features/testing.js.map +1 -0
- package/dist/src/features/tsconfig.d.ts +4 -0
- package/dist/src/features/tsconfig.d.ts.map +1 -0
- package/dist/src/features/tsconfig.js +83 -0
- package/dist/src/features/tsconfig.js.map +1 -0
- package/dist/src/prompts.d.ts +5 -0
- package/dist/src/prompts.d.ts.map +1 -0
- package/dist/src/prompts.js +295 -0
- package/dist/src/prompts.js.map +1 -0
- package/dist/src/types.d.ts +62 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +25 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +141 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +51 -11
- package/index.js +0 -140
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 TamilVanan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,37 +1,350 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
A
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
my-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
# tsc-app
|
|
2
|
+
|
|
3
|
+
A fast, interactive **TypeScript project generator** for Node.js. Create production-ready TypeScript projects with a single command.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
7
|
+
│ │
|
|
8
|
+
│ npx tsc-app my-awesome-project │
|
|
9
|
+
│ │
|
|
10
|
+
│ ✓ TypeScript 5.7 with strict mode │
|
|
11
|
+
│ ✓ ESLint + Prettier configured │
|
|
12
|
+
│ ✓ Modern ES2022 target │
|
|
13
|
+
│ ✓ Fast development with tsx │
|
|
14
|
+
│ ✓ Ready in seconds! │
|
|
15
|
+
│ │
|
|
16
|
+
└─────────────────────────────────────────────────────────────┘
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
### Option 1: Interactive Mode (Recommended for Beginners)
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npx tsc-app my-project
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
You'll see prompts like this:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
tsc-app - TypeScript Project Generator
|
|
33
|
+
|
|
34
|
+
? Project name: my-project
|
|
35
|
+
? Module system: › ESM (ES Modules)
|
|
36
|
+
? Enable TypeScript strict mode? › Yes
|
|
37
|
+
? ECMAScript target: › ES2022 (Recommended)
|
|
38
|
+
? Source directory: › src
|
|
39
|
+
? Output directory: › dist
|
|
40
|
+
...
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Option 2: Quick Setup with Defaults
|
|
44
|
+
|
|
45
|
+
Skip all prompts and use sensible defaults:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx tsc-app my-project -y
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Option 3: Customize with Flags
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx tsc-app my-project --testing --test-runner vitest --build-tool tsup
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## What Gets Generated?
|
|
60
|
+
|
|
61
|
+
When you run `tsc-app`, it creates a complete project structure:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
my-project/
|
|
65
|
+
├── src/
|
|
66
|
+
│ └── index.ts # Your main TypeScript file
|
|
67
|
+
├── dist/ # Compiled JavaScript (after build)
|
|
68
|
+
├── package.json # Project dependencies & scripts
|
|
69
|
+
├── tsconfig.json # TypeScript configuration
|
|
70
|
+
├── eslint.config.js # ESLint rules (if enabled)
|
|
71
|
+
├── .prettierrc # Prettier formatting (if enabled)
|
|
72
|
+
├── .gitignore # Git ignore patterns
|
|
73
|
+
├── .editorconfig # Editor settings
|
|
74
|
+
├── .nvmrc # Node version (22)
|
|
75
|
+
└── README.md # Project documentation
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Step-by-Step Guide
|
|
81
|
+
|
|
82
|
+
### 1. Create Your Project
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npx tsc-app hello-typescript
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 2. Navigate to Project
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
cd hello-typescript
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 3. Start Development
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npm run dev
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
You'll see:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
Hello, World!
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 4. Make Changes
|
|
107
|
+
|
|
108
|
+
Edit `src/index.ts`:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
function greet(name: string): string {
|
|
112
|
+
return `Hello, ${name}!`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
console.log(greet('TypeScript')); // Output: Hello, TypeScript!
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The dev server auto-reloads when you save!
|
|
119
|
+
|
|
120
|
+
### 5. Build for Production
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npm run build
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 6. Run Production Build
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
npm start
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Available Scripts
|
|
135
|
+
|
|
136
|
+
| Script | Command | Description |
|
|
137
|
+
|--------|---------|-------------|
|
|
138
|
+
| **dev** | `npm run dev` | Start development with hot reload |
|
|
139
|
+
| **build** | `npm run build` | Compile TypeScript to JavaScript |
|
|
140
|
+
| **start** | `npm start` | Run the compiled code |
|
|
141
|
+
| **typecheck** | `npm run typecheck` | Check types without building |
|
|
142
|
+
| **lint** | `npm run lint` | Find code issues with ESLint |
|
|
143
|
+
| **lint:fix** | `npm run lint:fix` | Auto-fix ESLint issues |
|
|
144
|
+
| **format** | `npm run format` | Format code with Prettier |
|
|
145
|
+
| **test** | `npm test` | Run tests (if testing enabled) |
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Configuration Options
|
|
150
|
+
|
|
151
|
+
### Interactive Prompts
|
|
152
|
+
|
|
153
|
+
When you run `tsc-app` without `-y`, you'll be asked about:
|
|
154
|
+
|
|
155
|
+
| Option | Choices | Default |
|
|
156
|
+
|--------|---------|---------|
|
|
157
|
+
| Module System | ESM, CommonJS | ESM |
|
|
158
|
+
| Strict Mode | Yes, No | Yes |
|
|
159
|
+
| ES Target | ES2020, ES2021, ES2022, ESNext | ES2022 |
|
|
160
|
+
| Source Dir | Any folder name | src |
|
|
161
|
+
| Output Dir | Any folder name | dist |
|
|
162
|
+
| Declaration Files | Yes, No | Yes |
|
|
163
|
+
| Incremental Build | Yes, No | No |
|
|
164
|
+
| Path Aliases | Yes, No | No |
|
|
165
|
+
| ESLint | Yes, No | Yes |
|
|
166
|
+
| ESLint Config | Recommended, Strict | Recommended |
|
|
167
|
+
| Prettier | Yes, No | Yes |
|
|
168
|
+
| Testing | Yes, No | No |
|
|
169
|
+
| Test Runner | Vitest, Jest, Node | Vitest |
|
|
170
|
+
| Build Tool | tsc, tsup, esbuild | tsc |
|
|
171
|
+
| Dev Runner | tsx, ts-node, nodemon | tsx |
|
|
172
|
+
| Package Manager | npm, pnpm, yarn | npm |
|
|
173
|
+
| Initialize Git | Yes, No | Yes |
|
|
174
|
+
| Install Dependencies | Yes, No | Yes |
|
|
175
|
+
|
|
176
|
+
### Command Line Flags
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Basic usage
|
|
180
|
+
npx tsc-app <project-name> [options]
|
|
181
|
+
|
|
182
|
+
# Examples
|
|
183
|
+
npx tsc-app my-api -y # Use all defaults
|
|
184
|
+
npx tsc-app my-api --testing # Add testing
|
|
185
|
+
npx tsc-app my-api --build-tool tsup # Use tsup bundler
|
|
186
|
+
npx tsc-app my-api -p pnpm # Use pnpm
|
|
187
|
+
npx tsc-app my-api --no-eslint --no-prettier # Skip linting
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
All available flags:
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
-V, --version Show version
|
|
194
|
+
-m, --module <type> esm | commonjs (default: esm)
|
|
195
|
+
--strict / --no-strict TypeScript strict mode (default: true)
|
|
196
|
+
-t, --target <target> ES2020 | ES2021 | ES2022 | ESNext
|
|
197
|
+
--src-dir <dir> Source directory (default: src)
|
|
198
|
+
--out-dir <dir> Output directory (default: dist)
|
|
199
|
+
-d, --declaration Generate .d.ts files (default: true)
|
|
200
|
+
-i, --incremental Enable incremental builds
|
|
201
|
+
--aliases Enable path aliases (@/*)
|
|
202
|
+
--eslint / --no-eslint Add ESLint (default: true)
|
|
203
|
+
--eslint-config <type> recommended | strict
|
|
204
|
+
--prettier / --no-prettier Add Prettier (default: true)
|
|
205
|
+
--testing Add testing framework
|
|
206
|
+
--test-runner <runner> vitest | jest | node
|
|
207
|
+
-b, --build-tool <tool> tsc | tsup | esbuild
|
|
208
|
+
--dev-runner <runner> tsx | ts-node | nodemon
|
|
209
|
+
--git / --no-git Initialize git (default: true)
|
|
210
|
+
--install / --no-install Install dependencies (default: true)
|
|
211
|
+
-p, --package-manager <pm> npm | pnpm | yarn
|
|
212
|
+
-y, --yes Skip prompts, use defaults
|
|
213
|
+
-h, --help Show help
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Common Recipes
|
|
219
|
+
|
|
220
|
+
### API Server Project
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
npx tsc-app my-api --testing --test-runner vitest
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### CLI Tool
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
npx tsc-app my-cli --build-tool tsup
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Library/Package
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
npx tsc-app my-lib --declaration --build-tool tsup
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Fast Development Setup
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
npx tsc-app my-project --dev-runner tsx
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Minimal Setup
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
npx tsc-app my-project --no-eslint --no-prettier --no-git -y
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Understanding the Configuration
|
|
253
|
+
|
|
254
|
+
### TypeScript Strict Mode
|
|
255
|
+
|
|
256
|
+
When enabled (default), TypeScript catches more errors:
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
// With strict mode ON - Error! ✓
|
|
260
|
+
function greet(name: string) {
|
|
261
|
+
console.log(name.toUppercase()); // Error: 'toUppercase' doesn't exist
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Without strict mode - No error, crashes at runtime ✗
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### ESM vs CommonJS
|
|
268
|
+
|
|
269
|
+
| Feature | ESM (Modern) | CommonJS (Legacy) |
|
|
270
|
+
|---------|--------------|-------------------|
|
|
271
|
+
| Import syntax | `import x from 'y'` | `const x = require('y')` |
|
|
272
|
+
| Export syntax | `export { x }` | `module.exports = x` |
|
|
273
|
+
| Top-level await | ✓ Yes | ✗ No |
|
|
274
|
+
| Tree shaking | ✓ Yes | ✗ Limited |
|
|
275
|
+
| **Recommendation** | **Use this** | For older projects |
|
|
276
|
+
|
|
277
|
+
### Build Tools Comparison
|
|
278
|
+
|
|
279
|
+
| Tool | Speed | Features | Best For |
|
|
280
|
+
|------|-------|----------|----------|
|
|
281
|
+
| **tsc** | Slow | Type checking | Learning, simple projects |
|
|
282
|
+
| **tsup** | Fast | Bundling, tree-shaking | Libraries, CLI tools |
|
|
283
|
+
| **esbuild** | Fastest | Basic bundling | Speed-critical builds |
|
|
284
|
+
|
|
285
|
+
### Dev Runners Comparison
|
|
286
|
+
|
|
287
|
+
| Runner | Speed | ESM Support | Best For |
|
|
288
|
+
|--------|-------|-------------|----------|
|
|
289
|
+
| **tsx** | Fast | ✓ Native | Modern projects |
|
|
290
|
+
| **ts-node** | Medium | ✓ Via loader | Compatibility |
|
|
291
|
+
| **nodemon** | Slow | Via ts-node | File watching |
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Troubleshooting
|
|
296
|
+
|
|
297
|
+
### "Directory already exists"
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# Remove existing folder or choose a different name
|
|
301
|
+
rm -rf my-project
|
|
302
|
+
npx tsc-app my-project
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### "Module not found" errors
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
# Make sure dependencies are installed
|
|
309
|
+
cd my-project
|
|
310
|
+
npm install
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### ESLint errors after generation
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
# Run auto-fix
|
|
317
|
+
npm run lint:fix
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### TypeScript errors
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
# Check what's wrong
|
|
324
|
+
npm run typecheck
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Requirements
|
|
330
|
+
|
|
331
|
+
- **Node.js**: 22.0.0 or higher
|
|
332
|
+
- **npm/pnpm/yarn**: Any recent version
|
|
333
|
+
|
|
334
|
+
Check your Node version:
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
node --version # Should show v22.x.x or higher
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## License
|
|
343
|
+
|
|
344
|
+
MIT
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## Contributing
|
|
349
|
+
|
|
350
|
+
Issues and PRs welcome at [github.com/tamil202/ts-app](https://github.com/tamil202/ts-app)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../bin/cli.ts"],"names":[],"mappings":""}
|
package/dist/bin/cli.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import pc from 'picocolors';
|
|
4
|
+
import { createApp } from '../src/createApp.js';
|
|
5
|
+
import { collectConfig, confirmProceed, applyDefaults } from '../src/prompts.js';
|
|
6
|
+
import { printBanner, printSummary, validateProjectName, directoryExists, logError, } from '../src/utils.js';
|
|
7
|
+
const program = new Command();
|
|
8
|
+
program
|
|
9
|
+
.name('tsc-app')
|
|
10
|
+
.description('Interactive TypeScript + Node.js project generator')
|
|
11
|
+
.version('4.0.0')
|
|
12
|
+
.argument('[project-name]', 'Name of the project')
|
|
13
|
+
.option('-m, --module <type>', 'Module system: esm | commonjs', 'esm')
|
|
14
|
+
.option('--strict', 'Enable strict TypeScript mode', true)
|
|
15
|
+
.option('--no-strict', 'Disable strict TypeScript mode')
|
|
16
|
+
.option('-t, --target <target>', 'ECMAScript target: ES2020 | ES2021 | ES2022 | ESNext', 'ES2022')
|
|
17
|
+
.option('--src-dir <dir>', 'Source directory', 'src')
|
|
18
|
+
.option('--out-dir <dir>', 'Output directory', 'dist')
|
|
19
|
+
.option('-d, --declaration', 'Generate .d.ts files', true)
|
|
20
|
+
.option('--no-declaration', 'Do not generate .d.ts files')
|
|
21
|
+
.option('-i, --incremental', 'Enable incremental compilation')
|
|
22
|
+
.option('--aliases', 'Enable path aliases')
|
|
23
|
+
.option('--alias-prefix <prefix>', 'Path alias prefix', '@/*')
|
|
24
|
+
.option('--eslint', 'Add ESLint', true)
|
|
25
|
+
.option('--no-eslint', 'Skip ESLint')
|
|
26
|
+
.option('--eslint-config <type>', 'ESLint config: recommended | strict', 'recommended')
|
|
27
|
+
.option('--prettier', 'Add Prettier', true)
|
|
28
|
+
.option('--no-prettier', 'Skip Prettier')
|
|
29
|
+
.option('--testing', 'Add testing')
|
|
30
|
+
.option('--test-runner <runner>', 'Test runner: vitest | jest | node', 'vitest')
|
|
31
|
+
.option('-b, --build-tool <tool>', 'Build tool: tsc | tsup | esbuild', 'tsc')
|
|
32
|
+
.option('--dev-runner <runner>', 'Dev runner: tsx | ts-node | nodemon', 'tsx')
|
|
33
|
+
.option('--git', 'Initialize git repository', true)
|
|
34
|
+
.option('--no-git', 'Skip git initialization')
|
|
35
|
+
.option('--install', 'Install dependencies', true)
|
|
36
|
+
.option('--no-install', 'Skip dependency installation')
|
|
37
|
+
.option('-p, --package-manager <pm>', 'Package manager: npm | pnpm | yarn', 'npm')
|
|
38
|
+
.option('-y, --yes', 'Use defaults, skip prompts')
|
|
39
|
+
.action(async (projectName, options) => {
|
|
40
|
+
printBanner();
|
|
41
|
+
const flags = {
|
|
42
|
+
name: projectName,
|
|
43
|
+
module: parseModuleSystem(options.module),
|
|
44
|
+
strict: options.strict,
|
|
45
|
+
target: parseTarget(options.target),
|
|
46
|
+
srcDir: options.srcDir,
|
|
47
|
+
outDir: options.outDir,
|
|
48
|
+
declaration: options.declaration,
|
|
49
|
+
incremental: options.incremental,
|
|
50
|
+
aliases: options.aliases,
|
|
51
|
+
aliasPrefix: options.aliasPrefix,
|
|
52
|
+
eslint: options.eslint,
|
|
53
|
+
eslintConfig: parseEslintConfig(options.eslintConfig),
|
|
54
|
+
prettier: options.prettier,
|
|
55
|
+
testing: options.testing,
|
|
56
|
+
testRunner: parseTestRunner(options.testRunner),
|
|
57
|
+
buildTool: parseBuildTool(options.buildTool),
|
|
58
|
+
devRunner: parseDevRunner(options.devRunner),
|
|
59
|
+
git: options.git,
|
|
60
|
+
install: options.install,
|
|
61
|
+
packageManager: parsePackageManager(options.packageManager),
|
|
62
|
+
yes: options.yes,
|
|
63
|
+
};
|
|
64
|
+
// Validate project name if provided
|
|
65
|
+
if (flags.name) {
|
|
66
|
+
const validation = validateProjectName(flags.name);
|
|
67
|
+
if (!validation.valid) {
|
|
68
|
+
logError(validation.error || 'Invalid project name');
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
if (await directoryExists(flags.name)) {
|
|
72
|
+
logError(`Directory "${flags.name}" already exists`);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
let config;
|
|
77
|
+
if (flags.yes) {
|
|
78
|
+
// Use defaults with any provided flags
|
|
79
|
+
if (!flags.name) {
|
|
80
|
+
logError('Project name is required when using -y/--yes flag');
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
config = applyDefaults(flags);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// Interactive mode
|
|
87
|
+
config = await collectConfig(flags);
|
|
88
|
+
if (!config) {
|
|
89
|
+
process.exit(0);
|
|
90
|
+
}
|
|
91
|
+
// Show summary and confirm
|
|
92
|
+
printSummary(config);
|
|
93
|
+
const proceed = await confirmProceed();
|
|
94
|
+
if (!proceed) {
|
|
95
|
+
console.log(pc.yellow('\nOperation cancelled.'));
|
|
96
|
+
process.exit(0);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
console.log();
|
|
100
|
+
// Create the project
|
|
101
|
+
const success = await createApp(config);
|
|
102
|
+
process.exit(success ? 0 : 1);
|
|
103
|
+
});
|
|
104
|
+
function parseModuleSystem(value) {
|
|
105
|
+
const normalized = value.toLowerCase();
|
|
106
|
+
if (normalized === 'commonjs' || normalized === 'cjs') {
|
|
107
|
+
return 'commonjs';
|
|
108
|
+
}
|
|
109
|
+
return 'esm';
|
|
110
|
+
}
|
|
111
|
+
function parseTarget(value) {
|
|
112
|
+
const normalized = value.toUpperCase();
|
|
113
|
+
if (['ES2020', 'ES2021', 'ES2022', 'ESNEXT'].includes(normalized)) {
|
|
114
|
+
return normalized;
|
|
115
|
+
}
|
|
116
|
+
return 'ES2022';
|
|
117
|
+
}
|
|
118
|
+
function parseEslintConfig(value) {
|
|
119
|
+
return value === 'strict' ? 'strict' : 'recommended';
|
|
120
|
+
}
|
|
121
|
+
function parseTestRunner(value) {
|
|
122
|
+
const normalized = value.toLowerCase();
|
|
123
|
+
if (['vitest', 'jest', 'node'].includes(normalized)) {
|
|
124
|
+
return normalized;
|
|
125
|
+
}
|
|
126
|
+
return 'vitest';
|
|
127
|
+
}
|
|
128
|
+
function parseBuildTool(value) {
|
|
129
|
+
const normalized = value.toLowerCase();
|
|
130
|
+
if (['tsc', 'tsup', 'esbuild'].includes(normalized)) {
|
|
131
|
+
return normalized;
|
|
132
|
+
}
|
|
133
|
+
return 'tsc';
|
|
134
|
+
}
|
|
135
|
+
function parseDevRunner(value) {
|
|
136
|
+
const normalized = value.toLowerCase();
|
|
137
|
+
if (['ts-node', 'tsx', 'nodemon'].includes(normalized)) {
|
|
138
|
+
return normalized;
|
|
139
|
+
}
|
|
140
|
+
return 'tsx';
|
|
141
|
+
}
|
|
142
|
+
function parsePackageManager(value) {
|
|
143
|
+
const normalized = value.toLowerCase();
|
|
144
|
+
if (['npm', 'pnpm', 'yarn'].includes(normalized)) {
|
|
145
|
+
return normalized;
|
|
146
|
+
}
|
|
147
|
+
return 'npm';
|
|
148
|
+
}
|
|
149
|
+
program.parse();
|
|
150
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../bin/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EACL,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,eAAe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