From 4e173755a88a21299df944b016c0178ba73b70f2 Mon Sep 17 00:00:00 2001 From: Adam Berecz Date: Tue, 7 May 2024 08:10:34 +0200 Subject: [PATCH] fix: windows fix --- CHANGELOG.md | 2 +- dist/index.mjs | 4 ++-- package.json | 2 +- src/index.js | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b41fe8..e110469 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## v1.0.7 - v1.0.9 +## v1.0.7 - v1.0.10 > `2024-05-07` diff --git a/dist/index.mjs b/dist/index.mjs index eed8a15..3f3ec62 100644 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -51,7 +51,7 @@ GFS4: `),console.error(e)}),!k[Y]){var io=Xt[Y]||[];ci(k,io),k.close=function(e) see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0001");const{srcStat:r,destStat:s}=await At.checkPaths(e,t,"copy",i);if(await At.checkParentPaths(e,r,t,"copy"),!await bi(e,t,i))return;const o=_t.dirname(t);await wo(o)||await yo(o),await Si(s,e,t,i)}async function bi(e,t,i){return i.filter?i.filter(e,t):!0}async function Si(e,t,i,r){const n=await(r.dereference?B.stat:B.lstat)(t);if(n.isDirectory())return Eo(n,e,t,i,r);if(n.isFile()||n.isCharacterDevice()||n.isBlockDevice())return bo(n,e,t,i,r);if(n.isSymbolicLink())return Po(e,t,i,r);throw n.isSocket()?new Error(`Cannot copy a socket file: ${t}`):n.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${t}`):new Error(`Unknown file: ${t}`)}async function bo(e,t,i,r,s){if(!t)return $i(e,i,r,s);if(s.overwrite)return await B.unlink(r),$i(e,i,r,s);if(s.errorOnExist)throw new Error(`'${r}' already exists`)}async function $i(e,t,i,r){if(await B.copyFile(t,i),r.preserveTimestamps){So(e.mode)&&await $o(i,e.mode);const s=await B.stat(t);await go(i,s.atime,s.mtime)}return B.chmod(i,e.mode)}function So(e){return(e&128)===0}function $o(e,t){return B.chmod(e,t|128)}async function Eo(e,t,i,r,s){t||await B.mkdir(r);const n=await B.readdir(i);await Promise.all(n.map(async o=>{const l=_t.join(i,o),y=_t.join(r,o);if(!await bi(l,y,s))return;const{destStat:a}=await At.checkPaths(l,y,"copy",s);return Si(a,l,y,s)})),t||await B.chmod(r,e.mode)}async function Po(e,t,i,r){let s=await B.readlink(t);if(r.dereference&&(s=_t.resolve(process.cwd(),s)),!e)return B.symlink(s,i);let n=null;try{n=await B.readlink(i)}catch(o){if(o.code==="EINVAL"||o.code==="UNKNOWN")return B.symlink(s,i);throw o}if(r.dereference&&(n=_t.resolve(process.cwd(),n)),At.isSrcSubdir(s,n))throw new Error(`Cannot copy '${s}' to a subdirectory of itself, '${n}'.`);if(At.isSrcSubdir(n,s))throw new Error(`Cannot overwrite '${n}' with '${s}'.`);return await B.unlink(i),B.symlink(s,i)}var xo=vo;const V=vt,It=A,Oo=X.mkdirsSync,To=yi.utimesMillisSync,Nt=Et;function Co(e,t,i){typeof i=="function"&&(i={filter:i}),i=i||{},i.clobber="clobber"in i?!!i.clobber:!0,i.overwrite="overwrite"in i?!!i.overwrite:i.clobber,i.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended; see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0002");const{srcStat:r,destStat:s}=Nt.checkPathsSync(e,t,"copy",i);if(Nt.checkParentPathsSync(e,r,t,"copy"),i.filter&&!i.filter(e,t))return;const n=It.dirname(t);return V.existsSync(n)||Oo(n),Ei(s,e,t,i)}function Ei(e,t,i,r){const n=(r.dereference?V.statSync:V.lstatSync)(t);if(n.isDirectory())return Io(n,e,t,i,r);if(n.isFile()||n.isCharacterDevice()||n.isBlockDevice())return Fo(n,e,t,i,r);if(n.isSymbolicLink())return jo(e,t,i,r);throw n.isSocket()?new Error(`Cannot copy a socket file: ${t}`):n.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${t}`):new Error(`Unknown file: ${t}`)}function Fo(e,t,i,r,s){return t?Mo(e,i,r,s):Pi(e,i,r,s)}function Mo(e,t,i,r){if(r.overwrite)return V.unlinkSync(i),Pi(e,t,i,r);if(r.errorOnExist)throw new Error(`'${i}' already exists`)}function Pi(e,t,i,r){return V.copyFileSync(t,i),r.preserveTimestamps&&ko(e.mode,t,i),ve(i,e.mode)}function ko(e,t,i){return Do(e)&&_o(i,e),Ao(t,i)}function Do(e){return(e&128)===0}function _o(e,t){return ve(e,t|128)}function ve(e,t){return V.chmodSync(e,t)}function Ao(e,t){const i=V.statSync(e);return To(t,i.atime,i.mtime)}function Io(e,t,i,r,s){return t?xi(i,r,s):No(e.mode,i,r,s)}function No(e,t,i,r){return V.mkdirSync(i),xi(t,i,r),ve(i,e)}function xi(e,t,i){V.readdirSync(e).forEach(r=>Ro(r,e,t,i))}function Ro(e,t,i,r){const s=It.join(t,e),n=It.join(i,e);if(r.filter&&!r.filter(s,n))return;const{destStat:o}=Nt.checkPathsSync(s,n,"copy",r);return Ei(o,s,n,r)}function jo(e,t,i,r){let s=V.readlinkSync(t);if(r.dereference&&(s=It.resolve(process.cwd(),s)),e){let n;try{n=V.readlinkSync(i)}catch(o){if(o.code==="EINVAL"||o.code==="UNKNOWN")return V.symlinkSync(s,i);throw o}if(r.dereference&&(n=It.resolve(process.cwd(),n)),Nt.isSrcSubdir(s,n))throw new Error(`Cannot copy '${s}' to a subdirectory of itself, '${n}'.`);if(Nt.isSrcSubdir(n,s))throw new Error(`Cannot overwrite '${n}' with '${s}'.`);return Lo(s,i)}else return V.symlinkSync(s,i)}function Lo(e,t){return V.unlinkSync(t),V.symlinkSync(e,t)}var Jo=Co;const Yo=I.fromPromise;var be={copy:Yo(xo),copySync:Jo};const Oi=vt,Bo=I.fromCallback;function Wo(e,t){Oi.rm(e,{recursive:!0,force:!0},t)}function Vo(e){Oi.rmSync(e,{recursive:!0,force:!0})}var qt={remove:Bo(Wo),removeSync:Vo};const Ho=I.fromPromise,Ti=W,Ci=A,Fi=X,Mi=qt,ki=Ho(async function(t){let i;try{i=await Ti.readdir(t)}catch{return Fi.mkdirs(t)}return Promise.all(i.map(r=>Mi.remove(Ci.join(t,r))))});function Di(e){let t;try{t=Ti.readdirSync(e)}catch{return Fi.mkdirsSync(e)}t.forEach(i=>{i=Ci.join(e,i),Mi.removeSync(i)})}var Uo={emptyDirSync:Di,emptydirSync:Di,emptyDir:ki,emptydir:ki};const Go=I.fromPromise,_i=A,nt=W,Ai=X;async function Ko(e){let t;try{t=await nt.stat(e)}catch{}if(t&&t.isFile())return;const i=_i.dirname(e);let r=null;try{r=await nt.stat(i)}catch(s){if(s.code==="ENOENT"){await Ai.mkdirs(i),await nt.writeFile(e,"");return}else throw s}r.isDirectory()?await nt.writeFile(e,""):await nt.readdir(i)}function qo(e){let t;try{t=nt.statSync(e)}catch{}if(t&&t.isFile())return;const i=_i.dirname(e);try{nt.statSync(i).isDirectory()||nt.readdirSync(i)}catch(r){if(r&&r.code==="ENOENT")Ai.mkdirsSync(i);else throw r}nt.writeFileSync(e,"")}var zo={createFile:Go(Ko),createFileSync:qo};const Zo=I.fromPromise,Ii=A,ht=W,Ni=X,{pathExists:Qo}=pt,{areIdentical:Ri}=Et;async function Xo(e,t){let i;try{i=await ht.lstat(t)}catch{}let r;try{r=await ht.lstat(e)}catch(o){throw o.message=o.message.replace("lstat","ensureLink"),o}if(i&&Ri(r,i))return;const s=Ii.dirname(t);await Qo(s)||await Ni.mkdirs(s),await ht.link(e,t)}function ta(e,t){let i;try{i=ht.lstatSync(t)}catch{}try{const n=ht.lstatSync(e);if(i&&Ri(n,i))return}catch(n){throw n.message=n.message.replace("lstat","ensureLink"),n}const r=Ii.dirname(t);return ht.existsSync(r)||Ni.mkdirsSync(r),ht.linkSync(e,t)}var ea={createLink:Zo(Xo),createLinkSync:ta};const dt=A,Rt=W,{pathExists:ia}=pt,ra=I.fromPromise;async function sa(e,t){if(dt.isAbsolute(e)){try{await Rt.lstat(e)}catch(n){throw n.message=n.message.replace("lstat","ensureSymlink"),n}return{toCwd:e,toDst:e}}const i=dt.dirname(t),r=dt.join(i,e);if(await ia(r))return{toCwd:r,toDst:e};try{await Rt.lstat(e)}catch(n){throw n.message=n.message.replace("lstat","ensureSymlink"),n}return{toCwd:e,toDst:dt.relative(i,e)}}function na(e,t){if(dt.isAbsolute(e)){if(!Rt.existsSync(e))throw new Error("absolute srcpath does not exist");return{toCwd:e,toDst:e}}const i=dt.dirname(t),r=dt.join(i,e);if(Rt.existsSync(r))return{toCwd:r,toDst:e};if(!Rt.existsSync(e))throw new Error("relative srcpath does not exist");return{toCwd:e,toDst:dt.relative(i,e)}}var oa={symlinkPaths:ra(sa),symlinkPathsSync:na};const ji=W,aa=I.fromPromise;async function la(e,t){if(t)return t;let i;try{i=await ji.lstat(e)}catch{return"file"}return i&&i.isDirectory()?"dir":"file"}function ca(e,t){if(t)return t;let i;try{i=ji.lstatSync(e)}catch{return"file"}return i&&i.isDirectory()?"dir":"file"}var ua={symlinkType:aa(la),symlinkTypeSync:ca};const ha=I.fromPromise,Li=A,tt=W,{mkdirs:da,mkdirsSync:fa}=X,{symlinkPaths:ma,symlinkPathsSync:pa}=oa,{symlinkType:ya,symlinkTypeSync:wa}=ua,{pathExists:ga}=pt,{areIdentical:Ji}=Et;async function va(e,t,i){let r;try{r=await tt.lstat(t)}catch{}if(r&&r.isSymbolicLink()){const[l,y]=await Promise.all([tt.stat(e),tt.stat(t)]);if(Ji(l,y))return}const s=await ma(e,t);e=s.toDst;const n=await ya(s.toCwd,i),o=Li.dirname(t);return await ga(o)||await da(o),tt.symlink(e,t,n)}function ba(e,t,i){let r;try{r=tt.lstatSync(t)}catch{}if(r&&r.isSymbolicLink()){const l=tt.statSync(e),y=tt.statSync(t);if(Ji(l,y))return}const s=pa(e,t);e=s.toDst,i=wa(s.toCwd,i);const n=Li.dirname(t);return tt.existsSync(n)||fa(n),tt.symlinkSync(e,t,i)}var Sa={createSymlink:ha(va),createSymlinkSync:ba};const{createFile:Yi,createFileSync:Bi}=zo,{createLink:Wi,createLinkSync:Vi}=ea,{createSymlink:Hi,createSymlinkSync:Ui}=Sa;var $a={createFile:Yi,createFileSync:Bi,ensureFile:Yi,ensureFileSync:Bi,createLink:Wi,createLinkSync:Vi,ensureLink:Wi,ensureLinkSync:Vi,createSymlink:Hi,createSymlinkSync:Ui,ensureSymlink:Hi,ensureSymlinkSync:Ui};function Ea(e,{EOL:t=` -`,finalEOL:i=!0,replacer:r=null,spaces:s}={}){const n=i?t:"";return JSON.stringify(e,r,s).replace(/\n/g,t)+n}function Pa(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e.replace(/^\uFEFF/,"")}var Se={stringify:Ea,stripBom:Pa};let Pt;try{Pt=vt}catch{Pt=Fe}const zt=I,{stringify:Gi,stripBom:Ki}=Se;async function xa(e,t={}){typeof t=="string"&&(t={encoding:t});const i=t.fs||Pt,r="throws"in t?t.throws:!0;let s=await zt.fromCallback(i.readFile)(e,t);s=Ki(s);let n;try{n=JSON.parse(s,t?t.reviver:null)}catch(o){if(r)throw o.message=`${e}: ${o.message}`,o;return null}return n}const Oa=zt.fromPromise(xa);function Ta(e,t={}){typeof t=="string"&&(t={encoding:t});const i=t.fs||Pt,r="throws"in t?t.throws:!0;try{let s=i.readFileSync(e,t);return s=Ki(s),JSON.parse(s,t.reviver)}catch(s){if(r)throw s.message=`${e}: ${s.message}`,s;return null}}async function Ca(e,t,i={}){const r=i.fs||Pt,s=Gi(t,i);await zt.fromCallback(r.writeFile)(e,s,i)}const Fa=zt.fromPromise(Ca);function Ma(e,t,i={}){const r=i.fs||Pt,s=Gi(t,i);return r.writeFileSync(e,s,i)}const ka={readFile:Oa,readFileSync:Ta,writeFile:Fa,writeFileSync:Ma};var Da=ka;const Zt=Da;var _a={readJson:Zt.readFile,readJsonSync:Zt.readFileSync,writeJson:Zt.writeFile,writeJsonSync:Zt.writeFileSync};const Aa=I.fromPromise,$e=W,qi=A,zi=X,Ia=pt.pathExists;async function Na(e,t,i="utf-8"){const r=qi.dirname(e);return await Ia(r)||await zi.mkdirs(r),$e.writeFile(e,t,i)}function Ra(e,...t){const i=qi.dirname(e);$e.existsSync(i)||zi.mkdirsSync(i),$e.writeFileSync(e,...t)}var Ee={outputFile:Aa(Na),outputFileSync:Ra};const{stringify:ja}=Se,{outputFile:La}=Ee;async function Ja(e,t,i={}){const r=ja(t,i);await La(e,r,i)}var Ya=Ja;const{stringify:Ba}=Se,{outputFileSync:Wa}=Ee;function Va(e,t,i){const r=Ba(t,i);Wa(e,r,i)}var Ha=Va;const Ua=I.fromPromise,H=_a;H.outputJson=Ua(Ya),H.outputJsonSync=Ha,H.outputJSON=H.outputJson,H.outputJSONSync=H.outputJsonSync,H.writeJSON=H.writeJson,H.writeJSONSync=H.writeJsonSync,H.readJSON=H.readJson,H.readJSONSync=H.readJsonSync;var Ga=H;const Ka=W,Zi=A,{copy:qa}=be,{remove:Qi}=qt,{mkdirp:za}=X,{pathExists:Za}=pt,Xi=Et;async function Qa(e,t,i={}){const r=i.overwrite||i.clobber||!1,{srcStat:s,isChangingCase:n=!1}=await Xi.checkPaths(e,t,"move",i);await Xi.checkParentPaths(e,s,t,"move");const o=Zi.dirname(t);return Zi.parse(o).root!==o&&await za(o),Xa(e,t,r,n)}async function Xa(e,t,i,r){if(!r){if(i)await Qi(t);else if(await Za(t))throw new Error("dest already exists.")}try{await Ka.rename(e,t)}catch(s){if(s.code!=="EXDEV")throw s;await tl(e,t,i)}}async function tl(e,t,i){return await qa(e,t,{overwrite:i,errorOnExist:!0,preserveTimestamps:!0}),Qi(e)}var el=Qa;const tr=vt,Pe=A,il=be.copySync,er=qt.removeSync,rl=X.mkdirpSync,ir=Et;function sl(e,t,i){i=i||{};const r=i.overwrite||i.clobber||!1,{srcStat:s,isChangingCase:n=!1}=ir.checkPathsSync(e,t,"move",i);return ir.checkParentPathsSync(e,s,t,"move"),nl(t)||rl(Pe.dirname(t)),ol(e,t,r,n)}function nl(e){const t=Pe.dirname(e);return Pe.parse(t).root===t}function ol(e,t,i,r){if(r)return xe(e,t,i);if(i)return er(t),xe(e,t,i);if(tr.existsSync(t))throw new Error("dest already exists.");return xe(e,t,i)}function xe(e,t,i){try{tr.renameSync(e,t)}catch(r){if(r.code!=="EXDEV")throw r;return al(e,t,i)}}function al(e,t,i){return il(e,t,{overwrite:i,errorOnExist:!0,preserveTimestamps:!0}),er(e)}var ll=sl;const cl=I.fromPromise;var ul={move:cl(el),moveSync:ll},hl={...W,...be,...Uo,...$a,...Ga,...X,...ul,...Ee,...pt,...qt};const ot=te(hl);let yt=!0;const xt=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let jt=0;if(xt.process&&xt.process.env&&xt.process.stdout){const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,NO_COLOR:i,TERM:r,COLORTERM:s}=xt.process.env;t||i||e==="0"?yt=!1:e==="1"||e==="2"||e==="3"?yt=!0:r==="dumb"?yt=!1:"CI"in xt.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(n=>n in xt.process.env)?yt=!0:yt=process.stdout.isTTY,yt&&(process.platform==="win32"||s&&(s==="truecolor"||s==="24bit")?jt=3:r&&(r.endsWith("-256color")||r.endsWith("256"))?jt=2:jt=1)}let rr={enabled:yt,supportLevel:jt};function Oe(e,t,i=1){const r=`\x1B[${e}m`,s=`\x1B[${t}m`,n=new RegExp(`\\x1b\\[${t}m`,"g");return o=>rr.enabled&&rr.supportLevel>=i?r+(""+o).replace(n,r)+s:""+o}const Ot=Oe(31,39),dl=Oe(32,39),Te=Oe(36,39),sr="18.0.0",nr="7.0.0",fl=gr(br),U=Bn(process.argv.slice(2),{string:["_"]}),or="vueform-project",ar=bl(process.env.npm_config_user_agent),Tt=ar?ar.name:"npm",ml=A.dirname(Er(import.meta.url)),pl=!!U.start||!!U.s,lr=!!U.force||!!U.f,cr=[{title:"Vite",value:"vite",command:{npm:"npm create vite@latest %PROJECT_NAME% -- --template %TEMPLATE%",yarn:"yarn create vite %PROJECT_NAME% --template %TEMPLATE%",pnpm:"pnpm create vite %PROJECT_NAME% --template %TEMPLATE%",bun:"bun create vite %PROJECT_NAME% --template %TEMPLATE%"}},{title:"Nuxt",value:"nuxt",command:{npm:"npx nuxi@latest init %PROJECT_NAME% --packageManager=%PACKAGE_MANAGER%",yarn:"npx nuxi@latest init %PROJECT_NAME% --packageManager=%PACKAGE_MANAGER%",pnpm:"pnpm dlx nuxi@latest init %PROJECT_NAME% --packageManager=%PACKAGE_MANAGER%",bun:"bunx nuxi@latest init %PROJECT_NAME% --packageManager=%PACKAGE_MANAGER%"}},{title:"Astro",value:"astro",command:{npm:"npm create astro@latest %PROJECT_NAME% -- --install=yes",yarn:"yarn create astro %PROJECT_NAME% --install=yes",pnpm:"pnpm create astro %PROJECT_NAME% --install=yes",bun:"bun create astro %PROJECT_NAME% --install=yes"}},{title:"Laravel",value:"laravel",command:"%COMPOSER_PATH% create-project laravel/laravel %PROJECT_NAME%"}],yl=[{title:"Vueform",value:"vueform"},{title:"Tailwind",value:"tailwind"},{title:"Bootstrap",value:"bootstrap"},{title:"Material",value:"material"},{title:"Tailwind Material",value:"tailwind-material"}],wl={vite:{install:["npm install -D tailwindcss postcss autoprefixer"]},nuxt:{install:["npm install -D @nuxtjs/tailwindcss"]},astro:{install:["npm install @astrojs/tailwind tailwindcss"]},laravel:{install:["npm install -D tailwindcss postcss autoprefixer"]}};process.env.PATH+=":/usr/local/bin",Ol();async function gl(){try{const{projectName:e}=await si({type:"text",name:"projectName",initial:or,message:"Choose a project name:",validate:async m=>/^[a-zA-Z0-9]+[a-zA-Z0-9-_]*$/.test(m)?!lr&&await ur(m)?`The directory '${m}' already exists.`:m?!0:"Please provide a project name":"Invalid project name. Use only alphanumeric, underscore, and hyphen characters and do not start with a hyphen or underscore."},{onCancel:()=>{throw new Error(Ot("\u2716")+" Operation cancelled")}});lr&&await ur(A.join(process.cwd(),e))&&await z("rm",["-r",or]);const t=await si([{type:U.builder||U.b?null:"select",name:"builder",message:"Which libraries do you want to install?",choices:[{title:"Vueform",value:"vueform"},{title:"Vueform + Builder",value:"builder"}]},{type:m=>U.builder||U.b||m==="builder"?"text":null,name:"publicKey",initial:U.publicKey||U.pk||"obtain a FREE one at https://app.vueform.com",message:"Your Public Key: ",validate:async m=>/^[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}$/.test(m)?m?!0:"Please provide your Public Key. If you don't have one go to https://app.vueform.com and generate one for FREE.":"Invalid Public Key. Please go to https://app.vueform.com and generate one for FREE."},{type:"select",name:"framework",message:"Choose a framework:",choices:cr},{type:m=>m!=="vite"||m==="laravel"?null:"toggle",name:"ts",message:"Do you plan to use TypeScript?",initial:"yes",active:"yes",inactive:"no"},{type:(m,{builder:v})=>U.builder||U.b||v==="builder"?null:"select",name:"theme",message:"Select a theme for your project:",choices:yl}],{onCancel:()=>{throw new Error(Ot("\u2716")+" Operation cancelled")}}),{framework:i,ts:r,publicKey:s}=t;console.log(e);const n=!!U.builder||!!U.b||t.builder==="builder",o=n?"tailwind":t.theme,l=i==="astro",y=["tailwind","tailwind-material"].indexOf(o)!==-1||n,d=["bootstrap"].indexOf(o)!==-1,a=i==="laravel";if(e&&i){const m=vl(i);Qt(` +`,finalEOL:i=!0,replacer:r=null,spaces:s}={}){const n=i?t:"";return JSON.stringify(e,r,s).replace(/\n/g,t)+n}function Pa(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e.replace(/^\uFEFF/,"")}var Se={stringify:Ea,stripBom:Pa};let Pt;try{Pt=vt}catch{Pt=Fe}const zt=I,{stringify:Gi,stripBom:Ki}=Se;async function xa(e,t={}){typeof t=="string"&&(t={encoding:t});const i=t.fs||Pt,r="throws"in t?t.throws:!0;let s=await zt.fromCallback(i.readFile)(e,t);s=Ki(s);let n;try{n=JSON.parse(s,t?t.reviver:null)}catch(o){if(r)throw o.message=`${e}: ${o.message}`,o;return null}return n}const Oa=zt.fromPromise(xa);function Ta(e,t={}){typeof t=="string"&&(t={encoding:t});const i=t.fs||Pt,r="throws"in t?t.throws:!0;try{let s=i.readFileSync(e,t);return s=Ki(s),JSON.parse(s,t.reviver)}catch(s){if(r)throw s.message=`${e}: ${s.message}`,s;return null}}async function Ca(e,t,i={}){const r=i.fs||Pt,s=Gi(t,i);await zt.fromCallback(r.writeFile)(e,s,i)}const Fa=zt.fromPromise(Ca);function Ma(e,t,i={}){const r=i.fs||Pt,s=Gi(t,i);return r.writeFileSync(e,s,i)}const ka={readFile:Oa,readFileSync:Ta,writeFile:Fa,writeFileSync:Ma};var Da=ka;const Zt=Da;var _a={readJson:Zt.readFile,readJsonSync:Zt.readFileSync,writeJson:Zt.writeFile,writeJsonSync:Zt.writeFileSync};const Aa=I.fromPromise,$e=W,qi=A,zi=X,Ia=pt.pathExists;async function Na(e,t,i="utf-8"){const r=qi.dirname(e);return await Ia(r)||await zi.mkdirs(r),$e.writeFile(e,t,i)}function Ra(e,...t){const i=qi.dirname(e);$e.existsSync(i)||zi.mkdirsSync(i),$e.writeFileSync(e,...t)}var Ee={outputFile:Aa(Na),outputFileSync:Ra};const{stringify:ja}=Se,{outputFile:La}=Ee;async function Ja(e,t,i={}){const r=ja(t,i);await La(e,r,i)}var Ya=Ja;const{stringify:Ba}=Se,{outputFileSync:Wa}=Ee;function Va(e,t,i){const r=Ba(t,i);Wa(e,r,i)}var Ha=Va;const Ua=I.fromPromise,H=_a;H.outputJson=Ua(Ya),H.outputJsonSync=Ha,H.outputJSON=H.outputJson,H.outputJSONSync=H.outputJsonSync,H.writeJSON=H.writeJson,H.writeJSONSync=H.writeJsonSync,H.readJSON=H.readJson,H.readJSONSync=H.readJsonSync;var Ga=H;const Ka=W,Zi=A,{copy:qa}=be,{remove:Qi}=qt,{mkdirp:za}=X,{pathExists:Za}=pt,Xi=Et;async function Qa(e,t,i={}){const r=i.overwrite||i.clobber||!1,{srcStat:s,isChangingCase:n=!1}=await Xi.checkPaths(e,t,"move",i);await Xi.checkParentPaths(e,s,t,"move");const o=Zi.dirname(t);return Zi.parse(o).root!==o&&await za(o),Xa(e,t,r,n)}async function Xa(e,t,i,r){if(!r){if(i)await Qi(t);else if(await Za(t))throw new Error("dest already exists.")}try{await Ka.rename(e,t)}catch(s){if(s.code!=="EXDEV")throw s;await tl(e,t,i)}}async function tl(e,t,i){return await qa(e,t,{overwrite:i,errorOnExist:!0,preserveTimestamps:!0}),Qi(e)}var el=Qa;const tr=vt,Pe=A,il=be.copySync,er=qt.removeSync,rl=X.mkdirpSync,ir=Et;function sl(e,t,i){i=i||{};const r=i.overwrite||i.clobber||!1,{srcStat:s,isChangingCase:n=!1}=ir.checkPathsSync(e,t,"move",i);return ir.checkParentPathsSync(e,s,t,"move"),nl(t)||rl(Pe.dirname(t)),ol(e,t,r,n)}function nl(e){const t=Pe.dirname(e);return Pe.parse(t).root===t}function ol(e,t,i,r){if(r)return xe(e,t,i);if(i)return er(t),xe(e,t,i);if(tr.existsSync(t))throw new Error("dest already exists.");return xe(e,t,i)}function xe(e,t,i){try{tr.renameSync(e,t)}catch(r){if(r.code!=="EXDEV")throw r;return al(e,t,i)}}function al(e,t,i){return il(e,t,{overwrite:i,errorOnExist:!0,preserveTimestamps:!0}),er(e)}var ll=sl;const cl=I.fromPromise;var ul={move:cl(el),moveSync:ll},hl={...W,...be,...Uo,...$a,...Ga,...X,...ul,...Ee,...pt,...qt};const ot=te(hl);let yt=!0;const xt=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let jt=0;if(xt.process&&xt.process.env&&xt.process.stdout){const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,NO_COLOR:i,TERM:r,COLORTERM:s}=xt.process.env;t||i||e==="0"?yt=!1:e==="1"||e==="2"||e==="3"?yt=!0:r==="dumb"?yt=!1:"CI"in xt.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(n=>n in xt.process.env)?yt=!0:yt=process.stdout.isTTY,yt&&(process.platform==="win32"||s&&(s==="truecolor"||s==="24bit")?jt=3:r&&(r.endsWith("-256color")||r.endsWith("256"))?jt=2:jt=1)}let rr={enabled:yt,supportLevel:jt};function Oe(e,t,i=1){const r=`\x1B[${e}m`,s=`\x1B[${t}m`,n=new RegExp(`\\x1b\\[${t}m`,"g");return o=>rr.enabled&&rr.supportLevel>=i?r+(""+o).replace(n,r)+s:""+o}const Ot=Oe(31,39),dl=Oe(32,39),Te=Oe(36,39),sr="18.0.0",nr="7.0.0",fl=gr(br),U=Bn(process.argv.slice(2),{string:["_"]}),or="vueform-project",ar=bl(process.env.npm_config_user_agent),Tt=ar?ar.name:"npm",ml=A.dirname(Er(import.meta.url)),pl=!!U.start||!!U.s,lr=!!U.force||!!U.f,cr=[{title:"Vite",value:"vite",command:{npm:"npm create vite@latest %PROJECT_NAME% -- --template %TEMPLATE%",yarn:"yarn create vite %PROJECT_NAME% --template %TEMPLATE%",pnpm:"pnpm create vite %PROJECT_NAME% --template %TEMPLATE%",bun:"bun create vite %PROJECT_NAME% --template %TEMPLATE%"}},{title:"Nuxt",value:"nuxt",command:{npm:"npx nuxi@latest init %PROJECT_NAME% --packageManager=%PACKAGE_MANAGER%",yarn:"npx nuxi@latest init %PROJECT_NAME% --packageManager=%PACKAGE_MANAGER%",pnpm:"pnpm dlx nuxi@latest init %PROJECT_NAME% --packageManager=%PACKAGE_MANAGER%",bun:"bunx nuxi@latest init %PROJECT_NAME% --packageManager=%PACKAGE_MANAGER%"}},{title:"Astro",value:"astro",command:{npm:"npm create astro@latest %PROJECT_NAME% -- --install=yes",yarn:"yarn create astro %PROJECT_NAME% --install=yes",pnpm:"pnpm create astro %PROJECT_NAME% --install=yes",bun:"bun create astro %PROJECT_NAME% --install=yes"}},{title:"Laravel",value:"laravel",command:"%COMPOSER_PATH% create-project laravel/laravel %PROJECT_NAME%"}],yl=[{title:"Vueform",value:"vueform"},{title:"Tailwind",value:"tailwind"},{title:"Bootstrap",value:"bootstrap"},{title:"Material",value:"material"},{title:"Tailwind Material",value:"tailwind-material"}],wl={vite:{install:["npm install -D tailwindcss postcss autoprefixer"]},nuxt:{install:["npm install -D @nuxtjs/tailwindcss"]},astro:{install:["npm install @astrojs/tailwind tailwindcss"]},laravel:{install:["npm install -D tailwindcss postcss autoprefixer"]}};process.env.PATH+=":/usr/local/bin",Ol();async function gl(){try{const{projectName:e}=await si({type:"text",name:"projectName",initial:or,message:"Choose a project name:",validate:async m=>/^[a-zA-Z0-9]+[a-zA-Z0-9-_]*$/.test(m)?!lr&&await ur(m)?`The directory '${m}' already exists.`:m?!0:"Please provide a project name":"Invalid project name. Use only alphanumeric, underscore, and hyphen characters and do not start with a hyphen or underscore."},{onCancel:()=>{throw new Error(Ot("\u2716")+" Operation cancelled")}});lr&&await ur(A.join(process.cwd(),e))&&await z("rm",["-r",or]);const t=await si([{type:U.builder||U.b?null:"select",name:"builder",message:"Which libraries do you want to install?",choices:[{title:"Vueform",value:"vueform"},{title:"Vueform + Builder",value:"builder"}]},{type:m=>U.builder||U.b||m==="builder"?"text":null,name:"publicKey",initial:U.publicKey||U.pk||"obtain a FREE one at https://app.vueform.com",message:"Your Public Key: ",validate:async m=>/^[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}$/.test(m)?m?!0:"Please provide your Public Key. If you don't have one go to https://app.vueform.com and generate one for FREE.":"Invalid Public Key. Please go to https://app.vueform.com and generate one for FREE."},{type:"select",name:"framework",message:"Choose a framework:",choices:cr},{type:m=>m!=="vite"||m==="laravel"?null:"toggle",name:"ts",message:"Do you plan to use TypeScript?",initial:"yes",active:"yes",inactive:"no"},{type:(m,{builder:v})=>U.builder||U.b||v==="builder"?null:"select",name:"theme",message:"Select a theme for your project:",choices:yl}],{onCancel:()=>{throw new Error(Ot("\u2716")+" Operation cancelled")}}),{framework:i,ts:r,publicKey:s}=t,n=!!U.builder||!!U.b||t.builder==="builder",o=n?"tailwind":t.theme,l=i==="astro",y=["tailwind","tailwind-material"].indexOf(o)!==-1||n,d=["bootstrap"].indexOf(o)!==-1,a=i==="laravel";if(e&&i){const m=vl(i);Qt(` Creating project '${e}' using ${m.title}...`);const v=i==="vite"?`vue${r?"-ts":""}`:"";let b="";i==="laravel"&&(b=await xl());let T=typeof m.command=="string"?m.command:m.command[Tt];T=T.replace("%PROJECT_NAME%",e).replace("%TEMPLATE%",v).replace("%PACKAGE_MANAGER%",Tt).replace("%COMPOSER_PATH%",b).split(" "),await z(T[0],T.slice(1),`create project with ${m.title}`)}else{console.error("Project creation canceled.");return}if(!o){console.error("Project creation canceled.");return}process.chdir(e);const h=await Sl(process.cwd(),i,r),c=A.join(ml,"../","templates",n?"builder":"vueform",i,o,h?"ts":"js"),u=process.cwd();Qt(` Installing dependencies...`),await z("npm",["install"],"install dependencies"),y&&(Qt(` Installing Tailwind...`),await Promise.all(wl[i].install.map(async m=>{const v=m.split(" ");await z(v[0],v.slice(1),"install Tailwind CSS")}))),d&&(console.log(` @@ -61,6 +61,6 @@ Installing Vue...`),await z("npm",["install","@vitejs/plugin-vue"],"install Vue Installing Vueform${n?" Builder":""}...`),await z("npm",["install",...f.split(" ")],`install ${f}`),await Pl(c,u),n&&await El(process.cwd(),s),console.log(dl(` \u2714 Installation finished`)),console.log(Te(` cd ${e}`)),console.log(Te(`${Tt} run dev -`)),pl&&(a?(await z("npm",["run","build"]),await z("php",["artisan","serve"])):await z("npm",["run","dev"]))}catch(e){console.log(Ot(e.message));return}}function vl(e){return cr.find(t=>t.value===e)}function bl(e){if(!e)return;const t=e.split(" ")[0].split("/");return{name:t[0],version:t[1]}}function z(e,t,i=""){return e==="npm"&&(e=["npm","yarn","pnpm","bun"].indexOf(Tt)!==-1?Tt:"npm",t[0]==="install"&&t.length>1&&["yarn","pnpm"].indexOf(Tt)!==-1&&(t=[...t],t[0]="add")),/^win/.test(process.platform)&&(e==="rm"?(e="rmdir",t=["/s","/q",...t.slice(1)]):e+=".cmd"),new Promise((r,s)=>{const n=$r(e,t,{stdio:"inherit"});n.on("close",o=>{o!==0?s(new Error(`${e} exited with code ${o}`)):r()}),n.on("error",o=>{s(new Error(`Failed to ${i||"start process"}: ${o.message}`))})})}function Qt(e){return console.log(Te(e))}async function ur(e){try{return(await mr.stat(e)).isDirectory()}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function Sl(e,t,i){switch(t){case"nuxt":return!0;case"astro":const r=A.join(e,"tsconfig.json");try{return(await ot.readJson(r)).extends!=="astro/tsconfigs/base"}catch(s){throw new Error(`Error reading tsconfig.json: ${s.message}`)}break;case"laravel":return!1;default:return i}}async function $l(e){const t=A.join(e,"tsconfig.json");try{const i=await ot.readJson(t);i.compilerOptions={jsx:"preserve"},await ot.writeJson(t,i,{spaces:2})}catch(i){throw new Error(`Error updating tsconfig.json: ${i.message}`)}}async function El(e,t){const i=A.join(e,"vueform.config.js"),r=A.join(e,"vueform.config.ts");let s;try{if(await ot.pathExists(i))s=i;else if(await ot.pathExists(r))s=r;else throw new Error(`No vueform.config.js or vueform.config.ts file found: ${err.message}`)}catch(n){throw new Error(`Error checking for config files: ${n.message}`)}try{let n=await ot.readFile(s,"utf8");n=n.replace(/YOUR_PUBLIC_KEY/g,t),await ot.writeFile(s,n,"utf8")}catch(n){throw new Error(`Error inserting Public Key to ${A.basename(s)}: ${n.message}`)}}async function Pl(e,t){try{await ot.copy(e,t,{overwrite:!0})}catch(i){throw new Error(`Error copying files: ${i.message}`)}}async function xl(){const e=["/usr/local/bin/composer","/usr/local/bin/composer.phar","/usr/bin/composer","/usr/bin/composer.phar","C:\\ProgramData\\ComposerSetup\\bin\\composer","C:\\ProgramData\\ComposerSetup\\bin\\composer.phar","C:\\Program Files\\Composer\\composer.phar","C:\\Program Files\\Composer\\composer"];let t="composer";try{return await fl("composer --version"),t}catch{t=""}if(e.forEach(i=>{ot.existsSync(i)&&(t=i)}),t.endsWith(".phar")&&(t=`php ${t}`),!t)throw console.error(Ot(` +`)),pl&&(a?(await z("npm",["run","build"]),await z("php",["artisan","serve"])):await z("npm",["run","dev"]))}catch(e){console.log(Ot(e.message));return}}function vl(e){return cr.find(t=>t.value===e)}function bl(e){if(!e)return;const t=e.split(" ")[0].split("/");return{name:t[0],version:t[1]}}function z(e,t,i=""){return e==="npm"&&(e=["npm","yarn","pnpm","bun"].indexOf(Tt)!==-1?Tt:"npm",t[0]==="install"&&t.length>1&&["yarn","pnpm"].indexOf(Tt)!==-1&&(t=[...t],t[0]="add")),/^win/.test(process.platform)&&(e==="rm"?(e="rmdir",t=["/s","/q",...t.slice(1)]):e+=".cmd"),new Promise((r,s)=>{const n=$r(e,t,{stdio:"inherit",shell:!0});n.on("close",o=>{o!==0?s(new Error(`${e} exited with code ${o}`)):r()}),n.on("error",o=>{s(new Error(`Failed to ${i||"start process"}: ${o.message}`))})})}function Qt(e){return console.log(Te(e))}async function ur(e){try{return(await mr.stat(e)).isDirectory()}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function Sl(e,t,i){switch(t){case"nuxt":return!0;case"astro":const r=A.join(e,"tsconfig.json");try{return(await ot.readJson(r)).extends!=="astro/tsconfigs/base"}catch(s){throw new Error(`Error reading tsconfig.json: ${s.message}`)}break;case"laravel":return!1;default:return i}}async function $l(e){const t=A.join(e,"tsconfig.json");try{const i=await ot.readJson(t);i.compilerOptions={jsx:"preserve"},await ot.writeJson(t,i,{spaces:2})}catch(i){throw new Error(`Error updating tsconfig.json: ${i.message}`)}}async function El(e,t){const i=A.join(e,"vueform.config.js"),r=A.join(e,"vueform.config.ts");let s;try{if(await ot.pathExists(i))s=i;else if(await ot.pathExists(r))s=r;else throw new Error(`No vueform.config.js or vueform.config.ts file found: ${err.message}`)}catch(n){throw new Error(`Error checking for config files: ${n.message}`)}try{let n=await ot.readFile(s,"utf8");n=n.replace(/YOUR_PUBLIC_KEY/g,t),await ot.writeFile(s,n,"utf8")}catch(n){throw new Error(`Error inserting Public Key to ${A.basename(s)}: ${n.message}`)}}async function Pl(e,t){try{await ot.copy(e,t,{overwrite:!0})}catch(i){throw new Error(`Error copying files: ${i.message}`)}}async function xl(){const e=["/usr/local/bin/composer","/usr/local/bin/composer.phar","/usr/bin/composer","/usr/bin/composer.phar","C:\\ProgramData\\ComposerSetup\\bin\\composer","C:\\ProgramData\\ComposerSetup\\bin\\composer.phar","C:\\Program Files\\Composer\\composer.phar","C:\\Program Files\\Composer\\composer"];let t="composer";try{return await fl("composer --version"),t}catch{t=""}if(e.forEach(i=>{ot.existsSync(i)&&(t=i)}),t.endsWith(".phar")&&(t=`php ${t}`),!t)throw console.error(Ot(` Composer not found. Please ensure Composer is installed and added to your PATH.`)),console.error(Ot(`Visit https://getcomposer.org/download/ for installation instructions. `)),new Error(Ot("\u2716")+" Operation cancelled");return t}function Ol(){const e=process.version.replace("v",""),t=Sr("npm -v").toString().trim();hr(e,sr)<0&&(console.error(`Error: Minimum Node.js version required is ${sr}. Your current version is ${e}. Please upgrade Node.js.`),process.exit(1)),hr(t,nr)<0&&(console.error(`Error: Minimum npm version required is ${nr}. Your current version is ${t}. Please upgrade npm.`),process.exit(1))}function hr(e,t){const i=e.split(".").map(Number),r=t.split(".").map(Number);for(let s=0;s<3;s++)if(i[s]!==r[s])return i[s]-r[s];return 0}gl(); diff --git a/package.json b/package.json index e3d6d21..d72230b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-vueform", - "version": "1.0.9", + "version": "1.0.10", "type": "module", "license": "MIT", "author": "Adam Berecz", diff --git a/src/index.js b/src/index.js index 406c80d..905dd67 100644 --- a/src/index.js +++ b/src/index.js @@ -171,8 +171,6 @@ async function main() { const { framework, ts, publicKey } = response - console.log(projectName) - /** * Variables */ @@ -362,6 +360,7 @@ function runCommand(command, args, name = '') { return new Promise((resolve, reject) => { const childProcess = spawn(command, args, { stdio: 'inherit', + shell: true, }) childProcess.on('close', code => {