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