create-banana 2.0.4 → 2.1.0
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 +11 -13
- package/dist/template/base/static/_gitignore +36 -0
- package/dist/template/husky/ejs/pre-commit.ejs +10 -0
- package/dist/template/husky/static/package.json +8 -0
- package/dist/template/lintStaged/eslint.json +5 -0
- package/dist/template/lintStaged/package.json +8 -0
- package/dist/template/lintStaged/prettier.json +5 -0
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
`),
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`)}
|
|
10
|
-
|
|
11
|
-
`),
|
|
12
|
-
|
|
13
|
-
`),A(e,n),S(`Initialize Git using the following command:
|
|
14
|
-
`),G()};await I();
|
|
2
|
+
import dt from"path";import b from"fs-extra";import{select as Z}from"@inquirer/prompts";import tt from"chalk";var et=async(t,e)=>{try{b.pathExistsSync(e)&&(await Z({message:`The target folder "${t}" is existing. ${tt.yellow("Overwrite")}?`,choices:[{name:"Yes",value:!0},{name:"No",value:!1}]})?(await b.remove(e),await b.mkdir(e)):(console.log("canceled!"),process.exit(0)))}catch(r){console.error(r),process.exit(1)}},A=et;import h from"fs-extra";import v from"path";import rt 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(()=>{h.copySync(e,v.join(this.targetDir,r))})}render(e,r,o){this.fileMiddlewares.push(()=>{h.outputFileSync(v.join(this.targetDir,r),rt.render(h.readFileSync(e,"utf-8"),o))})}async generate(){this.fileMiddlewares.forEach(e=>e()),h.writeFileSync(v.join(this.targetDir,"package.json"),JSON.stringify(this.pkg,null,2))}};import f from"chalk";import{input as it,checkbox as nt}from"@inquirer/prompts";import{select as ot}from"@inquirer/prompts";var u=async t=>await ot({message:t,choices:[{name:"Yes",value:!0},{name:"No",value:!1}]});var J=async()=>await it({message:`Enter your ${f.yellow("project name")}:`,required:!0}),L=async()=>{let t=await nt({message:`Please select the ${f.yellow("features")} to include:`,choices:[{name:"Eslint",value:"eslint"},{name:"Prettier",value:"prettier"},{name:"Pinia",value:"pinia"},{name:"Vue-Router",value:"vue-router"}]}),e=t.includes("eslint"),r=t.includes("prettier"),o=t.includes("pinia"),i=t.includes("vue-router"),n=!1;o&&(n=await u(`Do you want to use ${f.yellow.bold("pinia-plugin-persistedstate")} for Pinia state persistence?`));let s=!1;(e||r)&&(s=await u(`Do you want to use ${f.yellow.bold("Husky")} for Git hooks?`));let p=!1;return s&&(p=await u(`Do you want to use ${f.yellow.bold("lint-staged")} to run linters on staged files?`)),{useEslint:e,usePrettier:r,usePinia:o,useVueRouter:i,usePiniaPluginPersistedstate:n,useHusky:s,useLintStaged:p}};import st from"figlet";var at=async t=>{try{return await st.text(t,{font:"Big Money-se",horizontalLayout:"default",verticalLayout:"default",width:80,whitespaceBreak:!0})}catch(e){console.log("Something went wrong..."),console.dir(e)}},$=at;import pt from"chalk";function ct(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 mt(t){return t.split("").map((e,r)=>{let o=r/t.length*360,[i,n,s]=ct(o,100,50);return pt.rgb(i,n,s)(e)}).join("")}var D=mt;import j from"chalk";import M from"boxen";var k=console.log,P=[22,198,12],l,C=(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(j.cyan(M(j.rgb(...P)(`
|
|
3
|
+
${l}
|
|
4
|
+
`),{title:"commands",titleAlignment:"center"})),`
|
|
5
|
+
`)},S,E=(t,{useHusky:e})=>{S=e?`cd ${t} && git add . && git commit -m "Initial commit"`:`cd ${t} && git init && git add . && git commit -m "Initial commit"`,k(j.cyan(M(j.rgb(...P)(`
|
|
6
|
+
${S}
|
|
7
|
+
`),{title:"commands",titleAlignment:"center"})))},I=async()=>{k(D(await $("BANANA")))},N=async t=>{k(D(t))};import R from"fs-extra";import{fileURLToPath as ut}from"url";var a=ut(new URL("../dist/template",import.meta.url));import c from"path";var B=(t,e)=>{let r=c.join(a,"base");t.writePkg(R.readJSONSync(c.join(r,"static","package.json"))),t.copy(c.join(r,"static"),""),t.fileMiddlewares.push(()=>{R.renameSync(c.join(t.targetDir,"_gitignore"),c.join(t.targetDir,".gitignore"))}),t.render(c.join(r,"ejs","App.vue.ejs"),c.join("src","App.vue"),{...e}),t.render(c.join(r,"ejs","main.js.ejs"),c.join("src","main.js"),{...e})};import F from"fs-extra";import m from"path";var V=(t,e)=>{let{usePinia:r,usePiniaPluginPersistedstate:o}=e;if(!r)return;let i=m.join(a,"pinia");if(t.extendDepsPkg(F.readJSONSync(m.join(i,"package.json"))),t.copy(m.join(i,"counter.js"),m.join("src","stores","counter.js")),!o)return;let n=m.join(i,"pinia-plugin-persistedstate");t.extendDepsPkg(F.readJSONSync(m.join(n,"package.json"))),t.copy(m.join(n,"key.js"),m.join("src","stores","key.js"))};import z from"fs-extra";import w from"path";var H=(t,e)=>{let{useEslint:r,usePrettier:o}=e;if(!r)return;let i=w.join(a,"eslint"),n=z.readJSONSync(w.join(i,"package.json"));t.extendDevDepsPkg(n),t.extendScriptsPkg(n),t.render(w.join(i,"eslint.config.js.ejs"),"eslint.config.js",{usePrettier:o}),o&&t.extendDevDepsPkg(z.readJSONSync(w.join(i,"prettierPkg.json")))};import lt from"fs-extra";import G from"path";var Y=(t,e)=>{let{usePrettier:r}=e;if(!r)return;let o=G.join(a,"prettier"),i=lt.readJSONSync(G.join(o,"package.json"));t.extendDevDepsPkg(i),t.extendScriptsPkg(i),t.copy(G.join(o,".prettierrc"),".prettierrc")};import gt from"fs-extra";import d from"path";var U=(t,e)=>{let{useVueRouter:r,usePiniaPluginPersistedstate:o}=e;if(!r)return;let i=d.join(a,"vue-router");t.extendDepsPkg(gt.readJSONSync(d.join(i,"package.json"))),t.copy(d.join(i,"static"),"src"),t.render(d.join(i,"ejs","AboutView.vue.ejs"),d.join("src","views","AboutView.vue"),{usePiniaPluginPersistedstate:o})};import ft from"fs-extra";import y from"path";var q=(t,e)=>{let{useEslint:r,usePrettier:o,useHusky:i,useLintStaged:n}=e;if(!i)return;let s=y.join(a,"husky"),p=ft.readJSONSync(y.join(s,"static","package.json"));t.extendDevDepsPkg(p),t.extendScriptsPkg(p),t.copy(y.join(s,"static",".husky"),".husky"),t.render(y.join(s,"ejs","pre-commit.ejs"),y.join(".husky","pre-commit"),{useEslint:r,usePrettier:o,useLintStaged:n})};import T from"fs-extra";import x from"path";var _=(t,e)=>{let{useEslint:r,usePrettier:o,useLintStaged:i}=e;if(!i)return;let n=x.join(a,"lintStaged"),s=T.readJSONSync(x.join(n,"package.json"));t.extendDevDepsPkg(s),t.extendScriptsPkg(s);let p={};r?p=T.readJSONSync(x.join(n,"eslint.json")):o&&(p=T.readJSONSync(x.join(n,"prettier.json"))),t.writePkg(p)};var K=async t=>{let e=await L();return B(t,e),V(t,e),H(t,e),Y(t,e),U(t,e),q(t,e),_(t,e),e};import{execa as Q}from"execa";import O from"chalk";var W=async()=>{await u(`Do you want to ${O.yellow.bold("execute")} the above commands now?`)&&(await Q({shell:!0,stdio:"inherit"})`${l}`,await u(`Do you want to ${O.yellow.bold("execute the git")} commands now?`)&&await Q({shell:!0,stdio:"inherit"})`${S}`,console.log(O.rgb(...P).bold(`
|
|
8
|
+
All commands executed successfully!
|
|
9
|
+
`)))};var X=async()=>{await I();let t=await J(),e=dt.join(process.cwd(),t);await A(t,e);let r=new g(e),o=await K(r);await r.generate(),N(`
|
|
10
|
+
Project initialization complete. You may execute the following commands:
|
|
11
|
+
`),C(t,o),N(`And initialize Git using the following commands:
|
|
12
|
+
`),E(t,o),await W()};await X();
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Logs
|
|
2
|
+
logs
|
|
3
|
+
*.log
|
|
4
|
+
npm-debug.log*
|
|
5
|
+
yarn-debug.log*
|
|
6
|
+
yarn-error.log*
|
|
7
|
+
pnpm-debug.log*
|
|
8
|
+
lerna-debug.log*
|
|
9
|
+
|
|
10
|
+
node_modules
|
|
11
|
+
.DS_Store
|
|
12
|
+
dist
|
|
13
|
+
dist-ssr
|
|
14
|
+
coverage
|
|
15
|
+
*.local
|
|
16
|
+
|
|
17
|
+
# Editor directories and files
|
|
18
|
+
.vscode/*
|
|
19
|
+
!.vscode/extensions.json
|
|
20
|
+
.idea
|
|
21
|
+
*.suo
|
|
22
|
+
*.ntvs*
|
|
23
|
+
*.njsproj
|
|
24
|
+
*.sln
|
|
25
|
+
*.sw?
|
|
26
|
+
|
|
27
|
+
*.tsbuildinfo
|
|
28
|
+
|
|
29
|
+
.eslintcache
|
|
30
|
+
|
|
31
|
+
# Cypress
|
|
32
|
+
/cypress/videos/
|
|
33
|
+
/cypress/screenshots/
|
|
34
|
+
|
|
35
|
+
# Vitest
|
|
36
|
+
__screenshots__/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-banana",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/TMname1/create-banana.git"
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"boxen": "^8.0.1",
|
|
33
33
|
"chalk": "^5.6.2",
|
|
34
34
|
"ejs": "^3.1.10",
|
|
35
|
+
"execa": "^9.6.1",
|
|
35
36
|
"figlet": "^1.9.4",
|
|
36
37
|
"fs-extra": "^11.3.3"
|
|
37
38
|
},
|
|
@@ -51,7 +52,8 @@
|
|
|
51
52
|
"husky": "^8.0.0",
|
|
52
53
|
"lint-staged": "^16.2.7",
|
|
53
54
|
"prettier": "3.7.4",
|
|
54
|
-
"typescript": "^5.9.3"
|
|
55
|
+
"typescript": "^5.9.3",
|
|
56
|
+
"typescript-eslint": "^8.53.0"
|
|
55
57
|
},
|
|
56
58
|
"config": {
|
|
57
59
|
"commitizen": {
|