@tomjs/create-app 0.2.3 → 0.3.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/dist/index.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import a,{rmSync as te}from"fs";import ne from"os";import l from"path";import{fileURLToPath as re}from"url";import{blue as v,cyan as oe,green as ie,red as L,reset as d,yellow as N}from"kolorist";import{camelCase as se}from"lodash-es";import ae from"minimist";import ce from"prompts";import k from"shelljs";import p from"fs";import b from"path";function W(e){return[["t","template"]].forEach(([t,o])=>{e[o]=e[o]??e[t]}),e}function z(e){let t=p.readdirSync(e);return t.length===0||t.length===1&&t[0]===".git"}function j(e){return e?.trim().replace(/\/+$/g,"")}function ee(e,t){p.mkdirSync(t,{recursive:!0});for(let o of p.readdirSync(e)){let g=b.resolve(e,o),u=b.resolve(t,o);P(g,u)}}function P(e,t){p.statSync(e).isDirectory()?ee(e,t):p.copyFileSync(e,t)}function I(e){if(p.existsSync(e))for(let t of p.readdirSync(e))t!==".git"&&p.rmSync(b.resolve(e,t),{recursive:!0,force:!0})}function F(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function U(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function V(e){if(!e)return;let o=e.split(" ")[0].split("/");return{name:o[0],version:o[1]}}function R(e,t){let{variant:o,framework:g}=e,u=g;return u[t]||!!u?.variants?.find(y=>y.name===o&&y[t])}var $=W(ae(process.argv.slice(2),{string:["_"]})),D=process.cwd(),G=[{name:"vue",display:"Vue",color:ie,variants:[{name:"vue",display:"Web",color:v},{name:"electron-vue",display:"Electron",color:N}]},{name:"react",display:"React",color:oe,variants:[{name:"react",display:"Web",color:v},{name:"electron-react",display:"Electron",color:N}]},{name:"node",display:"Node",color:v,publish:!0,test:!0,variants:[{name:"node",display:"Base",color:v},{name:"node-electron",display:"Electron",color:N}]}],J=G.map(e=>e.variants&&e.variants.map(t=>t.name)||[e.name]).reduce((e,t)=>e.concat(t),[]),le={_gitignore:".gitignore","_lintstagedrc.cjs":".lintstagedrc.cjs"},A="my-app";function B(e){let t=k.exec(`git config --get ${e}`,{silent:!0});if(t.code===0)return t.stdout.trim()}async function me(){let e=j($._[0]),t=$.template||$.t,o=e||A,g=()=>o==="."?l.basename(l.resolve()):o,u={};u=await ce([{type:e?null:"text",name:"projectName",message:d("Project name:"),initial:A,onState:n=>{o=j(n.value)||A}},{type:()=>!a.existsSync(o)||z(o)?null:"toggle",name:"overwrite",message:()=>(o==="."?"Current directory":`Target directory "${o}"`)+" is not empty. Remove existing files and continue?",initial:!1,active:"yes",inactive:"no"},{type:(n,{overwrite:r})=>{if(r===!1)throw console.log(L("\u2716")+" Operation cancelled"),new Error;return null},name:"overwriteChecker"},{type:()=>F(g())?null:"text",name:"packageName",message:d("Package name:"),initial:()=>U(g()),validate:n=>F(n)||"Invalid package.json name"},{type:t&&J.includes(t)?null:"select",name:"framework",message:typeof t=="string"&&!J.includes(t)?d(`"${t}" isn't a valid template. Please choose from below: `):d("Select a framework:"),initial:0,choices:G.map(n=>{let r=n.color;return{title:r(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(r=>{let s=r.color;return{title:s(r.display||r.name),value:r.name}})},{type:(n,r)=>R(r,"publish")?"toggle":null,name:"needPublish",message:d("Whether to publish to the npm repository?"),initial:!0,active:"yes",inactive:"no"},{type:(n,r)=>R(r,"test")?"toggle":null,name:"needTest",message:d("Whether to add Test?"),initial:!0,active:"yes",inactive:"no"}],{onCancel:()=>{throw console.log(L("\u2716")+" Operation cancelled"),new Error}});let{framework:y,overwrite:K,packageName:q,variant:H,needPublish:T,needTest:Q}=u,c=l.join(D,o.substring(o.indexOf("/")+1));K?I(c):a.existsSync(c)||a.mkdirSync(c,{recursive:!0}),console.log(`
3
- Scaffolding project in ${c}...`);let S=H||y?.name||t||"",_=n=>l.join(re(import.meta.url),"../..",`template-${n}`),C=_(S),O=S.includes("node");[C,_("config")].forEach(n=>{let r=a.readdirSync(n);for(let s of r){let h=le[s]??s;if(O&&s.includes("stylelint"))continue;let x=l.join(c,h);P(l.join(n,s),x)}});let X=`template-${S}`,i=JSON.parse(a.readFileSync(l.join(C,"package.json"),"utf-8")),m=q||g();i.name=m;let f={name:"UserName",email:"name@github.com"};Z(),O&&Y();let M=V(process.env.npm_config_user_agent),w=M?M.name:"npm";k.which("git")&&k.exec(`cd ${c} && git init`);let E=l.relative(D,c);switch(console.log(`
2
+ import a,{renameSync as Ce}from"fs";import Oe from"os";import i from"path";import{fileURLToPath as Fe}from"url";import{blue as B,cyan as De,green as Te,red as fe,reset as w,yellow as Z}from"kolorist";import{camelCase as Ge}from"lodash-es";import Ue from"minimist";import _e from"prompts";import b from"shelljs";import pe from"os";import me from"path";import{blue as Pe,red as N,reset as C}from"kolorist";import Ae from"minimist";import L from"prompts";import p from"fs";import J from"path";function A(e){return[["t","template"],["g","git"]].forEach(([n,c])=>{e[c]=e[c]??e[n]}),e}function oe(e){let n=p.readdirSync(e);return n.length===0||n.length===1&&n[0]===".git"}function M(e){return e?.trim().replace(/\/+$/g,"")}function Re(e,n){p.mkdirSync(n,{recursive:!0});for(let c of p.readdirSync(e)){let h=J.resolve(e,c),u=J.resolve(n,c);z(h,u)}}function z(e,n){p.statSync(e).isDirectory()?Re(e,n):p.copyFileSync(e,n)}function re(e){if(p.existsSync(e))for(let n of p.readdirSync(e))n!==".git"&&p.rmSync(J.resolve(e,n),{recursive:!0,force:!0})}function V(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function ie(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function se(e){if(!e)return;let c=e.split(" ")[0].split("/");return{name:c[0],version:c[1]}}function v(e){if(p.existsSync(e))try{return JSON.parse(p.readFileSync(e,"utf8"))}catch(n){console.error(n)}}function x(e,n){p.writeFileSync(e,JSON.stringify(n,null,2)+`
3
+ `)}function $(e){p.existsSync(e)&&p.rmSync(e,{recursive:!0,force:!0})}function ce(e){p.existsSync(e)||p.mkdirSync(e,{recursive:!0})}var $e=A(Ae(process.argv.slice(2),{string:["_"]})),ae={repo:"https://github.com",owner:pe.userInfo().username};function K(e){let{repo:n,owner:c}=e;return`${n}${n.endsWith("/")?"":"/"}${c}`}async function le(e){let n=await L([{type:"text",name:"repo",message:C("Git repository url:"),initial:e?.repo||ae.repo},{type:"text",name:"owner",message:C("Git repository owner:"),initial:e?.owner||ae.owner}],{onCancel:()=>{throw console.log(N("\u2716")+" Operation cancelled"),new Error}});return{id:e?.id||Date.now().toString(),repo:n.repo,owner:n.owner}}var ue=me.join(pe.homedir(),".tomjs","create-app"),ge=me.join(ue,"config.json");function O(){return ce(ue),Object.assign({gitRepos:[]},v(ge))}function Ne(e){let n=O();n.createTime?n.updateTime=Date.now():n.createTime=Date.now(),x(ge,Object.assign(n,e))}function Y(e){Ne({gitRepos:e})}async function q(){let{gitRepos:e}=O();(e.length===0||$e.git)&&(e.length===0&&console.log(`You need to set the ${Pe("git remote repository")} for the first time.`),await n());async function n(){let c=e.map(g=>({title:K(g),value:g.id})).concat([{title:"Add",value:"add"},{title:N("Exit"),value:"exit"}]),h=await L({type:"select",name:"repoId",message:e.length===0?"You choose to add or exit:":"You can choose the repository to be operated, or choose to add or exit:",choices:c},{onCancel:()=>{throw console.log(N("\u2716")+" Operation cancelled"),new Error}}),{repoId:u}=h;if(u==="exit")return;if(u==="add"){let g=await le();return e.push(g),Y(e),n()}let S=e.findIndex(g=>g.id===u),R=await L([{type:"select",name:"action",message:C("Select an action?"),choices:[{title:"Edit",value:"edit"},{title:"Remove",value:"remove"},{title:"Exit",value:"exit"}]},{type:g=>g==="remove"&&"toggle",name:"confirmRemove",message:C("Where confirm to remove?"),initial:!0,active:"Yes",inactive:"No"}],{onCancel:()=>{throw console.log(N("\u2716")+" Operation cancelled"),new Error}}),{action:P,confirmRemove:F}=R;if(P==="exit")return q();if(P==="remove")return F&&(e.splice(S,1),Y(e)),n();let D=await le(e[S]);return e[S]=D,Y(e),n()}}var H=A(Ue(process.argv.slice(2),{string:["_"]})),Q=process.cwd(),ve=[{name:"vue",display:"Vue",color:Te,variants:[{name:"vue",display:"Web",color:B},{name:"electron-vue",display:"Electron",color:Z}]},{name:"react",display:"React",color:De,variants:[{name:"react",display:"Web",color:B},{name:"electron-react",display:"Electron",color:Z}]},{name:"node",display:"Node",color:B,options:[{id:"test",name:"Test"},{id:"publish",name:"Git Repository + NPM"},{id:"vite",name:"Vite Plugin"},{id:"electron",name:"Electron"},{id:"examples",name:"Examples"}]}],de=ve.map(e=>e.variants&&e.variants.map(n=>n.name)||[e.name]).reduce((e,n)=>e.concat(n),[]),X="my-app";function ye(e){let n=b.exec(`git config --get ${e}`,{silent:!0});if(n.code===0)return n.stdout.trim()}function he(e){return e.length>1?e.substring(e.indexOf("/")+1):e}async function Ie(){let e=M(H._[0]),n=H.template||H.t,c=e||X,h=()=>c==="."?i.basename(i.resolve()):c,u=he(c),{gitRepos:S}=O(),R=await _e([{type:e?null:"text",name:"projectName",message:w("Project name:"),initial:X,onState:t=>{c=M(t.value)||X,u=he(c)}},{type:()=>!a.existsSync(u)||oe(u)?null:"toggle",name:"overwrite",message:()=>(u==="."?"Current directory":`Target directory "${u}"`)+" is not empty. Remove existing files and continue?",initial:!1,active:"Yes",inactive:"No"},{type:(t,{overwrite:o})=>{if(o===!1)throw console.log(fe("\u2716")+" Operation cancelled"),new Error;return null},name:"overwriteChecker"},{type:()=>V(h())?null:"text",name:"packageName",message:w("Package name:"),initial:()=>ie(h()),validate:t=>V(t)||"Invalid package.json name"},{type:n&&de.includes(n)?null:"select",name:"framework",message:typeof n=="string"&&!de.includes(n)?w(`"${n}" isn't a valid template. Please choose from below: `):w("Select a framework:"),initial:0,choices:ve.map(t=>{let o=t.color;return{title:o(t.display||t.name),value:t}})},{type:t=>t&&t.variants?"select":null,name:"variant",message:w("Select a variant:"),choices:t=>t?.variants?.map(o=>{let r=o.color;return{title:r(o.display||o.name),value:o.name}})},{type:(t,o)=>{let{framework:r}=o;return r&&Array.isArray(r.options)&&r.options.length?"multiselect":null},name:"options",message:w("Select optional options:"),instructions:!1,choices:(t,o)=>{let{framework:r}=o;return r?.options?.map(l=>({title:l.name,value:l.id}))}},{type:(t,o)=>S.length&&Array.isArray(o.options)&&o.options.includes("publish")?"select":null,name:"gitUserUrl",message:w("Which git repository to publish to?"),choices:S.map(t=>{let o=K(t);return{title:o,value:o}})}],{onCancel:()=>{throw console.log(fe("\u2716")+" Operation cancelled"),new Error}}),{framework:P,overwrite:F,packageName:D,variant:g,gitUserUrl:xe}=R,f=R.options||[],s=i.join(Q,u);F?re(s):a.existsSync(s)||a.mkdirSync(s,{recursive:!0}),console.log(`
4
+ Scaffolding project in ${s}...`);let T=g||P?.name||n||"",G=t=>i.join(Fe(import.meta.url),"../..",`template-${t}`),we=G(T),U=T.includes("node");[we,G("config")].forEach(t=>{let o=a.readdirSync(t);for(let r of o){let l=r.startsWith("_")?r.replace("_","."):r;if(U&&!f.includes("examples")&&r.includes("stylelint"))continue;let m=i.join(s,l);z(i.join(t,r),m)}});let d=D||h(),Se=`template-${T}`,j={name:"UserName",email:"name@github.com"};function ee(){let t=d.startsWith("@")?d.split("/")[0].substring(1):Ge(j.name);return`${xe||`https://github.com/${t}`}/${d.substring(d.indexOf("/")+1)}.git`}ke(),U&&(je(),Ee(),be());let te=se(process.env.npm_config_user_agent),_=te?te.name:"npm";b.which("git")&&(b.exec(`cd ${s} && git init`),f.includes("publish")&&b.exec(`cd ${s} && git remote add origin ${ee()}`));let I=i.relative(Q,s);switch(console.log(`
4
5
  Done. Now run:
5
- `),c!==D&&console.log(` cd ${E.includes(" ")?`"${E}"`:E}`),w){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${w} install`),console.log(` ${w} run dev`);break}function Y(){["LICENSE","README.md","README.zh_CN.md"].forEach(n=>{let r=l.join(c,n);if(!T&&a.existsSync(r)){a.rmSync(r),n==="README.md"&&a.writeFileSync(r,`# ${m}
6
- `,{encoding:"utf-8"});return}if(!a.existsSync(r))return;let s=a.readFileSync(r,"utf-8").replace(new RegExp(X,"g"),m).replace(new RegExp("{{user.name}}","g"),f.name).replace(new RegExp("{{user.email}}","g"),f.email);if(n.startsWith("README")){let h=m.replace("@","%40"),x=m.replace("@","%40").replace(new RegExp("/","g"),"%2F");s=s.replace("{{badges}}",[`![npm](https://img.shields.io/npm/v/${h})`,`![node-current (scoped)](https://img.shields.io/node/v/${h})`,`![NPM](https://img.shields.io/npm/l/${x})`].join(" "))}a.writeFileSync(r,s)})}function Z(){if(T){k.which("git")&&(f.name=B("user.name")||ne.userInfo().username,f.email=B("user.email")||"",i.author=Object.assign(i.author,f));let n=m.startsWith("@")?m.split("/")[0].substring(1):se(f.name);i.repository.url=`git+https://github.com/${n}/${m.substring(m.indexOf("/")+1)}.git`}else delete i.author,delete i.publishConfig,delete i.repository,delete i.scripts.prepublishOnly,delete i.devDependencies.np;if(!Q){delete i.scripts.test,["jest.config.js","test"].forEach(r=>{let s=l.join(c,r);a.existsSync(s)&&te(s,{force:!0,recursive:!0})});let n=Object.keys(i.devDependencies||{});Array.isArray(n)&&n.forEach(r=>{r.includes("jest")&&delete i.devDependencies[r]})}a.writeFileSync(l.join(c,"package.json"),JSON.stringify(i,null,2)+`
7
- `)}}me().catch(e=>{e.message&&console.error(e)});
6
+ `),s!==Q&&console.log(` cd ${I.includes(" ")?`"${I}"`:I}`),_){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${_} install`),console.log(` ${_} run dev`);break}function je(){["LICENSE","README.md","README.zh_CN.md"].forEach(t=>{let o=i.join(s,t);if(!f.includes("publish")&&a.existsSync(o)){a.rmSync(o),t==="README.md"&&a.writeFileSync(o,`# ${d}
7
+ `,{encoding:"utf-8"});return}if(!a.existsSync(o))return;let r=a.readFileSync(o,"utf-8").replace(new RegExp(Se,"g"),d).replace(new RegExp("{{user.name}}","g"),j.name).replace(new RegExp("{{user.email}}","g"),j.email);if(t.startsWith("README")){let l=d.replace("@","%40"),m=d.replace("@","%40").replace(new RegExp("/","g"),"%2F");r=r.replace("{{badges}}",[`![npm](https://img.shields.io/npm/v/${l})`,`![node-current (scoped)](https://img.shields.io/node/v/${l})`,`![NPM](https://img.shields.io/npm/l/${m})`].join(" "))}a.writeFileSync(o,r)})}function k(t,...o){["dependencies","devDependencies"].forEach(r=>{Object.keys(t[r]||{}).forEach(l=>{o.find(m=>l.includes(m))&&delete t[r][l]})})}function ke(){let t=v(i.join(s,"package.json"));t.name=d,f.includes("publish")?(b.which("git")&&(j.name=ye("user.name")||Oe.userInfo().username,j.email=ye("user.email")||"",t.author=Object.assign(t.author,j)),t.repository.url=`git+${ee()}`):(delete t.author,delete t.publishConfig,delete t.repository,delete t.scripts.prepublishOnly,delete t.devDependencies.np),f.includes("electron")||(k(t,"electron"),t.scripts["lint:eslint"]=t.scripts["lint:eslint"].replace(",electron","")),U&&!f.includes("vite")&&k(t,"vite"),x(i.join(s,"package.json"),t)}function W(t,o){let r=t.lastIndexOf("."),l=t.substring(0,r)+"."+o+t.substring(r),m=i.join(s,t),y=i.join(s,l);f.includes(o)?($(m),a.existsSync(y)&&Ce(y,m)):$(y)}function Ee(){if(W("tsconfig.json","test"),W("jest.config.cjs","electron"),f.includes("test"))return;a.readdirSync(s).filter(r=>r.startsWith("jest.config")||["test"].includes(r)).forEach(r=>{$(i.join(s,r))});let t=i.join(s,"package.json"),o=v(t);delete o.scripts.test,o.scripts["lint:eslint"]=o.scripts["lint:eslint"].replace(",test",""),k(o,"jest"),x(t,o)}function be(){if(W(".lintstagedrc.cjs","examples"),!f.includes("examples")){let r=v(i.join(s,"package.json"));r.scripts.lint=r.scripts.lint.replace(" lint:stylelint",""),r.scripts["lint:eslint"]=r.scripts["lint:eslint"].replace(",examples",""),delete r.scripts["lint:stylelint"],k(r,"stylelint"),x(i.join(s,"package.json"),r);return}let t=i.join(s,"examples");a.mkdirSync(t);let o=f.includes("electron");["vue","react"].forEach(r=>{let l=G(o?`electron-${r}`:r),m=i.join(t,r);if(!a.existsSync(l)){console.log(`${Z(l)} template is not exist`);return}a.cpSync(l,m,{recursive:!0});let y=v(i.join(m,"package.json"));Object.keys(y.scripts).forEach(E=>{(E.startsWith("lint")||["prepare"].includes(E))&&delete y.scripts[E]}),k(y,"eslint","prettier","stylelint","commitlint","husky","lint-staged","tsconfig","lint-staged"),x(i.join(m,"package.json"),y),["_lintstagedrc.cjs"].forEach(E=>{let ne=i.join(m,E);a.existsSync(ne)&&a.rmSync(ne,{recursive:!0})})}),a.writeFileSync(i.join(s,"pnpm-workspace.yaml"),`packages:
8
+ - 'examples/*'`,{encoding:"utf-8"})}}q().then(async()=>Ie().catch(e=>{e.message&&console.error(e)})).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.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "create tomjs web app",
5
5
  "keywords": [
6
6
  "tomjs",
@@ -23,25 +23,25 @@
23
23
  "email": "tom@tomgao.cc"
24
24
  },
25
25
  "license": "MIT",
26
- "repository": {
27
- "type": "git",
28
- "url": "git+https://github.com/tomgao365/create-app.git"
29
- },
30
- "publishConfig": {
31
- "access": "public",
32
- "registry": "https://registry.npmjs.org"
26
+ "main": "dist/index.mjs",
27
+ "bin": {
28
+ "create-app": "dist/index.mjs"
33
29
  },
34
30
  "files": [
35
31
  "dist",
36
32
  "template-*/**"
37
33
  ],
38
- "main": "dist/index.mjs",
39
- "bin": {
40
- "create-app": "dist/index.mjs"
41
- },
42
34
  "engines": {
43
35
  "node": ">=18"
44
36
  },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/tomgao365/create-app.git"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public",
43
+ "registry": "https://registry.npmjs.org"
44
+ },
45
45
  "dependencies": {
46
46
  "kolorist": "^1.8.0",
47
47
  "lodash-es": "^4.17.21",
@@ -52,28 +52,31 @@
52
52
  "devDependencies": {
53
53
  "@commitlint/cli": "^18.4.3",
54
54
  "@tomjs/commitlint": "^2.0.5",
55
- "@tomjs/eslint": "^1.1.0",
55
+ "@tomjs/eslint": "^1.1.1",
56
56
  "@tomjs/prettier": "^1.0.6",
57
+ "@tomjs/stylelint": "^1.1.0",
57
58
  "@tomjs/tsconfig": "^1.0.8",
58
59
  "@types/lodash-es": "^4.17.12",
59
60
  "@types/minimist": "^1.2.5",
60
- "@types/node": "^18.19.2",
61
+ "@types/node": "^18.19.3",
61
62
  "@types/prompts": "^2.4.9",
62
63
  "@types/shelljs": "^0.8.15",
63
64
  "eslint": "^8.55.0",
64
65
  "husky": "^8.0.3",
65
66
  "lint-staged": "^15.2.0",
66
- "np": "^9.0.0",
67
+ "np": "^9.1.0",
67
68
  "npm-run-all": "^4.1.5",
68
69
  "prettier": "^3.1.0",
70
+ "stylelint": "^15.11.0",
69
71
  "tsup": "^8.0.1",
70
72
  "typescript": "~5.2.2"
71
73
  },
72
74
  "scripts": {
73
75
  "dev": "tsup --watch",
74
76
  "build": "tsup --minify",
75
- "lint": "run-s lint:eslint lint:prettier",
76
- "lint:eslint": "eslint \"src/**/*.{js,cjs,ts}\" *.{js,cjs,ts} --fix --cache",
77
- "lint:prettier": "prettier --write \"src/**/*.{js,cjs,ts,json,md}\" *.{js,cjs,ts,json,md}"
77
+ "lint": "run-s lint:eslint lint:stylelint lint:prettier",
78
+ "lint:eslint": "eslint \"{src,template-*}/**/*.{js,cjs,ts}\" *.{js,cjs,ts} --fix --cache",
79
+ "lint:stylelint": "stylelint \"template-*/**/*.{css,scss,less,vue,html}\" --fix --cache",
80
+ "lint:prettier": "prettier --write \"{src,template-*}/**/*.{js,cjs,ts,json,md}\" *.{js,cjs,ts,json,md}"
78
81
  }
79
82
  }
@@ -1,3 +1,3 @@
1
1
  module.exports = {
2
- extends: [require.resolve('@tomjs/stylelint/vue')],
2
+ extends: [require.resolve('@tomjs/stylelint')],
3
3
  };
@@ -29,16 +29,16 @@
29
29
  "devDependencies": {
30
30
  "@commitlint/cli": "^18.4.3",
31
31
  "@tomjs/commitlint": "^2.0.5",
32
- "@tomjs/eslint": "^1.1.0",
32
+ "@tomjs/eslint": "^1.1.1",
33
33
  "@tomjs/prettier": "^1.0.6",
34
- "@tomjs/stylelint": "^1.0.7",
34
+ "@tomjs/stylelint": "^1.1.0",
35
35
  "@tomjs/tsconfig": "^1.0.8",
36
- "@types/node": "^18.19.2",
37
- "@types/react": "^18.2.41",
36
+ "@types/node": "^18.19.3",
37
+ "@types/react": "^18.2.42",
38
38
  "@types/react-dom": "^18.2.17",
39
39
  "@types/shelljs": "^0.8.15",
40
40
  "@vitejs/plugin-react-swc": "^3.5.0",
41
- "electron": "^27.1.3",
41
+ "electron": "^28.0.0",
42
42
  "electron-builder": "^24.9.1",
43
43
  "eslint": "^8.55.0",
44
44
  "husky": "^8.0.3",
@@ -51,7 +51,7 @@
51
51
  "tree-kill": "^1.2.2",
52
52
  "tsx": "^4.6.2",
53
53
  "typescript": "~5.2.2",
54
- "vite": "^5.0.5",
54
+ "vite": "^5.0.6",
55
55
  "vite-plugin-electron": "^0.15.4",
56
56
  "vite-plugin-electron-renderer": "^0.14.5"
57
57
  }
@@ -22,19 +22,19 @@
22
22
  "prepare": "husky install"
23
23
  },
24
24
  "dependencies": {
25
- "vue": "^3.3.9"
25
+ "vue": "^3.3.10"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@commitlint/cli": "^18.4.3",
29
29
  "@tomjs/commitlint": "^2.0.5",
30
- "@tomjs/eslint": "^1.1.0",
30
+ "@tomjs/eslint": "^1.1.1",
31
31
  "@tomjs/prettier": "^1.0.6",
32
- "@tomjs/stylelint": "^1.0.7",
32
+ "@tomjs/stylelint": "^1.1.0",
33
33
  "@tomjs/tsconfig": "^1.0.8",
34
- "@types/node": "^18.19.2",
34
+ "@types/node": "^18.19.3",
35
35
  "@types/shelljs": "^0.8.15",
36
36
  "@vitejs/plugin-vue": "^4.5.1",
37
- "electron": "^27.1.3",
37
+ "electron": "^28.0.0",
38
38
  "electron-builder": "^24.9.1",
39
39
  "eslint": "^8.55.0",
40
40
  "husky": "^8.0.3",
@@ -47,9 +47,9 @@
47
47
  "tree-kill": "^1.2.2",
48
48
  "tsx": "^4.6.2",
49
49
  "typescript": "~5.2.2",
50
- "vite": "^5.0.5",
50
+ "vite": "^5.0.6",
51
51
  "vite-plugin-electron": "^0.15.4",
52
52
  "vite-plugin-electron-renderer": "^0.14.5",
53
- "vue-tsc": "^1.8.24"
53
+ "vue-tsc": "^1.8.25"
54
54
  }
55
55
  }
@@ -24,4 +24,4 @@ yarn add template-node
24
24
 
25
25
  ```bash
26
26
  npm i template-node
27
- ```
27
+ ```
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ '*.{js,cjs,ts,tsx}': ['eslint --fix', 'prettier --write'],
3
+ '*.{json,md}': ['prettier --write'],
4
+ '*.vue': ['eslint --fix', 'stylelint --fix', 'prettier --write'],
5
+ '*.{css,scss,less,html}': ['stylelint --fix', 'prettier --write'],
6
+ };
@@ -1,6 +1,7 @@
1
1
  /** @type {import('ts-jest').JestConfigWithTsJest} */
2
2
  module.exports = {
3
3
  preset: 'ts-jest',
4
+ runner: '@kayahr/jest-electron-runner/main',
4
5
  testEnvironment: 'node',
5
6
  testTimeout: 10000,
6
7
  testMatch: ['<rootDir>/test/**/*.test.ts'],
@@ -10,12 +10,22 @@
10
10
  "email": "name@github.com"
11
11
  },
12
12
  "license": "MIT",
13
- "engines": {
14
- "node": ">=16"
13
+ "main": "./dist/index.js",
14
+ "module": "./dist/index.mjs",
15
+ "types": "./dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "require": "./dist/index.js",
19
+ "import": "./dist/index.mjs",
20
+ "types": "./dist/index.d.ts"
21
+ }
15
22
  },
16
23
  "files": [
17
24
  "dist"
18
25
  ],
26
+ "engines": {
27
+ "node": ">=16"
28
+ },
19
29
  "publishConfig": {
20
30
  "access": "public",
21
31
  "registry": "https://registry.npmjs.org/"
@@ -24,52 +34,47 @@
24
34
  "type": "git",
25
35
  "url": "git+https://github.com/xxx/template-node.git"
26
36
  },
27
- "main": "./dist/index.js",
28
- "module": "./dist/index.mjs",
29
- "types": "./dist/index.d.ts",
30
- "exports": {
31
- ".": {
32
- "require": "./dist/index.js",
33
- "import": "./dist/index.mjs",
34
- "types": "./dist/index.d.ts"
35
- }
36
- },
37
37
  "scripts": {
38
38
  "dev": "tsup --watch",
39
- "start": "tsx ./src/index.ts",
39
+ "start": "tsx ./scripts/info.ts",
40
40
  "build": "tsup",
41
41
  "test": "jest",
42
- "lint": "run-s lint:eslint lint:prettier",
43
- "lint:eslint": "eslint \"{src,test}/**/*.ts\" *.{js,cjs,ts} --fix --cache",
42
+ "lint": "run-s lint:eslint lint:stylelint lint:prettier",
43
+ "lint:eslint": "eslint \"{src,scripts,test,examples}/**/*.ts\" *.{js,cjs,ts} --fix --cache",
44
+ "lint:stylelint": "stylelint \"examples/**/*.{css,scss,less,vue,html}\" --fix --cache",
44
45
  "lint:prettier": "prettier --write .",
45
46
  "prepare": "husky install",
46
47
  "prepublishOnly": "npm run build && np --any-branch --no-yarn --yolo --no-publish --message \"chore: release v%s\""
47
48
  },
48
49
  "dependencies": {
49
- "kolorist": "^1.8.0"
50
+ "kolorist": "^1.8.0",
51
+ "shelljs": "^0.8.5"
50
52
  },
51
53
  "devDependencies": {
52
54
  "@commitlint/cli": "^18.4.3",
53
55
  "@jest/globals": "^29.7.0",
56
+ "@kayahr/jest-electron-runner": "^29.10.0",
54
57
  "@tomjs/commitlint": "^2.0.5",
55
- "@tomjs/eslint": "^1.1.0",
58
+ "@tomjs/eslint": "^1.1.1",
56
59
  "@tomjs/prettier": "^1.0.6",
60
+ "@tomjs/stylelint": "^1.1.0",
57
61
  "@tomjs/tsconfig": "^1.0.8",
58
- "@types/jest": "^29.5.10",
59
- "@types/node": "^18.19.2",
60
- "@types/shelljs": "^0.8.15",
62
+ "@types/jest": "^29.5.11",
63
+ "@types/node": "^18.19.3",
64
+ "electron": "^28.0.0",
61
65
  "eslint": "^8.55.0",
62
66
  "husky": "^8.0.3",
63
67
  "jest": "^29.7.0",
64
68
  "lint-staged": "^15.2.0",
65
- "np": "^9.0.0",
69
+ "np": "^9.1.0",
66
70
  "npm-run-all": "^4.1.5",
67
71
  "prettier": "^3.1.0",
68
72
  "rimraf": "^5.0.5",
69
- "shelljs": "^0.8.5",
73
+ "stylelint": "^15.11.0",
70
74
  "ts-jest": "^29.1.1",
71
75
  "tsup": "^8.0.1",
72
76
  "tsx": "^4.6.2",
73
- "typescript": "~5.2.2"
77
+ "typescript": "~5.2.2",
78
+ "vite": "^5.0.6"
74
79
  }
75
80
  }
@@ -1,14 +1,3 @@
1
- import os from 'node:os';
2
- import { blue } from 'kolorist';
1
+ export function fun() {}
3
2
 
4
- function run() {
5
- console.log(blue('Hello World!'));
6
- console.log(
7
- `system: ${os.platform()} ${os.arch()} v${os.release()} ${os.cpus().length} cores ${Math.ceil(
8
- os.totalmem() / 1024 / 1024 / 1024,
9
- )}GB`,
10
- );
11
- console.log(`node: ${process.version} ${process.arch}`);
12
- }
13
-
14
- run();
3
+ export default fun();
@@ -1,9 +1,4 @@
1
1
  {
2
2
  "extends": "@tomjs/tsconfig/node.json",
3
- "include": [
4
- "src/**/*.ts",
5
- "src/**/*.d.ts",
6
- "test/**/*.ts",
7
- "test/**/*.d.ts"
8
- ],
3
+ "include": ["src/**/*.ts", "src/**/*.d.ts"]
9
4
  }
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "@tomjs/tsconfig/node.json",
3
+ "include": ["src/**/*.ts", "src/**/*.d.ts", "test/**/*.ts", "test/**/*.d.ts"]
4
+ }
@@ -4,4 +4,4 @@ vite + react
4
4
 
5
5
  ## Reference project
6
6
 
7
- - [create-vite](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts)
7
+ - [create-vite](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts)
@@ -23,12 +23,12 @@
23
23
  "devDependencies": {
24
24
  "@commitlint/cli": "^18.4.3",
25
25
  "@tomjs/commitlint": "^2.0.5",
26
- "@tomjs/eslint": "^1.1.0",
26
+ "@tomjs/eslint": "^1.1.1",
27
27
  "@tomjs/prettier": "^1.0.6",
28
- "@tomjs/stylelint": "^1.0.7",
28
+ "@tomjs/stylelint": "^1.1.0",
29
29
  "@tomjs/tsconfig": "^1.0.8",
30
- "@types/node": "^18.19.2",
31
- "@types/react": "^18.2.41",
30
+ "@types/node": "^18.19.3",
31
+ "@types/react": "^18.2.42",
32
32
  "@types/react-dom": "^18.2.17",
33
33
  "@vitejs/plugin-react-swc": "^3.5.0",
34
34
  "eslint": "^8.55.0",
@@ -38,6 +38,6 @@
38
38
  "prettier": "^3.1.0",
39
39
  "stylelint": "^15.11.0",
40
40
  "typescript": "~5.2.2",
41
- "vite": "^5.0.5"
41
+ "vite": "^5.0.6"
42
42
  }
43
43
  }
@@ -4,4 +4,4 @@ vite + vue
4
4
 
5
5
  ## Reference project
6
6
 
7
- - [create-vite](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-vue-ts)
7
+ - [create-vite](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-vue-ts)
@@ -17,16 +17,16 @@
17
17
  "prepare": "husky install"
18
18
  },
19
19
  "dependencies": {
20
- "vue": "^3.3.9"
20
+ "vue": "^3.3.10"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@commitlint/cli": "^18.4.3",
24
24
  "@tomjs/commitlint": "^2.0.5",
25
- "@tomjs/eslint": "^1.1.0",
25
+ "@tomjs/eslint": "^1.1.1",
26
26
  "@tomjs/prettier": "^1.0.6",
27
- "@tomjs/stylelint": "^1.0.7",
27
+ "@tomjs/stylelint": "^1.1.0",
28
28
  "@tomjs/tsconfig": "^1.0.8",
29
- "@types/node": "^18.19.2",
29
+ "@types/node": "^18.19.3",
30
30
  "@vitejs/plugin-vue": "^4.5.1",
31
31
  "eslint": "^8.55.0",
32
32
  "husky": "^8.0.3",
@@ -35,7 +35,7 @@
35
35
  "prettier": "^3.1.0",
36
36
  "stylelint": "^15.11.0",
37
37
  "typescript": "~5.2.2",
38
- "vite": "^5.0.5",
39
- "vue-tsc": "^1.8.24"
38
+ "vite": "^5.0.6",
39
+ "vue-tsc": "^1.8.25"
40
40
  }
41
41
  }
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- env: {
3
- node: true,
4
- es6: true,
5
- },
6
- extends: [require.resolve('@tomjs/eslint/typescript')],
7
- };
@@ -1,21 +0,0 @@
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,27 +0,0 @@
1
- # template-node-electron
2
-
3
- {{badges}}
4
-
5
- > Basic Electron template
6
-
7
- **English** | [中文](./README.zh_CN.md)
8
-
9
- ## Install
10
-
11
- With `pnpm`
12
-
13
- ```bash
14
- pnpm add template-node-electron
15
- ```
16
-
17
- With `yarn`
18
-
19
- ```bash
20
- yarn add template-node-electron
21
- ```
22
-
23
- With `npm`
24
-
25
- ```bash
26
- npm i template-node-electron
27
- ```
@@ -1,27 +0,0 @@
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
- ```
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- '*.{js,cjs,ts}': ['eslint --fix', 'prettier --write'],
3
- '*.{json,md}': ['prettier --write'],
4
- };
@@ -1,77 +0,0 @@
1
- {
2
- "name": "template-node-electron",
3
- "version": "0.0.0",
4
- "description": "Basic Electron template",
5
- "keywords": [
6
- "electron"
7
- ],
8
- "author": {
9
- "name": "name",
10
- "email": "name@github.com"
11
- },
12
- "license": "MIT",
13
- "engines": {
14
- "node": ">=16"
15
- },
16
- "files": [
17
- "dist"
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-electron.git"
26
- },
27
- "main": "./dist/index.js",
28
- "module": "./dist/index.mjs",
29
- "types": "./dist/index.d.ts",
30
- "exports": {
31
- ".": {
32
- "require": "./dist/index.js",
33
- "import": "./dist/index.mjs",
34
- "types": "./dist/index.d.ts"
35
- }
36
- },
37
- "scripts": {
38
- "dev": "tsup --watch",
39
- "start": "tsx ./src/index.ts",
40
- "build": "tsup",
41
- "test": "jest",
42
- "lint": "run-s lint:eslint lint:prettier",
43
- "lint:eslint": "eslint \"{src,test}/**/*.ts\" *.{js,cjs,ts} --fix --cache",
44
- "lint:prettier": "prettier --write .",
45
- "prepare": "husky install",
46
- "prepublishOnly": "npm run build && np --any-branch --no-yarn --yolo --no-publish --message \"chore: release v%s\""
47
- },
48
- "dependencies": {
49
- "kolorist": "^1.8.0"
50
- },
51
- "devDependencies": {
52
- "@commitlint/cli": "^18.4.3",
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.2",
61
- "@types/shelljs": "^0.8.15",
62
- "electron": "^27.1.3",
63
- "eslint": "^8.55.0",
64
- "husky": "^8.0.3",
65
- "jest": "^29.7.0",
66
- "lint-staged": "^15.2.0",
67
- "np": "^9.0.0",
68
- "npm-run-all": "^4.1.5",
69
- "prettier": "^3.1.0",
70
- "rimraf": "^5.0.5",
71
- "shelljs": "^0.8.5",
72
- "ts-jest": "^29.1.1",
73
- "tsup": "^8.0.1",
74
- "tsx": "^4.6.2",
75
- "typescript": "~5.2.2"
76
- }
77
- }
@@ -1,10 +0,0 @@
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
- });
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "@tomjs/tsconfig/node.json",
3
- "include": [
4
- "src/**/*.ts",
5
- "src/**/*.d.ts",
6
- "test/**/*.ts",
7
- "test/**/*.d.ts"
8
- ],
9
- }
@@ -1,12 +0,0 @@
1
- import { defineConfig } from 'tsup';
2
- import pkg from './package.json';
3
-
4
- export default defineConfig({
5
- entry: ['src/index.ts'],
6
- format: ['esm', 'cjs'],
7
- target: ['es2021', 'node16'],
8
- external: ['electron'].concat(Object.keys(pkg.dependencies)),
9
- clean: true,
10
- dts: true,
11
- splitting: true,
12
- });