@doyuli/create-vue 0.1.1 → 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/LICENSE +20 -20
- package/README.md +9 -9
- package/bin/index.js +2 -2
- package/dist/{index.js → index.mjs} +16 -5
- package/package.json +2 -2
- package/template/base/package.json +0 -2
- package/template/base/src/layouts/DefaultLayout.vue +11 -11
- 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 +21 -21
- package/template/git-hooks/scripts/verify-commit.js +41 -29
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 doyuli
|
|
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
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 doyuli
|
|
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
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
### Usage
|
|
2
|
-
|
|
3
|
-
```bash
|
|
4
|
-
npx @doyuli/create-vue
|
|
5
|
-
|
|
6
|
-
# or
|
|
7
|
-
|
|
8
|
-
npm create @doyuli/vue
|
|
9
|
-
```
|
|
1
|
+
### Usage
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
npx @doyuli/create-vue
|
|
5
|
+
|
|
6
|
+
# or
|
|
7
|
+
|
|
8
|
+
npm create @doyuli/vue
|
|
9
|
+
```
|
package/bin/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import '../dist/index.
|
|
1
|
+
#!/usr/bin/env node
|
|
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,20 +63,20 @@ 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");
|
|
59
70
|
const templateRoot = fileURLToPath(new URL("../template", import.meta.url));
|
|
60
71
|
const render = (templateName) => {
|
|
61
|
-
|
|
62
|
-
renderTemplate(templateDir, root);
|
|
72
|
+
renderTemplate(path.resolve(templateRoot, templateName), root);
|
|
63
73
|
};
|
|
64
74
|
render("base");
|
|
65
75
|
render("eslint");
|
|
66
76
|
render("tsconfig");
|
|
67
77
|
render(needsAutoRouter ? "router/unplugin" : "router/default");
|
|
68
78
|
if (needsGitHooks) render("git-hooks");
|
|
79
|
+
render(cssFramework === "tailwindcss" ? "css/tailwindcss" : "css/unocss");
|
|
69
80
|
const rootTsConfig = {
|
|
70
81
|
files: [],
|
|
71
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.
|
|
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.
|
|
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",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
<script setup lang="ts"></script>
|
|
2
|
-
|
|
3
|
-
<template>
|
|
4
|
-
<div>
|
|
5
|
-
<main>
|
|
6
|
-
<slot />
|
|
7
|
-
</main>
|
|
8
|
-
</div>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<style scoped></style>
|
|
1
|
+
<script setup lang="ts"></script>
|
|
2
|
+
|
|
3
|
+
<template>
|
|
4
|
+
<div>
|
|
5
|
+
<main>
|
|
6
|
+
<slot />
|
|
7
|
+
</main>
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<style scoped></style>
|
|
@@ -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";
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineConfig,
|
|
3
|
-
presetAttributify,
|
|
4
|
-
presetIcons,
|
|
5
|
-
presetUno,
|
|
6
|
-
} from 'unocss'
|
|
7
|
-
|
|
8
|
-
export default defineConfig({
|
|
9
|
-
presets: [
|
|
10
|
-
presetUno(),
|
|
11
|
-
presetAttributify(),
|
|
12
|
-
presetIcons({
|
|
13
|
-
scale: 1.2,
|
|
14
|
-
warn: true,
|
|
15
|
-
extraProperties: {
|
|
16
|
-
'display': 'inline-block',
|
|
17
|
-
'vertical-align': 'middle',
|
|
18
|
-
},
|
|
19
|
-
}),
|
|
20
|
-
],
|
|
21
|
-
})
|
|
1
|
+
import {
|
|
2
|
+
defineConfig,
|
|
3
|
+
presetAttributify,
|
|
4
|
+
presetIcons,
|
|
5
|
+
presetUno,
|
|
6
|
+
} from 'unocss'
|
|
7
|
+
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
presets: [
|
|
10
|
+
presetUno(),
|
|
11
|
+
presetAttributify(),
|
|
12
|
+
presetIcons({
|
|
13
|
+
scale: 1.2,
|
|
14
|
+
warn: true,
|
|
15
|
+
extraProperties: {
|
|
16
|
+
'display': 'inline-block',
|
|
17
|
+
'vertical-align': 'middle',
|
|
18
|
+
},
|
|
19
|
+
}),
|
|
20
|
+
],
|
|
21
|
+
})
|
|
@@ -1,29 +1,41 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { readFileSync } from 'node:fs'
|
|
4
|
-
import path from 'node:path'
|
|
5
|
-
import process from 'node:process'
|
|
6
|
-
import pico from 'picocolors'
|
|
7
|
-
|
|
8
|
-
const msgPath = path.resolve('.git/COMMIT_EDITMSG')
|
|
9
|
-
const msg = readFileSync(msgPath, 'utf-8').trim()
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line regexp/no-unused-capturing-group
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
if (!
|
|
15
|
-
console.log()
|
|
16
|
-
console.error(
|
|
17
|
-
` ${pico.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)}
|
|
25
|
-
|
|
26
|
-
)}
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
}
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from 'node:fs'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import process from 'node:process'
|
|
6
|
+
import pico from 'picocolors'
|
|
7
|
+
|
|
8
|
+
const msgPath = path.resolve('.git/COMMIT_EDITMSG')
|
|
9
|
+
const msg = readFileSync(msgPath, 'utf-8').trim()
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line regexp/no-unused-capturing-group
|
|
12
|
+
const COMMIT_RE = /^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/
|
|
13
|
+
|
|
14
|
+
if (!COMMIT_RE.test(msg)) {
|
|
15
|
+
console.log()
|
|
16
|
+
console.error(
|
|
17
|
+
` ${pico.bgRed(pico.white(' ERROR '))} ${pico.red(`Invalid commit message format.`)}\n\n`
|
|
18
|
+
+ ` ${pico.dim('Help us keep a meaningful git history by following')}\n\n`
|
|
19
|
+
|
|
20
|
+
+ ` ${pico.yellow('Standard Format:')}\n`
|
|
21
|
+
+ ` ${pico.green('<type>[optional scope]: <description>')}\n\n`
|
|
22
|
+
|
|
23
|
+
+ ` ${pico.cyan('Common Types:')}\n`
|
|
24
|
+
+ ` ${pico.green(' feat')} ${pico.dim('A new feature')}\n`
|
|
25
|
+
+ ` ${pico.green(' fix')} ${pico.dim('A bug fix')}\n`
|
|
26
|
+
+ ` ${pico.green(' docs')} ${pico.dim('Documentation only changes')}\n`
|
|
27
|
+
+ ` ${pico.green(' style')} ${pico.dim('Changes that do not affect the meaning of the code')}\n`
|
|
28
|
+
+ ` ${pico.green(' refactor')} ${pico.dim('Code change that neither fixes a bug nor adds a feature')}\n`
|
|
29
|
+
+ ` ${pico.green(' perf')} ${pico.dim('A code change that improves performance')}\n`
|
|
30
|
+
+ ` ${pico.green(' test')} ${pico.dim('Adding missing tests or correcting existing tests')}\n`
|
|
31
|
+
+ ` ${pico.green(' build')} ${pico.dim('Changes that affect the build system or external dependencies')}\n`
|
|
32
|
+
+ ` ${pico.green(' ci')} ${pico.dim('Changes to CI configuration files and scripts')}\n`
|
|
33
|
+
+ ` ${pico.green(' chore')} ${pico.dim('Other changes that don\'t modify src or test files')}\n`
|
|
34
|
+
+ ` ${pico.green(' revert')} ${pico.dim('Reverts a previous commit')}\n\n`
|
|
35
|
+
|
|
36
|
+
+ ` ${pico.cyan('Correct Examples:')}\n`
|
|
37
|
+
+ ` ${pico.white(' feat(ui): add secondary button style')}\n`
|
|
38
|
+
+ ` ${pico.white(' fix(auth): resolve token expiration issue')}\n\n`,
|
|
39
|
+
)
|
|
40
|
+
process.exit(1)
|
|
41
|
+
}
|