@moluoxixi/create-app 2.0.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.txt +21 -0
- package/README.md +129 -0
- package/dist/commands/create.d.ts +10 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +89 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +5 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/generators/index.d.ts +7 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +7 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/generators/project.d.ts +11 -0
- package/dist/generators/project.d.ts.map +1 -0
- package/dist/generators/project.js +26 -0
- package/dist/generators/project.js.map +1 -0
- package/dist/generators/react.d.ts +10 -0
- package/dist/generators/react.d.ts.map +1 -0
- package/dist/generators/react.js +39 -0
- package/dist/generators/react.js.map +1 -0
- package/dist/generators/vue.d.ts +10 -0
- package/dist/generators/vue.d.ts.map +1 -0
- package/dist/generators/vue.js +40 -0
- package/dist/generators/vue.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/test.d.ts +6 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +364 -0
- package/dist/test.js.map +1 -0
- package/dist/types/ejs.d.ts +11 -0
- package/dist/types/ejs.d.ts.map +1 -0
- package/dist/types/ejs.js +5 -0
- package/dist/types/ejs.js.map +1 -0
- package/dist/types/features.d.ts +26 -0
- package/dist/types/features.d.ts.map +1 -0
- package/dist/types/features.js +41 -0
- package/dist/types/features.js.map +1 -0
- package/dist/types/index.d.ts +59 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/viteConfig.d.ts +17 -0
- package/dist/types/viteConfig.d.ts.map +1 -0
- package/dist/types/viteConfig.js +6 -0
- package/dist/types/viteConfig.js.map +1 -0
- package/dist/utils/deepMerge.d.ts +8 -0
- package/dist/utils/deepMerge.d.ts.map +1 -0
- package/dist/utils/deepMerge.js +33 -0
- package/dist/utils/deepMerge.js.map +1 -0
- package/dist/utils/ejs.d.ts +19 -0
- package/dist/utils/ejs.d.ts.map +1 -0
- package/dist/utils/ejs.js +30 -0
- package/dist/utils/ejs.js.map +1 -0
- package/dist/utils/file.d.ts +70 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +119 -0
- package/dist/utils/file.js.map +1 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/install.d.ts +17 -0
- package/dist/utils/install.d.ts.map +1 -0
- package/dist/utils/install.js +37 -0
- package/dist/utils/install.js.map +1 -0
- package/dist/utils/prompts.d.ts +16 -0
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +180 -0
- package/dist/utils/prompts.js.map +1 -0
- package/dist/utils/renderFeatures.d.ts +18 -0
- package/dist/utils/renderFeatures.d.ts.map +1 -0
- package/dist/utils/renderFeatures.js +72 -0
- package/dist/utils/renderFeatures.js.map +1 -0
- package/dist/utils/renderTemplate.d.ts +6 -0
- package/dist/utils/renderTemplate.d.ts.map +1 -0
- package/dist/utils/renderTemplate.js +102 -0
- package/dist/utils/renderTemplate.js.map +1 -0
- package/dist/utils/sortDependencies.d.ts +6 -0
- package/dist/utils/sortDependencies.d.ts.map +1 -0
- package/dist/utils/sortDependencies.js +22 -0
- package/dist/utils/sortDependencies.js.map +1 -0
- package/dist/utils/viteConfigRender.d.ts +19 -0
- package/dist/utils/viteConfigRender.d.ts.map +1 -0
- package/dist/utils/viteConfigRender.js +180 -0
- package/dist/utils/viteConfigRender.js.map +1 -0
- package/package.json +93 -0
- package/templates/common/base/.env +7 -0
- package/templates/common/base/.env.development +5 -0
- package/templates/common/base/.env.production +5 -0
- package/templates/common/base/package.json +56 -0
- package/templates/common/base/pnpm-workspace.yaml +37 -0
- package/templates/common/base/scripts/build.mts +31 -0
- package/templates/common/base/src/apis/index.ts +8 -0
- package/templates/common/base/src/apis/request.ts +43 -0
- package/templates/common/base/src/apis/services/example.ts +40 -0
- package/templates/common/base/src/apis/services/user.ts +23 -0
- package/templates/common/base/src/apis/types/common.ts +28 -0
- package/templates/common/base/src/apis/types/example.ts +18 -0
- package/templates/common/base/src/apis/types/index.ts +7 -0
- package/templates/common/base/src/apis/types/user.ts +24 -0
- package/templates/common/base/src/assets/fonts/index.css +7 -0
- package/templates/common/base/src/assets/styles/base.scss +72 -0
- package/templates/common/base/src/assets/styles/custom.scss +7 -0
- package/templates/common/base/src/assets/styles/tailwind.scss +6 -0
- package/templates/common/base/src/constants/index.ts +29 -0
- package/templates/common/base/src/locales/lang/en.ts +30 -0
- package/templates/common/base/src/locales/lang/es.ts +30 -0
- package/templates/common/base/src/locales/lang/zh.ts +30 -0
- package/templates/common/base/src/utils/index.ts +83 -0
- package/templates/common/features/husky/.cz-config.cjs +35 -0
- package/templates/common/features/husky/.husky/commit-msg +9 -0
- package/templates/common/features/husky/.husky/install.mjs +6 -0
- package/templates/common/features/husky/.husky/pre-commit +4 -0
- package/templates/common/features/husky/commitlint.config.ts +32 -0
- package/templates/common/features/husky/package.json +28 -0
- package/templates/common/features/husky/pnpm-workspace.yaml +9 -0
- package/templates/react/base/env.d.ts +19 -0
- package/templates/react/base/index.html +14 -0
- package/templates/react/base/package.json +15 -0
- package/templates/react/base/pnpm-workspace.yaml +9 -0
- package/templates/react/base/src/App.tsx +18 -0
- package/templates/react/base/src/assets/styles/main.scss +8 -0
- package/templates/react/base/src/main.tsx.ejs +39 -0
- package/templates/react/base/src/pages/about/index.tsx +14 -0
- package/templates/react/base/src/pages/home/index.tsx +14 -0
- package/templates/react/base/src/router/index.tsx.ejs +28 -0
- package/templates/react/base/src/stores/user.ts +39 -0
- package/templates/react/base/tsconfig.app.json +17 -0
- package/templates/react/base/tsconfig.base.json +23 -0
- package/templates/react/base/tsconfig.json +12 -0
- package/templates/react/base/tsconfig.node.json +15 -0
- package/templates/react/base/vite.config.ts +52 -0
- package/templates/react/features/ant-design/package.json +7 -0
- package/templates/react/features/ant-design/pnpm-workspace.yaml +5 -0
- package/templates/react/features/eslint/eslint.config.ts +12 -0
- package/templates/react/features/eslint/package.json +7 -0
- package/templates/react/features/eslint/pnpm-workspace.yaml +6 -0
- package/templates/react/features/i18n/package.json +7 -0
- package/templates/react/features/i18n/pnpm-workspace.yaml +5 -0
- package/templates/react/features/i18n/src/locales/index.ts +20 -0
- package/templates/react/features/manualRoutes/src/router/routes.tsx +21 -0
- package/templates/react/features/pageRoutes/package.json +6 -0
- package/templates/react/features/pageRoutes/pnpm-workspace.yaml +4 -0
- package/templates/react/features/pageRoutes/vite.config.data.ts +10 -0
- package/templates/react/features/router/package.json +5 -0
- package/templates/react/features/router/pnpm-workspace.yaml +3 -0
- package/templates/react/features/sentry/package.json +7 -0
- package/templates/react/features/sentry/pnpm-workspace.yaml +5 -0
- package/templates/react/features/sentry/src/utils/sentry.ts +30 -0
- package/templates/react/features/sentry/vite.config.data.ts +23 -0
- package/templates/react/features/zustand/package.json +5 -0
- package/templates/react/features/zustand/pnpm-workspace.yaml +3 -0
- package/templates/react/features/zustand/src/stores/user.ts +19 -0
- package/templates/react/features/zustand/src/types/stores.ts +15 -0
- package/templates/vue/base/env.d.ts +27 -0
- package/templates/vue/base/index.html +14 -0
- package/templates/vue/base/package.json +13 -0
- package/templates/vue/base/pnpm-workspace.yaml +6 -0
- package/templates/vue/base/src/App.vue +13 -0
- package/templates/vue/base/src/assets/styles/element/index.scss +27 -0
- package/templates/vue/base/src/assets/styles/main.scss +9 -0
- package/templates/vue/base/src/components/SubMenu/index.ts +9 -0
- package/templates/vue/base/src/components/SubMenu/src/_types/index.ts +6 -0
- package/templates/vue/base/src/components/SubMenu/src/_types/props.ts +11 -0
- package/templates/vue/base/src/components/SubMenu/src/index.vue +24 -0
- package/templates/vue/base/src/directives/index.ts +36 -0
- package/templates/vue/base/src/layouts/AntDesign.vue +86 -0
- package/templates/vue/base/src/layouts/element.vue +81 -0
- package/templates/vue/base/src/layouts/index.ts +7 -0
- package/templates/vue/base/src/main.ts.ejs +100 -0
- package/templates/vue/base/src/pages/about/index.vue +31 -0
- package/templates/vue/base/src/pages/home/index.vue +31 -0
- package/templates/vue/base/src/router/index.ts.ejs +39 -0
- package/templates/vue/base/src/stores/index.ts +16 -0
- package/templates/vue/base/src/stores/modules/system.ts +52 -0
- package/templates/vue/base/src/stores/modules/user.ts +48 -0
- package/templates/vue/base/tsconfig.app.json +17 -0
- package/templates/vue/base/tsconfig.base.json +23 -0
- package/templates/vue/base/tsconfig.json +12 -0
- package/templates/vue/base/tsconfig.node.json +15 -0
- package/templates/vue/base/vite.config.ts +53 -0
- package/templates/vue/features/ant-design-vue/package.json +7 -0
- package/templates/vue/features/ant-design-vue/pnpm-workspace.yaml +5 -0
- package/templates/vue/features/element-plus/package.json +7 -0
- package/templates/vue/features/element-plus/pnpm-workspace.yaml +5 -0
- package/templates/vue/features/element-plus/vite.config.data.ts +15 -0
- package/templates/vue/features/eslint/eslint.config.ts +12 -0
- package/templates/vue/features/eslint/package.json +7 -0
- package/templates/vue/features/eslint/pnpm-workspace.yaml +6 -0
- package/templates/vue/features/i18n/package.json +5 -0
- package/templates/vue/features/i18n/pnpm-workspace.yaml +3 -0
- package/templates/vue/features/i18n/src/locales/index.ts +16 -0
- package/templates/vue/features/manualRoutes/src/router/layout.vue +10 -0
- package/templates/vue/features/manualRoutes/src/router/routes.ts +27 -0
- package/templates/vue/features/pageRoutes/package.json +5 -0
- package/templates/vue/features/pageRoutes/pnpm-workspace.yaml +4 -0
- package/templates/vue/features/pageRoutes/vite.config.data.ts +9 -0
- package/templates/vue/features/pinia/package.json +6 -0
- package/templates/vue/features/pinia/pnpm-workspace.yaml +4 -0
- package/templates/vue/features/pinia/src/stores/index.ts +8 -0
- package/templates/vue/features/pinia/src/stores/user.ts +36 -0
- package/templates/vue/features/qiankun/package.json +5 -0
- package/templates/vue/features/qiankun/pnpm-workspace.yaml +3 -0
- package/templates/vue/features/qiankun/src/qiankun/index.ts +56 -0
- package/templates/vue/features/router/package.json +5 -0
- package/templates/vue/features/router/pnpm-workspace.yaml +3 -0
- package/templates/vue/features/sentry/package.json +6 -0
- package/templates/vue/features/sentry/pnpm-workspace.yaml +4 -0
- package/templates/vue/features/sentry/src/utils/sentry.ts +33 -0
- package/templates/vue/features/sentry/vite.config.data.ts +23 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ViteConfigData } from '../../../../src/types/viteConfig'
|
|
2
|
+
|
|
3
|
+
const data: ViteConfigData = {
|
|
4
|
+
css: {
|
|
5
|
+
additionalData: `additionalData: (source: string, filename: string) => {
|
|
6
|
+
if (filename.includes('assets/styles/element/index.scss')) {
|
|
7
|
+
return \`$namespace: '\${appCode || 'el'}';
|
|
8
|
+
\${source}\`
|
|
9
|
+
}
|
|
10
|
+
return source
|
|
11
|
+
},`,
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default data
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createI18n } from 'vue-i18n'
|
|
2
|
+
|
|
3
|
+
import en from './lang/en'
|
|
4
|
+
import zh from './lang/zh'
|
|
5
|
+
|
|
6
|
+
const i18n = createI18n({
|
|
7
|
+
legacy: false,
|
|
8
|
+
locale: localStorage.getItem('locale') || 'zh',
|
|
9
|
+
fallbackLocale: 'zh',
|
|
10
|
+
messages: {
|
|
11
|
+
zh,
|
|
12
|
+
en,
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export default i18n
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Layout from './layout.vue'
|
|
2
|
+
|
|
3
|
+
export const routes = [
|
|
4
|
+
{
|
|
5
|
+
path: '/',
|
|
6
|
+
component: Layout,
|
|
7
|
+
redirect: '/home',
|
|
8
|
+
children: [
|
|
9
|
+
{
|
|
10
|
+
path: '/home',
|
|
11
|
+
name: 'Home',
|
|
12
|
+
component: () => import('@/pages/home/index.vue'),
|
|
13
|
+
meta: {
|
|
14
|
+
title: '首页',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
path: '/about',
|
|
19
|
+
name: 'About',
|
|
20
|
+
component: () => import('@/pages/about/index.vue'),
|
|
21
|
+
meta: {
|
|
22
|
+
title: '关于',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { UserInfoType } from '@/apis/types/user'
|
|
2
|
+
|
|
3
|
+
import { defineStore } from 'pinia'
|
|
4
|
+
import { ref } from 'vue'
|
|
5
|
+
|
|
6
|
+
export const useUserStore = defineStore(
|
|
7
|
+
'user',
|
|
8
|
+
() => {
|
|
9
|
+
const token = ref('')
|
|
10
|
+
const userInfo = ref<UserInfoType | null>(null)
|
|
11
|
+
|
|
12
|
+
function setToken(value: string): void {
|
|
13
|
+
token.value = value
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function setUserInfo(value: UserInfoType): void {
|
|
17
|
+
userInfo.value = value
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function logout(): void {
|
|
21
|
+
token.value = ''
|
|
22
|
+
userInfo.value = null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
token,
|
|
27
|
+
userInfo,
|
|
28
|
+
setToken,
|
|
29
|
+
setUserInfo,
|
|
30
|
+
logout,
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
persist: true,
|
|
35
|
+
},
|
|
36
|
+
)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { App } from 'vue'
|
|
2
|
+
import type { Router } from 'vue-router'
|
|
3
|
+
import {
|
|
4
|
+
renderWithQiankun,
|
|
5
|
+
qiankunWindow,
|
|
6
|
+
} from 'vite-plugin-qiankun/dist/helper'
|
|
7
|
+
|
|
8
|
+
let app: App | null = null
|
|
9
|
+
let router: Router | null = null
|
|
10
|
+
|
|
11
|
+
interface QiankunProps {
|
|
12
|
+
container?: Element
|
|
13
|
+
[key: string]: unknown
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface RenderOptions {
|
|
17
|
+
createApp: () => App
|
|
18
|
+
createRouter: (qiankunName?: string) => Router
|
|
19
|
+
mountApp: (app: App, router: Router, container: string | Element) => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function setupQiankun(options: RenderOptions): void {
|
|
23
|
+
const { createApp, createRouter, mountApp } = options
|
|
24
|
+
|
|
25
|
+
renderWithQiankun({
|
|
26
|
+
mount(props: QiankunProps) {
|
|
27
|
+
app = createApp()
|
|
28
|
+
const qiankunName = qiankunWindow.__POWERED_BY_QIANKUN__
|
|
29
|
+
? (qiankunWindow as { __INJECTED_PUBLIC_PATH_BY_QIANKUN__?: string }).__INJECTED_PUBLIC_PATH_BY_QIANKUN__?.split('/')[1]
|
|
30
|
+
: undefined
|
|
31
|
+
router = createRouter(qiankunName)
|
|
32
|
+
const container = props.container
|
|
33
|
+
? props.container.querySelector('#app')!
|
|
34
|
+
: '#app'
|
|
35
|
+
mountApp(app, router, container)
|
|
36
|
+
},
|
|
37
|
+
bootstrap() {
|
|
38
|
+
console.log('[Qiankun] bootstrap')
|
|
39
|
+
},
|
|
40
|
+
unmount() {
|
|
41
|
+
if (app) {
|
|
42
|
+
app.unmount()
|
|
43
|
+
app = null
|
|
44
|
+
router = null
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
update() {
|
|
48
|
+
console.log('[Qiankun] update')
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function isQiankun(): boolean {
|
|
54
|
+
return qiankunWindow.__POWERED_BY_QIANKUN__ || false
|
|
55
|
+
}
|
|
56
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { App } from 'vue'
|
|
2
|
+
import type { Router } from 'vue-router'
|
|
3
|
+
import * as Sentry from '@sentry/vue'
|
|
4
|
+
|
|
5
|
+
interface SentryConfig {
|
|
6
|
+
dsn: string
|
|
7
|
+
environment?: string
|
|
8
|
+
release?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function initSentry(app: App, router: Router, config: SentryConfig): void {
|
|
12
|
+
const { dsn, environment = 'production', release } = config
|
|
13
|
+
|
|
14
|
+
if (!dsn) {
|
|
15
|
+
console.warn('[Sentry] DSN is not configured, skipping initialization')
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Sentry.init({
|
|
20
|
+
app,
|
|
21
|
+
dsn,
|
|
22
|
+
environment,
|
|
23
|
+
release,
|
|
24
|
+
integrations: [
|
|
25
|
+
Sentry.browserTracingIntegration({ router }),
|
|
26
|
+
Sentry.replayIntegration(),
|
|
27
|
+
],
|
|
28
|
+
tracesSampleRate: 1.0,
|
|
29
|
+
replaysSessionSampleRate: 0.1,
|
|
30
|
+
replaysOnErrorSampleRate: 1.0,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ViteConfigData } from '../../../../src/types/viteConfig'
|
|
2
|
+
|
|
3
|
+
const data: ViteConfigData = {
|
|
4
|
+
imports: [
|
|
5
|
+
'import { sentryVitePlugin } from \'@sentry/vite-plugin\'',
|
|
6
|
+
],
|
|
7
|
+
plugins: [
|
|
8
|
+
`viteEnv.VITE_SENTRY && mode === 'production' && sentryVitePlugin({
|
|
9
|
+
authToken: process.env.SENTRY_AUTH_TOKEN,
|
|
10
|
+
org: 'f1f562b9b82f',
|
|
11
|
+
project: 'javascript-vue',
|
|
12
|
+
sourcemaps: {
|
|
13
|
+
assets: './dist/**',
|
|
14
|
+
ignore: ['node_modules'],
|
|
15
|
+
},
|
|
16
|
+
release: {
|
|
17
|
+
name: viteEnv.VITE_APP_VERSION || 'unknown',
|
|
18
|
+
},
|
|
19
|
+
})`,
|
|
20
|
+
],
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default data
|