create-pressplus 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Josef-qiao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # VitePress Custom Theme Template
2
+
3
+ 一个基于 **VitePress** 的现代化文档模板,默认启用 **自定义主题**,并集成常用的前端工程化工具,适合用于:
4
+
5
+ - 技术文档
6
+ - 博客 / 笔记站点
7
+ - 组件说明站
8
+ - 长期维护的知识库
9
+
10
+ 该模板以 **可维护性、可扩展性** 为核心设计目标。
11
+
12
+ ---
13
+
14
+ ## ✨ 特性一览
15
+
16
+ - ⚡️ 基于 **VitePress**
17
+ - 🎨 **完全自定义主题**(不依赖 DefaultTheme 布局)
18
+ - 🌬 **Tailwind CSS v4**(Vite 插件模式)
19
+ - 🧹 **ESLint**(代码规范)
20
+ - ✨ **Prettier**(统一格式化)
21
+ - 🧩 支持在 **Markdown / Theme / Vue 组件** 中无感使用
22
+ - 📦 适合二次开发与长期演进
23
+
24
+ ---
25
+
26
+ ## 📦 技术栈
27
+
28
+ | 技术 | 说明 |
29
+ | --------------- | ------------ |
30
+ | VitePress | 文档生成框架 |
31
+ | Vue 3 | 组件系统 |
32
+ | Tailwind CSS v4 | 原子化 CSS |
33
+ | ESLint | 代码规范 |
34
+ | Prettier | 格式化工具 |
35
+
36
+ ---
37
+
38
+ ## 📂 项目结构
39
+
40
+ ```txt
41
+ docs/
42
+ ├─ .vitepress/
43
+ │ ├─ config.ts # VitePress 配置
44
+ │ └─ theme/
45
+ │ ├─ index.ts # 自定义主题入口
46
+ │ ├─ Layout.vue # 全局布局
47
+ │ ├─ tailwind.css # Tailwind CSS v4 入口
48
+ │ └─ components/ # 主题级组件
49
+
50
+ ├─ index.md # 首页
51
+ └─ README.md
52
+ ```
53
+
54
+ ## 🚀 使用方式
55
+
56
+ ```txt
57
+ npx create-pressplus
58
+ ```
package/index.mjs ADDED
@@ -0,0 +1,201 @@
1
+ #!/usr/bin/env node
2
+ import fsExtra from "fs-extra";
3
+ import { join, resolve } from "path";
4
+ import { fileURLToPath } from "url";
5
+ import { spawn } from "child_process";
6
+ import ora from "ora";
7
+ import chalk from "chalk";
8
+ import enquirerPkg from "enquirer";
9
+ import gradient from "gradient-string";
10
+
11
+ const { prompt } = enquirerPkg
12
+ const { copy, readJSON, writeJSON, remove } = fsExtra;
13
+
14
+ const __dirname = fileURLToPath(new URL(".", import.meta.url));
15
+
16
+ // 打印欢迎信息
17
+ function printWelcome() {
18
+ console.log();
19
+ console.log(gradient.morning("✨ 欢迎使用 PressPlus 脚手架 ✨"));
20
+ console.log();
21
+ }
22
+
23
+ // 验证项目名称
24
+ function isValidPackageName(projectName) {
25
+ return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(
26
+ projectName
27
+ );
28
+ }
29
+
30
+ // 格式化项目名称
31
+ function toValidPackageName(projectName) {
32
+ return projectName
33
+ .trim()
34
+ .toLowerCase()
35
+ .replace(/\s+/g, "-")
36
+ .replace(/^[._]/, "")
37
+ .replace(/[^a-z0-9-~]+/g, "-");
38
+ }
39
+
40
+ // 将包名转换为目录名
41
+ function packageNameToDirName(packageName) {
42
+ if (packageName.includes("/")) {
43
+ return packageName.split("/")[1];
44
+ }
45
+ return packageName;
46
+ }
47
+
48
+ // 交互式提问
49
+ async function askForOptions(targetDir) {
50
+ const options = await prompt([
51
+ {
52
+ type: "input",
53
+ name: "packageName",
54
+ message: "请输入项目名称",
55
+ initial: toValidPackageName(targetDir),
56
+ validate: (name) =>
57
+ isValidPackageName(name) || "项目名称不符合 npm 包命名规则",
58
+ },
59
+ {
60
+ type: "confirm",
61
+ name: "installDeps",
62
+ message: "是否立即安装依赖?",
63
+ initial: true,
64
+ },
65
+ ]);
66
+
67
+ return options;
68
+ }
69
+
70
+ // 拷贝模板
71
+ async function copyTemplate(src, dest) {
72
+ const spinner = ora(`正在创建项目...`).start();
73
+ try {
74
+ await copy(src, dest);
75
+ spinner.succeed("项目创建成功");
76
+ } catch (err) {
77
+ spinner.fail("项目创建失败");
78
+ throw err;
79
+ }
80
+ }
81
+
82
+
83
+ // 更新 package.json
84
+ async function updatePackageJson(destDir, projectName) {
85
+ const packageJsonPath = join(destDir, "package.json");
86
+ const packageJson = await readJSON(packageJsonPath);
87
+ packageJson.name = projectName;
88
+ await writeJSON(packageJsonPath, packageJson, { spaces: 2 });
89
+ }
90
+
91
+ // 安装依赖
92
+ async function installDependencies(destDir) {
93
+ const spinner = ora("正在安装依赖...").start();
94
+
95
+ try {
96
+ await new Promise((resolve, reject) => {
97
+ const installer = spawn("npm", ["install"], {
98
+ cwd: destDir,
99
+ stdio: "ignore",
100
+ shell: true,
101
+ });
102
+
103
+ installer.on("close", (code) => {
104
+ if (code === 0) resolve();
105
+ else reject(new Error(`npm install 失败,退出码 ${code}`));
106
+ });
107
+ });
108
+ spinner.succeed("依赖安装完成");
109
+ } catch (err) {
110
+ spinner.fail(`依赖安装失败: ${err.message}`);
111
+ throw err;
112
+ }
113
+ }
114
+
115
+ // 打印完成信息
116
+ function printCompletion(targetDir, installDeps) {
117
+ console.log();
118
+ console.log(chalk.bold("🎉 项目创建完成!"));
119
+ console.log();
120
+
121
+ console.log(chalk.bold("接下来可以执行以下命令:"));
122
+ console.log();
123
+ console.log(chalk.dim(` # 进入项目目录`));
124
+ console.log(` cd ${chalk.cyan(targetDir)}`);
125
+
126
+ if (!installDeps) {
127
+ console.log(chalk.dim(` # 安装依赖`));
128
+ console.log(` npm install`);
129
+ }
130
+
131
+ console.log(chalk.dim(` # 启动开发服务器`));
132
+ console.log(` npm run dev`);
133
+ console.log();
134
+ console.log(chalk.dim(` # 构建生产版本`));
135
+ console.log(` npm run build`);
136
+ console.log();
137
+ }
138
+
139
+ // 主函数
140
+ async function main() {
141
+ printWelcome();
142
+
143
+ // 获取初始目标目录
144
+ const initialTargetDir = process.argv[2];
145
+
146
+ if (!initialTargetDir) {
147
+ console.error(
148
+ chalk.red("❌ 必须指定项目名称,例如:") +
149
+ chalk.cyan("npx create-pressplus my-project")
150
+ );
151
+ process.exit(1);
152
+ }
153
+
154
+ let destDir = null;
155
+ let finalDirName = null;
156
+
157
+ try {
158
+ // 先获取用户选项
159
+ const options = await askForOptions(initialTargetDir);
160
+
161
+ // 基于用户输入的项目名称确定最终目录名
162
+ finalDirName = packageNameToDirName(options.packageName);
163
+ destDir = resolve(process.cwd(), finalDirName);
164
+
165
+ // 检查目录是否已存在
166
+ if (fsExtra.existsSync(destDir)) {
167
+ console.error(chalk.red(`❌ 目录 "${finalDirName}" 已存在!`));
168
+ process.exit(1);
169
+ }
170
+
171
+ // 拷贝模板
172
+ await copyTemplate(join(__dirname, "template"), destDir);
173
+
174
+ // 更新 package.json
175
+ await updatePackageJson(destDir, options.packageName);
176
+
177
+ // 安装依赖
178
+ if (options.installDeps) {
179
+ await installDependencies(destDir);
180
+ }
181
+
182
+ // 打印完成信息
183
+ printCompletion(finalDirName, options.installDeps);
184
+ } catch (err) {
185
+ console.error(chalk.red("❌ 创建项目失败:"), err.message);
186
+
187
+ // 清理已创建的文件
188
+ if (destDir && fsExtra.existsSync(destDir)) {
189
+ const spinner = ora("清理已创建的文件...").start();
190
+ await remove(destDir);
191
+ spinner.succeed("清理完成");
192
+ }
193
+
194
+ process.exit(1);
195
+ }
196
+ }
197
+
198
+ main().catch((err) => {
199
+ console.error(chalk.red("❌ 发生未预期的错误:"), err);
200
+ process.exit(1);
201
+ });
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "create-pressplus",
3
+ "version": "1.0.0",
4
+ "description": "一个基于 VitePress 的现代化文档模板",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "create-vueplus": "./index.mjs"
8
+ },
9
+ "files": [
10
+ "index.mjs",
11
+ "template"
12
+ ],
13
+ "scripts": {
14
+ "test": "echo \"Error: no test specified\" && exit 1"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/359Steve/create-vitepress.git"
19
+ },
20
+ "keywords": [
21
+ "vue",
22
+ "vite",
23
+ "press",
24
+ "markdown",
25
+ "pressplus"
26
+ ],
27
+ "author": "josefqiao",
28
+ "license": "MIT",
29
+ "dependencies": {
30
+ "chalk": "^5.5.0",
31
+ "enquirer": "^2.4.1",
32
+ "fs-extra": "^11.3.0",
33
+ "gradient-string": "^3.0.0",
34
+ "ora": "^8.2.0"
35
+ }
36
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Josef-qiao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,58 @@
1
+ # VitePress Custom Theme Template
2
+
3
+ 一个基于 **VitePress** 的现代化文档模板,默认启用 **自定义主题**,并集成常用的前端工程化工具,适合用于:
4
+
5
+ - 技术文档
6
+ - 博客 / 笔记站点
7
+ - 组件说明站
8
+ - 长期维护的知识库
9
+
10
+ 该模板以 **可维护性、可扩展性** 为核心设计目标。
11
+
12
+ ---
13
+
14
+ ## ✨ 特性一览
15
+
16
+ - ⚡️ 基于 **VitePress**
17
+ - 🎨 **完全自定义主题**(不依赖 DefaultTheme 布局)
18
+ - 🌬 **Tailwind CSS v4**(Vite 插件模式)
19
+ - 🧹 **ESLint**(代码规范)
20
+ - ✨ **Prettier**(统一格式化)
21
+ - 🧩 支持在 **Markdown / Theme / Vue 组件** 中无感使用
22
+ - 📦 适合二次开发与长期演进
23
+
24
+ ---
25
+
26
+ ## 📦 技术栈
27
+
28
+ | 技术 | 说明 |
29
+ | --------------- | ------------ |
30
+ | VitePress | 文档生成框架 |
31
+ | Vue 3 | 组件系统 |
32
+ | Tailwind CSS v4 | 原子化 CSS |
33
+ | ESLint | 代码规范 |
34
+ | Prettier | 格式化工具 |
35
+
36
+ ---
37
+
38
+ ## 📂 项目结构
39
+
40
+ ```txt
41
+ docs/
42
+ ├─ .vitepress/
43
+ │ ├─ config.ts # VitePress 配置
44
+ │ └─ theme/
45
+ │ ├─ index.ts # 自定义主题入口
46
+ │ ├─ Layout.vue # 全局布局
47
+ │ ├─ tailwind.css # Tailwind CSS v4 入口
48
+ │ └─ components/ # 主题级组件
49
+
50
+ ├─ index.md # 首页
51
+ └─ README.md
52
+ ```
53
+
54
+ ## 🚀 使用方式
55
+
56
+ ```txt
57
+ npx create-pressplus
58
+ ```
@@ -0,0 +1,31 @@
1
+ {
2
+ "hash": "ada4f81b",
3
+ "configHash": "bde764a9",
4
+ "lockfileHash": "baacf20b",
5
+ "browserHash": "1a9d3965",
6
+ "optimized": {
7
+ "vue": {
8
+ "src": "../../../../node_modules/vue/dist/vue.runtime.esm-bundler.js",
9
+ "file": "vue.js",
10
+ "fileHash": "4a3f86cb",
11
+ "needsInterop": false
12
+ },
13
+ "vitepress > @vue/devtools-api": {
14
+ "src": "../../../../node_modules/@vue/devtools-api/dist/index.js",
15
+ "file": "vitepress___@vue_devtools-api.js",
16
+ "fileHash": "a9540d98",
17
+ "needsInterop": false
18
+ },
19
+ "vitepress > @vueuse/core": {
20
+ "src": "../../../../node_modules/@vueuse/core/index.mjs",
21
+ "file": "vitepress___@vueuse_core.js",
22
+ "fileHash": "4fccfa93",
23
+ "needsInterop": false
24
+ }
25
+ },
26
+ "chunks": {
27
+ "chunk-XKDLJUKD": {
28
+ "file": "chunk-XKDLJUKD.js"
29
+ }
30
+ }
31
+ }