@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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ![npm](https://img.shields.io/npm/v/%40tomjs/create-app) ![NPM](https://img.shields.io/npm/l/%40tomjs%2Fcreate-app) ![npm package minimized gzipped size (scoped version select exports)](https://img.shields.io/bundlejs/size/%40tomjs/create-app)
4
4
 
5
- Create a web application based on the tomjs configuration, recommended `node>=18`
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 --module
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 --module
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 --module
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 + electron
58
+ - electron-vue
60
59
  - react
61
- - react + electron
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
  ![npm](https://img.shields.io/npm/v/%40tomjs/create-app) ![NPM](https://img.shields.io/npm/l/%40tomjs%2Fcreate-app) ![npm package minimized gzipped size (scoped version select exports)](https://img.shields.io/bundlejs/size/%40tomjs/create-app)
4
4
 
5
- 创建基于 tomjs 配置的 web 应用,推荐 `node>=18`
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 --module
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 --module
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 --module
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 K}from"url";import{blue as D,cyan as q,green as B,red as $,reset as l,yellow as V}from"kolorist";import G from"minimist";import H from"prompts";import s from"fs";import k from"path";function T(e){return[["t","template"],["m","module"]].forEach(([t,r])=>{e[r]=e[r]??e[t]}),e}function _(e){let t=s.readdirSync(e);return t.length===0||t.length===1&&t[0]===".git"}function S(e){return e?.trim().replace(/\/+$/g,"")}function J(e,t){s.mkdirSync(t,{recursive:!0});for(let r of s.readdirSync(e)){let m=k.resolve(e,r),u=k.resolve(t,r);w(m,u)}}function w(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(k.resolve(e,t),{recursive:!0,force:!0})}function j(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 C(e){if(!e)return;let r=e.split(" ")[0].split("/");return{name:r[0],version:r[1]}}var g=T(G(process.argv.slice(2),{string:["_"]})),F=process.cwd(),R=[{name:"vue",display:"Vue",color:B,variants:[{name:"vue",display:"Web",color:D},{name:"electron-vue",display:"Electron",color:V}]},{name:"react",display:"React",color:q,variants:[{name:"react",display:"Web",color:D},{name:"electron-react",display:"Electron",color:V}]}],M=R.map(e=>e.variants&&e.variants.map(t=>t.name)||[e.name]).reduce((e,t)=>e.concat(t),[]),Q={_gitignore:".gitignore","_lintstagedrc.js":".lintstagedrc.js"},h="my-app";async function X(){let e=S(g._[0]),t=g.template||g.t,r=e||h,m=()=>r==="."?a.basename(a.resolve()):r,u=await H([{type:e?null:"text",name:"projectName",message:l("Project name:"),initial:h,onState:n=>{r=S(n.value)||h}},{type:()=>!c.existsSync(r)||_(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 new Error($("\u2716")+" Operation cancelled");return null},name:"overwriteChecker"},{type:()=>j(m())?null:"text",name:"packageName",message:l("Package name:"),initial:()=>A(m()),validate:n=>j(n)||"Invalid package.json name"},{type:t&&M.includes(t)?null:"select",name:"framework",message:typeof t=="string"&&!M.includes(t)?l(`"${t}" isn't a valid template. Please choose from below: `):l("Select a framework:"),initial:0,choices:R.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:l("Select a variant:"),choices:n=>n.variants.map(o=>{let p=o.color;return{title:p(o.display||o.name),value:o.name}})},{type:()=>g.module!==void 0?null:"toggle",name:"isModuleType",message:l("Is it set to module type?"),initial:!1,active:"yes",inactive:"no"}],{onCancel:()=>{throw console.log($("\u2716")+" Operation cancelled"),new Error}}),{framework:z,overwrite:O,packageName:W,variant:I}=u,i=a.join(F,r);O?E(i):c.existsSync(i)||c.mkdirSync(i,{recursive:!0}),console.log(`
3
- Scaffolding project in ${i}...`);let L=I||z?.name||t,x=u.isModuleType??g.module,b=n=>a.join(K(import.meta.url),"../..",`template-${n}`),N=b(L);[N,b("config")].forEach(n=>{let o=c.readdirSync(n);for(let p of o){let f=Q[p]??p;x&&f.endsWith("rc.js")&&(f=f.replace(".js",".cjs"));let U=a.join(i,f);w(a.join(n,p),U)}});let d=JSON.parse(c.readFileSync(a.join(N,"package.json"),"utf-8"));d.name=W||m(),x?d.type="module":delete d.type,c.writeFileSync(a.join(i,"package.json"),JSON.stringify(d,null,2)+`
4
- `);let P=C(process.env.npm_config_user_agent),y=P?P.name:"npm",v=a.relative(F,i);switch(console.log(`
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!==F&&console.log(` cd ${v.includes(" ")?`"${v}"`:v}`),y){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${y} install`),console.log(` ${y} run dev`);break}}X().catch(()=>{});
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.6",
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.6",
46
+ "@tomjs/tsconfig": "^1.0.7",
47
47
  "@types/minimist": "^1.2.5",
48
- "@types/node": "^18.18.9",
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.2.0",
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.9",
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.4.1",
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": "^4.5.0",
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.9",
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": "^4.5.0",
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"
@@ -1,3 +1,7 @@
1
1
  # react
2
2
 
3
- react project
3
+ vite + react
4
+
5
+ ## Reference project
6
+
7
+ - [create-vite](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts)
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "template-react",
3
3
  "version": "0.0.0",
4
- "type": "commonjs",
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.6",
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.4.1",
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": "^4.5.0"
40
+ "vite": "^5.0.0"
40
41
  }
41
42
  }
@@ -1,18 +1,7 @@
1
- # Vue 3 + TypeScript + Vite
1
+ # vue
2
2
 
3
- This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
3
+ vite + vue
4
4
 
5
- ## Recommended IDE Setup
5
+ ## Reference project
6
6
 
7
- - [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
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
- "type": "commonjs",
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.6",
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": "^4.5.0",
37
+ "vite": "^5.0.0",
37
38
  "vue-tsc": "^1.8.22"
38
39
  }
39
40
  }
File without changes
File without changes