create-vuepress-theme-hope 2.0.0-beta.172 → 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/README.md +12 -10
- package/lib/index.js +17 -17
- package/package.json +2 -1
- package/template/blog/.vuepress/theme.ts +2 -30
- package/template/blog/slides.md +1 -1
- package/template/docs/.vuepress/theme.ts +2 -30
- package/template/docs/slides.md +1 -1
package/README.md
CHANGED
|
@@ -7,14 +7,15 @@ Create template shortcut for vuepress-theme-hope.
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
+
# npm
|
|
10
11
|
npm init vuepress-theme-hope <dir>
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
<!-- Or
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
# yarn
|
|
16
14
|
yarn create vuepress-theme-hope <dir>
|
|
17
|
-
|
|
15
|
+
|
|
16
|
+
# pnpm
|
|
17
|
+
pnpm create vuepress-theme-hope <dir>
|
|
18
|
+
```
|
|
18
19
|
|
|
19
20
|
---
|
|
20
21
|
|
|
@@ -23,11 +24,12 @@ yarn create vuepress-theme-hope <dir>
|
|
|
23
24
|
## 使用
|
|
24
25
|
|
|
25
26
|
```bash
|
|
27
|
+
# npm
|
|
26
28
|
npm init vuepress-theme-hope <dir>
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
<!-- 或
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
# yarn
|
|
32
31
|
yarn create vuepress-theme-hope <dir>
|
|
33
|
-
|
|
32
|
+
|
|
33
|
+
# pnpm
|
|
34
|
+
pnpm create vuepress-theme-hope <dir>
|
|
35
|
+
```
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{existsSync as
|
|
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" 等!
|
|
@@ -7,18 +7,18 @@ import{existsSync as g,readFileSync as w,writeFileSync as d,readdirSync as h,mkd
|
|
|
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
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.`}}},
|
|
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.`}}},H=async()=>{const{language:e}=await p.prompt([{name:"language",type:"list",message:"Select a language to display / 选择显示语言",choices:["english (US)","简体中文"]}]);return{lang:e,message:W[e]}},J=e=>`
|
|
11
11
|
node_modules/
|
|
12
12
|
${e}/.vuepress/.cache/
|
|
13
13
|
${e}/.vuepress/.temp/
|
|
14
14
|
${e}/.vuepress/dist/
|
|
15
|
-
`,
|
|
16
|
-
name: ${
|
|
15
|
+
`,S=(e,t=process.cwd())=>{const s=n(t,".gitignore"),o=h(s)?$(s,{encoding:"utf-8"}):"";d(s,`${o}${J(e)}`,{encoding:"utf-8"})},R=(e,t,s)=>`
|
|
16
|
+
name: ${s==="简体中文"?"部署文档":"Deploy Docs"}
|
|
17
17
|
|
|
18
18
|
on:
|
|
19
19
|
push:
|
|
20
20
|
branches:
|
|
21
|
-
# ${
|
|
21
|
+
# ${s==="简体中文"?"确保这是你正在使用的分支名称":"make sure this is the branch you are using"}
|
|
22
22
|
- main
|
|
23
23
|
|
|
24
24
|
jobs:
|
|
@@ -29,38 +29,38 @@ jobs:
|
|
|
29
29
|
uses: actions/checkout@v3
|
|
30
30
|
with:
|
|
31
31
|
fetch-depth: 0
|
|
32
|
-
# ${
|
|
32
|
+
# ${s==="简体中文"?"如果你文档需要 Git 子模块,取消注释下一行":"if your docs needs submodules, uncomment the following line"}
|
|
33
33
|
# submodules: true
|
|
34
34
|
|
|
35
|
-
${e==="pnpm"?` - name: ${
|
|
35
|
+
${e==="pnpm"?` - name: ${s==="简体中文"?"安装 pnpm":"Install pnpm"}
|
|
36
36
|
uses: pnpm/action-setup@v2
|
|
37
37
|
with:
|
|
38
38
|
version: 7
|
|
39
39
|
run_install: true
|
|
40
40
|
`:""}
|
|
41
41
|
|
|
42
|
-
- name: ${
|
|
42
|
+
- name: ${s==="简体中文"?"设置 Node.js":"Setup Node.js"}
|
|
43
43
|
uses: actions/setup-node@v3
|
|
44
44
|
with:
|
|
45
45
|
node-version: 18
|
|
46
46
|
cache: ${e}
|
|
47
47
|
|
|
48
|
-
${e!=="pnpm"?` - name: ${
|
|
48
|
+
${e!=="pnpm"?` - name: ${s==="简体中文"?"安装依赖":"Install Deps"}
|
|
49
49
|
run: ${e==="npm"?"npm ci":`${e} install --frozen-lockfile`}
|
|
50
50
|
`:""}
|
|
51
|
-
- name: ${
|
|
51
|
+
- name: ${s==="简体中文"?"构建文档":"Build Docs"}
|
|
52
52
|
env:
|
|
53
53
|
NODE_OPTIONS: --max_old_space_size=8192
|
|
54
54
|
run: |-
|
|
55
55
|
${e} run docs:build
|
|
56
|
-
> ${
|
|
56
|
+
> ${b(t,".vuepress/dist/.nojekyll").replace(/\\/g,"/")}
|
|
57
57
|
|
|
58
|
-
- name: ${
|
|
58
|
+
- name: ${s==="简体中文"?"部署文档":"Deploy Docs"}
|
|
59
59
|
uses: JamesIves/github-pages-deploy-action@v4
|
|
60
60
|
with:
|
|
61
|
-
# ${
|
|
61
|
+
# ${s==="简体中文"?"这是文档部署到的分支名称":"This is the branch where the docs are deployed to"}
|
|
62
62
|
branch: gh-pages
|
|
63
|
-
folder: ${
|
|
64
|
-
`,
|
|
65
|
-
`,{encoding:"utf-8"})}else{console.log(
|
|
66
|
-
`,{encoding:"utf-8"})}},
|
|
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=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
|
+
`,{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
|
+
`,{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.
|
|
3
|
+
"version": "2.0.0-beta.174",
|
|
4
4
|
"description": "Create vuepress-theme-hope demo project helper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"create",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"create-vuepress-theme-hope": "./lib/index.js"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
|
+
"lib",
|
|
35
36
|
"template"
|
|
36
37
|
],
|
|
37
38
|
"dependencies": {
|
|
@@ -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
|
-
//
|
|
124
|
+
// all features are enabled for demo, only preserve features you need here
|
|
153
125
|
mdEnhance: {
|
|
154
126
|
align: true,
|
|
155
127
|
attrs: true,
|
package/template/blog/slides.md
CHANGED
|
@@ -331,7 +331,7 @@ Multiple elements can appear at the same index.
|
|
|
331
331
|
|
|
332
332
|
<!-- .element: class="r-fit-text" -->
|
|
333
333
|
|
|
334
|
-
Transition can be changed by setting the `transition` config option globally or `data-transition` attribute on
|
|
334
|
+
Transition can be changed by setting the `transition` config option globally or `data-transition` attribute on slide.
|
|
335
335
|
|
|
336
336
|
Possible values:
|
|
337
337
|
|
|
@@ -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
|
-
//
|
|
72
|
+
// all features are enabled for demo, only preserve features you need here
|
|
101
73
|
mdEnhance: {
|
|
102
74
|
align: true,
|
|
103
75
|
attrs: true,
|
package/template/docs/slides.md
CHANGED
|
@@ -331,7 +331,7 @@ Multiple elements can appear at the same index.
|
|
|
331
331
|
|
|
332
332
|
<!-- .element: class="r-fit-text" -->
|
|
333
333
|
|
|
334
|
-
Transition can be changed by setting the `transition` config option globally or `data-transition` attribute on
|
|
334
|
+
Transition can be changed by setting the `transition` config option globally or `data-transition` attribute on slide.
|
|
335
335
|
|
|
336
336
|
Possible values:
|
|
337
337
|
|