@doyuli/create-vue 0.1.2 → 0.2.1
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/bin/index.js +1 -1
- package/dist/{index.js → index.mjs} +15 -3
- package/package.json +2 -2
- package/template/base/package.json +0 -2
- package/template/base/src/{main.ts → main.ts.ejs} +4 -0
- package/template/base/src/pages/about/index.vue.ejs +1 -1
- package/template/base/src/pages/home/index.vue.ejs +1 -1
- package/template/base/vite.config.ts.ejs +8 -0
- package/template/css/tailwindcss/package.json +6 -0
- package/template/css/tailwindcss/src/assets/main.css +1 -0
- package/template/css/unocss/package.json +8 -0
- /package/template/{base → css/unocss}/unocss.config.ts +0 -0
package/bin/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import '../dist/index.
|
|
2
|
+
import '../dist/index.mjs'
|
|
@@ -4,7 +4,7 @@ import process from "node:process";
|
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { parseArgs } from "node:util";
|
|
6
6
|
import { intro, outro } from "@clack/prompts";
|
|
7
|
-
import { getCommand, getPackageManager, preOrderDirectoryTraverse, renderFile, renderTemplate, setupProject, setupPrompts } from "@doyuli/kits-core";
|
|
7
|
+
import { getCommand, getPackageManager, preOrderDirectoryTraverse, renderFile, renderTemplate, setupFeatures, setupProject, setupPrompts, setupSelect } from "@doyuli/kits-core";
|
|
8
8
|
import ejs from "ejs";
|
|
9
9
|
import pico from "picocolors";
|
|
10
10
|
|
|
@@ -24,6 +24,13 @@ const FEATURE_OPTIONS = [
|
|
|
24
24
|
label: "Vitest(单元测试)"
|
|
25
25
|
}
|
|
26
26
|
];
|
|
27
|
+
const CSS_FRAMEWORK_OPTIONS = [{
|
|
28
|
+
value: "unocss",
|
|
29
|
+
label: "UnoCSS"
|
|
30
|
+
}, {
|
|
31
|
+
value: "tailwindcss",
|
|
32
|
+
label: "TailwindCSS"
|
|
33
|
+
}];
|
|
27
34
|
|
|
28
35
|
//#endregion
|
|
29
36
|
//#region src/index.ts
|
|
@@ -34,7 +41,11 @@ const FEATURE_OPTIONS = [
|
|
|
34
41
|
allowPositionals: true
|
|
35
42
|
});
|
|
36
43
|
intro(pico.magenta(DEFAULT_BANNER));
|
|
37
|
-
const
|
|
44
|
+
const inputTargetDir = positionals[0];
|
|
45
|
+
const { result, targetDir } = await setupPrompts(inputTargetDir, [setupFeatures("features", { options: [...FEATURE_OPTIONS] }), setupSelect("cssFramework", {
|
|
46
|
+
message: "请选择 CSS 框架:",
|
|
47
|
+
options: [...CSS_FRAMEWORK_OPTIONS]
|
|
48
|
+
})]);
|
|
38
49
|
const root = await setupProject(cwd, result, targetDir);
|
|
39
50
|
renderTemplates(root, result);
|
|
40
51
|
outro(getOutroMessage(root, cwd));
|
|
@@ -52,7 +63,7 @@ function getOutroMessage(root, cwd) {
|
|
|
52
63
|
return message;
|
|
53
64
|
}
|
|
54
65
|
function renderTemplates(root, result) {
|
|
55
|
-
const { features
|
|
66
|
+
const { features, cssFramework } = result;
|
|
56
67
|
const needsAutoRouter = features.includes("unplugin-vue-router");
|
|
57
68
|
const needsGitHooks = features.includes("simple-git-hooks");
|
|
58
69
|
const needsVitest = features.includes("vitest");
|
|
@@ -65,6 +76,7 @@ function renderTemplates(root, result) {
|
|
|
65
76
|
render("tsconfig");
|
|
66
77
|
render(needsAutoRouter ? "router/unplugin" : "router/default");
|
|
67
78
|
if (needsGitHooks) render("git-hooks");
|
|
79
|
+
render(cssFramework === "tailwindcss" ? "css/tailwindcss" : "css/unocss");
|
|
68
80
|
const rootTsConfig = {
|
|
69
81
|
files: [],
|
|
70
82
|
references: [{ path: "./tsconfig.node.json" }, { path: "./tsconfig.app.json" }]
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doyuli/create-vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"description": "@doyuli/create-vue",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@clack/prompts": "^0.11.0",
|
|
35
35
|
"ejs": "3.1.10",
|
|
36
36
|
"picocolors": "^1.1.1",
|
|
37
|
-
"@doyuli/kits-core": "^0.1
|
|
37
|
+
"@doyuli/kits-core": "^0.2.1"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"dev": "tsdown --watch",
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"type-check": "vue-tsc --build"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@unocss/reset": "^66.5.1",
|
|
15
14
|
"@vueuse/core": "^13.9.0",
|
|
16
15
|
"pinia": "^3.0.3",
|
|
17
16
|
"vue": "^3.5.18"
|
|
@@ -23,7 +22,6 @@
|
|
|
23
22
|
"@vue/tsconfig": "^0.7.0",
|
|
24
23
|
"prettier": "3.6.2",
|
|
25
24
|
"typescript": "~5.8.0",
|
|
26
|
-
"unocss": "^66.5.1",
|
|
27
25
|
"unplugin-auto-import": "^20.1.0",
|
|
28
26
|
"vite": "^7.0.6",
|
|
29
27
|
"vite-plugin-vue-devtools": "^8.0.0",
|
|
@@ -3,8 +3,12 @@ import { createApp } from 'vue'
|
|
|
3
3
|
import App from './App.vue'
|
|
4
4
|
|
|
5
5
|
import router from './router'
|
|
6
|
+
<%_ if (cssFramework === 'unocss') { -%>
|
|
6
7
|
import 'virtual:uno.css'
|
|
7
8
|
import '@unocss/reset/tailwind-compat.css'
|
|
9
|
+
<%_ } else { -%>
|
|
10
|
+
import './assets/main.css'
|
|
11
|
+
<%_ } -%>
|
|
8
12
|
|
|
9
13
|
const app = createApp(App)
|
|
10
14
|
|
|
@@ -17,7 +17,7 @@ definePage({
|
|
|
17
17
|
<div class="max-w-2xl w-full space-y-6">
|
|
18
18
|
<p class="text-gray-700 leading-relaxed">
|
|
19
19
|
这是一个自用 Vue 3 开发模板,旨在快速搭建项目。
|
|
20
|
-
集成了 <span class="font-semibold">Vite、Vue Router、Pinia、UnoCSS、VueUse</span>。
|
|
20
|
+
集成了 <span class="font-semibold">Vite、Vue Router、Pinia、UnoCSS/TailwindCSS、VueUse</span>。
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
23
|
<div class="bg-white p-6 rounded-xl shadow space-y-3">
|
|
@@ -16,7 +16,7 @@ definePage({
|
|
|
16
16
|
<div class="text-center space-y-4">
|
|
17
17
|
<SiteTitle title="Vue Template" />
|
|
18
18
|
<p class="text-gray-600 max-w-lg mx-auto">
|
|
19
|
-
自用 Vue 3 开发模板,集成 Vite、Pinia、Vue Router、UnoCSS 等常用工具。
|
|
19
|
+
自用 Vue 3 开发模板,集成 Vite、Pinia、Vue Router、UnoCSS/TailwindCSS 等常用工具。
|
|
20
20
|
</p>
|
|
21
21
|
<div class="flex flex-wrap gap-4 justify-center mt-4">
|
|
22
22
|
<router-link
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { fileURLToPath, URL } from 'node:url'
|
|
2
2
|
|
|
3
3
|
import vue from '@vitejs/plugin-vue'
|
|
4
|
+
<%_ if (cssFramework === 'unocss') { -%>
|
|
4
5
|
import UnoCSS from 'unocss/vite'
|
|
6
|
+
<%_ } else { -%>
|
|
7
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
8
|
+
<%_ } -%>
|
|
5
9
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
6
10
|
<%_ if (features.includes('unplugin-vue-router')) { -%>
|
|
7
11
|
import { VueRouterAutoImports } from 'unplugin-vue-router'
|
|
@@ -31,7 +35,11 @@ export default defineConfig({
|
|
|
31
35
|
],
|
|
32
36
|
dts: 'types/auto-imports.d.ts',
|
|
33
37
|
}),
|
|
38
|
+
<%_ if (cssFramework === 'unocss') { -%>
|
|
34
39
|
UnoCSS(),
|
|
40
|
+
<%_ } else { -%>
|
|
41
|
+
tailwindcss(),
|
|
42
|
+
<%_ } -%>
|
|
35
43
|
vueDevTools(),
|
|
36
44
|
],
|
|
37
45
|
resolve: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
File without changes
|