create-banana 2.2.0 → 2.2.2
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 +10 -11
- package/dist/template/base/static/_gitignore +2 -0
- package/dist/template/husky/_/_gitignore +1 -0
- package/dist/template/husky/_/husky.sh +36 -0
- package/package.json +3 -2
- package/readme.md +8 -8
- /package/dist/template/husky/{static/package.json → package.json} +0 -0
- /package/dist/template/husky/{ejs/pre-commit.ejs → pre-commit.ejs} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import wt from"path";import G from"fs-extra";import{select as ot}from"@inquirer/prompts";import it from"chalk";import nt from"ora";var st=async(t,e)=>{try{if(G.pathExistsSync(e))if(!await ot({message:`The target folder "${t}" is existing. ${it.yellow("Overwrite")}?`,choices:[{name:"Yes",value:!0},{name:"No",value:!1}]}))console.log("canceled!"),process.exit(0);else{let o=nt("Overwriting existing folder...").start();await G.remove(e),await G.mkdir(e),o.succeed("Existing folder overwritten.")}}catch(r){console.error(r),process.exit(1)}},J=st;import d from"fs-extra";import y from"path";import at from"ejs";var h=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(()=>{d.copySync(e,y.join(this.targetDir,r))})}rename(e,r){this.fileMiddlewares.push(()=>{d.renameSync(y.join(this.targetDir,e),y.join(this.targetDir,r))})}render(e,r,o){this.fileMiddlewares.push(()=>{d.outputFileSync(y.join(this.targetDir,r),at.render(d.readFileSync(e,"utf-8"),o))})}async generate(){this.fileMiddlewares.forEach(e=>e()),d.writeFileSync(y.join(this.targetDir,"package.json"),JSON.stringify(this.pkg,null,2))}};import j from"chalk";import{input as mt,checkbox as ct}from"@inquirer/prompts";import{select as pt}from"@inquirer/prompts";var m=async t=>await pt({message:t,choices:[{name:"Yes",value:!0},{name:"No",value:!1}]});var L=async()=>await mt({message:`Enter your ${j.yellow("project name")}:`,required:!0}),M=async()=>{let t=await ct({message:`Please select the ${j.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 m(`Do you want to use ${j.yellow.bold("pinia-plugin-persistedstate")} for Pinia state persistence?`));let p=!1;(e||r)&&(p=await m(`Do you want to use ${j.yellow.bold("Husky")} for Git hooks?`));let A=!1;return p&&(A=await m(`Do you want to use ${j.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 ut from"figlet";var lt=async t=>{try{return await ut.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=lt;import gt from"chalk";function ft(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 dt(t){return t.split("").map((e,r)=>{let o=r/t.length*360,[i,n,s]=ft(o,100,50);return gt.rgb(i,n,s)(e)}).join("")}var T=dt;import f from"chalk";import C from"boxen";var k=console.log,P=[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,k(f.cyan(C(f.rgb(...P)(`
|
|
3
3
|
${l}
|
|
4
|
+
`),{title:"commands",titleAlignment:"center"})))},S,R=(t,{useHusky:e,useCommitizen:r})=>{S=e?`cd ${t} && git add .`:`cd ${t} && git init && git add .`,S+=` && ${r?"pnpm commit":'git commit -m "Initial commit"'}`,k(f.cyan(C(f.rgb(...P)(`
|
|
5
|
+
${S}
|
|
6
|
+
`),{title:"commands",titleAlignment:"center"})))},x,F=(t,{useCommitizen:e})=>{e&&(x=`cd ${t} && pnpm i -g commitizen && commitizen init cz-conventional-changelog --pnpm --save-dev --save-exact`,k(f.cyan(C(f.rgb(...P)(`
|
|
7
|
+
${x}
|
|
4
8
|
`),{title:"commands",titleAlignment:"center"})),`
|
|
5
|
-
`)},
|
|
6
|
-
${y}
|
|
7
|
-
`),{title:"commands",titleAlignment:"center"})))},w,B=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
|
-
${w}
|
|
9
|
-
`),{title:"commands",titleAlignment:"center"})),`
|
|
10
|
-
`)},F=async()=>{h(T(await E("BANANA")))},x=async t=>{h(T(t))};import V from"fs-extra";import{fileURLToPath as yt}from"url";var s=yt(new URL("../dist/template",import.meta.url));import m from"path";var H=(t,e)=>{let r=m.join(s,"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(s,"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(s,"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 ht from"fs-extra";import O from"path";var K=(t,e)=>{let{usePrettier:r}=e;if(!r)return;let o=O.join(s,"prettier"),i=ht.readJSONSync(O.join(o,"package.json"));t.extendDevDepsPkg(i),t.extendScriptsPkg(i),t.copy(O.join(o,".prettierrc"),".prettierrc")};import jt from"fs-extra";import S from"path";var Q=(t,e)=>{let{useVueRouter:r,usePiniaPluginPersistedstate:o}=e;if(!r)return;let i=S.join(s,"vue-router");t.extendDepsPkg(jt.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 St 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 a=k.join(s,"husky"),p=St.readJSONSync(k.join(a,"static","package.json"));t.extendDevDepsPkg(p),t.extendScriptsPkg(p),t.copy(k.join(a,"static",".husky"),".husky"),t.render(k.join(a,"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(s,"lintStaged"),a=$.readJSONSync(b.join(n,"package.json"));t.extendDevDepsPkg(a),t.extendScriptsPkg(a);let p={};r?p=$.readJSONSync(b.join(n,"eslint.json")):o&&(p=$.readJSONSync(b.join(n,"prettier.json"))),t.writePkg(p)};import kt from"fs-extra";import Z from"path";var tt=(t,e)=>{let{useCommitizen:r}=e;if(!r)return;let o=Z.join(s,"commitizen"),i=kt.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(`
|
|
9
|
+
`))},B=async()=>{k(T(await E("BANANA")))},v=async t=>{k(T(t))};import ht from"fs-extra";import{fileURLToPath as yt}from"url";var a=yt(new URL("../dist/template",import.meta.url));import g from"path";var V=(t,e)=>{let r=g.join(a,"base");t.writePkg(ht.readJSONSync(g.join(r,"static","package.json"))),t.copy(g.join(r,"static"),""),t.rename("_gitignore",".gitignore"),t.render(g.join(r,"ejs","App.vue.ejs"),g.join("src","App.vue"),{...e}),t.render(g.join(r,"ejs","main.js.ejs"),g.join("src","main.js"),{...e})};import _ from"fs-extra";import c from"path";var H=(t,e)=>{let{usePinia:r,usePiniaPluginPersistedstate:o}=e;if(!r)return;let i=c.join(a,"pinia");if(t.extendDepsPkg(_.readJSONSync(c.join(i,"package.json"))),t.copy(c.join(i,"counter.js"),c.join("src","stores","counter.js")),!o)return;let n=c.join(i,"pinia-plugin-persistedstate");t.extendDepsPkg(_.readJSONSync(c.join(n,"package.json"))),t.copy(c.join(n,"key.js"),c.join("src","stores","key.js"))};import Y from"fs-extra";import b from"path";var U=(t,e)=>{let{useEslint:r,usePrettier:o}=e;if(!r)return;let i=b.join(a,"eslint"),n=Y.readJSONSync(b.join(i,"package.json"));t.extendDevDepsPkg(n),t.extendScriptsPkg(n),t.render(b.join(i,"eslint.config.js.ejs"),"eslint.config.js",{usePrettier:o}),o&&t.extendDevDepsPkg(Y.readJSONSync(b.join(i,"prettierPkg.json")))};import jt from"fs-extra";import O from"path";var q=(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 w from"path";var K=(t,e)=>{let{useVueRouter:r,usePiniaPluginPersistedstate:o}=e;if(!r)return;let i=w.join(a,"vue-router");t.extendDepsPkg(St.readJSONSync(w.join(i,"package.json"))),t.copy(w.join(i,"static"),"src"),t.render(w.join(i,"ejs","AboutView.vue.ejs"),w.join("src","views","AboutView.vue"),{usePiniaPluginPersistedstate:o})};import kt from"fs-extra";import u from"path";var Q=(t,e)=>{let{useEslint:r,usePrettier:o,useHusky:i,useLintStaged:n}=e;if(!i)return;let s=u.join(a,"husky"),p=kt.readJSONSync(u.join(s,"package.json"));t.extendDevDepsPkg(p),t.extendScriptsPkg(p),t.copy(u.join(s,"_"),u.join(".husky","_")),t.rename(u.join(".husky","_gitignore"),u.join(".husky",".gitignore")),t.render(u.join(s,"pre-commit.ejs"),u.join(".husky","pre-commit"),{useEslint:r,usePrettier:o,useLintStaged:n})};import $ from"fs-extra";import D from"path";var W=(t,e)=>{let{useEslint:r,usePrettier:o,useLintStaged:i}=e;if(!i)return;let n=D.join(a,"lintStaged"),s=$.readJSONSync(D.join(n,"package.json"));t.extendDevDepsPkg(s),t.extendScriptsPkg(s);let p={};r?p=$.readJSONSync(D.join(n,"eslint.json")):o&&(p=$.readJSONSync(D.join(n,"prettier.json"))),t.writePkg(p)};import Pt from"fs-extra";import X from"path";var Z=(t,e)=>{let{useCommitizen:r}=e;if(!r)return;let o=X.join(a,"commitizen"),i=Pt.readJSONSync(X.join(o,"package.json"));t.extendScriptsPkg(i)};var tt=async t=>{let e=await M();return V(t,e),H(t,e),U(t,e),q(t,e),K(t,e),Q(t,e),W(t,e),Z(t,e),e};import{execa as z}from"execa";import N from"chalk";var et=async()=>{await m(`Do you want to ${N.yellow.bold("execute")} the above commands now?`)&&(await z({shell:!0,stdio:"inherit"})`${l}`,await m(`Do you want to ${N.yellow.bold("install the commitizen")} now?`)&&await z({shell:!0,stdio:"inherit"})`${x}`,await m(`Do you want to ${N.yellow.bold("execute the git")} commands now?`)&&await z({shell:!0,stdio:"inherit"})`${S}`,console.log(N.rgb(...P).bold(`
|
|
11
10
|
All commands executed successfully!
|
|
12
|
-
`)))};var
|
|
11
|
+
`)))};import xt from"ora";var rt=async()=>{await B();let t=await L(),e=wt.join(process.cwd(),t);await J(t,e);let r=new h(e),o=await tt(r),i=xt("Generating files...").start();await r.generate(),i.succeed("Files generated successfully."),v(`
|
|
13
12
|
Project initialization complete. You may execute the following commands:
|
|
14
|
-
`),I(t,o),
|
|
13
|
+
`),I(t,o),v(`
|
|
15
14
|
To set up Commitizen, run the following command:
|
|
16
|
-
`),
|
|
17
|
-
`),R(t,o),await
|
|
15
|
+
`),F(t,o),v(`And initialize Git using the following commands:
|
|
16
|
+
`),R(t,o),await et()};await rt();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
if [ -z "$husky_skip_init" ]; then
|
|
3
|
+
debug () {
|
|
4
|
+
if [ "$HUSKY_DEBUG" = "1" ]; then
|
|
5
|
+
echo "husky (debug) - $1"
|
|
6
|
+
fi
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
readonly hook_name="$(basename -- "$0")"
|
|
10
|
+
debug "starting $hook_name..."
|
|
11
|
+
|
|
12
|
+
if [ "$HUSKY" = "0" ]; then
|
|
13
|
+
debug "HUSKY env variable is set to 0, skipping hook"
|
|
14
|
+
exit 0
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
if [ -f ~/.huskyrc ]; then
|
|
18
|
+
debug "sourcing ~/.huskyrc"
|
|
19
|
+
. ~/.huskyrc
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
readonly husky_skip_init=1
|
|
23
|
+
export husky_skip_init
|
|
24
|
+
sh -e "$0" "$@"
|
|
25
|
+
exitCode="$?"
|
|
26
|
+
|
|
27
|
+
if [ $exitCode != 0 ]; then
|
|
28
|
+
echo "husky - $hook_name hook exited with code $exitCode (error)"
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
if [ $exitCode = 127 ]; then
|
|
32
|
+
echo "husky - command not found in PATH=$PATH"
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
exit $exitCode
|
|
36
|
+
fi
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-banana",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
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
|
|
|
File without changes
|
|
File without changes
|