@jatinmourya/ng-init 1.2.10 → 1.2.11
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/cli.js +70 -83
- package/package.json +1 -2
package/dist/cli.js
CHANGED
|
@@ -1,94 +1,81 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
${
|
|
4
|
-
`))
|
|
5
|
-
`)}function
|
|
6
|
-
${e}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`)
|
|
10
|
-
`);
|
|
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{
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
var Pe=Object.defineProperty;var o=(t,e)=>Pe(t,"name",{value:e,configurable:!0});var h=(t,e)=>()=>(t&&(e=t(t=0)),e);var _=(t,e)=>{for(var n in e)Pe(t,n,{get:e[n],enumerable:!0})};var Ce={};_(Ce,{printKeyValue:()=>y,printObjectList:()=>g,printSimpleTable:()=>Pt});import Ne from"cli-table3";import W from"chalk";function ke(t,e){t&&console.log(W.bold.cyan(`
|
|
3
|
+
${t}
|
|
4
|
+
`)),console.log(e.toString()+`
|
|
5
|
+
`)}function Y(t){return t==null?"":String(t)}function y(t,e=[]){if(e.length===0){console.log(W.yellow(`No ${t||"items"} to display.`));return}let n=new Ne({head:["Field","Value"],style:je});for(let[r,s]of e)n.push([Y(r),Y(s)]);ke(t,n)}function g(t,e=[],n=[]){if(!Array.isArray(e)||e.length===0){console.log(W.yellow(`No ${t||"items"} to display.`));return}let r=new Ne({head:n,style:je});for(let s of e)r.push(n.map(i=>Y(s[i])));ke(t,r)}function Pt(t,e=[]){if(!Array.isArray(e)||e.length===0){console.log(W.yellow(`No ${t||"items"} to display.`));return}g(t,e,Object.keys(e[0]))}var je,b=h(()=>{je={head:["cyan"]};o(ke,"render");o(Y,"toStr");o(y,"printKeyValue");o(g,"printObjectList");o(Pt,"printSimpleTable")});var Oe={};_(Oe,{compareVersions:()=>jt,displaySystemVersions:()=>te,getAngularCliVersion:()=>Le,getAvailableNodeVersions:()=>Nt,getInstalledNodeVersions:()=>ne,getNodeVersion:()=>z,getNpmVersion:()=>De,getNvmVersion:()=>Z,installNodeVersion:()=>re,isNvmInstalled:()=>ee,satisfiesVersion:()=>kt,switchNodeVersion:()=>J});import{execa as X}from"execa";import Ie from"semver";async function Q(t,e,n){try{let{stdout:r}=await X(t,e,n);return r.trim()||null}catch{return null}}async function U(t,e,n){let r=await Q(t,e,n);if(!r)return null;let s=r.match(Ve);return s?s[1]:null}function Ee(t){if(!t)return[];let e=[];for(let n of t.split(`
|
|
6
|
+
`)){let r=n.match(Ve);r&&e.push(r[1])}return e}function z(){return U("node",["--version"])}function De(){return U("npm",["--version"])}function Z(){return U("nvm",["--version"],k)}async function ee(){return await Z()!==null}function Le(){return U("ng",["version"],k)}async function te(){let[t,e,n,r]=await Promise.all([z(),De(),Z(),Le()]),s=o(i=>i??"Not installed","format");return g("\u{1F50D} System Environment Check",[{Tool:"Node.js",Version:s(t)},{Tool:"npm",Version:s(e)},{Tool:"nvm",Version:s(n)},{Tool:"Angular CLI",Version:s(r)}],["Tool","Version"]),{node:t,npm:e,nvm:n,angularCli:r}}async function Nt(){let t=await Q("nvm",["list","available"],k);return Ee(t)}async function ne(){let t=await Q("nvm",["list"],k);return Ee(t)}async function J(t){try{return await X("nvm",["use",t],{...k,stdio:"inherit"}),!0}catch{return!1}}async function re(t){try{return await X("nvm",["install",t],{...k,stdio:"inherit"}),!0}catch{return!1}}function jt(t,e){return Ie.compare(t,e)}function kt(t,e){return Ie.satisfies(t,e)}var Ve,k,oe=h(()=>{b();Ve=/(\d+\.\d+\.\d+)/;o(Q,"run");o(U,"runVersion");o(Ee,"extractVersionsFromOutput");k={shell:!0};o(z,"getNodeVersion");o(De,"getNpmVersion");o(Z,"getNvmVersion");o(ee,"isNvmInstalled");o(Le,"getAngularCliVersion");o(te,"displaySystemVersions");o(Nt,"getAvailableNodeVersions");o(ne,"getInstalledNodeVersions");o(J,"switchNodeVersion");o(re,"installNodeVersion");o(jt,"compareVersions");o(kt,"satisfiesVersion")});import Me from"axios";import Ct from"chalk";import{Agent as It}from"node:http";import{Agent as Vt}from"node:https";function Ft(t,e){let n=t.split(".").map(Number),r=e.split(".").map(Number);for(let s=0,i=Math.max(n.length,r.length);s<i;s++){let c=(n[s]||0)-(r[s]||0);if(c!==0)return c}return 0}function ae(t){return[...t].sort((e,n)=>Ft(n,e))}function Tt(t){return ae(t.filter(e=>!Rt.test(e)))}function ze({package:t}){return{name:t.name,version:t.version,description:t.description||"No description",author:t.publisher?.username||"Unknown",date:t.date,verified:t.publisher?.verified??!1}}function C(t){return Ue.dedupe(`abbr:${t}`,async()=>{let{data:e}=await Mt.get(`${ie}/${t}`);return e})}function _t(t){return Ue.dedupe(`full:${t}`,async()=>{let{data:e}=await G.get(`${ie}/${t}`);return e})}async function Je(t,e=10,{signal:n}={}){if(!t?.trim())return[];try{let{data:r}=await G.get(Fe,{params:{text:t,size:e},signal:n});return r.objects.map(ze)}catch(r){return r.name==="CanceledError"||n?.aborted?[]:(console.error("Error searching npm packages:",r.message),[])}}async function Wt(t){try{let e=await _t(t);return{name:e.name,description:e.description||"No description",latestVersion:e["dist-tags"]?.latest,versions:Object.keys(e.versions||{}),homepage:e.homepage,repository:e.repository,license:e.license,keywords:e.keywords||[]}}catch(e){if(e.response?.status===404)return null;throw e}}async function Ut(t){try{let{data:e}=await G.get(`${Et}/${t}`);return e.downloads}catch{return 0}}async function Ge(t){try{let[e,n]=await Promise.all([Wt(t),Ut(t)]);return e?{...e,weeklyDownloads:n}:null}catch(e){return console.error(`Error getting package info for ${t}:`,e.message),null}}function He(t){return t>=1e9?`${(t/1e9).toFixed(1)}B`:t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function zt(t=300){let e=null,n=null;return o(function(s,i){if(e&&clearTimeout(e),n&&n.abort(),!s||s.length<2){i([]);return}let c=n=new AbortController;e=setTimeout(async()=>{try{let{data:l}=await G.get(Fe,{params:{text:s,size:10},signal:c.signal});c.signal.aborted||i(l.objects.map(ze))}catch{c.signal.aborted||i([])}},t)},"debouncedSearch")}async function le(t){try{let e=await C(t),n=Tt(Object.keys(e.versions||{})),r=e["dist-tags"]||{};return{versions:n,latest:r.latest??null,lts:r.lts??null}}catch(e){return console.error(`Error fetching versions for ${t}:`,e.message),{versions:[],latest:null,lts:null}}}function qe(){return le("@angular/cli")}function Be(t){return[...new Set(t.map(n=>n.split(".")[0]))].sort((n,r)=>Number(r)-Number(n))}function Ke(t,e){let n=`${e}.`,r=[...new Set(t.filter(s=>s.startsWith(n)).map(s=>s.split(".").slice(0,2).join(".")))];return ae(r)}function Ye(t,e){return ae(t.filter(n=>n.startsWith(`${e}.`)))}async function Xe(t){let e=parseInt(t.split(".")[0],10);try{let r=(await C("@angular/cli")).versions?.[t]?.engines?.node;return r||Re(e)}catch{return console.log(Ct.gray(`Unable to fetch Node requirements, deriving from Angular ${e}\u2026`)),Re(e)}}function Re(t){let e;return t>=15?e=Math.floor(t/2)*2:t>=10?e=Math.floor((t+2)/2)*2:e=Math.floor(t*1.5/2)*2,`^${e}.0.0 || ^${e+2}.0.0 || ^${e+4}.0.0`}var ie,Fe,Et,Dt,Lt,Ot,Rt,Te,_e,We,G,Mt,se,Ue,Gn,H=h(()=>{ie="https://registry.npmjs.org",Fe=`${ie}/-/v1/search`,Et="https://api.npmjs.org/downloads/point/last-week",Dt=5e3,Lt=1e4,Ot=5*6e4,Rt=/-(rc|beta|next|alpha|canary|dev|pre)/i,Te={keepAlive:!0,maxSockets:15,maxFreeSockets:5},_e=new It(Te),We=new Vt(Te),G=Me.create({timeout:Dt,httpAgent:_e,httpsAgent:We,headers:{"Accept-Encoding":"gzip, deflate, br"}}),Mt=Me.create({timeout:Lt,httpAgent:_e,httpsAgent:We,headers:{Accept:"application/vnd.npm.install-v1+json","Accept-Encoding":"gzip, deflate, br"}}),se=class{static{o(this,"TTLCache")}#e=new Map;#t=new Map;#n;constructor(e=Ot){this.#n=e}get(e){let n=this.#e.get(e);if(n){if(Date.now()>n.exp){this.#e.delete(e);return}return n.value}}set(e,n){return this.#e.set(e,{value:n,exp:Date.now()+this.#n}),this}async dedupe(e,n){let r=this.get(e);if(r!==void 0)return r;if(!this.#t.has(e)){let s=n().then(i=>(this.set(e,i),this.#t.delete(e),i)).catch(i=>{throw this.#t.delete(e),i});this.#t.set(e,s)}return this.#t.get(e)}clear(){this.#e.clear(),this.#t.clear()}},Ue=new se;o(Ft,"semverCompare");o(ae,"sortDesc");o(Tt,"stableSortedDesc");o(ze,"mapSearchResult");o(C,"fetchAbbreviated");o(_t,"fetchFull");o(Je,"searchNpmPackages");o(Wt,"getPackageDetails");o(Ut,"getPackageDownloads");o(Ge,"getEnhancedPackageInfo");o(He,"formatDownloads");o(zt,"createDebouncedSearch");Gn=zt();o(le,"getPackageVersions");o(qe,"getAngularVersions");o(Be,"getMajorVersions");o(Ke,"getMinorVersionsForMajor");o(Ye,"getPatchVersionsForMinor");o(Xe,"getNodeRequirementsForAngular");o(Re,"deriveNodeRequirement")});import w from"semver";import O from"chalk";function ce(t){for(let e of Jt)if(t[e])return t[e];return null}function Qe(t){return Object.keys(t.versions||{}).filter(e=>w.valid(e)&&!w.prerelease(e)).sort(w.rcompare)}function ue(t,e){try{return w.satisfies(t,e)}catch{let n=t.split(".")[0];return e.includes(`^${n}.`)||e.includes(`~${n}.`)||e.includes(`>=${n}.`)||e.includes(`${n}.x`)}}function Ht(t){return Gt.some(e=>t.startsWith(e))}function Ze(t,e){try{return{compatible:w.satisfies(t,e),current:t,required:e}}catch(n){return{compatible:!1,current:t,required:e,error:n.message}}}function et(t){return y("\u{1F4CB} Compatibility Check",[["Current Node.js",O.cyan(`v${t.current}`)],["Required Node.js",O.cyan(t.required)],["Status",t.compatible?O.green("\u2713 Compatible"):O.red("\u2717 Incompatible")]]),t.compatible}function tt(t,e){return t.filter(n=>{try{return w.satisfies(n,e)}catch{return!1}}).sort(w.rcompare)}function nt(t){try{let e=w.minVersion(t);if(e)return e.version}catch{}return console.log(O.yellow("\u26A0\uFE0F Could not parse Node version range. Please install the latest LTS version.")),null}async function q(t,e,n){try{let s=(await C(t)).versions?.[e]?.peerDependencies??{},i=ce(s);if(!i)return{compatible:!0,hasPeerDependency:!1,reason:"No Angular peer dependency found"};let c=ue(n,i);return{compatible:c,peerDependency:i,hasPeerDependency:!0,reason:c?`Angular ${n} satisfies ${i}`:`Angular ${n} does not satisfy ${i}`}}catch{return{compatible:!0,hasPeerDependency:!1,reason:"Could not verify compatibility"}}}async function rt(t,e,n=10){try{let r=await C(t),s=Qe(r),i=[];for(let c of s){if(i.length>=n)break;let l=r.versions[c]?.peerDependencies??{},u=ce(l);(!u||ue(e,u))&&i.push({version:c,peerDependency:u??"No Angular peer dependency",reason:u?`Satisfies ${u}`:"No peer dependency constraint"})}return i}catch{return[]}}async function qt(t,e){let n;try{n=await C(t)}catch{return{version:"latest",source:"fallback",reason:"Could not fetch package data",warning:!0,matchType:"fallback"}}let r=w.major(e),s=Qe(n),i=n["dist-tags"]?.latest;if(Ht(t)){let c=s.find(l=>parseInt(l.split(".")[0],10)===r);if(c)return{version:`^${c}`,source:"dynamic",reason:`Matched Angular major version ${r}`,matchType:"ecosystem"}}for(let c of s){let l=n.versions[c]?.peerDependencies??{},u=ce(l);if(!u)return{version:`^${c}`,source:"dynamic",reason:"No Angular peer dependency",matchType:"no-peer"};if(ue(e,u))return{version:`^${c}`,source:"dynamic",reason:`Angular ${e} satisfies ${u}`,peerDependency:u,matchType:"peer-dependency"}}return{version:i?`^${i}`:"latest",source:"fallback",reason:"No version with compatible Angular peer dependency found",warning:!0,matchType:"fallback"}}async function ot(t,e){return Promise.all(t.map(n=>Bt(n,e)))}async function Bt(t,e){let n=t.version||"latest";if(n==="latest"){let i=await qt(t.name,e);return{...t,version:i.version,originalVersion:n,adjusted:i.source==="dynamic",source:i.source,reason:i.reason,warning:i.warning||!1}}let r=n.replace(/^[\^~]/,""),s=await q(t.name,r,e);return{...t,adjusted:!1,compatible:s.compatible,reason:s.reason,warning:!s.compatible}}var Jt,Gt,pe=h(()=>{b();H();Jt=["@angular/core","@angular/common","@angular/platform-browser"],Gt=["@angular/","@ngrx/","@ngxs/","@ng-bootstrap/","@angular-eslint/"];o(ce,"findAngularPeerDep");o(Qe,"stableVersionsDesc");o(ue,"satisfiesSafe");o(Ht,"isEcosystemPackage");o(Ze,"checkNodeCompatibility");o(et,"displayCompatibilityStatus");o(tt,"findCompatibleVersions");o(nt,"getRecommendedNodeVersion");o(q,"isVersionCompatibleWithAngular");o(rt,"getAllCompatibleVersions");o(qt,"findCompatibleLibraryVersion");o(ot,"resolveLibraryVersionsAsync");o(Bt,"resolveLibrary")});import{execa as de}from"execa";import I from"ora";import v from"chalk";import{platform as Kt}from"os";async function it({args:t,cwd:e,spinner:n,successMsg:r,failMsg:s,manualHint:i=[]}){try{return await de("npm",t,{cwd:e}),n.succeed(r),!0}catch{}n.warn("Peer dependency conflict \u2014 retrying with --legacy-peer-deps\u2026");try{return await de("npm",[...t,"--legacy-peer-deps"],{cwd:e}),n.succeed(`${r} (with --legacy-peer-deps)`),console.log(v.yellow("\u26A0\uFE0F Note: Installed with --legacy-peer-deps due to peer dependency conflicts")),!0}catch(c){if(n.fail(s),console.error(v.red(c.message)),i.length>0){console.log(v.yellow(`
|
|
7
|
+
\u{1F4A1} Tip: You can try installing manually with:`));for(let l of i)console.log(v.cyan(` ${l}`))}return!1}}function Xt(t=[],{dev:e=!1}={}){let n=["install"];return e&&n.push("--save-dev"),t.length>0&&n.push(...t),n}async function at(t,e,{spinner:n,successMsg:r,failMsg:s}){n.stop();try{return await de(t,e,{stdio:"inherit"}),I().succeed(r),!0}catch(i){return I().fail(s),console.error(v.red(i.message)),!1}}async function lt(t="LTS"){let e=t==="LTS"?"OpenJS.NodeJS.LTS":"OpenJS.NodeJS",n=I("Installing Node.js with winget\u2026").start();return at("winget",["install",e],{spinner:n,successMsg:"Node.js installed successfully",failMsg:"Failed to install Node.js"})}function Qt(){return st[Yt]??st.linux}function ct(){let t=Qt();y("\u{1F4DA} NVM Installation Guide",[["OS",v.cyan(t.os)],["Download/Repo",v.blue(t.download??t.repo??"-")],["Install",t.install?v.green(t.install):"-"],["Alternative",t.alternative?v.green(t.alternative):"-"]]);let e=o(n=>n.map((r,s)=>({Step:`${s+1}`,Instruction:r})),"toRows");t.steps&&g("Steps",e(t.steps),["Step","Instruction"]),t.postInstall&&g("Post-Install",e(t.postInstall),["Step","Instruction"]),g("Why use NVM?",[{Benefit:"Manage multiple Node.js versions"},{Benefit:"Switch instantly"},{Benefit:"No sudo/admin required"},{Benefit:"Per-project Node versions"}],["Benefit"])}function fe(t,e,n=!1){let r=`${t.length} ${n?"dev ":""}package(s)`,s=I(`Installing ${r}\u2026`).start();return it({args:Xt(t,{dev:n}),cwd:e,spinner:s,successMsg:`${r} installed successfully`,failMsg:`Failed to install ${r}`,manualHint:[`cd ${e}`,`npm install ${t.join(" ")}${n?" --save-dev":""} --force`]})}function ut(t){let e=I("Installing dependencies\u2026").start();return it({args:["install"],cwd:t,spinner:e,successMsg:"Dependencies installed successfully",failMsg:"Failed to install dependencies",manualHint:[`cd ${t}`,"npm install --force"]})}function Zt(t,e={}){let n=["new",t],r={skipInstall:"--skip-install",routing:"--routing",style:"--style",strict:"--strict",standalone:"--standalone"};for(let[s,i]of Object.entries(r)){let c=e[s];c!==void 0&&(c===!0&&i==="--skip-install"?n.push(i):c!==void 0&&n.push(`${i}=${c}`))}return n}async function pt(t,e,n={}){let r=e?`@angular/cli@${e}`:"@angular/cli",s=Zt(t,n),i=I(`Creating Angular project: ${t}\u2026`).start();return at("npx",[r,...s],{spinner:i,successMsg:`Angular project ${t} created successfully`,failMsg:"Failed to create Angular project"})}var Yt,st,dt=h(()=>{b();Yt=Kt();o(it,"npmExecWithRetry");o(Xt,"buildInstallArgs");o(at,"execInteractive");o(lt,"installNodeWithWinget");st={win32:{os:"Windows",download:"https://github.com/coreybutler/nvm-windows/releases",steps:["Download nvm-setup.exe","Run the installer","Restart your terminal"]},darwin:{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"]},linux:{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(Qt,"getNvmInstallInstructions");o(ct,"displayNvmInstallGuide");o(fe,"installPackages");o(ut,"runNpmInstall");o(Zt,"buildNgNewArgs");o(pt,"createAngularProject")});import{search as en,select as $,input as me,confirm as ge}from"@inquirer/prompts";import p from"chalk";async function he(t,e){let{versions:n,latest:r=null,lts:s=null}=e;if(n.length===0)return console.log(p.yellow(`No stable versions found for ${t}.`)),null;let i=Be(n),c=await $({message:`Select ${t} major version:`,choices:i.map(d=>({name:r?.startsWith(`${d}.`)?`${t} ${d} (latest)`:`${t} ${d}`,value:d})),pageSize:15}),l=Ke(n,c),u=await $({message:`Select ${t} ${c} minor version:`,choices:l.map(d=>({name:`v${d}.x`,value:d})),pageSize:15}),m=Ye(n,u);return $({message:`Select ${t} ${u} patch version:`,choices:m.map(d=>{let j=`v${d}`;return d===r&&(j+=" (latest)"),d===s&&(j+=" (LTS)"),{name:j,value:d}}),pageSize:15})}function tn(t){let e=t.verified?" \u2713":"",n=t.description.length>50?`${t.description.substring(0,50)}\u2026`:t.description;return`${t.name}${e} - ${n} (v${t.version})`}async function nn(t,e,n){console.log(p.cyan(`
|
|
8
|
+
\u{1F50D} Checking compatibility with Angular ${n}\u2026
|
|
9
|
+
`));let r=await q(t,e,n);if(r.compatible)return console.log(p.green(`\u2713 ${t}@${e} is compatible with Angular ${n}`)),r.peerDependency&&console.log(p.gray(` Peer dependency: ${r.peerDependency}
|
|
10
|
+
`)),{version:e,skip:!1};if(console.log(p.red(`\u2717 ${t}@${e} may not be compatible with Angular ${n}`)),console.log(p.gray(` ${r.reason}
|
|
11
|
+
`)),!await ge({message:"Would you like to see compatible versions?",default:!0}))return{version:e,skip:!1};console.log(p.cyan(`
|
|
12
|
+
\u{1F50D} Searching for compatible versions\u2026
|
|
13
|
+
`));let s=await rt(t,n,10);return s.length>0?{version:await $({message:"Select a compatible version:",choices:[...s.map(l=>({name:`${l.version}${l.peerDependency?` (peer: ${l.peerDependency})`:""}`,value:l.version})),{name:"Keep selected version anyway",value:e}],pageSize:12}),skip:!1}:(console.log(p.yellow("No compatible versions found automatically.")),await ge({message:"Continue with the selected version anyway?",default:!1})?{version:e,skip:!1}:{version:e,skip:!0})}async function ye(t){let e=await $({message:"What would you like to do next?",choices:[{name:"Add another library",value:"add"},{name:"Remove a library",value:"remove",disabled:t.count===0},{name:"Finish library selection",value:"finish"}],default:"add"});if(e!=="remove")return e;let n=await $({message:"Select library to remove:",choices:t.getAll().map(r=>({name:`${r.name}@${r.version}`,value:r.name}))});return t.remove(n),console.log(p.yellow(`
|
|
14
|
+
\u2713 Removed ${n}
|
|
15
|
+
`)),"add"}async function ft(t=null){let e=new B;console.log(p.bold.cyan(`
|
|
15
16
|
\u{1F4E6} Interactive Library Search
|
|
16
|
-
`)),
|
|
17
|
+
`)),t&&console.log(p.gray(`Angular version: ${t} (compatibility will be checked)
|
|
17
18
|
`)),console.log(p.gray(`Type to search npm packages. Press Enter to select.
|
|
18
|
-
`));
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
`))
|
|
22
|
-
|
|
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(`
|
|
26
|
-
\u{1F50D} Dynamically searching for compatible versions...
|
|
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(`
|
|
19
|
+
`));let n="add";for(;n==="add";)try{e.count>0&&e.display();let r=await en({message:"Search for a library:",source:o(async(u,{signal:m})=>{if(!u||u.length<2)return[];let d=await Je(u,15,{signal:m});if(m.aborted)return[];let j=d.filter(L=>!e.has(L.name));return j.length===0&&d.length>0?[{name:p.yellow("All matching libraries have already been selected"),value:null,disabled:!0}]:j.map(L=>({name:tn(L),value:L.name,description:L.description}))},"source"),pageSize:10});if(!r){if(!await ge({message:"Continue searching?",default:!1}))break;continue}let[s,i]=await Promise.all([Ge(r),le(r)]);if(!s){console.log(p.yellow(`Could not fetch info for ${r}. Skipping.
|
|
20
|
+
`));continue}y(`
|
|
21
|
+
Selected Package`,[["Name",p.green(s.name)],["Description",p.gray(s.description)],["Latest version",p.cyan(s.latestVersion)],["Weekly downloads",p.gray(He(s.weeklyDownloads))]]);let c=await $({message:"How would you like to select the version?",choices:[{name:`Use latest (${s.latestVersion})`,value:"latest"},{name:"Choose specific version (major.minor.patch)",value:"specific"},{name:"Enter version manually",value:"manual"}],default:"latest"}),l=s.latestVersion;if(c==="specific")if(i.versions.length===0)console.log(p.yellow("Could not fetch versions. Using latest."));else{let u=await he(s.name,i);u&&(l=u)}else c==="manual"&&(l=await me({message:"Enter version:",default:s.latestVersion,validate:o(u=>u?!0:"Version is required","validate")}));if(t&&l!=="latest"){let u=await nn(s.name,l,t);if(u.skip){console.log(p.yellow(`Skipping this library.
|
|
22
|
+
`)),n=await ye(e);continue}l=u.version}e.add({name:s.name,version:l,description:s.description}),console.log(p.green(`\u2713 Added ${s.name}@${l} to installation queue
|
|
23
|
+
`)),n=await ye(e)}catch(r){if(r.name==="ExitPromptError")break;console.error(p.red("Error during library search:"),r.message),n="finish"}return e.getAll()}async function mt(t=null){let e=new B;console.log(p.bold.cyan(`
|
|
32
24
|
\u{1F4E6} Add Libraries
|
|
33
|
-
`)),
|
|
34
|
-
`));
|
|
35
|
-
|
|
36
|
-
`))
|
|
37
|
-
`))):
|
|
38
|
-
`)),
|
|
39
|
-
`)))}t.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
25
|
+
`)),t&&console.log(p.gray(`Angular version: ${t} (compatibility will be checked)
|
|
26
|
+
`));let n="add";for(;n==="add";){e.count>0&&e.display();let r=await me({message:"Enter library name (or press Enter to skip):",validate:o(i=>i?/^[@a-z0-9-~][a-z0-9-._~]*$/.test(i)?e.has(i)?`${i} has already been selected`:!0:"Invalid package name format":!0,"validate")});if(!r)break;let s=await me({message:`Enter version for ${r} (or 'latest'):`,default:"latest"});if(t&&s!=="latest"){let i=await q(r,s,t);i.compatible?(console.log(p.green(`\u2713 ${r}@${s} is compatible with Angular ${t}`)),i.peerDependency&&console.log(p.gray(` Peer dependency: ${i.peerDependency}
|
|
27
|
+
`))):(console.log(p.red(`\u2717 ${r}@${s} may not be compatible with Angular ${t}`)),console.log(p.gray(` ${i.reason}
|
|
28
|
+
`)),console.log(p.yellow(`\u26A0\uFE0F This may cause installation issues.
|
|
29
|
+
`)))}e.add({name:r,version:s}),console.log(p.green(`\u2713 Added ${r}@${s}
|
|
30
|
+
`)),n=await ye(e)}return e.getAll()}function gt(){return $({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"})}var B,yt=h(()=>{H();pe();b();o(he,"selectVersionInteractively");B=class{static{o(this,"LibraryTracker")}#e=new Map;add(e){this.#e.set(e.name,e)}remove(e){this.#e.delete(e)}has(e){return this.#e.has(e)}getAll(){return[...this.#e.values()]}get count(){return this.#e.size}display(){if(this.#e.size===0){console.log(p.gray(` No libraries selected yet.
|
|
31
|
+
`));return}g("\u{1F4E6} Currently Selected Libraries",this.getAll().map(e=>({Library:e.name,Version:e.version,Description:(e.description??"").substring(0,70)})),["Library","Version","Description"])}};o(tn,"formatPackageChoice");o(nn,"resolveCompatibleVersion");o(ye,"askNextAction");o(ft,"interactiveLibrarySearch");o(mt,"simpleLibraryInput");o(gt,"askLibrarySearchPreference")});import gr from"chalk";import{execa as hr}from"execa";import vr from"ora";function ht(t){return!t||t.length===0?"Directory name cannot be empty":t.length>255?"Directory name is too long":rn.test(t)?"Directory name contains invalid characters":on.has(t.toUpperCase())?"Directory name is reserved":t.endsWith(" ")||t.endsWith(".")?"Directory name cannot end with a space or period":!0}var rn,on,wt=h(()=>{rn=/[<>:"|?*\x00-\x1f]/,on=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"]);o(ht,"validateDirectoryName")});var E={};_(E,{clearCache:()=>fn,deleteProfile:()=>cn,displayProfileInfo:()=>xe,exportProfile:()=>pn,getProfileDetails:()=>un,importProfile:()=>dn,listProfiles:()=>be,loadProfile:()=>M,loadProfiles:()=>ln,saveProfile:()=>$e});import R from"fs/promises";import vt from"path";import{homedir as sn}from"os";import f from"chalk";function xt(){return we??=R.mkdir(bt,{recursive:!0}).catch(t=>{throw console.error(f.red("Failed to create profiles directory:"),t.message),t}),we}async function V(){if(A!==null)return A;await xt();try{let t=await R.readFile($t,"utf-8");A=JSON.parse(t)}catch{A={}}return A}async function ve(t){await xt();try{return await R.writeFile($t,JSON.stringify(t,null,2),"utf-8"),A=t,!0}catch(e){return console.error(f.red("Failed to save profiles:"),e.message),!1}}function ln(){return V()}async function M(t){return(await V())[t]??null}async function be(){let t=await V();return Object.keys(t)}async function $e(t,e){let n=await V(),r=new Date().toISOString();n[t]={...e,createdAt:n[t]?.createdAt??r,updatedAt:r};let s=await ve(n);return s&&console.log(f.green(`\u2713 Profile "${t}" saved successfully`)),s}async function cn(t){let e=await V();if(!e[t])return console.log(f.yellow(`Profile "${t}" not found`)),!1;delete e[t];let n=await ve(e);return n&&console.log(f.green(`\u2713 Profile "${t}" deleted successfully`)),n}async function un(t){let e=await M(t);return e?{name:t,angularVersion:e.angularVersion,libraries:e.libraries?.length??0,createdAt:e.createdAt,updatedAt:e.updatedAt}:null}function xe(t,e){let n=[];e.angularVersion&&n.push(["Angular Version",f.green(e.angularVersion)]),e.template&&n.push(["Template",f.gray(`${e.template} (deprecated)`)]),n.push(["Libraries",f.cyan(String(e.libraries?.length??0))]),e.createdAt&&n.push(["Created",f.gray(new Date(e.createdAt).toLocaleString())]),e.updatedAt&&n.push(["Updated",f.gray(new Date(e.updatedAt).toLocaleString())]),y(`\u{1F4CB} Profile: ${t}`,n);let r=e.libraries;if(r?.length>0){let s=r.slice(0,K).map(i=>({Library:i.name,Version:i.version,Description:i.description??""}));g(`Libraries (showing up to ${K})`,s,["Library","Version","Description"]),r.length>K&&console.log(f.gray(` \u2026 and ${r.length-K} more`))}e.options&&g("Options",Object.entries(e.options).map(([s,i])=>({Option:s,Value:String(i)})),["Option","Value"])}async function pn(t,e){let n=await M(t);if(!n)return console.log(f.red(`Profile "${t}" not found`)),!1;try{let r={name:t,profile:n,exportedAt:new Date().toISOString(),version:an};return await R.writeFile(e,JSON.stringify(r,null,2),"utf-8"),console.log(f.green(`\u2713 Profile exported to ${e}`)),!0}catch(r){return console.error(f.red("Failed to export profile:"),r.message),!1}}async function dn(t){let e;try{let i=await R.readFile(t,"utf-8");e=JSON.parse(i)}catch(i){return console.error(f.red("Failed to read profile file:"),i.message),!1}if(!e.name||!e.profile)return console.log(f.red("Invalid profile file format")),!1;let n=await V(),r=new Date().toISOString();n[e.name]={...e.profile,createdAt:e.profile.createdAt??r,updatedAt:r};let s=await ve(n);return s&&console.log(f.green(`\u2713 Profile "${e.name}" imported successfully`)),s}function fn(){A=null,we=null}var bt,$t,an,K,we,A,P=h(()=>{b();bt=vt.join(sn(),".ng-init"),$t=vt.join(bt,"profiles.json"),an="1.0.0",K=50,we=null;o(xt,"ensureDir");A=null;o(V,"readProfiles");o(ve,"writeProfiles");o(ln,"loadProfiles");o(M,"loadProfile");o(be,"listProfiles");o($e,"saveProfile");o(cn,"deleteProfile");o(un,"getProfileDetails");o(xe,"displayProfileInfo");o(pn,"exportProfile");o(dn,"importProfile");o(fn,"clearCache")});var St={};_(St,{runCli:()=>wn});import{select as F,input as Se,confirm as x}from"@inquirer/prompts";import a from"chalk";import Ae from"path";import{readFileSync as mn}from"fs";import{fileURLToPath as gn}from"url";async function wn(){try{vn(),await te();let t=qe(),e={};if(await x({message:"Would you like to use a saved profile?",default:!1})&&(e=await bn()),!e.angularVersion){console.log(a.bold.cyan(`
|
|
32
|
+
\u{1F4E6} Fetching Angular versions\u2026
|
|
33
|
+
`));let u=await t;u.versions.length===0&&(console.log(a.red("Failed to fetch Angular versions. Check your internet connection.")),process.exit(1));let m=await he("Angular",u);m||(console.log(a.red("No version selected.")),process.exit(1)),e.angularVersion=m}console.log(a.green(`
|
|
34
|
+
\u2713 Selected Angular version: ${e.angularVersion}
|
|
35
|
+
`));let[n,r]=await Promise.all([Xe(e.angularVersion),z()]),s=Ze(r,n);if(et(s),s.compatible||await xn(n),e.projectName||(e.projectName=await Se({message:"Enter project name:",validate:o(u=>{if(!u)return"Project name is required";let m=ht(u);return m===!0?!0:m},"validate")})),!e.location){let u=await F({message:"Where would you like to create the project?",choices:[{name:"Current directory",value:"current"},{name:"Specify custom directory",value:"custom"}]});e.location=u==="custom"?await Se({message:"Enter directory path:",default:process.cwd()}):process.cwd()}let i=Ae.join(e.location,e.projectName);if(e.options||(e.options=await $n()),!e.libraries){let u=await gt();e.libraries=u==="interactive"?await ft(e.angularVersion):u==="manual"?await mt(e.angularVersion):[]}if(e.features=[],await x({message:"Save this configuration as a profile?",default:!1})){let u=await Se({message:"Enter profile name:",validate:o(m=>m?!0:"Profile name is required","validate")});await $e(u,e)}y("\u{1F4CB} Project Configuration Summary",[["Project Name",a.green(e.projectName)],["Location",a.cyan(i)],["Angular Version",a.green(e.angularVersion)],["Style",a.cyan(e.options.style)],["Routing",a.cyan(e.options.routing?"Yes":"No")],["Strict Mode",a.cyan(e.options.strict?"Yes":"No")],["Standalone",a.cyan(e.options.standalone?"Yes":"No")],["Libraries",a.cyan(String(e.libraries.length))]]),await x({message:"Create project with this configuration?",default:!0})||(console.log(a.yellow(`Project creation cancelled.
|
|
36
|
+
`)),process.exit(0)),console.log(a.bold.cyan(`
|
|
37
|
+
\u{1F680} Creating Angular project\u2026
|
|
38
|
+
`));let[c,l]=await Promise.all([pt(e.projectName,e.angularVersion,{...e.options,skipInstall:!0}),e.libraries.length>0?ot(e.libraries,e.angularVersion):Promise.resolve([])]);c||(console.log(a.red("Failed to create Angular project.")),process.exit(1)),l.length>0&&await An(l,i),console.log(a.bold.cyan(`
|
|
39
|
+
\u{1F4E5} Installing dependencies\u2026
|
|
40
|
+
`)),await ut(i),Pn(e.projectName)}catch(t){t.name==="ExitPromptError"&&(console.log(a.yellow(`
|
|
41
|
+
Exited.
|
|
42
|
+
`)),process.exit(0)),console.error(a.red(`
|
|
43
|
+
\u274C Error:`),t.message),process.exit(1)}}function vn(){let t=`Angular Project Initialization Automation CLI v${hn.version}`,e=60,n=e-t.length,r="\u2550".repeat(e);console.log(a.cyan.bold(`
|
|
43
44
|
\u2554${r}\u2557
|
|
44
|
-
\u2551${" ".repeat(n/2)}${
|
|
45
|
+
\u2551${" ".repeat(Math.floor(n/2))}${t}${" ".repeat(Math.ceil(n/2))}\u2551
|
|
45
46
|
\u255A${r}\u255D
|
|
46
|
-
`))
|
|
47
|
-
`));
|
|
48
|
-
\
|
|
49
|
-
`));let
|
|
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(`
|
|
47
|
+
`))}async function bn(){let t=await be();if(t.length===0)return console.log(a.yellow(`No saved profiles found. Continuing with manual setup\u2026
|
|
48
|
+
`)),{};let e=await F({message:"Select a profile:",choices:t.map(r=>({name:r,value:r}))}),n=await M(e);return xe(e,n),await x({message:"Use this profile?",default:!0})?n:{}}async function $n(){let t=await x({message:"Enable routing?",default:!0}),e=await F({message:"Select stylesheet format:",choices:["css","scss","sass","less"].map(s=>({name:s,value:s}))}),n=await x({message:"Enable strict mode?",default:!0}),r=await x({message:"Use standalone components?",default:!1});return{routing:t,style:e,strict:n,standalone:r}}async function xn(t){if(console.log(a.yellow(`\u26A0\uFE0F Node.js version incompatibility detected!
|
|
49
|
+
`)),await ee())return Sn(t);console.log(a.yellow(`\u26A0\uFE0F nvm is not installed on your system
|
|
50
|
+
`));let e=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"}]});e==="nvm"&&(ct(),console.log(a.yellow(`
|
|
61
51
|
Please install nvm and run this CLI again.
|
|
62
|
-
`)),process.exit(0))
|
|
52
|
+
`)),process.exit(0)),e==="direct"&&(process.platform!=="win32"&&(console.log(a.red("Direct installation is only supported on Windows.")),process.exit(1)),await lt("LTS")||(console.log(a.red("Failed to install Node.js. Please install manually.")),process.exit(1)),console.log(a.yellow(`
|
|
63
53
|
Please restart your terminal and run this CLI again.
|
|
64
|
-
`)),process.exit(0))
|
|
65
|
-
`)),process.exit(0)
|
|
66
|
-
`)),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
`));
|
|
71
|
-
`))
|
|
72
|
-
`)),
|
|
73
|
-
|
|
74
|
-
`))
|
|
75
|
-
\
|
|
76
|
-
`)),
|
|
54
|
+
`)),process.exit(0)),console.log(a.yellow(`Exiting. Please install a compatible Node.js version manually.
|
|
55
|
+
`)),process.exit(0)}async function Sn(t){console.log(a.cyan(`\u2713 nvm detected on your system
|
|
56
|
+
`));let e=await ne(),n=tt(e,t);if(n.length>0){console.log(a.green(`Found ${n.length} compatible Node version(s) installed:
|
|
57
|
+
`));let s=await F({message:"Select Node version to switch to:",choices:n.map(i=>({name:`v${i}`,value:i}))});console.log(a.cyan(`
|
|
58
|
+
Switching to Node.js v${s}\u2026
|
|
59
|
+
`)),await J(s)||(console.log(a.red("Failed to switch Node version. Please try manually.")),process.exit(1)),console.log(a.green(`\u2713 Node version switched successfully
|
|
60
|
+
`));return}console.log(a.yellow(`No compatible Node versions installed.
|
|
61
|
+
`));let r=nt(t);await x({message:`Install Node.js v${r}?`,default:!0})||(console.log(a.red("Cannot proceed without compatible Node.js version.")),process.exit(1)),await re(r)||(console.log(a.red("Failed to install Node version.")),process.exit(1)),console.log(a.green(`\u2713 Node.js installed successfully
|
|
62
|
+
`)),await J(r)}async function An(t,e){let n=t.filter(l=>l.adjusted);n.length>0&&(console.log(a.green(`
|
|
63
|
+
\u2713 Dynamically resolved compatible library versions:
|
|
64
|
+
`)),g("Resolved Library Versions",n.map(({name:l,originalVersion:u,version:m,reason:d})=>({Package:l,From:u,To:m,Reason:d||""})),["Package","From","To","Reason"]));let r=t.filter(l=>l.warning);r.length>0&&(console.log(a.yellow(`
|
|
65
|
+
\u26A0\uFE0F Potential compatibility warnings:
|
|
66
|
+
`)),g("Compatibility Warnings",r.map(({name:l,version:u,reason:m})=>({Package:l,Version:u,Reason:m||""})),["Package","Version","Reason"]));let s=o(l=>l.version==="latest"?l.name:`${l.name}@${l.version}`,"toSpec"),i=t.filter(l=>!l.isDev);i.length>0&&(console.log(a.bold.cyan(`
|
|
67
|
+
\u{1F4E6} Installing production libraries\u2026
|
|
68
|
+
`)),await fe(i.map(s),e));let c=t.filter(l=>l.isDev);c.length>0&&(console.log(a.bold.cyan(`
|
|
69
|
+
\u{1F4E6} Installing dev libraries\u2026
|
|
70
|
+
`)),await fe(c.map(s),e,!0))}function Pn(t){let e=a.gray("\u2501".repeat(50));console.log(a.bold.green(`
|
|
77
71
|
\u2705 Project created successfully! \u{1F389}
|
|
78
|
-
`)),console.log(
|
|
79
|
-
`)),console.log(
|
|
72
|
+
`)),console.log(a.bold.cyan(`\u{1F4CA} Next Steps:
|
|
73
|
+
`)),console.log(e),console.log(a.white("1. ")+a.cyan(`cd ${t}`)),console.log(a.white("2. ")+a.cyan("ng serve")),console.log(a.white("3. ")+a.cyan("Open http://localhost:4200 in your browser")),console.log(e),console.log(a.bold.cyan(`
|
|
80
74
|
\u{1F4A1} Useful Commands:
|
|
81
|
-
`))
|
|
82
|
-
|
|
83
|
-
`))}
|
|
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(`
|
|
75
|
+
`));let n=[["ng generate component <name>","Create a component"],["ng generate service <name>","Create a service"],["ng build","Build for production"],["ng test","Run unit tests"],["ng help","Get more help"]];for(let[r,s]of n)console.log(`${a.gray(` ${r.padEnd(34)}`)}${a.white(s)}`);console.log(a.bold.green(`
|
|
76
|
+
Happy coding! \u{1F680}
|
|
77
|
+
`))}var yn,hn,At=h(()=>{oe();H();pe();dt();yt();wt();P();b();yn=Ae.dirname(gn(import.meta.url)),hn=JSON.parse(mn(Ae.join(yn,"../package.json"),"utf-8"));o(wn,"runCli");o(vn,"displayBanner");o(bn,"handleProfileSelection");o($n,"promptProjectOptions");o(xn,"handleNodeIncompatibility");o(Sn,"handleNvmSwitch");o(An,"installResolvedLibraries");o(Pn,"displaySuccessMessage")});import{Command as Nn}from"commander";import S from"chalk";import{readFileSync as jn}from"fs";import{fileURLToPath as kn}from"url";import{dirname as Cn,join as In}from"path";var Vn=Cn(kn(import.meta.url)),{version:En}=JSON.parse(jn(In(Vn,"../package.json"),"utf-8"));function N(t){return async(...e)=>{try{await t(...e)}catch(n){console.error(S.red("Error:"),n.message),process.exitCode=1}}}o(N,"action");var D=new Nn;D.name("ng-init").description("Angular project initializer with intelligent version management and automation").version(En);D.command("create",{isDefault:!0}).alias("new").description("Create a new Angular project with interactive setup").action(N(async()=>{let{runCli:t}=await Promise.resolve().then(()=>(At(),St));await t()}));var T=D.command("profile").description("Manage configuration profiles");T.command("list").description("List all saved profiles").action(N(async()=>{let{listProfiles:t,getProfileDetails:e}=await Promise.resolve().then(()=>(P(),E)),{printObjectList:n}=await Promise.resolve().then(()=>(b(),Ce)),r=await t();if(r.length===0){console.log(S.yellow("No saved profiles found."));return}let s=await Promise.all(r.map(async i=>{let c=await e(i);return{Name:c.name,Angular:c.angularVersion||"-",Libraries:c.libraries??0,Created:c.createdAt||"-"}}));n("Saved Profiles",s,["Name","Angular","Libraries","Created"])}));T.command("show <name>").description("Show details of a profile").action(N(async t=>{let{loadProfile:e,displayProfileInfo:n}=await Promise.resolve().then(()=>(P(),E)),r=await e(t);if(!r){console.log(S.red(`Profile "${t}" not found.`));return}n(t,r)}));T.command("delete <name>").description("Delete a profile").action(N(async t=>{let{deleteProfile:e}=await Promise.resolve().then(()=>(P(),E));await e(t)}));T.command("export <name> <output>").description("Export a profile to a file").action(N(async(t,e)=>{let{exportProfile:n}=await Promise.resolve().then(()=>(P(),E));await n(t,e)}));T.command("import <file>").description("Import a profile from a file").action(N(async t=>{let{importProfile:e}=await Promise.resolve().then(()=>(P(),E));await e(t)}));D.command("check").description("Check system versions and compatibility").action(N(async()=>{let{displaySystemVersions:t}=await Promise.resolve().then(()=>(oe(),Oe));await t()}));D.command("examples").description("Show usage examples").action(()=>{let t=S.gray("\u2501".repeat(50)),e=[["Create new project (interactive)","ng-init","or ng-init create"],["Check system versions","ng-init check"],["List saved profiles","ng-init profile list"],["Show profile details","ng-init profile show my-profile"],["Delete a profile","ng-init profile delete my-profile"],["Export a profile","ng-init profile export my-profile ./profile.json"],["Import a profile","ng-init profile import ./profile.json"]];console.log(S.bold.cyan(`
|
|
85
78
|
\u{1F4DA} Usage Examples:
|
|
86
|
-
`)),console.log(
|
|
87
|
-
`)
|
|
88
|
-
`))
|
|
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);
|
|
79
|
+
`)),console.log(t);for(let[n,r,s]of e)console.log(S.white(`${n}:`)),console.log(S.green(` $ ${r}`)+(s?S.gray(` ${s}`):"")+`
|
|
80
|
+
`);console.log(t+`
|
|
81
|
+
`)});D.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.11",
|
|
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",
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"chalk": "^5.3.0",
|
|
49
49
|
"commander": "^13.1.0",
|
|
50
50
|
"execa": "^9.6.1",
|
|
51
|
-
"lodash.debounce": "^4.0.8",
|
|
52
51
|
"ora": "^8.0.1",
|
|
53
52
|
"semver": "^7.5.4",
|
|
54
53
|
"cli-table3": "^0.6.2"
|