@tomjs/create-app 1.0.0-alpha.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +8 -7
- package/package.json +11 -11
- package/templates/base/core/.commitlintrc.cjs +3 -0
- package/templates/base/core/.editorconfig +15 -0
- package/templates/base/core/.eslintignore +14 -0
- package/templates/base/core/.gitattributes +203 -0
- package/templates/base/core/.husky/commit-msg +1 -0
- package/templates/base/core/.husky/pre-commit +1 -0
- package/templates/base/core/.prettierignore +17 -0
- package/templates/base/core/.prettierrc.cjs +1 -0
- package/templates/base/core/_eslintrc.cjs +7 -0
- package/templates/base/core/_gitignore +60 -0
- package/templates/base/core/_lintstagedrc.cjs +4 -0
- package/templates/base/core/package.json +30 -0
- package/templates/base/electron/.vscode/launch.json +28 -0
- package/templates/base/electron/.vscode/tasks.json +37 -0
- package/templates/base/electron/electron/env.d.ts +1 -0
- package/templates/base/electron/electron/main/index.ts +111 -0
- package/templates/base/electron/electron/polyfills.ts +4 -0
- package/templates/base/electron/electron/preload/index.ts +1 -0
- package/templates/base/electron/package.json +25 -0
- package/templates/base/electron/tsconfig.node.json +7 -0
- package/templates/base/node/LICENSE +21 -0
- package/templates/base/node/README.md +13 -0
- package/templates/base/node/README.zh_CN.md +13 -0
- package/templates/base/node/package.json +46 -0
- package/templates/base/node/test/index.test.ts +7 -0
- package/templates/base/react/_eslintrc.cjs +7 -0
- package/templates/base/react/_lintstagedrc.cjs +6 -0
- package/templates/base/react/package.json +19 -0
- package/templates/base/react/tsconfig.json +5 -0
- package/templates/base/react/tsconfig.node.json +7 -0
- package/templates/base/style/.stylelintignore +16 -0
- package/templates/base/style/.stylelintrc.cjs +3 -0
- package/templates/base/style/_lintstagedrc.cjs +5 -0
- package/templates/base/style/package.json +10 -0
- package/templates/base/vscode/.vscode/extensions.json +5 -0
- package/templates/base/vscode/.vscode/launch.json +21 -0
- package/templates/base/vscode/.vscode/settings.json +3 -0
- package/templates/base/vscode/.vscode/tasks.json +36 -0
- package/templates/base/vscode/.vscodeignore +73 -0
- package/templates/base/vscode/LICENSE +21 -0
- package/templates/base/vscode/_gitignore +63 -0
- package/templates/base/vscode/extension/env.d.ts +1 -0
- package/templates/base/vscode/extension/index.ts +21 -0
- package/templates/base/vscode/extension/views/helper.ts +27 -0
- package/templates/base/vscode/extension/views/panel.ts +48 -0
- package/templates/base/vscode/locales/en.json +6 -0
- package/templates/base/vscode/locales/zh-CN.json +5 -0
- package/templates/base/vscode/locales/zh-TW.json +5 -0
- package/templates/base/vscode/package.json +70 -0
- package/templates/base/vscode/resources/logo.png +0 -0
- package/templates/base/vscode/tsconfig.node.json +7 -0
- package/templates/base/vue/_eslintrc.cjs +7 -0
- package/templates/base/vue/_lintstagedrc.cjs +6 -0
- package/templates/base/vue/package.json +17 -0
- package/templates/base/vue/tsconfig.json +5 -0
- package/templates/base/vue/tsconfig.node.json +7 -0
- package/templates/config.json +105 -0
- package/templates/electron-react/README.md +3 -0
- package/templates/electron-react/electron/main/index.ts +128 -0
- package/templates/electron-react/index.html +15 -0
- package/templates/electron-react/package.json +26 -0
- package/templates/electron-react/public/img/icon.png +0 -0
- package/templates/electron-react/public/vite.svg +1 -0
- package/templates/electron-react/src/App.css +45 -0
- package/templates/electron-react/src/App.tsx +42 -0
- package/templates/electron-react/src/assets/electron.svg +10 -0
- package/templates/electron-react/src/assets/react.svg +1 -0
- package/templates/electron-react/src/index.css +69 -0
- package/templates/electron-react/src/main.tsx +11 -0
- package/templates/electron-react/src/vite-env.d.ts +1 -0
- package/templates/electron-react/vite.config.ts +27 -0
- package/templates/electron-vue/README.md +3 -0
- package/templates/electron-vue/electron/main/index.ts +123 -0
- package/templates/electron-vue/package.json +6 -0
- package/templates/electron-vue/public/img/icon.png +0 -0
- package/templates/electron-vue/public/vite.svg +1 -0
- package/templates/electron-vue/src/App.vue +55 -0
- package/templates/electron-vue/src/assets/electron.svg +10 -0
- package/templates/electron-vue/src/assets/vue.svg +1 -0
- package/templates/electron-vue/src/components/HelloWorld.vue +43 -0
- package/templates/electron-vue/src/main.ts +6 -0
- package/templates/electron-vue/src/style.css +80 -0
- package/templates/electron-vue/src/vite-env.d.ts +1 -0
- package/templates/electron-vue/vite.config.ts +26 -0
- package/templates/node/package.json +12 -0
- package/templates/node/src/index.ts +3 -0
- package/templates/node/tsconfig.json +4 -0
- package/templates/node/tsup.config.ts +19 -0
- package/templates/node-cli/.vscode/launch.json +23 -0
- package/templates/node-cli/index.d.ts +5 -0
- package/templates/node-cli/package.json +33 -0
- package/templates/node-cli/src/cli.ts +68 -0
- package/templates/node-cli/src/config.ts +28 -0
- package/templates/node-cli/src/constants.ts +1 -0
- package/templates/node-cli/src/index.ts +3 -0
- package/templates/node-cli/src/types.ts +1 -0
- package/templates/node-cli/tsconfig.json +4 -0
- package/templates/node-cli/tsup.config.ts +18 -0
- package/templates/node-cli/xxx.config.cjs +0 -0
- package/templates/node-cli-legacy/.vscode/launch.json +23 -0
- package/templates/node-cli-legacy/index.d.ts +5 -0
- package/templates/node-cli-legacy/package.json +31 -0
- package/templates/node-cli-legacy/src/cli.ts +45 -0
- package/templates/node-cli-legacy/src/config.ts +28 -0
- package/templates/node-cli-legacy/src/index.ts +3 -0
- package/templates/node-cli-legacy/src/types.ts +1 -0
- package/templates/node-cli-legacy/src/utils.ts +5 -0
- package/templates/node-cli-legacy/tsconfig.json +4 -0
- package/templates/node-cli-legacy/tsup.config.ts +18 -0
- package/templates/node-cli-legacy/xxx.config.cjs +0 -0
- package/templates/node-vite-plugin/package.json +19 -0
- package/templates/node-vite-plugin/src/index.ts +10 -0
- package/templates/node-vite-plugin/src/types.ts +1 -0
- package/templates/node-vite-plugin/test/index.test.ts +7 -0
- package/templates/node-vite-plugin/tsconfig.json +4 -0
- package/templates/node-vite-plugin/tsup.config.ts +18 -0
- package/templates/node-workspaces/package.json +10 -0
- package/templates/react/index.html +14 -0
- package/templates/react/package.json +12 -0
- package/templates/react/public/vite.svg +1 -0
- package/templates/react/src/App.css +42 -0
- package/templates/react/src/App.tsx +32 -0
- package/templates/react/src/assets/react.svg +1 -0
- package/templates/react/src/index.css +69 -0
- package/templates/react/src/main.tsx +11 -0
- package/templates/react/src/vite-env.d.ts +1 -0
- package/templates/react/vite.config.ts +7 -0
- package/templates/schema.json +110 -0
- package/templates/vscode/.vscode/extensions.json +5 -0
- package/templates/vscode/.vscode/launch.json +21 -0
- package/templates/vscode/.vscode/settings.json +3 -0
- package/templates/vscode/.vscode/tasks.json +36 -0
- package/templates/vscode/.vscodeignore +72 -0
- package/templates/vscode/LICENSE +21 -0
- package/templates/vscode/README.md +3 -0
- package/templates/vscode/_gitignore +63 -0
- package/templates/vscode/locales/en.json +5 -0
- package/templates/vscode/locales/zh-CN.json +5 -0
- package/templates/vscode/locales/zh-TW.json +5 -0
- package/templates/vscode/package.json +57 -0
- package/templates/vscode/resources/logo.png +0 -0
- package/templates/vscode/src/index.ts +15 -0
- package/templates/vscode/tsconfig.json +5 -0
- package/templates/vscode/tsup.config.ts +13 -0
- package/templates/vscode-react/README.md +3 -0
- package/templates/vscode-react/index.html +14 -0
- package/templates/vscode-react/package.json +1 -0
- package/templates/vscode-react/src/App.css +7 -0
- package/templates/vscode-react/src/App.tsx +51 -0
- package/templates/vscode-react/src/main.tsx +9 -0
- package/templates/vscode-react/src/utils/index.ts +1 -0
- package/templates/vscode-react/src/utils/vscode.ts +83 -0
- package/templates/vscode-react/src/vite-env.d.ts +1 -0
- package/templates/vscode-react/vite.config.ts +20 -0
- package/templates/vscode-vue/README.md +3 -0
- package/templates/vscode-vue/index.html +14 -0
- package/templates/vscode-vue/package.json +6 -0
- package/templates/vscode-vue/src/App.vue +58 -0
- package/templates/vscode-vue/src/main.ts +4 -0
- package/templates/vscode-vue/src/utils/index.ts +1 -0
- package/templates/vscode-vue/src/utils/vscode.ts +83 -0
- package/templates/vscode-vue/src/vite-env.d.ts +1 -0
- package/templates/vscode-vue/vite.config.ts +29 -0
- package/templates/vue/electron/main/index.ts +123 -0
- package/templates/vue/index.html +14 -0
- package/templates/vue/package.json +12 -0
- package/templates/vue/public/vite.svg +1 -0
- package/templates/vue/src/App.vue +32 -0
- package/templates/vue/src/assets/vue.svg +1 -0
- package/templates/vue/src/components/HelloWorld.vue +37 -0
- package/templates/vue/src/main.ts +6 -0
- package/templates/vue/src/style.css +80 -0
- package/templates/vue/src/vite-env.d.ts +1 -0
- package/templates/vue/vite.config.ts +7 -0
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
${
|
|
3
|
-
`)}`)}else
|
|
4
|
-
${
|
|
1
|
+
import Ge from"meow";import w from"node:fs";import Oe from"node:os";import g from"node:path";import{fileURLToPath as Pe}from"node:url";import{copySync as Ae,mkdirSync as $e,readFileSync as ie,readJsonSync as ae,rmSync as N,writeFileSync as T,writeJsonSync as Ee}from"@tomjs/node";import x from"chalk";import{camelCase as De,cloneDeep as ce,merge as Se}from"lodash-es";import B from"node:os";import X from"node:path";import{mkdirSync as xe,readJsonSync as ve,writeJsonSync as be}from"@tomjs/node";import j from"chalk";import ke from"inquirer";import we from"@tomjs/logger";import{$ as he}from"execa";import E from"inquirer";var y=new we({directory:"create-app/logs"});function D(e,t,r){let n={message:e};return Array.isArray(t)||typeof t!="object"?n.default=t:Object.assign(n,t),Object.assign(n,r)}async function h(e,t){let r=`confirm-${Date.now()}`,n=D(e,t);return(await E.prompt([{type:"confirm",name:r,...n}]))[r]}async function _(e,t){let r=`input-${Date.now()}`,{required:n,...o}=D(e,t),i=n??!0,c=o.validate;return(i||c)&&(o.validate=s=>{let l=(s||"").trim();return i&&!l?"It's required!":c?c(s):!0}),(await E.prompt([{type:"input",name:r,...o}]))[r]}async function K(e,t,r){let n=`checkbox-${Date.now()}`,{required:o,min:i,max:c,...p}=D(e,r),s=o??!0,l=p.validate;return(s||i||c)&&(p.validate=a=>s&&a.length===0?"Please select at least one option":i&&a.length<i?`Please select at least ${i} options`:c&&a.length>c?`Please select at most ${c} options`:l?l(a):!0),(await E.prompt([{type:"checkbox",name:n,choices:t,pageSize:Math.min(t.length,10),...p}]))[n]}async function b(e,t,r){let n=`list-${Date.now()}`,o=D(e,r);return(await E.prompt([{type:"list",name:n,choices:t,pageSize:Math.min(t.length,10),...o}]))[n]}var U={cwd:"."};async function S(e,t){let{trim:r,...n}=Object.assign({stdio:"pipe",shell:!0,cwd:U.cwd},t);n.cwd??=U.cwd,Array.isArray(e)&&(e=e.join(" "));let o=i=>{U.verbose?y.debug(i):y.write(i)};o(`$ ${e}`);try{let c=(await he(n)`${e}`).stdout;return o(c),r?c.trim().replace(/\n|\r/g,""):c.trim()}catch(i){let c=i.stderr||i.message;throw o(c),new Error(c)}}function Q(e){if(e&&e.packageManager)return e.packageManager.split("@")[0];let t=process.env.npm_config_user_agent;return t?t.split(" ")[0].split("/")[0]:void 0}var Y={repo:"https://github.com",owner:B.userInfo().username};function q(e){let{repo:t,owner:r}=e;return`${t}${t.endsWith("/")?"":"/"}${r}`}async function H(e){let t=await ke.prompt([{type:"text",name:"repo",message:`${e?.repo?"Edit":"Add"} git repository url:`,default:e?.repo||Y.repo},{type:"text",name:"owner",message:`${e?.owner?"Edit":"Add"} git repository owner:`,default:e?.owner||Y.owner}]);return{id:e?.id||Date.now().toString(),repo:t.repo,owner:t.owner}}var Z=X.join(B.homedir(),".tomjs","create-app"),ee=X.join(Z,"config.json");function C(){return xe(Z),Object.assign({gitRepos:[]},ve(ee))}function je(e){let t=C();t.createTime?t.updateTime=Date.now():t.createTime=Date.now(),be(ee,Object.assign(t,e))}function G(e){je({gitRepos:e})}async function k(e,t=!1){e||(e=C().gitRepos||[]);let r=e.map(p=>({name:q(p),value:p.id})).concat([{name:j.green("+ Add"),value:"add"},{name:j.yellow("\u2190 Exit"),value:"exit"}]),n=await b(e.length===0?"You choose to add or exit:":"You can choose the repository to be operated, or choose to add or exit:",r);if(n==="exit")return;if(n==="add"){let p=await H();return e.push(p),G(e),k(e,t)}let o=e.findIndex(p=>p.id===n),i=await b("Select an action?",[{name:j.green("^ Edit"),value:"edit"},{name:j.red("- Remove"),value:"remove"},{name:j.yellow("\u2190 Exit"),value:"exit"}]);if(i==="exit")return t?k(e,t):C();if(i==="remove")return await h("Where confirm to remove?",!0)&&(e.splice(o,1),G(e)),k(e,t);let c=await H(e[o]);return e[o]=c,G(e),k(e,t)}async function te(){let e=C(),{gitRepos:t}=e;return t.length===0&&(console.log(`You need to set the ${j.blue("git remote repository")} for the first time.`),await k(t)),e}var v={},Ce=g.join(Pe(import.meta.url),"../../"),pe=g.join(Ce,"templates"),Te=ae(g.join(pe,"config.json"))||{},O=Te.list||[],I=O.map(e=>e.variants?e.variants.map(t=>({parent:e,...t})):[]).flat(),Ie=O.map(e=>e.variants&&e.variants.map(t=>t.name)||[e.name]).reduce((e,t)=>e.concat(t),[]),Re=["name","version","displayName","description","private","type","engines","packageManager","keywords","categories","author","publisher","contributors","homepage","bugs","license","files","bin","main","module","types","exports","publishConfig","repository","activationEvents","contributes","badges","icon","vsce","scripts","dependencies","devDependencies","peerDependencies","optionalDependencies"],Ne=["dev","dev:*","debug","start","build","build:*","release","clean","preview","test","lint","lint:eslint","lint:stylelint","lint:prettier"];async function ne(e){return S(`git config --get ${e}`,{trim:!0})}var se=e=>/^(?:(@[a-z0-9.+-]+(-[a-z0-9.+-]+)*\/)?([a-z0-9][a-z0-9._-]*[a-z0-9]))$/.test(e),Fe=e=>/^[a-z0-9._-]+$/.test(e),Ue=e=>e.includes("/")?e.substring(e.indexOf("/")+1):e;function R(e){return ae(g.join(e,"package.json"))||{}}function M(e,t){Ee(g.join(e,"package.json"),t)}function re(e,t,r){let n={},o=Object.keys(e).sort(),i=p(t),c=p(r);return i.concat(o.filter(s=>!i.includes(s)&&!c.includes(s))).concat(c).forEach(s=>{n[s]=e[s]}),n;function p(s){let l=Array.isArray(s)?s:[];return l.length>0&&(l=l.reduce((m,a)=>{if(a.endsWith(":*")){let u=a.replace(":*",":");console.log("sk:",u);let d=o.filter(A=>!m.includes(A)&&A.startsWith(u));return m.concat(d)}return o.includes(a)?m.concat(a):m},[])),l}}async function le(e){if(Object.assign(v,e),v.git){await k(void 0,!0);return}v.type==="project"?await Ve():await ue(v.type)}async function Ve(){let e="project",t=await me(e,v.cwd),{projectDir:r}=t.userOptions;W(e,t),await J(t);let{workspaces:n}=t,o=g.join(r,"packages");n&&await h("Do you want to create an package?")&&await ue("package",o);let{examples:i}=t,c=Array.isArray(i)&&i.length>0;if(c){let s=I.filter(m=>i.includes(m.name)),l=g.join(r,"examples");for(let m of s){let a=ce(m);a.templates=fe(a.templates).concat(a.name);let u=g.join(l,a.name);a.userOptions={projectDir:u,pkgName:a.name,gitUserUrl:"",textVars:{}},await ge(a),W("example",a),await J(a)}}let p=w.existsSync(o)&&w.readdirSync(g.join(r,"packages")).length>0;if(p||c){let s=R(r),l=Q(s)||"npm",m=[];if(p&&m.push("packages"),c&&m.push("examples"),l==="pnpm"){let u=g.join(r,"pnpm-workspace.yaml");w.existsSync(u)||T(u,`packages:
|
|
2
|
+
${m.map(d=>` - '${d}/*'
|
|
3
|
+
`)}`)}else s.workspaces??=m.map(u=>`"${u}/*"`),M(r,s);let a=s.devDependencies??{};p&&"vitest"in a&&T(g.join(r,"vitest.config.ts"),'export default ["packages/*"];')}await Qe(t)}async function ue(e,t){let r=!0,n=0;for(;r;){n++;let o=await me(e,t||v.cwd,n===1?v.template:void 0),{pkgName:i}=o.userOptions;W(e,o),await J(o),y.success(`${x.green(i)} created successfully!`),r=await h(`Do you want to create another ${e}?`)}}function oe(e,...t){!Array.isArray(t)||t.length===0||t.forEach(r=>{let n=g.join(e,r);w.existsSync(n)&&N(n)})}function Le(e,t,r){if(!w.existsSync(e))return;let n=ie(e);n=n.replaceAll(t,r),T(e,n)}function _e(e,t,r){let n=r.userOptions,{textVars:o}=n;if(["scripts","dependencies","devDependencies","peerDependencies"].forEach(i=>{e[i]&&(i==="scripts"?e[i]=re(e[i],Ne,["prepare"]):e[i]=re(e[i]))}),t==="example"?(delete e.types,delete e.exports,delete e.publishConfig,delete e.repository,delete e.module,delete e.license,e.private=!0):t==="package"&&e.repository&&typeof e.repository=="object"&&(e.repository.directory=`packages/${o.pkgShortName}`),!r.test){let i=e.scripts;if(i){delete i.test;{let c=i["lint:eslint"]||"";c&&(i["lint:eslint"]=c.replace(",test",""))}}delete e.devDependencies?.vitest}e.type==="commonjs"&&delete e.type,e.private===!1&&delete e.private}function W(e,t,r){let n=r??t.userOptions.projectDir,o=g.join(n,".temp");$e(o);let i=t.templates||[];if((e!=="project"?i:["base/core",...i]).forEach((p,s)=>{let l=g.join(pe,p);if(!w.existsSync(l))return;Ae(l,n);let m=R(o)||{},a=Se(m,R(n));if(s===i.length){let u={};Re.forEach(d=>{d in a&&(u[d]=a[d],delete a[d])}),a=Object.assign(u,a),_e(a,e,t),M(n,a)}else M(o,a)}),N(o),oe(n,"tests"),Le(g.join(n,"tsconfig.json"),', "test"',""),e==="package"){let p=[".vscode"].concat(t.packages?.exclude??[]);oe(n,...p)}}async function J(e,t){let r=e.userOptions,{textVars:n}=r,o=t??r.projectDir;w.readdirSync(o).filter(p=>p.startsWith("_")).forEach(p=>{w.renameSync(g.join(o,p),g.join(o,p.replace("_",".")))});let i=R(o),c=["LICENSE","README.md","README.zh_CN.md"];i.publishConfig||c.forEach(p=>{N(g.join(o,p))}),["package.json",...c].forEach(p=>{let s=g.join(o,p);if(!w.existsSync(s))return;let l=ie(s);Object.keys(n).forEach(m=>{l=l.replace(new RegExp("{{"+m+"}}","g"),n[m])}),T(s,l)})}async function me(e,t,r){let{gitRepos:n}=await te(),o=(v.name||"").trim(),i=se(o);(!o||!i)&&(o=await _("Package name:",{validate:a=>se(a)?!0:"Please input a valid name!"}));let c=Ue(o);c!==o&&(c=await _("Project name:",{default:c,validate:a=>Fe(a)?!0:"Please input a valid name!"})),y.debug("projectName:",c);let p=g.join(t,c);w.existsSync(p)&&await h("Project already exists, overwrite?")&&N(p),y.debug("projectDir:",p);let s;r&&Ie.includes(r)&&(s=I.find(a=>a.name===r));let l=async a=>{let u=await b(!s&&a?`${x.red(a)} is invalid, please select a framework again:`:"Select a framework:",O.filter(f=>!f.variants||!f.variants.length?!1:e==="package"?f.variants.filter($=>!$.packages?.ignore).length>0:!0).map(f=>({name:f.display,value:f.name})));y.debug("framework:",u);let d=O.find(f=>f.name===u)?.variants||[],A=e==="package"?d.filter(f=>!f.packages?.ignore).map(f=>{let $=f.parent;return $?{name:`${$.display} > ${f.display}`,value:f.name}:{name:f.display,value:f.name}}):d.map(f=>({name:f.display,value:f.name})),ye=O.find(f=>f.name===u)?.display,F=await b(`Select a ${x.blue(ye)} variant:`,A.concat([{name:x.yellow("\u2190 Back"),value:"_"}]));y.debug("variant:",F),F==="_"?await l(a):s=d.find(f=>f.name===F)};if(s||await l(r),!s)throw new Error("variant not found");s=ce(s),s.templates||(s.templates=[]),s.templates=fe(s.templates).concat(s.name),y.debug("variant:",s),e==="project"&&Array.isArray(s.examples)&&(s.examples=await K("Select examples:",s.examples.map(a=>{let u=I.find(d=>d.name===a);if(!u)throw new Error(`Can't find example ${x.yellow(a)} from ${x.blue(s.name)}`);return{name:u.display,value:u.name,checked:!0}}),{required:!1}));let m="";if(e==="example"?(s.devDependencies=0,s.workspaces=!1,s.test=!1):e==="package"?s.workspaces=!1:s.git&&(m=await b("Which git repository do you want to choose?",n.map(a=>{let u=q(a);return{name:u,value:u}}).concat([{name:x.yellow("None"),value:""}]))),s.devDependencies===2){let a=await h("Whether it will be used for devDependencies?");s.devDependencies=a?1:0}return s.test&&(s.test=await h("Whether to use test?")),s.userOptions={pkgName:o,projectDir:p,gitUserUrl:m},await ge(s),s}function fe(e){let t=[],r=async n=>{if(!(!Array.isArray(n)||!n.length))for(let o of n){if(o.startsWith("base/")){t.push(o);continue}let i=I.find(c=>c.name===o);if(!i){y.warning(`Can't find template ${x.yellow(o)}`);continue}r(i.templates)}};return r(e),[...new Set(t)]}async function ge(e){let{pkgName:t,gitUserUrl:r}=e.userOptions,n=await ne("user.name"),o=await ne("user.email"),i={name:n||Oe.userInfo().username,email:o||""},c=["pnpm","yarn","npm"].map(a=>`# ${a}
|
|
4
|
+
${a} add ${t}${e.devDependencies?" -D":""}`).join(`
|
|
5
5
|
|
|
6
|
-
`),
|
|
6
|
+
`),p={pkgName:t,pkgShortName:t.startsWith("@")?t.split("/")[1]:t,pkgInstall:c,gitUserName:i.name,gitUserEmail:i.email,gitOrg:l(),gitUrl:s(),gitFullUrl:m(),gitFullSSHUrl:m(),dateYear:new Date().getFullYear()};function s(){return`${r||`https://github.com/${l()}`}/${t.substring(t.indexOf("/")+1)}`}function l(){return r?r.substring(r.lastIndexOf("/")+1):t.startsWith("@")?t.split("/")[0].substring(1):De(i.name)}function m(a=!1){let u=r||`https://github.com/${l()}`;return a&&(u=u.replace(/http(s):\/\//g,"git@").replace(/\//,":")),`${u}/${t.substring(t.indexOf("/")+1)}.git`}return e.userOptions.textVars=p,p}async function Qe(e){let{gitUserUrl:t,textVars:r,projectDir:n}=e.userOptions;t&&(await S("git init",{cwd:n}),await S(`git remote add origin ${r.gitFullSSHUrl}`,{cwd:n}));let o=process.cwd(),i=g.relative(o,n);console.log(`
|
|
7
7
|
Done. Now run:
|
|
8
|
-
`),
|
|
8
|
+
`),n!==o&&console.log(` cd ${i.includes(" ")?`"${i}"`:i}`);let c=Q()||"npm";switch(c){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${c} install`),console.log(` ${c} run dev`);break}}var z=Ge(`
|
|
9
9
|
Usage
|
|
10
10
|
$ create-app [name] [options]
|
|
11
11
|
|
|
@@ -15,6 +15,7 @@ Options
|
|
|
15
15
|
--cwd The current working directory (default: ".")
|
|
16
16
|
-e, --example Only create examples
|
|
17
17
|
-p, --package Only create packages
|
|
18
|
+
--git Only manage git repository
|
|
18
19
|
--verbose Display verbose output
|
|
19
20
|
-h, --help Display this message
|
|
20
21
|
-v, --version Display version number
|
|
@@ -22,4 +23,4 @@ Options
|
|
|
22
23
|
Examples
|
|
23
24
|
$ create-app my-project
|
|
24
25
|
$ create-app my-project --template=vue
|
|
25
|
-
`,{importMeta:import.meta,booleanDefault:void 0,helpIndent:0,flags:{cwd:{type:"string"},verbose:{type:"boolean",default:process.env.NODE_ENV==="development"},example:{shortFlag:"e",type:"boolean",default:!1},package:{shortFlag:"p",type:"boolean",default:!1},h:{type:"boolean",default:!1},v:{type:"boolean",default:!1}}}),{input:
|
|
26
|
+
`,{importMeta:import.meta,booleanDefault:void 0,helpIndent:0,flags:{cwd:{type:"string"},verbose:{type:"boolean",default:process.env.NODE_ENV==="development"},example:{shortFlag:"e",type:"boolean",default:!1},package:{shortFlag:"p",type:"boolean",default:!1},h:{type:"boolean",default:!1},v:{type:"boolean",default:!1}}}),{input:de,flags:P}=z;if(P.h)z.showHelp(0);else if(P.v)z.showVersion();else{y.enableDebug(P.verbose),y.debug("cli options:",de,P);let e=Object.assign({name:de[0],type:"project"},P);e.cwd||=process.cwd(),y.debug("final options:",e),e.type=qe(e),await le(e)}function qe(e){return e.example?"example":e.package?"package":"project"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomjs/create-app",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"description": "create tomjs web app",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tomjs",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"dist",
|
|
32
|
-
"
|
|
32
|
+
"templates/**"
|
|
33
33
|
],
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">=18"
|
|
@@ -48,20 +48,20 @@
|
|
|
48
48
|
"chalk": "^5.3.0",
|
|
49
49
|
"dayjs": "^1.11.11",
|
|
50
50
|
"execa": "^9.1.0",
|
|
51
|
-
"inquirer": "^9.2.
|
|
51
|
+
"inquirer": "^9.2.23",
|
|
52
52
|
"lodash-es": "^4.17.21",
|
|
53
53
|
"meow": "^13.2.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@commitlint/cli": "^19.3.0",
|
|
57
|
-
"@tomjs/commitlint": "^3.
|
|
58
|
-
"@tomjs/eslint": "^3.1.
|
|
57
|
+
"@tomjs/commitlint": "^3.3.0",
|
|
58
|
+
"@tomjs/eslint": "^3.1.1",
|
|
59
59
|
"@tomjs/prettier": "^1.4.1",
|
|
60
60
|
"@tomjs/stylelint": "^2.5.0",
|
|
61
61
|
"@tomjs/tsconfig": "^1.6.0",
|
|
62
62
|
"@types/inquirer": "^9.0.7",
|
|
63
63
|
"@types/lodash-es": "^4.17.12",
|
|
64
|
-
"@types/node": "^18.19.
|
|
64
|
+
"@types/node": "^18.19.34",
|
|
65
65
|
"@types/prompts": "^2.4.9",
|
|
66
66
|
"cross-env": "^7.0.3",
|
|
67
67
|
"dotenv": "^16.4.5",
|
|
@@ -69,11 +69,11 @@
|
|
|
69
69
|
"husky": "^9.0.11",
|
|
70
70
|
"lint-staged": "^15.2.5",
|
|
71
71
|
"npm-run-all": "^4.1.5",
|
|
72
|
-
"prettier": "^3.
|
|
73
|
-
"stylelint": "^16.
|
|
74
|
-
"tsup": "^8.0
|
|
75
|
-
"tsx": "^4.
|
|
76
|
-
"type-fest": "^4.
|
|
72
|
+
"prettier": "^3.3.0",
|
|
73
|
+
"stylelint": "^16.6.1",
|
|
74
|
+
"tsup": "^8.1.0",
|
|
75
|
+
"tsx": "^4.11.2",
|
|
76
|
+
"type-fest": "^4.19.0",
|
|
77
77
|
"typescript": "~5.4.5"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# 🎨 editorconfig.org
|
|
2
|
+
|
|
3
|
+
root = true
|
|
4
|
+
|
|
5
|
+
[*]
|
|
6
|
+
charset = utf-8
|
|
7
|
+
end_of_line = lf
|
|
8
|
+
indent_style = space
|
|
9
|
+
indent_size = 2
|
|
10
|
+
trim_trailing_whitespace = true
|
|
11
|
+
insert_final_newline = true
|
|
12
|
+
|
|
13
|
+
[*.md]
|
|
14
|
+
insert_final_newline = false
|
|
15
|
+
trim_trailing_whitespace = false
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
## GITATTRIBUTES FOR WEB PROJECTS
|
|
2
|
+
#
|
|
3
|
+
# These settings are for any web project.
|
|
4
|
+
#
|
|
5
|
+
# Details per file setting:
|
|
6
|
+
# text These files should be normalized (i.e. convert CRLF to LF).
|
|
7
|
+
# binary These files are binary and should be left untouched.
|
|
8
|
+
#
|
|
9
|
+
# Note that binary is a macro for -text -diff.
|
|
10
|
+
######################################################################
|
|
11
|
+
|
|
12
|
+
## AUTO-DETECT
|
|
13
|
+
## Handle line endings automatically for files detected as
|
|
14
|
+
## text and leave all files detected as binary untouched.
|
|
15
|
+
## This will handle all files NOT defined below.
|
|
16
|
+
* text eol=lf
|
|
17
|
+
|
|
18
|
+
## SOURCE CODE
|
|
19
|
+
*.bat text eol=crlf
|
|
20
|
+
*.coffee text
|
|
21
|
+
*.css text
|
|
22
|
+
*.htm text
|
|
23
|
+
*.html text
|
|
24
|
+
*.inc text
|
|
25
|
+
*.ini text
|
|
26
|
+
*.java text
|
|
27
|
+
*.js text
|
|
28
|
+
*.json text
|
|
29
|
+
*.jsx text
|
|
30
|
+
*.less text
|
|
31
|
+
*.od text
|
|
32
|
+
*.onlydata text
|
|
33
|
+
*.php text
|
|
34
|
+
*.pl text
|
|
35
|
+
*.py text
|
|
36
|
+
*.rb text
|
|
37
|
+
*.sass text
|
|
38
|
+
*.scm text
|
|
39
|
+
*.scss text
|
|
40
|
+
*.sh text eol=lf
|
|
41
|
+
*.sql text
|
|
42
|
+
*.styl text
|
|
43
|
+
*.tag text
|
|
44
|
+
*.ts text
|
|
45
|
+
*.tsx text
|
|
46
|
+
*.xml text
|
|
47
|
+
*.xhtml text
|
|
48
|
+
|
|
49
|
+
## DOCKER
|
|
50
|
+
*.dockerignore text
|
|
51
|
+
Dockerfile text
|
|
52
|
+
|
|
53
|
+
## DOCUMENTATION
|
|
54
|
+
*.markdown text
|
|
55
|
+
*.md text
|
|
56
|
+
*.mdwn text
|
|
57
|
+
*.mdown text
|
|
58
|
+
*.mkd text
|
|
59
|
+
*.mkdn text
|
|
60
|
+
*.mdtxt text
|
|
61
|
+
*.mdtext text
|
|
62
|
+
*.txt text
|
|
63
|
+
AUTHORS text
|
|
64
|
+
CHANGELOG text
|
|
65
|
+
CHANGES text
|
|
66
|
+
CONTRIBUTING text
|
|
67
|
+
COPYING text
|
|
68
|
+
copyright text
|
|
69
|
+
*COPYRIGHT* text
|
|
70
|
+
INSTALL text
|
|
71
|
+
license text
|
|
72
|
+
LICENSE text
|
|
73
|
+
NEWS text
|
|
74
|
+
readme text
|
|
75
|
+
*README* text
|
|
76
|
+
|
|
77
|
+
## TEMPLATES
|
|
78
|
+
*.dot text
|
|
79
|
+
*.ejs text
|
|
80
|
+
*.haml text
|
|
81
|
+
*.handlebars text
|
|
82
|
+
*.hbs text
|
|
83
|
+
*.hbt text
|
|
84
|
+
*.jade text
|
|
85
|
+
*.latte text
|
|
86
|
+
*.mustache text
|
|
87
|
+
*.njk text
|
|
88
|
+
*.phtml text
|
|
89
|
+
*.tmpl text
|
|
90
|
+
*.tpl text
|
|
91
|
+
*.twig text
|
|
92
|
+
|
|
93
|
+
## LINTERS
|
|
94
|
+
.csslintrc text
|
|
95
|
+
.eslintrc text
|
|
96
|
+
.jscsrc text
|
|
97
|
+
.jshintrc text
|
|
98
|
+
.jshintignore text
|
|
99
|
+
.stylelintrc text
|
|
100
|
+
|
|
101
|
+
## CONFIGS
|
|
102
|
+
*.bowerrc text
|
|
103
|
+
*.cnf text
|
|
104
|
+
*.conf text
|
|
105
|
+
*.config text
|
|
106
|
+
.browserslistrc text
|
|
107
|
+
.editorconfig text
|
|
108
|
+
.gitattributes text
|
|
109
|
+
.gitconfig text
|
|
110
|
+
.gitignore text
|
|
111
|
+
.htaccess text
|
|
112
|
+
*.npmignore text
|
|
113
|
+
*.yaml text
|
|
114
|
+
*.yml text
|
|
115
|
+
browserslist text
|
|
116
|
+
Makefile text
|
|
117
|
+
makefile text
|
|
118
|
+
|
|
119
|
+
## HEROKU
|
|
120
|
+
Procfile text
|
|
121
|
+
.slugignore text
|
|
122
|
+
|
|
123
|
+
## GRAPHICS
|
|
124
|
+
*.ai binary
|
|
125
|
+
*.bmp binary
|
|
126
|
+
*.eps binary
|
|
127
|
+
*.gif binary
|
|
128
|
+
*.ico binary
|
|
129
|
+
*.jng binary
|
|
130
|
+
*.jp2 binary
|
|
131
|
+
*.jpg binary
|
|
132
|
+
*.jpeg binary
|
|
133
|
+
*.jpx binary
|
|
134
|
+
*.jxr binary
|
|
135
|
+
*.pdf binary
|
|
136
|
+
*.png binary
|
|
137
|
+
*.psb binary
|
|
138
|
+
*.psd binary
|
|
139
|
+
*.svg text
|
|
140
|
+
*.svgz binary
|
|
141
|
+
*.tif binary
|
|
142
|
+
*.tiff binary
|
|
143
|
+
*.wbmp binary
|
|
144
|
+
*.webp binary
|
|
145
|
+
|
|
146
|
+
## AUDIO
|
|
147
|
+
*.kar binary
|
|
148
|
+
*.m4a binary
|
|
149
|
+
*.mid binary
|
|
150
|
+
*.midi binary
|
|
151
|
+
*.mp3 binary
|
|
152
|
+
*.ogg binary
|
|
153
|
+
*.ra binary
|
|
154
|
+
|
|
155
|
+
## VIDEO
|
|
156
|
+
*.3gpp binary
|
|
157
|
+
*.3gp binary
|
|
158
|
+
*.as binary
|
|
159
|
+
*.asf binary
|
|
160
|
+
*.asx binary
|
|
161
|
+
*.fla binary
|
|
162
|
+
*.flv binary
|
|
163
|
+
*.m4v binary
|
|
164
|
+
*.mng binary
|
|
165
|
+
*.mov binary
|
|
166
|
+
*.mp4 binary
|
|
167
|
+
*.mpeg binary
|
|
168
|
+
*.mpg binary
|
|
169
|
+
*.swc binary
|
|
170
|
+
*.swf binary
|
|
171
|
+
*.webm binary
|
|
172
|
+
|
|
173
|
+
## ARCHIVES
|
|
174
|
+
*.7z binary
|
|
175
|
+
*.gz binary
|
|
176
|
+
*.rar binary
|
|
177
|
+
*.tar binary
|
|
178
|
+
*.zip binary
|
|
179
|
+
|
|
180
|
+
## FONTS
|
|
181
|
+
*.ttf binary
|
|
182
|
+
*.eot binary
|
|
183
|
+
*.otf binary
|
|
184
|
+
*.woff binary
|
|
185
|
+
*.woff2 binary
|
|
186
|
+
|
|
187
|
+
## EXECUTABLES
|
|
188
|
+
*.exe binary
|
|
189
|
+
*.pyc binary
|
|
190
|
+
*.jar binary
|
|
191
|
+
*.dll binary
|
|
192
|
+
|
|
193
|
+
## DOCUMENT
|
|
194
|
+
*.doc binary
|
|
195
|
+
*.docx binary
|
|
196
|
+
*.xls binary
|
|
197
|
+
*.xlsx binary
|
|
198
|
+
*.ppt binary
|
|
199
|
+
*.pptx binary
|
|
200
|
+
|
|
201
|
+
## EXTENSIONS
|
|
202
|
+
*.crx binary
|
|
203
|
+
*.xpi binary
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pnpm commitlint --edit $1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pnpm lint-staged
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require.resolve('@tomjs/prettier');
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# logs
|
|
2
|
+
*.log
|
|
3
|
+
lerna-debug.log*
|
|
4
|
+
logs
|
|
5
|
+
npm-debug.log*
|
|
6
|
+
pnpm-debug.log*
|
|
7
|
+
yarn-debug.log*
|
|
8
|
+
yarn-error.log*
|
|
9
|
+
|
|
10
|
+
# diagnostic reports (https://nodejs.org/api/report.html)
|
|
11
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
12
|
+
|
|
13
|
+
# runtime data
|
|
14
|
+
*.pid
|
|
15
|
+
*.pid.lock
|
|
16
|
+
*.seed
|
|
17
|
+
pids
|
|
18
|
+
|
|
19
|
+
# dependency directory
|
|
20
|
+
bower_components
|
|
21
|
+
jspm_packages
|
|
22
|
+
node_modules
|
|
23
|
+
web_modules
|
|
24
|
+
|
|
25
|
+
# cache
|
|
26
|
+
.cache
|
|
27
|
+
.npm
|
|
28
|
+
.tmp
|
|
29
|
+
.temp
|
|
30
|
+
.eslintcache
|
|
31
|
+
.stylelintcache
|
|
32
|
+
tsconfig.tsbuildinfo
|
|
33
|
+
|
|
34
|
+
# environment
|
|
35
|
+
*.local
|
|
36
|
+
|
|
37
|
+
# macOS
|
|
38
|
+
.DS_Store
|
|
39
|
+
|
|
40
|
+
# package files
|
|
41
|
+
*.7z
|
|
42
|
+
*.gz
|
|
43
|
+
*.gzip
|
|
44
|
+
*.rar
|
|
45
|
+
*.tar
|
|
46
|
+
*.tar.*
|
|
47
|
+
*.tgz
|
|
48
|
+
*.zip
|
|
49
|
+
*.vsix
|
|
50
|
+
|
|
51
|
+
# IDEA
|
|
52
|
+
.idea
|
|
53
|
+
|
|
54
|
+
# vscode
|
|
55
|
+
.history
|
|
56
|
+
|
|
57
|
+
# build output
|
|
58
|
+
build
|
|
59
|
+
dist
|
|
60
|
+
release
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{pkgName}}",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=16"
|
|
7
|
+
},
|
|
8
|
+
"packageManager": "pnpm@9.1.4",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"lint": "run-s lint:eslint lint:prettier",
|
|
11
|
+
"lint:eslint": "eslint \"src/**/*.ts\" *.{js,cjs,mjs,ts} --fix --cache",
|
|
12
|
+
"lint:prettier": "prettier --write .",
|
|
13
|
+
"prepare": "husky"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@commitlint/cli": "^19.3.0",
|
|
17
|
+
"@tomjs/commitlint": "^3.3.0",
|
|
18
|
+
"@tomjs/eslint": "^3.1.1",
|
|
19
|
+
"@tomjs/prettier": "^1.4.1",
|
|
20
|
+
"@tomjs/tsconfig": "^1.6.0",
|
|
21
|
+
"@types/node": "^18.19.34",
|
|
22
|
+
"eslint": "^8.57.0",
|
|
23
|
+
"husky": "^9.0.11",
|
|
24
|
+
"lint-staged": "^15.2.5",
|
|
25
|
+
"npm-run-all": "^4.1.5",
|
|
26
|
+
"prettier": "^3.3.0",
|
|
27
|
+
"rimraf": "^5.0.7",
|
|
28
|
+
"typescript": "~5.4.5"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Debug Main Process",
|
|
9
|
+
"type": "node",
|
|
10
|
+
"request": "launch",
|
|
11
|
+
"cwd": "${workspaceFolder}",
|
|
12
|
+
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
|
|
13
|
+
"windows": {
|
|
14
|
+
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
|
|
15
|
+
},
|
|
16
|
+
"args": [
|
|
17
|
+
".",
|
|
18
|
+
],
|
|
19
|
+
"outFiles": [
|
|
20
|
+
"${workspaceFolder}/**/*.js",
|
|
21
|
+
"${workspaceFolder}/**/*.cjs",
|
|
22
|
+
"${workspaceFolder}/**/*.mjs",
|
|
23
|
+
"!**/node_modules/**"
|
|
24
|
+
],
|
|
25
|
+
"preLaunchTask": "${defaultBuildTask}",
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
|
3
|
+
// for the documentation about the tasks.json format
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"tasks": [
|
|
6
|
+
{
|
|
7
|
+
"type": "npm",
|
|
8
|
+
"script": "dev",
|
|
9
|
+
"detail": "cross-env VITE_ELECTRON_DEBUG=1 vite",
|
|
10
|
+
"problemMatcher": {
|
|
11
|
+
"owner": "typescript",
|
|
12
|
+
"fileLocation": "relative",
|
|
13
|
+
"pattern": {
|
|
14
|
+
"regexp": "^([a-zA-Z]\\:\/?([\\w\\-]\/?)+\\.\\w+):(\\d+):(\\d+): (ERROR|WARNING)\\: (.*)$",
|
|
15
|
+
"file": 1,
|
|
16
|
+
"line": 3,
|
|
17
|
+
"column": 4,
|
|
18
|
+
"code": 5,
|
|
19
|
+
"message": 6
|
|
20
|
+
},
|
|
21
|
+
"background": {
|
|
22
|
+
"activeOnStart": true,
|
|
23
|
+
"beginsPattern": "^.*VITE v.* ready in \\d* ms.*$",
|
|
24
|
+
"endsPattern": "^.*\\[tomjs:electron\\] startup electron*$"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"isBackground": true,
|
|
28
|
+
"presentation": {
|
|
29
|
+
"reveal": "never"
|
|
30
|
+
},
|
|
31
|
+
"group": {
|
|
32
|
+
"kind": "build",
|
|
33
|
+
"isDefault": true
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="@tomjs/vite-plugin-electron/env" />
|