@tomjs/create-app 0.0.8 → 0.0.10
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/README.md +3 -2
- package/README.zh_CN.md +3 -2
- package/dist/index.mjs +4 -4
- package/package.json +11 -14
- package/template-electron-react/README.md +6 -6
- package/template-electron-vue/README.md +6 -6
- package/template-node/README.md +3 -0
package/README.md
CHANGED
|
@@ -50,14 +50,15 @@ pnpm create @tomjs/app --template vue
|
|
|
50
50
|
|
|
51
51
|
Parameters:
|
|
52
52
|
|
|
53
|
-
- `-t --template` : specify the template
|
|
53
|
+
- `-t --template` : specify the template
|
|
54
54
|
|
|
55
55
|
Support templates:
|
|
56
56
|
|
|
57
57
|
- vue
|
|
58
|
-
- electron-vue
|
|
59
58
|
- react
|
|
59
|
+
- electron-vue
|
|
60
60
|
- electron-react
|
|
61
|
+
- node
|
|
61
62
|
|
|
62
63
|
## Reference project
|
|
63
64
|
|
package/README.zh_CN.md
CHANGED
|
@@ -51,14 +51,15 @@ pnpm create @tomjs/app my-app --template vue
|
|
|
51
51
|
|
|
52
52
|
参数说明:
|
|
53
53
|
|
|
54
|
-
- `-t --template
|
|
54
|
+
- `-t --template`:指定模板
|
|
55
55
|
|
|
56
56
|
支持模板:
|
|
57
57
|
|
|
58
58
|
- vue
|
|
59
|
-
- electron-vue
|
|
60
59
|
- react
|
|
60
|
+
- electron-vue
|
|
61
61
|
- electron-react
|
|
62
|
+
- node
|
|
62
63
|
|
|
63
64
|
## 参考项目
|
|
64
65
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
Scaffolding project in ${i}...`);let M
|
|
4
|
-
`);let
|
|
2
|
+
import l from"fs";import a from"path";import{fileURLToPath as K}from"url";import{blue as w,cyan as q,green as B,red as T,reset as p,yellow as $}from"kolorist";import G from"minimist";import H from"prompts";import s from"fs";import d from"path";function b(e){return[["t","template"]].forEach(([t,n])=>{e[n]=e[n]??e[t]}),e}function C(e){let t=s.readdirSync(e);return t.length===0||t.length===1&&t[0]===".git"}function y(e){return e?.trim().replace(/\/+$/g,"")}function J(e,t){s.mkdirSync(t,{recursive:!0});for(let n of s.readdirSync(e)){let m=d.resolve(e,n),g=d.resolve(t,n);v(m,g)}}function v(e,t){s.statSync(e).isDirectory()?J(e,t):s.copyFileSync(e,t)}function E(e){if(s.existsSync(e))for(let t of s.readdirSync(e))t!==".git"&&s.rmSync(d.resolve(e,t),{recursive:!0,force:!0})}function k(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function A(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function D(e){if(!e)return;let n=e.split(" ")[0].split("/");return{name:n[0],version:n[1]}}var S=b(G(process.argv.slice(2),{string:["_"]})),F=process.cwd(),V=[{name:"vue",display:"Vue",color:B,variants:[{name:"vue",display:"Web",color:w},{name:"electron-vue",display:"Electron",color:$}]},{name:"react",display:"React",color:q,variants:[{name:"react",display:"Web",color:w},{name:"electron-react",display:"Electron",color:$}]},{name:"node",display:"Node",color:w}],R=V.map(e=>e.variants&&e.variants.map(t=>t.name)||[e.name]).reduce((e,t)=>e.concat(t),[]),Q={_gitignore:".gitignore","_lintstagedrc.cjs":".lintstagedrc.cjs"},h="my-app";async function X(){let e=y(S._[0]),t=S.template||S.t,n=e||h,m=()=>n==="."?a.basename(a.resolve()):n,g={};g=await H([{type:e?null:"text",name:"projectName",message:p("Project name:"),initial:h,onState:r=>{n=y(r.value)||h}},{type:()=>!l.existsSync(n)||C(n)?null:"toggle",name:"overwrite",message:()=>(n==="."?"Current directory":`Target directory "${n}"`)+" is not empty. Remove existing files and continue?",initial:!1,active:"yes",inactive:"no"},{type:(r,{overwrite:o})=>{if(o===!1)throw console.log(T("\u2716")+" Operation cancelled"),new Error;return null},name:"overwriteChecker"},{type:()=>k(m())?null:"text",name:"packageName",message:p("Package name:"),initial:()=>A(m()),validate:r=>k(r)||"Invalid package.json name"},{type:t&&R.includes(t)?null:"select",name:"framework",message:typeof t=="string"&&!R.includes(t)?p(`"${t}" isn't a valid template. Please choose from below: `):p("Select a framework:"),initial:0,choices:V.map(r=>{let o=r.color;return{title:o(r.display||r.name),value:r}})},{type:r=>r&&r.variants?"select":null,name:"variant",message:p("Select a variant:"),choices:r=>r?.variants?.map(o=>{let c=o.color;return{title:c(o.display||o.name),value:o.name}})}],{onCancel:()=>{throw console.log(T("\u2716")+" Operation cancelled"),new Error}});let{framework:z,overwrite:O,packageName:L,variant:M}=g,i=a.join(F,n);O?E(i):l.existsSync(i)||l.mkdirSync(i,{recursive:!0}),console.log(`
|
|
3
|
+
Scaffolding project in ${i}...`);let j=M||z?.name||t||"",x=r=>a.join(K(import.meta.url),"../..",`template-${r}`),N=x(j),U=j.includes("node");[N,x("config")].forEach(r=>{let o=l.readdirSync(r);for(let c of o){let W=Q[c]??c;if(U&&c.includes("stylelint"))continue;let I=a.join(i,W);v(a.join(r,c),I)}});let P=JSON.parse(l.readFileSync(a.join(N,"package.json"),"utf-8"));P.name=L||m(),l.writeFileSync(a.join(i,"package.json"),JSON.stringify(P,null,2)+`
|
|
4
|
+
`);let _=D(process.env.npm_config_user_agent),u=_?_.name:"npm",f=a.relative(F,i);switch(console.log(`
|
|
5
5
|
Done. Now run:
|
|
6
|
-
`),i!==
|
|
6
|
+
`),i!==F&&console.log(` cd ${f.includes(" ")?`"${f}"`:f}`),u){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${u} install`),console.log(` ${u} run dev`);break}}X().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.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "create tomjs web app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tomjs",
|
|
@@ -32,17 +32,7 @@
|
|
|
32
32
|
"engines": {
|
|
33
33
|
"node": ">=18"
|
|
34
34
|
},
|
|
35
|
-
"scripts": {
|
|
36
|
-
"dev": "tsup --watch",
|
|
37
|
-
"build": "tsup --minify",
|
|
38
|
-
"lint": "run-s lint:eslint lint:prettier",
|
|
39
|
-
"lint:eslint": "eslint \"src/**/*.{js,cjs,ts}\" *.{js,cjs,ts} --fix --cache",
|
|
40
|
-
"lint:prettier": "prettier --write \"src/**/*.{js,cjs,ts,json,md}\" *.{js,cjs,ts,json,md}",
|
|
41
|
-
"prepare": "husky install",
|
|
42
|
-
"prepublishOnly": "npm run build && np --any-branch --no-yarn --yolo --no-publish --message \"chore: release v%s\""
|
|
43
|
-
},
|
|
44
35
|
"dependencies": {
|
|
45
|
-
"cross-spawn": "^7.0.3",
|
|
46
36
|
"kolorist": "^1.8.0",
|
|
47
37
|
"minimist": "^1.2.8",
|
|
48
38
|
"prompts": "^2.4.2"
|
|
@@ -54,7 +44,7 @@
|
|
|
54
44
|
"@tomjs/prettier": "^1.0.5",
|
|
55
45
|
"@tomjs/tsconfig": "^1.0.7",
|
|
56
46
|
"@types/minimist": "^1.2.5",
|
|
57
|
-
"@types/node": "^18.18.
|
|
47
|
+
"@types/node": "^18.18.11",
|
|
58
48
|
"@types/prompts": "^2.4.8",
|
|
59
49
|
"eslint": "^8.53.0",
|
|
60
50
|
"husky": "^8.0.3",
|
|
@@ -62,7 +52,14 @@
|
|
|
62
52
|
"np": "^8.0.4",
|
|
63
53
|
"npm-run-all": "^4.1.5",
|
|
64
54
|
"prettier": "^3.1.0",
|
|
65
|
-
"tsup": "^
|
|
55
|
+
"tsup": "^8.0.1",
|
|
66
56
|
"typescript": "^5.2.2"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"dev": "tsup --watch",
|
|
60
|
+
"build": "tsup --minify",
|
|
61
|
+
"lint": "run-s lint:eslint lint:prettier",
|
|
62
|
+
"lint:eslint": "eslint \"src/**/*.{js,cjs,ts}\" *.{js,cjs,ts} --fix --cache",
|
|
63
|
+
"lint:prettier": "prettier --write \"src/**/*.{js,cjs,ts,json,md}\" *.{js,cjs,ts,json,md}"
|
|
67
64
|
}
|
|
68
|
-
}
|
|
65
|
+
}
|
|
@@ -8,18 +8,18 @@ vite + electron + react
|
|
|
8
8
|
|
|
9
9
|
```
|
|
10
10
|
├── electron
|
|
11
|
-
│ ├── main
|
|
12
|
-
│ ├── payload
|
|
13
|
-
├── src
|
|
11
|
+
│ ├── main > Electron-Main
|
|
12
|
+
│ ├── payload > Preload-Scripts
|
|
13
|
+
├── src > Electron-Renderer
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
- output
|
|
17
17
|
|
|
18
18
|
```
|
|
19
19
|
├─┬ dist
|
|
20
|
-
│ ├── main.
|
|
21
|
-
│ ├── preload.
|
|
22
|
-
│ ├─┬ render
|
|
20
|
+
│ ├── main.mjs > Electron-Main
|
|
21
|
+
│ ├── preload.mjs > Preload-Scripts
|
|
22
|
+
│ ├─┬ render > Electron-Renderer
|
|
23
23
|
│ │ └── index.html
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -8,18 +8,18 @@ vite + electron + vue
|
|
|
8
8
|
|
|
9
9
|
```
|
|
10
10
|
├── electron
|
|
11
|
-
│ ├── main
|
|
12
|
-
│ ├── payload
|
|
13
|
-
├── src
|
|
11
|
+
│ ├── main > Electron-Main
|
|
12
|
+
│ ├── payload > Preload-Scripts
|
|
13
|
+
├── src > Electron-Renderer
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
- output
|
|
17
17
|
|
|
18
18
|
```
|
|
19
19
|
├─┬ dist
|
|
20
|
-
│ ├── main.
|
|
21
|
-
│ ├── preload.
|
|
22
|
-
│ ├─┬ render
|
|
20
|
+
│ ├── main.mjs > Electron-Main
|
|
21
|
+
│ ├── preload.mjs > Preload-Scripts
|
|
22
|
+
│ ├─┬ render > Electron-Renderer
|
|
23
23
|
│ │ └── index.html
|
|
24
24
|
```
|
|
25
25
|
|