create-vuepress-theme-plume 1.0.0-rc.104 → 1.0.0-rc.106
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
|
@@ -39,17 +39,6 @@ import { execaCommand } from "execa";
|
|
|
39
39
|
import path2 from "node:path";
|
|
40
40
|
import { fileURLToPath } from "node:url";
|
|
41
41
|
|
|
42
|
-
// src/utils/depsVersion.ts
|
|
43
|
-
var api = "https://api.pengzhanbo.cn/npm/dependencies/version";
|
|
44
|
-
async function getDependenciesVersion(dependencies, version = "latest") {
|
|
45
|
-
const result = await fetch(api, {
|
|
46
|
-
method: "POST",
|
|
47
|
-
headers: { "content-type": "application/json" },
|
|
48
|
-
body: JSON.stringify({ dependencies, version })
|
|
49
|
-
}).then((res) => res.json());
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
42
|
// src/utils/fs.ts
|
|
54
43
|
import fs from "node:fs/promises";
|
|
55
44
|
import path from "node:path";
|
|
@@ -138,22 +127,22 @@ async function createPackageJson(mode, pkg, {
|
|
|
138
127
|
}
|
|
139
128
|
}
|
|
140
129
|
pkg.devDependencies ??= {};
|
|
130
|
+
const hasDep = (dep) => pkg.devDependencies?.[dep] || pkg.dependencies?.[dep];
|
|
141
131
|
const context = await readJsonFile(resolve("package.json"));
|
|
142
|
-
const meta = context["
|
|
132
|
+
const meta = context["plume-deps"];
|
|
133
|
+
pkg.devDependencies[`@vuepress/bundler-${bundler}`] = `${meta.vuepress}`;
|
|
143
134
|
pkg.devDependencies.vuepress = `${meta.vuepress}`;
|
|
144
135
|
pkg.devDependencies["vuepress-theme-plume"] = `${context.version}`;
|
|
145
|
-
pkg.devDependencies[`@vuepress/bundler-${bundler}`] = `${meta.vuepress}`;
|
|
146
136
|
pkg.devDependencies["http-server"] = "^14.1.1";
|
|
147
137
|
const deps = [];
|
|
148
|
-
if (!
|
|
138
|
+
if (!hasDep("vue"))
|
|
149
139
|
deps.push("vue");
|
|
150
|
-
if (bundler === "webpack" && !
|
|
140
|
+
if (bundler === "webpack" && !hasDep("sass-loader"))
|
|
151
141
|
deps.push("sass-loader");
|
|
152
|
-
if (!
|
|
142
|
+
if (!hasDep("sass-embedded"))
|
|
153
143
|
deps.push("sass-embedded");
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
pkg.devDependencies[d] = `^${v}`;
|
|
144
|
+
for (const dep of deps)
|
|
145
|
+
pkg.devDependencies[dep] = meta[dep];
|
|
157
146
|
return {
|
|
158
147
|
filepath: "package.json",
|
|
159
148
|
content: JSON.stringify(pkg, null, 2)
|
|
@@ -495,17 +484,35 @@ async function run(mode, root) {
|
|
|
495
484
|
const data = resolveData(result, mode);
|
|
496
485
|
const progress = spinner();
|
|
497
486
|
progress.start(t("spinner.start"));
|
|
498
|
-
|
|
487
|
+
try {
|
|
488
|
+
await generate(mode, data);
|
|
489
|
+
} catch (e) {
|
|
490
|
+
console.error(`${colors.red("generate files error: ")}
|
|
491
|
+
`, e);
|
|
492
|
+
process4.exit(1);
|
|
493
|
+
}
|
|
499
494
|
await sleep(200);
|
|
500
495
|
const cwd = path4.join(process4.cwd(), data.root);
|
|
501
496
|
if (data.git) {
|
|
502
497
|
progress.message(t("spinner.git"));
|
|
503
|
-
|
|
498
|
+
try {
|
|
499
|
+
await execaCommand3("git init", { cwd });
|
|
500
|
+
} catch (e) {
|
|
501
|
+
console.error(`${colors.red("git init error: ")}
|
|
502
|
+
`, e);
|
|
503
|
+
process4.exit(1);
|
|
504
|
+
}
|
|
504
505
|
}
|
|
505
506
|
const pm = data.packageManager;
|
|
506
507
|
if (data.install) {
|
|
507
508
|
progress.message(t("spinner.install"));
|
|
508
|
-
|
|
509
|
+
try {
|
|
510
|
+
await execaCommand3(pm === "yarn" ? "yarn" : `${pm} install`, { cwd });
|
|
511
|
+
} catch (e) {
|
|
512
|
+
console.error(`${colors.red("install dependencies error: ")}
|
|
513
|
+
`, e);
|
|
514
|
+
process4.exit(1);
|
|
515
|
+
}
|
|
509
516
|
}
|
|
510
517
|
const cdCommand = mode === 1 /* create */ ? colors.green(`cd ${data.root}`) : "";
|
|
511
518
|
const runCommand = colors.green(pm === "yarn" ? "yarn docs:dev" : `${pm} run docs:dev`);
|
|
@@ -531,5 +538,5 @@ var cli = cac("create-vuepress-theme-plume");
|
|
|
531
538
|
cli.command("[root]", "create a new vuepress-theme-plume project / \u521B\u5EFA\u65B0\u7684 vuepress-theme-plume \u9879\u76EE").action((root) => run(1 /* create */, root));
|
|
532
539
|
cli.command("init [root]", "Initial vuepress-theme-plume in the existing project / \u5728\u73B0\u6709\u9879\u76EE\u4E2D\u521D\u59CB\u5316 vuepress-theme-plume").action((root) => run(0 /* init */, root));
|
|
533
540
|
cli.help();
|
|
534
|
-
cli.version("1.0.0-rc.
|
|
541
|
+
cli.version("1.0.0-rc.105");
|
|
535
542
|
cli.parse();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-vuepress-theme-plume",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.106",
|
|
5
5
|
"description": "The cli for create vuepress-theme-plume's project",
|
|
6
6
|
"author": "pengzhanbo <q942450674@outlook.com> (https://github.com/pengzhanbo/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -34,8 +34,11 @@
|
|
|
34
34
|
"handlebars": "^4.7.8",
|
|
35
35
|
"picocolors": "^1.1.0"
|
|
36
36
|
},
|
|
37
|
-
"
|
|
38
|
-
"vuepress": "2.0.0-rc.
|
|
37
|
+
"plume-deps": {
|
|
38
|
+
"vuepress": "2.0.0-rc.17",
|
|
39
|
+
"vue": "^3.5.10",
|
|
40
|
+
"sass-embedded": "^1.79.4",
|
|
41
|
+
"sass-loader": "^16.0.2"
|
|
39
42
|
},
|
|
40
43
|
"scripts": {
|
|
41
44
|
"build": "tsup"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineUserConfig } from 'vuepress'
|
|
2
1
|
import { {{ bundler }}Bundler } from '@vuepress/bundler-{{ bundler }}'
|
|
2
|
+
import { defineUserConfig } from 'vuepress'
|
|
3
3
|
import { plumeTheme } from 'vuepress-theme-plume'
|
|
4
4
|
|
|
5
5
|
export default defineUserConfig({
|
|
@@ -32,8 +32,8 @@ export default defineUserConfig({
|
|
|
32
32
|
* @see https://theme-plume.vuejs.press/config/plugins/code-highlight/
|
|
33
33
|
*/
|
|
34
34
|
// shiki: {
|
|
35
|
+
// 强烈建议预设代码块高亮语言,插件默认加载所有语言会产生不必要的时间开销
|
|
35
36
|
// languages: ['shell', 'bash', 'typescript', 'javascript'],
|
|
36
|
-
// twoslash: true,
|
|
37
37
|
// },
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -72,7 +72,7 @@ export default defineUserConfig({
|
|
|
72
72
|
// },
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
* comments
|
|
75
|
+
* 评论 comments
|
|
76
76
|
* @see https://theme-plume.vuejs.press/guide/features/comments/
|
|
77
77
|
*/
|
|
78
78
|
// comment: {
|
|
@@ -51,6 +51,23 @@ npm run vp-update
|
|
|
51
51
|
```
|
|
52
52
|
{{/if}}
|
|
53
53
|
|
|
54
|
+
{{#if (equal deploy "github")}}
|
|
55
|
+
## Deploy to GitHub Pages
|
|
56
|
+
|
|
57
|
+
The plume theme has been created with GitHub Actions: `.github/workflows/docs-deploy.yml`. You also need to make the following settings in the GitHub repository:
|
|
58
|
+
|
|
59
|
+
- [ ] `settings > Actions > General`, Scroll to the bottom of the page, under `Workflow permissions`, check `Read and write permissions`, and click the save button.
|
|
60
|
+
|
|
61
|
+
- [ ] `settings > Pages`, In `Build and deployment`, select `Deploy from a branch` for `Source`, choose `gh-pages` for `Branch`, and click the save button.
|
|
62
|
+
(The `gh-pages` branch may not exist upon first creation. You can complete the above setup first, push the code to the main branch, wait for `github actions` to finish, and then proceed with the setup.)
|
|
63
|
+
|
|
64
|
+
- [ ] Modify the `base` option in `docs/.vuepress/config.ts`:
|
|
65
|
+
- If you are planning to deploy to `https://<USERNAME>.github.io/`, you can skip this step as `base` defaults to `"/"`.
|
|
66
|
+
- If you are planning to deploy to `https://<USERNAME>.github.io/<REPO>/`, meaning your repository URL is `https://github.com/<USERNAME>/<REPO>`, set `base` to `"/<REPO>/"`.
|
|
67
|
+
|
|
68
|
+
To customize a domain name, please refer to [Github Pages](https://docs.github.com/zh/pages/configuring-a-custom-domain-for-your-github-pages-site/about-custom-domains-and-github-pages)
|
|
69
|
+
|
|
70
|
+
{{/if}}
|
|
54
71
|
## Documents
|
|
55
72
|
|
|
56
73
|
- [vuepress](https://vuepress.vuejs.org/)
|
|
@@ -51,6 +51,23 @@ npm run vp-update
|
|
|
51
51
|
```
|
|
52
52
|
{{/if}}
|
|
53
53
|
|
|
54
|
+
{{#if (equal deploy "github")}}
|
|
55
|
+
## 部署到 GitHub Pages
|
|
56
|
+
|
|
57
|
+
主题已创建 github actions: `.github/workflows/docs-deploy.yml`,你还需要在 github 仓库中进行以下设置:
|
|
58
|
+
|
|
59
|
+
- [ ] `settings > Actions > General`,拉到页面底部,在 `Workflow permissions` 下,勾选 `Read and write permissions`,并点击保存按钮
|
|
60
|
+
|
|
61
|
+
- [ ] `settings > Pages`, 在 `Build and deployment` 中,`Source` 选择 `Deploy from a branch`, `Branch` 选择 `gh-pages`,并点击保存按钮
|
|
62
|
+
(首次创建可能没有 `gh-pages`分支,你可以先完成上面的设置后,推送一次代码到主分支,等待 `github actions` 完成后再进行设置)
|
|
63
|
+
|
|
64
|
+
- [ ] 修改 `docs/.vuepress/config.ts` 中的 `base` 选项:
|
|
65
|
+
- 如果你准备发布到 `https://<USERNAME>.github.io/` ,你可以省略这一步,因为 `base` 默认就是 `"/"` 。
|
|
66
|
+
- 如果你准备发布到 `https://<USERNAME>.github.io/<REPO>/` ,也就是说你的仓库地址是 `https://github.com/<USERNAME>/<REPO>` ,则将 `base` 设置为 `"/<REPO>/"`。
|
|
67
|
+
|
|
68
|
+
如需要自定义域名,请查看 [Github Pages 文档](https://docs.github.com/zh/pages/configuring-a-custom-domain-for-your-github-pages-site/about-custom-domains-and-github-pages)
|
|
69
|
+
|
|
70
|
+
{{/if}}
|
|
54
71
|
## 文档
|
|
55
72
|
|
|
56
73
|
- [vuepress](https://vuepress.vuejs.org/)
|