@tomjs/create-app 0.0.6 → 0.0.7
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 +7 -7
- package/README.zh_CN.md +7 -30
- package/dist/index.mjs +4 -4
- package/package.json +4 -4
- package/template-electron-react/package.json +4 -3
- package/template-electron-vue/package.json +3 -2
- package/template-react/README.md +5 -1
- package/template-react/package.json +5 -4
- package/template-vue/README.md +4 -15
- package/template-vue/package.json +4 -3
- /package/template-config/{.commitlintrc.js → .commitlintrc.cjs} +0 -0
- /package/template-config/{.prettierrc.js → .prettierrc.cjs} +0 -0
- /package/template-config/{.stylelintrc.js → .stylelintrc.cjs} +0 -0
- /package/template-electron-react/{.eslintrc.js → .eslintrc.cjs} +0 -0
- /package/template-electron-react/{_lintstagedrc.js → _lintstagedrc.cjs} +0 -0
- /package/template-electron-vue/{.eslintrc.js → .eslintrc.cjs} +0 -0
- /package/template-electron-vue/{_lintstagedrc.js → _lintstagedrc.cjs} +0 -0
- /package/template-react/{.eslintrc.js → .eslintrc.cjs} +0 -0
- /package/template-react/{_lintstagedrc.js → _lintstagedrc.cjs} +0 -0
- /package/template-vue/{.eslintrc.js → .eslintrc.cjs} +0 -0
- /package/template-vue/{_lintstagedrc.js → _lintstagedrc.cjs} +0 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
  
|
|
4
4
|
|
|
5
|
-
Create a web application based on
|
|
5
|
+
Create a web application based on [vite](https://github.com/vitejs/vite) + [tomjs](https://github.com/tomgao365/tomjs), recommended `node>=18`
|
|
6
6
|
|
|
7
7
|
**English** | [中文](./README.zh_CN.md)
|
|
8
8
|
|
|
@@ -33,33 +33,33 @@ You can also directly specify the project name, template, and module type.
|
|
|
33
33
|
- Using `npm`
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
npm create @tomjs/app@latest my-app -- --template vue
|
|
36
|
+
npm create @tomjs/app@latest my-app -- --template vue
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
- Using `yarn`
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
yarn create @tomjs/app my-app --template vue
|
|
42
|
+
yarn create @tomjs/app my-app --template vue
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
- Using `pnpm`
|
|
46
46
|
|
|
47
47
|
```bash
|
|
48
|
-
pnpm create @tomjs/app --template vue
|
|
48
|
+
pnpm create @tomjs/app --template vue
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
Parameters:
|
|
52
52
|
|
|
53
53
|
- `-t --template` : specify the template, optional values: `vue` , `react`
|
|
54
|
-
- `-m --module` : `package.json` uses `type:"module"`, otherwise use `commonjs`
|
|
55
54
|
|
|
56
55
|
Support templates:
|
|
57
56
|
|
|
58
57
|
- vue
|
|
59
|
-
- vue
|
|
58
|
+
- electron-vue
|
|
60
59
|
- react
|
|
61
|
-
- react
|
|
60
|
+
- electron-react
|
|
62
61
|
|
|
63
62
|
## Reference project
|
|
64
63
|
|
|
65
64
|
- [create-vite](https://github.com/vitejs/vite/tree/main/packages/create-vite)
|
|
65
|
+
- [electron-vite-vue](https://github.com/electron-vite/electron-vite-vue)
|
package/README.zh_CN.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
  
|
|
4
4
|
|
|
5
|
-
创建基于 tomjs
|
|
5
|
+
创建基于 [vite](https://github.com/vitejs/vite) + [tomjs](https://github.com/tomgao365/tomjs) 的 web 应用,推荐 `node>=18`
|
|
6
6
|
|
|
7
7
|
[English](./README.md) | **中文**
|
|
8
8
|
|
|
@@ -34,56 +34,33 @@ pnpm create @tomjs/app
|
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
36
|
npm create @tomjs/app@latest
|
|
37
|
-
npm create @tomjs/app@latest my-app -- --template vue
|
|
37
|
+
npm create @tomjs/app@latest my-app -- --template vue
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
- 使用 `yarn`
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
yarn create @tomjs/app my-app --template vue
|
|
43
|
+
yarn create @tomjs/app my-app --template vue
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
- 使用 `pnpm`
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
pnpm create @tomjs/app my-app --template vue
|
|
49
|
+
pnpm create @tomjs/app my-app --template vue
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
参数说明:
|
|
53
53
|
|
|
54
54
|
- `-t --template`:指定模板,可选值:`vue`、`react`
|
|
55
|
-
- `-m --module`:`package.json` 使用 `type:"module"`,否则使用 `commonjs`
|
|
56
55
|
|
|
57
56
|
支持模板:
|
|
58
57
|
|
|
59
58
|
- vue
|
|
59
|
+
- electron-vue
|
|
60
60
|
- react
|
|
61
|
-
|
|
62
|
-
## 项目配置
|
|
63
|
-
|
|
64
|
-
项目配置在 `package.json` 中,可配置项如下:
|
|
65
|
-
|
|
66
|
-
````json
|
|
67
|
-
{
|
|
68
|
-
"name": "my-app",
|
|
69
|
-
"version": "0.0.1",
|
|
70
|
-
"description": "",
|
|
71
|
-
"main": "src/main.ts",
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
## 项目结构
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
.
|
|
78
|
-
├── README.md
|
|
79
|
-
├── package.json
|
|
80
|
-
├── src
|
|
81
|
-
│ ├── App.vue
|
|
82
|
-
│ ├── main.ts
|
|
83
|
-
│ └── shims-vue.d.ts
|
|
84
|
-
├── tsconfig.json
|
|
61
|
+
- electron-react
|
|
85
62
|
|
|
86
63
|
## 参考项目
|
|
87
64
|
|
|
88
65
|
- [create-vite](https://github.com/vitejs/vite/tree/main/packages/create-vite)
|
|
89
|
-
|
|
66
|
+
- [electron-vite-vue](https://github.com/electron-vite/electron-vite-vue)
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import c from"fs";import a from"path";import{fileURLToPath as
|
|
3
|
-
Scaffolding project in ${i}...`);let L
|
|
4
|
-
`);let
|
|
2
|
+
import c from"fs";import a from"path";import{fileURLToPath as J}from"url";import{blue as A,cyan as K,green as q,red as D,reset as p,yellow as T}from"kolorist";import B from"minimist";import G from"prompts";import s from"fs";import d from"path";function P(e){return[["t","template"]].forEach(([t,n])=>{e[n]=e[n]??e[t]}),e}function _(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 I(e,t){s.mkdirSync(t,{recursive:!0});for(let n of s.readdirSync(e)){let l=d.resolve(e,n),g=d.resolve(t,n);v(l,g)}}function v(e,t){s.statSync(e).isDirectory()?I(e,t):s.copyFileSync(e,t)}function b(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 C(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function E(e){if(!e)return;let n=e.split(" ")[0].split("/");return{name:n[0],version:n[1]}}var w=P(B(process.argv.slice(2),{string:["_"]})),S=process.cwd(),R=[{name:"vue",display:"Vue",color:q,variants:[{name:"vue",display:"Web",color:A},{name:"electron-vue",display:"Electron",color:T}]},{name:"react",display:"React",color:K,variants:[{name:"react",display:"Web",color:A},{name:"electron-react",display:"Electron",color:T}]}],$=R.map(e=>e.variants&&e.variants.map(t=>t.name)||[e.name]).reduce((e,t)=>e.concat(t),[]),H={_gitignore:".gitignore","_lintstagedrc.cjs":".lintstagedrc.cjs"},F="my-app";async function Q(){let e=y(w._[0]),t=w.template||w.t,n=e||F,l=()=>n==="."?a.basename(a.resolve()):n,g={};g=await G([{type:e?null:"text",name:"projectName",message:p("Project name:"),initial:F,onState:r=>{n=y(r.value)||F}},{type:()=>!c.existsSync(n)||_(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(D("\u2716")+" Operation cancelled"),new Error;return null},name:"overwriteChecker"},{type:()=>k(l())?null:"text",name:"packageName",message:p("Package name:"),initial:()=>C(l()),validate:r=>k(r)||"Invalid package.json name"},{type:t&&$.includes(t)?null:"select",name:"framework",message:typeof t=="string"&&!$.includes(t)?p(`"${t}" isn't a valid template. Please choose from below: `):p("Select a framework:"),initial:0,choices:R.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 m=o.color;return{title:m(o.display||o.name),value:o.name}})}],{onCancel:()=>{throw console.log(D("\u2716")+" Operation cancelled"),new Error}});let{framework:V,overwrite:z,packageName:O,variant:L}=g,i=a.join(S,n);z?b(i):c.existsSync(i)||c.mkdirSync(i,{recursive:!0}),console.log(`
|
|
3
|
+
Scaffolding project in ${i}...`);let M=L||V?.name||t||"",h=r=>a.join(J(import.meta.url),"../..",`template-${r}`),j=h(M);[j,h("config")].forEach(r=>{let o=c.readdirSync(r);for(let m of o){let U=H[m]??m,W=a.join(i,U);v(a.join(r,m),W)}});let x=JSON.parse(c.readFileSync(a.join(j,"package.json"),"utf-8"));x.name=O||l(),c.writeFileSync(a.join(i,"package.json"),JSON.stringify(x,null,2)+`
|
|
4
|
+
`);let N=E(process.env.npm_config_user_agent),u=N?N.name:"npm",f=a.relative(S,i);switch(console.log(`
|
|
5
5
|
Done. Now run:
|
|
6
|
-
`),i!==
|
|
6
|
+
`),i!==S&&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}}Q().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.7",
|
|
4
4
|
"description": "create tomjs web app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tomjs",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"@tomjs/commitlint": "^2.0.3",
|
|
44
44
|
"@tomjs/eslint": "^1.0.7",
|
|
45
45
|
"@tomjs/prettier": "^1.0.5",
|
|
46
|
-
"@tomjs/tsconfig": "^1.0.
|
|
46
|
+
"@tomjs/tsconfig": "^1.0.7",
|
|
47
47
|
"@types/minimist": "^1.2.5",
|
|
48
|
-
"@types/node": "^18.18.
|
|
48
|
+
"@types/node": "^18.18.10",
|
|
49
49
|
"@types/prompts": "^2.4.8",
|
|
50
50
|
"eslint": "^8.53.0",
|
|
51
51
|
"husky": "^8.0.3",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"np": "^8.0.4",
|
|
54
54
|
"npm-run-all": "^4.1.5",
|
|
55
55
|
"prettier": "^3.1.0",
|
|
56
|
-
"tsup": "^7.
|
|
56
|
+
"tsup": "^7.3.0",
|
|
57
57
|
"typescript": "^5.2.2"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"name": "electron-app",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"description": "vite + electron + vue",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"engines": {
|
|
6
7
|
"node": ">=18"
|
|
7
8
|
},
|
|
@@ -35,11 +36,11 @@
|
|
|
35
36
|
"@tomjs/prettier": "^1.0.5",
|
|
36
37
|
"@tomjs/stylelint": "^1.0.5",
|
|
37
38
|
"@tomjs/tsconfig": "^1.0.7",
|
|
38
|
-
"@types/node": "^18.18.
|
|
39
|
+
"@types/node": "^18.18.10",
|
|
39
40
|
"@types/react": "^18.2.37",
|
|
40
41
|
"@types/react-dom": "^18.2.15",
|
|
41
42
|
"@types/shelljs": "^0.8.15",
|
|
42
|
-
"@vitejs/plugin-react-swc": "^3.
|
|
43
|
+
"@vitejs/plugin-react-swc": "^3.5.0",
|
|
43
44
|
"electron": "^27.1.0",
|
|
44
45
|
"electron-builder": "^24.6.4",
|
|
45
46
|
"eslint": "^8.53.0",
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
"tree-kill": "^1.2.2",
|
|
54
55
|
"tsx": "^4.1.3",
|
|
55
56
|
"typescript": "^5.2.2",
|
|
56
|
-
"vite": "^
|
|
57
|
+
"vite": "^5.0.0",
|
|
57
58
|
"vite-plugin-electron": "^0.15.4",
|
|
58
59
|
"vite-plugin-electron-renderer": "^0.14.5",
|
|
59
60
|
"vue-tsc": "^1.8.22"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"name": "electron-app",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"description": "vite + electron + vue",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"engines": {
|
|
6
7
|
"node": ">=18"
|
|
7
8
|
},
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
"@tomjs/prettier": "^1.0.5",
|
|
35
36
|
"@tomjs/stylelint": "^1.0.5",
|
|
36
37
|
"@tomjs/tsconfig": "^1.0.7",
|
|
37
|
-
"@types/node": "^18.18.
|
|
38
|
+
"@types/node": "^18.18.10",
|
|
38
39
|
"@types/shelljs": "^0.8.15",
|
|
39
40
|
"@vitejs/plugin-vue": "^4.5.0",
|
|
40
41
|
"electron": "^27.1.0",
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
"tree-kill": "^1.2.2",
|
|
51
52
|
"tsx": "^4.1.3",
|
|
52
53
|
"typescript": "^5.2.2",
|
|
53
|
-
"vite": "^
|
|
54
|
+
"vite": "^5.0.0",
|
|
54
55
|
"vite-plugin-electron": "^0.15.4",
|
|
55
56
|
"vite-plugin-electron-renderer": "^0.14.5",
|
|
56
57
|
"vue-tsc": "^1.8.22"
|
package/template-react/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "template-react",
|
|
3
3
|
"version": "0.0.0",
|
|
4
|
-
"
|
|
4
|
+
"description": "vite + react",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"engines": {
|
|
6
7
|
"node": ">=18"
|
|
7
8
|
},
|
|
@@ -25,10 +26,10 @@
|
|
|
25
26
|
"@tomjs/eslint": "^1.0.7",
|
|
26
27
|
"@tomjs/prettier": "^1.0.5",
|
|
27
28
|
"@tomjs/stylelint": "^1.0.5",
|
|
28
|
-
"@tomjs/tsconfig": "^1.0.
|
|
29
|
+
"@tomjs/tsconfig": "^1.0.7",
|
|
29
30
|
"@types/react": "^18.2.37",
|
|
30
31
|
"@types/react-dom": "^18.2.15",
|
|
31
|
-
"@vitejs/plugin-react-swc": "^3.
|
|
32
|
+
"@vitejs/plugin-react-swc": "^3.5.0",
|
|
32
33
|
"eslint": "^8.53.0",
|
|
33
34
|
"husky": "^8.0.3",
|
|
34
35
|
"lint-staged": "^15.1.0",
|
|
@@ -36,6 +37,6 @@
|
|
|
36
37
|
"prettier": "^3.1.0",
|
|
37
38
|
"stylelint": "^15.11.0",
|
|
38
39
|
"typescript": "^5.2.2",
|
|
39
|
-
"vite": "^
|
|
40
|
+
"vite": "^5.0.0"
|
|
40
41
|
}
|
|
41
42
|
}
|
package/template-vue/README.md
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# vue
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
vite + vue
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Reference project
|
|
6
6
|
|
|
7
|
-
- [
|
|
8
|
-
|
|
9
|
-
## Type Support For `.vue` Imports in TS
|
|
10
|
-
|
|
11
|
-
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
|
|
12
|
-
|
|
13
|
-
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
|
|
14
|
-
|
|
15
|
-
1. Disable the built-in TypeScript Extension
|
|
16
|
-
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
|
|
17
|
-
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
|
|
18
|
-
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
|
|
7
|
+
- [create-vite](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-vue-ts)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "template-vue",
|
|
3
3
|
"version": "0.0.0",
|
|
4
|
-
"
|
|
4
|
+
"description": "vite + vue",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"engines": {
|
|
6
7
|
"node": ">=18"
|
|
7
8
|
},
|
|
@@ -24,7 +25,7 @@
|
|
|
24
25
|
"@tomjs/eslint": "^1.0.7",
|
|
25
26
|
"@tomjs/prettier": "^1.0.5",
|
|
26
27
|
"@tomjs/stylelint": "^1.0.5",
|
|
27
|
-
"@tomjs/tsconfig": "^1.0.
|
|
28
|
+
"@tomjs/tsconfig": "^1.0.7",
|
|
28
29
|
"@vitejs/plugin-vue": "^4.5.0",
|
|
29
30
|
"eslint": "^8.53.0",
|
|
30
31
|
"husky": "^8.0.3",
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"prettier": "^3.1.0",
|
|
34
35
|
"stylelint": "^15.11.0",
|
|
35
36
|
"typescript": "^5.2.2",
|
|
36
|
-
"vite": "^
|
|
37
|
+
"vite": "^5.0.0",
|
|
37
38
|
"vue-tsc": "^1.8.22"
|
|
38
39
|
}
|
|
39
40
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|