create-banana 1.0.1 → 1.1.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/.prettierrc +10 -3
- package/.vscode/settings.json +10 -0
- package/bin/index.js +110 -35
- package/eslint.config.js +59 -0
- package/package.json +6 -2
- package/readme.md +6 -1
- package/template/Eslint/eslint.config.js.ejs +70 -31
- package/template/Eslint/package.json +1 -2
- package/template/Prettier/.prettierrc +1 -1
- package/template/Prettier/package.json +2 -2
- package/template/base/src/App.vue.ejs +119 -48
- package/template/base/src/components/HelloWorld.vue +1 -1
- package/template/base/src/components/TheWelcome.vue +61 -26
- package/template/base/src/components/icons/IconCommunity.vue +6 -1
- package/template/base/src/components/icons/IconDocumentation.vue +6 -1
- package/template/base/src/components/icons/IconEcosystem.vue +6 -1
- package/template/base/src/components/icons/IconSupport.vue +6 -1
- package/template/base/src/main.js.ejs +12 -1
- package/template/base/vite.config.js +5 -5
- package/template/pinia/counter.js +7 -7
- package/template/pinia/pinia-plugin-persistedstate/key.js +6 -6
- package/template/vue-router/components/TitleText.vue +13 -0
- package/template/vue-router/package.json +5 -0
- package/template/vue-router/router/index.js +32 -0
- package/template/vue-router/views/AboutView.vue.ejs +21 -0
- package/template/vue-router/views/HomeView.vue +7 -0
- package/template/vue-router/views/NotFound.vue +7 -0
- package/utils/URL.js +9 -7
- package/utils/figletPrint.js +6 -6
- package/utils/pathExists.js +13 -11
- package/utils/rainbow.js +17 -12
- package/utils/template/base/appVue.js +25 -13
- package/utils/template/base/base.js +12 -12
- package/utils/template/base/main.js +25 -13
- package/utils/template/eslint/eslint.js +16 -19
- package/utils/template/eslint/eslintConfig.js +14 -11
- package/utils/template/pinia/pinia.js +20 -12
- package/utils/template/pinia/piniaPluginPersistedstate.js +24 -13
- package/utils/template/prettier.js +19 -20
- package/utils/template/vueRouter/aboutView.js +29 -0
- package/utils/template/vueRouter/vueRouter.js +46 -0
- package/eslint.config.mjs +0 -27
- package/template/Eslint/.eslintignore +0 -36
- package/template/Prettier/.prettierignore +0 -7
- package/template/base/.vscode/extensions.json +0 -3
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import WelcomeItem from './WelcomeItem.vue'
|
|
3
|
-
import DocumentationIcon from './icons/IconDocumentation.vue'
|
|
4
|
-
import ToolingIcon from './icons/IconTooling.vue'
|
|
5
|
-
import EcosystemIcon from './icons/IconEcosystem.vue'
|
|
6
|
-
import CommunityIcon from './icons/IconCommunity.vue'
|
|
7
|
-
import SupportIcon from './icons/IconSupport.vue'
|
|
2
|
+
import WelcomeItem from './WelcomeItem.vue';
|
|
3
|
+
import DocumentationIcon from './icons/IconDocumentation.vue';
|
|
4
|
+
import ToolingIcon from './icons/IconTooling.vue';
|
|
5
|
+
import EcosystemIcon from './icons/IconEcosystem.vue';
|
|
6
|
+
import CommunityIcon from './icons/IconCommunity.vue';
|
|
7
|
+
import SupportIcon from './icons/IconSupport.vue';
|
|
8
8
|
|
|
9
|
-
const openReadmeInEditor = () => fetch('/__open-in-editor?file=README.md')
|
|
9
|
+
const openReadmeInEditor = () => fetch('/__open-in-editor?file=README.md');
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
12
|
<template>
|
|
@@ -17,7 +17,9 @@ const openReadmeInEditor = () => fetch('/__open-in-editor?file=README.md')
|
|
|
17
17
|
<template #heading>Documentation</template>
|
|
18
18
|
|
|
19
19
|
Vue’s
|
|
20
|
-
<a href="https://vuejs.org/" target="_blank" rel="noopener">
|
|
20
|
+
<a href="https://vuejs.org/" target="_blank" rel="noopener">
|
|
21
|
+
official documentation
|
|
22
|
+
</a>
|
|
21
23
|
provides you with all information you need to get started.
|
|
22
24
|
</WelcomeItem>
|
|
23
25
|
|
|
@@ -28,23 +30,39 @@ const openReadmeInEditor = () => fetch('/__open-in-editor?file=README.md')
|
|
|
28
30
|
<template #heading>Tooling</template>
|
|
29
31
|
|
|
30
32
|
This project is served and bundled with
|
|
31
|
-
<a
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
<a
|
|
34
|
+
href="https://vite.dev/guide/features.html"
|
|
35
|
+
target="_blank"
|
|
36
|
+
rel="noopener"
|
|
37
|
+
>
|
|
38
|
+
Vite
|
|
39
|
+
</a>
|
|
40
|
+
. The recommended IDE setup is
|
|
41
|
+
<a href="https://code.visualstudio.com/" target="_blank" rel="noopener">
|
|
42
|
+
VSCode
|
|
43
|
+
</a>
|
|
34
44
|
+
|
|
35
|
-
<a
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
<a
|
|
46
|
+
href="https://github.com/vuejs/language-tools"
|
|
47
|
+
target="_blank"
|
|
48
|
+
rel="noopener"
|
|
49
|
+
>
|
|
50
|
+
Vue - Official
|
|
51
|
+
</a>
|
|
52
|
+
. If you need to test your components and web pages, check out
|
|
38
53
|
<a href="https://vitest.dev/" target="_blank" rel="noopener">Vitest</a>
|
|
39
54
|
and
|
|
40
55
|
<a href="https://www.cypress.io/" target="_blank" rel="noopener">Cypress</a>
|
|
41
56
|
/
|
|
42
|
-
<a href="https://playwright.dev/" target="_blank" rel="noopener">
|
|
57
|
+
<a href="https://playwright.dev/" target="_blank" rel="noopener">
|
|
58
|
+
Playwright </a
|
|
59
|
+
>.
|
|
43
60
|
|
|
44
61
|
<br />
|
|
45
62
|
|
|
46
63
|
More instructions are available in
|
|
47
|
-
<a href="javascript:void(0)" @click="openReadmeInEditor"
|
|
64
|
+
<a href="javascript:void(0)" @click="openReadmeInEditor">
|
|
65
|
+
<code>README.md</code> </a
|
|
48
66
|
>.
|
|
49
67
|
</WelcomeItem>
|
|
50
68
|
|
|
@@ -56,11 +74,21 @@ const openReadmeInEditor = () => fetch('/__open-in-editor?file=README.md')
|
|
|
56
74
|
|
|
57
75
|
Get official tools and libraries for your project:
|
|
58
76
|
<a href="https://pinia.vuejs.org/" target="_blank" rel="noopener">Pinia</a>,
|
|
59
|
-
<a href="https://router.vuejs.org/" target="_blank" rel="noopener"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
77
|
+
<a href="https://router.vuejs.org/" target="_blank" rel="noopener"
|
|
78
|
+
>Vue Router</a
|
|
79
|
+
>,
|
|
80
|
+
<a href="https://test-utils.vuejs.org/" target="_blank" rel="noopener"
|
|
81
|
+
>Vue Test Utils</a
|
|
82
|
+
>, and
|
|
83
|
+
<a href="https://github.com/vuejs/devtools" target="_blank" rel="noopener"
|
|
84
|
+
>Vue Dev Tools</a
|
|
85
|
+
>. If you need more resources, we suggest paying
|
|
86
|
+
<a
|
|
87
|
+
href="https://github.com/vuejs/awesome-vue"
|
|
88
|
+
target="_blank"
|
|
89
|
+
rel="noopener"
|
|
90
|
+
>Awesome Vue</a
|
|
91
|
+
>
|
|
64
92
|
a visit.
|
|
65
93
|
</WelcomeItem>
|
|
66
94
|
|
|
@@ -73,10 +101,15 @@ const openReadmeInEditor = () => fetch('/__open-in-editor?file=README.md')
|
|
|
73
101
|
Got stuck? Ask your question on
|
|
74
102
|
<a href="https://chat.vuejs.org" target="_blank" rel="noopener">Vue Land</a>
|
|
75
103
|
(our official Discord server), or
|
|
76
|
-
<a
|
|
104
|
+
<a
|
|
105
|
+
href="https://stackoverflow.com/questions/tagged/vue.js"
|
|
106
|
+
target="_blank"
|
|
107
|
+
rel="noopener"
|
|
77
108
|
>StackOverflow</a
|
|
78
109
|
>. You should also follow the official
|
|
79
|
-
<a href="https://bsky.app/profile/vuejs.org" target="_blank" rel="noopener"
|
|
110
|
+
<a href="https://bsky.app/profile/vuejs.org" target="_blank" rel="noopener"
|
|
111
|
+
>@vuejs.org</a
|
|
112
|
+
>
|
|
80
113
|
Bluesky account or the
|
|
81
114
|
<a href="https://x.com/vuejs" target="_blank" rel="noopener">@vuejs</a>
|
|
82
115
|
X account for latest news in the Vue world.
|
|
@@ -88,8 +121,10 @@ const openReadmeInEditor = () => fetch('/__open-in-editor?file=README.md')
|
|
|
88
121
|
</template>
|
|
89
122
|
<template #heading>Support Vue</template>
|
|
90
123
|
|
|
91
|
-
As an independent project, Vue relies on community backing for its
|
|
92
|
-
us by
|
|
93
|
-
<a href="https://vuejs.org/sponsor/" target="_blank" rel="noopener"
|
|
124
|
+
As an independent project, Vue relies on community backing for its
|
|
125
|
+
sustainability. You can help us by
|
|
126
|
+
<a href="https://vuejs.org/sponsor/" target="_blank" rel="noopener"
|
|
127
|
+
>becoming a sponsor</a
|
|
128
|
+
>.
|
|
94
129
|
</WelcomeItem>
|
|
95
130
|
</template>
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<svg
|
|
2
|
+
<svg
|
|
3
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
+
width="20"
|
|
5
|
+
height="20"
|
|
6
|
+
fill="currentColor"
|
|
7
|
+
>
|
|
3
8
|
<path
|
|
4
9
|
d="M15 4a1 1 0 1 0 0 2V4zm0 11v-1a1 1 0 0 0-1 1h1zm0 4l-.707.707A1 1 0 0 0 16 19h-1zm-4-4l.707-.707A1 1 0 0 0 11 14v1zm-4.707-1.293a1 1 0 0 0-1.414 1.414l1.414-1.414zm-.707.707l-.707-.707.707.707zM9 11v-1a1 1 0 0 0-.707.293L9 11zm-4 0h1a1 1 0 0 0-1-1v1zm0 4H4a1 1 0 0 0 1.707.707L5 15zm10-9h2V4h-2v2zm2 0a1 1 0 0 1 1 1h2a3 3 0 0 0-3-3v2zm1 1v6h2V7h-2zm0 6a1 1 0 0 1-1 1v2a3 3 0 0 0 3-3h-2zm-1 1h-2v2h2v-2zm-3 1v4h2v-4h-2zm1.707 3.293l-4-4-1.414 1.414 4 4 1.414-1.414zM11 14H7v2h4v-2zm-4 0c-.276 0-.525-.111-.707-.293l-1.414 1.414C5.42 15.663 6.172 16 7 16v-2zm-.707 1.121l3.414-3.414-1.414-1.414-3.414 3.414 1.414 1.414zM9 12h4v-2H9v2zm4 0a3 3 0 0 0 3-3h-2a1 1 0 0 1-1 1v2zm3-3V3h-2v6h2zm0-6a3 3 0 0 0-3-3v2a1 1 0 0 1 1 1h2zm-3-3H3v2h10V0zM3 0a3 3 0 0 0-3 3h2a1 1 0 0 1 1-1V0zM0 3v6h2V3H0zm0 6a3 3 0 0 0 3 3v-2a1 1 0 0 1-1-1H0zm3 3h2v-2H3v2zm1-1v4h2v-4H4zm1.707 4.707l.586-.586-1.414-1.414-.586.586 1.414 1.414z"
|
|
5
10
|
/>
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<svg
|
|
2
|
+
<svg
|
|
3
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
+
width="20"
|
|
5
|
+
height="17"
|
|
6
|
+
fill="currentColor"
|
|
7
|
+
>
|
|
3
8
|
<path
|
|
4
9
|
d="M11 2.253a1 1 0 1 0-2 0h2zm-2 13a1 1 0 1 0 2 0H9zm.447-12.167a1 1 0 1 0 1.107-1.666L9.447 3.086zM1 2.253L.447 1.42A1 1 0 0 0 0 2.253h1zm0 13H0a1 1 0 0 0 1.553.833L1 15.253zm8.447.833a1 1 0 1 0 1.107-1.666l-1.107 1.666zm0-14.666a1 1 0 1 0 1.107 1.666L9.447 1.42zM19 2.253h1a1 1 0 0 0-.447-.833L19 2.253zm0 13l-.553.833A1 1 0 0 0 20 15.253h-1zm-9.553-.833a1 1 0 1 0 1.107 1.666L9.447 14.42zM9 2.253v13h2v-13H9zm1.553-.833C9.203.523 7.42 0 5.5 0v2c1.572 0 2.961.431 3.947 1.086l1.107-1.666zM5.5 0C3.58 0 1.797.523.447 1.42l1.107 1.666C2.539 2.431 3.928 2 5.5 2V0zM0 2.253v13h2v-13H0zm1.553 13.833C2.539 15.431 3.928 15 5.5 15v-2c-1.92 0-3.703.523-5.053 1.42l1.107 1.666zM5.5 15c1.572 0 2.961.431 3.947 1.086l1.107-1.666C9.203 13.523 7.42 13 5.5 13v2zm5.053-11.914C11.539 2.431 12.928 2 14.5 2V0c-1.92 0-3.703.523-5.053 1.42l1.107 1.666zM14.5 2c1.573 0 2.961.431 3.947 1.086l1.107-1.666C18.203.523 16.421 0 14.5 0v2zm3.5.253v13h2v-13h-2zm1.553 12.167C18.203 13.523 16.421 13 14.5 13v2c1.573 0 2.961.431 3.947 1.086l1.107-1.666zM14.5 13c-1.92 0-3.703.523-5.053 1.42l1.107 1.666C11.539 15.431 12.928 15 14.5 15v-2z"
|
|
5
10
|
/>
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<svg
|
|
2
|
+
<svg
|
|
3
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
+
width="18"
|
|
5
|
+
height="20"
|
|
6
|
+
fill="currentColor"
|
|
7
|
+
>
|
|
3
8
|
<path
|
|
4
9
|
d="M11.447 8.894a1 1 0 1 0-.894-1.789l.894 1.789zm-2.894-.789a1 1 0 1 0 .894 1.789l-.894-1.789zm0 1.789a1 1 0 1 0 .894-1.789l-.894 1.789zM7.447 7.106a1 1 0 1 0-.894 1.789l.894-1.789zM10 9a1 1 0 1 0-2 0h2zm-2 2.5a1 1 0 1 0 2 0H8zm9.447-5.606a1 1 0 1 0-.894-1.789l.894 1.789zm-2.894-.789a1 1 0 1 0 .894 1.789l-.894-1.789zm2 .789a1 1 0 1 0 .894-1.789l-.894 1.789zm-1.106-2.789a1 1 0 1 0-.894 1.789l.894-1.789zM18 5a1 1 0 1 0-2 0h2zm-2 2.5a1 1 0 1 0 2 0h-2zm-5.447-4.606a1 1 0 1 0 .894-1.789l-.894 1.789zM9 1l.447-.894a1 1 0 0 0-.894 0L9 1zm-2.447.106a1 1 0 1 0 .894 1.789l-.894-1.789zm-6 3a1 1 0 1 0 .894 1.789L.553 4.106zm2.894.789a1 1 0 1 0-.894-1.789l.894 1.789zm-2-.789a1 1 0 1 0-.894 1.789l.894-1.789zm1.106 2.789a1 1 0 1 0 .894-1.789l-.894 1.789zM2 5a1 1 0 1 0-2 0h2zM0 7.5a1 1 0 1 0 2 0H0zm8.553 12.394a1 1 0 1 0 .894-1.789l-.894 1.789zm-1.106-2.789a1 1 0 1 0-.894 1.789l.894-1.789zm1.106 1a1 1 0 1 0 .894 1.789l-.894-1.789zm2.894.789a1 1 0 1 0-.894-1.789l.894 1.789zM8 19a1 1 0 1 0 2 0H8zm2-2.5a1 1 0 1 0-2 0h2zm-7.447.394a1 1 0 1 0 .894-1.789l-.894 1.789zM1 15H0a1 1 0 0 0 .553.894L1 15zm1-2.5a1 1 0 1 0-2 0h2zm12.553 2.606a1 1 0 1 0 .894 1.789l-.894-1.789zM17 15l.447.894A1 1 0 0 0 18 15h-1zm1-2.5a1 1 0 1 0-2 0h2zm-7.447-5.394l-2 1 .894 1.789 2-1-.894-1.789zm-1.106 1l-2-1-.894 1.789 2 1 .894-1.789zM8 9v2.5h2V9H8zm8.553-4.894l-2 1 .894 1.789 2-1-.894-1.789zm.894 0l-2-1-.894 1.789 2 1 .894-1.789zM16 5v2.5h2V5h-2zm-4.553-3.894l-2-1-.894 1.789 2 1 .894-1.789zm-2.894-1l-2 1 .894 1.789 2-1L8.553.106zM1.447 5.894l2-1-.894-1.789-2 1 .894 1.789zm-.894 0l2 1 .894-1.789-2-1-.894 1.789zM0 5v2.5h2V5H0zm9.447 13.106l-2-1-.894 1.789 2 1 .894-1.789zm0 1.789l2-1-.894-1.789-2 1 .894 1.789zM10 19v-2.5H8V19h2zm-6.553-3.894l-2-1-.894 1.789 2 1 .894-1.789zM2 15v-2.5H0V15h2zm13.447 1.894l2-1-.894-1.789-2 1 .894 1.789zM18 15v-2.5h-2V15h2z"
|
|
5
10
|
/>
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<svg
|
|
2
|
+
<svg
|
|
3
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
+
width="20"
|
|
5
|
+
height="20"
|
|
6
|
+
fill="currentColor"
|
|
7
|
+
>
|
|
3
8
|
<path
|
|
4
9
|
d="M10 3.22l-.61-.6a5.5 5.5 0 0 0-7.666.105 5.5 5.5 0 0 0-.114 7.665L10 18.78l8.39-8.4a5.5 5.5 0 0 0-.114-7.665 5.5 5.5 0 0 0-7.666-.105l-.61.61z"
|
|
5
10
|
/>
|
|
@@ -3,5 +3,16 @@ import { createApp } from 'vue'
|
|
|
3
3
|
import App from './App.vue'
|
|
4
4
|
<% if(usePinia) { %>import { createPinia } from 'pinia'<% } %>
|
|
5
5
|
<% if(usePiniaPluginPersistedstate) { %>import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'<% } %>
|
|
6
|
+
<% if(useVueRouter) { %>import router from './router/index.js';<% } %>
|
|
6
7
|
|
|
7
|
-
createApp(App)
|
|
8
|
+
createApp(App)
|
|
9
|
+
<% if(usePinia) { %>
|
|
10
|
+
.use(createPinia()
|
|
11
|
+
<% if(usePiniaPluginPersistedstate) { %>
|
|
12
|
+
.use(piniaPluginPersistedstate)
|
|
13
|
+
<% } %>
|
|
14
|
+
)
|
|
15
|
+
<% } %>
|
|
16
|
+
<% if(useVueRouter) { %>
|
|
17
|
+
.use(router)
|
|
18
|
+
<% } %>.mount('#app')
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { fileURLToPath, URL } from 'node:url'
|
|
1
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
2
2
|
|
|
3
|
-
import { defineConfig } from 'vite'
|
|
4
|
-
import vue from '@vitejs/plugin-vue'
|
|
5
|
-
import vueDevTools from 'vite-plugin-vue-devtools'
|
|
3
|
+
import { defineConfig } from 'vite';
|
|
4
|
+
import vue from '@vitejs/plugin-vue';
|
|
5
|
+
import vueDevTools from 'vite-plugin-vue-devtools';
|
|
6
6
|
|
|
7
7
|
// https://vite.dev/config/
|
|
8
8
|
export default defineConfig({
|
|
@@ -12,4 +12,4 @@ export default defineConfig({
|
|
|
12
12
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
|
-
})
|
|
15
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ref, computed } from 'vue'
|
|
2
|
-
import { defineStore } from 'pinia'
|
|
1
|
+
import { ref, computed } from 'vue';
|
|
2
|
+
import { defineStore } from 'pinia';
|
|
3
3
|
|
|
4
4
|
export const useCounterStore = defineStore('counter', () => {
|
|
5
|
-
const count = ref(0)
|
|
6
|
-
const doubleCount = computed(() => count.value * 2)
|
|
5
|
+
const count = ref(0);
|
|
6
|
+
const doubleCount = computed(() => count.value * 2);
|
|
7
7
|
function increment() {
|
|
8
|
-
count.value
|
|
8
|
+
count.value++;
|
|
9
9
|
}
|
|
10
|
-
return { count, doubleCount, increment }
|
|
11
|
-
})
|
|
10
|
+
return { count, doubleCount, increment };
|
|
11
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ref } from 'vue'
|
|
2
|
-
import { defineStore } from 'pinia'
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import { defineStore } from 'pinia';
|
|
3
3
|
|
|
4
4
|
export const useKeyStore = defineStore(
|
|
5
5
|
'key',
|
|
6
6
|
() => {
|
|
7
|
-
const key = ref('')
|
|
8
|
-
return { key }
|
|
7
|
+
const key = ref('Hello Pinia Persisted State!');
|
|
8
|
+
return { key };
|
|
9
9
|
},
|
|
10
|
-
{ persist: true }
|
|
11
|
-
)
|
|
10
|
+
{ persist: true }
|
|
11
|
+
);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createRouter, createWebHistory } from 'vue-router';
|
|
2
|
+
import HomeView from '../views/HomeView.vue';
|
|
3
|
+
|
|
4
|
+
const router = createRouter({
|
|
5
|
+
// TODO: 根据需要选择 history 模式
|
|
6
|
+
history: createWebHistory(import.meta.env.BASE_URL),
|
|
7
|
+
routes: [
|
|
8
|
+
// redirect root to /home
|
|
9
|
+
{ path: '/', redirect: '/home' },
|
|
10
|
+
{
|
|
11
|
+
path: '/home',
|
|
12
|
+
name: 'home',
|
|
13
|
+
component: HomeView,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
path: '/about',
|
|
17
|
+
name: 'about',
|
|
18
|
+
// route level code-splitting
|
|
19
|
+
// this generates a separate chunk (About.[hash].js) for this route
|
|
20
|
+
// which is lazy-loaded when the route is visited.
|
|
21
|
+
component: () => import('../views/AboutView.vue'),
|
|
22
|
+
},
|
|
23
|
+
// 404 Not Found route
|
|
24
|
+
{
|
|
25
|
+
path: '/:pathMatch(.*)*',
|
|
26
|
+
name: 'notFound',
|
|
27
|
+
component: () => import('../views/NotFound.vue'),
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export default router;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import TitleText from '@/components/TitleText.vue';
|
|
3
|
+
<% if(usePiniaPluginPersistedstate) { %>
|
|
4
|
+
import {
|
|
5
|
+
useKeyStore
|
|
6
|
+
} from '@/stores/key.js';
|
|
7
|
+
const keyStore = useKeyStore();
|
|
8
|
+
<% } %>
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<TitleText>This is an about page
|
|
13
|
+
<% if(usePiniaPluginPersistedstate) { %>
|
|
14
|
+
,<div>
|
|
15
|
+
the key is:
|
|
16
|
+
<span style="color: white; font-weight: bold">
|
|
17
|
+
{{ keyStore.key }}</span>
|
|
18
|
+
</div>
|
|
19
|
+
<% } %>
|
|
20
|
+
</TitleText>
|
|
21
|
+
</template>
|
package/utils/URL.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
// 获得相对路径和模板目录路径的工具函数
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import { fileURLToPath } from 'url'
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
4
|
|
|
5
5
|
// 拼接相对路径
|
|
6
6
|
export const relativePath = (fileURL, targetURL) => {
|
|
7
|
-
const __filename = fileURLToPath(fileURL)
|
|
8
|
-
const __dirname = path.dirname(__filename)
|
|
9
|
-
return path.join(__dirname, targetURL)
|
|
10
|
-
}
|
|
7
|
+
const __filename = fileURLToPath(fileURL);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
return path.join(__dirname, targetURL);
|
|
10
|
+
};
|
|
11
11
|
|
|
12
12
|
// 获取模板目录路径
|
|
13
|
-
export const templatePath = fileURLToPath(
|
|
13
|
+
export const templatePath = fileURLToPath(
|
|
14
|
+
new URL('../template', import.meta.url)
|
|
15
|
+
);
|
package/utils/figletPrint.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// print BANANA in big money-se font using figlet
|
|
2
|
-
import figlet from 'figlet'
|
|
2
|
+
import figlet from 'figlet';
|
|
3
3
|
|
|
4
4
|
const printString = async (str) => {
|
|
5
5
|
try {
|
|
@@ -9,11 +9,11 @@ const printString = async (str) => {
|
|
|
9
9
|
verticalLayout: 'default',
|
|
10
10
|
width: 80,
|
|
11
11
|
whitespaceBreak: true,
|
|
12
|
-
})
|
|
12
|
+
});
|
|
13
13
|
} catch (err) {
|
|
14
|
-
console.log('Something went wrong...')
|
|
15
|
-
console.dir(err)
|
|
14
|
+
console.log('Something went wrong...');
|
|
15
|
+
console.dir(err);
|
|
16
16
|
}
|
|
17
|
-
}
|
|
17
|
+
};
|
|
18
18
|
|
|
19
|
-
export default printString
|
|
19
|
+
export default printString;
|
package/utils/pathExists.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// 确认路径是否存在,若存在则提示是否覆盖
|
|
2
2
|
// 若选择覆盖则删除已存在的文件夹,并新建一个文件夹
|
|
3
3
|
// 若选择不覆盖则退出程序
|
|
4
|
-
import fs from 'fs-extra'
|
|
5
|
-
import { select } from '@inquirer/prompts'
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import { select } from '@inquirer/prompts';
|
|
6
|
+
import chalk from 'chalk';
|
|
6
7
|
|
|
7
8
|
const confirmPathExists = async (projectName, projectDir) => {
|
|
8
9
|
try {
|
|
@@ -10,28 +11,29 @@ const confirmPathExists = async (projectName, projectDir) => {
|
|
|
10
11
|
if (await fs.pathExists(projectDir)) {
|
|
11
12
|
// 如果存在就提示是否要覆盖
|
|
12
13
|
const isOverwrite = await select({
|
|
13
|
-
message: `The target folder "${projectName}" is not empty. Overwrite?`,
|
|
14
|
+
message: `The target folder "${projectName}" is not empty. ${chalk.yellow('Overwrite')}?`,
|
|
14
15
|
choices: [
|
|
15
16
|
{ name: 'Yes', value: true },
|
|
16
17
|
{ name: 'No', value: false },
|
|
17
18
|
],
|
|
18
|
-
})
|
|
19
|
+
});
|
|
19
20
|
if (!isOverwrite) {
|
|
20
21
|
// TODO: 放一个更友好的提示
|
|
21
22
|
// 例如:X操作取消(换英文)
|
|
22
|
-
console.log('canceled!')
|
|
23
|
+
console.log('canceled!');
|
|
23
24
|
// 退出程序
|
|
24
|
-
process.exit(0)
|
|
25
|
+
process.exit(0);
|
|
25
26
|
} else {
|
|
26
27
|
// 删除已存在的文件夹并新建一个文件夹
|
|
27
|
-
await fs.remove(projectDir)
|
|
28
|
-
await fs.mkdir(projectDir)
|
|
28
|
+
await fs.remove(projectDir);
|
|
29
|
+
await fs.mkdir(projectDir);
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
} catch (err) {
|
|
32
33
|
// TODO: 放一个更友好的提示
|
|
33
|
-
console.error(err)
|
|
34
|
+
console.error(err);
|
|
35
|
+
process.exit(1);
|
|
34
36
|
}
|
|
35
|
-
}
|
|
37
|
+
};
|
|
36
38
|
|
|
37
|
-
export default confirmPathExists
|
|
39
|
+
export default confirmPathExists;
|
package/utils/rainbow.js
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
// use chalk to print text in rainbow colors
|
|
2
|
-
import chalk from 'chalk'
|
|
2
|
+
import chalk from 'chalk';
|
|
3
3
|
|
|
4
4
|
function hslToRgb(h, s, l) {
|
|
5
|
-
s /= 100
|
|
6
|
-
l /= 100
|
|
5
|
+
s /= 100;
|
|
6
|
+
l /= 100;
|
|
7
7
|
|
|
8
|
-
const k = (n) => (n + h / 30) % 12
|
|
9
|
-
const a = s * Math.min(l, 1 - l)
|
|
10
|
-
const f = (n) =>
|
|
8
|
+
const k = (n) => (n + h / 30) % 12;
|
|
9
|
+
const a = s * Math.min(l, 1 - l);
|
|
10
|
+
const f = (n) =>
|
|
11
|
+
l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
11
12
|
|
|
12
|
-
return [
|
|
13
|
+
return [
|
|
14
|
+
Math.round(255 * f(0)),
|
|
15
|
+
Math.round(255 * f(8)),
|
|
16
|
+
Math.round(255 * f(4)),
|
|
17
|
+
];
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
function rainbowGradient(text) {
|
|
16
21
|
return text
|
|
17
22
|
.split('')
|
|
18
23
|
.map((char, i) => {
|
|
19
|
-
const hue = (i / text.length) * 360
|
|
20
|
-
const [r, g, b] = hslToRgb(hue, 100, 50)
|
|
21
|
-
return chalk.rgb(r, g, b)(char)
|
|
24
|
+
const hue = (i / text.length) * 360;
|
|
25
|
+
const [r, g, b] = hslToRgb(hue, 100, 50);
|
|
26
|
+
return chalk.rgb(r, g, b)(char);
|
|
22
27
|
})
|
|
23
|
-
.join('')
|
|
28
|
+
.join('');
|
|
24
29
|
}
|
|
25
30
|
|
|
26
|
-
export default rainbowGradient
|
|
31
|
+
export default rainbowGradient;
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
// 渲染App.vue,通过模板匹配pinia的使用情况
|
|
2
|
-
import ejs from 'ejs'
|
|
3
|
-
import { templatePath } from '#utils/URL.js'
|
|
4
|
-
import fs from 'fs-extra'
|
|
5
|
-
import path from 'path'
|
|
2
|
+
import ejs from 'ejs';
|
|
3
|
+
import { templatePath } from '#utils/URL.js';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import path from 'path';
|
|
6
6
|
|
|
7
|
-
const addAppVue = async (
|
|
7
|
+
const addAppVue = async (
|
|
8
|
+
projectName,
|
|
9
|
+
usePinia,
|
|
10
|
+
usePiniaPluginPersistedstate,
|
|
11
|
+
useVueRouter
|
|
12
|
+
) => {
|
|
8
13
|
await fs.writeFile(
|
|
9
14
|
path.join(process.cwd(), projectName, 'src', 'App.vue'),
|
|
10
|
-
ejs.render(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
ejs.render(
|
|
16
|
+
await fs.readFile(
|
|
17
|
+
path.join(templatePath, 'base', 'src', 'App.vue.ejs'),
|
|
18
|
+
'utf-8'
|
|
19
|
+
),
|
|
20
|
+
{
|
|
21
|
+
usePinia,
|
|
22
|
+
usePiniaPluginPersistedstate,
|
|
23
|
+
useVueRouter,
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
await fs.remove(path.join(process.cwd(), projectName, 'src', 'App.vue.ejs'));
|
|
28
|
+
};
|
|
17
29
|
|
|
18
|
-
export default addAppVue
|
|
30
|
+
export default addAppVue;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// 获取base模板
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import { templatePath } from '#utils/URL.js'
|
|
4
|
-
import fs from 'fs-extra'
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { templatePath } from '#utils/URL.js';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
5
|
|
|
6
6
|
const createBaseProject = async (projectName) => {
|
|
7
|
-
const basePath = path.join(templatePath, 'base')
|
|
8
|
-
const projectDir = path.join(process.cwd(), projectName)
|
|
7
|
+
const basePath = path.join(templatePath, 'base');
|
|
8
|
+
const projectDir = path.join(process.cwd(), projectName);
|
|
9
9
|
// 复制模板文件到目标目录
|
|
10
|
-
fs.copySync(basePath, projectDir)
|
|
10
|
+
fs.copySync(basePath, projectDir);
|
|
11
11
|
|
|
12
|
-
const packageJsonPath = path.join(projectDir, 'package.json')
|
|
13
|
-
const packageJson = await fs.readJson(packageJsonPath)
|
|
14
|
-
packageJson.name = projectName
|
|
12
|
+
const packageJsonPath = path.join(projectDir, 'package.json');
|
|
13
|
+
const packageJson = await fs.readJson(packageJsonPath);
|
|
14
|
+
packageJson.name = projectName;
|
|
15
15
|
// 写回package.json文件
|
|
16
|
-
await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 })
|
|
17
|
-
}
|
|
16
|
+
await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
|
|
17
|
+
};
|
|
18
18
|
|
|
19
|
-
export default createBaseProject
|
|
19
|
+
export default createBaseProject;
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
// 渲染main.js,通过模板匹配pinia的使用情况
|
|
2
|
-
import ejs from 'ejs'
|
|
3
|
-
import { templatePath } from '#utils/URL.js'
|
|
4
|
-
import fs from 'fs-extra'
|
|
5
|
-
import path from 'path'
|
|
2
|
+
import ejs from 'ejs';
|
|
3
|
+
import { templatePath } from '#utils/URL.js';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import path from 'path';
|
|
6
6
|
|
|
7
|
-
const addMain = async (
|
|
7
|
+
const addMain = async (
|
|
8
|
+
projectName,
|
|
9
|
+
usePinia,
|
|
10
|
+
usePiniaPluginPersistedstate,
|
|
11
|
+
useVueRouter
|
|
12
|
+
) => {
|
|
8
13
|
await fs.writeFile(
|
|
9
14
|
path.join(process.cwd(), projectName, 'src', 'main.js'),
|
|
10
|
-
ejs.render(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
ejs.render(
|
|
16
|
+
await fs.readFile(
|
|
17
|
+
path.join(templatePath, 'base', 'src', 'main.js.ejs'),
|
|
18
|
+
'utf-8'
|
|
19
|
+
),
|
|
20
|
+
{
|
|
21
|
+
usePinia,
|
|
22
|
+
usePiniaPluginPersistedstate,
|
|
23
|
+
useVueRouter,
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
await fs.remove(path.join(process.cwd(), projectName, 'src', 'main.js.ejs'));
|
|
28
|
+
};
|
|
17
29
|
|
|
18
|
-
export default addMain
|
|
30
|
+
export default addMain;
|