@tomjs/create-app 0.12.1 → 0.13.1
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 +10 -8
- package/package.json +8 -8
- package/{template-node/.eslintrc.cjs → template-electron-react/_eslintrc.cjs} +1 -1
- package/template-electron-react/package.json +11 -11
- package/{template-vscode/.eslintrc.cjs → template-electron-vue/_eslintrc.cjs} +1 -1
- package/template-electron-vue/package.json +11 -11
- package/{template-vscode-vue/.eslintrc.cjs → template-node/_eslintrc.cjs} +1 -1
- package/template-node/package.json +13 -20
- package/template-node/scripts/info.ts +0 -2
- package/template-node/vitest.workspace.ts +3 -0
- package/{template-electron-vue/.eslintrc.cjs → template-react/_eslintrc.cjs} +1 -1
- package/template-react/package.json +8 -8
- package/template-vscode/_eslintrc.cjs +7 -0
- package/template-vscode/package.json +7 -9
- package/template-vscode/src/index.ts +7 -8
- package/template-vscode-react/_eslintrc.cjs +7 -0
- package/template-vscode-react/extension/env.d.ts +1 -0
- package/template-vscode-react/extension/index.ts +8 -9
- package/template-vscode-react/extension/views/helper.ts +27 -0
- package/template-vscode-react/extension/views/panel.ts +48 -0
- package/template-vscode-react/package.json +10 -13
- package/template-vscode-react/src/utils/vscode.ts +0 -1
- package/template-vscode-react/tsconfig.node.json +1 -1
- package/template-vscode-vue/_eslintrc.cjs +7 -0
- package/template-vscode-vue/extension/env.d.ts +1 -0
- package/template-vscode-vue/extension/index.ts +8 -9
- package/template-vscode-vue/extension/views/helper.ts +27 -0
- package/template-vscode-vue/extension/views/panel.ts +48 -0
- package/template-vscode-vue/package.json +10 -13
- package/template-vscode-vue/src/utils/vscode.ts +0 -1
- package/template-vscode-vue/tsconfig.node.json +1 -1
- package/template-vue/_eslintrc.cjs +7 -0
- package/template-vue/package.json +8 -8
- package/template-electron-react/.eslintrc.cjs +0 -7
- package/template-node/jest.config.cjs +0 -7
- package/template-node/jest.config.electron.cjs +0 -8
- package/template-node/test/simple.test.ts +0 -7
- package/template-react/.eslintrc.cjs +0 -7
- package/template-vscode-react/.eslintrc.cjs +0 -7
- package/template-vscode-react/extension/panels/MainPanel.ts +0 -168
- package/template-vscode-vue/extension/panels/MainPanel.ts +0 -168
- package/template-vue/.eslintrc.cjs +0 -7
- /package/template-node/test/{electron.test.ts → index.test.ts} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Scaffolding project in ${a}...`);let _=y||R?.name||i||"",I=n=>s.join(Je(import.meta.url),"../..",`template-${n}`),Pe=I(_),V=_.includes("node");[Pe,I("config")].forEach(n=>{let t=l.readdirSync(n);for(let r of t){let o=r.startsWith("_")?r.replace("_","."):r;if((V&&!m.includes("examples")||_==="vscode")&&r.includes("stylelint"))continue;let u=s.join(a,o);H(s.join(n,r),u)}});let f=U||w(),J={name:ke("user.name")||Ve.userInfo().username,email:ke("user.email")||""},M={"pkg.name":f,"user.name":J.name,"user.email":J.email,"git.org":W(),"git.url":Re(),"git.fullUrl":ie()};function Re(){return`${E||`https://github.com/${W()}`}/${f.substring(f.indexOf("/")+1)}`}function W(){return E?E.substring(E.lastIndexOf("/")+1):f.startsWith("@")?f.split("/")[0].substring(1):ze(J.name)}function ie(n=!1){let t=E||`https://github.com/${W()}`;return n&&(t=t.replace(/http(s):\/\//g,"git@").replace(/\//,":")),`${t}/${f.substring(f.indexOf("/")+1)}.git`}$e(),V&&(Ae(),Ce(),De());let re=me(process.env.npm_config_user_agent),z=re?re.name:"npm";T.which("git")&&(T.exec(`cd ${a} && git init`),m.includes("publish")&&T.exec(`cd ${a} && git remote add origin ${ie(m.includes("ssh"))}`));let L=s.relative(te,a);switch(console.log(`
|
|
1
|
+
import m,{renameSync as Be}from"fs";import He from"os";import l from"path";import{fileURLToPath as Ke}from"url";import{lightBlue as N,lightCyan as qe,lightGreen as U,lightYellow as be,red as je,reset as x,yellow as Qe}from"kolorist";import{camelCase as Xe}from"lodash-es";import Ze from"minimist";import et from"prompts";import _ from"shelljs";import xe from"os";import we from"path";import{blue as Me,red as D,reset as G}from"kolorist";import ze from"minimist";import te from"prompts";import u from"fs";import K from"path";function $(e){return[["t","template"],["g","git"]].forEach(([i,p])=>{e[p]=e[p]??e[i]}),e}function me(e){return u.readdirSync(e).length===0}function q(e){return e?.trim().replace(/\/+$/g,"")}function We(e,i){u.mkdirSync(i,{recursive:!0});for(let p of u.readdirSync(e)){let h=K.resolve(e,p),f=K.resolve(i,p);Q(h,f)}}function Q(e,i){u.statSync(e).isDirectory()?We(e,i):u.copyFileSync(e,i)}function ge(e){if(u.existsSync(e))for(let i of u.readdirSync(e))u.rmSync(K.resolve(e,i),{recursive:!0,force:!0})}function X(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function fe(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function de(e){if(!e)return;let p=e.split(" ")[0].split("/");return{name:p[0],version:p[1]}}function A(e){if(u.existsSync(e))try{return JSON.parse(u.readFileSync(e,"utf8"))}catch(i){console.error(i)}}function O(e,i){u.writeFileSync(e,JSON.stringify(i,null,2)+`
|
|
2
|
+
`)}function Z(e){return u.existsSync(e)?u.readFileSync(e,"utf8"):""}function F(e,i){u.writeFileSync(e,i)}function C(e){u.existsSync(e)&&u.rmSync(e,{recursive:!0,force:!0})}function ye(e){u.existsSync(e)||u.mkdirSync(e,{recursive:!0})}var Le=$(ze(process.argv.slice(2),{string:["_"]})),he={repo:"https://github.com",owner:xe.userInfo().username};function ne(e){let{repo:i,owner:p}=e;return`${i}${i.endsWith("/")?"":"/"}${p}`}async function ve(e){let i=await te([{type:"text",name:"repo",message:G("Git repository url:"),initial:e?.repo||he.repo},{type:"text",name:"owner",message:G("Git repository owner:"),initial:e?.owner||he.owner}],{onCancel:()=>{throw console.log(D("\u2716")+" Operation cancelled"),new Error}});return{id:e?.id||Date.now().toString(),repo:i.repo,owner:i.owner}}var ke=we.join(xe.homedir(),".tomjs","create-app"),Se=we.join(ke,"config.json");function T(){return ye(ke),Object.assign({gitRepos:[]},A(Se))}function Ye(e){let i=T();i.createTime?i.updateTime=Date.now():i.createTime=Date.now(),O(Se,Object.assign(i,e))}function ee(e){Ye({gitRepos:e})}async function ie(){let{gitRepos:e}=T();(e.length===0||Le.git)&&(e.length===0&&console.log(`You need to set the ${Me("git remote repository")} for the first time.`),await i());async function i(){let p=e.map(y=>({title:ne(y),value:y.id})).concat([{title:"Add",value:"add"},{title:D("Exit"),value:"exit"}]),h=await te({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:p},{onCancel:()=>{throw console.log(D("\u2716")+" Operation cancelled"),new Error}}),{repoId:f}=h;if(f==="exit")return;if(f==="add"){let y=await ve();return e.push(y),ee(e),i()}let w=e.findIndex(y=>y.id===f),P=await te([{type:"select",name:"action",message:G("Select an action?"),choices:[{title:"Edit",value:"edit"},{title:"Remove",value:"remove"},{title:"Exit",value:"exit"}]},{type:y=>y==="remove"&&"toggle",name:"confirmRemove",message:G("Where confirm to remove?"),initial:!0,active:"Yes",inactive:"No"}],{onCancel:()=>{throw console.log(D("\u2716")+" Operation cancelled"),new Error}}),{action:E,confirmRemove:I}=P;if(E==="exit")return ie();if(E==="remove")return I&&(e.splice(w,1),ee(e)),i();let V=await ve(e[w]);return e[w]=V,ee(e),i()}}var re=$(Ze(process.argv.slice(2),{string:["_"]})),oe=process.cwd(),tt=["test","vite","examples"],$e=[{name:"node",display:"Node",color:be,options:[{id:"test",name:"Test"},{id:"publish",name:"Git Repository + NPM Publish",selected:!0},{id:"ssh",name:"Git init by SSH",selected:!0},{id:"tsup",name:"Use tsup build",selected:!0},{id:"vite",name:"Use vite build"},{id:"vite-plugin",name:"Vite Plugin"},{id:"examples",name:"Examples"},{id:"workspace",name:"Workspaces/Monorepo"}]},{name:"web",display:"Web App",color:U,variants:[{name:"vue",display:"Vue",color:U},{name:"react",display:"React",color:N}]},{name:"electron",display:"Electron App",color:N,variants:[{name:"electron-vue",display:"Vue",color:U},{name:"electron-react",display:"React",color:N}]},{name:"vscode",display:"VSCode Extension",color:qe,options:[{id:"publish",name:"Git Repository"},{id:"ssh",name:"Git init by SSH"}],variants:[{name:"vscode",display:"Base",color:be},{name:"vscode-vue",display:"Vue",color:U},{name:"vscode-react",display:"React",color:N}]}],Pe=$e.map(e=>e.variants&&e.variants.map(i=>i.name)||[e.name]).reduce((e,i)=>e.concat(i),[]),se="my-app";function Ee(e){let i=_.exec(`git config --get ${e}`,{silent:!0});if(i.code===0)return i.stdout.trim()}function Re(e){return e.length>1?e.substring(e.indexOf("/")+1):e}async function nt(){let e=q(re._[0]),i=re.template||re.t,p=e||se,h=()=>p==="."?l.basename(l.resolve()):p,f=Re(p),{gitRepos:w}=T(),P=await et([{type:e?null:"text",name:"projectName",message:x("Project name:"),initial:se,onState:t=>{p=q(t.value)||se,f=Re(p)}},{type:()=>!m.existsSync(f)||me(f)?null:"toggle",name:"overwrite",message:()=>(f==="."?"Current directory":`Target directory "${f}"`)+" is not empty. Remove existing files and continue?",initial:!1,active:"Yes",inactive:"No"},{type:(t,{overwrite:n})=>{if(n===!1)throw console.log(je("\u2716")+" Operation cancelled"),new Error;return null},name:"overwriteChecker"},{type:()=>X(h())?null:"text",name:"packageName",message:x("Package name:"),initial:()=>fe(h()),validate:t=>X(t)||"Invalid package.json name"},{type:i&&Pe.includes(i)?null:"select",name:"framework",message:typeof i=="string"&&!Pe.includes(i)?x(`"${i}" isn't a valid template. Please choose from below: `):x("Select a framework:"),initial:0,choices:$e.map(t=>{let n=t.color;return{title:n(t.display||t.name),value:t}})},{type:t=>t&&t.variants?"select":null,name:"variant",message:x("Select a variant:"),choices:t=>t?.variants?.map(n=>{let r=n.color;return{title:r(n.display||n.name),value:n.name}})},{type:(t,n)=>{let{framework:r}=n;return r&&Array.isArray(r.options)&&r.options.length?"multiselect":null},name:"options",message:x("Select optional options:"),instructions:!1,choices:(t,n)=>{let{framework:r}=n;return r?.options?.map(o=>({title:o.name,value:o.id,selected:o.selected||!1}))}},{type:(t,n)=>w.length&&Array.isArray(n.options)&&n.options.includes("publish")?"select":null,name:"gitUserUrl",message:x("Which git repository to publish to?"),choices:w.map(t=>{let n=ne(t);return{title:n,value:n}})}],{onCancel:()=>{throw console.log(je("\u2716")+" Operation cancelled"),new Error}}),{framework:E,overwrite:I,packageName:V,variant:y,gitUserUrl:k}=P,g=P.options||[],c=l.join(oe,f);I?ge(c):m.existsSync(c)||m.mkdirSync(c,{recursive:!0}),console.log(`
|
|
3
|
+
Scaffolding project in ${c}...`);let J=y||E?.name||i||"",W=t=>l.join(Ke(import.meta.url),"../..",`template-${t}`),Ae=W(J),M=J.includes("node");[W("config"),Ae].forEach(t=>{let n=m.readdirSync(t);for(let r of n){let o=r.startsWith("_")?r.replace("_","."):r;(M&&!g.includes("examples")||J==="vscode")&&r.includes("stylelint")||Q(l.join(t,r),l.join(c,o))}});let d=V||h(),z={name:Ee("user.name")||He.userInfo().username,email:Ee("user.email")||""},L={"pkg.name":d,"user.name":z.name,"user.email":z.email,"git.org":Y(),"git.url":Oe(),"git.fullUrl":ce()};function Oe(){return`${k||`https://github.com/${Y()}`}/${d.substring(d.indexOf("/")+1)}`}function Y(){return k?k.substring(k.lastIndexOf("/")+1):d.startsWith("@")?d.split("/")[0].substring(1):Xe(z.name)}function ce(t=!1){let n=k||`https://github.com/${Y()}`;return t&&(n=n.replace(/http(s):\/\//g,"git@").replace(/\//,":")),`${n}/${d.substring(d.indexOf("/")+1)}.git`}Ne(),M&&(De(),Ie(),Ve(),Je());let ae=de(process.env.npm_config_user_agent),B=ae?ae.name:"npm";_.which("git")&&(_.exec(`cd ${c} && git init`),g.includes("publish")&&_.exec(`cd ${c} && git remote add origin ${ce(g.includes("ssh"))}`));let H=l.relative(oe,c);switch(console.log(`
|
|
5
4
|
Done. Now run:
|
|
6
|
-
`),
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
`),c!==oe&&console.log(` cd ${H.includes(" ")?`"${H}"`:H}`),B){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${B} install`),console.log(` ${B} run dev`);break}function S(){return A(l.join(c,"package.json"))}function b(t){O(l.join(c,"package.json"),t)}function Fe(){return Z(l.join(c,"package.json"))}function Ce(t){F(l.join(c,"package.json"),t)}function De(){_e(".lintstagedrc.cjs","tsconfig.json");let t=g.find(r=>["vite-plugin"].includes(r))||["cli","plugin"].find(r=>d.includes(`-${r}`)),n=["pnpm","yarn","npm"].map(r=>`# ${r}
|
|
6
|
+
${r} add ${d}${t?" -D":""}`).join(`
|
|
7
|
+
|
|
8
|
+
`);["LICENSE","README.md","README.zh_CN.md"].forEach(r=>{let o=l.join(c,r);if(!g.includes("publish")&&m.existsSync(o)){m.rmSync(o),r==="README.md"&&m.writeFileSync(o,`# ${d}
|
|
9
|
+
`,{encoding:"utf-8"});return}if(!m.existsSync(o))return;let s=Object.assign({},L,{"pkg.install":n}),a=m.readFileSync(o,"utf-8");Object.keys(s).forEach(v=>{a=a.replace(new RegExp("{{"+v+"}}","g"),s[v])}),m.writeFileSync(o,a,"utf8")})}function j(t,...n){le(t.devDependencies,...n)}function Ge(t,...n){le(t.peerDependencies,...n)}function le(t,...n){function r(s,a){return s.includes("@")?s.replace("@","").split("/").find(v=>r(v,a)):a===s||s.includes(`-${a}`)||s.includes(`${a}-`)}let o=t||{};Object.keys(o||{}).forEach(s=>{n.find(a=>r(s,a))&&delete o[s]})}function R(...t){!Array.isArray(t)||t.length===0||t.forEach(n=>{let r=l.join(c,n);m.existsSync(r)&&C(r)})}function Te(t,n,r){let o=l.join(c,t),s=Z(o);s=s.replaceAll(n,r),F(o,s)}function Ne(){let t=S();t.name=d,g.includes("publish")||(delete t.author,delete t.publishConfig,delete t.repository,delete t.scripts.prepublishOnly,delete t.devDependencies.np),M&&(g.includes("vite")?(t.scripts.dev="vite",t.scripts.build="vite build",j(t,"tsup"),R("tsup.config.ts")):(t.scripts.dev="tsup --watch",t.scripts.build="tsup",R("vite.config.ts"),g.includes("vite-plugin")||(j(t,"vite"),Te("tsup.config.ts","'vite'",""))),g.includes("vite-plugin")||Ge(t,"vite")),b(t);let n=Fe();Object.keys(L).forEach(r=>{n=n.replace(new RegExp("{{"+r+"}}","g"),L[r])}),Ce(n)}function Ue(t,n){let r=t.lastIndexOf("."),o=t.substring(0,r)+"."+n+t.substring(r),s=l.join(c,t),a=l.join(c,o);m.existsSync(a)&&(g.includes(n)?(C(s),Be(a,s)):C(a))}function _e(...t){t.forEach(n=>{tt.forEach(r=>{Ue(n,r)})})}function Ie(){let t=S();if(g.includes("test")){g.includes("workspace")||R("vitest.workspace.ts");return}delete t.scripts.test,t.scripts["lint:eslint"]=t.scripts["lint:eslint"].replace(",test",""),j(t,"vitest"),b(t),R("test","vitest.workspace.ts")}function Ve(){if(!g.includes("examples")){let n=S();n.scripts.lint=n.scripts.lint.replace(" lint:stylelint",""),n.scripts["lint:eslint"]=n.scripts["lint:eslint"].replace(",examples",""),delete n.scripts["lint:stylelint"],j(n,"stylelint"),b(n);return}let t=l.join(c,"examples");m.mkdirSync(t),["vue","react"].forEach(n=>{let r=W(n),o=l.join(t,n);if(!m.existsSync(r)){console.log(`${Qe(r)} template is not exist`);return}m.cpSync(r,o,{recursive:!0});let s=S();Object.keys(s.scripts).forEach(a=>{(a.startsWith("lint")||["prepare"].includes(a))&&delete s.scripts[a]}),j(s,"eslint","prettier","stylelint","commitlint","husky","lint-staged","tsconfig","lint-staged","npm-run-all"),b(s),["_lintstagedrc.cjs"].forEach(a=>{let v=l.join(o,a);m.existsSync(v)&&m.rmSync(v,{recursive:!0})})})}function Je(){let t=[];g.includes("examples")&&t.push("examples");let n=S();g.includes("workspace")?(t.push("packages"),delete n.private,delete n.version,delete n.description,delete n.keywords,delete n.license,delete n.main,delete n.module,delete n.types,delete n.exports,delete n.files,delete n.publishConfig,delete n.repository):delete n.private,b(n),t.length&&F(l.join(c,"pnpm-workspace.yaml"),`packages:
|
|
10
|
+
${t.map(r=>` - '${r}/*'`).join(`
|
|
11
|
+
`)}`)}}ie().then(async()=>nt().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.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "create tomjs web app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tomjs",
|
|
@@ -50,26 +50,26 @@
|
|
|
50
50
|
"shelljs": "^0.8.5"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@commitlint/cli": "^
|
|
54
|
-
"@tomjs/commitlint": "^
|
|
55
|
-
"@tomjs/eslint": "^
|
|
53
|
+
"@commitlint/cli": "^19.2.1",
|
|
54
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
55
|
+
"@tomjs/eslint": "^2.3.0",
|
|
56
56
|
"@tomjs/prettier": "^1.3.0",
|
|
57
57
|
"@tomjs/stylelint": "^2.3.0",
|
|
58
|
-
"@tomjs/tsconfig": "^1.
|
|
58
|
+
"@tomjs/tsconfig": "^1.5.0",
|
|
59
59
|
"@types/lodash-es": "^4.17.12",
|
|
60
60
|
"@types/minimist": "^1.2.5",
|
|
61
|
-
"@types/node": "^18.19.
|
|
61
|
+
"@types/node": "^18.19.26",
|
|
62
62
|
"@types/prompts": "^2.4.9",
|
|
63
63
|
"@types/shelljs": "^0.8.15",
|
|
64
64
|
"cross-env": "^7.0.3",
|
|
65
65
|
"eslint": "^8.57.0",
|
|
66
66
|
"husky": "^9.0.11",
|
|
67
67
|
"lint-staged": "^15.2.2",
|
|
68
|
-
"np": "^
|
|
68
|
+
"np": "^10.0.1",
|
|
69
69
|
"npm-run-all": "^4.1.5",
|
|
70
70
|
"prettier": "^3.2.5",
|
|
71
71
|
"stylelint": "^16.2.1",
|
|
72
|
-
"tsup": "^8.0.
|
|
72
|
+
"tsup": "^8.0.2",
|
|
73
73
|
"typescript": "~5.3.3"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
@@ -20,25 +20,25 @@
|
|
|
20
20
|
"prepare": "husky"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@tomjs/electron-devtools-installer": "^2.1
|
|
23
|
+
"@tomjs/electron-devtools-installer": "^2.2.1",
|
|
24
24
|
"react": "^18.2.0",
|
|
25
25
|
"react-dom": "^18.2.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@commitlint/cli": "^
|
|
29
|
-
"@tomjs/commitlint": "^
|
|
30
|
-
"@tomjs/eslint": "^
|
|
28
|
+
"@commitlint/cli": "^19.2.1",
|
|
29
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
30
|
+
"@tomjs/eslint": "^2.3.0",
|
|
31
31
|
"@tomjs/prettier": "^1.3.0",
|
|
32
32
|
"@tomjs/stylelint": "^2.3.0",
|
|
33
|
-
"@tomjs/tsconfig": "^1.
|
|
33
|
+
"@tomjs/tsconfig": "^1.5.0",
|
|
34
34
|
"@tomjs/vite-plugin-electron": "^1.9.0",
|
|
35
|
-
"@types/node": "^18.19.
|
|
36
|
-
"@types/react": "^18.2.
|
|
37
|
-
"@types/react-dom": "^18.2.
|
|
35
|
+
"@types/node": "^18.19.26",
|
|
36
|
+
"@types/react": "^18.2.67",
|
|
37
|
+
"@types/react-dom": "^18.2.22",
|
|
38
38
|
"@vitejs/plugin-react-swc": "^3.6.0",
|
|
39
39
|
"cross-env": "^7.0.3",
|
|
40
|
-
"electron": "^28.2.
|
|
41
|
-
"electron-builder": "^24.
|
|
40
|
+
"electron": "^28.2.8",
|
|
41
|
+
"electron-builder": "^24.13.3",
|
|
42
42
|
"eslint": "^8.57.0",
|
|
43
43
|
"husky": "^9.0.11",
|
|
44
44
|
"lint-staged": "^15.2.2",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"stylelint": "^16.2.1",
|
|
49
49
|
"tsx": "^4.7.1",
|
|
50
50
|
"typescript": "~5.3.3",
|
|
51
|
-
"vite": "^5.
|
|
51
|
+
"vite": "^5.2.2",
|
|
52
52
|
"vite-plugin-electron-renderer": "^0.14.5"
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -20,22 +20,22 @@
|
|
|
20
20
|
"prepare": "husky"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@tomjs/electron-devtools-installer": "^2.1
|
|
24
|
-
"vue": "
|
|
23
|
+
"@tomjs/electron-devtools-installer": "^2.2.1",
|
|
24
|
+
"vue": "^3.4.21"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@commitlint/cli": "^
|
|
28
|
-
"@tomjs/commitlint": "^
|
|
29
|
-
"@tomjs/eslint": "^
|
|
27
|
+
"@commitlint/cli": "^19.2.1",
|
|
28
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
29
|
+
"@tomjs/eslint": "^2.3.0",
|
|
30
30
|
"@tomjs/prettier": "^1.3.0",
|
|
31
31
|
"@tomjs/stylelint": "^2.3.0",
|
|
32
|
-
"@tomjs/tsconfig": "^1.
|
|
32
|
+
"@tomjs/tsconfig": "^1.5.0",
|
|
33
33
|
"@tomjs/vite-plugin-electron": "^1.9.0",
|
|
34
|
-
"@types/node": "^18.19.
|
|
34
|
+
"@types/node": "^18.19.26",
|
|
35
35
|
"@vitejs/plugin-vue": "^5.0.4",
|
|
36
36
|
"cross-env": "^7.0.3",
|
|
37
|
-
"electron": "^28.2.
|
|
38
|
-
"electron-builder": "^24.
|
|
37
|
+
"electron": "^28.2.8",
|
|
38
|
+
"electron-builder": "^24.13.3",
|
|
39
39
|
"eslint": "^8.57.0",
|
|
40
40
|
"husky": "^9.0.11",
|
|
41
41
|
"lint-staged": "^15.2.2",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"stylelint": "^16.2.1",
|
|
46
46
|
"tsx": "^4.7.1",
|
|
47
47
|
"typescript": "~5.3.3",
|
|
48
|
-
"vite": "^5.
|
|
48
|
+
"vite": "^5.2.2",
|
|
49
49
|
"vite-plugin-electron-renderer": "^0.14.5",
|
|
50
|
-
"vue-tsc": "^
|
|
50
|
+
"vue-tsc": "^2.0.7"
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "{{pkg.name}}",
|
|
3
|
+
"private": true,
|
|
3
4
|
"version": "0.0.0",
|
|
4
5
|
"description": "basic node.js template",
|
|
5
6
|
"keywords": [
|
|
@@ -44,40 +45,32 @@
|
|
|
44
45
|
"lint:stylelint": "stylelint \"examples/**/*.{css,scss,less,vue,html}\" --fix --cache",
|
|
45
46
|
"lint:prettier": "prettier --write .",
|
|
46
47
|
"prepare": "husky",
|
|
47
|
-
"prepublishOnly": "npm run build && np --any-branch --
|
|
48
|
-
},
|
|
49
|
-
"dependencies": {
|
|
50
|
-
"kolorist": "^1.8.0"
|
|
48
|
+
"prepublishOnly": "npm run build && np --any-branch --yolo --no-publish --message \"chore: release v%s\""
|
|
51
49
|
},
|
|
50
|
+
"dependencies": {},
|
|
52
51
|
"devDependencies": {
|
|
53
|
-
"@commitlint/cli": "^
|
|
54
|
-
"@
|
|
55
|
-
"@
|
|
56
|
-
"@tomjs/commitlint": "^2.3.0",
|
|
57
|
-
"@tomjs/eslint": "^1.5.0",
|
|
52
|
+
"@commitlint/cli": "^19.2.1",
|
|
53
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
54
|
+
"@tomjs/eslint": "^2.3.0",
|
|
58
55
|
"@tomjs/prettier": "^1.3.0",
|
|
59
56
|
"@tomjs/stylelint": "^2.3.0",
|
|
60
|
-
"@tomjs/tsconfig": "^1.
|
|
61
|
-
"@types/
|
|
62
|
-
"@types/node": "^18.19.19",
|
|
57
|
+
"@tomjs/tsconfig": "^1.5.0",
|
|
58
|
+
"@types/node": "^18.19.26",
|
|
63
59
|
"cross-env": "^7.0.3",
|
|
64
|
-
"electron": "^28.2.4",
|
|
65
60
|
"eslint": "^8.57.0",
|
|
66
61
|
"husky": "^9.0.11",
|
|
67
|
-
"jest": "^29.7.0",
|
|
68
62
|
"lint-staged": "^15.2.2",
|
|
69
|
-
"np": "^
|
|
63
|
+
"np": "^10.0.1",
|
|
70
64
|
"npm-run-all": "^4.1.5",
|
|
71
65
|
"prettier": "^3.2.5",
|
|
72
66
|
"rimraf": "^5.0.5",
|
|
73
67
|
"stylelint": "^16.2.1",
|
|
74
|
-
"
|
|
75
|
-
"tsup": "^8.0.1",
|
|
68
|
+
"tsup": "^8.0.2",
|
|
76
69
|
"tsx": "^4.7.1",
|
|
77
70
|
"typescript": "~5.3.3",
|
|
78
|
-
"vite": "^5.
|
|
79
|
-
"vite-plugin-dts": "^3.7.
|
|
80
|
-
"vitest": "^1.
|
|
71
|
+
"vite": "^5.2.2",
|
|
72
|
+
"vite-plugin-dts": "^3.7.3",
|
|
73
|
+
"vitest": "^1.4.0"
|
|
81
74
|
},
|
|
82
75
|
"peerDependencies": {
|
|
83
76
|
"vite": ">=2.0.0"
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
|
-
import { blue } from 'kolorist';
|
|
3
2
|
|
|
4
3
|
function run() {
|
|
5
|
-
console.log(blue('Hello World!'));
|
|
6
4
|
console.log(
|
|
7
5
|
`system: ${os.platform()} ${os.arch()} v${os.release()} ${os.cpus().length} cores ${Math.ceil(
|
|
8
6
|
os.totalmem() / 1024 / 1024 / 1024,
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"react-dom": "^18.2.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@commitlint/cli": "^
|
|
25
|
-
"@tomjs/commitlint": "^
|
|
26
|
-
"@tomjs/eslint": "^
|
|
24
|
+
"@commitlint/cli": "^19.2.1",
|
|
25
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
26
|
+
"@tomjs/eslint": "^2.3.0",
|
|
27
27
|
"@tomjs/prettier": "^1.3.0",
|
|
28
28
|
"@tomjs/stylelint": "^2.3.0",
|
|
29
|
-
"@tomjs/tsconfig": "^1.
|
|
30
|
-
"@types/node": "^18.19.
|
|
31
|
-
"@types/react": "^18.2.
|
|
32
|
-
"@types/react-dom": "^18.2.
|
|
29
|
+
"@tomjs/tsconfig": "^1.5.0",
|
|
30
|
+
"@types/node": "^18.19.26",
|
|
31
|
+
"@types/react": "^18.2.67",
|
|
32
|
+
"@types/react-dom": "^18.2.22",
|
|
33
33
|
"@vitejs/plugin-react-swc": "^3.6.0",
|
|
34
34
|
"cross-env": "^7.0.3",
|
|
35
35
|
"eslint": "^8.57.0",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"prettier": "^3.2.5",
|
|
40
40
|
"stylelint": "^16.2.1",
|
|
41
41
|
"typescript": "~5.3.3",
|
|
42
|
-
"vite": "^5.
|
|
42
|
+
"vite": "^5.2.2"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
"categories": [
|
|
17
17
|
"Other"
|
|
18
18
|
],
|
|
19
|
-
"activationEvents": [
|
|
20
|
-
"onCommand:hello-world.showHelloWorld"
|
|
21
|
-
],
|
|
19
|
+
"activationEvents": [],
|
|
22
20
|
"contributes": {
|
|
23
21
|
"commands": [
|
|
24
22
|
{
|
|
@@ -49,12 +47,12 @@
|
|
|
49
47
|
"prepare": "husky"
|
|
50
48
|
},
|
|
51
49
|
"devDependencies": {
|
|
52
|
-
"@commitlint/cli": "^
|
|
53
|
-
"@tomjs/commitlint": "^
|
|
54
|
-
"@tomjs/eslint": "^
|
|
50
|
+
"@commitlint/cli": "^19.2.1",
|
|
51
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
52
|
+
"@tomjs/eslint": "^2.3.0",
|
|
55
53
|
"@tomjs/prettier": "^1.3.0",
|
|
56
|
-
"@tomjs/tsconfig": "^1.
|
|
57
|
-
"@types/node": "^18.19.
|
|
54
|
+
"@tomjs/tsconfig": "^1.5.0",
|
|
55
|
+
"@types/node": "^18.19.26",
|
|
58
56
|
"@types/vscode": "^1.75.0",
|
|
59
57
|
"eslint": "^8.57.0",
|
|
60
58
|
"husky": "^9.0.11",
|
|
@@ -62,7 +60,7 @@
|
|
|
62
60
|
"npm-run-all": "^4.1.5",
|
|
63
61
|
"prettier": "^3.2.5",
|
|
64
62
|
"rimraf": "^5.0.5",
|
|
65
|
-
"tsup": "^8.0.
|
|
63
|
+
"tsup": "^8.0.2",
|
|
66
64
|
"typescript": "~5.3.3"
|
|
67
65
|
}
|
|
68
66
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ExtensionContext } from 'vscode';
|
|
2
|
+
import { commands, window } from 'vscode';
|
|
2
3
|
|
|
3
4
|
export function activate(context: ExtensionContext) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// Add command to the extension context
|
|
10
|
-
context.subscriptions.push(showHelloWorldCommand);
|
|
5
|
+
context.subscriptions.push(
|
|
6
|
+
commands.registerCommand('hello-world.showHelloWorld', async () => {
|
|
7
|
+
window.showInformationMessage('Hello World');
|
|
8
|
+
}),
|
|
9
|
+
);
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
export function deactivate() {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="@tomjs/vite-plugin-vscode/env" />
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ExtensionContext } from 'vscode';
|
|
2
|
+
import { commands } from 'vscode';
|
|
3
|
+
import { MainPanel } from './views/panel';
|
|
3
4
|
|
|
4
5
|
export function activate(context: ExtensionContext) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// Add command to the extension context
|
|
11
|
-
context.subscriptions.push(showHelloWorldCommand);
|
|
6
|
+
context.subscriptions.push(
|
|
7
|
+
commands.registerCommand('hello-world.showHelloWorld', async () => {
|
|
8
|
+
MainPanel.render(context.extensionUri);
|
|
9
|
+
}),
|
|
10
|
+
);
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export function deactivate() {}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Disposable, ExtensionContext, Webview } from 'vscode';
|
|
2
|
+
import { window } from 'vscode';
|
|
3
|
+
|
|
4
|
+
export class WebviewHelper {
|
|
5
|
+
public static setupHtml(webview: Webview, context: ExtensionContext) {
|
|
6
|
+
return process.env.VITE_DEV_SERVER_URL
|
|
7
|
+
? __getWebviewHtml__(process.env.VITE_DEV_SERVER_URL)
|
|
8
|
+
: __getWebviewHtml__(webview, context);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public static setupWebviewHooks(webview: Webview, disposables: Disposable[]) {
|
|
12
|
+
webview.onDidReceiveMessage(
|
|
13
|
+
(message: any) => {
|
|
14
|
+
const command = message.command;
|
|
15
|
+
const text = message.text;
|
|
16
|
+
console.log(`command: ${command}`);
|
|
17
|
+
switch (command) {
|
|
18
|
+
case 'hello':
|
|
19
|
+
window.showInformationMessage(text);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
undefined,
|
|
24
|
+
disposables,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Disposable, ExtensionContext, WebviewPanel } from 'vscode';
|
|
2
|
+
import { ViewColumn, window } from 'vscode';
|
|
3
|
+
import { WebviewHelper } from './helper';
|
|
4
|
+
|
|
5
|
+
export class MainPanel {
|
|
6
|
+
public static currentPanel: MainPanel | undefined;
|
|
7
|
+
private readonly _panel: WebviewPanel;
|
|
8
|
+
private _disposables: Disposable[] = [];
|
|
9
|
+
|
|
10
|
+
private constructor(panel: WebviewPanel, context: ExtensionContext) {
|
|
11
|
+
this._panel = panel;
|
|
12
|
+
|
|
13
|
+
this._panel.onDidDispose(() => this.dispose(), null, this._disposables);
|
|
14
|
+
this._panel.webview.html = WebviewHelper.setupHtml(this._panel.webview, context);
|
|
15
|
+
|
|
16
|
+
WebviewHelper.setupWebviewHooks(this._panel.webview, this._disposables);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public static render(context: ExtensionContext) {
|
|
20
|
+
if (MainPanel.currentPanel) {
|
|
21
|
+
MainPanel.currentPanel._panel.reveal(ViewColumn.One);
|
|
22
|
+
} else {
|
|
23
|
+
const panel = window.createWebviewPanel('showHelloWorld', 'Hello World', ViewColumn.One, {
|
|
24
|
+
enableScripts: true,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
MainPanel.currentPanel = new MainPanel(panel, context);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Cleans up and disposes of webview resources when the webview panel is closed.
|
|
33
|
+
*/
|
|
34
|
+
public dispose() {
|
|
35
|
+
MainPanel.currentPanel = undefined;
|
|
36
|
+
|
|
37
|
+
// Dispose of the current webview panel
|
|
38
|
+
this._panel.dispose();
|
|
39
|
+
|
|
40
|
+
// Dispose of all disposables (i.e. commands) for the current webview panel
|
|
41
|
+
while (this._disposables.length) {
|
|
42
|
+
const disposable = this._disposables.pop();
|
|
43
|
+
if (disposable) {
|
|
44
|
+
disposable.dispose();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
"categories": [
|
|
17
17
|
"Other"
|
|
18
18
|
],
|
|
19
|
-
"activationEvents": [
|
|
20
|
-
"onCommand:hello-world.showHelloWorld"
|
|
21
|
-
],
|
|
19
|
+
"activationEvents": [],
|
|
22
20
|
"contributes": {
|
|
23
21
|
"commands": [
|
|
24
22
|
{
|
|
@@ -56,17 +54,16 @@
|
|
|
56
54
|
"react-dom": "^18.2.0"
|
|
57
55
|
},
|
|
58
56
|
"devDependencies": {
|
|
59
|
-
"@commitlint/cli": "^
|
|
60
|
-
"@tomjs/commitlint": "^
|
|
61
|
-
"@tomjs/eslint": "^
|
|
57
|
+
"@commitlint/cli": "^19.2.1",
|
|
58
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
59
|
+
"@tomjs/eslint": "^2.3.0",
|
|
62
60
|
"@tomjs/prettier": "^1.3.0",
|
|
63
61
|
"@tomjs/stylelint": "^2.3.0",
|
|
64
|
-
"@tomjs/tsconfig": "^1.
|
|
65
|
-
"@tomjs/vite-plugin-vscode": "^2.
|
|
66
|
-
"@
|
|
67
|
-
"@types/
|
|
68
|
-
"@types/react": "^18.2.
|
|
69
|
-
"@types/react-dom": "^18.2.18",
|
|
62
|
+
"@tomjs/tsconfig": "^1.5.0",
|
|
63
|
+
"@tomjs/vite-plugin-vscode": "^2.2.0",
|
|
64
|
+
"@types/node": "^18.19.26",
|
|
65
|
+
"@types/react": "^18.2.67",
|
|
66
|
+
"@types/react-dom": "^18.2.22",
|
|
70
67
|
"@types/vscode": "^1.75.0",
|
|
71
68
|
"@types/vscode-webview": "^1.57.5",
|
|
72
69
|
"@vitejs/plugin-react-swc": "^3.6.0",
|
|
@@ -80,6 +77,6 @@
|
|
|
80
77
|
"stylelint": "^16.2.1",
|
|
81
78
|
"tsx": "^4.7.1",
|
|
82
79
|
"typescript": "~5.3.3",
|
|
83
|
-
"vite": "^5.
|
|
80
|
+
"vite": "^5.2.2"
|
|
84
81
|
}
|
|
85
82
|
}
|
|
@@ -13,7 +13,6 @@ class VSCodeAPIWrapper {
|
|
|
13
13
|
private readonly vsCodeApi: WebviewApi<unknown> | undefined;
|
|
14
14
|
|
|
15
15
|
constructor() {
|
|
16
|
-
console.log(typeof acquireVsCodeApi);
|
|
17
16
|
// Check if the acquireVsCodeApi function exists in the current development
|
|
18
17
|
// context (i.e. VS Code development window or web browser)
|
|
19
18
|
if (typeof acquireVsCodeApi === 'function') {
|