create-vuepress-theme-hope 2.0.0-beta.173 → 2.0.0-beta.174

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{existsSync as h,readFileSync as $,writeFileSync as d,readdirSync as v,mkdirSync as N,statSync as k,createReadStream as E,createWriteStream as I}from"node:fs";import{resolve as n,join as b,dirname as j}from"node:path";import{cac as O}from"cac";import{execaCommandSync as l,execaCommand as z}from"execa";import p from"inquirer";import{fileURLToPath as A}from"node:url";import"node:https";import{createRequire as F}from"node:module";const W={简体中文:{flow:{getVersion:"获取依赖的最新版本...",createPackage:"生成 package.json...",updatePackage:"更新 package.json...",generateTemplate:"生成模板...",install:"安装依赖...",devServer:`启动开发服务器...
2
+ import{existsSync as h,readFileSync as $,writeFileSync as d,readdirSync as v,mkdirSync as N,statSync as k,createReadStream as E,createWriteStream as I}from"node:fs";import{resolve as n,join as b,dirname as j}from"node:path";import{cac as O}from"cac";import{execaCommandSync as l,execaCommand as z}from"execa";import p from"inquirer";import{createRequire as A}from"node:module";import{fileURLToPath as F}from"node:url";const W={简体中文:{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 project-docs"`,updateDirMissing:e=>`"[dir]" 的方括号表示此处为一个参数,你应该替换为自己想使用的文件夹名称,如 "src", "docs" 等!
@@ -61,6 +61,6 @@ ${e!=="pnpm"?` - name: ${s==="简体中文"?"安装依赖":"Install Deps"}
61
61
  # ${s==="简体中文"?"这是文档部署到的分支名称":"This is the branch where the docs are deployed to"}
62
62
  branch: gh-pages
63
63
  folder: ${b(t,".vuepress/dist").replace(/\\/g,"/")}
64
- `,Y=Array.isArray,y=e=>Object.prototype.toString.call(e)==="[object Object]",f=(e,...t)=>{if(t.length===0)return e;const s=t.shift()||null;return s&&Object.entries(s).forEach(([o,r])=>{o==="__proto__"||o==="constructor"||(y(e[o])&&y(r)?f(e[o],r):Y(r)?e[o]=[...r]:y(r)?e[o]={...r}:e[o]=s[o])}),f(e,...t)},m=e=>{try{v(e)}catch{N(e,{recursive:!0})}},x=(e,t)=>{const s=j(t);m(s);const o=E(e),r=I(t);o.pipe(r)},D=(e,t)=>{m(t),v(e,{withFileTypes:!0}).forEach(s=>{s.isFile()?x(`${e}/${s.name}`,`${t}/${s.name}`):s.isDirectory()&&D(`${e}/${s.name}`,`${t}/${s.name}`)})},M=(e,t)=>{k(e).isDirectory()?D(e,t):k(e).isFile()&&x(e,t)},U=(e=process.cwd())=>{try{return l("git status",{cwd:e}),!0}catch{return!1}},V=()=>{try{return l("git --version"),!0}catch{return!1}},L=()=>{try{return l("pnpm --version",{stdio:"ignore"}).exitCode===0}catch{return!1}},B=()=>{try{return l("yarn --version",{stdio:"ignore"}).exitCode===0}catch{return!1}},w=["npm"];B()&&w.push("yarn"),L()&&w.push("pnpm");const K=async e=>(await p.prompt([{name:"packageManager",type:"list",message:e,choices:w}])).packageManager,Q=A(import.meta.url),T=j(Q),G=async(e,{cwd:t=process.cwd(),packageManager:s,lang:o,message:r,preset:a})=>{const{workflow:c}=await p.prompt([{name:"workflow",type:"confirm",message:r.question.workflow,default:!0}]);if(a||(a=(await p.prompt([{name:"preset",type:"list",message:r.question.preset,choices:["blog","docs"]}])).preset),console.log(r.flow.generateTemplate),M(n(T,"../template/public"),n(t,e,"./.vuepress/public")),M(n(T,"../template",a),n(t,e)),c){const i=n(t,".github/workflows");m(i),d(n(i,"deploy-docs.yml"),R(s,e,o),{encoding:"utf-8"})}if(U(t))S(e,t);else if(V()){const{git:i}=await p.prompt([{name:"git",type:"confirm",message:r.question.git,default:!0}]);i&&(l("git init",{cwd:t}),S(e,t))}},q=F(import.meta.url)("create-vuepress-theme-hope/package.json").version,X=(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`}),_=async(e,t,s,o=process.cwd())=>{const r=n(o,"package.json"),a=X(e,s),c={"@vuepress/client":"2.0.0-beta.60",vue:"^3.2.47",vuepress:"2.0.0-beta.60","vuepress-theme-hope":q};if(h(r)){console.log(t.flow.updatePackage);const i=JSON.parse($(r,{encoding:"utf-8"}));f(i,{scripts:a,devDependencies:c}),d(r,`${JSON.stringify(i,null,2)}
64
+ `,Y=Array.isArray,y=e=>Object.prototype.toString.call(e)==="[object Object]",f=(e,...t)=>{if(t.length===0)return e;const s=t.shift()||null;return s&&Object.entries(s).forEach(([o,r])=>{o==="__proto__"||o==="constructor"||(y(e[o])&&y(r)?f(e[o],r):Y(r)?e[o]=[...r]:y(r)?e[o]={...r}:e[o]=s[o])}),f(e,...t)},m=e=>{try{v(e)}catch{N(e,{recursive:!0})}},x=(e,t)=>{const s=j(t);m(s);const o=E(e),r=I(t);o.pipe(r)},D=(e,t)=>{m(t),v(e,{withFileTypes:!0}).forEach(s=>{s.isFile()?x(`${e}/${s.name}`,`${t}/${s.name}`):s.isDirectory()&&D(`${e}/${s.name}`,`${t}/${s.name}`)})},M=(e,t)=>{k(e).isDirectory()?D(e,t):k(e).isFile()&&x(e,t)},U=(e=process.cwd())=>{try{return l("git status",{cwd:e}),!0}catch{return!1}},V=()=>{try{return l("git --version"),!0}catch{return!1}},L=()=>{try{return l("pnpm --version",{stdio:"ignore"}).exitCode===0}catch{return!1}},B=()=>{try{return l("yarn --version",{stdio:"ignore"}).exitCode===0}catch{return!1}},w=["npm"];B()&&w.push("yarn"),L()&&w.push("pnpm");const K=async e=>(await p.prompt([{name:"packageManager",type:"list",message:e,choices:w}])).packageManager,Q=F(import.meta.url),T=j(Q),G=async(e,{cwd:t=process.cwd(),packageManager:s,lang:o,message:r,preset:a})=>{const{workflow:c}=await p.prompt([{name:"workflow",type:"confirm",message:r.question.workflow,default:!0}]);if(a||(a=(await p.prompt([{name:"preset",type:"list",message:r.question.preset,choices:["blog","docs"]}])).preset),console.log(r.flow.generateTemplate),M(n(T,"../template/public"),n(t,e,"./.vuepress/public")),M(n(T,"../template",a),n(t,e)),c){const i=n(t,".github/workflows");m(i),d(n(i,"deploy-docs.yml"),R(s,e,o),{encoding:"utf-8"})}if(U(t))S(e,t);else if(V()){const{git:i}=await p.prompt([{name:"git",type:"confirm",message:r.question.git,default:!0}]);i&&(l("git init",{cwd:t}),S(e,t))}},q=A(import.meta.url)("create-vuepress-theme-hope/package.json").version,X=(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`}),_=async(e,t,s,o=process.cwd())=>{const r=n(o,"package.json"),a=X(e,s),c={"@vuepress/client":"2.0.0-beta.60",vue:"^3.2.47",vuepress:"2.0.0-beta.60","vuepress-theme-hope":q};if(h(r)){console.log(t.flow.updatePackage);const i=JSON.parse($(r,{encoding:"utf-8"}));f(i,{scripts:a,devDependencies:c}),d(r,`${JSON.stringify(i,null,2)}
65
65
  `,{encoding:"utf-8"})}else{console.log(t.flow.createPackage);const i={...await p.prompt([{name:"name",type:"input",message:t.question.name,default:"vuepress-theme-hope-template",validate:g=>/^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/u.exec(g)?!0:t.error.name},{name:"version",type:"input",message:t.question.version,default:"2.0.0",validate:g=>/^[0-9]+\.[0-9]+\.(?:[0=9]+|[0-9]+-[a-z]+\.[0-9])$/u.exec(g)?!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:a,devDependencies:c};d(r,`${JSON.stringify(i,null,2)}
66
66
  `,{encoding:"utf-8"})}},Z="https://registry.npmmirror.com/",ee=e=>l(`${e} config get registry`).stdout,te=async(e,t)=>{const s=ee(e);if(t==="简体中文"){const{registry:o}=await p.prompt([{name:"registry",type:"list",message:"选择你想使用的源",choices:["国内镜像源","当前源"]}]);return o==="国内镜像源"?Z:s}return s},P=async(e,t)=>{if(!e)return u.outputHelp();const{lang:s,message:o}=await H();if(t&&!["docs","blog"].includes(t))return console.log(o.error.preset);const r=await K(o.question.packageManager);if(e.startsWith("[")&&e.endsWith("]"))return console.log(o.error.updateDirMissing(r));const a=n(process.cwd(),e);return h(a)&&v(a).length?console.error(o.error.dirNotEmpty(e)):(m(a),{lang:s,message:o,packageManager:r})},C=async({cwd:e=process.cwd(),lang:t,message:s,packageManager:o})=>{const r=o==="pnpm"?"":await te(o,t);console.log(s.flow.install),console.warn(s.hint.install),l(`${o} install ${r?`--registry ${r}`:""}`,{cwd:e,stdout:"inherit"}),console.log(s.hint.finish);const{choice:a}=await p.prompt([{name:"choice",type:"confirm",message:s.question.devServer,default:!0}]);a?(console.log(s.flow.devServer),await z(`${o} run docs:dev`,{cwd:e,stdout:"inherit"})):console.log(s.hint.devServer(o))},u=O("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] / yarn create vuepress-theme-hope [dir] / npm init vuepress-theme-hope [dir]").example("docs").action(async(e,{preset:t=null})=>{const s=n(process.cwd(),e),o=await P(e,t);if(o){const{lang:r,message:a,packageManager:c}=o;await _(c,a,"src",e),await G("src",{cwd:s,packageManager:c,lang:r,message:a,preset:t}),await C({cwd:s,lang:r,message:a,packageManager:c})}}),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] / 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 P(e,t);if(s){const{lang:o,message:r,packageManager:a}=s;await _(a,r,e),await G(e,{packageManager:a,lang:o,message:r,preset:t}),await C({message:r,lang:o,packageManager:a})}}),u.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"}]),u.version(q),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.173",
3
+ "version": "2.0.0-beta.174",
4
4
  "description": "Create vuepress-theme-hope demo project helper",
5
5
  "keywords": [
6
6
  "create",
@@ -116,40 +116,12 @@ export default hopeTheme({
116
116
  plugins: {
117
117
  blog: true,
118
118
 
119
- // If you don’t need comment feature, you can remove following option
120
- // The following config is for demo ONLY, if you need comment feature, please generate and use your own config, see comment plugin documentation for details.
121
- // To avoid disturbing the theme developer and consuming his resources, please DO NOT use the following config directly in your production environment!!!!!
122
119
  comment: {
123
- /**
124
- * Using Giscus
125
- */
120
+ // @ts-expect-error: You should generate and use your own comment service
126
121
  provider: "Giscus",
127
- repo: "vuepress-theme-hope/giscus-discussions",
128
- repoId: "R_kgDOG_Pt2A",
129
- category: "Announcements",
130
- categoryId: "DIC_kwDOG_Pt2M4COD69",
131
-
132
- /**
133
- * Using Twikoo
134
- */
135
- // provider: "Twikoo",
136
- // envId: "https://twikoo.ccknbc.vercel.app",
137
-
138
- /**
139
- * Using Waline
140
- */
141
- // provider: "Waline",
142
- // serverURL: "https://vuepress-theme-hope-comment.vercel.app",
143
-
144
- /**
145
- * Using artalk
146
- */
147
- // provider: "Artalk",
148
- // site: "artalk-demo",
149
- // server: "https://demo-artalk.jjdxb.top/",
150
122
  },
151
123
 
152
- // Disable features you don’t want here
124
+ // all features are enabled for demo, only preserve features you need here
153
125
  mdEnhance: {
154
126
  align: true,
155
127
  attrs: true,
@@ -64,40 +64,12 @@ export default hopeTheme({
64
64
  },
65
65
 
66
66
  plugins: {
67
- // If you don’t need comment feature, you can remove following option
68
- // The following config is for demo ONLY, if you need comment feature, please generate and use your own config, see comment plugin documentation for details.
69
- // To avoid disturbing the theme developer and consuming his resources, please DO NOT use the following config directly in your production environment!!!!!
70
67
  comment: {
71
- /**
72
- * Using Giscus
73
- */
74
- // provider: "Giscus",
75
- // repo: "vuepress-theme-hope/giscus-discussions",
76
- // repoId: "R_kgDOG_Pt2A",
77
- // category: "Announcements",
78
- // categoryId: "DIC_kwDOG_Pt2M4COD69",
79
-
80
- /**
81
- * Using Twikoo
82
- */
83
- // provider: "Twikoo",
84
- // envId: "https://twikoo.ccknbc.vercel.app",
85
-
86
- /**
87
- * Using Waline
88
- */
68
+ // @ts-expect-error: You should generate and use your own comment service
89
69
  provider: "Waline",
90
- serverURL: "https://vuepress-theme-hope-comment.vercel.app",
91
-
92
- /**
93
- * Using artalk
94
- */
95
- // provider: "Artalk",
96
- // site: "artalk-demo",
97
- // server: "https://demo-artalk.jjdxb.top/",
98
70
  },
99
71
 
100
- // Disable features you don’t want here
72
+ // all features are enabled for demo, only preserve features you need here
101
73
  mdEnhance: {
102
74
  align: true,
103
75
  attrs: true,