create-vuepress-theme-hope 2.0.0-beta.248 → 2.0.0-beta.249

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 (2) hide show
  1. package/lib/index.js +1 -1
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -64,6 +64,6 @@ ${e!=="pnpm"?` - name: ${s==="简体中文"?"安装依赖":"Install Deps"}
64
64
  # ${s==="简体中文"?"这是文档部署到的分支名称":"This is the branch where the docs are deployed to"}
65
65
  branch: gh-pages
66
66
  folder: ${x(t,".vuepress/dist").replace(/\\/g,"/")}
67
- `,V=/^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/u,L=/^[0-9]+\.[0-9]+\.(?:[0=9]+|[0-9]+-[a-z]+\.[0-9])$/u,B=Array.isArray,$=e=>Object.prototype.toString.call(e)==="[object Object]",k=(e,...t)=>{if(t.length===0)return e;const s=t.shift()||null;return s&&Object.entries(s).forEach(([a,o])=>{a==="__proto__"||a==="constructor"||($(e[a])&&$(o)?k(e[a],o):B(o)?e[a]=[...o]:$(o)?e[a]={...o}:e[a]=s[a])}),k(e,...t)},y=e=>{try{w(e)}catch{try{A(e,{recursive:!0})}catch{}}},G=(e,t)=>{const s=D(t);y(s);const a=C(e),o=I(t);a.pipe(o)},T=(e,t)=>{y(t),w(e,{withFileTypes:!0}).forEach(s=>{s.isFile()?G(`${e}/${s.name}`,`${t}/${s.name}`):s.isDirectory()&&T(`${e}/${s.name}`,`${t}/${s.name}`)})},c=(e,t)=>{S(e).isDirectory()?T(e,t):S(e).isFile()&&G(e,t)},K=(e=process.cwd())=>{try{return u("git status",{cwd:e}),!0}catch{return!1}},Q=()=>{try{return u("git --version"),!0}catch{return!1}},X=()=>{try{return u("pnpm --version",{stdio:"ignore"}).exitCode===0}catch{return!1}},Z=()=>{try{return u("yarn --version",{stdio:"ignore"}).exitCode===0}catch{return!1}},b=["npm"];Z()&&b.push("yarn"),X()&&b.push("pnpm");const ee=async e=>(await m.prompt([{name:"packageManager",type:"list",message:e,choices:b}])).packageManager,te=W(import.meta.url),p=D(te),_=async(e,{cwd:t=process.cwd(),packageManager:s,lang:a,message:o,preset:n})=>{const{i18n:l,workflow:d}=await m.prompt([{name:"i18n",type:"confirm",message:o.question.i18n,default:!1},{name:"workflow",type:"confirm",message:o.question.workflow,default:!0}]);n||(n=(await m.prompt([{name:"preset",type:"list",message:o.question.preset,choices:["blog","docs"]}])).preset),console.log(o.flow.generateTemplate);const i=n;if(c(r(p,"../template/public"),r(t,e,"./.vuepress/public")),c(r(p,"../template",i,"config/base"),r(t,e,".vuepress")),l?(c(r(p,"../template",i,"en"),r(t,e)),c(r(p,"../template",i,"zh"),r(t,e,"zh")),c(r(p,"../template",i,"config/multi"),r(t,e,".vuepress"))):a==="简体中文"?(c(r(p,"../template",i,"zh"),r(t,e)),c(r(p,"../template",i,"config/zh"),r(t,e,".vuepress"))):(c(r(p,"../template",i,"en"),r(t,e)),c(r(p,"../template",i,"config/en"),r(t,e,".vuepress"))),d){const h=r(t,".github/workflows");y(h),v(r(h,"deploy-docs.yml"),U(s,e,a),{encoding:"utf-8"})}if(K(t))M(e,t);else if(Q()){const{git:h}=await m.prompt([{name:"git",type:"confirm",message:o.question.git,default:!0}]);h&&(u("git init",{cwd:t}),M(e,t))}},E=R(import.meta.url)("create-vuepress-theme-hope/package.json").version,se=(e,t)=>({"docs:build":`vuepress build ${t}`,"docs:clean-dev":`vuepress dev ${t} --clean-cache`,"docs:dev":`vuepress dev ${t}`,"docs:update-package":`${e==="npm"?"npx":`${e} dlx`} vp-update`}),q=async(e,t,s,a=process.cwd())=>{const o=r(a,"package.json"),n=se(e,s),l={"@vuepress/client":"2.0.0-beta.67",vue:"^3.3.4",vuepress:"2.0.0-beta.67","vuepress-theme-hope":E};if(f(o)){console.log(t.flow.updatePackage);const d=JSON.parse(j(o,{encoding:"utf-8"}));k(d,{scripts:n,devDependencies:l}),v(o,`${JSON.stringify(d,null,2)}
67
+ `,V=/^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/u,L=/^[0-9]+\.[0-9]+\.(?:[0=9]+|[0-9]+-[a-z]+\.[0-9])$/u,B=Array.isArray,$=e=>Object.prototype.toString.call(e)==="[object Object]",k=(e,...t)=>{if(t.length===0)return e;const s=t.shift()||null;return s&&Object.entries(s).forEach(([a,o])=>{a==="__proto__"||a==="constructor"||($(e[a])&&$(o)?k(e[a],o):B(o)?e[a]=[...o]:$(o)?e[a]={...o}:e[a]=s[a])}),k(e,...t)},y=e=>{try{w(e)}catch{try{A(e,{recursive:!0})}catch{}}},G=(e,t)=>{const s=D(t);y(s);const a=C(e),o=I(t);a.pipe(o)},T=(e,t)=>{y(t),w(e,{withFileTypes:!0}).forEach(s=>{s.isFile()?G(`${e}/${s.name}`,`${t}/${s.name}`):s.isDirectory()&&T(`${e}/${s.name}`,`${t}/${s.name}`)})},c=(e,t)=>{S(e).isDirectory()?T(e,t):S(e).isFile()&&G(e,t)},K=(e=process.cwd())=>{try{return u("git status",{cwd:e}),!0}catch{return!1}},Q=()=>{try{return u("git --version"),!0}catch{return!1}},X=()=>{try{return u("pnpm --version",{stdio:"ignore"}).exitCode===0}catch{return!1}},Z=()=>{try{return u("yarn --version",{stdio:"ignore"}).exitCode===0}catch{return!1}},b=["npm"];Z()&&b.push("yarn"),X()&&b.push("pnpm");const ee=async e=>(await m.prompt([{name:"packageManager",type:"list",message:e,choices:b}])).packageManager,te=W(import.meta.url),p=D(te),_=async(e,{cwd:t=process.cwd(),packageManager:s,lang:a,message:o,preset:n})=>{const{i18n:l,workflow:d}=await m.prompt([{name:"i18n",type:"confirm",message:o.question.i18n,default:!1},{name:"workflow",type:"confirm",message:o.question.workflow,default:!0}]);n||(n=(await m.prompt([{name:"preset",type:"list",message:o.question.preset,choices:["blog","docs"]}])).preset),console.log(o.flow.generateTemplate);const i=n;if(c(r(p,"../template/public"),r(t,e,"./.vuepress/public")),c(r(p,"../template",i,"config/base"),r(t,e,".vuepress")),l?(c(r(p,"../template",i,"en"),r(t,e)),c(r(p,"../template",i,"zh"),r(t,e,"zh")),c(r(p,"../template",i,"config/multi"),r(t,e,".vuepress"))):a==="简体中文"?(c(r(p,"../template",i,"zh"),r(t,e)),c(r(p,"../template",i,"config/zh"),r(t,e,".vuepress"))):(c(r(p,"../template",i,"en"),r(t,e)),c(r(p,"../template",i,"config/en"),r(t,e,".vuepress"))),d){const h=r(t,".github/workflows");y(h),v(r(h,"deploy-docs.yml"),U(s,e,a),{encoding:"utf-8"})}if(K(t))M(e,t);else if(Q()){const{git:h}=await m.prompt([{name:"git",type:"confirm",message:o.question.git,default:!0}]);h&&(u("git init",{cwd:t}),M(e,t))}},E=R(import.meta.url)("create-vuepress-theme-hope/package.json").version,se=(e,t)=>({"docs:build":`vuepress build ${t}`,"docs:clean-dev":`vuepress dev ${t} --clean-cache`,"docs:dev":`vuepress dev ${t}`,"docs:update-package":`${e==="npm"?"npx":`${e} dlx`} vp-update`}),q=async(e,t,s,a=process.cwd())=>{const o=r(a,"package.json"),n=se(e,s),l={"@vuepress/client":"2.0.0-beta.68",vue:"^3.3.8",vuepress:"2.0.0-beta.68","vuepress-theme-hope":E};if(f(o)){console.log(t.flow.updatePackage);const d=JSON.parse(j(o,{encoding:"utf-8"}));k(d,{scripts:n,devDependencies:l}),v(o,`${JSON.stringify(d,null,2)}
68
68
  `,{encoding:"utf-8"})}else{console.log(t.flow.createPackage);const d={...await m.prompt([{name:"name",type:"input",message:t.question.name,default:"vuepress-theme-hope-template",validate:i=>V.exec(i)?!0:t.error.name},{name:"version",type:"input",message:t.question.version,default:"2.0.0",validate:i=>L.exec(i)?!0:t.error.version},{name:"description",type:"input",message:t.question.description,default:"A project of vuepress-theme-hope"},{name:"license",type:"input",message:t.question.license,default:"MIT"}]),type:"module",scripts:n,devDependencies:l};v(o,`${JSON.stringify(d,null,2)}
69
69
  `,{encoding:"utf-8"})}},P="https://registry.npmmirror.com/",ae=e=>u(`${e} config get registry`).stdout,oe=async(e,t)=>{const s=ae(e);if(/https:\/\/registry\.npm\.taobao\.org\/?/.test(s)&&(console.error("npm.taobao.org is no longer available, resetting it to npmmirror.com"),u(`${e} config set registry ${P}`)),t==="简体中文"){const{registry:a}=await m.prompt([{name:"registry",type:"list",message:"选择你想使用的源",choices:["国内镜像源","当前源"]}]);return a==="国内镜像源"?P:s}return s},z=async(e,t)=>{if(!e)return g.outputHelp();const{lang:s,message:a}=await J();if(t&&!["docs","blog"].includes(t))return console.log(a.error.preset);const o=await ee(a.question.packageManager);if(e.startsWith("[")&&e.endsWith("]"))return console.log(a.error.updateDirMissing(o));const n=r(process.cwd(),e);return f(n)&&w(n).length?console.error(a.error.dirNotEmpty(e)):(y(n),{lang:s,message:a,packageManager:o})},N=async({cwd:e=process.cwd(),lang:t,message:s,packageManager:a})=>{const o=a==="pnpm"?"":await oe(a,t);console.log(s.flow.install),console.warn(s.hint.install),u(`${a} install ${o?`--registry ${o}`:""}`,{cwd:e,stdout:"inherit"}),console.log(s.hint.finish);const{choice:n}=await m.prompt([{name:"choice",type:"confirm",message:s.question.devServer,default:!0}]);n?(console.log(s.flow.devServer),await F(`${a} run docs:dev`,{cwd:e,stdout:"inherit"})):console.log(s.hint.devServer(a))},g=O("vuepress-theme-hope");g.command("[dir]","Generate a new vuepress-theme-hope project").option("-p, --preset <preset>","Choose preset to use").usage("pnpm create vuepress-theme-hope [dir] / yarn create vuepress-theme-hope [dir] / npm init vuepress-theme-hope [dir]").example("docs").action(async(e,{preset:t=null})=>{const s=r(process.cwd(),e),a=await z(e,t);if(a){const{lang:o,message:n,packageManager:l}=a;await q(l,n,"src",e),await _("src",{cwd:s,packageManager:l,lang:o,message:n,preset:t}),await N({cwd:s,lang:o,message:n,packageManager:l})}}),g.command("add [dir]","Add vuepress template to dir").alias("inject").option("-p, --preset <preset>","Choose preset to use").usage("pnpm create vuepress-theme-hope add [dir] / yarn create vuepress-theme-hope add [dir] / npm init vuepress-theme-hope add [dir]").example("docs").action(async(e,{preset:t=null})=>{const s=await z(e,t);if(s){const{lang:a,message:o,packageManager:n}=s;await q(n,o,e),await _(e,{packageManager:n,lang:a,message:o,preset:t}),await N({message:o,lang:a,packageManager:n})}}),g.help(()=>[{title:"pnpm create vuepress-theme-hope [dir] / yarn create vuepress-theme-hope [dir] / npm init vuepress-theme-hope [dir]",body:"Create a vuepress-theme-hope template in [dir]"},{title:"pnpm create vuepress-theme-hope inject [dir] / yarn create vuepress-theme-hope add [dir] / npm init vuepress-theme-hope inject [dir]",body:"Add vuepress-theme-hope template in [dir] under current project"}]),g.version(E),g.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-vuepress-theme-hope",
3
- "version": "2.0.0-beta.248",
3
+ "version": "2.0.0-beta.249",
4
4
  "description": "Create vuepress-theme-hope demo project helper",
5
5
  "keywords": [
6
6
  "create",