create-vuepress-theme-plume 1.0.0-rc.105 → 1.0.0-rc.107

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";
@@ -104,7 +93,8 @@ async function createPackageJson(mode, pkg, {
104
93
  siteName,
105
94
  siteDescription,
106
95
  bundler,
107
- injectNpmScripts
96
+ injectNpmScripts,
97
+ useTs
108
98
  }) {
109
99
  if (mode === 1 /* create */) {
110
100
  pkg.name = kebabCase(siteName);
@@ -112,8 +102,10 @@ async function createPackageJson(mode, pkg, {
112
102
  pkg.version = "1.0.0";
113
103
  pkg.description = siteDescription;
114
104
  if (packageManager !== "npm") {
115
- const version = await getPackageManagerVersion(packageManager);
105
+ let version = await getPackageManagerVersion(packageManager);
116
106
  if (version) {
107
+ if (packageManager === "yarn" && version.startsWith("1"))
108
+ version = "4.5.0";
117
109
  pkg.packageManager = `${packageManager}@${version}`;
118
110
  }
119
111
  }
@@ -138,22 +130,23 @@ async function createPackageJson(mode, pkg, {
138
130
  }
139
131
  }
140
132
  pkg.devDependencies ??= {};
133
+ const hasDep = (dep) => pkg.devDependencies?.[dep] || pkg.dependencies?.[dep];
141
134
  const context = await readJsonFile(resolve("package.json"));
142
- const meta = context["theme-plume"];
135
+ const meta = context["plume-deps"];
136
+ pkg.devDependencies[`@vuepress/bundler-${bundler}`] = `${meta.vuepress}`;
143
137
  pkg.devDependencies.vuepress = `${meta.vuepress}`;
144
138
  pkg.devDependencies["vuepress-theme-plume"] = `${context.version}`;
145
- pkg.devDependencies[`@vuepress/bundler-${bundler}`] = `${meta.vuepress}`;
146
- pkg.devDependencies["http-server"] = "^14.1.1";
147
- const deps = [];
148
- if (!pkg.dependencies?.vue && !pkg.devDependencies.vue)
139
+ const deps = ["http-server"];
140
+ if (!hasDep("vue"))
149
141
  deps.push("vue");
150
- if (bundler === "webpack" && !pkg.dependencies?.["sass-loader"] && !pkg.devDependencies["sass-loader"])
142
+ if (bundler === "webpack" && !hasDep("sass-loader"))
151
143
  deps.push("sass-loader");
152
- if (!pkg.dependencies?.["sass-embedded"] && !pkg.devDependencies["sass-embedded"])
144
+ if (!hasDep("sass-embedded"))
153
145
  deps.push("sass-embedded");
154
- const dv = await getDependenciesVersion(deps);
155
- for (const [d, v] of Object.entries(dv))
156
- pkg.devDependencies[d] = `^${v}`;
146
+ if (useTs)
147
+ deps.push("typescript");
148
+ for (const dep of deps)
149
+ pkg.devDependencies[dep] = meta[dep];
157
150
  return {
158
151
  filepath: "package.json",
159
152
  content: JSON.stringify(pkg, null, 2)
@@ -265,6 +258,12 @@ ${docs}/.vuepress/dist
265
258
  fileList.push(...gitFiles);
266
259
  }
267
260
  }
261
+ if (data.packageManager === "yarn") {
262
+ fileList.push({
263
+ filepath: ".yarnrc.yml",
264
+ content: "nodeLinker: 'node-modules'\n"
265
+ });
266
+ }
268
267
  if (data.deploy !== "custom" /* custom */) {
269
268
  fileList.push(...await readFiles(getTemplate(`deploy/${data.deploy}`)));
270
269
  }
@@ -518,7 +517,7 @@ async function run(mode, root) {
518
517
  if (data.install) {
519
518
  progress.message(t("spinner.install"));
520
519
  try {
521
- await execaCommand3(pm === "yarn" ? "yarn" : `${pm} install`, { cwd });
520
+ await execaCommand3(`${pm} install`, { cwd });
522
521
  } catch (e) {
523
522
  console.error(`${colors.red("install dependencies error: ")}
524
523
  `, e);
@@ -526,8 +525,8 @@ async function run(mode, root) {
526
525
  }
527
526
  }
528
527
  const cdCommand = mode === 1 /* create */ ? colors.green(`cd ${data.root}`) : "";
529
- const runCommand = colors.green(pm === "yarn" ? "yarn docs:dev" : `${pm} run docs:dev`);
530
- const installCommand = colors.green(pm === "yarn" ? "yarn" : `${pm} install`);
528
+ const runCommand = colors.green(`${pm} run docs:dev`);
529
+ const installCommand = colors.green(`${pm} install`);
531
530
  progress.stop(t("spinner.stop"));
532
531
  if (mode === 1 /* create */) {
533
532
  outro(`${t("spinner.command")}
@@ -549,5 +548,5 @@ var cli = cac("create-vuepress-theme-plume");
549
548
  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));
550
549
  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));
551
550
  cli.help();
552
- cli.version("1.0.0-rc.104");
551
+ cli.version("1.0.0-rc.106");
553
552
  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.105",
4
+ "version": "1.0.0-rc.107",
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,13 @@
34
34
  "handlebars": "^4.7.8",
35
35
  "picocolors": "^1.1.0"
36
36
  },
37
- "theme-plume": {
38
- "vuepress": "2.0.0-rc.15"
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",
42
+ "http-server": "^14.1.1",
43
+ "typescript": "^5.6.2"
39
44
  },
40
45
  "scripts": {
41
46
  "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,7 +32,7 @@ export default defineUserConfig({
32
32
  * @see https://theme-plume.vuejs.press/config/plugins/code-highlight/
33
33
  */
34
34
  // shiki: {
35
- // // 强烈建议预设代码块高亮语言,插件默认加载所有语言会产生不必要的时间开销
35
+ // 强烈建议预设代码块高亮语言,插件默认加载所有语言会产生不必要的时间开销
36
36
  // languages: ['shell', 'bash', 'typescript', 'javascript'],
37
37
  // },
38
38
 
@@ -50,8 +50,8 @@ npm run docs:preview
50
50
  npm run vp-update
51
51
  ```
52
52
  {{/if}}
53
- {{#if (equal deploy "github")}}
54
53
 
54
+ {{#if (equal deploy "github")}}
55
55
  ## Deploy to GitHub Pages
56
56
 
57
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:
@@ -50,8 +50,8 @@ npm run docs:preview
50
50
  npm run vp-update
51
51
  ```
52
52
  {{/if}}
53
- {{#if (equal deploy "github")}}
54
53
 
54
+ {{#if (equal deploy "github")}}
55
55
  ## 部署到 GitHub Pages
56
56
 
57
57
  主题已创建 github actions: `.github/workflows/docs-deploy.yml`,你还需要在 github 仓库中进行以下设置: