create-vuepress-theme-hope 2.0.0-beta.166 → 2.0.0-beta.167

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/README.md CHANGED
@@ -7,7 +7,7 @@ Create template shortcut for vuepress-theme-hope.
7
7
  ## Usage
8
8
 
9
9
  ```bash
10
- npm init vuepress-theme-hope@next <dir>
10
+ npm init vuepress-theme-hope <dir>
11
11
  ```
12
12
 
13
13
  <!-- Or
@@ -23,7 +23,7 @@ yarn create vuepress-theme-hope <dir>
23
23
  ## 使用
24
24
 
25
25
  ```bash
26
- npm init vuepress-theme-hope@next <dir>
26
+ npm init vuepress-theme-hope <dir>
27
27
  ```
28
28
 
29
29
  <!-- 或
package/lib/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
- import{existsSync as g,readFileSync as w,writeFileSync as d,readdirSync as h,mkdirSync as C,statSync as k,createReadStream as N,createWriteStream as E}from"node:fs";import{resolve as a,join as $,dirname as b}from"node:path";import{cac as I}from"cac";import{execaCommandSync as l,execaCommand as O}from"execa";import p from"inquirer";import{fileURLToPath as z}from"node:url";import"node:https";import{createRequire as A}from"node:module";const F={简体中文:{flow:{getVersion:"获取依赖的最新版本...",createPackage:"生成 package.json...",updatePackage:"更新 package.json...",generateTemplate:"生成模板...",install:"安装依赖...",devServer:`启动开发服务器...
2
+ import{existsSync as g,readFileSync as w,writeFileSync as d,readdirSync as h,mkdirSync as C,statSync as k,createReadStream as N,createWriteStream as E}from"node:fs";import{resolve as n,join as $,dirname as b}from"node:path";import{cac as I}from"cac";import{execaCommandSync as l,execaCommand as O}from"execa";import p from"inquirer";import{fileURLToPath as z}from"node:url";import"node:https";import{createRequire as A}from"node:module";const F={简体中文:{flow:{getVersion:"获取依赖的最新版本...",createPackage:"生成 package.json...",updatePackage:"更新 package.json...",generateTemplate:"生成模板...",install:"安装依赖...",devServer:`启动开发服务器...
3
3
  启动成功后,请在浏览器输入给出的开发服务器地址(默认为 'localhost:8080')`},question:{packageManager:"选择包管理器",i18n:"项目需要用到多语言么?",git:"是否初始化 Git 仓库?",workflow:"是否需要一个自动部署文档到 GitHub Pages 的工作流?",preset:"你想要创建什么类型的项目?",devServer:"是否想要现在启动 Demo 查看?",name:"设置应用名称",version:"设置应用版本号",description:"设置应用描述",license:"设置协议"},hint:{install:`这可能需要数分钟,请耐心等待.
4
4
  我们无法正确输出子进程的进度条,所以进程可能会看似未响应`,finish:"模板已成功生成!",devServer:e=>`提示: 请使用 "${e} run docs:dev" 命令启动开发服务器`},error:{name:"应用名称应只包含小写字母、数字和连接线 (-)",version:"此版本无效,版本号应为 'x.x.x'",preset:"预设 (--preset) 仅支持 doc 或 blog",outputDirMissing:e=>`"[dir]" 的方括号表示此处为一个参数,你应该替换为自己想使用的文件夹名称,如 "my-blog", "project-docs" 等!
5
- 例如: "${e} init vuepress-theme-hope@next project-docs"`,updateDirMissing:e=>`"[dir]" 的方括号表示此处为一个参数,你应该替换为自己想使用的文件夹名称,如 "src", "docs" 等!
6
- 例如: "${e} init vuepress-theme-hope@next docs"`,dirNotEmpty:e=>`目标文件夹 "${e}" 不为空,请选择一个空文件夹或者手动删除文件夹中的文件`}},"english (US)":{flow:{getVersion:"Getting latest version of deps...",createPackage:"Generating package.json...",updatePackage:"Updating package.json...",generateTemplate:"Generating Template...",install:"Installing Deps...",devServer:`Staring dev server...
5
+ 例如: "${e} init vuepress-theme-hope project-docs"`,updateDirMissing:e=>`"[dir]" 的方括号表示此处为一个参数,你应该替换为自己想使用的文件夹名称,如 "src", "docs" 等!
6
+ 例如: "${e} init vuepress-theme-hope docs"`,dirNotEmpty:e=>`目标文件夹 "${e}" 不为空,请选择一个空文件夹或者手动删除文件夹中的文件`}},"english (US)":{flow:{getVersion:"Getting latest version of deps...",createPackage:"Generating package.json...",updatePackage:"Updating package.json...",generateTemplate:"Generating Template...",install:"Installing Deps...",devServer:`Staring dev server...
7
7
  After the dev server starts running, please visit the given server link ('localhost:8080' by default)`},question:{i18n:"Does the project need multiple languages?",git:"Initialize a git repository?",workflow:"Do you need a GitHub workflow to deploy docs on GitHub pages?",preset:"What type of project do you want to create?",packageManager:"Choose package manager",devServer:"Would you like to preview template now?",name:"Your project name",version:"Your project version",description:"Your project description",license:"Your project license"},hint:{install:`This may take a few minutes, please be patient.
8
8
  We can not correctly output progress bar from child process, so the process may look stuck.`,finish:"Successful Generated!",devServer:e=>`Hint: You should execute "${e} run docs:dev" to start dev server.`},error:{name:"package name should only contain lowercase characters, numbers and dash",version:"This version is not a valid one. Version should be like 'x.x.x'",preset:'preset (--preset) only support "doc" or "blog"',outputDirMissing:e=>`The brackets in "[dir]" means it is an argument, you should replace it with folder name you want to use! E.g.: "my-blog", "project-docs"
9
- For example: "${e} init vuepress-theme-hope@next project-docs"`,updateDirMissing:e=>`The brackets in "[dir]" means it is an argument, you should replace it with folder name you want to use! E.g.: "src", "docs"
10
- For example: "${e} init vuepress-theme-hope@next docs"`,dirNotEmpty:e=>`Target folder "${e}" is not empty, please choose an empty folder or delete files in it.`}}},W=async()=>{const{language:e}=await p.prompt([{name:"language",type:"list",message:"Select a language to display / 选择显示语言",choices:["english (US)","简体中文"]}]);return{lang:e,message:F[e]}},H=e=>`
9
+ For example: "${e} init vuepress-theme-hope project-docs"`,updateDirMissing:e=>`The brackets in "[dir]" means it is an argument, you should replace it with folder name you want to use! E.g.: "src", "docs"
10
+ For example: "${e} init vuepress-theme-hope docs"`,dirNotEmpty:e=>`Target folder "${e}" is not empty, please choose an empty folder or delete files in it.`}}},W=async()=>{const{language:e}=await p.prompt([{name:"language",type:"list",message:"Select a language to display / 选择显示语言",choices:["english (US)","简体中文"]}]);return{lang:e,message:F[e]}},H=e=>`
11
11
  node_modules/
12
12
  ${e}/.vuepress/.cache/
13
13
  ${e}/.vuepress/.temp/
14
14
  ${e}/.vuepress/dist/
15
- `,x=(e,s=process.cwd())=>{const t=a(s,".gitignore"),r=g(t)?w(t,{encoding:"utf-8"}):"";d(t,`${r}${H(e)}`,{encoding:"utf-8"})},J=(e,s,t)=>`
15
+ `,j=(e,s=process.cwd())=>{const t=n(s,".gitignore"),r=g(t)?w(t,{encoding:"utf-8"}):"";d(t,`${r}${H(e)}`,{encoding:"utf-8"})},J=(e,s,t)=>`
16
16
  name: ${t==="简体中文"?"部署文档":"Deploy Docs"}
17
17
 
18
18
  on:
@@ -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: ${$(s,".vuepress/dist").replace(/\\/g,"/")}
64
- `,R=Array.isArray,v=e=>Object.prototype.toString.call(e)==="[object Object]",y=(e,...s)=>{if(s.length===0)return e;const t=s.shift()||null;return t&&Object.entries(t).forEach(([r,n])=>{r==="__proto__"||r==="constructor"||(v(e[r])&&v(n)?y(e[r],n):R(n)?e[r]=[...n]:v(n)?e[r]={...n}:e[r]=t[r])}),y(e,...s)},m=e=>{try{h(e)}catch{C(e,{recursive:!0})}},j=(e,s)=>{const t=b(s);m(t);const r=N(e),n=E(s);r.pipe(n)},S=(e,s)=>{m(s),h(e,{withFileTypes:!0}).forEach(t=>{t.isFile()?j(`${e}/${t.name}`,`${s}/${t.name}`):t.isDirectory()&&S(`${e}/${t.name}`,`${s}/${t.name}`)})},D=(e,s)=>{k(e).isDirectory()?S(e,s):k(e).isFile()&&j(e,s)},Y=(e=process.cwd())=>{try{return l("git status",{cwd:e}),!0}catch{return!1}},U=()=>{try{return l("git --version"),!0}catch{return!1}},V=()=>{try{return l("pnpm --version",{stdio:"ignore"}).exitCode===0}catch{return!1}},L=()=>{try{return l("yarn --version",{stdio:"ignore"}).exitCode===0}catch{return!1}},f=["npm"];L()&&f.push("yarn"),V()&&f.push("pnpm");const B=async e=>(await p.prompt([{name:"packageManager",type:"list",message:e,choices:f}])).packageManager,K=z(import.meta.url),M=b(K),T=async(e,{cwd:s=process.cwd(),packageManager:t,lang:r,message:n,preset:o})=>{const{workflow:i}=await p.prompt([{name:"workflow",type:"confirm",message:n.question.workflow,default:!0}]);if(o||(o=(await p.prompt([{name:"preset",type:"list",message:n.question.preset,choices:["blog","docs"]}])).preset),console.log(n.flow.generateTemplate),D(a(M,"../template/public"),a(s,e,"./.vuepress/public")),D(a(M,"../template",o),a(s,e)),i){const c=a(s,".github/workflows");m(c),d(a(c,"deploy-docs.yml"),J(t,e,r),{encoding:"utf-8"})}if(Y(s))x(e,s);else if(U()){const{git:c}=await p.prompt([{name:"git",type:"confirm",message:n.question.git,default:!0}]);c&&(l("git init",{cwd:s}),x(e,s))}},G=A(import.meta.url)("create-vuepress-theme-hope/package.json").version,Q=e=>({"docs:build":`vuepress build ${e}`,"docs:clean-dev":`vuepress dev ${e} --clean-cache`,"docs:dev":`vuepress dev ${e}`}),q=async(e,s,t=process.cwd())=>{const r=a(t,"package.json"),n=Q(s),o={"@vuepress/client":"2.0.0-beta.60",vue:"^3.2.45",vuepress:"2.0.0-beta.60","vuepress-theme-hope":G};if(g(r)){console.log(e.flow.updatePackage);const i=JSON.parse(w(r,{encoding:"utf-8"}));y(i,{scripts:n,devDependencies:o}),d(r,`${JSON.stringify(i,null,2)}
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:n,devDependencies:o};d(r,`${JSON.stringify(i,null,2)}
66
- `,{encoding:"utf-8"})}},X="https://registry.npmmirror.com/",Z=e=>l(`${e} config get registry`).stdout,ee=async(e,s)=>{const t=Z(e);if(s==="简体中文"){const{registry:r}=await p.prompt([{name:"registry",type:"list",message:"选择你想使用的源",choices:["国内镜像源","当前源"]}]);return r==="国内镜像源"?X:t}return t},_=async(e,s)=>{if(!e)return u.outputHelp();const{lang:t,message:r}=await W();if(s&&!["docs","blog"].includes(s))return console.log(r.error.preset);const n=await B(r.question.packageManager);if(e.startsWith("[")&&e.endsWith("]"))return console.log(r.error.updateDirMissing(n));const o=a(process.cwd(),e);return g(o)&&h(o).length?console.error(r.error.dirNotEmpty(e)):(m(o),{lang:t,message:r,packageManager:n})},P=async({cwd:e=process.cwd(),lang:s,message:t,packageManager:r})=>{const n=r==="pnpm"?"":await ee(r,s);console.log(t.flow.install),console.warn(t.hint.install),l(`${r} install ${n?`--registry ${n}`:""}`,{cwd:e,stdout:"inherit"}),console.log(t.hint.finish);const{choice:o}=await p.prompt([{name:"choice",type:"confirm",message:t.question.devServer,default:!0}]);o?(console.log(t.flow.devServer),await O(`${r} run docs:dev`,{cwd:e,stdout:"inherit"})):console.log(t.hint.devServer(r))},u=I("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:s=null})=>{const t=a(process.cwd(),e),r=await _(e,s);if(r){const{lang:n,message:o,packageManager:i}=r;await q(o,"src",e),await T("src",{cwd:t,packageManager:i,lang:n,message:o,preset:s}),await P({cwd:t,lang:n,message:o,packageManager:i})}}),u.command("add [dir]","Add vuepress template to dir").alias("inject").option("-p, --preset <preset>","Choose preset to use").usage("pnpm create vuepress-theme-hope@next add [dir] / npm init vuepress-theme-hope@next add [dir]").example("docs").action(async(e,{preset:s=null})=>{const t=await _(e,s);if(t){const{lang:r,message:n,packageManager:o}=t;await q(n,e),await T(e,{packageManager:o,lang:r,message:n,preset:s}),await P({message:n,lang:r,packageManager:o})}}),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(G),u.parse();
64
+ `,R=Array.isArray,v=e=>Object.prototype.toString.call(e)==="[object Object]",y=(e,...s)=>{if(s.length===0)return e;const t=s.shift()||null;return t&&Object.entries(t).forEach(([r,o])=>{r==="__proto__"||r==="constructor"||(v(e[r])&&v(o)?y(e[r],o):R(o)?e[r]=[...o]:v(o)?e[r]={...o}:e[r]=t[r])}),y(e,...s)},m=e=>{try{h(e)}catch{C(e,{recursive:!0})}},S=(e,s)=>{const t=b(s);m(t);const r=N(e),o=E(s);r.pipe(o)},D=(e,s)=>{m(s),h(e,{withFileTypes:!0}).forEach(t=>{t.isFile()?S(`${e}/${t.name}`,`${s}/${t.name}`):t.isDirectory()&&D(`${e}/${t.name}`,`${s}/${t.name}`)})},M=(e,s)=>{k(e).isDirectory()?D(e,s):k(e).isFile()&&S(e,s)},Y=(e=process.cwd())=>{try{return l("git status",{cwd:e}),!0}catch{return!1}},U=()=>{try{return l("git --version"),!0}catch{return!1}},V=()=>{try{return l("pnpm --version",{stdio:"ignore"}).exitCode===0}catch{return!1}},L=()=>{try{return l("yarn --version",{stdio:"ignore"}).exitCode===0}catch{return!1}},f=["npm"];L()&&f.push("yarn"),V()&&f.push("pnpm");const B=async e=>(await p.prompt([{name:"packageManager",type:"list",message:e,choices:f}])).packageManager,K=z(import.meta.url),x=b(K),T=async(e,{cwd:s=process.cwd(),packageManager:t,lang:r,message:o,preset:a})=>{const{workflow:i}=await p.prompt([{name:"workflow",type:"confirm",message:o.question.workflow,default:!0}]);if(a||(a=(await p.prompt([{name:"preset",type:"list",message:o.question.preset,choices:["blog","docs"]}])).preset),console.log(o.flow.generateTemplate),M(n(x,"../template/public"),n(s,e,"./.vuepress/public")),M(n(x,"../template",a),n(s,e)),i){const c=n(s,".github/workflows");m(c),d(n(c,"deploy-docs.yml"),J(t,e,r),{encoding:"utf-8"})}if(Y(s))j(e,s);else if(U()){const{git:c}=await p.prompt([{name:"git",type:"confirm",message:o.question.git,default:!0}]);c&&(l("git init",{cwd:s}),j(e,s))}},G=A(import.meta.url)("create-vuepress-theme-hope/package.json").version,Q=e=>({"docs:build":`vuepress build ${e}`,"docs:clean-dev":`vuepress dev ${e} --clean-cache`,"docs:dev":`vuepress dev ${e}`}),q=async(e,s,t=process.cwd())=>{const r=n(t,"package.json"),o=Q(s),a={"@vuepress/client":"2.0.0-beta.60",vue:"^3.2.45",vuepress:"2.0.0-beta.60","vuepress-theme-hope":G};if(g(r)){console.log(e.flow.updatePackage);const i=JSON.parse(w(r,{encoding:"utf-8"}));y(i,{scripts:o,devDependencies:a}),d(r,`${JSON.stringify(i,null,2)}
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:a};d(r,`${JSON.stringify(i,null,2)}
66
+ `,{encoding:"utf-8"})}},X="https://registry.npmmirror.com/",Z=e=>l(`${e} config get registry`).stdout,ee=async(e,s)=>{const t=Z(e);if(s==="简体中文"){const{registry:r}=await p.prompt([{name:"registry",type:"list",message:"选择你想使用的源",choices:["国内镜像源","当前源"]}]);return r==="国内镜像源"?X:t}return t},_=async(e,s)=>{if(!e)return u.outputHelp();const{lang:t,message:r}=await W();if(s&&!["docs","blog"].includes(s))return console.log(r.error.preset);const o=await B(r.question.packageManager);if(e.startsWith("[")&&e.endsWith("]"))return console.log(r.error.updateDirMissing(o));const a=n(process.cwd(),e);return g(a)&&h(a).length?console.error(r.error.dirNotEmpty(e)):(m(a),{lang:t,message:r,packageManager:o})},P=async({cwd:e=process.cwd(),lang:s,message:t,packageManager:r})=>{const o=r==="pnpm"?"":await ee(r,s);console.log(t.flow.install),console.warn(t.hint.install),l(`${r} install ${o?`--registry ${o}`:""}`,{cwd:e,stdout:"inherit"}),console.log(t.hint.finish);const{choice:a}=await p.prompt([{name:"choice",type:"confirm",message:t.question.devServer,default:!0}]);a?(console.log(t.flow.devServer),await O(`${r} run docs:dev`,{cwd:e,stdout:"inherit"})):console.log(t.hint.devServer(r))},u=I("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 [dir] / npm init vuepress-theme-hope [dir]").example("docs").action(async(e,{preset:s=null})=>{const t=n(process.cwd(),e),r=await _(e,s);if(r){const{lang:o,message:a,packageManager:i}=r;await q(a,"src",e),await T("src",{cwd:t,packageManager:i,lang:o,message:a,preset:s}),await P({cwd:t,lang:o,message:a,packageManager:i})}}),u.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] / npm init vuepress-theme-hope add [dir]").example("docs").action(async(e,{preset:s=null})=>{const t=await _(e,s);if(t){const{lang:r,message:o,packageManager:a}=t;await q(o,e),await T(e,{packageManager:a,lang:r,message:o,preset:s}),await P({message:o,lang:r,packageManager:a})}}),u.help(()=>[{title:"pnpm 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] / npm init vuepress-theme-hope inject [dir]",body:"Add vuepress-theme-hope template in [dir] under current project"}]),u.version(G),u.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-vuepress-theme-hope",
3
- "version": "2.0.0-beta.166",
3
+ "version": "2.0.0-beta.167",
4
4
  "description": "Create vuepress-theme-hope demo project helper",
5
5
  "keywords": [
6
6
  "create",