@tomjs/create-app 5.0.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +1 -1
- package/package.json +5 -5
- package/templates/config/base/package.json +3 -0
- package/templates/config/electron/package.json +2 -2
- package/templates/config/hbuilderx/extension/index.ts +22 -0
- package/templates/config/hbuilderx/extension/webview.ts +71 -0
- package/templates/config/hbuilderx/package.json +96 -0
- package/templates/config/hbuilderx/tsconfig.node.json +15 -0
- package/templates/config/package.json +26 -15
- package/templates/config/react/package.json +3 -3
- package/templates/{web-react → config/react}/tsconfig.app.json +3 -1
- package/templates/config/style/package.json +2 -2
- package/templates/config/style/stylelint.config.mjs +4 -0
- package/templates/config/vscode/package.json +1 -1
- package/templates/config/vue/_eslint.config.mjs +5 -0
- package/templates/config/vue/env.d.ts +3 -0
- package/templates/config/vue/package.json +8 -2
- package/templates/{vscode-vue → config/vue}/tsconfig.app.json +8 -3
- package/templates/config/vue/uno.config.ts +9 -0
- package/templates/electron-react/vite.config.ts +7 -3
- package/templates/electron-vue/package.json +3 -1
- package/templates/electron-vue/vite.config.ts +16 -2
- package/templates/hbuilderx-base/README.md +20 -0
- package/templates/hbuilderx-base/package.json +52 -0
- package/templates/hbuilderx-base/src/env.d.ts +1 -0
- package/templates/hbuilderx-base/src/index.ts +17 -0
- package/templates/hbuilderx-base/tsconfig.json +7 -0
- package/templates/hbuilderx-base/tsdown.config.ts +13 -0
- package/templates/hbuilderx-react/README.md +25 -0
- package/templates/hbuilderx-react/index.html +13 -0
- package/templates/hbuilderx-react/package.json +12 -0
- package/templates/hbuilderx-react/pnpm-workspace.yaml +5 -0
- package/templates/hbuilderx-react/src/App.css +45 -0
- package/templates/hbuilderx-react/src/App.tsx +41 -0
- package/templates/hbuilderx-react/src/assets/react.svg +1 -0
- package/templates/hbuilderx-react/src/assets/vite.svg +1 -0
- package/templates/hbuilderx-react/src/index.css +73 -0
- package/templates/hbuilderx-react/src/main.tsx +10 -0
- package/templates/hbuilderx-react/tsconfig.app.json +18 -0
- package/templates/hbuilderx-react/vite.config.ts +20 -0
- package/templates/hbuilderx-vue/README.md +26 -0
- package/templates/hbuilderx-vue/index.html +13 -0
- package/templates/hbuilderx-vue/package.json +12 -0
- package/templates/hbuilderx-vue/pnpm-workspace.yaml +4 -0
- package/templates/hbuilderx-vue/src/App.vue +32 -0
- package/templates/hbuilderx-vue/src/assets/vite.svg +1 -0
- package/templates/hbuilderx-vue/src/assets/vue.svg +1 -0
- package/templates/hbuilderx-vue/src/components/HelloWorld.vue +29 -0
- package/templates/hbuilderx-vue/src/main.ts +5 -0
- package/templates/hbuilderx-vue/src/style.css +68 -0
- package/templates/hbuilderx-vue/tsconfig.app.json +18 -0
- package/templates/hbuilderx-vue/vite.config.ts +31 -0
- package/templates/node-vite/examples/vue/src/App.vue +3 -3
- package/templates/node-vite/examples/vue/src/components/HelloWorld.vue +6 -4
- package/templates/vscode-react/package.json +1 -1
- package/templates/vscode-react/vite.config.ts +6 -2
- package/templates/vscode-vue/package.json +1 -1
- package/templates/vscode-vue/vite.config.ts +16 -2
- package/templates/web-react/public/vite.svg +1 -0
- package/templates/web-react/vite.config.ts +3 -1
- package/templates/web-vue/package.json +3 -0
- package/templates/web-vue/public/vite.svg +1 -0
- package/templates/web-vue/src/App.vue +3 -3
- package/templates/web-vue/src/components/HelloWorld.vue +6 -4
- package/templates/web-vue/src/main.ts +1 -1
- package/templates/web-vue/vite.config.ts +19 -1
- package/templates/vscode-react/tsconfig.app.json +0 -8
- package/templates/vscode-vue/tsconfig.node.json +0 -8
- package/templates/web-vue/tsconfig.app.json +0 -9
- /package/templates/{vscode-react → config/hbuilderx}/tsconfig.json +0 -0
- /package/templates/{vscode-vue → config/react}/tsconfig.json +0 -0
- /package/templates/{web-react → config/react}/tsconfig.node.json +0 -0
- /package/templates/{web-react → config/vscode}/tsconfig.json +0 -0
- /package/templates/{vscode-react → config/vscode}/tsconfig.node.json +0 -0
- /package/templates/{web-vue → config/vue}/tsconfig.json +0 -0
- /package/templates/{web-vue → config/vue}/tsconfig.node.json +0 -0
- /package/templates/{config/react → electron-react}/public/vite.svg +0 -0
- /package/templates/{config/vue → electron-vue}/public/vite.svg +0 -0
- /package/templates/web-vue/src/{style.css → style.scss} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from"meow";import t from"node:fs";import n,{readdir as r}from"node:fs/promises";import i from"node:os";import a from"node:path";import{fileURLToPath as o}from"node:url";import*as s from"@clack/prompts";import{copy as c,mkdir as l,mkdirp as u,readFile as d,readJson as f,readJsonSync as p,rm as m,rmSync as h,writeFile as g,writeJson as _}from"@tomjs/node";import{camelCase as v,merge as y,upperFirst as b}from"lodash-es";import{glob as x}from"tinyglobby";import S from"chalk";import{$ as C}from"execa";import w from"@tomjs/logger";const T=o(new URL(`..`,import.meta.url)),ee=[`vue`,`react`],E=[{name:`node`,display:`Node`,color:S.green,children:[{name:`node-base`,display:`Base`,color:S.green,public:`npm`},{name:`node-cli`,display:`CLI`,color:S.green,public:`npm`},{name:`node-vite`,display:`Vite Plugin`,value:`vite-plugin-xxx`,color:S.blue,hasStyle:!0,public:`npm`}]},{name:`web`,display:`Web`,color:S.magenta,children:[{name:`web-vue`,display:`Vue`,color:S.green,hasStyle:!0},{name:`web-react`,display:`React`,color:S.blue,hasStyle:!0}]},{name:`vscode`,display:`VSCode`,color:S.blue,children:[{name:`vscode-base`,display:`Base`,color:S.yellow,public:`public`},{name:`vscode-vue`,display:`Vue`,color:S.green,commonTemplates:[`vscode`],hasStyle:!0,public:`public`},{name:`vscode-react`,display:`React`,color:S.blue,commonTemplates:[`vscode`],hasStyle:!0,public:`public`}]},{name:`electron`,display:`Electron`,color:S.cyan,children:[{name:`electron-vue`,display:`Vue`,color:S.green,commonTemplates:[`electron`],hasStyle:!0},{name:`electron-react`,display:`React`,color:S.blue,commonTemplates:[`electron`],hasStyle:!0}]}],D=[{id:`github`,name:`Github`,url:`https://github.com`},{id:`gitcode`,name:`GitCode`,url:`https://gitcode.com`},{id:`gitee`,name:`码云`,url:`https://gitee.com`}],O=`publisher.name.displayName.type.version.private.packageManager.description.author.contributors.license.funding.homepage.repository.publishConfig.bugs.keywords.categories.sideEffects.imports.exports.main.module.unpkg.jsdelivr.types.typesVersions.bin.icon.files.engines.activationEvents.contributes.scripts.peerDependencies.peerDependenciesMeta.dependencies.optionalDependencies.devDependencies.pnpm.overrides.resolutions.husky.simple-git-hooks.lint-staged.eslintConfig`.split(`.`),k=[`dev`,`dev:`,`debug`,`debug:`,`start`,`build`,`build:`,`preview`,`release`,`release:`,`clean`,`clean:`,`test`,`lint`,`lint:`],A=new w({directory:`create-app/logs`}),te=process.platform===`win32`;let j={};function ne(e){j=e}function M(){return j}async function N(e,t){let{trim:n,...r}=Object.assign({stdio:`pipe`,shell:!0},t);Array.isArray(e)&&(e=e.join(` `));let i=e=>{M().verbose?A.debug(e):A.write(e)};i(`$ ${e}`);try{let t=(await C(r)`${e}`).stdout;return i(t),n?t.trim().replace(/\n|\r/g,``):t.trim()}catch(e){let t=e.stderr||e.message;throw i(t),Error(t)}}function P(e){if(e===`C`)return`en-US`;let t=``;try{t=Intl.getCanonicalLocales(e)[0]}catch(t){console.log(`${t.toString()}, invalid language tag: "${e}"\n`)}switch(t){case`zh-TW`:case`zh-HK`:case`zh-MO`:case`zh-CN`:case`zh-SG`:t=`zh-CN`;break;default:t=e}return t}function F(){return P((process.env.LC_ALL||process.env.LC_MESSAGES||process.env.LANG||Intl.DateTimeFormat().resolvedOptions().locale||`en-US`).split(`.`)[0].replace(`_`,`-`))}async function I(e){return await t.promises.readFile(e,`utf-8`).then(e=>JSON.parse(e)||{})}async function L(e){let n=F(),r=a.resolve(e,`${n}.json`),i=a.resolve(e,`en-US.json`);return t.existsSync(r)?await I(r):await I(i)}const R=await L(a.join(T,`locales`));function z(...e){if(e.length===0||!R)return``;let[t,...n]=e,r=R[t]??``;if(n[0]===null||n[0]===void 0||n[0]===``)return r;let i=typeof n[0]==`object`?n[0]:n;return r.replace(/\{([^}]+)\}/g,(e,t)=>i[t]??e)}const B=a.join(o(import.meta.url),`../../`),V=a.join(B,`templates`),H=()=>s.cancel(z(`prompt.cancel`));async function U(e){ne(e);let t=await W(e);t&&(await G(t),e.package&&await ue(t),t.template===`node-vite`&&await de(t.targetDir,t.packageName),e.package||await N(`git init`,{cwd:t.targetDir}))}async function W(e){let n=async function(){let e=await s.select({message:z(`prompt.templateType.message`),options:E.map(e=>({label:e.color(e.display||e.name),value:e.name}))});if(s.isCancel(e))return H();let t=E.find(t=>t.name===e),r=await s.select({message:z(`prompt.template.message`),options:t.children.map(e=>({label:e.color(e.display||e.name),value:e.name})).concat({label:z(`prompt.template.back`),value:`back`})});return s.isCancel(r)?H():r===`back`?await n():{template:r,templateOptions:t.children.find(e=>e.name===r)}},r=await n();if(!r)return;let o=``;await q(`user.email`)===`tom@tomgao.cc`&&(o=`tomjs`);let{template:c,templateOptions:l}=r,u=c.startsWith(`node-`),d=e.packageName;d||(d=l.value||c,o&&u&&(d=`@${o}/${d}`));let f=await s.text({message:z(`prompt.package.message`),initialValue:d,defaultValue:d,placeholder:d,validate:e=>e.length===0||ae(e)?void 0:z(`prompt.package.invalid`)});if(s.isCancel(f))return H();d=f;let p=K(d),m=await s.text({message:z(`prompt.project.message`),defaultValue:p,initialValue:p,placeholder:p,validate:e=>e.length===0||e.length>0?void 0:z(`prompt.project.invalid`)});if(s.isCancel(m))return H();if(p=a.resolve(p===`~`&&!te?i.homedir():e.cwd||process.cwd(),m),t.existsSync(p)&&!re(p)){let t=e.overwrite;if(!t){let e=await s.select({message:z(`prompt.exist.message`,p),options:[{label:z(`prompt.exist.option.no`),value:`no`},{label:z(`prompt.exist.option.yes`),value:`yes`},{label:z(`prompt.exist.option.ignore`),value:`ignore`}]});if(s.isCancel(e))return H();t=e}switch(t){case`yes`:ie(p);break;case`no`:H();return}}let h;if(e.private!==!0&&l.public){let e=await s.confirm({message:z(`prompt.public.message`),active:z(`prompt.confirm.yes`),inactive:z(`prompt.confirm.no`),initialValue:!0});if(s.isCancel(e))return H();h=e}let g;if(h){let e=await s.select({message:z(`prompt.gitUrl.message`),options:D.map(e=>({label:`${e.name} (${e.url})`,value:e.id}))});if(s.isCancel(e))return H();g=D.find(t=>t.id===e)?.url}let _;if(h){o=se(d)||o;let e=await s.text({message:z(`prompt.orgName.message`),defaultValue:o,placeholder:o,validate:e=>o&&!e||oe(e)?void 0:z(`prompt.orgName.invalid`)});if(s.isCancel(e))return H();_=e}return delete l.color,{targetDir:p,orgName:_,packageName:d,template:c,templateOptions:l,isPublic:h,gitUrl:g}}async function G(e){A.debug(`projectOptions:`,e);let{targetDir:t,packageName:o,template:s,isPublic:p,gitUrl:h,orgName:v,templateOptions:b}=e;await l(t);let S=s.includes(`vscode`),C={},w=a.join(t,`.temp`);if(await u(w),await J(C,`base`,w),b.hasStyle&&(await J(C,`style`,w),!s.includes(`vue`))){function e(e){return e.replaceAll(`vue,`,``).replaceAll(`,vue`,``)}let t=await r(a.join(V,`config/style`));for(let n of t){if(n===`package.json`){C.scripts&&Object.keys(C.scripts).forEach(t=>{C.scripts[t].includes(`vue`)&&(C.scripts[t]=e(C.scripts[t]))});continue}let t=a.join(w,n),r=await d(t);r.includes(`vue`)&&g(t,e(r))}}p&&b.public&&await J(C,b.public,w);let T=ee.find(e=>s.includes(`-${e}`));T&&await J(C,T,w);let E=b.commonTemplates;if(Array.isArray(E)&&E.length>0)for(let e of E)await J(C,e,w);if(await c(w,t),await m(w),await c(a.join(V,s),t),y(C,await f(a.join(a.join(V,s),`package.json`))),C.name=o,p){delete C.private,C.name=o,C.license=`MIT`;let e=await q(`user.name`)||i.userInfo().username,n=await q(`user.email`);e&&n?C.author={name:e,email:n}:e&&(C.author=e);let r=`${h}/${v}/${a.basename(t)}`;S&&(C.publisher=v,C.homepage=`${r}/blob/main/README.md`,C.bugs={url:`${r}/issues`},delete C.publishConfig),C.repository={type:`git`,url:`${r}.git`,directory:M().package?`packages/${a.basename(t)}`:void 0}}else C.private=!0,delete C.publishConfig,C.devDependencies&&delete C.devDependencies.publint;if(await _(a.join(t,`package.json`),X(C)),await le(t),p){let{author:e}=C,r=``;e&&(typeof e==`string`?r=e:typeof e==`object`&&(e.name&&e.email?r=`${e.name}<${e.email}>`:e.name?r=e.name:e.email&&(r=e.email)));let i={pkgName:o,dateYear:new Date().getFullYear(),gitUserName:r},s=(await n.readdir(t)).filter(e=>[`README.md`,`README.zh_CN.md`,`LICENSE`].includes(e));for(let e of s){let n=await d(a.join(t,e));Object.keys(i).forEach(e=>{n=n.replace(RegExp(`{{${e}}}`,`g`),i[e])}),await g(a.join(t,e),n)}}let D=await x(`**/_*`,{ignore:[`**/node_modules/**`,`**/.*`],cwd:t});for(let e of D){let r=e.split(`/`);r[r.length-1]=r[r.length-1].substring(1),await n.rename(a.join(t,e),a.join(t,r.join(`/`)))}}function K(e){return(e||``).trim().replace(/^@[^/]+\//,``)}function re(e){return t.readdirSync(e).length===0}function ie(e){t.existsSync(e)&&h(e)}function ae(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function oe(e){return/^[a-z][a-z\d\-._]*$/.test(e)}async function q(e){return N(`git config --get ${e}`,{trim:!0})}function se(e){if(e.startsWith(`@`))return e.split(`/`)[0].substring(1)}async function J(e,r,i){let o=a.join(V,`config/${r}`);if(!t.existsSync(o))return;let s=await n.readdir(o);for(let t of s)[`node_modules`,`.git`].includes(t)||(t===`package.json`?y(e,await f(a.join(o,`package.json`))):await c(a.join(o,t),a.join(i,t)))}function Y(e,t){if(!e)return e;let n={};return Array.isArray(t)&&t.length>0?(t.filter(t=>t in e).forEach(t=>{n[t]=e[t]}),Object.keys(e).filter(e=>!t.includes(e)).sort().forEach(t=>{n[t]=e[t]})):Object.keys(e).sort().forEach(t=>{n[t]=e[t]}),n}function ce(e,t,n){let r={},i=Object.keys(e);{let e=i.filter(e=>e.includes(`:`));i=i.filter(e=>!e.includes(`:`)).sort().concat(e)}let a=s(t),o=s(n);return a.concat(i.filter(e=>!a.includes(e)&&!o.includes(e))).concat(o).forEach(t=>{r[t]=e[t]}),r;function s(e){let t=Array.isArray(e)?e:[];return t.length>0&&(t=t.reduce((e,t)=>{if(t.endsWith(`:`)){let n=i.filter(n=>!e.includes(n)&&n.startsWith(t));return e.concat(n)}return i.includes(t)?e.concat(t):e},[])),t}}function X(e){return e=Y(e,O),e.scripts&&=ce(e.scripts,k,[`prepare`,`prepublishOnly`]),[`dependencies`,`devDependencies`,`peerDependencies`].forEach(t=>{e[t]&&(e[t]=Y(e[t]))}),e}async function le(e){let t=p(a.join(V,`config/package.json`))?.dependencies||{},n=await x(`**/package.json`,{ignore:[`**/node_modules/**`,`**/.*`],cwd:e});for(let r of n){let n=a.join(e,r),i=await f(n);[`dependencies`,`devDependencies`].forEach(e=>{let n=i[e];n&&Object.keys(n).forEach(e=>{n[e]=t[e]||n[e]})}),_(n,X(i))}}async function ue(e){let n=e.templateOptions.hasStyle,r=[`.editorconfig`,`.gitignore`,`.gitattributes`,`commitlint.config.mjs`,`simple-git-hooks.mjs`,`pnpm-workspace.yaml`];n||r.push(`lint-staged.config.mjs`),[`vscode`,`electron`].find(t=>e.template.startsWith(t))||r.push(`.vscode`),r.forEach(n=>{let r=a.join(e.targetDir,n);t.existsSync(r)&&h(r)});let i=await f(a.join(e.targetDir,`package.json`));if(i.scripts&&delete i.scripts.prepare,!n)delete i.devDependencies;else if(i.devDependencies){let e=await f(a.join(V,`config/style/package.json`)),t=Object.keys(e.devDependencies||{});Object.keys(i.devDependencies).forEach(e=>{t.includes(e)||delete i.devDependencies[e]})}await _(a.join(e.targetDir,`package.json`),i)}async function de(e,t){let n=v((t.split(`/`).pop()||``).replace(`vite-plugin`,``)||`xxx`),r=await x([`src/**/*.ts`,`examples/*/vite.config.ts`,`examples/*/package.json`],{ignore:[`**/node_modules/**`,`**/.*`],cwd:e});for(let t of r){let r=a.join(e,t);await g(r,(await d(r)).replaceAll(`xxx`,n).replaceAll(`Xxx`,b(n)))}}const Z=e(`
|
|
1
|
+
import e from"meow";import t from"node:fs";import n,{readdir as r}from"node:fs/promises";import i from"node:os";import a from"node:path";import{fileURLToPath as o}from"node:url";import*as s from"@clack/prompts";import{copy as c,mkdir as l,mkdirp as u,readFile as d,readJson as f,readJsonSync as p,rm as m,rmSync as h,writeFile as g,writeJson as _}from"@tomjs/node";import{camelCase as v,merge as y,upperFirst as b}from"lodash-es";import{glob as x}from"tinyglobby";import S from"chalk";import{$ as C}from"execa";import w from"@tomjs/logger";const T=o(new URL(`..`,import.meta.url)),ee=[`vue`,`react`],E=[{name:`node`,display:`Node`,color:S.green,children:[{name:`node-base`,display:`Base`,color:S.green,public:`npm`},{name:`node-cli`,display:`CLI`,color:S.green,public:`npm`},{name:`node-vite`,display:`Vite Plugin`,value:`vite-plugin-xxx`,color:S.blue,hasStyle:!0,public:`npm`}]},{name:`web`,display:`Web`,color:S.magenta,children:[{name:`web-vue`,display:`Vue`,color:S.green,hasStyle:!0},{name:`web-react`,display:`React`,color:S.blue,hasStyle:!0}]},{name:`vscode`,display:`VSCode`,color:S.blue,children:[{name:`vscode-base`,display:`Base`,color:S.yellow,public:`public`},{name:`vscode-vue`,display:`Vue`,color:S.green,commonTemplates:[`vscode`],hasStyle:!0,public:`public`},{name:`vscode-react`,display:`React`,color:S.blue,commonTemplates:[`vscode`],hasStyle:!0,public:`public`}]},{name:`electron`,display:`Electron`,color:S.cyan,children:[{name:`electron-vue`,display:`Vue`,color:S.green,commonTemplates:[`electron`],hasStyle:!0},{name:`electron-react`,display:`React`,color:S.blue,commonTemplates:[`electron`],hasStyle:!0}]},{name:`hbuilderx`,display:`HBuilderX`,color:S.yellow,children:[{name:`hbuilderx-base`,display:`Base`,color:S.yellow,public:`public`},{name:`hbuilderx-vue`,display:`Vue`,color:S.green,commonTemplates:[`hbuilderx`],hasStyle:!0,public:`public`},{name:`hbuilderx-react`,display:`React`,color:S.blue,commonTemplates:[`hbuilderx`],hasStyle:!0,public:`public`}]}],D=[{id:`github`,name:`Github`,url:`https://github.com`},{id:`gitcode`,name:`GitCode`,url:`https://gitcode.com`},{id:`gitee`,name:`码云`,url:`https://gitee.com`}],O=`publisher.name.displayName.type.version.private.packageManager.description.author.contributors.license.funding.homepage.repository.publishConfig.bugs.keywords.categories.sideEffects.imports.exports.main.module.unpkg.jsdelivr.types.typesVersions.bin.icon.files.engines.activationEvents.contributes.scripts.peerDependencies.peerDependenciesMeta.dependencies.optionalDependencies.devDependencies.pnpm.overrides.resolutions.husky.simple-git-hooks.lint-staged.eslintConfig`.split(`.`),k=[`dev`,`dev:`,`debug`,`debug:`,`start`,`build`,`build:`,`preview`,`release`,`release:`,`clean`,`clean:`,`test`,`lint`,`lint:`],A=new w({directory:`create-app/logs`}),te=process.platform===`win32`;let j={};function ne(e){j=e}function M(){return j}async function N(e,t){let{trim:n,...r}=Object.assign({stdio:`pipe`,shell:!0},t);Array.isArray(e)&&(e=e.join(` `));let i=e=>{M().verbose?A.debug(e):A.write(e)};i(`$ ${e}`);try{let t=(await C(r)`${e}`).stdout;return i(t),n?t.trim().replace(/\n|\r/g,``):t.trim()}catch(e){let t=e.stderr||e.message;throw i(t),Error(t)}}function P(e){if(e===`C`)return`en-US`;let t=``;try{t=Intl.getCanonicalLocales(e)[0]}catch(t){console.log(`${t.toString()}, invalid language tag: "${e}"\n`)}switch(t){case`zh-TW`:case`zh-HK`:case`zh-MO`:case`zh-CN`:case`zh-SG`:t=`zh-CN`;break;default:t=e}return t}function F(){return P((process.env.LC_ALL||process.env.LC_MESSAGES||process.env.LANG||Intl.DateTimeFormat().resolvedOptions().locale||`en-US`).split(`.`)[0].replace(`_`,`-`))}async function I(e){return await t.promises.readFile(e,`utf-8`).then(e=>JSON.parse(e)||{})}async function L(e){let n=F(),r=a.resolve(e,`${n}.json`),i=a.resolve(e,`en-US.json`);return t.existsSync(r)?await I(r):await I(i)}const R=await L(a.join(T,`locales`));function z(...e){if(e.length===0||!R)return``;let[t,...n]=e,r=R[t]??``;if(n[0]===null||n[0]===void 0||n[0]===``)return r;let i=typeof n[0]==`object`?n[0]:n;return r.replace(/\{([^}]+)\}/g,(e,t)=>i[t]??e)}const B=a.join(o(import.meta.url),`../../`),V=a.join(B,`templates`),H=()=>s.cancel(z(`prompt.cancel`));async function U(e){ne(e);let t=await W(e);t&&(await G(t),e.package&&await ue(t),t.template===`node-vite`&&await de(t.targetDir,t.packageName),e.package||await N(`git init`,{cwd:t.targetDir}))}async function W(e){let n=async function(){let e=await s.select({message:z(`prompt.templateType.message`),options:E.map(e=>({label:e.color(e.display||e.name),value:e.name}))});if(s.isCancel(e))return H();let t=E.find(t=>t.name===e),r=await s.select({message:z(`prompt.template.message`),options:t.children.map(e=>({label:e.color(e.display||e.name),value:e.name})).concat({label:z(`prompt.template.back`),value:`back`})});return s.isCancel(r)?H():r===`back`?await n():{template:r,templateOptions:t.children.find(e=>e.name===r)}},r=await n();if(!r)return;let o=``;await q(`user.email`)===`tom@tomgao.cc`&&(o=`tomjs`);let{template:c,templateOptions:l}=r,u=c.startsWith(`node-`),d=e.packageName;d||(d=l.value||c,o&&u&&(d=`@${o}/${d}`));let f=await s.text({message:z(`prompt.package.message`),initialValue:d,defaultValue:d,placeholder:d,validate:e=>e.length===0||ae(e)?void 0:z(`prompt.package.invalid`)});if(s.isCancel(f))return H();d=f;let p=K(d),m=await s.text({message:z(`prompt.project.message`),defaultValue:p,initialValue:p,placeholder:p,validate:e=>e.length===0||e.length>0?void 0:z(`prompt.project.invalid`)});if(s.isCancel(m))return H();if(p=a.resolve(p===`~`&&!te?i.homedir():e.cwd||process.cwd(),m),t.existsSync(p)&&!re(p)){let t=e.overwrite;if(!t){let e=await s.select({message:z(`prompt.exist.message`,p),options:[{label:z(`prompt.exist.option.no`),value:`no`},{label:z(`prompt.exist.option.yes`),value:`yes`},{label:z(`prompt.exist.option.ignore`),value:`ignore`}]});if(s.isCancel(e))return H();t=e}switch(t){case`yes`:ie(p);break;case`no`:H();return}}let h;if(e.private!==!0&&l.public){let e=await s.confirm({message:z(`prompt.public.message`),active:z(`prompt.confirm.yes`),inactive:z(`prompt.confirm.no`),initialValue:!0});if(s.isCancel(e))return H();h=e}let g;if(h){let e=await s.select({message:z(`prompt.gitUrl.message`),options:D.map(e=>({label:`${e.name} (${e.url})`,value:e.id}))});if(s.isCancel(e))return H();g=D.find(t=>t.id===e)?.url}let _;if(h){o=se(d)||o;let e=await s.text({message:z(`prompt.orgName.message`),defaultValue:o,placeholder:o,validate:e=>o&&!e||oe(e)?void 0:z(`prompt.orgName.invalid`)});if(s.isCancel(e))return H();_=e}return delete l.color,{targetDir:p,orgName:_,packageName:d,template:c,templateOptions:l,isPublic:h,gitUrl:g}}async function G(e){A.debug(`projectOptions:`,e);let{targetDir:t,packageName:o,template:s,isPublic:p,gitUrl:h,orgName:v,templateOptions:b}=e;await l(t);let S=s.includes(`vscode`),C={},w=a.join(t,`.temp`);if(await u(w),await J(C,`base`,w),b.hasStyle&&(await J(C,`style`,w),!s.includes(`vue`))){function e(e){return e.replaceAll(`vue,`,``).replaceAll(`,vue`,``)}let t=await r(a.join(V,`config/style`));for(let n of t){if(n===`package.json`){C.scripts&&Object.keys(C.scripts).forEach(t=>{C.scripts[t].includes(`vue`)&&(C.scripts[t]=e(C.scripts[t]))});continue}let t=a.join(w,n),r=await d(t);r.includes(`vue`)&&g(t,e(r))}}p&&b.public&&await J(C,b.public,w);let T=ee.find(e=>s.includes(`-${e}`));T&&await J(C,T,w);let E=b.commonTemplates;if(Array.isArray(E)&&E.length>0)for(let e of E)await J(C,e,w);if(await c(w,t),await m(w),await c(a.join(V,s),t),y(C,await f(a.join(a.join(V,s),`package.json`))),C.name=o,p){delete C.private,C.name=o,C.license=`MIT`;let e=await q(`user.name`)||i.userInfo().username,n=await q(`user.email`);e&&n?C.author={name:e,email:n}:e&&(C.author=e);let r=`${h}/${v}/${a.basename(t)}`;S&&(C.publisher=v,C.homepage=`${r}/blob/main/README.md`,C.bugs={url:`${r}/issues`},delete C.publishConfig),C.repository={type:`git`,url:`${r}.git`,directory:M().package?`packages/${a.basename(t)}`:void 0}}else C.private=!0,delete C.publishConfig,C.devDependencies&&delete C.devDependencies.publint;if(await _(a.join(t,`package.json`),X(C)),await le(t),p){let{author:e}=C,r=``;e&&(typeof e==`string`?r=e:typeof e==`object`&&(e.name&&e.email?r=`${e.name}<${e.email}>`:e.name?r=e.name:e.email&&(r=e.email)));let i={pkgName:o,dateYear:new Date().getFullYear(),gitUserName:r},s=(await n.readdir(t)).filter(e=>[`README.md`,`README.zh_CN.md`,`LICENSE`].includes(e));for(let e of s){let n=await d(a.join(t,e));Object.keys(i).forEach(e=>{n=n.replace(RegExp(`{{${e}}}`,`g`),i[e])}),await g(a.join(t,e),n)}}let D=await x(`**/_*`,{ignore:[`**/node_modules/**`,`**/.*`],cwd:t});for(let e of D){let r=e.split(`/`);r[r.length-1]=r[r.length-1].substring(1),await n.rename(a.join(t,e),a.join(t,r.join(`/`)))}}function K(e){return(e||``).trim().replace(/^@[^/]+\//,``)}function re(e){return t.readdirSync(e).length===0}function ie(e){t.existsSync(e)&&h(e)}function ae(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function oe(e){return/^[a-z][a-z\d\-._]*$/.test(e)}async function q(e){return N(`git config --get ${e}`,{trim:!0})}function se(e){if(e.startsWith(`@`))return e.split(`/`)[0].substring(1)}async function J(e,r,i){let o=a.join(V,`config/${r}`);if(!t.existsSync(o))return;let s=await n.readdir(o);for(let t of s)[`node_modules`,`.git`].includes(t)||(t===`package.json`?y(e,await f(a.join(o,`package.json`))):await c(a.join(o,t),a.join(i,t)))}function Y(e,t){if(!e)return e;let n={};return Array.isArray(t)&&t.length>0?(t.filter(t=>t in e).forEach(t=>{n[t]=e[t]}),Object.keys(e).filter(e=>!t.includes(e)).sort().forEach(t=>{n[t]=e[t]})):Object.keys(e).sort().forEach(t=>{n[t]=e[t]}),n}function ce(e,t,n){let r={},i=Object.keys(e);{let e=i.filter(e=>e.includes(`:`));i=i.filter(e=>!e.includes(`:`)).sort().concat(e)}let a=s(t),o=s(n);return a.concat(i.filter(e=>!a.includes(e)&&!o.includes(e))).concat(o).forEach(t=>{r[t]=e[t]}),r;function s(e){let t=Array.isArray(e)?e:[];return t.length>0&&(t=t.reduce((e,t)=>{if(t.endsWith(`:`)){let n=i.filter(n=>!e.includes(n)&&n.startsWith(t));return e.concat(n)}return i.includes(t)?e.concat(t):e},[])),t}}function X(e){return e=Y(e,O),e.scripts&&=ce(e.scripts,k,[`prepare`,`prepublishOnly`]),[`dependencies`,`devDependencies`,`peerDependencies`].forEach(t=>{e[t]&&(e[t]=Y(e[t]))}),e}async function le(e){let t=p(a.join(V,`config/package.json`))?.dependencies||{},n=await x(`**/package.json`,{ignore:[`**/node_modules/**`,`**/.*`],cwd:e});for(let r of n){let n=a.join(e,r),i=await f(n);[`dependencies`,`devDependencies`].forEach(e=>{let n=i[e];n&&Object.keys(n).forEach(e=>{n[e]=t[e]||n[e]})}),_(n,X(i))}}async function ue(e){let n=e.templateOptions.hasStyle,r=[`.editorconfig`,`.gitignore`,`.gitattributes`,`commitlint.config.mjs`,`simple-git-hooks.mjs`,`pnpm-workspace.yaml`];n||r.push(`lint-staged.config.mjs`),[`vscode`,`electron`].find(t=>e.template.startsWith(t))||r.push(`.vscode`),r.forEach(n=>{let r=a.join(e.targetDir,n);t.existsSync(r)&&h(r)});let i=await f(a.join(e.targetDir,`package.json`));if(i.scripts&&delete i.scripts.prepare,!n)delete i.devDependencies;else if(i.devDependencies){let e=await f(a.join(V,`config/style/package.json`)),t=Object.keys(e.devDependencies||{});Object.keys(i.devDependencies).forEach(e=>{t.includes(e)||delete i.devDependencies[e]})}await _(a.join(e.targetDir,`package.json`),i)}async function de(e,t){let n=v((t.split(`/`).pop()||``).replace(`vite-plugin`,``)||`xxx`),r=await x([`src/**/*.ts`,`examples/*/vite.config.ts`,`examples/*/package.json`],{ignore:[`**/node_modules/**`,`**/.*`],cwd:e});for(let t of r){let r=a.join(e,t);await g(r,(await d(r)).replaceAll(`xxx`,n).replaceAll(`Xxx`,b(n)))}}const Z=e(`
|
|
2
2
|
Usage
|
|
3
3
|
$ create-app [options] <package-name>
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomjs/create-app",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.2.0",
|
|
5
5
|
"description": "Create a node/web/electron/vscode project based on tomjs",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Tom Gao",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@clack/prompts": "^0.11.0",
|
|
51
|
-
"@tomjs/logger": "^
|
|
51
|
+
"@tomjs/logger": "^3.0.0",
|
|
52
52
|
"@tomjs/node": "^2.2.3",
|
|
53
53
|
"chalk": "^5.6.2",
|
|
54
54
|
"dayjs": "^1.11.19",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"@antfu/eslint-config": "^6.7.3",
|
|
62
62
|
"@commitlint/cli": "^20.3.0",
|
|
63
63
|
"@tomjs/commitlint": "^5.0.0",
|
|
64
|
-
"@tomjs/eslint": "^6.
|
|
65
|
-
"@tomjs/stylelint": "^7.
|
|
66
|
-
"@tomjs/tsconfig": "^3.0
|
|
64
|
+
"@tomjs/eslint": "^6.5.0",
|
|
65
|
+
"@tomjs/stylelint": "^7.1.0",
|
|
66
|
+
"@tomjs/tsconfig": "^3.2.0",
|
|
67
67
|
"@tsconfig/node20": "^20.1.8",
|
|
68
68
|
"@types/lodash-es": "^4.17.12",
|
|
69
69
|
"@types/node": "^20.19.27",
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
"build": "vite build"
|
|
6
6
|
},
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"@tomjs/vite-plugin-electron": "^2.2
|
|
8
|
+
"@tomjs/vite-plugin-electron": "^2.4.2",
|
|
9
9
|
"electron": "^39.2.7",
|
|
10
|
-
"electron-builder": "^26.0
|
|
10
|
+
"electron-builder": "^26.4.0",
|
|
11
11
|
"vite-plugin-electron-renderer": "^0.14.6"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ExtensionContext } from 'hbuilderx';
|
|
2
|
+
import { setContext } from '@tomjs/hbuilderx';
|
|
3
|
+
import { commands } from 'hbuilderx';
|
|
4
|
+
import { createDialogWebview, createLeftWebview, createRightWebview } from './webview';
|
|
5
|
+
|
|
6
|
+
export function activate(context: ExtensionContext) {
|
|
7
|
+
setContext(context);
|
|
8
|
+
|
|
9
|
+
context.subscriptions.push(
|
|
10
|
+
commands.registerCommand('tomjs.ext.showLeftWebview', async () => {
|
|
11
|
+
createLeftWebview();
|
|
12
|
+
}),
|
|
13
|
+
commands.registerCommand('tomjs.ext.showRightWebview', async () => {
|
|
14
|
+
createRightWebview();
|
|
15
|
+
}),
|
|
16
|
+
commands.registerCommand('tomjs.ext.showWebviewDialog', async () => {
|
|
17
|
+
createDialogWebview();
|
|
18
|
+
}),
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function deactivate() { }
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { WebViewDialog, WebViewPanel } from 'hbuilderx';
|
|
2
|
+
import { getContext } from '@tomjs/hbuilderx';
|
|
3
|
+
import { window } from 'hbuilderx';
|
|
4
|
+
import { getWebviewHtml } from 'virtual:hbuilderx';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description 显示webview
|
|
8
|
+
*/
|
|
9
|
+
function showWebView(webviewPanel: WebViewPanel | WebViewDialog) {
|
|
10
|
+
const webview = webviewPanel.webView;
|
|
11
|
+
|
|
12
|
+
webview.html = getWebviewHtml({
|
|
13
|
+
// dev server
|
|
14
|
+
serverUrl: process.env.VITE_DEV_SERVER_URL,
|
|
15
|
+
// build
|
|
16
|
+
context: getContext(),
|
|
17
|
+
injectCode: `<script>window.__FLAG1__=666;window.__FLAG2__=888;console.log(window.__FLAG1__);</script>`,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// 插件接收webview发送的消息(可以被JSON化的数据)
|
|
21
|
+
webview.onDidReceiveMessage((msg) => {
|
|
22
|
+
console.log('extension msg:', msg);
|
|
23
|
+
if (msg.command === 'alert') {
|
|
24
|
+
window.showInformationMessage(msg.text);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
let leftWebviewPanel: WebViewPanel;
|
|
30
|
+
export function createLeftWebview() {
|
|
31
|
+
if (!leftWebviewPanel) {
|
|
32
|
+
leftWebviewPanel = window.createWebView('tomjs.webview.left', {
|
|
33
|
+
enableScripts: true,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
showWebView(leftWebviewPanel);
|
|
38
|
+
|
|
39
|
+
window.showView({
|
|
40
|
+
containerId: 'tomjsActivitybar',
|
|
41
|
+
viewId: 'tomjs.webview.left',
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
let rightWebviewPanel: WebViewPanel;
|
|
46
|
+
export function createRightWebview() {
|
|
47
|
+
if (!rightWebviewPanel) {
|
|
48
|
+
rightWebviewPanel = window.createWebView('tomjs.webview.right', {
|
|
49
|
+
enableScripts: true,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
showWebView(rightWebviewPanel);
|
|
54
|
+
|
|
55
|
+
window.showView({
|
|
56
|
+
containerId: 'tomjsRightSide',
|
|
57
|
+
viewId: 'tomjs.webview.right',
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export function createDialogWebview() {
|
|
62
|
+
const dialogWebviewPanel = window.createWebViewDialog({
|
|
63
|
+
title: 'Dialog Webview',
|
|
64
|
+
}, {
|
|
65
|
+
enableScripts: true,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
showWebView(dialogWebviewPanel);
|
|
69
|
+
|
|
70
|
+
dialogWebviewPanel.show();
|
|
71
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"keywords": [
|
|
3
|
+
"HBuilderX"
|
|
4
|
+
],
|
|
5
|
+
"categories": [
|
|
6
|
+
"Other"
|
|
7
|
+
],
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=16.17.0",
|
|
10
|
+
"HBuilderX": "^2.7.0"
|
|
11
|
+
},
|
|
12
|
+
"activationEvents": [],
|
|
13
|
+
"contributes": {
|
|
14
|
+
"commands": [
|
|
15
|
+
{
|
|
16
|
+
"command": "tomjs.ext.showLeftWebview",
|
|
17
|
+
"title": "触发左侧视图"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"command": "tomjs.ext.showRightWebview",
|
|
21
|
+
"title": "触发右侧视图"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"command": "tomjs.ext.showWebviewDialog",
|
|
25
|
+
"title": "触发弹框视图"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"menus": {
|
|
29
|
+
"editor/context": [
|
|
30
|
+
{
|
|
31
|
+
"command": "tomjs.ext.showLeftWebview",
|
|
32
|
+
"group": "z_commands",
|
|
33
|
+
"when": "editorTextFocus"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"command": "tomjs.ext.showRightWebview",
|
|
37
|
+
"group": "z_commands",
|
|
38
|
+
"when": "editorTextFocus"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"command": "tomjs.ext.showWebviewDialog",
|
|
42
|
+
"group": "z_commands",
|
|
43
|
+
"when": "editorTextFocus"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"command": "tomjs.ext.showCustomEditor",
|
|
47
|
+
"group": "z_commands",
|
|
48
|
+
"when": "editorTextFocus"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"group": "z_commands"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
"viewsContainers": {
|
|
56
|
+
"activitybar": [
|
|
57
|
+
{
|
|
58
|
+
"id": "tomjsActivitybar",
|
|
59
|
+
"title": "左侧webview展示"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"rightside": [
|
|
63
|
+
{
|
|
64
|
+
"id": "tomjsRightSide",
|
|
65
|
+
"title": "右侧webview展示"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
"views": {
|
|
70
|
+
"tomjsActivitybar": [
|
|
71
|
+
{
|
|
72
|
+
"id": "tomjs.webview.left",
|
|
73
|
+
"title": "webview - 展示"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"tomjsRightSide": [
|
|
77
|
+
{
|
|
78
|
+
"id": "tomjs.webview.right",
|
|
79
|
+
"title": "webview - 展示"
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"scripts": {
|
|
85
|
+
"dev": "run-p dev:*",
|
|
86
|
+
"dev:vite": "vite",
|
|
87
|
+
"dev:cli": "hx-cli --watch"
|
|
88
|
+
},
|
|
89
|
+
"dependencies": {
|
|
90
|
+
"@tomjs/hbuilderx": "^1.2.0"
|
|
91
|
+
},
|
|
92
|
+
"devDependencies": {
|
|
93
|
+
"@tomjs/hbuilderx-cli": "^1.3.1",
|
|
94
|
+
"@tomjs/vite-plugin-hbuilderx": "^1.3.0"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@tomjs/tsconfig/node.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
5
|
+
"types": [
|
|
6
|
+
"@tomjs/hbuilderx/types",
|
|
7
|
+
"@tomjs/vite-plugin-hbuilderx/types"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"include": [
|
|
11
|
+
"hbuilderx.d.ts",
|
|
12
|
+
"extension",
|
|
13
|
+
"vite.config.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -2,34 +2,40 @@
|
|
|
2
2
|
"dependencies": {
|
|
3
3
|
"@antfu/eslint-config": "^6.7.3",
|
|
4
4
|
"@clack/prompts": "^0.11.0",
|
|
5
|
-
"@commitlint/cli": "^20.3.
|
|
6
|
-
"@eslint-react/eslint-plugin": "^2.5.
|
|
5
|
+
"@commitlint/cli": "^20.3.1",
|
|
6
|
+
"@eslint-react/eslint-plugin": "^2.5.5",
|
|
7
7
|
"@tomjs/commitlint": "^5.0.0",
|
|
8
|
-
"@tomjs/eslint": "^6.
|
|
9
|
-
"@tomjs/
|
|
8
|
+
"@tomjs/eslint": "^6.5.0",
|
|
9
|
+
"@tomjs/hbuilderx": "^1.2.0",
|
|
10
|
+
"@tomjs/hbuilderx-cli": "^1.3.1",
|
|
11
|
+
"@tomjs/logger": "^3.0.0",
|
|
10
12
|
"@tomjs/node": "^2.2.3",
|
|
11
|
-
"@tomjs/stylelint": "^7.
|
|
12
|
-
"@tomjs/tsconfig": "^3.0
|
|
13
|
-
"@tomjs/vite-plugin-electron": "^2.2
|
|
14
|
-
"@tomjs/vite-plugin-
|
|
13
|
+
"@tomjs/stylelint": "^7.1.1",
|
|
14
|
+
"@tomjs/tsconfig": "^3.2.0",
|
|
15
|
+
"@tomjs/vite-plugin-electron": "^2.4.2",
|
|
16
|
+
"@tomjs/vite-plugin-hbuilderx": "^1.3.0",
|
|
17
|
+
"@tomjs/vite-plugin-vscode": "^7.0.0",
|
|
15
18
|
"@tomjs/vscode": "^2.5.0",
|
|
16
19
|
"@tomjs/vscode-dev": "^3.1.2",
|
|
17
20
|
"@tomjs/vscode-webview": "^2.0.2",
|
|
18
|
-
"@types/node": "^20.19.
|
|
19
|
-
"@types/react": "^19.2.
|
|
21
|
+
"@types/node": "^20.19.28",
|
|
22
|
+
"@types/react": "^19.2.8",
|
|
20
23
|
"@types/react-dom": "^19.2.3",
|
|
21
24
|
"@types/vscode": "^1.56.0",
|
|
22
25
|
"@types/vscode-webview": "^1.57.5",
|
|
26
|
+
"@unocss/eslint-plugin": "^66.5.12",
|
|
23
27
|
"@vitejs/plugin-react": "^5.1.2",
|
|
24
28
|
"@vitejs/plugin-react-swc": "^4.2.2",
|
|
25
29
|
"@vitejs/plugin-vue": "^6.0.3",
|
|
26
30
|
"@vscode/webview-ui-toolkit": "^1.4.0",
|
|
27
31
|
"@vue/tsconfig": "^0.8.1",
|
|
32
|
+
"@vueuse/core": "^14.1.0",
|
|
28
33
|
"chalk": "^5.6.2",
|
|
29
34
|
"cosmiconfig": "^9.0.0",
|
|
30
35
|
"cross-env": "^10.1.0",
|
|
36
|
+
"dayjs": "^1.11.19",
|
|
31
37
|
"electron": "^39.2.7",
|
|
32
|
-
"electron-builder": "^26.0
|
|
38
|
+
"electron-builder": "^26.4.0",
|
|
33
39
|
"eslint": "^9.39.2",
|
|
34
40
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
35
41
|
"eslint-plugin-react-refresh": "^0.4.26",
|
|
@@ -38,20 +44,25 @@
|
|
|
38
44
|
"meow": "^14.0.0",
|
|
39
45
|
"npm-run-all2": "^8.0.4",
|
|
40
46
|
"ora": "^9.0.0",
|
|
47
|
+
"pinia": "^3.0.4",
|
|
41
48
|
"publint": "0.3.16",
|
|
42
49
|
"react": "^19.2.3",
|
|
43
50
|
"react-dom": "^19.2.3",
|
|
44
|
-
"sass": "^1.97.
|
|
51
|
+
"sass": "^1.97.2",
|
|
45
52
|
"simple-git-hooks": "^2.13.1",
|
|
46
53
|
"stylelint": "^16.26.1",
|
|
47
|
-
"tsdown": "^0.
|
|
54
|
+
"tsdown": "^0.19.0",
|
|
48
55
|
"tsx": "^4.21.0",
|
|
49
56
|
"typescript": "~5.9.3",
|
|
50
|
-
"
|
|
57
|
+
"unocss": "^66.5.12",
|
|
58
|
+
"unplugin-auto-import": "^20.3.0",
|
|
59
|
+
"unplugin-vue-components": "^30.0.0",
|
|
60
|
+
"vite": "^7.3.1",
|
|
51
61
|
"vite-plugin-electron-renderer": "^0.14.6",
|
|
52
62
|
"vite-plugin-vue-devtools": "^8.0.5",
|
|
53
63
|
"vue": "^3.5.26",
|
|
54
64
|
"vue-i18n": "^11.2.8",
|
|
55
|
-
"vue-
|
|
65
|
+
"vue-router": "^4.6.4",
|
|
66
|
+
"vue-tsc": "^3.2.2"
|
|
56
67
|
}
|
|
57
68
|
}
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
"react-dom": "^19.2.3"
|
|
5
5
|
},
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@eslint-react/eslint-plugin": "^2.5.
|
|
8
|
-
"@types/react": "^19.2.
|
|
7
|
+
"@eslint-react/eslint-plugin": "^2.5.5",
|
|
8
|
+
"@types/react": "^19.2.8",
|
|
9
9
|
"@types/react-dom": "^19.2.3",
|
|
10
10
|
"@vitejs/plugin-react-swc": "^4.2.2",
|
|
11
11
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
12
12
|
"eslint-plugin-react-refresh": "^0.4.26",
|
|
13
|
-
"vite": "^7.3.
|
|
13
|
+
"vite": "^7.3.1"
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "@tomjs/tsconfig/react-dom.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"composite": true,
|
|
5
4
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
5
|
+
"paths": {
|
|
6
|
+
"@/*": ["./src/*"]
|
|
7
|
+
},
|
|
6
8
|
"types": ["vite/client"]
|
|
7
9
|
},
|
|
8
10
|
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts"]
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
+
"@vueuse/core": "^14.1.0",
|
|
4
|
+
"pinia": "^3.0.4",
|
|
3
5
|
"vue": "^3.5.26"
|
|
4
6
|
},
|
|
5
7
|
"devDependencies": {
|
|
8
|
+
"@unocss/eslint-plugin": "^66.5.12",
|
|
6
9
|
"@vitejs/plugin-vue": "^6.0.3",
|
|
7
|
-
"
|
|
10
|
+
"unocss": "^66.5.12",
|
|
11
|
+
"unplugin-auto-import": "^20.3.0",
|
|
12
|
+
"unplugin-vue-components": "^30.0.0",
|
|
13
|
+
"vite": "^7.3.1",
|
|
8
14
|
"vite-plugin-vue-devtools": "^8.0.5",
|
|
9
|
-
"vue-tsc": "^3.2.
|
|
15
|
+
"vue-tsc": "^3.2.2"
|
|
10
16
|
}
|
|
11
17
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "@tomjs/tsconfig/vue-dom.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"composite": true,
|
|
5
4
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
6
|
-
"
|
|
5
|
+
"paths": {
|
|
6
|
+
"@/*": ["./src/*"]
|
|
7
|
+
}
|
|
7
8
|
},
|
|
8
|
-
"include": [
|
|
9
|
+
"include": [
|
|
10
|
+
"env.d.ts",
|
|
11
|
+
"src/**/*",
|
|
12
|
+
"src/**/*.vue"
|
|
13
|
+
]
|
|
9
14
|
}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
1
2
|
import electron from '@tomjs/vite-plugin-electron';
|
|
2
3
|
import react from '@vitejs/plugin-react-swc';
|
|
3
4
|
import { defineConfig } from 'vite';
|
|
4
5
|
import renderer from 'vite-plugin-electron-renderer';
|
|
5
6
|
|
|
6
7
|
export default defineConfig({
|
|
8
|
+
resolve: {
|
|
9
|
+
alias: {
|
|
10
|
+
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
11
|
+
},
|
|
12
|
+
},
|
|
7
13
|
plugins: [
|
|
8
14
|
react(),
|
|
9
|
-
electron({
|
|
10
|
-
external: ['fs-extra'],
|
|
11
|
-
}),
|
|
12
15
|
renderer(),
|
|
16
|
+
electron(),
|
|
13
17
|
],
|
|
14
18
|
});
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
"build": "vue-tsc --noEmit && vite build",
|
|
13
13
|
"release": "vue-tsc --noEmit && cross-env VITE_ELECTRON_BUILDER=1 vite build"
|
|
14
14
|
},
|
|
15
|
-
"dependencies": {
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"vue-router": "^4.6.4"
|
|
17
|
+
},
|
|
16
18
|
"devDependencies": {
|
|
17
19
|
"vite-plugin-electron-renderer": "^0.14.6"
|
|
18
20
|
}
|
|
@@ -1,14 +1,28 @@
|
|
|
1
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
1
2
|
import electron from '@tomjs/vite-plugin-electron';
|
|
2
3
|
import vue from '@vitejs/plugin-vue';
|
|
4
|
+
import UnoCSS from 'unocss/vite';
|
|
5
|
+
import AutoImport from 'unplugin-auto-import/vite';
|
|
6
|
+
import Components from 'unplugin-vue-components/vite';
|
|
3
7
|
import { defineConfig } from 'vite';
|
|
4
8
|
import renderer from 'vite-plugin-electron-renderer';
|
|
5
9
|
import devtools from 'vite-plugin-vue-devtools';
|
|
6
10
|
|
|
7
11
|
export default defineConfig({
|
|
12
|
+
resolve: {
|
|
13
|
+
alias: {
|
|
14
|
+
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
15
|
+
},
|
|
16
|
+
},
|
|
8
17
|
plugins: [
|
|
9
18
|
vue(),
|
|
10
|
-
|
|
11
|
-
|
|
19
|
+
AutoImport({
|
|
20
|
+
imports: ['vue', 'vue-router'],
|
|
21
|
+
}),
|
|
22
|
+
Components(),
|
|
23
|
+
UnoCSS(),
|
|
12
24
|
renderer(),
|
|
25
|
+
electron({ builder: true }),
|
|
26
|
+
devtools(),
|
|
13
27
|
],
|
|
14
28
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# hbuilderx-base
|
|
2
|
+
|
|
3
|
+
简单命令弹框插件
|
|
4
|
+
|
|
5
|
+
## 使用
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 开发模式,不压缩代码
|
|
9
|
+
pnpm dev
|
|
10
|
+
# 生产模式,压缩代码
|
|
11
|
+
pnpm build
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 调试
|
|
15
|
+
|
|
16
|
+
根据以下步骤调试插件,具体参考官方[插件教程](https://hx.dcloud.net.cn/ExtensionTutorial/firstExtension)
|
|
17
|
+
|
|
18
|
+
- 将当前项目 `hbuilderx-base` 拖拽到 `HBuilderX` 中
|
|
19
|
+
- 点击左上 `运行` 图标,选择点击 `运行插件-[hbuilderx-base]` 或 `调试插件-[hbuilderx-base]`,会打开的 `HBuilderX` 窗口调试插件。
|
|
20
|
+
- 在调试导入或创建任意项目,打开任意文件,在文件编辑器中点击鼠标右唤出菜单,选择 `Hello World` 选项, 会在右下角弹出提示框。
|