@tomjs/create-app 0.2.1 → 0.2.3
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.mjs +5 -5
- package/package.json +3 -3
- package/template-config/.gitattributes +4 -0
- package/template-electron-react/package.json +4 -4
- package/template-electron-vue/package.json +3 -3
- package/template-node/package.json +4 -2
- package/template-node/tsconfig.json +3 -1
- package/template-node-electron/package.json +4 -2
- package/template-react/package.json +4 -4
- package/template-vue/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import a from"fs";import
|
|
3
|
-
Scaffolding project in ${
|
|
4
|
-
`),_&&["LICENSE","README.md","README.zh_CN.md"].forEach(n=>{let o=l.join(s,n);if(!C&&a.existsSync(o)){a.rmSync(o),n==="README.md"&&a.writeFileSync(o,`# ${m}
|
|
5
|
-
`,{encoding:"utf-8"});return}if(!a.existsSync(o))return;let i=a.readFileSync(o,"utf-8").replace(new RegExp(Q,"g"),m).replace(new RegExp("{{user.name}}","g"),g.name).replace(new RegExp("{{user.email}}","g"),g.email);if(n.startsWith("README")){let u=m.replace("@","%40"),y=m.replace("@","%40").replace(new RegExp("/","g"),"%2F");i=i.replace("{{badges}}",[``,``,``].join(" "))}a.writeFileSync(o,i)});let T=I(process.env.npm_config_user_agent),b=T?T.name:"npm";w.which("git")&&w.exec(`cd ${s} && git init`);let S=l.relative(R,s);switch(console.log(`
|
|
2
|
+
import a,{rmSync as te}from"fs";import ne from"os";import l from"path";import{fileURLToPath as re}from"url";import{blue as v,cyan as oe,green as ie,red as L,reset as d,yellow as N}from"kolorist";import{camelCase as se}from"lodash-es";import ae from"minimist";import ce from"prompts";import k from"shelljs";import p from"fs";import b from"path";function W(e){return[["t","template"]].forEach(([t,o])=>{e[o]=e[o]??e[t]}),e}function z(e){let t=p.readdirSync(e);return t.length===0||t.length===1&&t[0]===".git"}function j(e){return e?.trim().replace(/\/+$/g,"")}function ee(e,t){p.mkdirSync(t,{recursive:!0});for(let o of p.readdirSync(e)){let g=b.resolve(e,o),u=b.resolve(t,o);P(g,u)}}function P(e,t){p.statSync(e).isDirectory()?ee(e,t):p.copyFileSync(e,t)}function I(e){if(p.existsSync(e))for(let t of p.readdirSync(e))t!==".git"&&p.rmSync(b.resolve(e,t),{recursive:!0,force:!0})}function F(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function U(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function V(e){if(!e)return;let o=e.split(" ")[0].split("/");return{name:o[0],version:o[1]}}function R(e,t){let{variant:o,framework:g}=e,u=g;return u[t]||!!u?.variants?.find(y=>y.name===o&&y[t])}var $=W(ae(process.argv.slice(2),{string:["_"]})),D=process.cwd(),G=[{name:"vue",display:"Vue",color:ie,variants:[{name:"vue",display:"Web",color:v},{name:"electron-vue",display:"Electron",color:N}]},{name:"react",display:"React",color:oe,variants:[{name:"react",display:"Web",color:v},{name:"electron-react",display:"Electron",color:N}]},{name:"node",display:"Node",color:v,publish:!0,test:!0,variants:[{name:"node",display:"Base",color:v},{name:"node-electron",display:"Electron",color:N}]}],J=G.map(e=>e.variants&&e.variants.map(t=>t.name)||[e.name]).reduce((e,t)=>e.concat(t),[]),le={_gitignore:".gitignore","_lintstagedrc.cjs":".lintstagedrc.cjs"},A="my-app";function B(e){let t=k.exec(`git config --get ${e}`,{silent:!0});if(t.code===0)return t.stdout.trim()}async function me(){let e=j($._[0]),t=$.template||$.t,o=e||A,g=()=>o==="."?l.basename(l.resolve()):o,u={};u=await ce([{type:e?null:"text",name:"projectName",message:d("Project name:"),initial:A,onState:n=>{o=j(n.value)||A}},{type:()=>!a.existsSync(o)||z(o)?null:"toggle",name:"overwrite",message:()=>(o==="."?"Current directory":`Target directory "${o}"`)+" is not empty. Remove existing files and continue?",initial:!1,active:"yes",inactive:"no"},{type:(n,{overwrite:r})=>{if(r===!1)throw console.log(L("\u2716")+" Operation cancelled"),new Error;return null},name:"overwriteChecker"},{type:()=>F(g())?null:"text",name:"packageName",message:d("Package name:"),initial:()=>U(g()),validate:n=>F(n)||"Invalid package.json name"},{type:t&&J.includes(t)?null:"select",name:"framework",message:typeof t=="string"&&!J.includes(t)?d(`"${t}" isn't a valid template. Please choose from below: `):d("Select a framework:"),initial:0,choices:G.map(n=>{let r=n.color;return{title:r(n.display||n.name),value:n}})},{type:n=>n&&n.variants?"select":null,name:"variant",message:d("Select a variant:"),choices:n=>n?.variants?.map(r=>{let s=r.color;return{title:s(r.display||r.name),value:r.name}})},{type:(n,r)=>R(r,"publish")?"toggle":null,name:"needPublish",message:d("Whether to publish to the npm repository?"),initial:!0,active:"yes",inactive:"no"},{type:(n,r)=>R(r,"test")?"toggle":null,name:"needTest",message:d("Whether to add Test?"),initial:!0,active:"yes",inactive:"no"}],{onCancel:()=>{throw console.log(L("\u2716")+" Operation cancelled"),new Error}});let{framework:y,overwrite:K,packageName:q,variant:H,needPublish:T,needTest:Q}=u,c=l.join(D,o.substring(o.indexOf("/")+1));K?I(c):a.existsSync(c)||a.mkdirSync(c,{recursive:!0}),console.log(`
|
|
3
|
+
Scaffolding project in ${c}...`);let S=H||y?.name||t||"",_=n=>l.join(re(import.meta.url),"../..",`template-${n}`),C=_(S),O=S.includes("node");[C,_("config")].forEach(n=>{let r=a.readdirSync(n);for(let s of r){let h=le[s]??s;if(O&&s.includes("stylelint"))continue;let x=l.join(c,h);P(l.join(n,s),x)}});let X=`template-${S}`,i=JSON.parse(a.readFileSync(l.join(C,"package.json"),"utf-8")),m=q||g();i.name=m;let f={name:"UserName",email:"name@github.com"};Z(),O&&Y();let M=V(process.env.npm_config_user_agent),w=M?M.name:"npm";k.which("git")&&k.exec(`cd ${c} && git init`);let E=l.relative(D,c);switch(console.log(`
|
|
6
4
|
Done. Now run:
|
|
7
|
-
`),
|
|
5
|
+
`),c!==D&&console.log(` cd ${E.includes(" ")?`"${E}"`:E}`),w){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${w} install`),console.log(` ${w} run dev`);break}function Y(){["LICENSE","README.md","README.zh_CN.md"].forEach(n=>{let r=l.join(c,n);if(!T&&a.existsSync(r)){a.rmSync(r),n==="README.md"&&a.writeFileSync(r,`# ${m}
|
|
6
|
+
`,{encoding:"utf-8"});return}if(!a.existsSync(r))return;let s=a.readFileSync(r,"utf-8").replace(new RegExp(X,"g"),m).replace(new RegExp("{{user.name}}","g"),f.name).replace(new RegExp("{{user.email}}","g"),f.email);if(n.startsWith("README")){let h=m.replace("@","%40"),x=m.replace("@","%40").replace(new RegExp("/","g"),"%2F");s=s.replace("{{badges}}",[``,``,``].join(" "))}a.writeFileSync(r,s)})}function Z(){if(T){k.which("git")&&(f.name=B("user.name")||ne.userInfo().username,f.email=B("user.email")||"",i.author=Object.assign(i.author,f));let n=m.startsWith("@")?m.split("/")[0].substring(1):se(f.name);i.repository.url=`git+https://github.com/${n}/${m.substring(m.indexOf("/")+1)}.git`}else delete i.author,delete i.publishConfig,delete i.repository,delete i.scripts.prepublishOnly,delete i.devDependencies.np;if(!Q){delete i.scripts.test,["jest.config.js","test"].forEach(r=>{let s=l.join(c,r);a.existsSync(s)&&te(s,{force:!0,recursive:!0})});let n=Object.keys(i.devDependencies||{});Array.isArray(n)&&n.forEach(r=>{r.includes("jest")&&delete i.devDependencies[r]})}a.writeFileSync(l.join(c,"package.json"),JSON.stringify(i,null,2)+`
|
|
7
|
+
`)}}me().catch(e=>{e.message&&console.error(e)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomjs/create-app",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "create tomjs web app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tomjs",
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
"@tomjs/tsconfig": "^1.0.8",
|
|
58
58
|
"@types/lodash-es": "^4.17.12",
|
|
59
59
|
"@types/minimist": "^1.2.5",
|
|
60
|
-
"@types/node": "^18.19.
|
|
60
|
+
"@types/node": "^18.19.2",
|
|
61
61
|
"@types/prompts": "^2.4.9",
|
|
62
62
|
"@types/shelljs": "^0.8.15",
|
|
63
63
|
"eslint": "^8.55.0",
|
|
64
64
|
"husky": "^8.0.3",
|
|
65
|
-
"lint-staged": "^15.
|
|
65
|
+
"lint-staged": "^15.2.0",
|
|
66
66
|
"np": "^9.0.0",
|
|
67
67
|
"npm-run-all": "^4.1.5",
|
|
68
68
|
"prettier": "^3.1.0",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@tomjs/prettier": "^1.0.6",
|
|
34
34
|
"@tomjs/stylelint": "^1.0.7",
|
|
35
35
|
"@tomjs/tsconfig": "^1.0.8",
|
|
36
|
-
"@types/node": "^18.19.
|
|
37
|
-
"@types/react": "^18.2.
|
|
36
|
+
"@types/node": "^18.19.2",
|
|
37
|
+
"@types/react": "^18.2.41",
|
|
38
38
|
"@types/react-dom": "^18.2.17",
|
|
39
39
|
"@types/shelljs": "^0.8.15",
|
|
40
40
|
"@vitejs/plugin-react-swc": "^3.5.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"electron-builder": "^24.9.1",
|
|
43
43
|
"eslint": "^8.55.0",
|
|
44
44
|
"husky": "^8.0.3",
|
|
45
|
-
"lint-staged": "^15.
|
|
45
|
+
"lint-staged": "^15.2.0",
|
|
46
46
|
"npm-run-all": "^4.1.5",
|
|
47
47
|
"prettier": "^3.1.0",
|
|
48
48
|
"rimraf": "^5.0.5",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"tree-kill": "^1.2.2",
|
|
52
52
|
"tsx": "^4.6.2",
|
|
53
53
|
"typescript": "~5.2.2",
|
|
54
|
-
"vite": "^5.0.
|
|
54
|
+
"vite": "^5.0.5",
|
|
55
55
|
"vite-plugin-electron": "^0.15.4",
|
|
56
56
|
"vite-plugin-electron-renderer": "^0.14.5"
|
|
57
57
|
}
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"@tomjs/prettier": "^1.0.6",
|
|
32
32
|
"@tomjs/stylelint": "^1.0.7",
|
|
33
33
|
"@tomjs/tsconfig": "^1.0.8",
|
|
34
|
-
"@types/node": "^18.19.
|
|
34
|
+
"@types/node": "^18.19.2",
|
|
35
35
|
"@types/shelljs": "^0.8.15",
|
|
36
36
|
"@vitejs/plugin-vue": "^4.5.1",
|
|
37
37
|
"electron": "^27.1.3",
|
|
38
38
|
"electron-builder": "^24.9.1",
|
|
39
39
|
"eslint": "^8.55.0",
|
|
40
40
|
"husky": "^8.0.3",
|
|
41
|
-
"lint-staged": "^15.
|
|
41
|
+
"lint-staged": "^15.2.0",
|
|
42
42
|
"npm-run-all": "^4.1.5",
|
|
43
43
|
"prettier": "^3.1.0",
|
|
44
44
|
"rimraf": "^5.0.5",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"tree-kill": "^1.2.2",
|
|
48
48
|
"tsx": "^4.6.2",
|
|
49
49
|
"typescript": "~5.2.2",
|
|
50
|
-
"vite": "^5.0.
|
|
50
|
+
"vite": "^5.0.5",
|
|
51
51
|
"vite-plugin-electron": "^0.15.4",
|
|
52
52
|
"vite-plugin-electron-renderer": "^0.14.5",
|
|
53
53
|
"vue-tsc": "^1.8.24"
|
|
@@ -56,15 +56,17 @@
|
|
|
56
56
|
"@tomjs/prettier": "^1.0.6",
|
|
57
57
|
"@tomjs/tsconfig": "^1.0.8",
|
|
58
58
|
"@types/jest": "^29.5.10",
|
|
59
|
-
"@types/node": "^18.19.
|
|
59
|
+
"@types/node": "^18.19.2",
|
|
60
|
+
"@types/shelljs": "^0.8.15",
|
|
60
61
|
"eslint": "^8.55.0",
|
|
61
62
|
"husky": "^8.0.3",
|
|
62
63
|
"jest": "^29.7.0",
|
|
63
|
-
"lint-staged": "^15.
|
|
64
|
+
"lint-staged": "^15.2.0",
|
|
64
65
|
"np": "^9.0.0",
|
|
65
66
|
"npm-run-all": "^4.1.5",
|
|
66
67
|
"prettier": "^3.1.0",
|
|
67
68
|
"rimraf": "^5.0.5",
|
|
69
|
+
"shelljs": "^0.8.5",
|
|
68
70
|
"ts-jest": "^29.1.1",
|
|
69
71
|
"tsup": "^8.0.1",
|
|
70
72
|
"tsx": "^4.6.2",
|
|
@@ -57,16 +57,18 @@
|
|
|
57
57
|
"@tomjs/prettier": "^1.0.6",
|
|
58
58
|
"@tomjs/tsconfig": "^1.0.8",
|
|
59
59
|
"@types/jest": "^29.5.10",
|
|
60
|
-
"@types/node": "^18.19.
|
|
60
|
+
"@types/node": "^18.19.2",
|
|
61
|
+
"@types/shelljs": "^0.8.15",
|
|
61
62
|
"electron": "^27.1.3",
|
|
62
63
|
"eslint": "^8.55.0",
|
|
63
64
|
"husky": "^8.0.3",
|
|
64
65
|
"jest": "^29.7.0",
|
|
65
|
-
"lint-staged": "^15.
|
|
66
|
+
"lint-staged": "^15.2.0",
|
|
66
67
|
"np": "^9.0.0",
|
|
67
68
|
"npm-run-all": "^4.1.5",
|
|
68
69
|
"prettier": "^3.1.0",
|
|
69
70
|
"rimraf": "^5.0.5",
|
|
71
|
+
"shelljs": "^0.8.5",
|
|
70
72
|
"ts-jest": "^29.1.1",
|
|
71
73
|
"tsup": "^8.0.1",
|
|
72
74
|
"tsx": "^4.6.2",
|
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
"@tomjs/prettier": "^1.0.6",
|
|
28
28
|
"@tomjs/stylelint": "^1.0.7",
|
|
29
29
|
"@tomjs/tsconfig": "^1.0.8",
|
|
30
|
-
"@types/node": "^18.19.
|
|
31
|
-
"@types/react": "^18.2.
|
|
30
|
+
"@types/node": "^18.19.2",
|
|
31
|
+
"@types/react": "^18.2.41",
|
|
32
32
|
"@types/react-dom": "^18.2.17",
|
|
33
33
|
"@vitejs/plugin-react-swc": "^3.5.0",
|
|
34
34
|
"eslint": "^8.55.0",
|
|
35
35
|
"husky": "^8.0.3",
|
|
36
|
-
"lint-staged": "^15.
|
|
36
|
+
"lint-staged": "^15.2.0",
|
|
37
37
|
"npm-run-all": "^4.1.5",
|
|
38
38
|
"prettier": "^3.1.0",
|
|
39
39
|
"stylelint": "^15.11.0",
|
|
40
40
|
"typescript": "~5.2.2",
|
|
41
|
-
"vite": "^5.0.
|
|
41
|
+
"vite": "^5.0.5"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"@tomjs/prettier": "^1.0.6",
|
|
27
27
|
"@tomjs/stylelint": "^1.0.7",
|
|
28
28
|
"@tomjs/tsconfig": "^1.0.8",
|
|
29
|
-
"@types/node": "^18.19.
|
|
29
|
+
"@types/node": "^18.19.2",
|
|
30
30
|
"@vitejs/plugin-vue": "^4.5.1",
|
|
31
31
|
"eslint": "^8.55.0",
|
|
32
32
|
"husky": "^8.0.3",
|
|
33
|
-
"lint-staged": "^15.
|
|
33
|
+
"lint-staged": "^15.2.0",
|
|
34
34
|
"npm-run-all": "^4.1.5",
|
|
35
35
|
"prettier": "^3.1.0",
|
|
36
36
|
"stylelint": "^15.11.0",
|
|
37
37
|
"typescript": "~5.2.2",
|
|
38
|
-
"vite": "^5.0.
|
|
38
|
+
"vite": "^5.0.5",
|
|
39
39
|
"vue-tsc": "^1.8.24"
|
|
40
40
|
}
|
|
41
41
|
}
|