create-banana 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -5
- package/package.json +3 -2
- package/readme.md +8 -8
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import wt from"path";import N from"fs-extra";import{select as it}from"@inquirer/prompts";import nt from"chalk";import st from"ora";var at=async(t,e)=>{try{if(N.pathExistsSync(e))if(!await it({message:`The target folder "${t}" is existing. ${nt.yellow("Overwrite")}?`,choices:[{name:"Yes",value:!0},{name:"No",value:!1}]}))console.log("canceled!"),process.exit(0);else{let o=st("Overwriting existing folder...").start();await N.remove(e),await N.mkdir(e),o.succeed("Existing folder overwritten.")}}catch(r){console.error(r),process.exit(1)}},J=at;import P from"fs-extra";import G from"path";import pt from"ejs";var g=class{targetDir;pkg;fileMiddlewares;constructor(e){this.targetDir=e,this.pkg={},this.fileMiddlewares=[]}writePkg(e){this.pkg={...this.pkg,...e}}extendDepsPkg(e){this.pkg.dependencies={...this.pkg.dependencies,...e.dependencies}}extendDevDepsPkg(e){this.pkg.devDependencies={...this.pkg.devDependencies,...e.devDependencies}}extendScriptsPkg(e){this.pkg.scripts={...this.pkg.scripts,...e.scripts}}copy(e,r){this.fileMiddlewares.push(()=>{P.copySync(e,G.join(this.targetDir,r))})}render(e,r,o){this.fileMiddlewares.push(()=>{P.outputFileSync(G.join(this.targetDir,r),pt.render(P.readFileSync(e,"utf-8"),o))})}async generate(){this.fileMiddlewares.forEach(e=>e()),P.writeFileSync(G.join(this.targetDir,"package.json"),JSON.stringify(this.pkg,null,2))}};import d from"chalk";import{input as ct,checkbox as ut}from"@inquirer/prompts";import{select as mt}from"@inquirer/prompts";var c=async t=>await mt({message:t,choices:[{name:"Yes",value:!0},{name:"No",value:!1}]});var L=async()=>await ct({message:`Enter your ${d.yellow("project name")}:`,required:!0}),M=async()=>{let t=await ut({message:`Please select the ${d.yellow("features")} to include:`,choices:[{name:"Eslint",value:"eslint"},{name:"Prettier",value:"prettier"},{name:"Pinia",value:"pinia"},{name:"Vue-Router",value:"vue-router"},{name:"Commitizen",value:"commitizen"}]}),e=t.includes("eslint"),r=t.includes("prettier"),o=t.includes("pinia"),i=t.includes("vue-router"),n=t.includes("commitizen"),s=!1;o&&(s=await c(`Do you want to use ${d.yellow.bold("pinia-plugin-persistedstate")} for Pinia state persistence?`));let p=!1;(e||r)&&(p=await c(`Do you want to use ${d.yellow.bold("Husky")} for Git hooks?`));let A=!1;return p&&(A=await c(`Do you want to use ${d.yellow.bold("lint-staged")} to run linters on staged files?`)),{useEslint:e,usePrettier:r,usePinia:o,useVueRouter:i,usePiniaPluginPersistedstate:s,useHusky:p,useLintStaged:A,useCommitizen:n}};import lt from"figlet";var ft=async t=>{try{return await lt.text(t,{font:"Big Money-se",horizontalLayout:"default",verticalLayout:"default",width:80,whitespaceBreak:!0})}catch(e){console.log("Something went wrong..."),console.dir(e)}},E=ft;import gt from"chalk";function dt(t,e,r){e/=100,r/=100;let o=s=>(s+t/30)%12,i=e*Math.min(r,1-r),n=s=>r-i*Math.max(-1,Math.min(o(s)-3,Math.min(9-o(s),1)));return[Math.round(255*n(0)),Math.round(255*n(8)),Math.round(255*n(4))]}function yt(t){return t.split("").map((e,r)=>{let o=r/t.length*360,[i,n,s]=dt(o,100,50);return gt.rgb(i,n,s)(e)}).join("")}var T=yt;import f from"chalk";import C from"boxen";var h=console.log,j=[22,198,12],l,I=(t,{useEslint:e,usePrettier:r,useHusky:o})=>{l=e?"pnpm i && pnpm lint":r?"pnpm i && pnpm format":"pnpm i",l=o?`cd ${t} && git init && `+l:`cd ${t} && `+l,h(f.cyan(C(f.rgb(...j)(`
|
|
3
3
|
${l}
|
|
4
4
|
`),{title:"commands",titleAlignment:"center"})),`
|
|
5
5
|
`)},y,R=(t,{useHusky:e,useCommitizen:r})=>{y=e?`cd ${t} && git add .`:`cd ${t} && git init && git add .`,y+=` && ${r?"pnpm commit":'git commit -m "Initial commit"'}`,h(f.cyan(C(f.rgb(...j)(`
|
|
6
6
|
${y}
|
|
7
|
-
`),{title:"commands",titleAlignment:"center"})))},w,
|
|
7
|
+
`),{title:"commands",titleAlignment:"center"})))},w,F=t=>{w=`cd ${t} && pnpm i -g commitizen && commitizen init cz-conventional-changelog --pnpm --save-dev --save-exact`,h(f.cyan(C(f.rgb(...j)(`
|
|
8
8
|
${w}
|
|
9
9
|
`),{title:"commands",titleAlignment:"center"})),`
|
|
10
|
-
`)},
|
|
10
|
+
`)},B=async()=>{h(T(await E("BANANA")))},x=async t=>{h(T(t))};import V from"fs-extra";import{fileURLToPath as ht}from"url";var a=ht(new URL("../dist/template",import.meta.url));import m from"path";var H=(t,e)=>{let r=m.join(a,"base");t.writePkg(V.readJSONSync(m.join(r,"static","package.json"))),t.copy(m.join(r,"static"),""),t.fileMiddlewares.push(()=>{V.renameSync(m.join(t.targetDir,"_gitignore"),m.join(t.targetDir,".gitignore"))}),t.render(m.join(r,"ejs","App.vue.ejs"),m.join("src","App.vue"),{...e}),t.render(m.join(r,"ejs","main.js.ejs"),m.join("src","main.js"),{...e})};import Y from"fs-extra";import u from"path";var U=(t,e)=>{let{usePinia:r,usePiniaPluginPersistedstate:o}=e;if(!r)return;let i=u.join(a,"pinia");if(t.extendDepsPkg(Y.readJSONSync(u.join(i,"package.json"))),t.copy(u.join(i,"counter.js"),u.join("src","stores","counter.js")),!o)return;let n=u.join(i,"pinia-plugin-persistedstate");t.extendDepsPkg(Y.readJSONSync(u.join(n,"package.json"))),t.copy(u.join(n,"key.js"),u.join("src","stores","key.js"))};import q from"fs-extra";import v from"path";var _=(t,e)=>{let{useEslint:r,usePrettier:o}=e;if(!r)return;let i=v.join(a,"eslint"),n=q.readJSONSync(v.join(i,"package.json"));t.extendDevDepsPkg(n),t.extendScriptsPkg(n),t.render(v.join(i,"eslint.config.js.ejs"),"eslint.config.js",{usePrettier:o}),o&&t.extendDevDepsPkg(q.readJSONSync(v.join(i,"prettierPkg.json")))};import jt from"fs-extra";import O from"path";var K=(t,e)=>{let{usePrettier:r}=e;if(!r)return;let o=O.join(a,"prettier"),i=jt.readJSONSync(O.join(o,"package.json"));t.extendDevDepsPkg(i),t.extendScriptsPkg(i),t.copy(O.join(o,".prettierrc"),".prettierrc")};import St from"fs-extra";import S from"path";var Q=(t,e)=>{let{useVueRouter:r,usePiniaPluginPersistedstate:o}=e;if(!r)return;let i=S.join(a,"vue-router");t.extendDepsPkg(St.readJSONSync(S.join(i,"package.json"))),t.copy(S.join(i,"static"),"src"),t.render(S.join(i,"ejs","AboutView.vue.ejs"),S.join("src","views","AboutView.vue"),{usePiniaPluginPersistedstate:o})};import kt from"fs-extra";import k from"path";var W=(t,e)=>{let{useEslint:r,usePrettier:o,useHusky:i,useLintStaged:n}=e;if(!i)return;let s=k.join(a,"husky"),p=kt.readJSONSync(k.join(s,"static","package.json"));t.extendDevDepsPkg(p),t.extendScriptsPkg(p),t.copy(k.join(s,"static",".husky"),".husky"),t.render(k.join(s,"ejs","pre-commit.ejs"),k.join(".husky","pre-commit"),{useEslint:r,usePrettier:o,useLintStaged:n})};import $ from"fs-extra";import b from"path";var X=(t,e)=>{let{useEslint:r,usePrettier:o,useLintStaged:i}=e;if(!i)return;let n=b.join(a,"lintStaged"),s=$.readJSONSync(b.join(n,"package.json"));t.extendDevDepsPkg(s),t.extendScriptsPkg(s);let p={};r?p=$.readJSONSync(b.join(n,"eslint.json")):o&&(p=$.readJSONSync(b.join(n,"prettier.json"))),t.writePkg(p)};import Pt from"fs-extra";import Z from"path";var tt=(t,e)=>{let{useCommitizen:r}=e;if(!r)return;let o=Z.join(a,"commitizen"),i=Pt.readJSONSync(Z.join(o,"package.json"));t.extendScriptsPkg(i)};var et=async t=>{let e=await M();return H(t,e),U(t,e),_(t,e),K(t,e),Q(t,e),W(t,e),X(t,e),tt(t,e),e};import{execa as z}from"execa";import D from"chalk";var rt=async()=>{await c(`Do you want to ${D.yellow.bold("execute")} the above commands now?`)&&(await z({shell:!0,stdio:"inherit"})`${l}`,await c(`Do you want to ${D.yellow.bold("install the commitizen")} now?`)&&await z({shell:!0,stdio:"inherit"})`${w}`,await c(`Do you want to ${D.yellow.bold("execute the git")} commands now?`)&&await z({shell:!0,stdio:"inherit"})`${y}`,console.log(D.rgb(...j).bold(`
|
|
11
11
|
All commands executed successfully!
|
|
12
|
-
`)))};var ot=async()=>{await
|
|
12
|
+
`)))};import xt from"ora";var ot=async()=>{await B();let t=await L(),e=wt.join(process.cwd(),t);await J(t,e);let r=new g(e),o=await et(r),i=xt("Generating files...").start();await r.generate(),i.succeed("Files generated successfully."),x(`
|
|
13
13
|
Project initialization complete. You may execute the following commands:
|
|
14
14
|
`),I(t,o),x(`
|
|
15
15
|
To set up Commitizen, run the following command:
|
|
16
|
-
`),
|
|
16
|
+
`),F(t),x(`And initialize Git using the following commands:
|
|
17
17
|
`),R(t,o),await rt()};await ot();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-banana",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/TMname1/create-banana.git"
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"ejs": "^3.1.10",
|
|
35
35
|
"execa": "^9.6.1",
|
|
36
36
|
"figlet": "^1.9.4",
|
|
37
|
-
"fs-extra": "^11.3.3"
|
|
37
|
+
"fs-extra": "^11.3.3",
|
|
38
|
+
"ora": "^9.0.0"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@eslint/js": "^9.39.2",
|
package/readme.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# Currently implemented functions
|
|
2
2
|
|
|
3
|
-
- eslint
|
|
4
|
-
- prettier
|
|
5
|
-
- pinia
|
|
6
|
-
- pinia-plugin-persistedstate
|
|
7
|
-
- vue-router
|
|
8
|
-
- husky
|
|
9
|
-
- lint-staged
|
|
10
|
-
- commitizen
|
|
3
|
+
- [eslint](https://eslint.org/)
|
|
4
|
+
- [prettier](https://prettier.io/)
|
|
5
|
+
- [pinia](https://pinia.vuejs.org/)
|
|
6
|
+
- [pinia-plugin-persistedstate](https://prazdevs.github.io/pinia-plugin-persistedstate/)
|
|
7
|
+
- [vue-router](https://router.vuejs.org/)
|
|
8
|
+
- [husky](https://typicode.github.io/husky/)
|
|
9
|
+
- [lint-staged](https://github.com/lint-staged/lint-staged)
|
|
10
|
+
- [commitizen](https://github.com/commitizen/cz-cli)
|
|
11
11
|
|
|
12
12
|
# Project structure
|
|
13
13
|
|