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