create-vuepress-theme-hope 2.0.0-beta.150 → 2.0.0-beta.152

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (C) 2020 - PRESENT by MrHope
3
+ Copyright (C) 2020 - PRESENT by Mr.Hope<mister-hope@outlook.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{existsSync as g,readFileSync as f,writeFileSync as d,readdirSync as h,mkdirSync as A,statSync as w,createReadStream as C,createWriteStream as N}from"node:fs";import{resolve as a,join as k,dirname as $}from"node:path";import{cac as E}from"cac";import{execaCommandSync as l,execaCommand as I}from"execa";import p from"inquirer";import{fileURLToPath as z}from"node:url";import"node:https";import{createRequire as F}from"node:module";const _={简体中文:{flow:{getVersion:"获取依赖的最新版本...",createPackage:"生成 package.json...",updatePackage:"更新 package.json...",generateTemplate:"生成模板...",install:"安装依赖...",devServer:`启动开发服务器...
2
+ import{existsSync as g,readFileSync as f,writeFileSync as d,readdirSync as h,mkdirSync as A,statSync as w,createReadStream as C,createWriteStream as N}from"node:fs";import{resolve as n,join as k,dirname as $}from"node:path";import{cac as E}from"cac";import{execaCommandSync as l,execaCommand as I}from"execa";import p from"inquirer";import{fileURLToPath as z}from"node:url";import"node:https";import{createRequire as F}from"node:module";const _={简体中文:{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
5
  例如: "${e} init vuepress-theme-hope@next project-docs"`,updateDirMissing:e=>`"[dir]" 的方括号表示此处为一个参数,你应该替换为自己想使用的文件夹名称,如 "src", "docs" 等!
@@ -12,7 +12,7 @@ node_modules/
12
12
  ${e}/.vuepress/.cache/
13
13
  ${e}/.vuepress/.temp/
14
14
  ${e}/.vuepress/dist/
15
- `,b=(e,r=process.cwd())=>{const t=a(r,".gitignore"),s=g(t)?f(t,{encoding:"utf-8"}):"";d(t,`${s}${W(e)}`,{encoding:"utf-8"})},H=(e,r,t)=>`
15
+ `,b=(e,r=process.cwd())=>{const t=n(r,".gitignore"),s=g(t)?f(t,{encoding:"utf-8"}):"";d(t,`${s}${W(e)}`,{encoding:"utf-8"})},H=(e,r,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: ${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{A(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.60",vue:"^3.2.45",vuepress:"2.0.0-beta.60","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
- `,{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
- `,{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})},P=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 P({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 P({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();
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{A(e,{recursive:!0})}},x=(e,r)=>{const t=$(r);m(t);const s=C(e),o=N(r);s.pipe(o)},j=(e,r)=>{m(r),h(e,{withFileTypes:!0}).forEach(t=>{t.isFile()?x(`${e}/${t.name}`,`${r}/${t.name}`):t.isDirectory()&&j(`${e}/${t.name}`,`${r}/${t.name}`)})},S=(e,r)=>{w(e).isDirectory()?j(e,r):w(e).isFile()&&x(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: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),S(n(D,"../template/public"),n(r,e,"./.vuepress/public")),S(n(D,"../template",a),n(r,e)),i){const c=n(r,".github/workflows");m(c),d(n(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=n(t,"package.json"),o=B(r),a={"@vuepress/client":"2.0.0-beta.60",vue:"^3.2.45",vuepress:"2.0.0-beta.60","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:a}),d(s,`${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(s,`${JSON.stringify(i,null,2)}
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 a=n(process.cwd(),e);return g(a)&&h(a).length?console.error(s.error.dirNotEmpty(e)):(m(a),{lang:t,message:s,packageManager:o})},P=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:a}=await p.prompt([{name:"choice",type:"confirm",message:t.question.devServer,default:!0}]);a?(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=n(process.cwd(),e),s=await q(e,r);if(s){const{lang:o,message:a,packageManager:i}=s;await G(a,"src",e),await M("src",{cwd:t,packageManager:i,lang:o,message:a,preset:r}),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@next add [dir] / npm init vuepress-theme-hope@next add [dir]").example("docs").action(async(e,{preset:r=null})=>{const t=await q(e,r);if(t){const{lang:s,message:o,packageManager:a}=t;await G(o,e),await M(e,{packageManager:a,lang:s,message:o,preset:r}),await P({message:o,lang:s,packageManager:a})}}),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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-vuepress-theme-hope",
3
- "version": "2.0.0-beta.150",
3
+ "version": "2.0.0-beta.152",
4
4
  "description": "Create vuepress-theme-hope demo project helper",
5
5
  "keywords": [
6
6
  "create",
@@ -18,8 +18,6 @@ export default hopeTheme({
18
18
 
19
19
  docsDir: "docs",
20
20
 
21
- pageInfo: ["Author", "Original", "Date", "Category", "Tag", "ReadingTime"],
22
-
23
21
  blog: {
24
22
  medias: {
25
23
  Baidu: "https://example.com",
@@ -239,12 +237,6 @@ export default hopeTheme({
239
237
  // purpose: "maskable",
240
238
  // type: "image/png",
241
239
  // },
242
- // {
243
- // src: "/assets/icon/guide-monochrome.png",
244
- // sizes: "192x192",
245
- // purpose: "monochrome",
246
- // type: "image/png",
247
- // },
248
240
  // ],
249
241
  // },
250
242
  // ],
@@ -18,8 +18,6 @@ export default hopeTheme({
18
18
 
19
19
  docsDir: "demo/theme-docs/src",
20
20
 
21
- pageInfo: ["Author", "Original", "Date", "Category", "Tag", "ReadingTime"],
22
-
23
21
  locales: {
24
22
  "/": {
25
23
  // navbar
@@ -187,12 +185,6 @@ export default hopeTheme({
187
185
  // purpose: "maskable",
188
186
  // type: "image/png",
189
187
  // },
190
- // {
191
- // src: "/assets/icon/guide-monochrome.png",
192
- // sizes: "192x192",
193
- // purpose: "monochrome",
194
- // type: "image/png",
195
- // },
196
188
  // ],
197
189
  // },
198
190
  // ],