@jatinmourya/ng-init 1.2.4 → 1.2.6
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/dist/runner.js +8 -8
- package/dist/utils/installer.js +11 -10
- package/package.json +1 -1
package/dist/runner.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
var R=Object.defineProperty;var y=(
|
|
1
|
+
var R=Object.defineProperty;var y=(f,v)=>R(f,"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 S,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 p,LIBRARY_BUNDLES as k,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
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(13)}\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
|
|
3
|
+
`));const f=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
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
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
|
|
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 u=`Angular ${c}`;return{name:a.latest&&a.latest.startsWith(`${c}.`)?`${u} (latest)`:u,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 u=`v${c}`;return c===a.latest&&(u+=" (latest)"),c===a.lts&&(u+=" (LTS)"),{name:u,value:c}}),x=await m({message:`Select Angular ${r} patch version:`,choices:L,pageSize:15});o.angularVersion=x}console.log(e.green(`
|
|
7
7
|
\u2713 Selected Angular version: ${o.angularVersion}
|
|
8
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
9
|
`)),await D()){console.log(e.cyan(`\u2713 nvm detected on your system
|
|
10
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
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
12
|
Switching to Node.js v${n}...
|
|
13
|
-
`)),await
|
|
13
|
+
`)),await S(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
14
|
`))}else{console.log(e.yellow(`No compatible Node versions installed.
|
|
15
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
|
|
16
|
+
`)),await S(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
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
18
|
Please install nvm and run this CLI again.
|
|
19
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
20
|
Please restart your terminal and run this CLI again.
|
|
21
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(
|
|
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(p).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=p[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(k).map(([i,n])=>({name:`${n.name} - ${n.description}`,value:i}))});for(const i of s){const n=k[i];n.packages&&o.libraries.push(...n.packages),n.devPackages&&o.libraries.push(...n.devPackages.map(g=>({...g,isDev:!0})))}}if(o.template!=="custom"&&p[o.template].packages){const s=p[o.template].packages.map(i=>({name:i,version:"latest"}));o.libraries.push(...s)}if(o.template!=="custom"&&p[o.template].devPackages){const s=p[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
23
|
\u{1F4CB} Project Configuration Summary
|
|
24
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
25
|
`),await d({message:"Create project with this configuration?",default:!0})||(console.log(e.yellow(`Project creation cancelled.
|
|
@@ -52,5 +52,5 @@ Please restart your terminal and run this CLI again.
|
|
|
52
52
|
\u{1F4A1} Useful Commands:
|
|
53
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
54
|
`)),console.log(e.bold.green(`Happy coding! \u{1F680}
|
|
55
|
-
`))}catch(
|
|
56
|
-
\u274C Error:`),
|
|
55
|
+
`))}catch(f){console.error(e.red(`
|
|
56
|
+
\u274C Error:`),f.message),process.exit(1)}}y(ze,"runCli");export{ze as runCli};
|
package/dist/utils/installer.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
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(
|
|
2
|
-
\u{1F4DA}
|
|
3
|
-
`)),console.log(n.gray("\u2501".repeat(50))),console.log(n.white("
|
|
4
|
-
Command:`)),console.log(n.green(` ${e.
|
|
5
|
-
Alternative:`)),console.log(n.green(` ${e.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
\u{1F4A1} Tip: You can try installing manually with:`)),console.log(n.cyan(` cd ${
|
|
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(s){return t.fail("Failed to install Node.js"),console.error(n.red(s.message)),!1}}o(v,"installNodeWithWinget");function g(){switch(d()){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"]}}}o(g,"getNvmInstallInstructions");function I(){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("OS: ")+n.cyan(e.os)),e.download&&console.log(n.white("Download: ")+n.blue(e.download)),e.repo&&console.log(n.white("Repository: ")+n.blue(e.repo)),e.install&&(console.log(n.white(`
|
|
4
|
+
Install Command:`)),console.log(n.green(` ${e.install}`))),e.alternative&&(console.log(n.white(`
|
|
5
|
+
Alternative Command:`)),console.log(n.green(` ${e.alternative}`))),Array.isArray(e.steps)&&(console.log(n.white(`
|
|
6
|
+
Steps:`)),e.steps.forEach((t,s)=>{console.log(n.gray(` ${s+1}. ${t}`))})),Array.isArray(e.postInstall)&&(console.log(n.white(`
|
|
7
|
+
Post-Install:`)),e.postInstall.forEach((t,s)=>{console.log(n.gray(` ${s+1}. ${t}`))})),console.log(n.gray("\u2501".repeat(50))),console.log(n.yellow(`
|
|
8
|
+
\u{1F4A1} Why use NVM?`)),console.log(n.gray(" \u2022 Manage multiple Node.js versions")),console.log(n.gray(" \u2022 Switch instantly")),console.log(n.gray(" \u2022 No sudo/admin required")),console.log(n.gray(` \u2022 Per-project Node versions
|
|
9
|
+
`))}o(I,"displayNvmInstallGuide");async function p(e,t="latest"){const s=c(`Installing ${e}@${t}...`).start();try{const l=t==="latest"?e:`${e}@${t}`;return await a("npm",["install","-g",l],{stdio:"inherit"}),s.succeed(`${e} installed successfully`),!0}catch(l){return s.fail(`Failed to install ${e}`),console.error(n.red(l.message)),!1}}o(p,"installGlobalPackage");async function $(e,t,s=!1){const l=c(`Installing ${e.length} package(s)...`).start();try{const r=["install"];return s&&r.push("--save-dev"),r.push(...e),await a("npm",r,{cwd:t}),l.succeed("Packages installed successfully"),!0}catch{l.warn("Failed with strict dependencies, retrying with --legacy-peer-deps...");try{const i=["install","--legacy-peer-deps"];return s&&i.push("--save-dev"),i.push(...e),await a("npm",i,{cwd:t}),l.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 l.fail("Failed to install packages"),console.error(n.red(i.message)),console.log(n.yellow(`
|
|
10
|
+
\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($,"installPackages");async function b(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(b,"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(l){return t.fail("Failed to install dependencies"),console.error(n.red(l.message)),console.log(n.yellow(`
|
|
11
|
+
\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 N(e="latest"){return p("@angular/cli",e)}o(N,"installAngularCli");async function S(e,t,s={}){const l=c(`Creating Angular project: ${e}...`).start();try{const r=["new",e];s.skipInstall&&r.push("--skip-install"),s.routing!==void 0&&r.push(`--routing=${s.routing}`),s.style&&r.push(`--style=${s.style}`),s.strict!==void 0&&r.push(`--strict=${s.strict}`),s.standalone!==void 0&&r.push(`--standalone=${s.standalone}`);const i=t?`@angular/cli@${t}`:"@angular/cli";return await a("npx",[i,...r],{stdio:"inherit"}),l.succeed(`Angular project ${e} created successfully`),!0}catch(r){return l.fail("Failed to create Angular project"),console.error(n.red(r.message)),!1}}o(S,"createAngularProject");export{S as createAngularProject,I as displayNvmInstallGuide,g as getNvmInstallInstructions,b as initNpmProject,N as installAngularCli,p as installGlobalPackage,v as installNodeWithWinget,$ as installPackages,x as runNpmInstall};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jatinmourya/ng-init",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
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
6
|
"files": [
|