@jatinmourya/ng-init 1.2.9 → 1.2.10
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 +25 -152
- package/dist/cli.js +78 -228
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -19,14 +19,6 @@ A comprehensive command-line interface (CLI) tool designed to automate and strea
|
|
|
19
19
|
|
|
20
20
|
### Advanced Features
|
|
21
21
|
|
|
22
|
-
- **🎨 Pre-configured Project Templates**
|
|
23
|
-
- Basic SPA (Minimal setup)
|
|
24
|
-
- Enterprise (NgRx, Material, ESLint)
|
|
25
|
-
- PWA Ready (Service workers, offline support)
|
|
26
|
-
- Material Design (Angular Material components)
|
|
27
|
-
- Testing Ready (Jest, Testing Library)
|
|
28
|
-
- Standalone Components (Modern Angular)
|
|
29
|
-
|
|
30
22
|
- **🔍 Interactive Library Search & Installation**
|
|
31
23
|
- Real-time npm package search with autocomplete
|
|
32
24
|
- Package validation and metadata display
|
|
@@ -41,41 +33,6 @@ A comprehensive command-line interface (CLI) tool designed to automate and strea
|
|
|
41
33
|
- Displays compatibility warnings
|
|
42
34
|
- Caches npm responses for performance
|
|
43
35
|
|
|
44
|
-
- **📦 Popular Library Bundles**
|
|
45
|
-
- UI Framework Bundle (Material + CDK + Flex Layout)
|
|
46
|
-
- State Management Bundle (NgRx suite)
|
|
47
|
-
- Form & Validation Bundle
|
|
48
|
-
- Testing Bundle (Jest + Testing Library)
|
|
49
|
-
- Performance Bundle (Universal + optimization)
|
|
50
|
-
- Authentication Bundle (Firebase integration)
|
|
51
|
-
- Utilities Bundle (Lodash, date-fns, RxJS)
|
|
52
|
-
- HTTP & API Bundle
|
|
53
|
-
|
|
54
|
-
- **🔧 Configuration Presets**
|
|
55
|
-
- TypeScript strict mode
|
|
56
|
-
- ESLint + Prettier setup
|
|
57
|
-
- Husky pre-commit hooks
|
|
58
|
-
- Custom configurations
|
|
59
|
-
|
|
60
|
-
- **📁 Project Structure Generator**
|
|
61
|
-
- Standard Angular structure (core, shared, features)
|
|
62
|
-
- Domain-driven structure
|
|
63
|
-
- Automatic folder and file generation
|
|
64
|
-
|
|
65
|
-
- **🔐 Environment Configuration**
|
|
66
|
-
- Environment file templates
|
|
67
|
-
- Configuration management
|
|
68
|
-
|
|
69
|
-
- **🚀 Git Integration**
|
|
70
|
-
- Initialize repository
|
|
71
|
-
- Create .gitignore with Angular-specific entries
|
|
72
|
-
- Initial commit creation
|
|
73
|
-
|
|
74
|
-
- **📚 Documentation Generation**
|
|
75
|
-
- Auto-generate README.md
|
|
76
|
-
- CHANGELOG.md template
|
|
77
|
-
- Project structure documentation
|
|
78
|
-
|
|
79
36
|
- **💾 Profile Management**
|
|
80
37
|
- Save configurations as reusable profiles
|
|
81
38
|
- Load saved profiles for quick setup
|
|
@@ -121,10 +78,8 @@ This starts the interactive CLI that guides you through:
|
|
|
121
78
|
2. Angular version selection
|
|
122
79
|
3. Node.js compatibility check and resolution
|
|
123
80
|
4. Project configuration
|
|
124
|
-
5.
|
|
125
|
-
6.
|
|
126
|
-
7. Additional features setup
|
|
127
|
-
8. Profile saving option
|
|
81
|
+
5. Library search and installation
|
|
82
|
+
6. Profile saving option
|
|
128
83
|
|
|
129
84
|
### Check System Versions
|
|
130
85
|
|
|
@@ -184,16 +139,14 @@ ng-init examples
|
|
|
184
139
|
|
|
185
140
|
## 🎯 Usage Examples
|
|
186
141
|
|
|
187
|
-
### Example 1: Create
|
|
142
|
+
### Example 1: Create Project with Libraries
|
|
188
143
|
|
|
189
144
|
1. Run `ng-init`
|
|
190
145
|
2. Select Angular version 17
|
|
191
|
-
3.
|
|
146
|
+
3. Configure project options (routing, style, etc.)
|
|
192
147
|
4. Select "Interactive search" for libraries
|
|
193
|
-
5. Search and add
|
|
194
|
-
6.
|
|
195
|
-
7. Enable README generation
|
|
196
|
-
8. Save as profile for future use
|
|
148
|
+
5. Search and add packages like @angular/material, @ngrx/store
|
|
149
|
+
6. Save as profile for future use
|
|
197
150
|
|
|
198
151
|
### Example 2: Quick Setup with Saved Profile
|
|
199
152
|
|
|
@@ -203,15 +156,13 @@ ng-init examples
|
|
|
203
156
|
4. Confirm configuration
|
|
204
157
|
5. Project is created automatically
|
|
205
158
|
|
|
206
|
-
### Example 3:
|
|
159
|
+
### Example 3: Quick Project Setup
|
|
207
160
|
|
|
208
161
|
1. Run `ng-init`
|
|
209
162
|
2. Select latest Angular version
|
|
210
|
-
3.
|
|
211
|
-
4.
|
|
212
|
-
5.
|
|
213
|
-
6. Enable Husky hooks
|
|
214
|
-
7. Project created with complete testing setup
|
|
163
|
+
3. Configure project options
|
|
164
|
+
4. Skip library installation
|
|
165
|
+
5. Project created with basic Angular setup
|
|
215
166
|
|
|
216
167
|
## 📊 CLI Application Flow Diagram
|
|
217
168
|
|
|
@@ -269,26 +220,15 @@ flowchart TB
|
|
|
269
220
|
BB -->|"Custom"| DD["Enter custom path"]
|
|
270
221
|
CC --> EE["Project path confirmed"]
|
|
271
222
|
DD --> EE
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
FF -->|"Enterprise"| HH["NgRx + Material + ESLint"]
|
|
278
|
-
FF -->|"PWA Ready"| II["Service workers + offline"]
|
|
279
|
-
FF -->|"Material Design"| JJ["Angular Material components"]
|
|
280
|
-
FF -->|"Testing Ready"| KK["Jest + Testing Library"]
|
|
281
|
-
FF -->|"Standalone"| LL["Modern standalone components"]
|
|
282
|
-
FF -->|"Custom"| MM["Configure manually"]
|
|
283
|
-
MM --> NN["Enable routing?"]
|
|
284
|
-
NN --> OO["Select stylesheet format"]
|
|
285
|
-
OO --> PP["Enable strict mode?"]
|
|
286
|
-
PP --> QQ["Use standalone components?"]
|
|
287
|
-
GG & HH & II & JJ & KK & LL & QQ --> RR["Template configured"]
|
|
223
|
+
EE --> FF["Enable routing?"]
|
|
224
|
+
FF --> GG["Select stylesheet format"]
|
|
225
|
+
GG --> HH["Enable strict mode?"]
|
|
226
|
+
HH --> II["Use standalone components?"]
|
|
227
|
+
II --> JJ["Project configuration complete"]
|
|
288
228
|
end
|
|
289
229
|
|
|
290
230
|
subgraph LIBRARY["📚 Library Selection"]
|
|
291
|
-
|
|
231
|
+
JJ --> SS{"Library selection method?"}
|
|
292
232
|
SS -->|"Interactive Search"| TT["Search npm packages"]
|
|
293
233
|
TT --> UU["Select package"]
|
|
294
234
|
UU --> VV["Choose version method"]
|
|
@@ -303,26 +243,11 @@ flowchart TB
|
|
|
303
243
|
SS -->|"Manual Input"| CCC["Enter package names"]
|
|
304
244
|
CCC --> BBB
|
|
305
245
|
|
|
306
|
-
SS -->|"Library Bundles"| DDD["Select predefined bundles"]
|
|
307
|
-
DDD --> EEE["UI Framework / State Mgmt /<br/>Forms / Testing / etc."]
|
|
308
|
-
EEE --> BBB
|
|
309
|
-
|
|
310
246
|
SS -->|"Skip"| BBB
|
|
311
247
|
end
|
|
312
248
|
|
|
313
|
-
subgraph FEATURES["⚙️ Additional Features"]
|
|
314
|
-
BBB --> FFF["Select features"]
|
|
315
|
-
FFF --> GGG["☑️ Git initialization"]
|
|
316
|
-
FFF --> HHH["☑️ Project structure"]
|
|
317
|
-
FFF --> III["☑️ README.md"]
|
|
318
|
-
FFF --> JJJ["☐ CHANGELOG.md"]
|
|
319
|
-
FFF --> KKK["☐ ESLint + Prettier"]
|
|
320
|
-
FFF --> LLL["☐ Husky hooks"]
|
|
321
|
-
GGG & HHH & III & JJJ & KKK & LLL --> MMM["Features configured"]
|
|
322
|
-
end
|
|
323
|
-
|
|
324
249
|
subgraph SAVE["💾 Save Profile"]
|
|
325
|
-
|
|
250
|
+
BBB --> NNN{"Save as profile?"}
|
|
326
251
|
NNN -->|"Yes"| OOO["Enter profile name"]
|
|
327
252
|
OOO --> PPP["Profile saved"]
|
|
328
253
|
PPP --> QQQ["Display configuration summary"]
|
|
@@ -340,29 +265,7 @@ flowchart TB
|
|
|
340
265
|
UUU --> VVV["Resolve library versions"]
|
|
341
266
|
VVV --> WWW["Install additional libraries"]
|
|
342
267
|
WWW --> XXX["Run npm install"]
|
|
343
|
-
XXX -->
|
|
344
|
-
YYY -->|"Yes"| ZZZ["Create project folders & files"]
|
|
345
|
-
YYY -->|"No"| AAAA
|
|
346
|
-
ZZZ --> AAAA{"Git enabled?"}
|
|
347
|
-
AAAA -->|"Yes"| BBBB["Initialize Git repo"]
|
|
348
|
-
BBBB --> CCCC["Create .gitignore"]
|
|
349
|
-
AAAA -->|"No"| DDDD
|
|
350
|
-
CCCC --> DDDD{"README enabled?"}
|
|
351
|
-
DDDD -->|"Yes"| EEEE["Generate README.md"]
|
|
352
|
-
DDDD -->|"No"| FFFF
|
|
353
|
-
EEEE --> FFFF{"Changelog enabled?"}
|
|
354
|
-
FFFF -->|"Yes"| GGGG["Generate CHANGELOG.md"]
|
|
355
|
-
FFFF -->|"No"| HHHH
|
|
356
|
-
GGGG --> HHHH{"ESLint enabled?"}
|
|
357
|
-
HHHH -->|"Yes"| IIII["Setup ESLint + Prettier"]
|
|
358
|
-
HHHH -->|"No"| JJJJ
|
|
359
|
-
IIII --> JJJJ{"Husky enabled?"}
|
|
360
|
-
JJJJ -->|"Yes"| KKKK["Setup Husky hooks"]
|
|
361
|
-
JJJJ -->|"No"| LLLL
|
|
362
|
-
KKKK --> LLLL{"Git enabled?"}
|
|
363
|
-
LLLL -->|"Yes"| MMMM["Create initial commit"]
|
|
364
|
-
LLLL -->|"No"| NNNN
|
|
365
|
-
MMMM --> NNNN["🎉 Success!"]
|
|
268
|
+
XXX --> NNNN["🎉 Success!"]
|
|
366
269
|
end
|
|
367
270
|
|
|
368
271
|
subgraph END["🏁 Complete"]
|
|
@@ -377,9 +280,7 @@ flowchart TB
|
|
|
377
280
|
style ANGULAR fill:#fff3e0
|
|
378
281
|
style NODE fill:#ffebee
|
|
379
282
|
style PROJECT fill:#e8f5e9
|
|
380
|
-
style TEMPLATE fill:#fce4ec
|
|
381
283
|
style LIBRARY fill:#e0f2f1
|
|
382
|
-
style FEATURES fill:#fff8e1
|
|
383
284
|
style SAVE fill:#f3e5f5
|
|
384
285
|
style CONFIRM fill:#e8eaf6
|
|
385
286
|
style CREATE fill:#e3f2fd
|
|
@@ -396,13 +297,11 @@ flowchart TB
|
|
|
396
297
|
| 4 | **Angular Version** | Three-tier selection: Major → Minor → Patch version |
|
|
397
298
|
| 5 | **Node.js Check** | Validates and resolves Node.js compatibility |
|
|
398
299
|
| 6 | **Project Setup** | Configure project name and location |
|
|
399
|
-
| 7 | **
|
|
400
|
-
| 8 | **
|
|
401
|
-
| 9 | **
|
|
402
|
-
| 10 | **
|
|
403
|
-
| 11 | **
|
|
404
|
-
| 12 | **Create** | Execute all selected operations |
|
|
405
|
-
| 13 | **Complete** | Display success message and next steps |
|
|
300
|
+
| 7 | **Libraries** | Interactive search or manual input |
|
|
301
|
+
| 8 | **Save Profile** | Optionally save configuration for reuse |
|
|
302
|
+
| 9 | **Confirm** | Review summary and confirm creation |
|
|
303
|
+
| 10 | **Create** | Execute all selected operations |
|
|
304
|
+
| 11 | **Complete** | Display success message and next steps |
|
|
406
305
|
|
|
407
306
|
## 🏗️ Project Structure
|
|
408
307
|
|
|
@@ -419,39 +318,13 @@ ng-init/
|
|
|
419
318
|
│ │ ├── prompt-handler.js # Interactive prompts
|
|
420
319
|
│ │ ├── file-utils.js # File operations
|
|
421
320
|
│ │ └── profile-manager.js # Profile management
|
|
422
|
-
│ └── templates/ #
|
|
423
|
-
│ └── templates.js # Template definitions
|
|
321
|
+
│ └── templates/ # Configuration templates (disabled)
|
|
322
|
+
│ └── templates.js # Template definitions (all features disabled)
|
|
424
323
|
├── build.js # Build script for production
|
|
425
324
|
├── package.json
|
|
426
325
|
└── README.md
|
|
427
326
|
```
|
|
428
327
|
|
|
429
|
-
## 🔧 Configuration
|
|
430
|
-
|
|
431
|
-
### Project Templates
|
|
432
|
-
|
|
433
|
-
The CLI includes several pre-configured templates:
|
|
434
|
-
|
|
435
|
-
- **basic**: Minimal Angular setup with routing
|
|
436
|
-
- **enterprise**: Complete setup with NgRx, Material, ESLint
|
|
437
|
-
- **pwa**: Progressive Web App ready
|
|
438
|
-
- **material**: Angular Material UI components
|
|
439
|
-
- **testing**: Jest and Testing Library setup
|
|
440
|
-
- **standalone**: Modern standalone components
|
|
441
|
-
|
|
442
|
-
### Library Bundles
|
|
443
|
-
|
|
444
|
-
Pre-configured library combinations for common use cases:
|
|
445
|
-
|
|
446
|
-
- **uiFramework**: Angular Material suite
|
|
447
|
-
- **stateManagement**: NgRx complete setup
|
|
448
|
-
- **forms**: Form utilities and validators
|
|
449
|
-
- **testing**: Complete testing stack
|
|
450
|
-
- **performance**: Optimization tools
|
|
451
|
-
- **authentication**: Auth integration
|
|
452
|
-
- **utilities**: Common utility libraries
|
|
453
|
-
- **http**: HTTP and API tools
|
|
454
|
-
|
|
455
328
|
## 🤝 Contributing
|
|
456
329
|
|
|
457
330
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
package/dist/cli.js
CHANGED
|
@@ -1,244 +1,94 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
`))
|
|
5
|
-
`)
|
|
6
|
-
|
|
7
|
-
`)
|
|
8
|
-
|
|
9
|
-
`)
|
|
10
|
-
`)
|
|
11
|
-
\u{1F4DA} NVM Installation Guide
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Steps:`)),e.steps.forEach((n,t)=>{console.log(d.gray(` ${t+1}. ${n}`))})),Array.isArray(e.postInstall)&&(console.log(d.white(`
|
|
16
|
-
Post-Install:`)),e.postInstall.forEach((n,t)=>{console.log(d.gray(` ${t+1}. ${n}`))})),console.log(d.gray("\u2501".repeat(50))),console.log(d.yellow(`
|
|
17
|
-
\u{1F4A1} Why use NVM?`)),console.log(d.gray(" \u2022 Manage multiple Node.js versions")),console.log(d.gray(" \u2022 Switch instantly")),console.log(d.gray(" \u2022 No sudo/admin required")),console.log(d.gray(` \u2022 Per-project Node versions
|
|
18
|
-
`))}s(Je,"displayNvmInstallGuide");async function J(e,n,t=!1){let r=te(`Installing ${e.length} package(s)...`).start();try{let o=["install"];return t&&o.push("--save-dev"),o.push(...e),await O("npm",o,{cwd:n}),r.succeed("Packages installed successfully"),!0}catch{r.warn("Failed with strict dependencies, retrying with --legacy-peer-deps...");try{let l=["install","--legacy-peer-deps"];return t&&l.push("--save-dev"),l.push(...e),await O("npm",l,{cwd:n}),r.succeed("Packages installed successfully with --legacy-peer-deps"),console.log(d.yellow("\u26A0\uFE0F Note: Installed with --legacy-peer-deps flag due to peer dependency conflicts")),!0}catch(l){return r.fail("Failed to install packages"),console.error(d.red(l.message)),console.log(d.yellow(`
|
|
19
|
-
\u{1F4A1} Tip: You can try installing manually with:`)),console.log(d.cyan(` cd ${n}`)),console.log(d.cyan(` npm install ${e.join(" ")} --force`)),!1}}}s(J,"installPackages");async function We(e){let n=te("Installing dependencies...").start();try{return await O("npm",["install"],{cwd:e}),n.succeed("Dependencies installed successfully"),!0}catch{n.warn("Failed with strict dependencies, retrying with --legacy-peer-deps...");try{return await O("npm",["install","--legacy-peer-deps"],{cwd:e}),n.succeed("Dependencies installed successfully with --legacy-peer-deps"),console.log(d.yellow("\u26A0\uFE0F Note: Installed with --legacy-peer-deps flag due to peer dependency conflicts")),!0}catch(r){return n.fail("Failed to install dependencies"),console.error(d.red(r.message)),console.log(d.yellow(`
|
|
20
|
-
\u{1F4A1} Tip: You can try installing manually with:`)),console.log(d.cyan(` cd ${e}`)),console.log(d.cyan(" npm install --force")),!1}}}s(We,"runNpmInstall");async function ze(e,n,t={}){let r=te(`Creating Angular project: ${e}...`).start();try{let o=["new",e];t.skipInstall&&o.push("--skip-install"),t.routing!==void 0&&o.push(`--routing=${t.routing}`),t.style&&o.push(`--style=${t.style}`),t.strict!==void 0&&o.push(`--strict=${t.strict}`),t.standalone!==void 0&&o.push(`--standalone=${t.standalone}`);let l=n?`@angular/cli@${n}`:"@angular/cli";return await O("npx",[l,...o],{stdio:"inherit"}),r.succeed(`Angular project ${e} created successfully`),!0}catch(o){return r.fail("Failed to create Angular project"),console.error(d.red(o.message)),!1}}s(ze,"createAngularProject");import{search as Et,select as _,input as ge,confirm as W}from"@inquirer/prompts";import y from"chalk";async function Be(e=null){let n=[],t=!0;for(console.log(y.bold.cyan(`
|
|
2
|
+
var $e=Object.defineProperty;var a=(e,t)=>$e(e,"name",{value:t,configurable:!0});var xe=(e,t)=>()=>(e&&(t=e(e=0)),t);var Pe=(e,t)=>{for(var r in t)$e(e,r,{get:t[r],enumerable:!0})};var Y={};Pe(Y,{default:()=>pt,printKeyValue:()=>N,printObjectList:()=>C,printSimpleTable:()=>Ce});import Ve from"cli-table3";import H from"chalk";function N(e,t=[]){e&&console.log(H.bold.cyan(`
|
|
3
|
+
${e}
|
|
4
|
+
`));let r=new Ve({head:["Field","Value"],style:{head:["cyan"]}});t.forEach(([n,o])=>r.push([n,o])),console.log(r.toString()+`
|
|
5
|
+
`)}function C(e,t=[],r=[]){if(!Array.isArray(t)||t.length===0){console.log(H.yellow(`No ${e||"items"} to display.`));return}e&&console.log(H.bold.cyan(`
|
|
6
|
+
${e}
|
|
7
|
+
`));let n=new Ve({head:r,style:{head:["cyan"]}});t.forEach(o=>{let i=r.map(s=>o[s]!==void 0?String(o[s]):"");n.push(i)}),console.log(n.toString()+`
|
|
8
|
+
`)}function Ce(e,t=[]){if(!Array.isArray(t)||t.length===0){console.log(H.yellow(`No ${e||"items"} to display.`));return}let r=Object.keys(t[0]);C(e,t,r)}var pt,S=xe(()=>{a(N,"printKeyValue");a(C,"printObjectList");a(Ce,"printSimpleTable");pt={printKeyValue:N,printObjectList:C,printSimpleTable:Ce}});var je={};Pe(je,{compareVersions:()=>mt,displaySystemVersions:()=>ue,getAngularCliVersion:()=>Se,getAvailableNodeVersions:()=>dt,getInstalledNodeVersions:()=>pe,getNodeVersion:()=>B,getNpmVersion:()=>Ne,getNvmVersion:()=>le,installNodeVersion:()=>de,isNvmInstalled:()=>ce,satisfiesVersion:()=>gt,switchNodeVersion:()=>X});import{execa as D}from"execa";import"chalk";import ke from"semver";async function B(){try{let{stdout:e}=await D("node",["--version"]);return e.trim().replace("v","")}catch{return null}}async function Ne(){try{let{stdout:e}=await D("npm",["--version"]);return e.trim()}catch{return null}}async function le(){try{let{stdout:e}=await D("nvm",["--version"],{shell:!0});return e.trim()}catch{return null}}async function ce(){return await le()!==null}async function Se(){try{let{stdout:e}=await D("ng",["--version"],{shell:!0});return e.trim()||null}catch{return null}}async function ue(){let e=await B(),t=await Ne(),r=await le(),n=await Se(),o=null;if(n){let s=n.match(/(\d+\.\d+\.\d+)/);o=s?s[1]:n.split(`
|
|
9
|
+
`)[0]||null}let i=[{Tool:"Node.js",Version:e?`${e}`:"Not installed"},{Tool:"npm",Version:t?`${t}`:"Not installed"},{Tool:"nvm",Version:r?`${r}`:"Not installed"},{Tool:"Angular CLI",Version:o?`${o}`:"Not installed"}];try{let s=i.map(c=>({Tool:c.Tool,Version:c.Version}));C("\u{1F50D} System Environment Check",s,["Tool","Version"])}catch{console.table(i)}return{node:e,npm:t,nvm:r,angularCli:o}}async function dt(){try{let{stdout:e}=await D("nvm",["list","available"],{shell:!0}),t=[],r=e.split(`
|
|
10
|
+
`);for(let n of r){let o=n.match(/(\d+\.\d+\.\d+)/);o&&t.push(o[1])}return t}catch{return[]}}async function pe(){try{let{stdout:e}=await D("nvm",["list"],{shell:!0}),t=[],r=e.split(`
|
|
11
|
+
`);for(let n of r){let o=n.match(/(\d+\.\d+\.\d+)/);o&&t.push(o[1])}return t}catch{return[]}}async function X(e){try{return await D("nvm",["use",e],{shell:!0,stdio:"inherit"}),!0}catch{return!1}}async function de(e){try{return await D("nvm",["install",e],{shell:!0,stdio:"inherit"}),!0}catch{return!1}}function mt(e,t){return ke.compare(e,t)}function gt(e,t){return ke.satisfies(e,t)}var me=xe(()=>{S();a(B,"getNodeVersion");a(Ne,"getNpmVersion");a(le,"getNvmVersion");a(ce,"isNvmInstalled");a(Se,"getAngularCliVersion");a(ue,"displaySystemVersions");a(dt,"getAvailableNodeVersions");a(pe,"getInstalledNodeVersions");a(X,"switchNodeVersion");a(de,"installNodeVersion");a(mt,"compareVersions");a(gt,"satisfiesVersion")});import{Command as zt}from"commander";me();import{select as F,input as ve,confirm as E}from"@inquirer/prompts";import l from"chalk";import It from"path";import T from"axios";import ft from"chalk";import yt from"lodash.debounce";var Z="https://registry.npmjs.org",ht="https://registry.npmjs.org/-/v1/search",wt="https://api.npmjs.org/downloads/point/last-week";async function ge(e,t=10){try{return(await T.get(ht,{params:{text:e,size:t},timeout:5e3})).data.objects.map(n=>({name:n.package.name,version:n.package.version,description:n.package.description||"No description",author:n.package.publisher?.username||"Unknown",date:n.package.date,verified:n.package.publisher?.verified||!1}))}catch(r){return console.error("Error searching npm packages:",r.message),[]}}a(ge,"searchNpmPackages");async function vt(e){try{let t=await T.get(`${Z}/${e}`,{timeout:5e3}),r=t.data["dist-tags"]?.latest,n=Object.keys(t.data.versions||{});return{name:t.data.name,description:t.data.description||"No description",latestVersion:r,versions:n,homepage:t.data.homepage,repository:t.data.repository,license:t.data.license,keywords:t.data.keywords||[]}}catch(t){if(t.response?.status===404)return null;throw t}}a(vt,"getPackageDetails");async function bt(e){try{return(await T.get(`${wt}/${e}`,{timeout:5e3})).data.downloads}catch{return 0}}a(bt,"getPackageDownloads");async function Le(e){try{let[t,r]=await Promise.all([vt(e),bt(e)]);return t?{...t,weeklyDownloads:r}:null}catch(t){return console.error(`Error getting package info for ${e}:`,t.message),null}}a(Le,"getEnhancedPackageInfo");function fe(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}a(fe,"formatDownloads");var lr=yt(async(e,t)=>{if(!e||e.length<2){t([]);return}let r=await ge(e,10);t(r)},300);async function Ie(){try{let e=await T.get(`${Z}/@angular/cli`,{timeout:1e4}),t=Object.keys(e.data.versions||{}).filter(n=>!n.includes("rc")&&!n.includes("beta")&&!n.includes("next")).sort((n,o)=>{let i=n.split(".").map(Number),s=o.split(".").map(Number);for(let c=0;c<Math.max(i.length,s.length);c++){let d=i[c]||0,u=s[c]||0;if(d!==u)return u-d}return 0}),r=e.data["dist-tags"]||{};return{versions:t,latest:r.latest,lts:r.lts}}catch(e){return console.error("Error fetching Angular versions:",e.message),{versions:[],latest:null,lts:null}}}a(Ie,"getAngularVersions");function Q(e){let t=new Set;return e.forEach(r=>{let n=r.split(".")[0];t.add(n)}),Array.from(t).sort((r,n)=>Number(n)-Number(r))}a(Q,"getMajorVersions");function ee(e,t){let r=new Set;return e.filter(n=>n.startsWith(`${t}.`)).forEach(n=>{let o=n.split("."),i=`${o[0]}.${o[1]}`;r.add(i)}),Array.from(r).sort((n,o)=>{let i=n.split(".").map(Number),s=o.split(".").map(Number);for(let c=0;c<Math.max(i.length,s.length);c++){let d=i[c]||0,u=s[c]||0;if(d!==u)return u-d}return 0})}a(ee,"getMinorVersionsForMajor");function te(e,t){return e.filter(r=>r.startsWith(`${t}.`)).sort((r,n)=>{let o=r.split(".").map(Number),i=n.split(".").map(Number);for(let s=0;s<Math.max(o.length,i.length);s++){let c=o[s]||0,d=i[s]||0;if(c!==d)return d-c}return 0})}a(te,"getPatchVersionsForMinor");async function De(e){try{let t=await T.get(`${Z}/${e}`,{timeout:1e4}),r=Object.keys(t.data.versions||{}).filter(o=>!o.includes("rc")&&!o.includes("beta")&&!o.includes("next")&&!o.includes("alpha")).sort((o,i)=>{let s=o.split(".").map(Number),c=i.split(".").map(Number);for(let d=0;d<Math.max(s.length,c.length);d++){let u=s[d]||0,$=c[d]||0;if(u!==$)return $-u}return 0}),n=t.data["dist-tags"]||{};return{versions:r,latest:n.latest,lts:n.lts}}catch(t){return console.error(`Error fetching versions for ${e}:`,t.message),{versions:[],latest:null,lts:null}}}a(De,"getPackageVersions");async function Fe(e){try{let r=(await T.get(`${Z}/@angular/cli/${e}`,{timeout:5e3})).data.engines||{};if(!r.node){let n=parseInt(e.split(".")[0]);return Ae(n)}return r.node}catch{let r=parseInt(e.split(".")[0]);return console.log(ft.gray(`Unable to fetch Node requirements, deriving from Angular ${r}...`)),Ae(r)}}a(Fe,"getNodeRequirementsForAngular");function Ae(e){let t;e>=15?t=Math.floor(e/2)*2:e>=10?t=Math.floor((e+2)/2)*2:t=Math.floor(e*1.5/2)*2;let r=t,n=t+2,o=t+4;return`^${r}.0.0 || ^${n}.0.0 || ^${o}.0.0`}a(Ae,"generateNodeRequirementFromAngularVersion");S();import O from"semver";import M from"chalk";import Ee from"axios";var Me="https://registry.npmjs.org",U=new Map,$t=300*1e3,xt=100;function Oe(e,t){try{return{compatible:O.satisfies(e,t),current:e,required:t}}catch(r){return{compatible:!1,current:e,required:t,error:r.message}}}a(Oe,"checkNodeCompatibility");function Re(e){let t=[["Current Node.js",M.cyan(`v${e.current}`)],["Required Node.js",M.cyan(e.required)],["Status",e.compatible?M.green("\u2713 Compatible"):M.red("\u2717 Incompatible")]];return N("\u{1F4CB} Compatibility Check",t),e.compatible}a(Re,"displayCompatibilityStatus");function Te(e,t){try{return e.filter(r=>{try{return O.satisfies(r,t)}catch{return!1}}).sort((r,n)=>O.rcompare(r,n))}catch{return[]}}a(Te,"findCompatibleVersions");function ze(e){try{let t=e.split("||").map(o=>o.trim()),r=[];for(let o of t){let i=o.match(/[~^><=]*\s*(\d+)\./g);i&&i.forEach(s=>{let c=parseInt(s.match(/(\d+)/)[1]);r.includes(c)||r.push(c)})}return r.length===0?(console.log(M.yellow("\u26A0\uFE0F Could not parse Node version range. Please install the latest LTS version.")),null):(r.sort((o,i)=>o-i),`${r[0]}.0.0`)}catch{return console.log(M.yellow("\u26A0\uFE0F Could not parse Node version range. Please install a compatible version manually.")),null}}a(ze,"getRecommendedNodeVersion");async function We(e){let t=e,r=U.get(t);if(r&&Date.now()-r.timestamp<$t)return r.data;try{let o=(await Ee.get(`${Me}/${encodeURIComponent(e)}`,{timeout:1e4})).data;if(U.size>=xt){let i=U.keys().next().value;U.delete(i)}return U.set(t,{data:o,timestamp:Date.now()}),o}catch(n){return console.error(M.gray(`Could not fetch package data for ${e}: ${n.message}`)),null}}a(We,"fetchPackageData");async function Pt(e,t){try{return(await Ee.get(`${Me}/${encodeURIComponent(e)}/${t}`,{timeout:5e3})).data}catch{return null}}a(Pt,"fetchPackageVersionData");async function Vt(e,t){return(await Pt(e,t))?.peerDependencies||{}}a(Vt,"getPackagePeerDependencies");async function z(e,t,r){let n=await Vt(e,t),o=["@angular/core","@angular/common","@angular/platform-browser"],i=null;for(let s of o)if(n[s]){i=n[s];break}if(!i)return{compatible:!0,reason:"No Angular peer dependency found",hasPeerDependency:!1};try{let s=O.satisfies(r,i);return{compatible:s,peerDependency:i,hasPeerDependency:!0,reason:s?`Angular ${r} satisfies ${i}`:`Angular ${r} does not satisfy ${i}`}}catch{return kt(i,r)}}a(z,"isVersionCompatibleWithAngular");async function Ct(e,t,r=!0){let n=await We(e);if(!n)return{version:"latest",source:"fallback",reason:"Could not fetch package data"};let o=parseInt(t.split(".")[0]),i=Object.keys(n.versions||{}).filter(g=>!g.includes("rc")&&!g.includes("beta")&&!g.includes("alpha")&&!g.includes("next")).sort((g,v)=>O.rcompare(g,v));if(e.startsWith("@angular/")){let g=i.filter(v=>parseInt(v.split(".")[0])===o);if(g.length>0)return{version:`^${g[0]}`,source:"dynamic",reason:`Matched Angular major version ${o}`,matchType:"angular-scope"}}if(["@ngrx/","@ngxs/","@ng-bootstrap/","@angular-eslint/"].some(g=>e.startsWith(g))){let g=i.filter(v=>parseInt(v.split(".")[0])===o);if(g.length>0)return{version:`^${g[0]}`,source:"dynamic",reason:`Matched Angular ecosystem major version ${o}`,matchType:"ecosystem"}}let c=[],d=i.length>50?30:20,u=i.slice(0,d);for(let g of u){let v=await z(e,g,t);if(v.compatible&&(c.push({version:g,peerDependency:v.peerDependency,hasPeerDependency:v.hasPeerDependency}),r))return{version:`^${g}`,source:"dynamic",reason:v.reason,peerDependency:v.peerDependency,matchType:"peer-dependency"}}if(c.length>0){let g=c[0];return{version:`^${g.version}`,source:"dynamic",reason:`Found ${c.length} compatible version(s)`,peerDependency:g.peerDependency,matchType:"peer-dependency"}}let $=n["dist-tags"]?.latest;return{version:$?`^${$}`:"latest",source:"fallback",reason:"No version with compatible Angular peer dependency found",warning:!0,matchType:"fallback"}}a(Ct,"findCompatibleLibraryVersion");async function Je(e,t){let r=[];for(let n of e){let o=n.version||"latest";if(o==="latest"){let i=await Ct(n.name,t);r.push({...n,version:i.version,originalVersion:o,adjusted:i.source==="dynamic",source:i.source,reason:i.reason,warning:i.warning||!1})}else{let i=await z(n.name,o.replace(/[\^~]/,""),t);r.push({...n,adjusted:!1,compatible:i.compatible,reason:i.reason,warning:!i.compatible})}}return r}a(Je,"resolveLibraryVersionsAsync");function kt(e,t){if(!e||e==="No Angular peer dependency")return{compatible:!0,reason:"No Angular peer dependency specified"};try{return O.satisfies(t,e)?{compatible:!0,reason:`Angular ${t} satisfies peer dependency '${e}'`}:{compatible:!1,reason:`Angular ${t} does not satisfy peer dependency '${e}'`}}catch{let n=t.split(".")[0],o=t.split(".")[1]||"0";return[`^${n}.`,`~${n}.`,`>=${n}.`,`${n}.x`,`${n}.${o}.`,` ${n}.`,`||.*${n}.`].some(c=>new RegExp(c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).test(e))?{compatible:!0,reason:`Peer dependency '${e}' appears compatible with Angular ${n}`}:{compatible:!1,reason:`Peer dependency '${e}' may not support Angular ${n}`}}}a(kt,"checkLibraryCompatibility");async function _e(e,t,r=10){let n=await We(e);if(!n)return[];let o=Object.keys(n.versions||{}).filter(s=>!s.includes("rc")&&!s.includes("beta")&&!s.includes("alpha")&&!s.includes("next")).sort((s,c)=>O.rcompare(s,c)),i=[];for(let s of o){if(i.length>=r)break;let c=await z(e,s,t);c.compatible&&i.push({version:s,peerDependency:c.peerDependency,reason:c.reason})}return i}a(_e,"getAllCompatibleVersions");S();import{execa as W}from"execa";import re from"ora";import x from"chalk";import{platform as Nt}from"os";async function Ue(e="LTS"){let t=re("Installing Node.js with winget...").start();try{return await W("winget",["install",e==="LTS"?"OpenJS.NodeJS.LTS":"OpenJS.NodeJS"],{stdio:"inherit"}),t.succeed("Node.js installed successfully"),!0}catch(r){return t.fail("Failed to install Node.js"),console.error(x.red(r.message)),!1}}a(Ue,"installNodeWithWinget");function St(){switch(Nt()){case"win32":return{os:"Windows",download:"https://github.com/coreybutler/nvm-windows/releases",steps:["Download nvm-setup.exe","Run the installer","Restart your terminal"]};case"darwin":return{os:"macOS",repo:"https://github.com/nvm-sh/nvm",install:"curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash",postInstall:["Restart terminal","If using zsh: source ~/.zshrc","If using bash: source ~/.bash_profile"],steps:["Run the install command","Reload your shell configuration","Verify: nvm --version","Install Node: nvm install node"]};default:return{os:"Linux",repo:"https://github.com/nvm-sh/nvm",install:"curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash",alternative:"wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash",steps:["Run install command","Restart terminal or run: source ~/.bashrc","Verify: nvm --version","Install Node: nvm install node"]}}}a(St,"getNvmInstallInstructions");function Ge(){let e=St();if(N("\u{1F4DA} NVM Installation Guide",[["OS",x.cyan(e.os)],["Download/Repo",e.download?x.blue(e.download):e.repo?x.blue(e.repo):"-"],["Install",e.install?x.green(e.install):"-"],["Alternative",e.alternative?x.green(e.alternative):"-"]]),Array.isArray(e.steps)){let r=e.steps.map((n,o)=>({Step:`${o+1}`,Instruction:n}));C("Steps",r,["Step","Instruction"])}if(Array.isArray(e.postInstall)){let r=e.postInstall.map((n,o)=>({Step:`${o+1}`,Instruction:n}));C("Post-Install",r,["Step","Instruction"])}C("Why use NVM?",[{Benefit:"Manage multiple Node.js versions"},{Benefit:"Switch instantly"},{Benefit:"No sudo/admin required"},{Benefit:"Per-project Node versions"}],["Benefit"])}a(Ge,"displayNvmInstallGuide");async function ye(e,t,r=!1){let n=re(`Installing ${e.length} package(s)...`).start();try{let o=["install"];return r&&o.push("--save-dev"),o.push(...e),await W("npm",o,{cwd:t}),n.succeed("Packages installed successfully"),!0}catch{n.warn("Failed with strict dependencies, retrying with --legacy-peer-deps...");try{let i=["install","--legacy-peer-deps"];return r&&i.push("--save-dev"),i.push(...e),await W("npm",i,{cwd:t}),n.succeed("Packages installed successfully with --legacy-peer-deps"),console.log(x.yellow("\u26A0\uFE0F Note: Installed with --legacy-peer-deps flag due to peer dependency conflicts")),!0}catch(i){return n.fail("Failed to install packages"),console.error(x.red(i.message)),console.log(x.yellow(`
|
|
12
|
+
\u{1F4A1} Tip: You can try installing manually with:`)),console.log(x.cyan(` cd ${t}`)),console.log(x.cyan(` npm install ${e.join(" ")} --force`)),!1}}}a(ye,"installPackages");async function qe(e){let t=re("Installing dependencies...").start();try{return await W("npm",["install"],{cwd:e}),t.succeed("Dependencies installed successfully"),!0}catch{t.warn("Failed with strict dependencies, retrying with --legacy-peer-deps...");try{return await W("npm",["install","--legacy-peer-deps"],{cwd:e}),t.succeed("Dependencies installed successfully with --legacy-peer-deps"),console.log(x.yellow("\u26A0\uFE0F Note: Installed with --legacy-peer-deps flag due to peer dependency conflicts")),!0}catch(n){return t.fail("Failed to install dependencies"),console.error(x.red(n.message)),console.log(x.yellow(`
|
|
13
|
+
\u{1F4A1} Tip: You can try installing manually with:`)),console.log(x.cyan(` cd ${e}`)),console.log(x.cyan(" npm install --force")),!1}}}a(qe,"runNpmInstall");async function Ke(e,t,r={}){let n=re(`Creating Angular project: ${e}...`).start();try{let o=["new",e];r.skipInstall&&o.push("--skip-install"),r.routing!==void 0&&o.push(`--routing=${r.routing}`),r.style&&o.push(`--style=${r.style}`),r.strict!==void 0&&o.push(`--strict=${r.strict}`),r.standalone!==void 0&&o.push(`--standalone=${r.standalone}`);let i=t?`@angular/cli@${t}`:"@angular/cli";return await W("npx",[i,...o],{stdio:"inherit"}),n.succeed(`Angular project ${e} created successfully`),!0}catch(o){return n.fail("Failed to create Angular project"),console.error(x.red(o.message)),!1}}a(Ke,"createAngularProject");import{search as jt,select as j,input as he,confirm as ne}from"@inquirer/prompts";import p from"chalk";S();var oe=class{static{a(this,"LibraryTracker")}constructor(){this.selectedLibraries=new Map}add(t){this.selectedLibraries.set(t.name,t)}remove(t){this.selectedLibraries.delete(t)}has(t){return this.selectedLibraries.has(t)}getAll(){return Array.from(this.selectedLibraries.values())}size(){return this.selectedLibraries.size}clear(){this.selectedLibraries.clear()}displaySelected(){if(this.selectedLibraries.size===0){console.log(p.gray(` No libraries selected yet.
|
|
14
|
+
`));return}let t=this.getAll().map(r=>({Library:r.name,Version:r.version,Description:r.description?r.description.substring(0,70):""}));C("\u{1F4E6} Currently Selected Libraries",t,["Library","Version","Description"])}};async function He(e=null){let t=new oe,r=!0;for(console.log(p.bold.cyan(`
|
|
21
15
|
\u{1F4E6} Interactive Library Search
|
|
22
|
-
`)),e&&console.log(
|
|
23
|
-
`)),console.log(
|
|
24
|
-
`));
|
|
25
|
-
|
|
16
|
+
`)),e&&console.log(p.gray(`Angular version: ${e} (compatibility will be checked)
|
|
17
|
+
`)),console.log(p.gray(`Type to search npm packages. Press Enter to select.
|
|
18
|
+
`));r;)try{t.size()>0&&t.displaySelected();let n=await jt({message:"Search for a library:",source:a(async(s,{signal:c})=>{if(!s||s.length<2)return[];let d=await ge(s,15),u=d.filter($=>!t.has($.name));return u.length===0&&d.length>0?[{name:p.yellow("All matching libraries have already been selected"),value:null,disabled:!0}]:u.map($=>({name:At($),value:$.name,description:$.description}))},"source"),pageSize:10});if(!n){r=await ne({message:"Continue searching for libraries?",default:!1});continue}let o=await Le(n);if(o){N(`
|
|
19
|
+
Selected Package`,[["Name",p.green(o.name)],["Description",p.gray(o.description)],["Latest version",p.cyan(o.latestVersion)],["Weekly downloads",p.gray(fe(o.weeklyDownloads))]]);let s=await j({message:"How would you like to select the version?",choices:[{name:`Use latest (${o.latestVersion})`,value:"latest"},{name:"Choose specific version (major.minor.patch)",value:"specific"},{name:"Enter version manually",value:"manual"}],default:"latest"}),c=o.latestVersion;if(s==="specific"){console.log(p.cyan(`
|
|
26
20
|
\u{1F4E6} Fetching versions for ${o.name}...
|
|
27
|
-
`));let
|
|
21
|
+
`));let u=await De(o.name);if(u.versions.length===0)console.log(p.yellow("Could not fetch versions. Using latest version.")),c=o.latestVersion;else{let g=Q(u.versions).map(y=>{let h=`${o.name} ${y}`;return{name:u.latest&&u.latest.startsWith(`${y}.`)?`${h} (latest)`:h,value:y}}),v=await j({message:`Select ${o.name} major version:`,choices:g,pageSize:15}),be=ee(u.versions,v).map(y=>({name:`v${y}.x`,value:y})),K=await j({message:`Select ${o.name} ${v} minor version:`,choices:be,pageSize:15}),m=te(u.versions,K).map(y=>{let h=`v${y}`;return y===u.latest&&(h+=" (latest)"),y===u.lts&&(h+=" (LTS)"),{name:h,value:y}});c=await j({message:`Select ${o.name} ${K} patch version:`,choices:m,pageSize:15})}}else s==="manual"&&(c=await he({message:"Enter version:",default:o.latestVersion,validate:a(u=>u?!0:"Version is required","validate")}));if(e&&c!=="latest"){console.log(p.cyan(`
|
|
28
22
|
\u{1F50D} Checking compatibility with Angular ${e}...
|
|
29
|
-
`));let
|
|
30
|
-
`));else if(console.log(
|
|
31
|
-
`)),await
|
|
23
|
+
`));let u=await z(o.name,c,e);if(u.compatible)console.log(p.green(`\u2713 ${o.name}@${c} is compatible with Angular ${e}`)),u.peerDependency&&console.log(p.gray(` Peer dependency: ${u.peerDependency}
|
|
24
|
+
`));else if(console.log(p.red(`\u2717 ${o.name}@${c} may not be compatible with Angular ${e}`)),console.log(p.gray(` ${u.reason}
|
|
25
|
+
`)),await ne({message:"Would you like to see compatible versions?",default:!0})){console.log(p.cyan(`
|
|
32
26
|
\u{1F50D} Dynamically searching for compatible versions...
|
|
33
|
-
`));let
|
|
34
|
-
`)),
|
|
35
|
-
`))}
|
|
27
|
+
`));let g=await _e(o.name,e,10);if(g.length>0){let v=g.map(A=>({name:`${A.version}${A.peerDependency?` (peer: ${A.peerDependency})`:""}`,value:A.version}));v.push({name:"Keep selected version anyway",value:c}),c=await j({message:"Select a compatible version:",choices:v,pageSize:12})}else if(console.log(p.yellow("No compatible versions found automatically.")),!await ne({message:"Continue with the selected version anyway?",default:!1})){console.log(p.yellow(`Skipping this library.
|
|
28
|
+
`)),r=await ne({message:"Search for another library?",default:!0});continue}}}let d={name:o.name,version:c,description:o.description};t.add(d),console.log(p.green(`\u2713 Added ${o.name}@${c} to installation queue
|
|
29
|
+
`))}let i=await j({message:"What would you like to do next?",choices:[{name:"Add another library",value:"add"},{name:"Remove a library",value:"remove",disabled:t.size()===0},{name:"Finish library selection",value:"finish"}],default:"add"});if(i==="remove"){let s=t.getAll().map(d=>({name:`${d.name}@${d.version}`,value:d.name})),c=await j({message:"Select library to remove:",choices:s});t.remove(c),console.log(p.yellow(`
|
|
30
|
+
\u2713 Removed ${c}
|
|
31
|
+
`)),r=!0}else i==="finish"?r=!1:r=!0}catch(n){console.error(p.red("Error during library search:",n.message)),r=!1}return t.getAll()}a(He,"interactiveLibrarySearch");function At(e){let t=fe(e.weeklyDownloads||0),r=e.verified?" \u2713":"",n=e.description.substring(0,50)+(e.description.length>50?"...":"");return`${e.name}${r} - ${n} (v${e.version}, \u2B07 ${t}/week)`}a(At,"formatPackageChoice");async function Ye(e=null){let t=new oe,r=!0;for(console.log(p.bold.cyan(`
|
|
36
32
|
\u{1F4E6} Add Libraries
|
|
37
|
-
`)),e&&console.log(
|
|
38
|
-
`));
|
|
33
|
+
`)),e&&console.log(p.gray(`Angular version: ${e} (compatibility will be checked)
|
|
34
|
+
`));r;){t.size()>0&&t.displaySelected();let n=await he({message:"Enter library name (or press Enter to skip):",validate:a(async s=>s?s.match(/^[@a-z0-9-~][a-z0-9-._~]*$/)?t.has(s)?`${s} has already been selected`:!0:"Invalid package name format":!0,"validate")});if(!n)break;let o=await he({message:`Enter version for ${n} (or 'latest'):`,default:"latest"});if(e&&o!=="latest"){console.log(p.cyan(`
|
|
39
35
|
\u{1F50D} Checking compatibility with Angular ${e}...
|
|
40
|
-
`));let
|
|
41
|
-
`))):(console.log(
|
|
42
|
-
`)),console.log(
|
|
43
|
-
`)))}
|
|
44
|
-
`))
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Singleton services, guards, and interceptors go here.`,"src/app/shared/README.md":`# Shared Module
|
|
53
|
-
|
|
54
|
-
Reusable components, directives, and pipes go here.`,"src/app/features/README.md":`# Features
|
|
55
|
-
|
|
56
|
-
Feature modules go here.`,"src/app/models/README.md":`# Models
|
|
57
|
-
|
|
58
|
-
TypeScript interfaces and types go here.`}},domain:{name:"Domain-Driven Structure",folders:["src/app/core","src/app/shared","src/app/domains","src/app/infrastructure"]}},ye={gitignore:`# See http://help.github.com/ignore-files/ for more about ignoring files.
|
|
59
|
-
|
|
60
|
-
# Compiled output
|
|
61
|
-
/dist
|
|
62
|
-
/tmp
|
|
63
|
-
/out-tsc
|
|
64
|
-
/bazel-out
|
|
65
|
-
|
|
66
|
-
# Node
|
|
67
|
-
/node_modules
|
|
68
|
-
npm-debug.log
|
|
69
|
-
yarn-error.log
|
|
70
|
-
|
|
71
|
-
# IDEs and editors
|
|
72
|
-
.idea/
|
|
73
|
-
.project
|
|
74
|
-
.classpath
|
|
75
|
-
.c9/
|
|
76
|
-
*.launch
|
|
77
|
-
.settings/
|
|
78
|
-
*.sublime-workspace
|
|
79
|
-
|
|
80
|
-
# Visual Studio Code
|
|
81
|
-
.vscode/*
|
|
82
|
-
!.vscode/settings.json
|
|
83
|
-
!.vscode/tasks.json
|
|
84
|
-
!.vscode/launch.json
|
|
85
|
-
!.vscode/extensions.json
|
|
86
|
-
.history/*
|
|
87
|
-
|
|
88
|
-
# Miscellaneous
|
|
89
|
-
/.angular/cache
|
|
90
|
-
.sass-cache/
|
|
91
|
-
/connect.lock
|
|
92
|
-
/coverage
|
|
93
|
-
/libpeerconnection.log
|
|
94
|
-
testem.log
|
|
95
|
-
/typings
|
|
96
|
-
|
|
97
|
-
# System files
|
|
98
|
-
.DS_Store
|
|
99
|
-
Thumbs.db
|
|
100
|
-
|
|
101
|
-
# Environment
|
|
102
|
-
.env
|
|
103
|
-
.env.local
|
|
104
|
-
`,initialCommitMessage:"Initial commit: Angular project setup"},he={readme:s((e,n)=>`# ${e}
|
|
105
|
-
|
|
106
|
-
${n||"An Angular application"}
|
|
107
|
-
|
|
108
|
-
## Description
|
|
109
|
-
|
|
110
|
-
This project was generated with Angular CLI.
|
|
111
|
-
|
|
112
|
-
## Development server
|
|
113
|
-
|
|
114
|
-
Run \`ng serve\` for a dev server. Navigate to \`http://localhost:4200/\`. The application will automatically reload if you change any of the source files.
|
|
115
|
-
|
|
116
|
-
## Code scaffolding
|
|
117
|
-
|
|
118
|
-
Run \`ng generate component component-name\` to generate a new component. You can also use \`ng generate directive|pipe|service|class|guard|interface|enum|module\`.
|
|
119
|
-
|
|
120
|
-
## Build
|
|
121
|
-
|
|
122
|
-
Run \`ng build\` to build the project. The build artifacts will be stored in the \`dist/\` directory.
|
|
123
|
-
|
|
124
|
-
## Running unit tests
|
|
125
|
-
|
|
126
|
-
Run \`ng test\` to execute the unit tests via your test runner.
|
|
127
|
-
|
|
128
|
-
## Running end-to-end tests
|
|
129
|
-
|
|
130
|
-
Run \`ng e2e\` to execute the end-to-end tests via a platform of your choice.
|
|
131
|
-
|
|
132
|
-
## Further help
|
|
133
|
-
|
|
134
|
-
To get more help on the Angular CLI use \`ng help\` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
|
135
|
-
|
|
136
|
-
## Project Structure
|
|
137
|
-
|
|
138
|
-
\`\`\`
|
|
139
|
-
src/
|
|
140
|
-
\u251C\u2500\u2500 app/
|
|
141
|
-
\u2502 \u251C\u2500\u2500 core/ # Singleton services, guards
|
|
142
|
-
\u2502 \u251C\u2500\u2500 shared/ # Common components, pipes, directives
|
|
143
|
-
\u2502 \u251C\u2500\u2500 features/ # Feature modules
|
|
144
|
-
\u2502 \u251C\u2500\u2500 models/ # TypeScript interfaces/types
|
|
145
|
-
\u2502 \u2514\u2500\u2500 services/ # Business logic services
|
|
146
|
-
\`\`\`
|
|
147
|
-
|
|
148
|
-
## Contributing
|
|
149
|
-
|
|
150
|
-
1. Fork the repository
|
|
151
|
-
2. Create your feature branch (\`git checkout -b feature/amazing-feature\`)
|
|
152
|
-
3. Commit your changes (\`git commit -m 'Add some amazing feature'\`)
|
|
153
|
-
4. Push to the branch (\`git push origin feature/amazing-feature\`)
|
|
154
|
-
5. Open a Pull Request
|
|
155
|
-
|
|
156
|
-
## License
|
|
157
|
-
|
|
158
|
-
This project is licensed under the MIT License.
|
|
159
|
-
`,"readme"),changelog:`# Changelog
|
|
160
|
-
|
|
161
|
-
All notable changes to this project will be documented in this file.
|
|
162
|
-
|
|
163
|
-
## [Unreleased]
|
|
164
|
-
|
|
165
|
-
### Added
|
|
166
|
-
- Initial project setup
|
|
167
|
-
|
|
168
|
-
### Changed
|
|
169
|
-
|
|
170
|
-
### Fixed
|
|
171
|
-
|
|
172
|
-
### Removed
|
|
173
|
-
`};import I from"fs/promises";import L from"path";import x from"chalk";import{execa as we}from"execa";import ve from"ora";async function Ye(e){let n=ve("Initializing Git repository...").start();try{return await we("git",["init"],{cwd:e}),n.succeed("Git repository initialized"),!0}catch(t){return n.fail("Failed to initialize Git repository"),console.error(x.red(t.message)),!1}}s(Ye,"initGitRepo");async function Ke(e,n){try{let t=L.join(e,".gitignore");return await I.writeFile(t,n,"utf-8"),console.log(x.green("\u2713 Created .gitignore")),!0}catch(t){return console.error(x.red("Failed to create .gitignore:"),t.message),!1}}s(Ke,"createGitignore");async function Xe(e,n){let t=ve("Creating initial commit...").start();try{return await we("git",["add","."],{cwd:e}),await we("git",["commit","-m",n],{cwd:e}),t.succeed("Initial commit created"),!0}catch(r){return t.fail("Failed to create initial commit"),console.error(x.red(r.message)),!1}}s(Xe,"createInitialCommit");async function Qe(e,n){let t=ve("Creating project structure...").start();try{for(let r of n){let o=L.join(e,r);await I.mkdir(o,{recursive:!0})}return t.succeed("Project structure created"),!0}catch(r){return t.fail("Failed to create project structure"),console.error(x.red(r.message)),!1}}s(Qe,"createProjectFolders");async function be(e,n){try{for(let[t,r]of Object.entries(n)){let o=L.join(e,t),l=L.dirname(o);await I.mkdir(l,{recursive:!0});let i=typeof r=="string"?r:JSON.stringify(r,null,2);await I.writeFile(o,i,"utf-8")}return console.log(x.green(`\u2713 Created ${Object.keys(n).length} file(s)`)),!0}catch(t){return console.error(x.red("Failed to create project files:"),t.message),!1}}s(be,"createProjectFiles");async function Ze(e,n){try{let t=L.join(e,"README.md");return await I.writeFile(t,n,"utf-8"),console.log(x.green("\u2713 Created README.md")),!0}catch(t){return console.error(x.red("Failed to create README.md:"),t.message),!1}}s(Ze,"createReadme");async function et(e,n){try{let t=L.join(e,"CHANGELOG.md");return await I.writeFile(t,n,"utf-8"),console.log(x.green("\u2713 Created CHANGELOG.md")),!0}catch(t){return console.error(x.red("Failed to create CHANGELOG.md:"),t.message),!1}}s(et,"createChangelog");function tt(e){return/[<>:"|?*\x00-\x1f]/.test(e)?"Directory name contains invalid characters":["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"].includes(e.toUpperCase())?"Directory name is reserved":e.length===0?"Directory name cannot be empty":e.length>255?"Directory name is too long":e.endsWith(" ")||e.endsWith(".")?"Directory name cannot end with a space or period":!0}s(tt,"validateDirectoryName");async function nt(e,n){try{let t=L.join(e,"package.json"),r=JSON.parse(await I.readFile(t,"utf-8"));return r.scripts={...r.scripts,...n},await I.writeFile(t,JSON.stringify(r,null,2),"utf-8"),console.log(x.green("\u2713 Updated package.json scripts")),!0}catch(t){return console.error(x.red("Failed to update package.json:"),t.message),!1}}s(nt,"updatePackageJsonScripts");import B from"fs/promises";import rt from"path";import{homedir as Dt}from"os";import h from"chalk";var ot=rt.join(Dt(),".ng-init"),st=rt.join(ot,"profiles.json");async function at(){try{return await B.mkdir(ot,{recursive:!0}),!0}catch(e){return console.error(h.red("Failed to create profiles directory:"),e.message),!1}}s(at,"ensureProfilesDirectory");async function ne(){try{await at();let e=await B.readFile(st,"utf-8");return JSON.parse(e)}catch{return{}}}s(ne,"loadProfiles");async function it(e){try{return await at(),await B.writeFile(st,JSON.stringify(e,null,2),"utf-8"),!0}catch(n){return console.error(h.red("Failed to save profiles:"),n.message),!1}}s(it,"saveProfiles");async function $e(e,n){let t=await ne();t[e]={...n,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};let r=await it(t);return r&&console.log(h.green(`\u2713 Profile "${e}" saved successfully`)),r}s($e,"saveProfile");async function H(e){return(await ne())[e]||null}s(H,"loadProfile");async function lt(e){let n=await ne();if(!n[e])return console.log(h.yellow(`Profile "${e}" not found`)),!1;delete n[e];let t=await it(n);return t&&console.log(h.green(`\u2713 Profile "${e}" deleted successfully`)),t}s(lt,"deleteProfile");async function re(){let e=await ne();return Object.keys(e)}s(re,"listProfiles");async function ct(e,n){let t=await H(e);if(!t)return console.log(h.red(`Profile "${e}" not found`)),!1;try{let r={name:e,profile:t,exportedAt:new Date().toISOString(),version:"1.0.0"};return await B.writeFile(n,JSON.stringify(r,null,2),"utf-8"),console.log(h.green(`\u2713 Profile exported to ${n}`)),!0}catch(r){return console.error(h.red("Failed to export profile:"),r.message),!1}}s(ct,"exportProfile");async function ut(e){try{let n=await B.readFile(e,"utf-8"),t=JSON.parse(n);if(!t.name||!t.profile)return console.log(h.red("Invalid profile file format")),!1;let r=await $e(t.name,t.profile);return r&&console.log(h.green(`\u2713 Profile "${t.name}" imported successfully`)),r}catch(n){return console.error(h.red("Failed to import profile:"),n.message),!1}}s(ut,"importProfile");function oe(e,n){console.log(h.bold.cyan(`
|
|
174
|
-
\u{1F4CB} Profile: ${e}
|
|
175
|
-
`)),console.log(h.gray("\u2501".repeat(50))),n.angularVersion&&console.log(h.white("Angular Version: ")+h.green(n.angularVersion)),n.template&&console.log(h.white("Template: ")+h.cyan(n.template)),n.libraries&&n.libraries.length>0&&(console.log(h.white("Libraries: ")+h.cyan(n.libraries.length)),n.libraries.slice(0,5).forEach(t=>{console.log(h.gray(` \u2022 ${t.name}@${t.version}`))}),n.libraries.length>5&&console.log(h.gray(` ... and ${n.libraries.length-5} more`))),n.options&&(console.log(h.white("Options:")),Object.entries(n.options).forEach(([t,r])=>{console.log(h.gray(` \u2022 ${t}: ${r}`))})),n.createdAt&&console.log(h.white("Created: ")+h.gray(new Date(n.createdAt).toLocaleString())),console.log(h.gray("\u2501".repeat(50))+`
|
|
176
|
-
`)}s(oe,"displayProfileInfo");import{readFileSync as Rt}from"fs";import{fileURLToPath as Mt}from"url";import{dirname as Ft,join as Tt}from"path";var Ot=Mt(import.meta.url),_t=Ft(Ot),Gt=JSON.parse(Rt(Tt(_t,"../package.json"),"utf-8"));async function dt(){try{console.log(a.bold.cyan(`
|
|
177
|
-
\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557`)),console.log(a.bold.cyan(`\u2551 Angular Project Automation CLI v${Gt.version.padEnd(13)}\u2551`)),console.log(a.bold.cyan(`\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
178
|
-
`));let e=await ie(),n=await E({message:"Would you like to use a saved profile?",default:!1}),t={};if(n){let u=await re();if(u.length===0)console.log(a.yellow(`No saved profiles found. Continuing with manual setup...
|
|
179
|
-
`));else{let g=await A({message:"Select a profile:",choices:u.map(C=>({name:C,value:C}))}),w=await H(g);oe(g,w),await E({message:"Use this profile?",default:!0})&&(t=w)}}if(!t.angularVersion){console.log(a.bold.cyan(`
|
|
36
|
+
`));let s=await z(n,o,e);s.compatible?(console.log(p.green(`\u2713 ${n}@${o} is compatible with Angular ${e}`)),s.peerDependency&&console.log(p.gray(` Peer dependency: ${s.peerDependency}
|
|
37
|
+
`))):(console.log(p.red(`\u2717 ${n}@${o} may not be compatible with Angular ${e}`)),console.log(p.gray(` ${s.reason}
|
|
38
|
+
`)),console.log(p.yellow(`\u26A0\uFE0F This may cause installation issues. Consider using a different version.
|
|
39
|
+
`)))}t.add({name:n,version:o}),console.log(p.green(`\u2713 Added ${n}@${o}
|
|
40
|
+
`));let i=await j({message:"What would you like to do next?",choices:[{name:"Add another library",value:"add"},{name:"Remove a library",value:"remove",disabled:t.size()===0},{name:"Finish library selection",value:"finish"}],default:"add"});if(i==="remove"){let s=t.getAll().map(d=>({name:`${d.name}@${d.version}`,value:d.name})),c=await j({message:"Select library to remove:",choices:s});t.remove(c),console.log(p.yellow(`
|
|
41
|
+
\u2713 Removed ${c}
|
|
42
|
+
`)),r=!0}else i==="finish"&&(r=!1)}return t.getAll()}a(Ye,"simpleLibraryInput");async function Be(){return await j({message:"How would you like to add libraries?",choices:[{name:"Interactive search with autocomplete (Recommended)",value:"interactive"},{name:"Manual entry",value:"manual"},{name:"Skip for now",value:"skip"}],default:"interactive"})}a(Be,"askLibrarySearchPreference");import Er from"chalk";import{execa as Or}from"execa";import Tr from"ora";function Xe(e){return/[<>:"|?*\x00-\x1f]/.test(e)?"Directory name contains invalid characters":["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"].includes(e.toUpperCase())?"Directory name is reserved":e.length===0?"Directory name cannot be empty":e.length>255?"Directory name is too long":e.endsWith(" ")||e.endsWith(".")?"Directory name cannot end with a space or period":!0}a(Xe,"validateDirectoryName");S();import G from"fs/promises";import Ze from"path";import{homedir as Lt}from"os";import P from"chalk";var Qe=Ze.join(Lt(),".ng-init"),et=Ze.join(Qe,"profiles.json");async function tt(){try{return await G.mkdir(Qe,{recursive:!0}),!0}catch(e){return console.error(P.red("Failed to create profiles directory:"),e.message),!1}}a(tt,"ensureProfilesDirectory");async function se(){try{await tt();let e=await G.readFile(et,"utf-8");return JSON.parse(e)}catch{return{}}}a(se,"loadProfiles");async function rt(e){try{return await tt(),await G.writeFile(et,JSON.stringify(e,null,2),"utf-8"),!0}catch(t){return console.error(P.red("Failed to save profiles:"),t.message),!1}}a(rt,"saveProfiles");async function we(e,t){let r=await se();r[e]={...t,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};let n=await rt(r);return n&&console.log(P.green(`\u2713 Profile "${e}" saved successfully`)),n}a(we,"saveProfile");async function J(e){return(await se())[e]||null}a(J,"loadProfile");async function nt(e){let t=await se();if(!t[e])return console.log(P.yellow(`Profile "${e}" not found`)),!1;delete t[e];let r=await rt(t);return r&&console.log(P.green(`\u2713 Profile "${e}" deleted successfully`)),r}a(nt,"deleteProfile");async function ae(){let e=await se();return Object.keys(e)}a(ae,"listProfiles");async function ot(e){let t=await J(e);return t?{name:e,angularVersion:t.angularVersion,libraries:t.libraries?.length||0,createdAt:t.createdAt,updatedAt:t.updatedAt}:null}a(ot,"getProfileDetails");async function st(e,t){let r=await J(e);if(!r)return console.log(P.red(`Profile "${e}" not found`)),!1;try{let n={name:e,profile:r,exportedAt:new Date().toISOString(),version:"1.0.0"};return await G.writeFile(t,JSON.stringify(n,null,2),"utf-8"),console.log(P.green(`\u2713 Profile exported to ${t}`)),!0}catch(n){return console.error(P.red("Failed to export profile:"),n.message),!1}}a(st,"exportProfile");async function at(e){try{let t=await G.readFile(e,"utf-8"),r=JSON.parse(t);if(!r.name||!r.profile)return console.log(P.red("Invalid profile file format")),!1;let n=await we(r.name,r.profile);return n&&console.log(P.green(`\u2713 Profile "${r.name}" imported successfully`)),n}catch(t){return console.error(P.red("Failed to import profile:"),t.message),!1}}a(at,"importProfile");function ie(e,t){let r=[];if(t.angularVersion&&r.push(["Angular Version",P.green(t.angularVersion)]),t.template&&r.push(["Template",P.gray(`${t.template} (deprecated)`)]),r.push(["Libraries",P.cyan(t.libraries?.length||0)]),t.createdAt&&r.push(["Created",P.gray(new Date(t.createdAt).toLocaleString())]),t.updatedAt&&r.push(["Updated",P.gray(new Date(t.updatedAt).toLocaleString())]),N(`\u{1F4CB} Profile: ${e}`,r),t.libraries&&t.libraries.length>0){let n=t.libraries.slice(0,50).map(o=>({Library:o.name,Version:o.version,Description:o.description||""}));C("Libraries (showing up to 50)",n,["Library","Version","Description"]),t.libraries.length>50&&console.log(P.gray(` ... and ${t.libraries.length-50} more`))}if(t.options){let n=Object.entries(t.options).map(([o,i])=>({Option:o,Value:String(i)}));C("Options",n,["Option","Value"])}}a(ie,"displayProfileInfo");import{readFileSync as Dt}from"fs";import{fileURLToPath as Ft}from"url";import{dirname as Et,join as Mt}from"path";var Ot=Ft(import.meta.url),Rt=Et(Ot),Tt=JSON.parse(Dt(Mt(Rt,"../package.json"),"utf-8"));async function it(){try{let e=`Angular Project Initialization Automation CLI v${Tt.version}`,t=60,r="\u2550".repeat(t),n=t-e.length;console.log(l.cyan.bold(`
|
|
43
|
+
\u2554${r}\u2557
|
|
44
|
+
\u2551${" ".repeat(n/2)}${e}${" ".repeat(Math.ceil(n/2))}\u2551
|
|
45
|
+
\u255A${r}\u255D
|
|
46
|
+
`));let o=await ue(),i=await E({message:"Would you like to use a saved profile?",default:!1}),s={};if(i){let m=await ae();if(m.length===0)console.log(l.yellow(`No saved profiles found. Continuing with manual setup...
|
|
47
|
+
`));else{let b=await F({message:"Select a profile:",choices:m.map(L=>({name:L,value:L}))}),y=await J(b);ie(b,y),await E({message:"Use this profile?",default:!0})&&(s=y)}}if(!s.angularVersion){console.log(l.bold.cyan(`
|
|
180
48
|
\u{1F4E6} Fetching Angular versions...
|
|
181
|
-
`));let
|
|
182
|
-
\u2713 Selected Angular version: ${
|
|
183
|
-
`));let
|
|
184
|
-
`)),await
|
|
185
|
-
`));let
|
|
186
|
-
`));let
|
|
187
|
-
Switching to Node.js v${
|
|
188
|
-
`)),await
|
|
189
|
-
`))}else{console.log(
|
|
190
|
-
`));let
|
|
191
|
-
`)),await
|
|
192
|
-
`));let
|
|
49
|
+
`));let m=await Ie();m.versions.length===0&&(console.log(l.red("Failed to fetch Angular versions. Please check your internet connection.")),process.exit(1));let y=Q(m.versions).map(k=>{let R=`Angular ${k}`;return{name:m.latest&&m.latest.startsWith(`${k}.`)?`${R} (latest)`:R,value:k}}),h=await F({message:"Select Angular major version:",choices:y,pageSize:15}),w=ee(m.versions,h).map(k=>({name:`v${k}.x`,value:k})),V=await F({message:`Select Angular ${h} minor version:`,choices:w,pageSize:15}),ct=te(m.versions,V).map(k=>{let R=`v${k}`;return k===m.latest&&(R+=" (latest)"),k===m.lts&&(R+=" (LTS)"),{name:R,value:k}}),ut=await F({message:`Select Angular ${V} patch version:`,choices:ct,pageSize:15});s.angularVersion=ut}console.log(l.green(`
|
|
50
|
+
\u2713 Selected Angular version: ${s.angularVersion}
|
|
51
|
+
`));let c=await Fe(s.angularVersion),d=await B(),u=Oe(d,c);if(Re(u),!u.compatible)if(console.log(l.yellow(`\u26A0\uFE0F Node.js version incompatibility detected!
|
|
52
|
+
`)),await ce()){console.log(l.cyan(`\u2713 nvm detected on your system
|
|
53
|
+
`));let b=await pe(),y=Te(b,c);if(y.length>0){console.log(l.green(`Found ${y.length} compatible Node version(s) installed:
|
|
54
|
+
`));let h=await F({message:"Select Node version to switch to:",choices:y.map(w=>({name:`v${w}`,value:w}))});console.log(l.cyan(`
|
|
55
|
+
Switching to Node.js v${h}...
|
|
56
|
+
`)),await X(h)||(console.log(l.red("Failed to switch Node version. Please try manually.")),process.exit(1)),console.log(l.green(`\u2713 Node version switched successfully
|
|
57
|
+
`))}else{console.log(l.yellow(`No compatible Node versions installed.
|
|
58
|
+
`));let h=ze(c);await E({message:`Install Node.js v${h}?`,default:!0})?(await de(h)||(console.log(l.red("Failed to install Node version.")),process.exit(1)),console.log(l.green(`\u2713 Node.js installed successfully
|
|
59
|
+
`)),await X(h)):(console.log(l.red("Cannot proceed without compatible Node.js version.")),process.exit(1))}}else{console.log(l.yellow(`\u26A0\uFE0F nvm is not installed on your system
|
|
60
|
+
`));let b=await F({message:"How would you like to proceed?",choices:[{name:"Install nvm (Recommended)",value:"nvm"},{name:"Install Node.js directly (Windows only)",value:"direct"},{name:"Exit and install manually",value:"exit"}]});b==="nvm"?(Ge(),console.log(l.yellow(`
|
|
193
61
|
Please install nvm and run this CLI again.
|
|
194
|
-
`)),process.exit(0)):
|
|
62
|
+
`)),process.exit(0)):b==="direct"?(process.platform!=="win32"&&(console.log(l.red("Direct installation is only supported on Windows.")),process.exit(1)),await Ue("LTS")||(console.log(l.red("Failed to install Node.js. Please install manually.")),process.exit(1)),console.log(l.yellow(`
|
|
195
63
|
Please restart your terminal and run this CLI again.
|
|
196
|
-
`)),process.exit(0)):(console.log(
|
|
197
|
-
`)),process.exit(0))}
|
|
198
|
-
|
|
199
|
-
`)),console.log(a.gray("\u2501".repeat(50))),console.log(a.white("Project Name: ")+a.green(t.projectName)),console.log(a.white("Location: ")+a.cyan(i)),console.log(a.white("Angular Version: ")+a.green(t.angularVersion)),console.log(a.white("Template: ")+a.cyan(t.template)),console.log(a.white("Libraries: ")+a.cyan(t.libraries.length)),console.log(a.white("Features: ")+a.cyan(t.features.join(", "))),console.log(a.gray("\u2501".repeat(50))+`
|
|
200
|
-
`),await E({message:"Create project with this configuration?",default:!0})||(console.log(a.yellow(`Project creation cancelled.
|
|
201
|
-
`)),process.exit(0)),console.log(a.bold.cyan(`
|
|
64
|
+
`)),process.exit(0)):(console.log(l.yellow(`Exiting. Please install a compatible Node.js version manually.
|
|
65
|
+
`)),process.exit(0))}s.projectName||(s.projectName=await ve({message:"Enter project name:",validate:a(m=>{if(!m)return"Project name is required";let b=Xe(m);return b===!0?!0:b},"validate")})),s.location||(await F({message:"Where would you like to create the project?",choices:[{name:"Current directory",value:"current"},{name:"Specify custom directory",value:"custom"}]})==="custom"?s.location=await ve({message:"Enter directory path:",default:process.cwd()}):s.location=process.cwd());let $=It.join(s.location,s.projectName);if(!s.options){let m=await E({message:"Enable routing?",default:!0}),b=await F({message:"Select stylesheet format:",choices:[{name:"css",value:"css"},{name:"scss",value:"scss"},{name:"sass",value:"sass"},{name:"less",value:"less"}]}),y=await E({message:"Enable strict mode?",default:!0}),h=await E({message:"Use standalone components?",default:!1});s.options={routing:m,style:b,strict:y,standalone:h}}if(!s.libraries){let m=await Be();s.libraries=[],m==="interactive"?s.libraries=await He(s.angularVersion):m==="manual"&&(s.libraries=await Ye(s.angularVersion))}if(s.features=[],await E({message:"Save this configuration as a profile?",default:!1})){let m=await ve({message:"Enter profile name:",validate:a(b=>b?!0:"Profile name is required","validate")});await we(m,s)}let{printKeyValue:v}=await Promise.resolve().then(()=>(S(),Y)),A=[["Project Name",l.green(s.projectName)],["Location",l.cyan($)],["Angular Version",l.green(s.angularVersion)],["Style",l.cyan(s.options.style)],["Routing",l.cyan(s.options.routing?"Yes":"No")],["Strict Mode",l.cyan(s.options.strict?"Yes":"No")],["Standalone",l.cyan(s.options.standalone?"Yes":"No")],["Libraries",l.cyan(s.libraries.length)]];v("\u{1F4CB} Project Configuration Summary",A),await E({message:"Create project with this configuration?",default:!0})||(console.log(l.yellow(`Project creation cancelled.
|
|
66
|
+
`)),process.exit(0)),console.log(l.bold.cyan(`
|
|
202
67
|
\u{1F680} Creating Angular project...
|
|
203
|
-
`));let
|
|
68
|
+
`));let K={...s.options,skipInstall:!0};if(await Ke(s.projectName,s.angularVersion,K)||(console.log(l.red("Failed to create Angular project.")),process.exit(1)),s.libraries.length>0){console.log(l.bold.cyan(`
|
|
204
69
|
\u{1F4E6} Resolving library versions...
|
|
205
|
-
`));let
|
|
206
|
-
`)),
|
|
207
|
-
`)),w
|
|
208
|
-
`));let
|
|
209
|
-
`));let
|
|
70
|
+
`));let m=await Je(s.libraries,s.angularVersion),b=m.filter(w=>w.adjusted);if(b.length>0){let{printObjectList:w}=await Promise.resolve().then(()=>(S(),Y)),V=b.map(I=>({Package:I.name,From:I.originalVersion,To:I.version,Reason:I.reason||""}));console.log(l.green(`\u2713 Dynamically resolved compatible library versions:
|
|
71
|
+
`)),w("Resolved Library Versions",V,["Package","From","To","Reason"])}let y=m.filter(w=>w.warning);if(y.length>0){let{printObjectList:w}=await Promise.resolve().then(()=>(S(),Y)),V=y.map(I=>({Package:I.name,Version:I.version,Reason:I.reason||""}));console.log(l.yellow(`\u26A0\uFE0F Potential compatibility warnings:
|
|
72
|
+
`)),w("Compatibility Warnings",V,["Package","Version","Reason"])}let h=m.filter(w=>!w.isDev),L=m.filter(w=>w.isDev);if(h.length>0){console.log(l.bold.cyan(`\u{1F4E6} Installing production libraries...
|
|
73
|
+
`));let w=h.map(V=>V.version==="latest"?V.name:`${V.name}@${V.version}`);await ye(w,$)}if(L.length>0){console.log(l.bold.cyan(`\u{1F4E6} Installing dev libraries...
|
|
74
|
+
`));let w=L.map(V=>V.version==="latest"?V.name:`${V.name}@${V.version}`);await ye(w,$,!0)}}console.log(l.bold.cyan(`
|
|
210
75
|
\u{1F4E5} Installing dependencies...
|
|
211
|
-
`)),await
|
|
212
|
-
\u{1F4C1} Creating project structure...
|
|
213
|
-
`)),await Qe(i,fe.standard.folders),await be(i,fe.standard.files)),t.features.includes("git")&&(console.log(a.bold.cyan(`
|
|
214
|
-
\u{1F527} Initializing Git repository...
|
|
215
|
-
`)),await Ye(i),await Ke(i,ye.gitignore)),t.features.includes("readme")){console.log(a.bold.cyan(`
|
|
216
|
-
\u{1F4DD} Generating README.md...
|
|
217
|
-
`));let u=he.readme(t.projectName,"An Angular application created with Angular Project Automator");await Ze(i,u)}if(t.features.includes("changelog")&&await et(i,he.changelog),t.features.includes("eslint")){console.log(a.bold.cyan(`
|
|
218
|
-
\u{1F527} Setting up ESLint + Prettier...
|
|
219
|
-
`));let u=z.eslint.packages.map(g=>g);await J(u,i,!0),await be(i,z.eslint.files)}if(t.features.includes("husky")){console.log(a.bold.cyan(`
|
|
220
|
-
\u{1F436} Setting up Husky...
|
|
221
|
-
`));let u=z.husky.devPackages.map(g=>g);await J(u,i,!0),await nt(i,z.husky.scripts)}t.features.includes("git")&&(console.log(a.bold.cyan(`
|
|
222
|
-
\u{1F4DD} Creating initial commit...
|
|
223
|
-
`)),await Xe(i,ye.initialCommitMessage)),console.log(a.bold.green(`
|
|
76
|
+
`)),await qe($),console.log(l.bold.green(`
|
|
224
77
|
\u2705 Project created successfully! \u{1F389}
|
|
225
|
-
`)),console.log(
|
|
226
|
-
`)),console.log(
|
|
78
|
+
`)),console.log(l.bold.cyan(`\u{1F4CA} Next Steps:
|
|
79
|
+
`)),console.log(l.gray("\u2501".repeat(50))),console.log(l.white("1. ")+l.cyan(`cd ${s.projectName}`)),console.log(l.white("2. ")+l.cyan("ng serve")),console.log(l.white("3. ")+l.cyan("Open http://localhost:4200 in your browser")),console.log(l.gray("\u2501".repeat(50))),console.log(l.bold.cyan(`
|
|
227
80
|
\u{1F4A1} Useful Commands:
|
|
228
|
-
`)),console.log(
|
|
229
|
-
`)),console.log(
|
|
230
|
-
`))}catch(e){console.error(
|
|
231
|
-
\u274C Error:`),e.message),process.exit(1)}}
|
|
232
|
-
\u{1F4CB} Saved Profiles:
|
|
233
|
-
`)),console.log(m.gray("\u2501".repeat(50))),e.forEach(n=>{console.log(m.white(" \u2022 ")+m.green(n))}),console.log(m.gray("\u2501".repeat(50))+`
|
|
234
|
-
`)}catch(e){console.error(m.red("Error listing profiles:"),e.message)}});q.command("show <name>").description("Show details of a profile").action(async e=>{try{let n=await H(e);if(!n){console.log(m.red(`Profile "${e}" not found.`));return}oe(e,n)}catch(n){console.error(m.red("Error loading profile:"),n.message)}});q.command("delete <name>").description("Delete a profile").action(async e=>{try{await lt(e)}catch(n){console.error(m.red("Error deleting profile:"),n.message)}});q.command("export <name> <output>").description("Export a profile to a file").action(async(e,n)=>{try{await ct(e,n)}catch(t){console.error(m.red("Error exporting profile:"),t.message)}});q.command("import <file>").description("Import a profile from a file").action(async e=>{try{await ut(e)}catch(n){console.error(m.red("Error importing profile:"),n.message)}});G.command("check").description("Check system versions and compatibility").action(async()=>{try{let{displaySystemVersions:e}=await Promise.resolve().then(()=>(ue(),Ae));await e()}catch(e){console.error(m.red("Error checking versions:"),e.message)}});G.command("examples").description("Show usage examples").action(()=>{console.log(m.bold.cyan(`
|
|
81
|
+
`)),console.log(l.gray(" ng generate component <name> ")+l.white("Create a component")),console.log(l.gray(" ng generate service <name> ")+l.white("Create a service")),console.log(l.gray(" ng build ")+l.white("Build for production")),console.log(l.gray(" ng test ")+l.white("Run unit tests")),console.log(l.gray(" ng help ")+l.white(`Get more help
|
|
82
|
+
`)),console.log(l.bold.green(`Happy coding! \u{1F680}
|
|
83
|
+
`))}catch(e){console.error(l.red(`
|
|
84
|
+
\u274C Error:`),e.message),process.exit(1)}}a(it,"runCli");S();import f from"chalk";import{readFileSync as Wt}from"fs";import{fileURLToPath as Jt}from"url";import{dirname as _t,join as Ut}from"path";var Gt=Jt(import.meta.url),qt=_t(Gt),Kt=JSON.parse(Wt(Ut(qt,"../package.json"),"utf-8")),_=new zt;_.name("ng-init").description("Angular project initializer with intelligent version management and automation").version(Kt.version);_.command("create",{isDefault:!0}).alias("new").description("Create a new Angular project with interactive setup").action(()=>{it()});var q=_.command("profile").description("Manage configuration profiles");q.command("list").description("List all saved profiles").action(async()=>{try{let e=await ae();if(e.length===0){console.log(f.yellow("No saved profiles found."));return}let t=[];for(let r of e){let n=await ot(r);t.push({Name:n.name,Angular:n.angularVersion||"-",Libraries:n.libraries||0,Created:n.createdAt||"-"})}C("Saved Profiles",t,["Name","Angular","Libraries","Created"])}catch(e){console.error(f.red("Error listing profiles:"),e.message)}});q.command("show <name>").description("Show details of a profile").action(async e=>{try{let t=await J(e);if(!t){console.log(f.red(`Profile "${e}" not found.`));return}ie(e,t)}catch(t){console.error(f.red("Error loading profile:"),t.message)}});q.command("delete <name>").description("Delete a profile").action(async e=>{try{await nt(e)}catch(t){console.error(f.red("Error deleting profile:"),t.message)}});q.command("export <name> <output>").description("Export a profile to a file").action(async(e,t)=>{try{await st(e,t)}catch(r){console.error(f.red("Error exporting profile:"),r.message)}});q.command("import <file>").description("Import a profile from a file").action(async e=>{try{await at(e)}catch(t){console.error(f.red("Error importing profile:"),t.message)}});_.command("check").description("Check system versions and compatibility").action(async()=>{try{let{displaySystemVersions:e}=await Promise.resolve().then(()=>(me(),je));await e()}catch(e){console.error(f.red("Error checking versions:"),e.message)}});_.command("examples").description("Show usage examples").action(()=>{console.log(f.bold.cyan(`
|
|
235
85
|
\u{1F4DA} Usage Examples:
|
|
236
|
-
`)),console.log(
|
|
237
|
-
`)),console.log(
|
|
238
|
-
`)),console.log(
|
|
239
|
-
`)),console.log(
|
|
240
|
-
`)),console.log(
|
|
241
|
-
`)),console.log(
|
|
242
|
-
`)),console.log(
|
|
243
|
-
`)),console.log(
|
|
244
|
-
`)});
|
|
86
|
+
`)),console.log(f.gray("\u2501".repeat(50))),console.log(f.white("Create new project (interactive):")),console.log(f.green(" $ ng-init")+f.gray(" or ")+f.green(`ng-init create
|
|
87
|
+
`)),console.log(f.white("Check system versions:")),console.log(f.green(` $ ng-init check
|
|
88
|
+
`)),console.log(f.white("List saved profiles:")),console.log(f.green(` $ ng-init profile list
|
|
89
|
+
`)),console.log(f.white("Show profile details:")),console.log(f.green(` $ ng-init profile show my-profile
|
|
90
|
+
`)),console.log(f.white("Delete a profile:")),console.log(f.green(` $ ng-init profile delete my-profile
|
|
91
|
+
`)),console.log(f.white("Export a profile:")),console.log(f.green(` $ ng-init profile export my-profile ./profile.json
|
|
92
|
+
`)),console.log(f.white("Import a profile:")),console.log(f.green(` $ ng-init profile import ./profile.json
|
|
93
|
+
`)),console.log(f.gray("\u2501".repeat(50))+`
|
|
94
|
+
`)});_.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jatinmourya/ng-init",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.10",
|
|
4
4
|
"description": "A comprehensive CLI tool to automate Angular project initialization with intelligent version management and prerequisite handling",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cli.js",
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"execa": "^9.6.1",
|
|
51
51
|
"lodash.debounce": "^4.0.8",
|
|
52
52
|
"ora": "^8.0.1",
|
|
53
|
-
"semver": "^7.5.4"
|
|
53
|
+
"semver": "^7.5.4",
|
|
54
|
+
"cli-table3": "^0.6.2"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"esbuild": "^0.27.2",
|