@jatinmourya/ng-init 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.js +15 -0
- package/dist/runner.js +56 -0
- package/dist/templates/templates.js +130 -0
- package/dist/utils/compatibility.js +4 -0
- package/dist/utils/file-utils.js +1 -0
- package/dist/utils/installer.js +10 -0
- package/dist/utils/npm-search.js +1 -0
- package/dist/utils/profile-manager.js +4 -0
- package/dist/utils/prompt-handler.js +25 -0
- package/dist/utils/version-checker.js +6 -0
- package/package.json +19 -6
- package/src/index.js +0 -148
- package/src/runner.js +0 -603
- package/src/templates/templates.js +0 -401
- package/src/utils/compatibility.js +0 -521
- package/src/utils/file-utils.js +0 -232
- package/src/utils/installer.js +0 -243
- package/src/utils/npm-search.js +0 -355
- package/src/utils/profile-manager.js +0 -219
- package/src/utils/prompt-handler.js +0 -386
- package/src/utils/version-checker.js +0 -169
package/README.md
CHANGED
|
@@ -34,14 +34,14 @@ A comprehensive command-line interface (CLI) tool designed to automate and strea
|
|
|
34
34
|
- Version selection (latest or specific)
|
|
35
35
|
- Multiple library queue management
|
|
36
36
|
|
|
37
|
-
-
|
|
37
|
+
- ** Dynamic Library Version Resolution**
|
|
38
38
|
- Automatically resolves compatible versions based on Angular version
|
|
39
39
|
- Checks peer dependencies from npm registry
|
|
40
40
|
- Matches major versions for Angular-scoped packages
|
|
41
41
|
- Displays compatibility warnings
|
|
42
42
|
- Caches npm responses for performance
|
|
43
43
|
|
|
44
|
-
-
|
|
44
|
+
- ** 📦 Popular Library Bundles**
|
|
45
45
|
- UI Framework Bundle (Material + CDK + Flex Layout)
|
|
46
46
|
- State Management Bundle (NgRx suite)
|
|
47
47
|
- Form & Validation Bundle
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{Command as l}from"commander";import{runCli as a}from"./runner.js";import{listProfiles as s,loadProfile as c,deleteProfile as p,displayProfileInfo as g,exportProfile as m,importProfile as f}from"./utils/profile-manager.js";import o from"chalk";import{readFileSync as d}from"fs";import{fileURLToPath as h}from"url";import{dirname as y,join as w}from"path";const u=h(import.meta.url),v=y(u),E=JSON.parse(d(w(v,"../package.json"),"utf-8")),i=new l;i.name("ng-init").description("Angular project initializer with intelligent version management and automation").version(E.version);i.command("create",{isDefault:!0}).alias("new").description("Create a new Angular project with interactive setup").action(()=>{a()});const n=i.command("profile").description("Manage configuration profiles");n.command("list").description("List all saved profiles").action(async()=>{try{const e=await s();if(e.length===0){console.log(o.yellow("No saved profiles found."));return}console.log(o.bold.cyan(`
|
|
3
|
+
\u{1F4CB} Saved Profiles:
|
|
4
|
+
`)),console.log(o.gray("\u2501".repeat(50))),e.forEach(r=>{console.log(o.white(" \u2022 ")+o.green(r))}),console.log(o.gray("\u2501".repeat(50))+`
|
|
5
|
+
`)}catch(e){console.error(o.red("Error listing profiles:"),e.message)}});n.command("show <name>").description("Show details of a profile").action(async e=>{try{const r=await c(e);if(!r){console.log(o.red(`Profile "${e}" not found.`));return}g(e,r)}catch(r){console.error(o.red("Error loading profile:"),r.message)}});n.command("delete <name>").description("Delete a profile").action(async e=>{try{await p(e)}catch(r){console.error(o.red("Error deleting profile:"),r.message)}});n.command("export <name> <output>").description("Export a profile to a file").action(async(e,r)=>{try{await m(e,r)}catch(t){console.error(o.red("Error exporting profile:"),t.message)}});n.command("import <file>").description("Import a profile from a file").action(async e=>{try{await f(e)}catch(r){console.error(o.red("Error importing profile:"),r.message)}});i.command("check").description("Check system versions and compatibility").action(async()=>{try{const{displaySystemVersions:e}=await import("./utils/version-checker.js");await e()}catch(e){console.error(o.red("Error checking versions:"),e.message)}});i.command("examples").description("Show usage examples").action(()=>{console.log(o.bold.cyan(`
|
|
6
|
+
\u{1F4DA} Usage Examples:
|
|
7
|
+
`)),console.log(o.gray("\u2501".repeat(50))),console.log(o.white("Create new project (interactive):")),console.log(o.green(" $ ng-init")+o.gray(" or ")+o.green(`ng-init create
|
|
8
|
+
`)),console.log(o.white("Check system versions:")),console.log(o.green(` $ ng-init check
|
|
9
|
+
`)),console.log(o.white("List saved profiles:")),console.log(o.green(` $ ng-init profile list
|
|
10
|
+
`)),console.log(o.white("Show profile details:")),console.log(o.green(` $ ng-init profile show my-profile
|
|
11
|
+
`)),console.log(o.white("Delete a profile:")),console.log(o.green(` $ ng-init profile delete my-profile
|
|
12
|
+
`)),console.log(o.white("Export a profile:")),console.log(o.green(` $ ng-init profile export my-profile ./profile.json
|
|
13
|
+
`)),console.log(o.white("Import a profile:")),console.log(o.green(` $ ng-init profile import ./profile.json
|
|
14
|
+
`)),console.log(o.gray("\u2501".repeat(50))+`
|
|
15
|
+
`)});i.parse(process.argv);
|
package/dist/runner.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var R=Object.defineProperty;var y=(u,v)=>R(u,"name",{value:v,configurable:!0});import{select as m,input as P,confirm as d,checkbox as N}from"@inquirer/prompts";import e from"chalk";import F from"path";import{displaySystemVersions as G,getNodeVersion as T,isNvmInstalled as D,switchNodeVersion as k,installNodeVersion as M,getInstalledNodeVersions as O}from"./utils/version-checker.js";import{getAngularVersions as _,getNodeRequirementsForAngular as U,getMajorVersions as W,getMinorVersionsForMajor as z,getPatchVersionsForMinor as H}from"./utils/npm-search.js";import{checkNodeCompatibility as J,displayCompatibilityStatus as q,findCompatibleVersions as B,getRecommendedNodeVersion as K,resolveLibraryVersionsAsync as Y}from"./utils/compatibility.js";import{createAngularProject as Q,installPackages as h,runNpmInstall as X,installNodeWithWinget as Z,displayNvmInstallGuide as ee}from"./utils/installer.js";import{interactiveLibrarySearch as oe,simpleLibraryInput as ae,askLibrarySearchPreference as se}from"./utils/prompt-handler.js";import{PROJECT_TEMPLATES as f,LIBRARY_BUNDLES as S,CONFIG_PRESETS as w,PROJECT_STRUCTURE as V,GIT_CONFIG as C,DOC_TEMPLATES as $}from"./templates/templates.js";import{initGitRepo as te,createGitignore as ne,createInitialCommit as ie,createProjectFolders as le,createProjectFiles as E,createReadme as re,createChangelog as ce,validateDirectoryName as ge,updatePackageJsonScripts as me}from"./utils/file-utils.js";import{saveProfile as de,loadProfile as ue,listProfiles as pe,displayProfileInfo as fe}from"./utils/profile-manager.js";import{readFileSync as ye}from"fs";import{fileURLToPath as he}from"url";import{dirname as we,join as ve}from"path";const be=he(import.meta.url),Pe=we(be),je=JSON.parse(ye(ve(Pe,"../package.json"),"utf-8"));async function ze(){try{console.log(e.bold.cyan(`
|
|
2
|
+
\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(e.bold.cyan(`\u2551 Angular Project Automation CLI v${je.version.padEnd(10)}\u2551`)),console.log(e.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
|
|
3
|
+
`));const u=await G(),v=await d({message:"Would you like to use a saved profile?",default:!1});let o={};if(v){const a=await pe();if(a.length===0)console.log(e.yellow(`No saved profiles found. Continuing with manual setup...
|
|
4
|
+
`));else{const s=await m({message:"Select a profile:",choices:a.map(g=>({name:g,value:g}))}),i=await ue(s);fe(s,i),await d({message:"Use this profile?",default:!0})&&(o=i)}}if(!o.angularVersion){console.log(e.bold.cyan(`
|
|
5
|
+
\u{1F4E6} Fetching Angular versions...
|
|
6
|
+
`));const a=await _();a.versions.length===0&&(console.log(e.red("Failed to fetch Angular versions. Please check your internet connection.")),process.exit(1));const i=W(a.versions).map(c=>{const p=`Angular ${c}`;return{name:a.latest&&a.latest.startsWith(`${c}.`)?`${p} (latest)`:p,value:c}}),n=await m({message:"Select Angular major version:",choices:i,pageSize:15}),t=z(a.versions,n).map(c=>({name:`v${c}.x`,value:c})),r=await m({message:`Select Angular ${n} minor version:`,choices:t,pageSize:15}),L=H(a.versions,r).map(c=>{let p=`v${c}`;return c===a.latest&&(p+=" (latest)"),c===a.lts&&(p+=" (LTS)"),{name:p,value:c}}),x=await m({message:`Select Angular ${r} patch version:`,choices:L,pageSize:15});o.angularVersion=x}console.log(e.green(`
|
|
7
|
+
\u2713 Selected Angular version: ${o.angularVersion}
|
|
8
|
+
`));const b=await U(o.angularVersion),I=await T(),j=J(I,b);if(q(j),!j.compatible)if(console.log(e.yellow(`\u26A0\uFE0F Node.js version incompatibility detected!
|
|
9
|
+
`)),await D()){console.log(e.cyan(`\u2713 nvm detected on your system
|
|
10
|
+
`));const s=await O(),i=B(s,b);if(i.length>0){console.log(e.green(`Found ${i.length} compatible Node version(s) installed:
|
|
11
|
+
`));const n=await m({message:"Select Node version to switch to:",choices:i.map(t=>({name:`v${t}`,value:t}))});console.log(e.cyan(`
|
|
12
|
+
Switching to Node.js v${n}...
|
|
13
|
+
`)),await k(n)||(console.log(e.red("Failed to switch Node version. Please try manually.")),process.exit(1)),console.log(e.green(`\u2713 Node version switched successfully
|
|
14
|
+
`))}else{console.log(e.yellow(`No compatible Node versions installed.
|
|
15
|
+
`));const n=K(b);await d({message:`Install Node.js v${n}?`,default:!0})?(await M(n)||(console.log(e.red("Failed to install Node version.")),process.exit(1)),console.log(e.green(`\u2713 Node.js installed successfully
|
|
16
|
+
`)),await k(n)):(console.log(e.red("Cannot proceed without compatible Node.js version.")),process.exit(1))}}else{console.log(e.yellow(`\u26A0\uFE0F nvm is not installed on your system
|
|
17
|
+
`));const s=await m({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"}]});s==="nvm"?(ee(),console.log(e.yellow(`
|
|
18
|
+
Please install nvm and run this CLI again.
|
|
19
|
+
`)),process.exit(0)):s==="direct"?(process.platform!=="win32"&&(console.log(e.red("Direct installation is only supported on Windows.")),process.exit(1)),await Z("LTS")||(console.log(e.red("Failed to install Node.js. Please install manually.")),process.exit(1)),console.log(e.yellow(`
|
|
20
|
+
Please restart your terminal and run this CLI again.
|
|
21
|
+
`)),process.exit(0)):(console.log(e.yellow(`Exiting. Please install a compatible Node.js version manually.
|
|
22
|
+
`)),process.exit(0))}o.projectName||(o.projectName=await P({message:"Enter project name:",validate:y(a=>{if(!a)return"Project name is required";const s=ge(a);return s===!0?!0:s},"validate")})),o.location||(await m({message:"Where would you like to create the project?",choices:[{name:"Current directory",value:"current"},{name:"Specify custom directory",value:"custom"}]})==="custom"?o.location=await P({message:"Enter directory path:",default:process.cwd()}):o.location=process.cwd());const l=F.join(o.location,o.projectName);if(!o.template)if(o.template=await m({message:"Select project template:",choices:[...Object.entries(f).map(([a,s])=>({name:`${s.name} - ${s.description}`,value:a})),{name:"Custom (configure manually)",value:"custom"}]}),o.template==="custom"){const a=await d({message:"Enable routing?",default:!0}),s=await m({message:"Select stylesheet format:",choices:[{name:"css",value:"css"},{name:"scss",value:"scss"},{name:"sass",value:"sass"},{name:"less",value:"less"}]}),i=await d({message:"Enable strict mode?",default:!0}),n=await d({message:"Use standalone components?",default:!1});o.options={routing:a,style:s,strict:i,standalone:n}}else o.options=f[o.template].options;if(!o.libraries){const a=await se();if(o.libraries=[],a==="interactive")o.libraries=await oe(o.angularVersion);else if(a==="manual")o.libraries=await ae(o.angularVersion);else if(a==="bundles"){const s=await N({message:"Select library bundles:",choices:Object.entries(S).map(([i,n])=>({name:`${n.name} - ${n.description}`,value:i}))});for(const i of s){const n=S[i];n.packages&&o.libraries.push(...n.packages),n.devPackages&&o.libraries.push(...n.devPackages.map(g=>({...g,isDev:!0})))}}if(o.template!=="custom"&&f[o.template].packages){const s=f[o.template].packages.map(i=>({name:i,version:"latest"}));o.libraries.push(...s)}if(o.template!=="custom"&&f[o.template].devPackages){const s=f[o.template].devPackages.map(i=>({name:i,version:"latest",isDev:!0}));o.libraries.push(...s)}}if(o.features||(o.features=await N({message:"Select additional features:",choices:[{name:"Git initialization",value:"git",checked:!0},{name:"Create project structure",value:"structure",checked:!0},{name:"Generate README.md",value:"readme",checked:!0},{name:"Generate CHANGELOG.md",value:"changelog",checked:!1},{name:"ESLint + Prettier setup",value:"eslint",checked:!1},{name:"Husky pre-commit hooks",value:"husky",checked:!1}]})),await d({message:"Save this configuration as a profile?",default:!1})){const a=await P({message:"Enter profile name:",validate:y(s=>s?!0:"Profile name is required","validate")});await de(a,o)}console.log(e.bold.cyan(`
|
|
23
|
+
\u{1F4CB} Project Configuration Summary
|
|
24
|
+
`)),console.log(e.gray("\u2501".repeat(50))),console.log(e.white("Project Name: ")+e.green(o.projectName)),console.log(e.white("Location: ")+e.cyan(l)),console.log(e.white("Angular Version: ")+e.green(o.angularVersion)),console.log(e.white("Template: ")+e.cyan(o.template)),console.log(e.white("Libraries: ")+e.cyan(o.libraries.length)),console.log(e.white("Features: ")+e.cyan(o.features.join(", "))),console.log(e.gray("\u2501".repeat(50))+`
|
|
25
|
+
`),await d({message:"Create project with this configuration?",default:!0})||(console.log(e.yellow(`Project creation cancelled.
|
|
26
|
+
`)),process.exit(0)),console.log(e.bold.cyan(`
|
|
27
|
+
\u{1F680} Creating Angular project...
|
|
28
|
+
`));const A={...o.options,skipInstall:!0};if(await Q(o.projectName,o.angularVersion,A)||(console.log(e.red("Failed to create Angular project.")),process.exit(1)),o.libraries.length>0){console.log(e.bold.cyan(`
|
|
29
|
+
\u{1F4E6} Resolving library versions...
|
|
30
|
+
`));const a=await Y(o.libraries,o.angularVersion),s=a.filter(t=>t.adjusted);s.length>0&&(console.log(e.green(`\u2713 Dynamically resolved compatible library versions:
|
|
31
|
+
`)),s.forEach(t=>{console.log(e.gray(` ${t.name}: ${t.originalVersion} \u2192 ${t.version}`)),t.reason&&console.log(e.gray(` \u2514\u2500 ${t.reason}`))}),console.log(""));const i=a.filter(t=>t.warning);i.length>0&&(console.log(e.yellow(`\u26A0\uFE0F Potential compatibility warnings:
|
|
32
|
+
`)),i.forEach(t=>{console.log(e.yellow(` ${t.name}@${t.version}`)),t.reason&&console.log(e.gray(` \u2514\u2500 ${t.reason}`))}),console.log(""));const n=a.filter(t=>!t.isDev),g=a.filter(t=>t.isDev);if(n.length>0){console.log(e.bold.cyan(`\u{1F4E6} Installing production libraries...
|
|
33
|
+
`));const t=n.map(r=>r.version==="latest"?r.name:`${r.name}@${r.version}`);await h(t,l)}if(g.length>0){console.log(e.bold.cyan(`\u{1F4E6} Installing dev libraries...
|
|
34
|
+
`));const t=g.map(r=>r.version==="latest"?r.name:`${r.name}@${r.version}`);await h(t,l,!0)}}if(console.log(e.bold.cyan(`
|
|
35
|
+
\u{1F4E5} Installing dependencies...
|
|
36
|
+
`)),await X(l),o.features.includes("structure")&&(console.log(e.bold.cyan(`
|
|
37
|
+
\u{1F4C1} Creating project structure...
|
|
38
|
+
`)),await le(l,V.standard.folders),await E(l,V.standard.files)),o.features.includes("git")&&(console.log(e.bold.cyan(`
|
|
39
|
+
\u{1F527} Initializing Git repository...
|
|
40
|
+
`)),await te(l),await ne(l,C.gitignore)),o.features.includes("readme")){console.log(e.bold.cyan(`
|
|
41
|
+
\u{1F4DD} Generating README.md...
|
|
42
|
+
`));const a=$.readme(o.projectName,"An Angular application created with Angular Project Automator");await re(l,a)}if(o.features.includes("changelog")&&await ce(l,$.changelog),o.features.includes("eslint")){console.log(e.bold.cyan(`
|
|
43
|
+
\u{1F527} Setting up ESLint + Prettier...
|
|
44
|
+
`));const a=w.eslint.packages.map(s=>s);await h(a,l,!0),await E(l,w.eslint.files)}if(o.features.includes("husky")){console.log(e.bold.cyan(`
|
|
45
|
+
\u{1F436} Setting up Husky...
|
|
46
|
+
`));const a=w.husky.devPackages.map(s=>s);await h(a,l,!0),await me(l,w.husky.scripts)}o.features.includes("git")&&(console.log(e.bold.cyan(`
|
|
47
|
+
\u{1F4DD} Creating initial commit...
|
|
48
|
+
`)),await ie(l,C.initialCommitMessage)),console.log(e.bold.green(`
|
|
49
|
+
\u2705 Project created successfully! \u{1F389}
|
|
50
|
+
`)),console.log(e.bold.cyan(`\u{1F4CA} Next Steps:
|
|
51
|
+
`)),console.log(e.gray("\u2501".repeat(50))),console.log(e.white("1. ")+e.cyan(`cd ${o.projectName}`)),console.log(e.white("2. ")+e.cyan("ng serve")),console.log(e.white("3. ")+e.cyan("Open http://localhost:4200 in your browser")),console.log(e.gray("\u2501".repeat(50))),console.log(e.bold.cyan(`
|
|
52
|
+
\u{1F4A1} Useful Commands:
|
|
53
|
+
`)),console.log(e.gray(" ng generate component <name> ")+e.white("Create a component")),console.log(e.gray(" ng generate service <name> ")+e.white("Create a service")),console.log(e.gray(" ng build ")+e.white("Build for production")),console.log(e.gray(" ng test ")+e.white("Run unit tests")),console.log(e.gray(" ng help ")+e.white(`Get more help
|
|
54
|
+
`)),console.log(e.bold.green(`Happy coding! \u{1F680}
|
|
55
|
+
`))}catch(u){console.error(e.red(`
|
|
56
|
+
\u274C Error:`),u.message),u.stack&&console.error(e.gray(u.stack)),process.exit(1)}}y(ze,"runCli");export{ze as runCli};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
var n=Object.defineProperty;var s=(e,t)=>n(e,"name",{value:t,configurable:!0});const a={basic:{name:"Basic SPA",description:"Minimal setup with routing",options:{routing:!0,style:"css",strict:!1,standalone:!1},packages:[]},enterprise:{name:"Enterprise",description:"NgRx, Angular Material, strict mode, ESLint",options:{routing:!0,style:"scss",strict:!0,standalone:!1},packages:["@angular/material","@angular/cdk","@ngrx/store","@ngrx/effects","@ngrx/entity","@ngrx/store-devtools","eslint"],devPackages:["@typescript-eslint/eslint-plugin","@typescript-eslint/parser"]},pwa:{name:"PWA Ready",description:"Service workers, manifest, offline support",options:{routing:!0,style:"scss",strict:!0,standalone:!1},packages:["@angular/pwa","@angular/service-worker"]},material:{name:"Material Design",description:"Angular Material UI components",options:{routing:!0,style:"scss",strict:!1,standalone:!1},packages:["@angular/material","@angular/cdk"]},testing:{name:"Testing Ready",description:"Jest, Testing Library, Spectator",options:{routing:!0,style:"scss",strict:!0,standalone:!1},packages:["@testing-library/angular","@ngneat/spectator"],devPackages:["jest","@types/jest","jest-preset-angular"]},standalone:{name:"Standalone Components",description:"Modern Angular with standalone components",options:{routing:!0,style:"scss",strict:!0,standalone:!0},packages:[]}},i={uiFramework:{name:"UI Framework Bundle",description:"Angular Material + CDK",packages:[{name:"@angular/material",version:"latest"},{name:"@angular/cdk",version:"latest"}]},stateManagement:{name:"State Management Bundle",description:"NgRx + Entity + Effects + DevTools",packages:[{name:"@ngrx/store",version:"latest"},{name:"@ngrx/effects",version:"latest"},{name:"@ngrx/entity",version:"latest"},{name:"@ngrx/store-devtools",version:"latest"}]},forms:{name:"Form & Validation Bundle",description:"Reactive Forms utilities and validators",packages:[{name:"ngx-mask",version:"latest"},{name:"@angular/forms",version:"latest"}]},testing:{name:"Testing Bundle",description:"Jest + Testing Library + Spectator",packages:[],devPackages:[{name:"jest",version:"latest"},{name:"@types/jest",version:"latest"},{name:"jest-preset-angular",version:"latest"},{name:"@testing-library/angular",version:"latest"},{name:"@ngneat/spectator",version:"latest"}]},performance:{name:"Performance Bundle",description:"Angular Universal + optimization tools",packages:[{name:"@nguniversal/express-engine",version:"latest"}]},authentication:{name:"Authentication Bundle",description:"Auth utilities and Firebase",packages:[{name:"@angular/fire",version:"latest"},{name:"firebase",version:"latest"}]},utilities:{name:"Utilities Bundle",description:"Common utility libraries",packages:[{name:"lodash",version:"latest"},{name:"date-fns",version:"latest"},{name:"rxjs",version:"latest"}]},http:{name:"HTTP & API Bundle",description:"HTTP client and API tools",packages:[{name:"@angular/common",version:"latest"},{name:"axios",version:"latest"}]}},o={typescript:{name:"TypeScript Strict Mode",files:{"tsconfig.json":s(e=>({...e,compilerOptions:{...e.compilerOptions,strict:!0,noImplicitAny:!0,noImplicitReturns:!0,noFallthroughCasesInSwitch:!0,strictNullChecks:!0}}),"tsconfig.json")}},eslint:{name:"ESLint + Prettier",packages:["eslint","prettier","eslint-config-prettier","eslint-plugin-prettier"],files:{".eslintrc.json":{extends:["eslint:recommended","plugin:@typescript-eslint/recommended","prettier"],parser:"@typescript-eslint/parser",plugins:["@typescript-eslint","prettier"],rules:{"prettier/prettier":"error"}},".prettierrc":{semi:!0,singleQuote:!0,trailingComma:"es5",printWidth:100,tabWidth:2}}},husky:{name:"Husky Pre-commit Hooks",devPackages:["husky","lint-staged"],scripts:{prepare:"husky install","pre-commit":"lint-staged"},files:{".husky/pre-commit":`#!/bin/sh
|
|
2
|
+
. "$(dirname "$0")/_/husky.sh"
|
|
3
|
+
|
|
4
|
+
npx lint-staged`,"lint-staged.config.js":`module.exports = {
|
|
5
|
+
'*.{js,ts}': ['eslint --fix', 'prettier --write'],
|
|
6
|
+
'*.{json,md}': ['prettier --write']
|
|
7
|
+
};`}}},l={standard:{name:"Standard Structure",folders:["src/app/core","src/app/core/services","src/app/core/guards","src/app/core/interceptors","src/app/shared","src/app/shared/components","src/app/shared/directives","src/app/shared/pipes","src/app/features","src/app/models","src/assets/images","src/assets/styles","src/environments"],files:{"src/app/core/README.md":`# Core Module
|
|
8
|
+
|
|
9
|
+
Singleton services, guards, and interceptors go here.`,"src/app/shared/README.md":`# Shared Module
|
|
10
|
+
|
|
11
|
+
Reusable components, directives, and pipes go here.`,"src/app/features/README.md":`# Features
|
|
12
|
+
|
|
13
|
+
Feature modules go here.`,"src/app/models/README.md":`# Models
|
|
14
|
+
|
|
15
|
+
TypeScript interfaces and types go here.`}},domain:{name:"Domain-Driven Structure",folders:["src/app/core","src/app/shared","src/app/domains","src/app/infrastructure"]}},c={gitignore:`# See http://help.github.com/ignore-files/ for more about ignoring files.
|
|
16
|
+
|
|
17
|
+
# Compiled output
|
|
18
|
+
/dist
|
|
19
|
+
/tmp
|
|
20
|
+
/out-tsc
|
|
21
|
+
/bazel-out
|
|
22
|
+
|
|
23
|
+
# Node
|
|
24
|
+
/node_modules
|
|
25
|
+
npm-debug.log
|
|
26
|
+
yarn-error.log
|
|
27
|
+
|
|
28
|
+
# IDEs and editors
|
|
29
|
+
.idea/
|
|
30
|
+
.project
|
|
31
|
+
.classpath
|
|
32
|
+
.c9/
|
|
33
|
+
*.launch
|
|
34
|
+
.settings/
|
|
35
|
+
*.sublime-workspace
|
|
36
|
+
|
|
37
|
+
# Visual Studio Code
|
|
38
|
+
.vscode/*
|
|
39
|
+
!.vscode/settings.json
|
|
40
|
+
!.vscode/tasks.json
|
|
41
|
+
!.vscode/launch.json
|
|
42
|
+
!.vscode/extensions.json
|
|
43
|
+
.history/*
|
|
44
|
+
|
|
45
|
+
# Miscellaneous
|
|
46
|
+
/.angular/cache
|
|
47
|
+
.sass-cache/
|
|
48
|
+
/connect.lock
|
|
49
|
+
/coverage
|
|
50
|
+
/libpeerconnection.log
|
|
51
|
+
testem.log
|
|
52
|
+
/typings
|
|
53
|
+
|
|
54
|
+
# System files
|
|
55
|
+
.DS_Store
|
|
56
|
+
Thumbs.db
|
|
57
|
+
|
|
58
|
+
# Environment
|
|
59
|
+
.env
|
|
60
|
+
.env.local
|
|
61
|
+
`,initialCommitMessage:"Initial commit: Angular project setup"},p={readme:s((e,t)=>`# ${e}
|
|
62
|
+
|
|
63
|
+
${t||"An Angular application"}
|
|
64
|
+
|
|
65
|
+
## Description
|
|
66
|
+
|
|
67
|
+
This project was generated with Angular CLI.
|
|
68
|
+
|
|
69
|
+
## Development server
|
|
70
|
+
|
|
71
|
+
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.
|
|
72
|
+
|
|
73
|
+
## Code scaffolding
|
|
74
|
+
|
|
75
|
+
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\`.
|
|
76
|
+
|
|
77
|
+
## Build
|
|
78
|
+
|
|
79
|
+
Run \`ng build\` to build the project. The build artifacts will be stored in the \`dist/\` directory.
|
|
80
|
+
|
|
81
|
+
## Running unit tests
|
|
82
|
+
|
|
83
|
+
Run \`ng test\` to execute the unit tests via your test runner.
|
|
84
|
+
|
|
85
|
+
## Running end-to-end tests
|
|
86
|
+
|
|
87
|
+
Run \`ng e2e\` to execute the end-to-end tests via a platform of your choice.
|
|
88
|
+
|
|
89
|
+
## Further help
|
|
90
|
+
|
|
91
|
+
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.
|
|
92
|
+
|
|
93
|
+
## Project Structure
|
|
94
|
+
|
|
95
|
+
\`\`\`
|
|
96
|
+
src/
|
|
97
|
+
\u251C\u2500\u2500 app/
|
|
98
|
+
\u2502 \u251C\u2500\u2500 core/ # Singleton services, guards
|
|
99
|
+
\u2502 \u251C\u2500\u2500 shared/ # Common components, pipes, directives
|
|
100
|
+
\u2502 \u251C\u2500\u2500 features/ # Feature modules
|
|
101
|
+
\u2502 \u251C\u2500\u2500 models/ # TypeScript interfaces/types
|
|
102
|
+
\u2502 \u2514\u2500\u2500 services/ # Business logic services
|
|
103
|
+
\`\`\`
|
|
104
|
+
|
|
105
|
+
## Contributing
|
|
106
|
+
|
|
107
|
+
1. Fork the repository
|
|
108
|
+
2. Create your feature branch (\`git checkout -b feature/amazing-feature\`)
|
|
109
|
+
3. Commit your changes (\`git commit -m 'Add some amazing feature'\`)
|
|
110
|
+
4. Push to the branch (\`git push origin feature/amazing-feature\`)
|
|
111
|
+
5. Open a Pull Request
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
This project is licensed under the MIT License.
|
|
116
|
+
`,"readme"),changelog:`# Changelog
|
|
117
|
+
|
|
118
|
+
All notable changes to this project will be documented in this file.
|
|
119
|
+
|
|
120
|
+
## [Unreleased]
|
|
121
|
+
|
|
122
|
+
### Added
|
|
123
|
+
- Initial project setup
|
|
124
|
+
|
|
125
|
+
### Changed
|
|
126
|
+
|
|
127
|
+
### Fixed
|
|
128
|
+
|
|
129
|
+
### Removed
|
|
130
|
+
`};export{o as CONFIG_PRESETS,p as DOC_TEMPLATES,c as GIT_CONFIG,i as LIBRARY_BUNDLES,l as PROJECT_STRUCTURE,a as PROJECT_TEMPLATES};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var A=Object.defineProperty;var i=(e,n)=>A(e,"name",{value:n,configurable:!0});import d from"semver";import l from"chalk";import g from"axios";const y="https://registry.npmjs.org",f=new Map,v=300*1e3,w=100;function _(e,n){try{return{compatible:d.satisfies(e,n),current:e,required:n}}catch(t){return{compatible:!1,current:e,required:n,error:t.message}}}i(_,"checkNodeCompatibility");function q(e){return console.log(l.bold.cyan(`
|
|
2
|
+
\u{1F4CB} Compatibility Check
|
|
3
|
+
`)),console.log(l.gray("\u2501".repeat(50))),console.log(l.white("Current Node.js: ")+l.cyan(`v${e.current}`)),console.log(l.white("Required Node.js: ")+l.cyan(e.required)),e.compatible?console.log(l.white("Status: ")+l.green("\u2713 Compatible")):console.log(l.white("Status: ")+l.red("\u2717 Incompatible")),console.log(l.gray("\u2501".repeat(50))+`
|
|
4
|
+
`),e.compatible}i(q,"displayCompatibilityStatus");function E(e,n){try{return e.filter(t=>{try{return d.satisfies(t,n)}catch{return!1}}).sort((t,r)=>d.rcompare(t,r))}catch{return[]}}i(E,"findCompatibleVersions");function S(e){try{const n=e.split("||").map(t=>t.trim());for(const t of n){const r=t.match(/(\d+)\./);if(r){const o=parseInt(r[1]);if(o===20)return"20.11.0";if(o===18)return"18.19.0";if(o===16)return"16.20.2";if(o===14)return"14.21.3"}}return"18.19.0"}catch{return"18.19.0"}}i(S,"getRecommendedNodeVersion");async function x(e){try{return((await g.get(`${y}/@angular/cli/${e}`,{timeout:5e3})).data.engines||{}).node||null}catch{return null}}i(x,"getAngularNodeCompatibility");const h={19:"^18.19.1 || ^20.11.1 || ^22.0.0",18:"^18.19.1 || ^20.11.1 || ^22.0.0",17:"^18.13.0 || ^20.9.0",16:"^16.14.0 || ^18.10.0",15:"^14.20.0 || ^16.13.0 || ^18.10.0",14:"^14.15.0 || ^16.10.0",13:"^12.20.0 || ^14.15.0 || ^16.10.0",12:"^12.20.0 || ^14.15.0",11:"^10.13.0 || ^12.11.0",10:"^10.13.0 || ^12.11.0"},T=h;async function V(e){const n=await x(e);if(n)return n;const t=e.split(".")[0];return h[t]||"^18.13.0 || ^20.9.0"}i(V,"getNodeRequirementFromMatrix");function N(e){return d.valid(e)!==null}i(N,"isValidAngularVersion");function O(e,n){if(!e)return{needed:!0,reason:"Angular CLI is not installed"};const t=parseInt(e.split(".")[0]),r=parseInt(n.split(".")[0]);return t!==r?{needed:!0,reason:`Angular CLI version mismatch (current: ${t}, target: ${r})`,suggestion:`Consider using npx @angular/cli@${n} instead`}:{needed:!1,reason:"Angular CLI version is compatible"}}i(O,"needsAngularCli");async function $(e){const n=e,t=f.get(n);if(t&&Date.now()-t.timestamp<v)return t.data;try{const o=(await g.get(`${y}/${encodeURIComponent(e)}`,{timeout:1e4})).data;if(f.size>=w){const s=f.keys().next().value;f.delete(s)}return f.set(n,{data:o,timestamp:Date.now()}),o}catch(r){return console.error(l.gray(`Could not fetch package data for ${e}: ${r.message}`)),null}}i($,"fetchPackageData");async function j(e,n){try{return(await g.get(`${y}/${encodeURIComponent(e)}/${n}`,{timeout:5e3})).data}catch{return null}}i(j,"fetchPackageVersionData");async function D(e,n){return(await j(e,n))?.peerDependencies||{}}i(D,"getPackagePeerDependencies");async function b(e,n,t){const r=await D(e,n),o=r["@angular/core"]||r["@angular/common"];if(!o)return{compatible:!0,reason:"No Angular peer dependency"};try{const s=d.satisfies(t,o);return{compatible:s,peerDependency:o,reason:s?`Angular ${t} satisfies ${o}`:`Angular ${t} does not satisfy ${o}`}}catch{const a=t.split(".")[0],m=[`^${a}.`,`~${a}.`,`>=${a}.`,`${a}.`].some(c=>o.includes(c));return{compatible:m,peerDependency:o,reason:m?`Peer dependency appears compatible with Angular ${a}`:`Peer dependency ${o} may not support Angular ${a}`}}}i(b,"isVersionCompatibleWithAngular");async function C(e,n,t=!0){const r=await $(e);if(!r)return{version:"latest",source:"fallback",reason:"Could not fetch package data"};const o=parseInt(n.split(".")[0]),s=Object.keys(r.versions||{}).filter(c=>!c.includes("rc")&&!c.includes("beta")&&!c.includes("alpha")&&!c.includes("next")).sort((c,p)=>d.rcompare(c,p));if(e.startsWith("@angular/")){const c=s.filter(p=>parseInt(p.split(".")[0])===o);if(c.length>0)return{version:`^${c[0]}`,source:"dynamic",reason:`Matched Angular major version ${o}`}}const a=[],u=s.slice(0,20);for(const c of u){const p=await b(e,c,n);if(p.compatible&&(a.push({version:c,peerDependency:p.peerDependency}),t))return{version:`^${c}`,source:"dynamic",reason:p.reason,peerDependency:p.peerDependency}}if(a.length>0){const c=a[0];return{version:`^${c.version}`,source:"dynamic",reason:`Found ${a.length} compatible version(s)`,peerDependency:c.peerDependency}}const m=r["dist-tags"]?.latest;return{version:m?`^${m}`:"latest",source:"fallback",reason:"No version with compatible Angular peer dependency found",warning:!0}}i(C,"findCompatibleLibraryVersion");async function U(e,n){return(await C(e,n)).version}i(U,"getCompatibleLibraryVersionAsync");function I(e,n){const t=n.split(".")[0];return e.startsWith("@angular/")?`^${t}.0.0`:e.startsWith("@ngrx/")?`^${t}.0.0`:"latest"}i(I,"getCompatibleLibraryVersion");async function W(e,n){const t=[];for(const r of e){const o=r.version||"latest";if(o==="latest"){const s=await C(r.name,n);t.push({...r,version:s.version,originalVersion:o,adjusted:s.source==="dynamic",source:s.source,reason:s.reason,warning:s.warning||!1})}else{const s=await b(r.name,o.replace(/[\^~]/,""),n);t.push({...r,adjusted:!1,compatible:s.compatible,reason:s.reason,warning:!s.compatible})}}return t}i(W,"resolveLibraryVersionsAsync");function F(e,n){return e.map(t=>{const r=t.version||"latest";if(r==="latest"){const o=I(t.name,n);return{...t,version:o,originalVersion:r,adjusted:o!=="latest"}}return{...t,adjusted:!1}})}i(F,"resolveLibraryVersions");function G(e,n){if(!e||e==="No Angular peer dependency")return{compatible:!0,reason:"No Angular peer dependency specified"};try{return d.satisfies(n,e)?{compatible:!0,reason:`Angular ${n} satisfies peer dependency '${e}'`}:{compatible:!1,reason:`Angular ${n} does not satisfy peer dependency '${e}'`}}catch{const r=n.split(".")[0];return[`^${r}.`,`~${r}.`,`>=${r}.`,`${r}.x`,`${r}.0.0`,` ${r}.`].some(a=>e.includes(a))?{compatible:!0,reason:`Peer dependency '${e}' appears compatible with Angular ${r}`}:{compatible:!1,reason:`Peer dependency '${e}' may not support Angular ${r}`}}}i(G,"checkLibraryCompatibility");async function K(e,n,t=10){const r=await $(e);if(!r)return[];const o=Object.keys(r.versions||{}).filter(a=>!a.includes("rc")&&!a.includes("beta")&&!a.includes("alpha")&&!a.includes("next")).sort((a,u)=>d.rcompare(a,u)),s=[];for(const a of o){if(s.length>=t)break;const u=await b(e,a,n);u.compatible&&s.push({version:a,peerDependency:u.peerDependency,reason:u.reason})}return s}i(K,"getAllCompatibleVersions");export{T as ANGULAR_NODE_COMPATIBILITY,G as checkLibraryCompatibility,_ as checkNodeCompatibility,q as displayCompatibilityStatus,C as findCompatibleLibraryVersion,E as findCompatibleVersions,K as getAllCompatibleVersions,x as getAngularNodeCompatibility,I as getCompatibleLibraryVersion,U as getCompatibleLibraryVersionAsync,V as getNodeRequirementFromMatrix,D as getPackagePeerDependencies,S as getRecommendedNodeVersion,N as isValidAngularVersion,b as isVersionCompatibleWithAngular,O as needsAngularCli,F as resolveLibraryVersions,W as resolveLibraryVersionsAsync};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var g=Object.defineProperty;var n=(r,t)=>g(r,"name",{value:t,configurable:!0});import i from"fs/promises";import c from"path";import o from"chalk";import{execa as l}from"execa";import u from"ora";async function P(r){const t=u("Initializing Git repository...").start();try{return await l("git",["init"],{cwd:r}),t.succeed("Git repository initialized"),!0}catch(e){return t.fail("Failed to initialize Git repository"),console.error(o.red(e.message)),!1}}n(P,"initGitRepo");async function j(r,t){try{const e=c.join(r,".gitignore");return await i.writeFile(e,t,"utf-8"),console.log(o.green("\u2713 Created .gitignore")),!0}catch(e){return console.error(o.red("Failed to create .gitignore:"),e.message),!1}}n(j,"createGitignore");async function F(r,t){const e=u("Creating initial commit...").start();try{return await l("git",["add","."],{cwd:r}),await l("git",["commit","-m",t],{cwd:r}),e.succeed("Initial commit created"),!0}catch(a){return e.fail("Failed to create initial commit"),console.error(o.red(a.message)),!1}}n(F,"createInitialCommit");async function O(r,t){const e=u("Creating project structure...").start();try{for(const a of t){const s=c.join(r,a);await i.mkdir(s,{recursive:!0})}return e.succeed("Project structure created"),!0}catch(a){return e.fail("Failed to create project structure"),console.error(o.red(a.message)),!1}}n(O,"createProjectFolders");async function k(r,t){try{for(const[e,a]of Object.entries(t)){const s=c.join(r,e),d=c.dirname(s);await i.mkdir(d,{recursive:!0});const f=typeof a=="string"?a:JSON.stringify(a,null,2);await i.writeFile(s,f,"utf-8")}return console.log(o.green(`\u2713 Created ${Object.keys(t).length} file(s)`)),!0}catch(e){return console.error(o.red("Failed to create project files:"),e.message),!1}}n(k,"createProjectFiles");async function x(r,t){try{const e=c.join(r,"README.md");return await i.writeFile(e,t,"utf-8"),console.log(o.green("\u2713 Created README.md")),!0}catch(e){return console.error(o.red("Failed to create README.md:"),e.message),!1}}n(x,"createReadme");async function L(r,t){try{const e=c.join(r,"CHANGELOG.md");return await i.writeFile(e,t,"utf-8"),console.log(o.green("\u2713 Created CHANGELOG.md")),!0}catch(e){return console.error(o.red("Failed to create CHANGELOG.md:"),e.message),!1}}n(L,"createChangelog");async function J(r){try{return(await i.readdir(r)).length===0}catch{return!0}}n(J,"isDirectoryEmpty");async function M(r){try{return await i.mkdir(r,{recursive:!0}),!0}catch(t){return console.error(o.red("Failed to create directory:"),t.message),!1}}n(M,"ensureDirectory");function N(r){return/[<>:"|?*\x00-\x1f]/.test(r)?"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(r.toUpperCase())?"Directory name is reserved":r.length===0?"Directory name cannot be empty":r.length>255?"Directory name is too long":r.endsWith(" ")||r.endsWith(".")?"Directory name cannot end with a space or period":!0}n(N,"validateDirectoryName");async function D(r,t){try{const e=c.join(r,"package.json"),a=JSON.parse(await i.readFile(e,"utf-8"));return a.scripts={...a.scripts,...t},await i.writeFile(e,JSON.stringify(a,null,2),"utf-8"),console.log(o.green("\u2713 Updated package.json scripts")),!0}catch(e){return console.error(o.red("Failed to update package.json:"),e.message),!1}}n(D,"updatePackageJsonScripts");async function G(r){try{const t=c.join(r,"package.json"),e=await i.readFile(t,"utf-8");return JSON.parse(e)}catch{return null}}n(G,"readPackageJson");async function v(r,t){try{const e=c.join(r,"package.json");return await i.writeFile(e,JSON.stringify(t,null,2),"utf-8"),!0}catch(e){return console.error(o.red("Failed to write package.json:"),e.message),!1}}n(v,"writePackageJson");export{L as createChangelog,j as createGitignore,F as createInitialCommit,k as createProjectFiles,O as createProjectFolders,x as createReadme,M as ensureDirectory,P as initGitRepo,J as isDirectoryEmpty,G as readPackageJson,D as updatePackageJsonScripts,N as validateDirectoryName,v as writePackageJson};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var u=Object.defineProperty;var o=(e,t)=>u(e,"name",{value:t,configurable:!0});import{execa as a}from"execa";import c from"ora";import n from"chalk";import{platform as d}from"os";async function v(e="LTS"){const t=c("Installing Node.js with winget...").start();try{return await a("winget",["install",e==="LTS"?"OpenJS.NodeJS.LTS":"OpenJS.NodeJS"],{stdio:"inherit"}),t.succeed("Node.js installed successfully"),!0}catch(l){return t.fail("Failed to install Node.js"),console.error(n.red(l.message)),!1}}o(v,"installNodeWithWinget");function g(){const e=d();return e==="win32"?{os:"Windows",method:"Download and install",url:"https://github.com/coreybutler/nvm-windows/releases",command:null,description:"Download the nvm-setup.zip file from the releases page and run the installer."}:e==="darwin"?{os:"macOS",method:"Using curl",url:"https://github.com/nvm-sh/nvm",command:"curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash",description:"Run the curl command in your terminal to install nvm."}:{os:"Linux",method:"Using curl or wget",url:"https://github.com/nvm-sh/nvm",command:"curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash",alternativeCommand:"wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash",description:"Run either the curl or wget command in your terminal to install nvm."}}o(g,"getNvmInstallInstructions");function $(){const e=g();console.log(n.bold.yellow(`
|
|
2
|
+
\u{1F4DA} nvm Installation Guide
|
|
3
|
+
`)),console.log(n.gray("\u2501".repeat(50))),console.log(n.white("Operating System: ")+n.cyan(e.os)),console.log(n.white("Method: ")+n.cyan(e.method)),console.log(n.white("URL: ")+n.blue(e.url)),e.command&&(console.log(n.white(`
|
|
4
|
+
Command:`)),console.log(n.green(` ${e.command}`)),e.alternativeCommand&&(console.log(n.white(`
|
|
5
|
+
Alternative:`)),console.log(n.green(` ${e.alternativeCommand}`)))),console.log(n.white(`
|
|
6
|
+
Description:`)),console.log(n.gray(` ${e.description}`)),console.log(n.gray("\u2501".repeat(50))+`
|
|
7
|
+
`),console.log(n.yellow("\u{1F4A1} Benefits of using nvm:")),console.log(n.gray(" \u2022 Manage multiple Node.js versions")),console.log(n.gray(" \u2022 Switch between versions easily")),console.log(n.gray(" \u2022 No admin/sudo required for installations")),console.log(n.gray(` \u2022 Project-specific Node versions
|
|
8
|
+
`))}o($,"displayNvmInstallGuide");async function p(e,t="latest"){const l=c(`Installing ${e}@${t}...`).start();try{const s=t==="latest"?e:`${e}@${t}`;return await a("npm",["install","-g",s],{stdio:"inherit"}),l.succeed(`${e} installed successfully`),!0}catch(s){return l.fail(`Failed to install ${e}`),console.error(n.red(s.message)),!1}}o(p,"installGlobalPackage");async function b(e,t,l=!1){const s=c(`Installing ${e.length} package(s)...`).start();try{const r=["install"];return l&&r.push("--save-dev"),r.push(...e),await a("npm",r,{cwd:t}),s.succeed("Packages installed successfully"),!0}catch{s.warn("Failed with strict dependencies, retrying with --legacy-peer-deps...");try{const i=["install","--legacy-peer-deps"];return l&&i.push("--save-dev"),i.push(...e),await a("npm",i,{cwd:t}),s.succeed("Packages installed successfully with --legacy-peer-deps"),console.log(n.yellow("\u26A0\uFE0F Note: Installed with --legacy-peer-deps flag due to peer dependency conflicts")),!0}catch(i){return s.fail("Failed to install packages"),console.error(n.red(i.message)),console.log(n.yellow(`
|
|
9
|
+
\u{1F4A1} Tip: You can try installing manually with:`)),console.log(n.cyan(` cd ${t}`)),console.log(n.cyan(` npm install ${e.join(" ")} --force`)),!1}}}o(b,"installPackages");async function I(e){try{return await a("npm",["init","-y"],{cwd:e,stdio:"inherit"}),!0}catch{return console.error(n.red("Failed to initialize npm project")),!1}}o(I,"initNpmProject");async function x(e){const t=c("Installing dependencies...").start();try{return await a("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 a("npm",["install","--legacy-peer-deps"],{cwd:e}),t.succeed("Dependencies installed successfully with --legacy-peer-deps"),console.log(n.yellow("\u26A0\uFE0F Note: Installed with --legacy-peer-deps flag due to peer dependency conflicts")),!0}catch(s){return t.fail("Failed to install dependencies"),console.error(n.red(s.message)),console.log(n.yellow(`
|
|
10
|
+
\u{1F4A1} Tip: You can try installing manually with:`)),console.log(n.cyan(` cd ${e}`)),console.log(n.cyan(" npm install --force")),!1}}}o(x,"runNpmInstall");async function S(e="latest"){return p("@angular/cli",e)}o(S,"installAngularCli");async function N(e,t,l={}){const s=c(`Creating Angular project: ${e}...`).start();try{const r=["new",e];l.skipInstall&&r.push("--skip-install"),l.routing!==void 0&&r.push(`--routing=${l.routing}`),l.style&&r.push(`--style=${l.style}`),l.strict!==void 0&&r.push(`--strict=${l.strict}`),l.standalone!==void 0&&r.push(`--standalone=${l.standalone}`);const i=t?`@angular/cli@${t}`:"@angular/cli";return await a("npx",[i,...r],{stdio:"inherit"}),s.succeed(`Angular project ${e} created successfully`),!0}catch(r){return s.fail("Failed to create Angular project"),console.error(n.red(r.message)),!1}}o(N,"createAngularProject");export{N as createAngularProject,$ as displayNvmInstallGuide,g as getNvmInstallInstructions,I as initNpmProject,S as installAngularCli,p as installGlobalPackage,v as installNodeWithWinget,b as installPackages,x as runNpmInstall};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f=Object.defineProperty;var l=(e,t)=>f(e,"name",{value:t,configurable:!0});import p from"axios";import h from"lodash.debounce";const g="https://registry.npmjs.org",y="https://registry.npmjs.org/-/v1/search",$="https://api.npmjs.org/downloads/point/last-week";async function b(e,t=10){try{return(await p.get(y,{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),[]}}l(b,"searchNpmPackages");async function m(e){try{const t=await p.get(`${g}/${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}}l(m,"getPackageDetails");async function x(e){try{return(await p.get(`${$}/${e}`,{timeout:5e3})).data.downloads}catch{return 0}}l(x,"getPackageDownloads");async function D(e){return await m(e)!==null}l(D,"validatePackage");async function M(e){try{const[t,r]=await Promise.all([m(e),x(e)]);return t?{...t,weeklyDownloads:r}:null}catch(t){return console.error(`Error getting package info for ${e}:`,t.message),null}}l(M,"getEnhancedPackageInfo");function N(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}l(N,"formatDownloads");const E=h(async(e,t)=>{if(!e||e.length<2){t([]);return}const r=await b(e,10);t(r)},300);async function R(){try{const e=await p.get(`${g}/@angular/cli`,{timeout:1e4}),t=Object.keys(e.data.versions||{}).filter(n=>!n.includes("rc")&&!n.includes("beta")&&!n.includes("next")).sort((n,s)=>{const i=n.split(".").map(Number),c=s.split(".").map(Number);for(let o=0;o<Math.max(i.length,c.length);o++){const a=i[o]||0,u=c[o]||0;if(a!==u)return u-a}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}}}l(R,"getAngularVersions");function j(e){const t=new Set;return e.forEach(r=>{const n=r.split(".")[0];t.add(n)}),Array.from(t).sort((r,n)=>Number(n)-Number(r))}l(j,"getMajorVersions");function A(e,t){const r=new Set;return e.filter(n=>n.startsWith(`${t}.`)).forEach(n=>{const s=n.split("."),i=`${s[0]}.${s[1]}`;r.add(i)}),Array.from(r).sort((n,s)=>{const i=n.split(".").map(Number),c=s.split(".").map(Number);for(let o=0;o<Math.max(i.length,c.length);o++){const a=i[o]||0,u=c[o]||0;if(a!==u)return u-a}return 0})}l(A,"getMinorVersionsForMajor");function S(e,t){return e.filter(r=>r.startsWith(`${t}.`)).sort((r,n)=>{const s=r.split(".").map(Number),i=n.split(".").map(Number);for(let c=0;c<Math.max(s.length,i.length);c++){const o=s[c]||0,a=i[c]||0;if(o!==a)return a-o}return 0})}l(S,"getPatchVersionsForMinor");async function w(e){try{const t=await p.get(`${g}/${e}`,{timeout:1e4}),r=Object.keys(t.data.versions||{}).filter(s=>!s.includes("rc")&&!s.includes("beta")&&!s.includes("next")&&!s.includes("alpha")).sort((s,i)=>{const c=s.split(".").map(Number),o=i.split(".").map(Number);for(let a=0;a<Math.max(c.length,o.length);a++){const u=c[a]||0,d=o[a]||0;if(u!==d)return d-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}}}l(w,"getPackageVersions");async function _(e){try{return((await p.get(`${g}/@angular/cli/${e}`,{timeout:5e3})).data.engines||{}).node||"^18.13.0 || ^20.9.0"}catch{const r=parseInt(e.split(".")[0]);return r>=19?"^18.19.1 || ^20.11.1 || ^22.0.0":r>=17?"^18.13.0 || ^20.9.0":r>=16?"^16.14.0 || ^18.10.0":r>=15?"^14.20.0 || ^16.13.0 || ^18.10.0":r>=14?"^14.15.0 || ^16.10.0":"^14.0.0 || ^16.0.0 || ^18.0.0"}}l(_,"getNodeRequirementsForAngular");async function P(e,t){try{return(await p.get(`${g}/${e}/${t}`,{timeout:5e3})).data.peerDependencies||{}}catch(r){return console.error(`Error fetching peer dependencies for ${e}@${t}:`,r.message),{}}}l(P,"getPackagePeerDependencies");async function F(e,t,r=5){try{const n=await w(e),s=t.split(".")[0],i=[];for(const c of n.versions){if(i.length>=r)break;const o=await P(e,c);if(o["@angular/core"]||o["@angular/common"]){const a=o["@angular/core"]||o["@angular/common"];(a.includes(`^${s}.`)||a.includes(`~${s}.`)||a.includes(`>=${s}.`)||a.includes(`${s}.x`))&&i.push({version:c,peerDependency:a})}else i.push({version:c,peerDependency:"No Angular peer dependency"})}return i}catch(n){return console.error(`Error finding compatible versions for ${e}:`,n.message),[]}}l(F,"findCompatiblePackageVersions");export{E as debouncedSearch,F as findCompatiblePackageVersions,N as formatDownloads,R as getAngularVersions,M as getEnhancedPackageInfo,j as getMajorVersions,A as getMinorVersionsForMajor,_ as getNodeRequirementsForAngular,m as getPackageDetails,x as getPackageDownloads,P as getPackagePeerDependencies,w as getPackageVersions,S as getPatchVersionsForMinor,b as searchNpmPackages,D as validatePackage};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var p=Object.defineProperty;var n=(r,e)=>p(r,"name",{value:e,configurable:!0});import a from"fs/promises";import l from"path";import{homedir as y}from"os";import o from"chalk";const c=l.join(y(),".ng-init"),f=l.join(c,"profiles.json");async function u(){try{return await a.mkdir(c,{recursive:!0}),!0}catch(r){return console.error(o.red("Failed to create profiles directory:"),r.message),!1}}n(u,"ensureProfilesDirectory");async function s(){try{await u();const r=await a.readFile(f,"utf-8");return JSON.parse(r)}catch{return{}}}n(s,"loadProfiles");async function g(r){try{return await u(),await a.writeFile(f,JSON.stringify(r,null,2),"utf-8"),!0}catch(e){return console.error(o.red("Failed to save profiles:"),e.message),!1}}n(g,"saveProfiles");async function w(r,e){const t=await s();t[r]={...e,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};const i=await g(t);return i&&console.log(o.green(`\u2713 Profile "${r}" saved successfully`)),i}n(w,"saveProfile");async function d(r){return(await s())[r]||null}n(d,"loadProfile");async function O(r){const e=await s();if(!e[r])return console.log(o.yellow(`Profile "${r}" not found`)),!1;delete e[r];const t=await g(e);return t&&console.log(o.green(`\u2713 Profile "${r}" deleted successfully`)),t}n(O,"deleteProfile");async function $(){const r=await s();return Object.keys(r)}n($,"listProfiles");async function b(r){const e=await d(r);return e?{name:r,angularVersion:e.angularVersion,template:e.template,libraries:e.libraries?.length||0,createdAt:e.createdAt,updatedAt:e.updatedAt}:null}n(b,"getProfileDetails");async function F(r,e){const t=await d(r);if(!t)return console.log(o.red(`Profile "${r}" not found`)),!1;try{const i={name:r,profile:t,exportedAt:new Date().toISOString(),version:"1.0.0"};return await a.writeFile(e,JSON.stringify(i,null,2),"utf-8"),console.log(o.green(`\u2713 Profile exported to ${e}`)),!0}catch(i){return console.error(o.red("Failed to export profile:"),i.message),!1}}n(F,"exportProfile");async function A(r){try{const e=await a.readFile(r,"utf-8"),t=JSON.parse(e);if(!t.name||!t.profile)return console.log(o.red("Invalid profile file format")),!1;const i=await w(t.name,t.profile);return i&&console.log(o.green(`\u2713 Profile "${t.name}" imported successfully`)),i}catch(e){return console.error(o.red("Failed to import profile:"),e.message),!1}}n(A,"importProfile");function D(r,e){console.log(o.bold.cyan(`
|
|
2
|
+
\u{1F4CB} Profile: ${r}
|
|
3
|
+
`)),console.log(o.gray("\u2501".repeat(50))),e.angularVersion&&console.log(o.white("Angular Version: ")+o.green(e.angularVersion)),e.template&&console.log(o.white("Template: ")+o.cyan(e.template)),e.libraries&&e.libraries.length>0&&(console.log(o.white("Libraries: ")+o.cyan(e.libraries.length)),e.libraries.slice(0,5).forEach(t=>{console.log(o.gray(` \u2022 ${t.name}@${t.version}`))}),e.libraries.length>5&&console.log(o.gray(` ... and ${e.libraries.length-5} more`))),e.options&&(console.log(o.white("Options:")),Object.entries(e.options).forEach(([t,i])=>{console.log(o.gray(` \u2022 ${t}: ${i}`))})),e.createdAt&&console.log(o.white("Created: ")+o.gray(new Date(e.createdAt).toLocaleString())),console.log(o.gray("\u2501".repeat(50))+`
|
|
4
|
+
`)}n(D,"displayProfileInfo");export{O as deleteProfile,D as displayProfileInfo,F as exportProfile,b as getProfileDetails,A as importProfile,$ as listProfiles,d as loadProfile,s as loadProfiles,w as saveProfile};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var A=Object.defineProperty;var m=(n,l)=>A(n,"name",{value:l,configurable:!0});import{search as C,select as p,input as f,confirm as y}from"@inquirer/prompts";import o from"chalk";import{searchNpmPackages as V,getEnhancedPackageInfo as D,formatDownloads as w,getPackageVersions as P,getMajorVersions as L,getMinorVersionsForMajor as E,getPatchVersionsForMinor as z}from"./npm-search.js";import{isVersionCompatibleWithAngular as $,getAllCompatibleVersions as j}from"./compatibility.js";async function _(n=null){const l=[];let c=!0;for(console.log(o.bold.cyan(`
|
|
2
|
+
\u{1F4E6} Interactive Library Search
|
|
3
|
+
`)),n&&console.log(o.gray(`Angular version: ${n} (compatibility will be checked)
|
|
4
|
+
`)),console.log(o.gray(`Type to search npm packages. Press Enter to select.
|
|
5
|
+
`));c;)try{const s=await C({message:"Search for a library:",source:m(async(e,{signal:i})=>!e||e.length<2?[]:(await V(e,15)).map(a=>({name:M(a),value:a.name,description:a.description})),"source"),pageSize:10});if(s){const e=await D(s);if(e){console.log(o.green(`
|
|
6
|
+
\u2713 Selected: ${e.name}`)),console.log(o.gray(` Description: ${e.description}`)),console.log(o.gray(` Latest version: ${e.latestVersion}`)),console.log(o.gray(` Weekly downloads: ${w(e.weeklyDownloads)}`));const i=await p({message:"How would you like to select the version?",choices:[{name:`Use latest (${e.latestVersion})`,value:"latest"},{name:"Choose specific version (major.minor.patch)",value:"specific"},{name:"Enter version manually",value:"manual"}],default:"latest"});let t=e.latestVersion;if(i==="specific"){console.log(o.cyan(`
|
|
7
|
+
\u{1F4E6} Fetching versions for ${e.name}...
|
|
8
|
+
`));const a=await P(e.name);if(a.versions.length===0)console.log(o.yellow("Could not fetch versions. Using latest version.")),t=e.latestVersion;else{const h=L(a.versions).map(r=>{const d=`${e.name} ${r}`;return{name:a.latest&&a.latest.startsWith(`${r}.`)?`${d} (latest)`:d,value:r}}),g=await p({message:`Select ${e.name} major version:`,choices:h,pageSize:15}),k=E(a.versions,g).map(r=>({name:`v${r}.x`,value:r})),v=await p({message:`Select ${e.name} ${g} minor version:`,choices:k,pageSize:15}),S=z(a.versions,v).map(r=>{let d=`v${r}`;return r===a.latest&&(d+=" (latest)"),r===a.lts&&(d+=" (LTS)"),{name:d,value:r}});t=await p({message:`Select ${e.name} ${v} patch version:`,choices:S,pageSize:15})}}else i==="manual"&&(t=await f({message:"Enter version:",default:e.latestVersion,validate:m(a=>a?!0:"Version is required","validate")}));if(n&&t!=="latest"){console.log(o.cyan(`
|
|
9
|
+
\u{1F50D} Checking compatibility with Angular ${n}...
|
|
10
|
+
`));const a=await $(e.name,t,n);if(a.compatible)console.log(o.green(`\u2713 ${e.name}@${t} is compatible with Angular ${n}`)),a.peerDependency&&console.log(o.gray(` Peer dependency: ${a.peerDependency}
|
|
11
|
+
`));else if(console.log(o.red(`\u2717 ${e.name}@${t} may not be compatible with Angular ${n}`)),console.log(o.gray(` ${a.reason}
|
|
12
|
+
`)),await y({message:"Would you like to see compatible versions?",default:!0})){console.log(o.cyan(`
|
|
13
|
+
\u{1F50D} Dynamically searching for compatible versions...
|
|
14
|
+
`));const h=await j(e.name,n,10);if(h.length>0){const g=h.map(u=>({name:`${u.version}${u.peerDependency?` (peer: ${u.peerDependency})`:""}`,value:u.version}));g.push({name:"Keep selected version anyway",value:t}),t=await p({message:"Select a compatible version:",choices:g,pageSize:12})}else if(console.log(o.yellow("No compatible versions found automatically.")),!await y({message:"Continue with the selected version anyway?",default:!1})){console.log(o.yellow(`Skipping this library.
|
|
15
|
+
`)),c=await y({message:"Add another library?",default:!0});continue}}}l.push({name:e.name,version:t,description:e.description}),console.log(o.green(`\u2713 Added ${e.name}@${t} to installation queue
|
|
16
|
+
`))}}c=await y({message:"Add another library?",default:!1})}catch(s){console.error(o.red("Error during library search:",s.message)),c=!1}return l}m(_,"interactiveLibrarySearch");function M(n){const l=w(n.weeklyDownloads||0),c=n.verified?" \u2713":"",s=n.description.substring(0,50)+(n.description.length>50?"...":"");return`${n.name}${c} - ${s} (v${n.version}, \u2B07 ${l}/week)`}m(M,"formatPackageChoice");async function B(n=null){const l=[];let c=!0;for(console.log(o.bold.cyan(`
|
|
17
|
+
\u{1F4E6} Add Libraries
|
|
18
|
+
`)),n&&console.log(o.gray(`Angular version: ${n} (compatibility will be checked)
|
|
19
|
+
`));c;){const s=await f({message:"Enter library name (or press Enter to skip):",validate:m(async i=>i?i.match(/^[@a-z0-9-~][a-z0-9-._~]*$/)?!0:"Invalid package name format":!0,"validate")});if(!s)break;const e=await f({message:`Enter version for ${s} (or 'latest'):`,default:"latest"});if(n&&e!=="latest"){console.log(o.cyan(`
|
|
20
|
+
\u{1F50D} Checking compatibility with Angular ${n}...
|
|
21
|
+
`));const i=await $(s,e,n);i.compatible?(console.log(o.green(`\u2713 ${s}@${e} is compatible with Angular ${n}`)),i.peerDependency&&console.log(o.gray(` Peer dependency: ${i.peerDependency}
|
|
22
|
+
`))):(console.log(o.red(`\u2717 ${s}@${e} may not be compatible with Angular ${n}`)),console.log(o.gray(` ${i.reason}
|
|
23
|
+
`)),console.log(o.yellow(`\u26A0\uFE0F This may cause installation issues. Consider using a different version.
|
|
24
|
+
`)))}l.push({name:s,version:e}),console.log(o.green(`\u2713 Added ${s}@${e}
|
|
25
|
+
`)),c=await y({message:"Add another library?",default:!1})}return l}m(B,"simpleLibraryInput");async function G(){return await p({message:"How would you like to add libraries?",choices:[{name:"Interactive search with autocomplete (Recommended)",value:"interactive"},{name:"Manual entry",value:"manual"},{name:"Choose from popular bundles",value:"bundles"},{name:"Skip for now",value:"skip"}],default:"interactive"})}m(G,"askLibrarySearchPreference");export{G as askLibrarySearchPreference,_ as interactiveLibrarySearch,B as simpleLibraryInput};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var u=Object.defineProperty;var r=(n,t)=>u(n,"name",{value:t,configurable:!0});import{execa as o}from"execa";import e from"chalk";import a from"semver";async function m(){try{const{stdout:n}=await o("node",["--version"]);return n.trim().replace("v","")}catch{return null}}r(m,"getNodeVersion");async function d(){try{const{stdout:n}=await o("npm",["--version"]);return n.trim()}catch{return null}}r(d,"getNpmVersion");async function c(){try{const{stdout:n}=await o("nvm",["--version"],{shell:!0});return n.trim()}catch{return null}}r(c,"getNvmVersion");async function g(){return await c()!==null}r(g,"isNvmInstalled");async function p(){try{const{stdout:n}=await o("ng",["version","--json"],{shell:!0});return JSON.parse(n).cli.version||null}catch{return null}}r(p,"getAngularCliVersion");async function w(){console.log(e.bold.cyan(`
|
|
2
|
+
\u{1F50D} System Environment Check
|
|
3
|
+
`)),console.log(e.gray("\u2501".repeat(50)));const n=await m(),t=await d(),s=await c(),i=await p();return console.log(e.white("Node.js: ")+(n?e.green(`v${n}`):e.red("Not installed"))),console.log(e.white("npm: ")+(t?e.green(`v${t}`):e.red("Not installed"))),console.log(e.white("nvm: ")+(s?e.green(`v${s}`):e.yellow("Not installed"))),console.log(e.white("Angular CLI: ")+(i?e.green(`v${i}`):e.yellow("Not installed"))),console.log(e.gray("\u2501".repeat(50))+`
|
|
4
|
+
`),{node:n,npm:t,nvm:s,angularCli:i}}r(w,"displaySystemVersions");async function V(){try{const{stdout:n}=await o("nvm",["list","available"],{shell:!0}),t=[],s=n.split(`
|
|
5
|
+
`);for(const i of s){const l=i.match(/(\d+\.\d+\.\d+)/);l&&t.push(l[1])}return t}catch{return[]}}r(V,"getAvailableNodeVersions");async function N(){try{const{stdout:n}=await o("nvm",["list"],{shell:!0}),t=[],s=n.split(`
|
|
6
|
+
`);for(const i of s){const l=i.match(/(\d+\.\d+\.\d+)/);l&&t.push(l[1])}return t}catch{return[]}}r(N,"getInstalledNodeVersions");async function x(n){try{return await o("nvm",["use",n],{shell:!0,stdio:"inherit"}),!0}catch{return!1}}r(x,"switchNodeVersion");async function j(n){try{return await o("nvm",["install",n],{shell:!0,stdio:"inherit"}),!0}catch{return!1}}r(j,"installNodeVersion");function C(n,t){return a.compare(n,t)}r(C,"compareVersions");function $(n,t){return a.satisfies(n,t)}r($,"satisfiesVersion");export{C as compareVersions,w as displaySystemVersions,p as getAngularCliVersion,V as getAvailableNodeVersions,N as getInstalledNodeVersions,m as getNodeVersion,d as getNpmVersion,c as getNvmVersion,j as installNodeVersion,g as isNvmInstalled,$ as satisfiesVersion,x as switchNodeVersion};
|
package/package.json
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jatinmourya/ng-init",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"main": "
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
5
|
"description": "A comprehensive CLI tool to automate Angular project initialization with intelligent version management and prerequisite handling",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/",
|
|
8
|
+
"README.md",
|
|
9
|
+
"LICENSE"
|
|
10
|
+
],
|
|
6
11
|
"scripts": {
|
|
7
12
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
-
"start": "node src/index.js"
|
|
13
|
+
"start": "node src/index.js",
|
|
14
|
+
"build": "node build.js",
|
|
15
|
+
"prepublishOnly": "npm run build && npm run check-size",
|
|
16
|
+
"check-size": "npm pack --dry-run",
|
|
17
|
+
"check-contents": "npm pack && tar -tzf *.tgz && rm *.tgz"
|
|
9
18
|
},
|
|
10
19
|
"type": "module",
|
|
11
20
|
"bin": {
|
|
12
|
-
"ng-init": "./
|
|
21
|
+
"ng-init": "./dist/index.js"
|
|
13
22
|
},
|
|
14
23
|
"keywords": [
|
|
15
24
|
"angular",
|
|
@@ -44,13 +53,17 @@
|
|
|
44
53
|
"chalk": "^5.3.0",
|
|
45
54
|
"commander": "^13.1.0",
|
|
46
55
|
"execa": "^9.6.1",
|
|
47
|
-
"inquirer": "^9.2.12",
|
|
48
|
-
"inquirer-autocomplete-prompt": "^3.0.1",
|
|
49
56
|
"lodash.debounce": "^4.0.8",
|
|
50
57
|
"ora": "^8.0.1",
|
|
51
58
|
"semver": "^7.5.4"
|
|
52
59
|
},
|
|
53
60
|
"engines": {
|
|
54
61
|
"node": ">=18.0.0"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"esbuild": "^0.27.2"
|
|
65
|
+
},
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public"
|
|
55
68
|
}
|
|
56
69
|
}
|
package/src/index.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { Command } from 'commander';
|
|
4
|
-
import { runCli } from './runner.js';
|
|
5
|
-
import { listProfiles, loadProfile, deleteProfile, displayProfileInfo, exportProfile, importProfile } from './utils/profile-manager.js';
|
|
6
|
-
import chalk from 'chalk';
|
|
7
|
-
|
|
8
|
-
const program = new Command();
|
|
9
|
-
|
|
10
|
-
program
|
|
11
|
-
.name('ng-init')
|
|
12
|
-
.description('Angular project initializer with intelligent version management and automation')
|
|
13
|
-
.version('1.1.0');
|
|
14
|
-
|
|
15
|
-
// Main command - create new project
|
|
16
|
-
program
|
|
17
|
-
.command('create', { isDefault: true })
|
|
18
|
-
.alias('new')
|
|
19
|
-
.description('Create a new Angular project with interactive setup')
|
|
20
|
-
.action(() => {
|
|
21
|
-
runCli();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// Profile management commands
|
|
25
|
-
const profileCommand = program
|
|
26
|
-
.command('profile')
|
|
27
|
-
.description('Manage configuration profiles');
|
|
28
|
-
|
|
29
|
-
profileCommand
|
|
30
|
-
.command('list')
|
|
31
|
-
.description('List all saved profiles')
|
|
32
|
-
.action(async () => {
|
|
33
|
-
try {
|
|
34
|
-
const profiles = await listProfiles();
|
|
35
|
-
|
|
36
|
-
if (profiles.length === 0) {
|
|
37
|
-
console.log(chalk.yellow('No saved profiles found.'));
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
console.log(chalk.bold.cyan('\n📋 Saved Profiles:\n'));
|
|
42
|
-
console.log(chalk.gray('━'.repeat(50)));
|
|
43
|
-
profiles.forEach(name => {
|
|
44
|
-
console.log(chalk.white(' • ') + chalk.green(name));
|
|
45
|
-
});
|
|
46
|
-
console.log(chalk.gray('━'.repeat(50)) + '\n');
|
|
47
|
-
} catch (error) {
|
|
48
|
-
console.error(chalk.red('Error listing profiles:'), error.message);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
profileCommand
|
|
53
|
-
.command('show <name>')
|
|
54
|
-
.description('Show details of a profile')
|
|
55
|
-
.action(async (name) => {
|
|
56
|
-
try {
|
|
57
|
-
const profile = await loadProfile(name);
|
|
58
|
-
|
|
59
|
-
if (!profile) {
|
|
60
|
-
console.log(chalk.red(`Profile "${name}" not found.`));
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
displayProfileInfo(name, profile);
|
|
65
|
-
} catch (error) {
|
|
66
|
-
console.error(chalk.red('Error loading profile:'), error.message);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
profileCommand
|
|
71
|
-
.command('delete <name>')
|
|
72
|
-
.description('Delete a profile')
|
|
73
|
-
.action(async (name) => {
|
|
74
|
-
try {
|
|
75
|
-
await deleteProfile(name);
|
|
76
|
-
} catch (error) {
|
|
77
|
-
console.error(chalk.red('Error deleting profile:'), error.message);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
profileCommand
|
|
82
|
-
.command('export <name> <output>')
|
|
83
|
-
.description('Export a profile to a file')
|
|
84
|
-
.action(async (name, output) => {
|
|
85
|
-
try {
|
|
86
|
-
await exportProfile(name, output);
|
|
87
|
-
} catch (error) {
|
|
88
|
-
console.error(chalk.red('Error exporting profile:'), error.message);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
profileCommand
|
|
93
|
-
.command('import <file>')
|
|
94
|
-
.description('Import a profile from a file')
|
|
95
|
-
.action(async (file) => {
|
|
96
|
-
try {
|
|
97
|
-
await importProfile(file);
|
|
98
|
-
} catch (error) {
|
|
99
|
-
console.error(chalk.red('Error importing profile:'), error.message);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
// Version check command
|
|
104
|
-
program
|
|
105
|
-
.command('check')
|
|
106
|
-
.description('Check system versions and compatibility')
|
|
107
|
-
.action(async () => {
|
|
108
|
-
try {
|
|
109
|
-
const { displaySystemVersions } = await import('./utils/version-checker.js');
|
|
110
|
-
await displaySystemVersions();
|
|
111
|
-
} catch (error) {
|
|
112
|
-
console.error(chalk.red('Error checking versions:'), error.message);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
// Help command with examples
|
|
117
|
-
program
|
|
118
|
-
.command('examples')
|
|
119
|
-
.description('Show usage examples')
|
|
120
|
-
.action(() => {
|
|
121
|
-
console.log(chalk.bold.cyan('\n📚 Usage Examples:\n'));
|
|
122
|
-
console.log(chalk.gray('━'.repeat(50)));
|
|
123
|
-
console.log(chalk.white('Create new project (interactive):'));
|
|
124
|
-
console.log(chalk.green(' $ ng-init') + chalk.gray(' or ') + chalk.green('ng-init create\n'));
|
|
125
|
-
|
|
126
|
-
console.log(chalk.white('Check system versions:'));
|
|
127
|
-
console.log(chalk.green(' $ ng-init check\n'));
|
|
128
|
-
|
|
129
|
-
console.log(chalk.white('List saved profiles:'));
|
|
130
|
-
console.log(chalk.green(' $ ng-init profile list\n'));
|
|
131
|
-
|
|
132
|
-
console.log(chalk.white('Show profile details:'));
|
|
133
|
-
console.log(chalk.green(' $ ng-init profile show my-profile\n'));
|
|
134
|
-
|
|
135
|
-
console.log(chalk.white('Delete a profile:'));
|
|
136
|
-
console.log(chalk.green(' $ ng-init profile delete my-profile\n'));
|
|
137
|
-
|
|
138
|
-
console.log(chalk.white('Export a profile:'));
|
|
139
|
-
console.log(chalk.green(' $ ng-init profile export my-profile ./profile.json\n'));
|
|
140
|
-
|
|
141
|
-
console.log(chalk.white('Import a profile:'));
|
|
142
|
-
console.log(chalk.green(' $ ng-init profile import ./profile.json\n'));
|
|
143
|
-
|
|
144
|
-
console.log(chalk.gray('━'.repeat(50)) + '\n');
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
program.parse(process.argv);
|
|
148
|
-
|