@tomjs/create-app 0.11.4 → 0.12.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.
Files changed (29) hide show
  1. package/dist/index.mjs +7 -7
  2. package/package.json +12 -12
  3. package/template-electron-react/package.json +16 -16
  4. package/template-electron-react/vite.config.ts +0 -1
  5. package/template-electron-vue/package.json +15 -15
  6. package/template-electron-vue/vite.config.ts +0 -1
  7. package/template-node/package.json +22 -18
  8. package/template-node/test/electron.test.ts +7 -0
  9. package/template-node/tsup.config.ts +2 -0
  10. package/template-node/vite.config.ts +42 -0
  11. package/template-react/package.json +15 -15
  12. package/template-vscode/package.json +22 -16
  13. package/template-vscode/package.nls.json +4 -0
  14. package/template-vscode/package.nls.zh-cn.json +4 -0
  15. package/template-vscode-react/extension/panels/MainPanel.ts +4 -7
  16. package/template-vscode-react/package.json +30 -22
  17. package/template-vscode-react/package.nls.json +4 -0
  18. package/template-vscode-react/package.nls.zh-cn.json +4 -0
  19. package/template-vscode-react/vite.config.ts +0 -1
  20. package/template-vscode-vue/extension/panels/MainPanel.ts +4 -7
  21. package/template-vscode-vue/package.json +29 -20
  22. package/template-vscode-vue/package.nls.json +4 -0
  23. package/template-vscode-vue/package.nls.zh-cn.json +4 -0
  24. package/template-vscode-vue/vite.config.ts +10 -2
  25. package/template-vue/package.json +14 -14
  26. package/template-node/tsup.config.vite.ts +0 -15
  27. /package/template-vscode/{images/icon.png → resources/logo.png} +0 -0
  28. /package/template-vscode-react/{images/icon.png → resources/logo.png} +0 -0
  29. /package/template-vscode-vue/{images/icon.png → resources/logo.png} +0 -0
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import s,{renameSync as Ie}from"fs";import Ve from"os";import c from"path";import{fileURLToPath as Je}from"url";import{lightBlue as C,lightCyan as Me,lightGreen as D,lightYellow as Se,red as we,reset as w,yellow as We}from"kolorist";import{camelCase as ze}from"lodash-es";import Le from"minimist";import Ye from"prompts";import G from"shelljs";import ye from"os";import he from"path";import{blue as Te,red as $,reset as O}from"kolorist";import Ne from"minimist";import q from"prompts";import p from"fs";import L from"path";function R(e){return[["t","template"],["g","git"]].forEach(([r,l])=>{e[l]=e[l]??e[r]}),e}function ae(e){return p.readdirSync(e).length===0}function Y(e){return e?.trim().replace(/\/+$/g,"")}function Ge(e,r){p.mkdirSync(r,{recursive:!0});for(let l of p.readdirSync(e)){let x=L.resolve(e,l),g=L.resolve(r,l);B(x,g)}}function B(e,r){p.statSync(e).isDirectory()?Ge(e,r):p.copyFileSync(e,r)}function le(e){if(p.existsSync(e))for(let r of p.readdirSync(e))p.rmSync(L.resolve(e,r),{recursive:!0,force:!0})}function H(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function pe(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function me(e){if(!e)return;let l=e.split(" ")[0].split("/");return{name:l[0],version:l[1]}}function S(e){if(p.existsSync(e))try{return JSON.parse(p.readFileSync(e,"utf8"))}catch(r){console.error(r)}}function v(e,r){p.writeFileSync(e,JSON.stringify(r,null,2)+`
3
- `)}function ue(e){return p.existsSync(e)?p.readFileSync(e,"utf8"):""}function A(e){p.existsSync(e)&&p.rmSync(e,{recursive:!0,force:!0})}function ge(e){p.existsSync(e)||p.mkdirSync(e,{recursive:!0})}var _e=R(Ne(process.argv.slice(2),{string:["_"]})),fe={repo:"https://github.com",owner:ye.userInfo().username};function Q(e){let{repo:r,owner:l}=e;return`${r}${r.endsWith("/")?"":"/"}${l}`}async function de(e){let r=await q([{type:"text",name:"repo",message:O("Git repository url:"),initial:e?.repo||fe.repo},{type:"text",name:"owner",message:O("Git repository owner:"),initial:e?.owner||fe.owner}],{onCancel:()=>{throw console.log($("\u2716")+" Operation cancelled"),new Error}});return{id:e?.id||Date.now().toString(),repo:r.repo,owner:r.owner}}var ve=he.join(ye.homedir(),".tomjs","create-app"),xe=he.join(ve,"config.json");function F(){return ge(ve),Object.assign({gitRepos:[]},S(xe))}function Ue(e){let r=F();r.createTime?r.updateTime=Date.now():r.createTime=Date.now(),v(xe,Object.assign(r,e))}function K(e){Ue({gitRepos:e})}async function X(){let{gitRepos:e}=F();(e.length===0||_e.git)&&(e.length===0&&console.log(`You need to set the ${Te("git remote repository")} for the first time.`),await r());async function r(){let l=e.map(y=>({title:Q(y),value:y.id})).concat([{title:"Add",value:"add"},{title:$("Exit"),value:"exit"}]),x=await q({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:l},{onCancel:()=>{throw console.log($("\u2716")+" Operation cancelled"),new Error}}),{repoId:g}=x;if(g==="exit")return;if(g==="add"){let y=await de();return e.push(y),K(e),r()}let j=e.findIndex(y=>y.id===g),E=await q([{type:"select",name:"action",message:O("Select an action?"),choices:[{title:"Edit",value:"edit"},{title:"Remove",value:"remove"},{title:"Exit",value:"exit"}]},{type:y=>y==="remove"&&"toggle",name:"confirmRemove",message:O("Where confirm to remove?"),initial:!0,active:"Yes",inactive:"No"}],{onCancel:()=>{throw console.log($("\u2716")+" Operation cancelled"),new Error}}),{action:P,confirmRemove:T}=E;if(P==="exit")return X();if(P==="remove")return T&&(e.splice(j,1),K(e)),r();let N=await de(e[j]);return e[j]=N,K(e),r()}}var Z=R(Le(process.argv.slice(2),{string:["_"]})),ee=process.cwd(),Be=["test","vite","electron","examples"],Ee=[{name:"web",display:"Web App",color:D,variants:[{name:"vue",display:"Vue",color:D},{name:"react",display:"React",color:C}]},{name:"electron",display:"Electron App",color:C,variants:[{name:"electron-vue",display:"Vue",color:D},{name:"electron-react",display:"React",color:C}]},{name:"vscode",display:"VSCode Extension",color:Me,options:[{id:"publish",name:"Git Repository"},{id:"ssh",name:"Git init by SSH"}],variants:[{name:"vscode",display:"Base",color:Se},{name:"vscode-vue",display:"Vue",color:D},{name:"vscode-react",display:"React",color:C}]},{name:"node",display:"Node",color:Se,options:[{id:"test",name:"Test"},{id:"publish",name:"Git Repository + NPM Publish"},{id:"ssh",name:"Git init by SSH"},{id:"vite",name:"Vite Plugin"},{id:"electron",name:"Electron"},{id:"examples",name:"Examples"}]}],je=Ee.map(e=>e.variants&&e.variants.map(r=>r.name)||[e.name]).reduce((e,r)=>e.concat(r),[]),te="my-app";function ke(e){let r=G.exec(`git config --get ${e}`,{silent:!0});if(r.code===0)return r.stdout.trim()}function be(e){return e.length>1?e.substring(e.indexOf("/")+1):e}async function He(){let e=Y(Z._[0]),r=Z.template||Z.t,l=e||te,x=()=>l==="."?c.basename(c.resolve()):l,g=be(l),{gitRepos:j}=F(),E=await Ye([{type:e?null:"text",name:"projectName",message:w("Project name:"),initial:te,onState:t=>{l=Y(t.value)||te,g=be(l)}},{type:()=>!s.existsSync(g)||ae(g)?null:"toggle",name:"overwrite",message:()=>(g==="."?"Current directory":`Target directory "${g}"`)+" is not empty. Remove existing files and continue?",initial:!1,active:"Yes",inactive:"No"},{type:(t,{overwrite:n})=>{if(n===!1)throw console.log(we("\u2716")+" Operation cancelled"),new Error;return null},name:"overwriteChecker"},{type:()=>H(x())?null:"text",name:"packageName",message:w("Package name:"),initial:()=>pe(x()),validate:t=>H(t)||"Invalid package.json name"},{type:r&&je.includes(r)?null:"select",name:"framework",message:typeof r=="string"&&!je.includes(r)?w(`"${r}" isn't a valid template. Please choose from below: `):w("Select a framework:"),initial:0,choices:Ee.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:w("Select a variant:"),choices:t=>t?.variants?.map(n=>{let i=n.color;return{title:i(n.display||n.name),value:n.name}})},{type:(t,n)=>{let{framework:i}=n;return i&&Array.isArray(i.options)&&i.options.length?"multiselect":null},name:"options",message:w("Select optional options:"),instructions:!1,choices:(t,n)=>{let{framework:i}=n;return i?.options?.map(o=>({title:o.name,value:o.id}))}},{type:(t,n)=>j.length&&Array.isArray(n.options)&&n.options.includes("publish")?"select":null,name:"gitUserUrl",message:w("Which git repository to publish to?"),choices:j.map(t=>{let n=Q(t);return{title:n,value:n}})}],{onCancel:()=>{throw console.log(we("\u2716")+" Operation cancelled"),new Error}}),{framework:P,overwrite:T,packageName:N,variant:y,gitUserUrl:b}=E,u=E.options||[],a=c.join(ee,g);T?le(a):s.existsSync(a)||s.mkdirSync(a,{recursive:!0}),console.log(`
4
- Scaffolding project in ${a}...`);let _=y||P?.name||r||"",U=t=>c.join(Je(import.meta.url),"../..",`template-${t}`),Pe=U(_),I=_.includes("node");[Pe,U("config")].forEach(t=>{let n=s.readdirSync(t);for(let i of n){let o=i.startsWith("_")?i.replace("_","."):i;if((I&&!u.includes("examples")||_==="vscode")&&i.includes("stylelint"))continue;let m=c.join(a,o);B(c.join(t,i),m)}});let f=N||x(),V={name:ke("user.name")||Ve.userInfo().username,email:ke("user.email")||""},J={"pkg.name":f,"user.name":V.name,"user.email":V.email,"git.org":M(),"git.url":Re(),"git.fullUrl":ne()};function Re(){return`${b||`https://github.com/${M()}`}/${f.substring(f.indexOf("/")+1)}`}function M(){return b?b.substring(b.lastIndexOf("/")+1):f.startsWith("@")?f.split("/")[0].substring(1):ze(V.name)}function ne(t=!1){let n=b||`https://github.com/${M()}`;return t&&(n=n.replace(/http(s):\/\//g,"git@").replace(/\//,":")),`${n}/${f.substring(f.indexOf("/")+1)}.git`}$e(),I&&(Ae(),Ce(),De());let ie=me(process.env.npm_config_user_agent),W=ie?ie.name:"npm";G.which("git")&&(G.exec(`cd ${a} && git init`),u.includes("publish")&&G.exec(`cd ${a} && git remote add origin ${ne(u.includes("ssh"))}`));let z=c.relative(ee,a);switch(console.log(`
2
+ import l,{renameSync as Ie}from"fs";import Ve from"os";import s from"path";import{fileURLToPath as Je}from"url";import{lightBlue as D,lightCyan as Me,lightGreen as G,lightYellow as we,red as Se,reset as j,yellow as We}from"kolorist";import{camelCase as ze}from"lodash-es";import Le from"minimist";import Ye from"prompts";import T from"shelljs";import ye from"os";import he from"path";import{blue as Te,red as O,reset as F}from"kolorist";import Ne from"minimist";import Q from"prompts";import p from"fs";import Y from"path";function A(e){return[["t","template"],["g","git"]].forEach(([i,c])=>{e[c]=e[c]??e[i]}),e}function ae(e){return p.readdirSync(e).length===0}function B(e){return e?.trim().replace(/\/+$/g,"")}function Ge(e,i){p.mkdirSync(i,{recursive:!0});for(let c of p.readdirSync(e)){let w=Y.resolve(e,c),g=Y.resolve(i,c);H(w,g)}}function H(e,i){p.statSync(e).isDirectory()?Ge(e,i):p.copyFileSync(e,i)}function le(e){if(p.existsSync(e))for(let i of p.readdirSync(e))p.rmSync(Y.resolve(e,i),{recursive:!0,force:!0})}function K(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function pe(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function me(e){if(!e)return;let c=e.split(" ")[0].split("/");return{name:c[0],version:c[1]}}function S(e){if(p.existsSync(e))try{return JSON.parse(p.readFileSync(e,"utf8"))}catch(i){console.error(i)}}function h(e,i){p.writeFileSync(e,JSON.stringify(i,null,2)+`
3
+ `)}function ue(e){return p.existsSync(e)?p.readFileSync(e,"utf8"):""}function $(e){p.existsSync(e)&&p.rmSync(e,{recursive:!0,force:!0})}function ge(e){p.existsSync(e)||p.mkdirSync(e,{recursive:!0})}var Ue=A(Ne(process.argv.slice(2),{string:["_"]})),fe={repo:"https://github.com",owner:ye.userInfo().username};function X(e){let{repo:i,owner:c}=e;return`${i}${i.endsWith("/")?"":"/"}${c}`}async function de(e){let i=await Q([{type:"text",name:"repo",message:F("Git repository url:"),initial:e?.repo||fe.repo},{type:"text",name:"owner",message:F("Git repository owner:"),initial:e?.owner||fe.owner}],{onCancel:()=>{throw console.log(O("\u2716")+" Operation cancelled"),new Error}});return{id:e?.id||Date.now().toString(),repo:i.repo,owner:i.owner}}var ve=he.join(ye.homedir(),".tomjs","create-app"),xe=he.join(ve,"config.json");function C(){return ge(ve),Object.assign({gitRepos:[]},S(xe))}function _e(e){let i=C();i.createTime?i.updateTime=Date.now():i.createTime=Date.now(),h(xe,Object.assign(i,e))}function q(e){_e({gitRepos:e})}async function Z(){let{gitRepos:e}=C();(e.length===0||Ue.git)&&(e.length===0&&console.log(`You need to set the ${Te("git remote repository")} for the first time.`),await i());async function i(){let c=e.map(y=>({title:X(y),value:y.id})).concat([{title:"Add",value:"add"},{title:O("Exit"),value:"exit"}]),w=await Q({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(O("\u2716")+" Operation cancelled"),new Error}}),{repoId:g}=w;if(g==="exit")return;if(g==="add"){let y=await de();return e.push(y),q(e),i()}let k=e.findIndex(y=>y.id===g),P=await Q([{type:"select",name:"action",message:F("Select an action?"),choices:[{title:"Edit",value:"edit"},{title:"Remove",value:"remove"},{title:"Exit",value:"exit"}]},{type:y=>y==="remove"&&"toggle",name:"confirmRemove",message:F("Where confirm to remove?"),initial:!0,active:"Yes",inactive:"No"}],{onCancel:()=>{throw console.log(O("\u2716")+" Operation cancelled"),new Error}}),{action:R,confirmRemove:N}=P;if(R==="exit")return Z();if(R==="remove")return N&&(e.splice(k,1),q(e)),i();let U=await de(e[k]);return e[k]=U,q(e),i()}}var ee=A(Le(process.argv.slice(2),{string:["_"]})),te=process.cwd(),Be=["test","vite","electron","examples"],Ee=[{name:"web",display:"Web App",color:G,variants:[{name:"vue",display:"Vue",color:G},{name:"react",display:"React",color:D}]},{name:"electron",display:"Electron App",color:D,variants:[{name:"electron-vue",display:"Vue",color:G},{name:"electron-react",display:"React",color:D}]},{name:"vscode",display:"VSCode Extension",color:Me,options:[{id:"publish",name:"Git Repository"},{id:"ssh",name:"Git init by SSH"}],variants:[{name:"vscode",display:"Base",color:we},{name:"vscode-vue",display:"Vue",color:G},{name:"vscode-react",display:"React",color:D}]},{name:"node",display:"Node",color:we,options:[{id:"test",name:"Test"},{id:"publish",name:"Git Repository + NPM Publish"},{id:"ssh",name:"Git init by SSH"},{id:"vite",name:"Vite Plugin"},{id:"tsup",name:"Use tsup build"},{id:"electron",name:"Electron"},{id:"examples",name:"Examples"}]}],je=Ee.map(e=>e.variants&&e.variants.map(i=>i.name)||[e.name]).reduce((e,i)=>e.concat(i),[]),ne="my-app";function ke(e){let i=T.exec(`git config --get ${e}`,{silent:!0});if(i.code===0)return i.stdout.trim()}function be(e){return e.length>1?e.substring(e.indexOf("/")+1):e}async function He(){let e=B(ee._[0]),i=ee.template||ee.t,c=e||ne,w=()=>c==="."?s.basename(s.resolve()):c,g=be(c),{gitRepos:k}=C(),P=await Ye([{type:e?null:"text",name:"projectName",message:j("Project name:"),initial:ne,onState:n=>{c=B(n.value)||ne,g=be(c)}},{type:()=>!l.existsSync(g)||ae(g)?null:"toggle",name:"overwrite",message:()=>(g==="."?"Current directory":`Target directory "${g}"`)+" is not empty. Remove existing files and continue?",initial:!1,active:"Yes",inactive:"No"},{type:(n,{overwrite:t})=>{if(t===!1)throw console.log(Se("\u2716")+" Operation cancelled"),new Error;return null},name:"overwriteChecker"},{type:()=>K(w())?null:"text",name:"packageName",message:j("Package name:"),initial:()=>pe(w()),validate:n=>K(n)||"Invalid package.json name"},{type:i&&je.includes(i)?null:"select",name:"framework",message:typeof i=="string"&&!je.includes(i)?j(`"${i}" isn't a valid template. Please choose from below: `):j("Select a framework:"),initial:0,choices:Ee.map(n=>{let t=n.color;return{title:t(n.display||n.name),value:n}})},{type:n=>n&&n.variants?"select":null,name:"variant",message:j("Select a variant:"),choices:n=>n?.variants?.map(t=>{let r=t.color;return{title:r(t.display||t.name),value:t.name}})},{type:(n,t)=>{let{framework:r}=t;return r&&Array.isArray(r.options)&&r.options.length?"multiselect":null},name:"options",message:j("Select optional options:"),instructions:!1,choices:(n,t)=>{let{framework:r}=t;return r?.options?.map(o=>({title:o.name,value:o.id}))}},{type:(n,t)=>k.length&&Array.isArray(t.options)&&t.options.includes("publish")?"select":null,name:"gitUserUrl",message:j("Which git repository to publish to?"),choices:k.map(n=>{let t=X(n);return{title:t,value:t}})}],{onCancel:()=>{throw console.log(Se("\u2716")+" Operation cancelled"),new Error}}),{framework:R,overwrite:N,packageName:U,variant:y,gitUserUrl:E}=P,m=P.options||[],a=s.join(te,g);N?le(a):l.existsSync(a)||l.mkdirSync(a,{recursive:!0}),console.log(`
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(`
5
5
  Done. Now run:
6
- `),a!==ee&&console.log(` cd ${z.includes(" ")?`"${z}"`:z}`),W){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${W} install`),console.log(` ${W} run dev`);break}function Ae(){Fe(".lintstagedrc.cjs","jest.config.cjs","tsconfig.json","tsup.config.ts");let t=u.find(i=>["vite"].includes(i)),n=["#pnpm",`pnpm add ${f}${t?" -D":""}`,"","#yarn",`yarn add ${f}${t?" -D":""}`,"","#npm",`npm i ${f}${t?" --save-dev":""}`].join(`
7
- `);["LICENSE","README.md","README.zh_CN.md"].forEach(i=>{let o=c.join(a,i);if(!u.includes("publish")&&s.existsSync(o)){s.rmSync(o),i==="README.md"&&s.writeFileSync(o,`# ${f}
8
- `,{encoding:"utf-8"});return}if(!s.existsSync(o))return;let m=Object.assign({},J,{"pkg.install":n}),d=s.readFileSync(o,"utf-8");Object.keys(m).forEach(h=>{d=d.replace(new RegExp("{{"+h+"}}","g"),m[h])}),s.writeFileSync(o,d,"utf8")})}function k(t,...n){["dependencies","devDependencies"].forEach(i=>{Object.keys(t[i]||{}).forEach(o=>{n.find(m=>o.includes(m))&&delete t[i][o]})})}function re(...t){!Array.isArray(t)||t.length===0||t.forEach(n=>{let i=c.join(a,n);s.existsSync(i)&&A(i)})}function $e(){let t=c.join(a,"package.json"),n=S(t);n.name=f,u.includes("publish")||(delete n.author,delete n.publishConfig,delete n.repository,delete n.scripts.prepublishOnly,delete n.devDependencies.np),I&&(u.includes("electron")||(k(n,"electron"),n.scripts["lint:eslint"]=n.scripts["lint:eslint"].replace(",electron","")),u.includes("vite")||k(n,"vite")),v(t,n);let i=ue(t);Object.keys(J).forEach(o=>{i=i.replace(new RegExp("{{"+o+"}}","g"),J[o])}),s.writeFileSync(t,i)}function Oe(t,n){let i=t.lastIndexOf("."),o=t.substring(0,i)+"."+n+t.substring(i),m=c.join(a,t),d=c.join(a,o);s.existsSync(d)&&(u.includes(n)?(A(m),Ie(d,m)):A(d))}function Fe(...t){t.forEach(n=>{Be.forEach(i=>{Oe(n,i)})})}function Ce(){let t=c.join(a,"package.json"),n=S(t);if(u.includes("test")){if(u.includes("electron")){k(n,"vitest"),v(t,n);let i=c.join(a,"test/simple.test.ts");if(s.existsSync(i)){let o=s.readFileSync(i,{encoding:"utf8"});s.writeFileSync(i,o.replace("import { describe, expect, it } from 'vitest';",""),{encoding:"utf8"})}}else re("jest.config.cjs");return}delete n.scripts.test,n.scripts["lint:eslint"]=n.scripts["lint:eslint"].replace(",test",""),k(n,"jest","vitest"),re(".lintstagedrc.cjs","jest.config.cjs","test"),v(t,n)}function De(){if(!u.includes("examples")){let i=S(c.join(a,"package.json"));i.scripts.lint=i.scripts.lint.replace(" lint:stylelint",""),i.scripts["lint:eslint"]=i.scripts["lint:eslint"].replace(",examples",""),delete i.scripts["lint:stylelint"],k(i,"stylelint"),v(c.join(a,"package.json"),i);return}let t=c.join(a,"examples");s.mkdirSync(t);let n=u.includes("electron");["vue","react"].forEach(i=>{let o=U(n?`electron-${i}`:i),m=c.join(t,i);if(!s.existsSync(o)){console.log(`${We(o)} template is not exist`);return}s.cpSync(o,m,{recursive:!0});let d=S(c.join(m,"package.json"));Object.keys(d.scripts).forEach(h=>{(h.startsWith("lint")||["prepare"].includes(h))&&delete d.scripts[h]}),k(d,"eslint","prettier","stylelint","commitlint","husky","lint-staged","tsconfig","lint-staged","npm-run-all"),v(c.join(m,"package.json"),d),["_lintstagedrc.cjs"].forEach(h=>{let oe=c.join(m,h);s.existsSync(oe)&&s.rmSync(oe,{recursive:!0})})}),s.writeFileSync(c.join(a,"pnpm-workspace.yaml"),`packages:
9
- - 'examples/*'`,{encoding:"utf-8"})}}X().then(async()=>He().catch(e=>{e.message&&console.error(e)})).catch(e=>{e.message&&console.error(e)});
6
+ `),a!==te&&console.log(` cd ${L.includes(" ")?`"${L}"`:L}`),z){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${z} install`),console.log(` ${z} run dev`);break}function Ae(){Fe(".lintstagedrc.cjs","jest.config.cjs","tsconfig.json");let n=m.find(r=>["vite"].includes(r)),t=["#pnpm",`pnpm add ${f}${n?" -D":""}`,"","#yarn",`yarn add ${f}${n?" -D":""}`,"","#npm",`npm i ${f}${n?" --save-dev":""}`].join(`
7
+ `);["LICENSE","README.md","README.zh_CN.md"].forEach(r=>{let o=s.join(a,r);if(!m.includes("publish")&&l.existsSync(o)){l.rmSync(o),r==="README.md"&&l.writeFileSync(o,`# ${f}
8
+ `,{encoding:"utf-8"});return}if(!l.existsSync(o))return;let u=Object.assign({},M,{"pkg.install":t}),d=l.readFileSync(o,"utf-8");Object.keys(u).forEach(x=>{d=d.replace(new RegExp("{{"+x+"}}","g"),u[x])}),l.writeFileSync(o,d,"utf8")})}function v(n,...t){["dependencies","devDependencies"].forEach(r=>{Object.keys(n[r]||{}).forEach(o=>{t.find(u=>o.includes(u))&&delete n[r][o]})})}function b(...n){!Array.isArray(n)||n.length===0||n.forEach(t=>{let r=s.join(a,t);l.existsSync(r)&&$(r)})}function $e(){let n=s.join(a,"package.json"),t=S(n);t.name=f,m.includes("publish")||(delete t.author,delete t.publishConfig,delete t.repository,delete t.scripts.prepublishOnly,delete t.devDependencies.np),V&&(m.includes("electron")||(v(t,"electron"),t.scripts["lint:eslint"]=t.scripts["lint:eslint"].replace(",electron","")),m.includes("vite")||m.includes("tsup")&&v(t,"vite"),m.includes("tsup")?(t.scripts.dev="tsup --watch",t.scripts.build="tsup",b("vite.config.ts")):(t.scripts.dev="vite",t.scripts.build="vite build",v(t,"tsup"),b("tsup.config.ts"))),h(n,t);let r=ue(n);Object.keys(M).forEach(o=>{r=r.replace(new RegExp("{{"+o+"}}","g"),M[o])}),l.writeFileSync(n,r)}function Oe(n,t){let r=n.lastIndexOf("."),o=n.substring(0,r)+"."+t+n.substring(r),u=s.join(a,n),d=s.join(a,o);l.existsSync(d)&&(m.includes(t)?($(u),Ie(d,u)):$(d))}function Fe(...n){n.forEach(t=>{Be.forEach(r=>{Oe(t,r)})})}function Ce(){let n=s.join(a,"package.json"),t=S(n);if(m.includes("test")){m.includes("electron")?(t.scripts.test="jest",v(t,"vitest"),h(n,t),b("test/simple.test.ts")):(t.scripts.test="vitest",v(t,"jest"),h(n,t),b("test/electron.test.ts"),b("jest.config.cjs"));return}delete t.scripts.test,t.scripts["lint:eslint"]=t.scripts["lint:eslint"].replace(",test",""),v(t,"jest","vitest"),h(n,t),b("jest.config.cjs","test")}function De(){if(!m.includes("examples")){let r=S(s.join(a,"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"],v(r,"stylelint"),h(s.join(a,"package.json"),r);return}let n=s.join(a,"examples");l.mkdirSync(n);let t=m.includes("electron");["vue","react"].forEach(r=>{let o=I(t?`electron-${r}`:r),u=s.join(n,r);if(!l.existsSync(o)){console.log(`${We(o)} template is not exist`);return}l.cpSync(o,u,{recursive:!0});let d=S(s.join(u,"package.json"));Object.keys(d.scripts).forEach(x=>{(x.startsWith("lint")||["prepare"].includes(x))&&delete d.scripts[x]}),v(d,"eslint","prettier","stylelint","commitlint","husky","lint-staged","tsconfig","lint-staged","npm-run-all"),h(s.join(u,"package.json"),d),["_lintstagedrc.cjs"].forEach(x=>{let oe=s.join(u,x);l.existsSync(oe)&&l.rmSync(oe,{recursive:!0})})}),l.writeFileSync(s.join(a,"pnpm-workspace.yaml"),`packages:
9
+ - 'examples/*'`,{encoding:"utf-8"})}}Z().then(async()=>He().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.11.4",
3
+ "version": "0.12.0",
4
4
  "description": "create tomjs web app",
5
5
  "keywords": [
6
6
  "tomjs",
@@ -50,25 +50,25 @@
50
50
  "shelljs": "^0.8.5"
51
51
  },
52
52
  "devDependencies": {
53
- "@commitlint/cli": "^18.4.4",
54
- "@tomjs/commitlint": "^2.1.2",
55
- "@tomjs/eslint": "^1.2.2",
56
- "@tomjs/prettier": "^1.1.1",
57
- "@tomjs/stylelint": "^2.2.0",
58
- "@tomjs/tsconfig": "^1.3.0",
53
+ "@commitlint/cli": "^18.6.0",
54
+ "@tomjs/commitlint": "^2.3.0",
55
+ "@tomjs/eslint": "^1.4.0",
56
+ "@tomjs/prettier": "^1.3.0",
57
+ "@tomjs/stylelint": "^2.3.0",
58
+ "@tomjs/tsconfig": "^1.4.0",
59
59
  "@types/lodash-es": "^4.17.12",
60
60
  "@types/minimist": "^1.2.5",
61
- "@types/node": "^18.19.7",
61
+ "@types/node": "^18.19.14",
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.56.0",
66
- "husky": "^8.0.3",
67
- "lint-staged": "^15.2.0",
66
+ "husky": "^9.0.10",
67
+ "lint-staged": "^15.2.1",
68
68
  "np": "^9.2.0",
69
69
  "npm-run-all": "^4.1.5",
70
- "prettier": "^3.2.2",
71
- "stylelint": "^16.1.0",
70
+ "prettier": "^3.2.4",
71
+ "stylelint": "^16.2.1",
72
72
  "tsup": "^8.0.1",
73
73
  "typescript": "~5.3.3"
74
74
  },
@@ -17,7 +17,7 @@
17
17
  "lint:eslint": "eslint \"{src,electron,scripts}/**/*.{ts,tsx}\" *.{js,cjs,ts} --fix --cache",
18
18
  "lint:stylelint": "stylelint \"{src,electron,scripts}/**/*.{css,scss,less,html}\" --fix --cache",
19
19
  "lint:prettier": "prettier --write .",
20
- "prepare": "husky install"
20
+ "prepare": "husky"
21
21
  },
22
22
  "dependencies": {
23
23
  "@tomjs/electron-devtools-installer": "^2.1.0",
@@ -25,30 +25,30 @@
25
25
  "react-dom": "^18.2.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@commitlint/cli": "^18.4.4",
29
- "@tomjs/commitlint": "^2.1.2",
30
- "@tomjs/eslint": "^1.2.2",
31
- "@tomjs/prettier": "^1.1.1",
32
- "@tomjs/stylelint": "^2.2.0",
33
- "@tomjs/tsconfig": "^1.3.0",
28
+ "@commitlint/cli": "^18.6.0",
29
+ "@tomjs/commitlint": "^2.3.0",
30
+ "@tomjs/eslint": "^1.4.0",
31
+ "@tomjs/prettier": "^1.3.0",
32
+ "@tomjs/stylelint": "^2.3.0",
33
+ "@tomjs/tsconfig": "^1.4.0",
34
34
  "@tomjs/vite-plugin-electron": "^1.8.2",
35
- "@types/node": "^18.19.7",
36
- "@types/react": "^18.2.48",
35
+ "@types/node": "^18.19.14",
36
+ "@types/react": "^18.2.52",
37
37
  "@types/react-dom": "^18.2.18",
38
- "@vitejs/plugin-react-swc": "^3.5.0",
38
+ "@vitejs/plugin-react-swc": "^3.6.0",
39
39
  "cross-env": "^7.0.3",
40
- "electron": "^28.1.3",
40
+ "electron": "^28.2.1",
41
41
  "electron-builder": "^24.9.1",
42
42
  "eslint": "^8.56.0",
43
- "husky": "^8.0.3",
44
- "lint-staged": "^15.2.0",
43
+ "husky": "^9.0.10",
44
+ "lint-staged": "^15.2.1",
45
45
  "npm-run-all": "^4.1.5",
46
- "prettier": "^3.2.2",
46
+ "prettier": "^3.2.4",
47
47
  "rimraf": "^5.0.5",
48
- "stylelint": "^16.1.0",
48
+ "stylelint": "^16.2.1",
49
49
  "tsx": "^4.7.0",
50
50
  "typescript": "~5.3.3",
51
- "vite": "^5.0.11",
51
+ "vite": "^5.0.12",
52
52
  "vite-plugin-electron-renderer": "^0.14.5"
53
53
  }
54
54
  }
@@ -23,6 +23,5 @@ export default defineConfig(() => {
23
23
  // Use Node.js API in the Renderer process
24
24
  renderer(),
25
25
  ],
26
- clearScreen: false,
27
26
  };
28
27
  });
@@ -17,35 +17,35 @@
17
17
  "lint:eslint": "eslint \"{src,electron,scripts}/**/*.{js,cjs,ts,tsx,vue}\" *.{js,cjs,ts} --fix --cache",
18
18
  "lint:stylelint": "stylelint \"{src,electron,scripts}/**/*.{css,scss,less,html}\" --fix --cache",
19
19
  "lint:prettier": "prettier --write .",
20
- "prepare": "husky install"
20
+ "prepare": "husky"
21
21
  },
22
22
  "dependencies": {
23
23
  "@tomjs/electron-devtools-installer": "^2.1.0",
24
- "vue": "^3.4.13"
24
+ "vue": "~3.3.13"
25
25
  },
26
26
  "devDependencies": {
27
- "@commitlint/cli": "^18.4.4",
28
- "@tomjs/commitlint": "^2.1.2",
29
- "@tomjs/eslint": "^1.2.2",
30
- "@tomjs/prettier": "^1.1.1",
31
- "@tomjs/stylelint": "^2.2.0",
32
- "@tomjs/tsconfig": "^1.3.0",
27
+ "@commitlint/cli": "^18.6.0",
28
+ "@tomjs/commitlint": "^2.3.0",
29
+ "@tomjs/eslint": "^1.4.0",
30
+ "@tomjs/prettier": "^1.3.0",
31
+ "@tomjs/stylelint": "^2.3.0",
32
+ "@tomjs/tsconfig": "^1.4.0",
33
33
  "@tomjs/vite-plugin-electron": "^1.8.2",
34
- "@types/node": "^18.19.7",
34
+ "@types/node": "^18.19.14",
35
35
  "@vitejs/plugin-vue": "^5.0.3",
36
36
  "cross-env": "^7.0.3",
37
- "electron": "^28.1.3",
37
+ "electron": "^28.2.1",
38
38
  "electron-builder": "^24.9.1",
39
39
  "eslint": "^8.56.0",
40
- "husky": "^8.0.3",
41
- "lint-staged": "^15.2.0",
40
+ "husky": "^9.0.10",
41
+ "lint-staged": "^15.2.1",
42
42
  "npm-run-all": "^4.1.5",
43
- "prettier": "^3.2.2",
43
+ "prettier": "^3.2.4",
44
44
  "rimraf": "^5.0.5",
45
- "stylelint": "^16.1.0",
45
+ "stylelint": "^16.2.1",
46
46
  "tsx": "^4.7.0",
47
47
  "typescript": "~5.3.3",
48
- "vite": "^5.0.11",
48
+ "vite": "^5.0.12",
49
49
  "vite-plugin-electron-renderer": "^0.14.5",
50
50
  "vue-tsc": "^1.8.27"
51
51
  }
@@ -22,6 +22,5 @@ export default defineConfig(() => {
22
22
  // Use Node.js API in the Renderer process
23
23
  renderer(),
24
24
  ],
25
- clearScreen: false,
26
25
  };
27
26
  });
@@ -35,47 +35,51 @@
35
35
  "url": "git+{{git.url}}.git"
36
36
  },
37
37
  "scripts": {
38
- "dev": "tsup --watch",
39
38
  "start": "tsx ./scripts/info.ts",
39
+ "dev": "tsup --watch",
40
40
  "build": "tsup",
41
41
  "test": "jest",
42
42
  "lint": "run-s lint:eslint lint:stylelint lint:prettier",
43
43
  "lint:eslint": "eslint \"{src,scripts,test,examples}/**/*.ts\" *.{js,cjs,ts} --fix --cache",
44
44
  "lint:stylelint": "stylelint \"examples/**/*.{css,scss,less,vue,html}\" --fix --cache",
45
45
  "lint:prettier": "prettier --write .",
46
- "prepare": "husky install",
46
+ "prepare": "husky",
47
47
  "prepublishOnly": "npm run build && np --any-branch --no-yarn --yolo --no-publish --message \"chore: release v%s\""
48
48
  },
49
49
  "dependencies": {
50
50
  "kolorist": "^1.8.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@commitlint/cli": "^18.4.4",
53
+ "@commitlint/cli": "^18.6.0",
54
54
  "@jest/globals": "^29.7.0",
55
55
  "@kayahr/jest-electron-runner": "^29.11.0",
56
- "@tomjs/commitlint": "^2.1.2",
57
- "@tomjs/eslint": "^1.2.2",
58
- "@tomjs/prettier": "^1.1.1",
59
- "@tomjs/stylelint": "^2.2.0",
60
- "@tomjs/tsconfig": "^1.3.0",
61
- "@types/jest": "^29.5.11",
62
- "@types/node": "^18.19.7",
56
+ "@tomjs/commitlint": "^2.3.0",
57
+ "@tomjs/eslint": "^1.4.0",
58
+ "@tomjs/prettier": "^1.3.0",
59
+ "@tomjs/stylelint": "^2.3.0",
60
+ "@tomjs/tsconfig": "^1.4.0",
61
+ "@types/jest": "^29.5.12",
62
+ "@types/node": "^18.19.14",
63
63
  "cross-env": "^7.0.3",
64
- "electron": "^28.1.3",
64
+ "electron": "^28.2.1",
65
65
  "eslint": "^8.56.0",
66
- "husky": "^8.0.3",
66
+ "husky": "^9.0.10",
67
67
  "jest": "^29.7.0",
68
- "lint-staged": "^15.2.0",
68
+ "lint-staged": "^15.2.1",
69
69
  "np": "^9.2.0",
70
70
  "npm-run-all": "^4.1.5",
71
- "prettier": "^3.2.2",
71
+ "prettier": "^3.2.4",
72
72
  "rimraf": "^5.0.5",
73
- "stylelint": "^16.1.0",
74
- "ts-jest": "^29.1.1",
73
+ "stylelint": "^16.2.1",
74
+ "ts-jest": "^29.1.2",
75
75
  "tsup": "^8.0.1",
76
76
  "tsx": "^4.7.0",
77
77
  "typescript": "~5.3.3",
78
- "vite": "^5.0.11",
79
- "vitest": "^1.2.0"
78
+ "vite": "^5.0.12",
79
+ "vite-plugin-dts": "^3.7.2",
80
+ "vitest": "^1.2.2"
81
+ },
82
+ "peerDependencies": {
83
+ "vite": ">=2.0.0"
80
84
  }
81
85
  }
@@ -0,0 +1,7 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ describe('some test', () => {
4
+ it('1 + 1 = 2', () => {
5
+ expect(1 + 1).toBe(2);
6
+ });
7
+ });
@@ -5,9 +5,11 @@ export default defineConfig(options => {
5
5
  entry: ['src/index.ts'],
6
6
  format: ['esm', 'cjs'],
7
7
  target: ['es2021', 'node16'],
8
+ external: ['vite'],
8
9
  shims: true,
9
10
  clean: true,
10
11
  sourcemap: !!options.watch,
12
+ minifyWhitespace: !options.watch,
11
13
  dts: true,
12
14
  splitting: true,
13
15
  };
@@ -0,0 +1,42 @@
1
+ import fs from 'node:fs';
2
+ import { builtinModules } from 'node:module';
3
+ import { defineConfig, type PluginOption } from 'vite';
4
+ import dts from 'vite-plugin-dts';
5
+ import pkg from './package.json';
6
+
7
+ const isDev = process.argv.includes('--watch');
8
+
9
+ const plugins: PluginOption[] = [];
10
+ if (!isDev) {
11
+ plugins.push(
12
+ dts({
13
+ rollupTypes: true,
14
+ afterBuild: () => {
15
+ fs.copyFileSync('dist/index.d.ts', 'dist/index.d.mts');
16
+ },
17
+ }),
18
+ );
19
+ }
20
+
21
+ export default defineConfig({
22
+ build: {
23
+ target: ['es2021', 'node16'],
24
+ lib: {
25
+ entry: 'src/index.ts',
26
+ fileName: 'index',
27
+ formats: ['es', 'cjs'],
28
+ },
29
+ minify: false,
30
+ sourcemap: isDev,
31
+ rollupOptions: {
32
+ output: {
33
+ exports: 'named',
34
+ },
35
+ external: ['vite']
36
+ .concat(builtinModules)
37
+ .concat(builtinModules.map(s => `node:${s}`))
38
+ .concat(Object.keys(pkg.dependencies)),
39
+ },
40
+ },
41
+ plugins,
42
+ });
@@ -14,31 +14,31 @@
14
14
  "lint:eslint": "eslint \"src/**/*.{ts,tsx}\" *.{js,cjs,ts} --fix --cache",
15
15
  "lint:stylelint": "stylelint \"src/**/*.{css,scss,less,html}\" --fix --cache",
16
16
  "lint:prettier": "prettier --write .",
17
- "prepare": "husky install"
17
+ "prepare": "husky"
18
18
  },
19
19
  "dependencies": {
20
20
  "react": "^18.2.0",
21
21
  "react-dom": "^18.2.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@commitlint/cli": "^18.4.4",
25
- "@tomjs/commitlint": "^2.1.2",
26
- "@tomjs/eslint": "^1.2.2",
27
- "@tomjs/prettier": "^1.1.1",
28
- "@tomjs/stylelint": "^2.2.0",
29
- "@tomjs/tsconfig": "^1.3.0",
30
- "@types/node": "^18.19.7",
31
- "@types/react": "^18.2.48",
24
+ "@commitlint/cli": "^18.6.0",
25
+ "@tomjs/commitlint": "^2.3.0",
26
+ "@tomjs/eslint": "^1.4.0",
27
+ "@tomjs/prettier": "^1.3.0",
28
+ "@tomjs/stylelint": "^2.3.0",
29
+ "@tomjs/tsconfig": "^1.4.0",
30
+ "@types/node": "^18.19.14",
31
+ "@types/react": "^18.2.52",
32
32
  "@types/react-dom": "^18.2.18",
33
- "@vitejs/plugin-react-swc": "^3.5.0",
33
+ "@vitejs/plugin-react-swc": "^3.6.0",
34
34
  "cross-env": "^7.0.3",
35
35
  "eslint": "^8.56.0",
36
- "husky": "^8.0.3",
37
- "lint-staged": "^15.2.0",
36
+ "husky": "^9.0.10",
37
+ "lint-staged": "^15.2.1",
38
38
  "npm-run-all": "^4.1.5",
39
- "prettier": "^3.2.2",
40
- "stylelint": "^16.1.0",
39
+ "prettier": "^3.2.4",
40
+ "stylelint": "^16.2.1",
41
41
  "typescript": "~5.3.3",
42
- "vite": "^5.0.11"
42
+ "vite": "^5.0.12"
43
43
  }
44
44
  }
@@ -1,15 +1,21 @@
1
1
  {
2
- "name": "{{pkg.name}}",
3
- "displayName": "{{pkg.name}}",
4
- "description": "",
2
+ "name": "vscode-extension",
3
+ "displayName": "%displayName%",
4
+ "description": "%description%",
5
5
  "version": "0.0.0",
6
6
  "publisher": "{{git.org}}",
7
7
  "license": "MIT",
8
8
  "engines": {
9
9
  "node": ">=14",
10
- "vscode": "^1.56.0"
10
+ "vscode": "^1.75.0"
11
11
  },
12
12
  "main": "dist/index.js",
13
+ "keywords": [
14
+ "vscode"
15
+ ],
16
+ "categories": [
17
+ "Other"
18
+ ],
13
19
  "activationEvents": [
14
20
  "onCommand:hello-world.showHelloWorld"
15
21
  ],
@@ -29,7 +35,7 @@
29
35
  "url": "git+{{git.url}}/issues"
30
36
  },
31
37
  "homepage": "{{git.url}}/blob/main/README.md",
32
- "icon": "images/icon.png",
38
+ "icon": "resources/logo.png",
33
39
  "vsce": {
34
40
  "dependencies": false,
35
41
  "yarn": false
@@ -40,21 +46,21 @@
40
46
  "lint": "run-s lint:eslint lint:prettier",
41
47
  "lint:eslint": "eslint \"{src,scripts}/**/*.{js,cjs,ts}\" *.{js,cjs,ts} --fix --cache",
42
48
  "lint:prettier": "prettier --write .",
43
- "prepare": "husky install"
49
+ "prepare": "husky"
44
50
  },
45
51
  "devDependencies": {
46
- "@commitlint/cli": "^18.4.4",
47
- "@tomjs/commitlint": "^2.1.2",
48
- "@tomjs/eslint": "^1.2.2",
49
- "@tomjs/prettier": "^1.1.1",
50
- "@tomjs/tsconfig": "^1.3.0",
51
- "@types/node": "^18.19.7",
52
- "@types/vscode": "^1.56.0",
52
+ "@commitlint/cli": "^18.6.0",
53
+ "@tomjs/commitlint": "^2.3.0",
54
+ "@tomjs/eslint": "^1.4.0",
55
+ "@tomjs/prettier": "^1.3.0",
56
+ "@tomjs/tsconfig": "^1.4.0",
57
+ "@types/node": "^18.19.14",
58
+ "@types/vscode": "^1.75.0",
53
59
  "eslint": "^8.56.0",
54
- "husky": "^8.0.3",
55
- "lint-staged": "^15.2.0",
60
+ "husky": "^9.0.10",
61
+ "lint-staged": "^15.2.1",
56
62
  "npm-run-all": "^4.1.5",
57
- "prettier": "^3.2.2",
63
+ "prettier": "^3.2.4",
58
64
  "rimraf": "^5.0.5",
59
65
  "tsup": "^8.0.1",
60
66
  "typescript": "~5.3.3"
@@ -0,0 +1,4 @@
1
+ {
2
+ "displayName": "VSCode Extension",
3
+ "description": "This is a VSCode Extension"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "displayName": "VSCode 扩展",
3
+ "description": "这是一个 VSCode 扩展"
4
+ }
@@ -1,5 +1,4 @@
1
1
  import { Disposable, Uri, ViewColumn, Webview, WebviewPanel, window } from 'vscode';
2
- // import __getWebviewHtml__ from '@tomjs/vscode-extension-webview';
3
2
 
4
3
  function uuid() {
5
4
  let text = '';
@@ -15,11 +14,11 @@ function getUri(webview: Webview, extensionUri: Uri, pathList: string[]) {
15
14
  }
16
15
 
17
16
  /**
18
- * This class manages the state and behavior of HelloWorld webview panels.
17
+ * This class manages the state and behavior of Main webview panels.
19
18
  *
20
19
  * It contains all the data and methods for:
21
20
  *
22
- * - Creating and rendering HelloWorld webview panels
21
+ * - Creating and rendering Main webview panels
23
22
  * - Properly cleaning up and disposing of webview resources when the panel is closed
24
23
  * - Setting the HTML (and by proxy CSS/JavaScript) content of the webview panel
25
24
  * - Setting message listeners so data can be passed between the webview and extension
@@ -30,7 +29,7 @@ export class MainPanel {
30
29
  private _disposables: Disposable[] = [];
31
30
 
32
31
  /**
33
- * The HelloWorldPanel class private constructor (called only from the render method).
32
+ * The MainPanel class private constructor (called only from the render method).
34
33
  *
35
34
  * @param panel A reference to the webview panel
36
35
  * @param extensionUri The URI of the directory containing the extension
@@ -111,9 +110,8 @@ export class MainPanel {
111
110
  * rendered within the webview panel
112
111
  */
113
112
  private _getWebviewContent(webview: Webview, extensionUri: Uri) {
114
- // The CSS file from the Vue build output
113
+ // The file from the vite build output
115
114
  const stylesUri = getUri(webview, extensionUri, ['dist', 'webview', 'assets', 'index.css']);
116
- // The JS file from the Vue build output
117
115
  const scriptUri = getUri(webview, extensionUri, ['dist', 'webview', 'assets', 'index.js']);
118
116
 
119
117
  const nonce = uuid();
@@ -122,7 +120,6 @@ export class MainPanel {
122
120
  return __getWebviewHtml__(process.env.VITE_DEV_SERVER_URL);
123
121
  }
124
122
 
125
- // Tip: Install the es6-string-html VS Code extension to enable code highlighting below
126
123
  return /*html*/ `
127
124
  <!doctype html>
128
125
  <html lang="en">
@@ -1,13 +1,21 @@
1
1
  {
2
- "name": "{{pkg.name}}",
2
+ "name": "vscode-extension",
3
+ "displayName": "%displayName%",
4
+ "description": "%description%",
3
5
  "version": "0.0.0",
4
- "description": "vite + vscode + react",
5
- "keywords": [],
6
+ "publisher": "{{git.org}}",
7
+ "license": "MIT",
6
8
  "engines": {
7
9
  "node": ">=14",
8
- "vscode": "^1.56.0"
10
+ "vscode": "^1.75.0"
9
11
  },
10
12
  "main": "dist/extension/index.js",
13
+ "keywords": [
14
+ "vscode"
15
+ ],
16
+ "categories": [
17
+ "Other"
18
+ ],
11
19
  "activationEvents": [
12
20
  "onCommand:hello-world.showHelloWorld"
13
21
  ],
@@ -27,7 +35,7 @@
27
35
  "url": "git+{{git.url}}/issues"
28
36
  },
29
37
  "homepage": "{{git.url}}/blob/main/README.md",
30
- "icon": "images/icon.png",
38
+ "icon": "resources/logo.png",
31
39
  "vsce": {
32
40
  "dependencies": false,
33
41
  "yarn": false
@@ -40,7 +48,7 @@
40
48
  "lint:eslint": "eslint \"{src,extension,scripts}/**/*.{js,cjs,ts,tsx}\" *.{js,cjs,ts} --fix --cache",
41
49
  "lint:stylelint": "stylelint \"{src,extension,scripts}/**/*.{css,scss,less,html}\" --fix --cache",
42
50
  "lint:prettier": "prettier --write .",
43
- "prepare": "husky install"
51
+ "prepare": "husky"
44
52
  },
45
53
  "dependencies": {
46
54
  "@vscode/webview-ui-toolkit": "^1.4.0",
@@ -48,30 +56,30 @@
48
56
  "react-dom": "^18.2.0"
49
57
  },
50
58
  "devDependencies": {
51
- "@commitlint/cli": "^18.4.4",
52
- "@tomjs/commitlint": "^2.1.2",
53
- "@tomjs/eslint": "^1.2.2",
54
- "@tomjs/prettier": "^1.1.1",
55
- "@tomjs/stylelint": "^2.2.0",
56
- "@tomjs/tsconfig": "^1.3.0",
57
- "@tomjs/vite-plugin-vscode": "^1.4.0",
59
+ "@commitlint/cli": "^18.6.0",
60
+ "@tomjs/commitlint": "^2.3.0",
61
+ "@tomjs/eslint": "^1.4.0",
62
+ "@tomjs/prettier": "^1.3.0",
63
+ "@tomjs/stylelint": "^2.3.0",
64
+ "@tomjs/tsconfig": "^1.4.0",
65
+ "@tomjs/vite-plugin-vscode": "^1.5.0",
58
66
  "@tomjs/vscode-extension-webview": "^1.2.0",
59
- "@types/node": "^18.19.7",
60
- "@types/react": "^18.2.48",
67
+ "@types/node": "^18.19.14",
68
+ "@types/react": "^18.2.52",
61
69
  "@types/react-dom": "^18.2.18",
62
- "@types/vscode": "^1.56.0",
70
+ "@types/vscode": "^1.75.0",
63
71
  "@types/vscode-webview": "^1.57.4",
64
- "@vitejs/plugin-react-swc": "^3.5.0",
72
+ "@vitejs/plugin-react-swc": "^3.6.0",
65
73
  "cross-env": "^7.0.3",
66
74
  "eslint": "^8.56.0",
67
- "husky": "^8.0.3",
68
- "lint-staged": "^15.2.0",
75
+ "husky": "^9.0.10",
76
+ "lint-staged": "^15.2.1",
69
77
  "npm-run-all": "^4.1.5",
70
- "prettier": "^3.2.2",
78
+ "prettier": "^3.2.4",
71
79
  "rimraf": "^5.0.5",
72
- "stylelint": "^16.1.0",
80
+ "stylelint": "^16.2.1",
73
81
  "tsx": "^4.7.0",
74
82
  "typescript": "~5.3.3",
75
- "vite": "^5.0.11"
83
+ "vite": "^5.0.12"
76
84
  }
77
85
  }
@@ -0,0 +1,4 @@
1
+ {
2
+ "displayName": "VSCode Extension",
3
+ "description": "This is a VSCode Extension"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "displayName": "VSCode 扩展",
3
+ "description": "这是一个 VSCode 扩展"
4
+ }
@@ -16,6 +16,5 @@ export default defineConfig(() => {
16
16
  },
17
17
  },
18
18
  plugins: [react(), vscode()],
19
- clearScreen: false,
20
19
  };
21
20
  });
@@ -1,5 +1,4 @@
1
1
  import { Disposable, Uri, ViewColumn, Webview, WebviewPanel, window } from 'vscode';
2
- // import __getWebviewHtml__ from '@tomjs/vscode-extension-webview';
3
2
 
4
3
  function uuid() {
5
4
  let text = '';
@@ -15,11 +14,11 @@ function getUri(webview: Webview, extensionUri: Uri, pathList: string[]) {
15
14
  }
16
15
 
17
16
  /**
18
- * This class manages the state and behavior of HelloWorld webview panels.
17
+ * This class manages the state and behavior of Main webview panels.
19
18
  *
20
19
  * It contains all the data and methods for:
21
20
  *
22
- * - Creating and rendering HelloWorld webview panels
21
+ * - Creating and rendering Main webview panels
23
22
  * - Properly cleaning up and disposing of webview resources when the panel is closed
24
23
  * - Setting the HTML (and by proxy CSS/JavaScript) content of the webview panel
25
24
  * - Setting message listeners so data can be passed between the webview and extension
@@ -30,7 +29,7 @@ export class MainPanel {
30
29
  private _disposables: Disposable[] = [];
31
30
 
32
31
  /**
33
- * The HelloWorldPanel class private constructor (called only from the render method).
32
+ * The MainPanel class private constructor (called only from the render method).
34
33
  *
35
34
  * @param panel A reference to the webview panel
36
35
  * @param extensionUri The URI of the directory containing the extension
@@ -111,9 +110,8 @@ export class MainPanel {
111
110
  * rendered within the webview panel
112
111
  */
113
112
  private _getWebviewContent(webview: Webview, extensionUri: Uri) {
114
- // The CSS file from the Vue build output
113
+ // The file from the vite build output
115
114
  const stylesUri = getUri(webview, extensionUri, ['dist', 'webview', 'assets', 'index.css']);
116
- // The JS file from the Vue build output
117
115
  const scriptUri = getUri(webview, extensionUri, ['dist', 'webview', 'assets', 'index.js']);
118
116
 
119
117
  const nonce = uuid();
@@ -122,7 +120,6 @@ export class MainPanel {
122
120
  return __getWebviewHtml__(process.env.VITE_DEV_SERVER_URL);
123
121
  }
124
122
 
125
- // Tip: Install the es6-string-html VS Code extension to enable code highlighting below
126
123
  return /*html*/ `
127
124
  <!doctype html>
128
125
  <html lang="en">
@@ -1,12 +1,21 @@
1
1
  {
2
- "name": "{{pkg.name}}",
2
+ "name": "vscode-extension",
3
+ "displayName": "%displayName%",
4
+ "description": "%description%",
3
5
  "version": "0.0.0",
4
- "description": "vite + vscode + vue",
6
+ "publisher": "{{git.org}}",
7
+ "license": "MIT",
5
8
  "engines": {
6
9
  "node": ">=14",
7
- "vscode": "^1.56.0"
10
+ "vscode": "^1.75.0"
8
11
  },
9
12
  "main": "dist/extension/index.js",
13
+ "keywords": [
14
+ "vscode"
15
+ ],
16
+ "categories": [
17
+ "Other"
18
+ ],
10
19
  "activationEvents": [
11
20
  "onCommand:hello-world.showHelloWorld"
12
21
  ],
@@ -26,7 +35,7 @@
26
35
  "url": "git+{{git.url}}/issues"
27
36
  },
28
37
  "homepage": "{{git.url}}/blob/main/README.md",
29
- "icon": "images/icon.png",
38
+ "icon": "resources/logo.png",
30
39
  "vsce": {
31
40
  "dependencies": false,
32
41
  "yarn": false
@@ -39,36 +48,36 @@
39
48
  "lint:eslint": "eslint \"{src,extension,scripts}/**/*.{js,cjs,ts,tsx,vue}\" *.{js,cjs,ts} --fix --cache",
40
49
  "lint:stylelint": "stylelint \"{src,extension,scripts}/**/*.{css,scss,less,html}\" --fix --cache",
41
50
  "lint:prettier": "prettier --write .",
42
- "prepare": "husky install"
51
+ "prepare": "husky"
43
52
  },
44
53
  "dependencies": {
45
54
  "@vscode/webview-ui-toolkit": "^1.4.0",
46
- "vue": "^3.4.13"
55
+ "vue": "~3.3.13"
47
56
  },
48
57
  "devDependencies": {
49
- "@commitlint/cli": "^18.4.4",
50
- "@tomjs/commitlint": "^2.1.2",
51
- "@tomjs/eslint": "^1.2.2",
52
- "@tomjs/prettier": "^1.1.1",
53
- "@tomjs/stylelint": "^2.2.0",
54
- "@tomjs/tsconfig": "^1.3.0",
55
- "@tomjs/vite-plugin-vscode": "^1.4.0",
58
+ "@commitlint/cli": "^18.6.0",
59
+ "@tomjs/commitlint": "^2.3.0",
60
+ "@tomjs/eslint": "^1.4.0",
61
+ "@tomjs/prettier": "^1.3.0",
62
+ "@tomjs/stylelint": "^2.3.0",
63
+ "@tomjs/tsconfig": "^1.4.0",
64
+ "@tomjs/vite-plugin-vscode": "^1.5.0",
56
65
  "@tomjs/vscode-extension-webview": "^1.2.0",
57
- "@types/node": "^18.19.7",
58
- "@types/vscode": "^1.56.0",
66
+ "@types/node": "^18.19.14",
67
+ "@types/vscode": "^1.75.0",
59
68
  "@types/vscode-webview": "^1.57.4",
60
69
  "@vitejs/plugin-vue": "^5.0.3",
61
70
  "cross-env": "^7.0.3",
62
71
  "eslint": "^8.56.0",
63
- "husky": "^8.0.3",
64
- "lint-staged": "^15.2.0",
72
+ "husky": "^9.0.10",
73
+ "lint-staged": "^15.2.1",
65
74
  "npm-run-all": "^4.1.5",
66
- "prettier": "^3.2.2",
75
+ "prettier": "^3.2.4",
67
76
  "rimraf": "^5.0.5",
68
- "stylelint": "^16.1.0",
77
+ "stylelint": "^16.2.1",
69
78
  "tsx": "^4.7.0",
70
79
  "typescript": "~5.3.3",
71
- "vite": "^5.0.11",
80
+ "vite": "^5.0.12",
72
81
  "vue-tsc": "^1.8.27"
73
82
  }
74
83
  }
@@ -0,0 +1,4 @@
1
+ {
2
+ "displayName": "VSCode Extension",
3
+ "description": "This is a VSCode Extension"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "displayName": "VSCode 扩展",
3
+ "description": "这是一个 VSCode 扩展"
4
+ }
@@ -15,7 +15,15 @@ export default defineConfig(() => {
15
15
  '@': path.join(__dirname, 'src'),
16
16
  },
17
17
  },
18
- plugins: [vue(), vscode()],
19
- clearScreen: false,
18
+ plugins: [
19
+ vue({
20
+ template: {
21
+ compilerOptions: {
22
+ isCustomElement: (tag: string) => tag.startsWith('vscode-'),
23
+ },
24
+ },
25
+ }),
26
+ vscode(),
27
+ ],
20
28
  };
21
29
  });
@@ -14,29 +14,29 @@
14
14
  "lint:eslint": "eslint \"src/**/*.{ts,tsx,vue}\" *.{js,cjs,ts} --fix --cache",
15
15
  "lint:stylelint": "stylelint \"src/**/*.{css,scss,less,vue,html}\" --fix --cache",
16
16
  "lint:prettier": "prettier --write .",
17
- "prepare": "husky install"
17
+ "prepare": "husky"
18
18
  },
19
19
  "dependencies": {
20
- "vue": "^3.4.13"
20
+ "vue": "~3.3.13"
21
21
  },
22
22
  "devDependencies": {
23
- "@commitlint/cli": "^18.4.4",
24
- "@tomjs/commitlint": "^2.1.2",
25
- "@tomjs/eslint": "^1.2.2",
26
- "@tomjs/prettier": "^1.1.1",
27
- "@tomjs/stylelint": "^2.2.0",
28
- "@tomjs/tsconfig": "^1.3.0",
29
- "@types/node": "^18.19.7",
23
+ "@commitlint/cli": "^18.6.0",
24
+ "@tomjs/commitlint": "^2.3.0",
25
+ "@tomjs/eslint": "^1.4.0",
26
+ "@tomjs/prettier": "^1.3.0",
27
+ "@tomjs/stylelint": "^2.3.0",
28
+ "@tomjs/tsconfig": "^1.4.0",
29
+ "@types/node": "^18.19.14",
30
30
  "@vitejs/plugin-vue": "^5.0.3",
31
31
  "cross-env": "^7.0.3",
32
32
  "eslint": "^8.56.0",
33
- "husky": "^8.0.3",
34
- "lint-staged": "^15.2.0",
33
+ "husky": "^9.0.10",
34
+ "lint-staged": "^15.2.1",
35
35
  "npm-run-all": "^4.1.5",
36
- "prettier": "^3.2.2",
37
- "stylelint": "^16.1.0",
36
+ "prettier": "^3.2.4",
37
+ "stylelint": "^16.2.1",
38
38
  "typescript": "~5.3.3",
39
- "vite": "^5.0.11",
39
+ "vite": "^5.0.12",
40
40
  "vue-tsc": "^1.8.27"
41
41
  }
42
42
  }
@@ -1,15 +0,0 @@
1
- import { defineConfig } from 'tsup';
2
-
3
- export default defineConfig(options => {
4
- return {
5
- entry: ['src/index.ts'],
6
- format: ['esm', 'cjs'],
7
- target: ['es2021', 'node16'],
8
- external: ['vite'],
9
- shims: true,
10
- clean: true,
11
- sourcemap: !!options.watch,
12
- dts: true,
13
- splitting: true,
14
- };
15
- });