create-vuepress-theme-plume 1.0.0-rc.97 → 1.0.0-rc.98
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,82 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import cac from "cac";
|
|
3
3
|
|
|
4
|
-
// src/run.ts
|
|
5
|
-
import process4 from "node:process";
|
|
6
|
-
import path4 from "node:path";
|
|
7
|
-
import { intro, outro, spinner } from "@clack/prompts";
|
|
8
|
-
import { execaCommand as execaCommand3 } from "execa";
|
|
9
|
-
import colors from "picocolors";
|
|
10
|
-
|
|
11
|
-
// src/prompt.ts
|
|
12
|
-
import process from "node:process";
|
|
13
|
-
import { createRequire } from "node:module";
|
|
14
|
-
import { cancel, confirm, group, select, text } from "@clack/prompts";
|
|
15
|
-
|
|
16
|
-
// src/locales/en.ts
|
|
17
|
-
var en = {
|
|
18
|
-
"question.root": "Where would you want to initialize VuePress?",
|
|
19
|
-
"question.site.name": "Site Name:",
|
|
20
|
-
"question.site.description": "Site Description:",
|
|
21
|
-
"question.bundler": "Select a bundler",
|
|
22
|
-
"question.multiLanguage": "Do you want to use multiple languages?",
|
|
23
|
-
"question.defaultLanguage": "Select the default language of the site",
|
|
24
|
-
"question.useTs": "Use TypeScript?",
|
|
25
|
-
"question.injectNpmScripts": "Inject npm scripts?",
|
|
26
|
-
"question.deploy": "Deploy type:",
|
|
27
|
-
"question.git": "Initialize a git repository?",
|
|
28
|
-
"question.installDeps": "Install dependencies?",
|
|
29
|
-
"spinner.start": "\u{1F680} Creating...",
|
|
30
|
-
"spinner.stop": "\u{1F389} Create success!",
|
|
31
|
-
"spinner.git": "\u{1F4C4} Initializing git repository...",
|
|
32
|
-
"spinner.install": "\u{1F4E6} Installing dependencies...",
|
|
33
|
-
"spinner.command": "\u{1F528} Execute the following command to start:",
|
|
34
|
-
"hint.cancel": "Operation cancelled.",
|
|
35
|
-
"hint.root": "The path cannot be an absolute path, and cannot contain the parent path.",
|
|
36
|
-
"hint.root.illegal": "Project names cannot contain special characters."
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// src/locales/zh.ts
|
|
40
|
-
var zh = {
|
|
41
|
-
"question.root": "\u60A8\u60F3\u5728\u54EA\u91CC\u521D\u59CB\u5316 VuePress\uFF1F",
|
|
42
|
-
"question.site.name": "\u7AD9\u70B9\u540D\u79F0\uFF1A",
|
|
43
|
-
"question.site.description": "\u7AD9\u70B9\u63CF\u8FF0\u4FE1\u606F\uFF1A",
|
|
44
|
-
"question.bundler": "\u8BF7\u9009\u62E9\u6253\u5305\u5DE5\u5177",
|
|
45
|
-
"question.multiLanguage": "\u662F\u5426\u4F7F\u7528\u591A\u8BED\u8A00\uFF1F",
|
|
46
|
-
"question.defaultLanguage": "\u8BF7\u9009\u62E9\u7AD9\u70B9\u9ED8\u8BA4\u8BED\u8A00",
|
|
47
|
-
"question.useTs": "\u662F\u5426\u4F7F\u7528 TypeScript\uFF1F",
|
|
48
|
-
"question.injectNpmScripts": "\u662F\u5426\u6CE8\u5165 npm \u811A\u672C\uFF1F",
|
|
49
|
-
"question.deploy": "\u90E8\u7F72\u65B9\u5F0F\uFF1A",
|
|
50
|
-
"question.git": "\u662F\u5426\u521D\u59CB\u5316 git \u4ED3\u5E93\uFF1F",
|
|
51
|
-
"question.installDeps": "\u662F\u5426\u5B89\u88C5\u4F9D\u8D56\uFF1F",
|
|
52
|
-
"spinner.start": "\u{1F680} \u6B63\u5728\u521B\u5EFA...",
|
|
53
|
-
"spinner.stop": "\u{1F389} \u521B\u5EFA\u6210\u529F!",
|
|
54
|
-
"spinner.git": "\u{1F4C4} \u521D\u59CB\u5316 git \u4ED3\u5E93...",
|
|
55
|
-
"spinner.install": "\u{1F4E6} \u5B89\u88C5\u4F9D\u8D56...",
|
|
56
|
-
"spinner.command": "\u{1F528} \u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u5373\u53EF\u542F\u52A8\uFF1A",
|
|
57
|
-
"hint.cancel": "\u64CD\u4F5C\u5DF2\u53D6\u6D88\u3002",
|
|
58
|
-
"hint.root": "\u6587\u4EF6\u8DEF\u5F84\u4E0D\u80FD\u662F\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u5305\u542B\u7236\u8DEF\u5F84\u3002",
|
|
59
|
-
"hint.root.illegal": "\u6587\u4EF6\u5939\u4E0D\u80FD\u5305\u542B\u7279\u6B8A\u5B57\u7B26\u3002"
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// src/locales/index.ts
|
|
63
|
-
var locales = {
|
|
64
|
-
"zh-CN": zh,
|
|
65
|
-
"en-US": en
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// src/translate.ts
|
|
69
|
-
function createTranslate(lang) {
|
|
70
|
-
let current = lang || "en-US";
|
|
71
|
-
return {
|
|
72
|
-
setLang: (lang2) => {
|
|
73
|
-
current = lang2;
|
|
74
|
-
},
|
|
75
|
-
t: (key) => locales[current][key]
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
var { t, setLang } = createTranslate();
|
|
79
|
-
|
|
80
4
|
// src/constants.ts
|
|
81
5
|
var languageOptions = [
|
|
82
6
|
{ label: "English", value: "en-US" },
|
|
@@ -93,130 +17,41 @@ var deployOptions = [
|
|
|
93
17
|
{ label: "Netlify", value: "netlify" /* netlify */ }
|
|
94
18
|
];
|
|
95
19
|
|
|
96
|
-
// src/
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
try {
|
|
103
|
-
hasTs = !!require2.resolve("typescript");
|
|
104
|
-
} catch {
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
const result = await group({
|
|
108
|
-
displayLang: async () => {
|
|
109
|
-
const lang = await select({
|
|
110
|
-
message: "Select a language to display / \u9009\u62E9\u663E\u793A\u8BED\u8A00",
|
|
111
|
-
options: languageOptions
|
|
112
|
-
});
|
|
113
|
-
if (typeof lang === "string")
|
|
114
|
-
setLang(lang);
|
|
115
|
-
return lang;
|
|
116
|
-
},
|
|
117
|
-
root: async () => {
|
|
118
|
-
if (root)
|
|
119
|
-
return root;
|
|
120
|
-
const DEFAULT_ROOT = mode === 0 /* init */ ? "./docs" : "./my-project";
|
|
121
|
-
return await text({
|
|
122
|
-
message: t("question.root"),
|
|
123
|
-
placeholder: DEFAULT_ROOT,
|
|
124
|
-
validate(value) {
|
|
125
|
-
if (value?.startsWith("/") || value?.startsWith(".."))
|
|
126
|
-
return t("hint.root");
|
|
127
|
-
if (value && REG_DIR_CHAR.test(value))
|
|
128
|
-
return t("hint.root.illegal");
|
|
129
|
-
return void 0;
|
|
130
|
-
},
|
|
131
|
-
defaultValue: DEFAULT_ROOT
|
|
132
|
-
});
|
|
133
|
-
},
|
|
134
|
-
siteName: () => text({
|
|
135
|
-
message: t("question.site.name"),
|
|
136
|
-
placeholder: "My Vuepress Site",
|
|
137
|
-
defaultValue: "My Vuepress Site"
|
|
138
|
-
}),
|
|
139
|
-
siteDescription: () => text({
|
|
140
|
-
message: t("question.site.description")
|
|
141
|
-
}),
|
|
142
|
-
multiLanguage: () => confirm({
|
|
143
|
-
message: t("question.multiLanguage"),
|
|
144
|
-
initialValue: false
|
|
145
|
-
}),
|
|
146
|
-
defaultLanguage: () => select({
|
|
147
|
-
message: t("question.defaultLanguage"),
|
|
148
|
-
options: languageOptions
|
|
149
|
-
}),
|
|
150
|
-
useTs: async () => {
|
|
151
|
-
if (mode === 0 /* init */)
|
|
152
|
-
return hasTs;
|
|
153
|
-
if (hasTs)
|
|
154
|
-
return true;
|
|
155
|
-
return await confirm({
|
|
156
|
-
message: t("question.useTs"),
|
|
157
|
-
initialValue: true
|
|
158
|
-
});
|
|
159
|
-
},
|
|
160
|
-
injectNpmScripts: async () => {
|
|
161
|
-
if (mode === 1 /* create */)
|
|
162
|
-
return true;
|
|
163
|
-
return await confirm({
|
|
164
|
-
message: t("question.injectNpmScripts"),
|
|
165
|
-
initialValue: true
|
|
166
|
-
});
|
|
167
|
-
},
|
|
168
|
-
bundler: () => select({
|
|
169
|
-
message: t("question.bundler"),
|
|
170
|
-
options: bundlerOptions
|
|
171
|
-
}),
|
|
172
|
-
deploy: async () => {
|
|
173
|
-
if (mode === 0 /* init */) {
|
|
174
|
-
return "custom" /* custom */;
|
|
175
|
-
}
|
|
176
|
-
return await select({
|
|
177
|
-
message: t("question.deploy"),
|
|
178
|
-
options: deployOptions,
|
|
179
|
-
initialValue: "custom" /* custom */
|
|
180
|
-
});
|
|
181
|
-
},
|
|
182
|
-
git: async () => {
|
|
183
|
-
if (mode === 0 /* init */)
|
|
184
|
-
return false;
|
|
185
|
-
return confirm({
|
|
186
|
-
message: t("question.git"),
|
|
187
|
-
initialValue: true
|
|
188
|
-
});
|
|
189
|
-
},
|
|
190
|
-
install: () => confirm({
|
|
191
|
-
message: t("question.installDeps"),
|
|
192
|
-
initialValue: true
|
|
193
|
-
})
|
|
194
|
-
}, {
|
|
195
|
-
onCancel: () => {
|
|
196
|
-
cancel(t("hint.cancel"));
|
|
197
|
-
process.exit(0);
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
return result;
|
|
201
|
-
}
|
|
20
|
+
// src/run.ts
|
|
21
|
+
import path4 from "node:path";
|
|
22
|
+
import process4 from "node:process";
|
|
23
|
+
import { intro, outro, spinner } from "@clack/prompts";
|
|
24
|
+
import { execaCommand as execaCommand3 } from "execa";
|
|
25
|
+
import colors from "picocolors";
|
|
202
26
|
|
|
203
27
|
// src/generate.ts
|
|
204
|
-
import path3 from "node:path";
|
|
205
|
-
import process3 from "node:process";
|
|
206
28
|
import fs2 from "node:fs";
|
|
29
|
+
import path3 from "node:path";
|
|
30
|
+
import process2 from "node:process";
|
|
207
31
|
import { execaCommand as execaCommand2 } from "execa";
|
|
208
32
|
|
|
209
33
|
// src/packageJson.ts
|
|
210
|
-
import { execaCommand } from "execa";
|
|
211
34
|
import { kebabCase } from "@pengzhanbo/utils";
|
|
35
|
+
import { execaCommand } from "execa";
|
|
212
36
|
|
|
213
37
|
// src/utils/index.ts
|
|
214
|
-
import { fileURLToPath } from "node:url";
|
|
215
38
|
import path2 from "node:path";
|
|
39
|
+
import { fileURLToPath } from "node:url";
|
|
40
|
+
|
|
41
|
+
// src/utils/depsVersion.ts
|
|
42
|
+
var api = "https://api.pengzhanbo.cn/npm/dependencies/version";
|
|
43
|
+
async function getDependenciesVersion(dependencies, version = "latest") {
|
|
44
|
+
const result = await fetch(api, {
|
|
45
|
+
method: "POST",
|
|
46
|
+
headers: { "content-type": "application/json" },
|
|
47
|
+
body: JSON.stringify({ dependencies, version })
|
|
48
|
+
}).then((res) => res.json());
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
216
51
|
|
|
217
52
|
// src/utils/fs.ts
|
|
218
|
-
import path from "node:path";
|
|
219
53
|
import fs from "node:fs/promises";
|
|
54
|
+
import path from "node:path";
|
|
220
55
|
async function readFiles(root) {
|
|
221
56
|
const filepaths = await fs.readdir(root, { recursive: true });
|
|
222
57
|
const files = [];
|
|
@@ -249,21 +84,10 @@ async function readJsonFile(filepath) {
|
|
|
249
84
|
}
|
|
250
85
|
}
|
|
251
86
|
|
|
252
|
-
// src/utils/depsVersion.ts
|
|
253
|
-
var api = "https://api.pengzhanbo.cn/npm/dependencies/version";
|
|
254
|
-
async function getDependenciesVersion(dependencies, version = "latest") {
|
|
255
|
-
const result = await fetch(api, {
|
|
256
|
-
method: "POST",
|
|
257
|
-
headers: { "content-type": "application/json" },
|
|
258
|
-
body: JSON.stringify({ dependencies, version })
|
|
259
|
-
}).then((res) => res.json());
|
|
260
|
-
return result;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
87
|
// src/utils/getPackageManager.ts
|
|
264
|
-
import
|
|
88
|
+
import process from "node:process";
|
|
265
89
|
function getPackageManager() {
|
|
266
|
-
const name =
|
|
90
|
+
const name = process.env?.npm_config_user_agent || "npm";
|
|
267
91
|
return name.split("/")[0];
|
|
268
92
|
}
|
|
269
93
|
|
|
@@ -274,6 +98,7 @@ var getTemplate = (dir) => resolve("templates", dir);
|
|
|
274
98
|
|
|
275
99
|
// src/packageJson.ts
|
|
276
100
|
async function createPackageJson(mode, pkg, {
|
|
101
|
+
packageManager,
|
|
277
102
|
docsDir,
|
|
278
103
|
siteName,
|
|
279
104
|
siteDescription,
|
|
@@ -285,11 +110,18 @@ async function createPackageJson(mode, pkg, {
|
|
|
285
110
|
pkg.type = "module";
|
|
286
111
|
pkg.version = "1.0.0";
|
|
287
112
|
pkg.description = siteDescription;
|
|
113
|
+
if (packageManager !== "npm") {
|
|
114
|
+
const version = await getPackageManagerVersion(packageManager);
|
|
115
|
+
if (version) {
|
|
116
|
+
pkg.packageManager = `${packageManager}@${version}`;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
288
119
|
const userInfo = await getUserInfo();
|
|
289
120
|
if (userInfo) {
|
|
290
121
|
pkg.author = userInfo.username + (userInfo.email ? ` <${userInfo.email}>` : "");
|
|
291
122
|
}
|
|
292
123
|
pkg.license = "MIT";
|
|
124
|
+
pkg.engines = { node: "^18.20.0 || >=20.0.0" };
|
|
293
125
|
}
|
|
294
126
|
if (injectNpmScripts) {
|
|
295
127
|
pkg.scripts ??= {};
|
|
@@ -333,10 +165,18 @@ async function getUserInfo() {
|
|
|
333
165
|
return null;
|
|
334
166
|
}
|
|
335
167
|
}
|
|
168
|
+
async function getPackageManagerVersion(pkg) {
|
|
169
|
+
try {
|
|
170
|
+
const { stdout } = await execaCommand(`${pkg} -v`);
|
|
171
|
+
return stdout;
|
|
172
|
+
} catch {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
336
176
|
|
|
337
177
|
// src/render.ts
|
|
338
|
-
import handlebars from "handlebars";
|
|
339
178
|
import { kebabCase as kebabCase2 } from "@pengzhanbo/utils";
|
|
179
|
+
import handlebars from "handlebars";
|
|
340
180
|
handlebars.registerHelper("removeLeadingSlash", (path5) => path5.replace(/^\//, ""));
|
|
341
181
|
handlebars.registerHelper("equal", (a, b) => a === b);
|
|
342
182
|
function createRender(result) {
|
|
@@ -365,7 +205,7 @@ function createRender(result) {
|
|
|
365
205
|
|
|
366
206
|
// src/generate.ts
|
|
367
207
|
async function generate(mode, data) {
|
|
368
|
-
const cwd =
|
|
208
|
+
const cwd = process2.cwd();
|
|
369
209
|
let userPkg = {};
|
|
370
210
|
if (mode === 0 /* init */) {
|
|
371
211
|
const pkgPath = path3.join(cwd, "package.json");
|
|
@@ -469,6 +309,182 @@ function updateFileListTarget(fileList, target) {
|
|
|
469
309
|
}));
|
|
470
310
|
}
|
|
471
311
|
|
|
312
|
+
// src/prompt.ts
|
|
313
|
+
import { createRequire } from "node:module";
|
|
314
|
+
import process3 from "node:process";
|
|
315
|
+
import { cancel, confirm, group, select, text } from "@clack/prompts";
|
|
316
|
+
|
|
317
|
+
// src/locales/en.ts
|
|
318
|
+
var en = {
|
|
319
|
+
"question.root": "Where would you want to initialize VuePress?",
|
|
320
|
+
"question.site.name": "Site Name:",
|
|
321
|
+
"question.site.description": "Site Description:",
|
|
322
|
+
"question.bundler": "Select a bundler",
|
|
323
|
+
"question.multiLanguage": "Do you want to use multiple languages?",
|
|
324
|
+
"question.defaultLanguage": "Select the default language of the site",
|
|
325
|
+
"question.useTs": "Use TypeScript?",
|
|
326
|
+
"question.injectNpmScripts": "Inject npm scripts?",
|
|
327
|
+
"question.deploy": "Deploy type:",
|
|
328
|
+
"question.git": "Initialize a git repository?",
|
|
329
|
+
"question.installDeps": "Install dependencies?",
|
|
330
|
+
"spinner.start": "\u{1F680} Creating...",
|
|
331
|
+
"spinner.stop": "\u{1F389} Create success!",
|
|
332
|
+
"spinner.git": "\u{1F4C4} Initializing git repository...",
|
|
333
|
+
"spinner.install": "\u{1F4E6} Installing dependencies...",
|
|
334
|
+
"spinner.command": "\u{1F528} Execute the following command to start:",
|
|
335
|
+
"hint.cancel": "Operation cancelled.",
|
|
336
|
+
"hint.root": "The path cannot be an absolute path, and cannot contain the parent path.",
|
|
337
|
+
"hint.root.illegal": "Project names cannot contain special characters."
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
// src/locales/zh.ts
|
|
341
|
+
var zh = {
|
|
342
|
+
"question.root": "\u60A8\u60F3\u5728\u54EA\u91CC\u521D\u59CB\u5316 VuePress\uFF1F",
|
|
343
|
+
"question.site.name": "\u7AD9\u70B9\u540D\u79F0\uFF1A",
|
|
344
|
+
"question.site.description": "\u7AD9\u70B9\u63CF\u8FF0\u4FE1\u606F\uFF1A",
|
|
345
|
+
"question.bundler": "\u8BF7\u9009\u62E9\u6253\u5305\u5DE5\u5177",
|
|
346
|
+
"question.multiLanguage": "\u662F\u5426\u4F7F\u7528\u591A\u8BED\u8A00\uFF1F",
|
|
347
|
+
"question.defaultLanguage": "\u8BF7\u9009\u62E9\u7AD9\u70B9\u9ED8\u8BA4\u8BED\u8A00",
|
|
348
|
+
"question.useTs": "\u662F\u5426\u4F7F\u7528 TypeScript\uFF1F",
|
|
349
|
+
"question.injectNpmScripts": "\u662F\u5426\u6CE8\u5165 npm \u811A\u672C\uFF1F",
|
|
350
|
+
"question.deploy": "\u90E8\u7F72\u65B9\u5F0F\uFF1A",
|
|
351
|
+
"question.git": "\u662F\u5426\u521D\u59CB\u5316 git \u4ED3\u5E93\uFF1F",
|
|
352
|
+
"question.installDeps": "\u662F\u5426\u5B89\u88C5\u4F9D\u8D56\uFF1F",
|
|
353
|
+
"spinner.start": "\u{1F680} \u6B63\u5728\u521B\u5EFA...",
|
|
354
|
+
"spinner.stop": "\u{1F389} \u521B\u5EFA\u6210\u529F!",
|
|
355
|
+
"spinner.git": "\u{1F4C4} \u521D\u59CB\u5316 git \u4ED3\u5E93...",
|
|
356
|
+
"spinner.install": "\u{1F4E6} \u5B89\u88C5\u4F9D\u8D56...",
|
|
357
|
+
"spinner.command": "\u{1F528} \u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u5373\u53EF\u542F\u52A8\uFF1A",
|
|
358
|
+
"hint.cancel": "\u64CD\u4F5C\u5DF2\u53D6\u6D88\u3002",
|
|
359
|
+
"hint.root": "\u6587\u4EF6\u8DEF\u5F84\u4E0D\u80FD\u662F\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u5305\u542B\u7236\u8DEF\u5F84\u3002",
|
|
360
|
+
"hint.root.illegal": "\u6587\u4EF6\u5939\u4E0D\u80FD\u5305\u542B\u7279\u6B8A\u5B57\u7B26\u3002"
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
// src/locales/index.ts
|
|
364
|
+
var locales = {
|
|
365
|
+
"zh-CN": zh,
|
|
366
|
+
"en-US": en
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
// src/translate.ts
|
|
370
|
+
function createTranslate(lang) {
|
|
371
|
+
let current = lang || "en-US";
|
|
372
|
+
return {
|
|
373
|
+
setLang: (lang2) => {
|
|
374
|
+
current = lang2;
|
|
375
|
+
},
|
|
376
|
+
t: (key) => locales[current][key]
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
var { t, setLang } = createTranslate();
|
|
380
|
+
|
|
381
|
+
// src/prompt.ts
|
|
382
|
+
var require2 = createRequire(process3.cwd());
|
|
383
|
+
var REG_DIR_CHAR = /[<>:"\\|?*[\]]/;
|
|
384
|
+
async function prompt(mode, root) {
|
|
385
|
+
let hasTs = false;
|
|
386
|
+
if (mode === 0 /* init */) {
|
|
387
|
+
try {
|
|
388
|
+
hasTs = !!require2.resolve("typescript");
|
|
389
|
+
} catch {
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
const result = await group({
|
|
393
|
+
displayLang: async () => {
|
|
394
|
+
const lang = await select({
|
|
395
|
+
message: "Select a language to display / \u9009\u62E9\u663E\u793A\u8BED\u8A00",
|
|
396
|
+
options: languageOptions
|
|
397
|
+
});
|
|
398
|
+
if (typeof lang === "string")
|
|
399
|
+
setLang(lang);
|
|
400
|
+
return lang;
|
|
401
|
+
},
|
|
402
|
+
root: async () => {
|
|
403
|
+
if (root)
|
|
404
|
+
return root;
|
|
405
|
+
const DEFAULT_ROOT = mode === 0 /* init */ ? "./docs" : "./my-project";
|
|
406
|
+
return await text({
|
|
407
|
+
message: t("question.root"),
|
|
408
|
+
placeholder: DEFAULT_ROOT,
|
|
409
|
+
validate(value) {
|
|
410
|
+
if (value?.startsWith("/") || value?.startsWith(".."))
|
|
411
|
+
return t("hint.root");
|
|
412
|
+
if (value && REG_DIR_CHAR.test(value))
|
|
413
|
+
return t("hint.root.illegal");
|
|
414
|
+
return void 0;
|
|
415
|
+
},
|
|
416
|
+
defaultValue: DEFAULT_ROOT
|
|
417
|
+
});
|
|
418
|
+
},
|
|
419
|
+
siteName: () => text({
|
|
420
|
+
message: t("question.site.name"),
|
|
421
|
+
placeholder: "My Vuepress Site",
|
|
422
|
+
defaultValue: "My Vuepress Site"
|
|
423
|
+
}),
|
|
424
|
+
siteDescription: () => text({
|
|
425
|
+
message: t("question.site.description")
|
|
426
|
+
}),
|
|
427
|
+
multiLanguage: () => confirm({
|
|
428
|
+
message: t("question.multiLanguage"),
|
|
429
|
+
initialValue: false
|
|
430
|
+
}),
|
|
431
|
+
defaultLanguage: () => select({
|
|
432
|
+
message: t("question.defaultLanguage"),
|
|
433
|
+
options: languageOptions
|
|
434
|
+
}),
|
|
435
|
+
useTs: async () => {
|
|
436
|
+
if (mode === 0 /* init */)
|
|
437
|
+
return hasTs;
|
|
438
|
+
if (hasTs)
|
|
439
|
+
return true;
|
|
440
|
+
return await confirm({
|
|
441
|
+
message: t("question.useTs"),
|
|
442
|
+
initialValue: true
|
|
443
|
+
});
|
|
444
|
+
},
|
|
445
|
+
injectNpmScripts: async () => {
|
|
446
|
+
if (mode === 1 /* create */)
|
|
447
|
+
return true;
|
|
448
|
+
return await confirm({
|
|
449
|
+
message: t("question.injectNpmScripts"),
|
|
450
|
+
initialValue: true
|
|
451
|
+
});
|
|
452
|
+
},
|
|
453
|
+
bundler: () => select({
|
|
454
|
+
message: t("question.bundler"),
|
|
455
|
+
options: bundlerOptions
|
|
456
|
+
}),
|
|
457
|
+
deploy: async () => {
|
|
458
|
+
if (mode === 0 /* init */) {
|
|
459
|
+
return "custom" /* custom */;
|
|
460
|
+
}
|
|
461
|
+
return await select({
|
|
462
|
+
message: t("question.deploy"),
|
|
463
|
+
options: deployOptions,
|
|
464
|
+
initialValue: "custom" /* custom */
|
|
465
|
+
});
|
|
466
|
+
},
|
|
467
|
+
git: async () => {
|
|
468
|
+
if (mode === 0 /* init */)
|
|
469
|
+
return false;
|
|
470
|
+
return confirm({
|
|
471
|
+
message: t("question.git"),
|
|
472
|
+
initialValue: true
|
|
473
|
+
});
|
|
474
|
+
},
|
|
475
|
+
install: () => confirm({
|
|
476
|
+
message: t("question.installDeps"),
|
|
477
|
+
initialValue: true
|
|
478
|
+
})
|
|
479
|
+
}, {
|
|
480
|
+
onCancel: () => {
|
|
481
|
+
cancel(t("hint.cancel"));
|
|
482
|
+
process3.exit(0);
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
return result;
|
|
486
|
+
}
|
|
487
|
+
|
|
472
488
|
// src/run.ts
|
|
473
489
|
async function run(mode, root) {
|
|
474
490
|
intro(colors.cyan("Welcome to VuePress and vuepress-theme-plume !"));
|
|
@@ -511,5 +527,5 @@ var cli = cac("create-vuepress-theme-plume");
|
|
|
511
527
|
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));
|
|
512
528
|
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));
|
|
513
529
|
cli.help();
|
|
514
|
-
cli.version("1.0.0-rc.
|
|
530
|
+
cli.version("1.0.0-rc.97");
|
|
515
531
|
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.98",
|
|
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",
|
|
@@ -35,6 +35,13 @@ jobs:
|
|
|
35
35
|
# 选择要使用的 node 版本
|
|
36
36
|
node-version: 20
|
|
37
37
|
|
|
38
|
+
{{#if (equal packageManager "npm")}}
|
|
39
|
+
# 安装依赖
|
|
40
|
+
# Install dependencies
|
|
41
|
+
- name: Install Dependencies
|
|
42
|
+
run: npm ci
|
|
43
|
+
{{/if}}
|
|
44
|
+
|
|
38
45
|
{{#if (equal packageManager "yarn")}}
|
|
39
46
|
- name: Run install
|
|
40
47
|
uses: borales/actions-yarn@v4
|