@tomjs/create-app 0.1.2 → 0.2.0

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
@@ -59,6 +59,7 @@ Support templates:
59
59
  - electron-vue
60
60
  - electron-react
61
61
  - node
62
+ - node-electron
62
63
 
63
64
  ## Reference project
64
65
 
package/README.zh_CN.md CHANGED
@@ -60,6 +60,7 @@ pnpm create @tomjs/app my-app --template vue
60
60
  - electron-vue
61
61
  - electron-react
62
62
  - node
63
+ - node-electron
63
64
 
64
65
  ## 参考项目
65
66
 
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import c from"fs";import X from"os";import s from"path";import{fileURLToPath as Y}from"url";import{blue as h,cyan as Z,green as ee,red as I,reset as d,yellow as j}from"kolorist";import te from"minimist";import ne from"prompts";import k from"shelljs";import m from"fs";import E from"path";function T(e){return[["t","template"]].forEach(([t,r])=>{e[r]=e[r]??e[t]}),e}function M(e){let t=m.readdirSync(e);return t.length===0||t.length===1&&t[0]===".git"}function N(e){return e?.trim().replace(/\/+$/g,"")}function Q(e,t){m.mkdirSync(t,{recursive:!0});for(let r of m.readdirSync(e)){let p=E.resolve(e,r),f=E.resolve(t,r);F(p,f)}}function F(e,t){m.statSync(e).isDirectory()?Q(e,t):m.copyFileSync(e,t)}function O(e){if(m.existsSync(e))for(let t of m.readdirSync(e))t!==".git"&&m.rmSync(E.resolve(e,t),{recursive:!0,force:!0})}function b(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function V(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function z(e){if(!e)return;let r=e.split(" ")[0].split("/");return{name:r[0],version:r[1]}}var $=T(te(process.argv.slice(2),{string:["_"]})),P=process.cwd(),L=[{name:"vue",display:"Vue",color:ee,variants:[{name:"vue",display:"Web",color:h},{name:"electron-vue",display:"Electron",color:j}]},{name:"react",display:"React",color:Z,variants:[{name:"react",display:"Web",color:h},{name:"electron-react",display:"Electron",color:j}]},{name:"node",display:"Node",color:h,variants:[{name:"node",display:"base",color:h},{name:"node-github",display:"Github + NPM",color:j}]}],W=L.map(e=>e.variants&&e.variants.map(t=>t.name)||[e.name]).reduce((e,t)=>e.concat(t),[]),re={_gitignore:".gitignore","_lintstagedrc.cjs":".lintstagedrc.cjs"},R="my-app";function G(e){let t=k.exec(`git config --get ${e}`,{silent:!0});if(t.code===0)return t.stdout.trim()}async function oe(){let e=N($._[0]),t=$.template||$.t,r=e||R,p=()=>r==="."?s.basename(s.resolve()):r,f={};f=await ne([{type:e?null:"text",name:"projectName",message:d("Project name:"),initial:R,onState:n=>{r=N(n.value)||R}},{type:()=>!c.existsSync(r)||M(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(I("\u2716")+" Operation cancelled"),new Error;return null},name:"overwriteChecker"},{type:()=>b(p())?null:"text",name:"packageName",message:d("Package name:"),initial:()=>V(p()),validate:n=>b(n)||"Invalid package.json name"},{type:t&&W.includes(t)?null:"select",name:"framework",message:typeof t=="string"&&!W.includes(t)?d(`"${t}" isn't a valid template. Please choose from below: `):d("Select a framework:"),initial:0,choices:L.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 a=o.color;return{title:a(o.display||o.name),value:o.name}})}],{onCancel:()=>{throw console.log(I("\u2716")+" Operation cancelled"),new Error}});let{framework:U,overwrite:J,packageName:H,variant:K}=f,i=s.join(P,r.substring(r.indexOf("/")+1));J?O(i):c.existsSync(i)||c.mkdirSync(i,{recursive:!0}),console.log(`
3
- Scaffolding project in ${i}...`);let y=K||U?.name||t||"",A=n=>s.join(Y(import.meta.url),"../..",`template-${n}`),C=A(y),q=y.includes("node");[C,A("config")].forEach(n=>{let o=c.readdirSync(n);for(let a of o){let v=re[a]??a;if(q&&a.includes("stylelint"))continue;let x=s.join(i,v);F(s.join(n,a),x)}});let D=y.includes("github"),B=`template-${y}`,u=JSON.parse(c.readFileSync(s.join(C,"package.json"),"utf-8")),l=H||p();u.name=l;let g={name:"Tom Gao",email:"tom@tomgao.cc"};if(D){k.which("git")&&(g.name=G("user.name")||X.userInfo().username,g.email=G("user.email")||"",u.author=Object.assign(u.author,g));let n=l.startsWith("@")?l.split("/")[0].substring(1):g.name;u.repository.url=`https://github.com/${n}/${l.substring(l.indexOf("/")+1)}.git`}c.writeFileSync(s.join(i,"package.json"),JSON.stringify(u,null,2)+`
4
- `),D&&["LICENSE","README.md","README.zh_CN.md"].forEach(n=>{let o=s.join(i,n);if(!c.existsSync(o))return;let a=c.readFileSync(o,"utf-8").replace(new RegExp(B,"g"),l).replace(new RegExp("{{user.name}}","g"),g.name).replace(new RegExp("{{user.email}}","g"),g.email);if(n.startsWith("README")){let v=l.replace("@","%40"),x=l.replace("@","%40").replace(new RegExp("/","g"),"%2F");a=a.replace("{{badges}}",[`![npm](https://img.shields.io/npm/v/${v})`,`![node-current (scoped)](https://img.shields.io/node/v/${v})`,`![NPM](https://img.shields.io/npm/l/${x})`].join(" "))}c.writeFileSync(o,a)});let _=z(process.env.npm_config_user_agent),w=_?_.name:"npm";k.which("git")&&k.exec(`cd ${i} && git init`);let S=s.relative(P,i);switch(console.log(`
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(),G=[{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=G.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:G.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:K,overwrite:q,packageName:B,variant:H,publish:C}=h,s=l.join(R,r.substring(r.indexOf("/")+1));q?z(s):a.existsSync(s)||a.mkdirSync(s,{recursive:!0}),console.log(`
3
+ Scaffolding project in ${s}...`);let k=H||K?.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=B||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=`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
+ `),_&&["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}}",[`![npm](https://img.shields.io/npm/v/${u})`,`![node-current (scoped)](https://img.shields.io/node/v/${u})`,`![NPM](https://img.shields.io/npm/l/${y})`].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(`
5
6
  Done. Now run:
6
- `),i!==P&&console.log(` cd ${S.includes(" ")?`"${S}"`:S}`),w){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${w} install`),console.log(` ${w} run dev`);break}}oe().catch(e=>{e.message&&console.error(e)});
7
+ `),s!==R&&console.log(` cd ${S.includes(" ")?`"${S}"`:S}`),b){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${b} install`),console.log(` ${b} run dev`);break}}se().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.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "create tomjs web app",
5
5
  "keywords": [
6
6
  "tomjs",
@@ -44,18 +44,20 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "kolorist": "^1.8.0",
47
+ "lodash-es": "^4.17.21",
47
48
  "minimist": "^1.2.8",
48
49
  "prompts": "^2.4.2",
49
50
  "shelljs": "^0.8.5"
50
51
  },
51
52
  "devDependencies": {
52
53
  "@commitlint/cli": "^18.4.3",
53
- "@tomjs/commitlint": "^2.0.3",
54
- "@tomjs/eslint": "^1.0.8",
55
- "@tomjs/prettier": "^1.0.5",
56
- "@tomjs/tsconfig": "^1.0.7",
54
+ "@tomjs/commitlint": "^2.0.5",
55
+ "@tomjs/eslint": "^1.1.0",
56
+ "@tomjs/prettier": "^1.0.6",
57
+ "@tomjs/tsconfig": "^1.0.8",
58
+ "@types/lodash-es": "^4.17.12",
57
59
  "@types/minimist": "^1.2.5",
58
- "@types/node": "^18.18.13",
60
+ "@types/node": "^18.19.0",
59
61
  "@types/prompts": "^2.4.9",
60
62
  "@types/shelljs": "^0.8.15",
61
63
  "eslint": "^8.54.0",
@@ -28,17 +28,17 @@
28
28
  },
29
29
  "devDependencies": {
30
30
  "@commitlint/cli": "^18.4.3",
31
- "@tomjs/commitlint": "^2.0.3",
32
- "@tomjs/eslint": "^1.0.8",
33
- "@tomjs/prettier": "^1.0.5",
31
+ "@tomjs/commitlint": "^2.0.5",
32
+ "@tomjs/eslint": "^1.1.0",
33
+ "@tomjs/prettier": "^1.0.6",
34
34
  "@tomjs/stylelint": "^1.0.5",
35
- "@tomjs/tsconfig": "^1.0.7",
36
- "@types/node": "^18.18.13",
35
+ "@tomjs/tsconfig": "^1.0.8",
36
+ "@types/node": "^18.19.0",
37
37
  "@types/react": "^18.2.37",
38
38
  "@types/react-dom": "^18.2.15",
39
39
  "@types/shelljs": "^0.8.15",
40
40
  "@vitejs/plugin-react-swc": "^3.5.0",
41
- "electron": "^27.1.2",
41
+ "electron": "^27.1.3",
42
42
  "electron-builder": "^24.6.4",
43
43
  "eslint": "^8.54.0",
44
44
  "husky": "^8.0.3",
@@ -49,7 +49,7 @@
49
49
  "shelljs": "^0.8.5",
50
50
  "stylelint": "^15.11.0",
51
51
  "tree-kill": "^1.2.2",
52
- "tsx": "^4.6.0",
52
+ "tsx": "^4.6.1",
53
53
  "typescript": "~5.2.2",
54
54
  "vite": "^5.0.2",
55
55
  "vite-plugin-electron": "^0.15.4",
@@ -26,15 +26,15 @@
26
26
  },
27
27
  "devDependencies": {
28
28
  "@commitlint/cli": "^18.4.3",
29
- "@tomjs/commitlint": "^2.0.3",
30
- "@tomjs/eslint": "^1.0.8",
31
- "@tomjs/prettier": "^1.0.5",
29
+ "@tomjs/commitlint": "^2.0.5",
30
+ "@tomjs/eslint": "^1.1.0",
31
+ "@tomjs/prettier": "^1.0.6",
32
32
  "@tomjs/stylelint": "^1.0.5",
33
- "@tomjs/tsconfig": "^1.0.7",
34
- "@types/node": "^18.18.13",
33
+ "@tomjs/tsconfig": "^1.0.8",
34
+ "@types/node": "^18.19.0",
35
35
  "@types/shelljs": "^0.8.15",
36
36
  "@vitejs/plugin-vue": "^4.5.0",
37
- "electron": "^27.1.2",
37
+ "electron": "^27.1.3",
38
38
  "electron-builder": "^24.6.4",
39
39
  "eslint": "^8.54.0",
40
40
  "husky": "^8.0.3",
@@ -45,7 +45,7 @@
45
45
  "shelljs": "^0.8.5",
46
46
  "stylelint": "^15.11.0",
47
47
  "tree-kill": "^1.2.2",
48
- "tsx": "^4.6.0",
48
+ "tsx": "^4.6.1",
49
49
  "typescript": "~5.2.2",
50
50
  "vite": "^5.0.2",
51
51
  "vite-plugin-electron": "^0.15.4",
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-PRESENT {{user.name}}<{{user.email}}>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,3 +1,27 @@
1
- # node
1
+ # template-node
2
2
 
3
- Basic node template
3
+ {{badges}}
4
+
5
+ > Basic node template
6
+
7
+ **English** | [中文](./README.zh_CN.md)
8
+
9
+ ## Install
10
+
11
+ With `pnpm`
12
+
13
+ ```bash
14
+ pnpm add template-node
15
+ ```
16
+
17
+ With `yarn`
18
+
19
+ ```bash
20
+ yarn add template-node
21
+ ```
22
+
23
+ With `npm`
24
+
25
+ ```bash
26
+ npm i template-node
27
+ ```
@@ -1,5 +1,27 @@
1
- # node
1
+ # template-node
2
2
 
3
- 基础 node 模板
3
+ {{badges}}
4
+
5
+ > 基础 node 模板
4
6
 
5
7
  [English](./README.md) | **中文**
8
+
9
+ ## 安装
10
+
11
+ 使用 `pnpm`
12
+
13
+ ```bash
14
+ pnpm add template-node
15
+ ```
16
+
17
+ 使用 `yarn`
18
+
19
+ ```bash
20
+ yarn add template-node
21
+ ```
22
+
23
+ 使用 `npm`
24
+
25
+ ```bash
26
+ npm i template-node
27
+ ```
@@ -0,0 +1,7 @@
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ preset: 'ts-jest',
4
+ testEnvironment: 'node',
5
+ testTimeout: 10000,
6
+ testMatch: ['<rootDir>/test/**/*.test.ts'],
7
+ };
@@ -3,16 +3,27 @@
3
3
  "version": "0.0.0",
4
4
  "description": "basic node.js template",
5
5
  "keywords": [
6
- "tomjs",
7
- "node",
8
- "backend"
6
+ "node"
9
7
  ],
8
+ "author": {
9
+ "name": "name",
10
+ "email": "name@github.com"
11
+ },
12
+ "license": "MIT",
10
13
  "engines": {
11
14
  "node": ">=16"
12
15
  },
13
16
  "files": [
14
17
  "dist"
15
18
  ],
19
+ "publishConfig": {
20
+ "access": "public",
21
+ "registry": "https://registry.npmjs.org/"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/xxx/template-node.git"
26
+ },
16
27
  "main": "./dist/index.js",
17
28
  "module": "./dist/index.mjs",
18
29
  "types": "./dist/index.d.ts",
@@ -27,29 +38,36 @@
27
38
  "dev": "tsup --watch",
28
39
  "start": "tsx ./src/index.ts",
29
40
  "build": "tsup",
41
+ "test": "jest",
30
42
  "lint": "run-s lint:eslint lint:prettier",
31
- "lint:eslint": "eslint \"src/**/*.ts\" *.{js,cjs,ts} --fix --cache",
43
+ "lint:eslint": "eslint \"{src,test}/**/*.ts\" *.{js,cjs,ts} --fix --cache",
32
44
  "lint:prettier": "prettier --write .",
33
- "prepare": "husky install"
45
+ "prepare": "husky install",
46
+ "prepublishOnly": "npm run build && np --any-branch --no-yarn --yolo --no-publish --message \"chore: release v%s\""
34
47
  },
35
48
  "dependencies": {
36
49
  "kolorist": "^1.8.0"
37
50
  },
38
51
  "devDependencies": {
39
52
  "@commitlint/cli": "^18.4.3",
40
- "@tomjs/commitlint": "^2.0.3",
41
- "@tomjs/eslint": "^1.0.8",
42
- "@tomjs/prettier": "^1.0.5",
43
- "@tomjs/tsconfig": "^1.0.7",
44
- "@types/node": "^18.18.13",
53
+ "@jest/globals": "^29.7.0",
54
+ "@tomjs/commitlint": "^2.0.5",
55
+ "@tomjs/eslint": "^1.1.0",
56
+ "@tomjs/prettier": "^1.0.6",
57
+ "@tomjs/tsconfig": "^1.0.8",
58
+ "@types/jest": "^29.5.10",
59
+ "@types/node": "^18.19.0",
45
60
  "eslint": "^8.54.0",
46
61
  "husky": "^8.0.3",
62
+ "jest": "^29.7.0",
47
63
  "lint-staged": "^15.1.0",
64
+ "np": "^9.0.0",
48
65
  "npm-run-all": "^4.1.5",
49
66
  "prettier": "^3.1.0",
50
67
  "rimraf": "^5.0.5",
68
+ "ts-jest": "^29.1.1",
51
69
  "tsup": "^8.0.1",
52
- "tsx": "^4.6.0",
70
+ "tsx": "^4.6.1",
53
71
  "typescript": "~5.2.2"
54
72
  }
55
73
  }
@@ -0,0 +1,5 @@
1
+ describe('simple', () => {
2
+ it('should work', () => {
3
+ expect(1).toBe(1);
4
+ });
5
+ })
@@ -6,6 +6,5 @@ export default defineConfig({
6
6
  target: ['es2021', 'node16'],
7
7
  clean: true,
8
8
  dts: true,
9
- sourcemap: false,
10
9
  splitting: true,
11
10
  });
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) {{user.name}}<{{user.email}}>
3
+ Copyright (c) 2023-PRESENT {{user.name}}<{{user.email}}>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,8 +1,8 @@
1
- # template-node-github
1
+ # template-node-electron
2
2
 
3
3
  {{badges}}
4
4
 
5
- > Basic node template
5
+ > Basic Electron template
6
6
 
7
7
  **English** | [中文](./README.zh_CN.md)
8
8
 
@@ -11,17 +11,17 @@
11
11
  With `pnpm`
12
12
 
13
13
  ```bash
14
- pnpm add template-node-github
14
+ pnpm add template-node-electron
15
15
  ```
16
16
 
17
17
  With `yarn`
18
18
 
19
19
  ```bash
20
- yarn add template-node-github
20
+ yarn add template-node-electron
21
21
  ```
22
22
 
23
23
  With `npm`
24
24
 
25
25
  ```bash
26
- npm i template-node-github
26
+ npm i template-node-electron
27
27
  ```
@@ -0,0 +1,27 @@
1
+ # template-node-electron
2
+
3
+ {{badges}}
4
+
5
+ > 基础 Electron 模板
6
+
7
+ [English](./README.md) | **中文**
8
+
9
+ ## 安装
10
+
11
+ 使用 `pnpm`
12
+
13
+ ```bash
14
+ pnpm add template-node-electron
15
+ ```
16
+
17
+ 使用 `yarn`
18
+
19
+ ```bash
20
+ yarn add template-node-electron
21
+ ```
22
+
23
+ 使用 `npm`
24
+
25
+ ```bash
26
+ npm i template-node-electron
27
+ ```
@@ -0,0 +1,8 @@
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ preset: 'ts-jest',
4
+ runner: '@kayahr/jest-electron-runner/main',
5
+ testEnvironment: 'node',
6
+ testTimeout: 10000,
7
+ testMatch: ['<rootDir>/test/**/*.test.ts'],
8
+ };
@@ -1,12 +1,9 @@
1
1
  {
2
- "name": "template-node-github",
2
+ "name": "template-node-electron",
3
3
  "version": "0.0.0",
4
- "description": "basic node.js template",
4
+ "description": "Basic Electron template",
5
5
  "keywords": [
6
- "tomjs",
7
- "node",
8
- "back-end",
9
- "backend"
6
+ "electron"
10
7
  ],
11
8
  "author": {
12
9
  "name": "name",
@@ -25,7 +22,7 @@
25
22
  },
26
23
  "repository": {
27
24
  "type": "git",
28
- "url": "git+https://github.com/xxx/template-node-github.git"
25
+ "url": "git+https://github.com/xxx/template-node-electron.git"
29
26
  },
30
27
  "main": "./dist/index.js",
31
28
  "module": "./dist/index.mjs",
@@ -41,8 +38,9 @@
41
38
  "dev": "tsup --watch",
42
39
  "start": "tsx ./src/index.ts",
43
40
  "build": "tsup",
41
+ "test": "jest",
44
42
  "lint": "run-s lint:eslint lint:prettier",
45
- "lint:eslint": "eslint \"src/**/*.ts\" *.{js,cjs,ts} --fix --cache",
43
+ "lint:eslint": "eslint \"{src,test}/**/*.ts\" *.{js,cjs,ts} --fix --cache",
46
44
  "lint:prettier": "prettier --write .",
47
45
  "prepare": "husky install",
48
46
  "prepublishOnly": "npm run build && np --any-branch --no-yarn --yolo --no-publish --message \"chore: release v%s\""
@@ -52,20 +50,26 @@
52
50
  },
53
51
  "devDependencies": {
54
52
  "@commitlint/cli": "^18.4.3",
55
- "@tomjs/commitlint": "^2.0.3",
56
- "@tomjs/eslint": "^1.0.8",
57
- "@tomjs/prettier": "^1.0.5",
58
- "@tomjs/tsconfig": "^1.0.7",
59
- "@types/node": "^18.18.13",
53
+ "@jest/globals": "^29.7.0",
54
+ "@kayahr/jest-electron-runner": "^29.10.0",
55
+ "@tomjs/commitlint": "^2.0.5",
56
+ "@tomjs/eslint": "^1.1.0",
57
+ "@tomjs/prettier": "^1.0.6",
58
+ "@tomjs/tsconfig": "^1.0.8",
59
+ "@types/jest": "^29.5.10",
60
+ "@types/node": "^18.19.0",
61
+ "electron": "^27.1.3",
60
62
  "eslint": "^8.54.0",
61
63
  "husky": "^8.0.3",
64
+ "jest": "^29.7.0",
62
65
  "lint-staged": "^15.1.0",
63
66
  "np": "^9.0.0",
64
67
  "npm-run-all": "^4.1.5",
65
68
  "prettier": "^3.1.0",
66
69
  "rimraf": "^5.0.5",
70
+ "ts-jest": "^29.1.1",
67
71
  "tsup": "^8.0.1",
68
- "tsx": "^4.6.0",
72
+ "tsx": "^4.6.1",
69
73
  "typescript": "~5.2.2"
70
74
  }
71
75
  }
@@ -0,0 +1,10 @@
1
+ import { app } from 'electron';
2
+
3
+ describe('simple', () => {
4
+ it('should work', () => {
5
+ return app.whenReady().then(() => {
6
+ // some code
7
+ expect(app.getVersion()).not.toBe(undefined);
8
+ });
9
+ });
10
+ });
@@ -2,6 +2,8 @@
2
2
  "extends": "@tomjs/tsconfig/node.json",
3
3
  "include": [
4
4
  "src/**/*.ts",
5
- "src/**/*.d.ts"
5
+ "src/**/*.d.ts",
6
+ "test/**/*.ts",
7
+ "test/**/*.d.ts"
6
8
  ],
7
9
  }
@@ -1,11 +1,12 @@
1
1
  import { defineConfig } from 'tsup';
2
+ import pkg from './package.json';
2
3
 
3
4
  export default defineConfig({
4
5
  entry: ['src/index.ts'],
5
6
  format: ['esm', 'cjs'],
6
7
  target: ['es2021', 'node16'],
8
+ external: ['electron'].concat(Object.keys(pkg.dependencies)),
7
9
  clean: true,
8
10
  dts: true,
9
- sourcemap: false,
10
11
  splitting: true,
11
12
  });
@@ -22,12 +22,12 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@commitlint/cli": "^18.4.3",
25
- "@tomjs/commitlint": "^2.0.3",
26
- "@tomjs/eslint": "^1.0.8",
27
- "@tomjs/prettier": "^1.0.5",
25
+ "@tomjs/commitlint": "^2.0.5",
26
+ "@tomjs/eslint": "^1.1.0",
27
+ "@tomjs/prettier": "^1.0.6",
28
28
  "@tomjs/stylelint": "^1.0.5",
29
- "@tomjs/tsconfig": "^1.0.7",
30
- "@types/node": "^18.18.13",
29
+ "@tomjs/tsconfig": "^1.0.8",
30
+ "@types/node": "^18.19.0",
31
31
  "@types/react": "^18.2.37",
32
32
  "@types/react-dom": "^18.2.15",
33
33
  "@vitejs/plugin-react-swc": "^3.5.0",
@@ -21,12 +21,12 @@
21
21
  },
22
22
  "devDependencies": {
23
23
  "@commitlint/cli": "^18.4.3",
24
- "@tomjs/commitlint": "^2.0.3",
25
- "@tomjs/eslint": "^1.0.8",
26
- "@tomjs/prettier": "^1.0.5",
24
+ "@tomjs/commitlint": "^2.0.5",
25
+ "@tomjs/eslint": "^1.1.0",
26
+ "@tomjs/prettier": "^1.0.6",
27
27
  "@tomjs/stylelint": "^1.0.5",
28
- "@tomjs/tsconfig": "^1.0.7",
29
- "@types/node": "^18.18.13",
28
+ "@tomjs/tsconfig": "^1.0.8",
29
+ "@types/node": "^18.19.0",
30
30
  "@vitejs/plugin-vue": "^4.5.0",
31
31
  "eslint": "^8.54.0",
32
32
  "husky": "^8.0.3",
@@ -1,27 +0,0 @@
1
- # template-node-github
2
-
3
- {{badges}}
4
-
5
- > 基础 node 模板
6
-
7
- [English](./README.md) | **中文**
8
-
9
- ## 安装
10
-
11
- 使用 `pnpm`
12
-
13
- ```bash
14
- pnpm add template-node-github
15
- ```
16
-
17
- 使用 `yarn`
18
-
19
- ```bash
20
- yarn add template-node-github
21
- ```
22
-
23
- 使用 `npm`
24
-
25
- ```bash
26
- npm i template-node-github
27
- ```