@dengzhibo/create-vue-template 0.0.0-stage → 0.0.2
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/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +62 -2
- package/bin/index.js +39 -0
- package/lib/generate.js +100 -0
- package/lib/options.js +53 -0
- package/lib/prompts.js +317 -0
- package/package.json +46 -3
- package/templates/base/.gitattributes +1 -0
- package/templates/base/.vscode/extensions.json +5 -0
- package/templates/base/.vscode/settings.json +10 -0
- package/templates/base/README.md +75 -0
- package/templates/base/_gitignore +44 -0
- package/templates/base/env.d.ts +1 -0
- package/templates/base/index.html +13 -0
- package/templates/base/package.json +32 -0
- package/templates/base/pnpm-workspace.yaml +19 -0
- package/templates/base/public/favicon.ico +0 -0
- package/templates/base/src/App.vue +85 -0
- package/templates/base/src/assets/base.css +86 -0
- package/templates/base/src/assets/logo.svg +1 -0
- package/templates/base/src/assets/main.css +35 -0
- package/templates/base/src/components/HelloWorld.vue +41 -0
- package/templates/base/src/components/TheWelcome.vue +95 -0
- package/templates/base/src/components/WelcomeItem.vue +87 -0
- package/templates/base/src/components/icons/IconCommunity.vue +7 -0
- package/templates/base/src/components/icons/IconDocumentation.vue +7 -0
- package/templates/base/src/components/icons/IconEcosystem.vue +7 -0
- package/templates/base/src/components/icons/IconSupport.vue +7 -0
- package/templates/base/src/components/icons/IconTooling.vue +19 -0
- package/templates/base/src/main.ts +14 -0
- package/templates/base/src/router/index.ts +23 -0
- package/templates/base/src/stores/counter.ts +12 -0
- package/templates/base/src/views/AboutView.vue +15 -0
- package/templates/base/src/views/HomeView.vue +9 -0
- package/templates/base/tsconfig.app.json +18 -0
- package/templates/base/tsconfig.json +11 -0
- package/templates/base/tsconfig.node.json +28 -0
- package/templates/base/vite.config.ts +18 -0
- package/templates/features/code-quality/.editorconfig +8 -0
- package/templates/features/code-quality/.oxfmtrc.json +5 -0
- package/templates/features/code-quality/.oxlintrc.json +10 -0
- package/templates/features/code-quality/eslint.config.ts +38 -0
- package/templates/features/code-quality/package.fragment.json +21 -0
- package/templates/features/code-quality/settings.fragment.json +7 -0
- package/templates/features/e2e/e2e/tsconfig.json +4 -0
- package/templates/features/e2e/e2e/vue.spec.ts +8 -0
- package/templates/features/e2e/package.fragment.json +8 -0
- package/templates/features/e2e/playwright.config.ts +110 -0
- package/templates/features/unit-test/package.fragment.json +11 -0
- package/templates/features/unit-test/src/components/__tests__/HelloWorld.spec.ts +11 -0
- package/templates/features/unit-test/tsconfig.vitest.json +19 -0
- package/templates/features/unit-test/vitest.config.ts +14 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!-- This icon is from <https://github.com/Templarian/MaterialDesign>, distributed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) license-->
|
|
2
|
+
<template>
|
|
3
|
+
<svg
|
|
4
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
6
|
+
aria-hidden="true"
|
|
7
|
+
role="img"
|
|
8
|
+
class="iconify iconify--mdi"
|
|
9
|
+
width="24"
|
|
10
|
+
height="24"
|
|
11
|
+
preserveAspectRatio="xMidYMid meet"
|
|
12
|
+
viewBox="0 0 24 24"
|
|
13
|
+
>
|
|
14
|
+
<path
|
|
15
|
+
d="M20 18v-4h-3v1h-2v-1H9v1H7v-1H4v4h16M6.33 8l-1.74 4H7v-1h2v1h6v-1h2v1h2.41l-1.74-4H6.33M9 5v1h6V5H9m12.84 7.61c.1.22.16.48.16.8V18c0 .53-.21 1-.6 1.41c-.4.4-.85.59-1.4.59H4c-.55 0-1-.19-1.4-.59C2.21 19 2 18.53 2 18v-4.59c0-.32.06-.58.16-.8L4.5 7.22C4.84 6.41 5.45 6 6.33 6H7V5c0-.55.18-1 .57-1.41C7.96 3.2 8.44 3 9 3h6c.56 0 1.04.2 1.43.59c.39.41.57.86.57 1.41v1h.67c.88 0 1.49.41 1.83 1.22l2.34 5.39z"
|
|
16
|
+
fill="currentColor"
|
|
17
|
+
></path>
|
|
18
|
+
</svg>
|
|
19
|
+
</template>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import './assets/main.css'
|
|
2
|
+
|
|
3
|
+
import { createApp } from 'vue'
|
|
4
|
+
import { createPinia } from 'pinia'
|
|
5
|
+
|
|
6
|
+
import App from './App.vue'
|
|
7
|
+
import router from './router'
|
|
8
|
+
|
|
9
|
+
const app = createApp(App)
|
|
10
|
+
|
|
11
|
+
app.use(createPinia())
|
|
12
|
+
app.use(router)
|
|
13
|
+
|
|
14
|
+
app.mount('#app')
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createRouter, createWebHistory } from 'vue-router'
|
|
2
|
+
import HomeView from '../views/HomeView.vue'
|
|
3
|
+
|
|
4
|
+
const router = createRouter({
|
|
5
|
+
history: createWebHistory(import.meta.env.BASE_URL),
|
|
6
|
+
routes: [
|
|
7
|
+
{
|
|
8
|
+
path: '/',
|
|
9
|
+
name: 'home',
|
|
10
|
+
component: HomeView,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
path: '/about',
|
|
14
|
+
name: 'about',
|
|
15
|
+
// route level code-splitting
|
|
16
|
+
// this generates a separate chunk (About.[hash].js) for this route
|
|
17
|
+
// which is lazy-loaded when the route is visited.
|
|
18
|
+
component: () => import('../views/AboutView.vue'),
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
export default router
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ref, computed } from 'vue'
|
|
2
|
+
import { defineStore } from 'pinia'
|
|
3
|
+
|
|
4
|
+
export const useCounterStore = defineStore('counter', () => {
|
|
5
|
+
const count = ref(0)
|
|
6
|
+
const doubleCount = computed(() => count.value * 2)
|
|
7
|
+
function increment() {
|
|
8
|
+
count.value++
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return { count, doubleCount, increment }
|
|
12
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
|
3
|
+
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
|
|
4
|
+
"exclude": ["src/**/__tests__/*"],
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
// Extra safety for array and object lookups, but may have false positives.
|
|
7
|
+
"noUncheckedIndexedAccess": true,
|
|
8
|
+
|
|
9
|
+
// Path mapping for cleaner imports.
|
|
10
|
+
"paths": {
|
|
11
|
+
"@/*": ["./src/*"]
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
// `vue-tsc --build` produces a .tsbuildinfo file for incremental type-checking.
|
|
15
|
+
// Specified here to keep it out of the root directory.
|
|
16
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// TSConfig for modules that run in Node.js environment via either transpilation or type-stripping.
|
|
2
|
+
{
|
|
3
|
+
"extends": "@tsconfig/node24/tsconfig.json",
|
|
4
|
+
"include": [
|
|
5
|
+
"vite.config.*",
|
|
6
|
+
"vitest.config.*",
|
|
7
|
+
"cypress.config.*",
|
|
8
|
+
"playwright.config.*",
|
|
9
|
+
"eslint.config.*"
|
|
10
|
+
],
|
|
11
|
+
"compilerOptions": {
|
|
12
|
+
// Most tools use transpilation instead of Node.js's native type-stripping.
|
|
13
|
+
// Bundler mode provides a smoother developer experience.
|
|
14
|
+
"module": "preserve",
|
|
15
|
+
"moduleResolution": "bundler",
|
|
16
|
+
"allowImportingTsExtensions": true,
|
|
17
|
+
|
|
18
|
+
// Include Node.js types and avoid accidentally including other `@types/*` packages.
|
|
19
|
+
"types": ["node"],
|
|
20
|
+
|
|
21
|
+
// Disable emitting output during `vue-tsc --build`, which is used for type-checking only.
|
|
22
|
+
"noEmit": true,
|
|
23
|
+
|
|
24
|
+
// `vue-tsc --build` produces a .tsbuildinfo file for incremental type-checking.
|
|
25
|
+
// Specified here to keep it out of the root directory.
|
|
26
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { fileURLToPath, URL } from 'node:url'
|
|
2
|
+
|
|
3
|
+
import { defineConfig } from 'vite'
|
|
4
|
+
import vue from '@vitejs/plugin-vue'
|
|
5
|
+
import vueDevTools from 'vite-plugin-vue-devtools'
|
|
6
|
+
|
|
7
|
+
// https://vite.dev/config/
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
plugins: [
|
|
10
|
+
vue(),
|
|
11
|
+
vueDevTools(),
|
|
12
|
+
],
|
|
13
|
+
resolve: {
|
|
14
|
+
alias: {
|
|
15
|
+
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { globalIgnores } from 'eslint/config'
|
|
2
|
+
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
|
|
3
|
+
import pluginVue from 'eslint-plugin-vue'
|
|
4
|
+
import pluginPlaywright from 'eslint-plugin-playwright'
|
|
5
|
+
import pluginVitest from '@vitest/eslint-plugin'
|
|
6
|
+
import pluginOxlint from 'eslint-plugin-oxlint'
|
|
7
|
+
import skipFormatting from 'eslint-config-prettier/flat'
|
|
8
|
+
|
|
9
|
+
// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
|
|
10
|
+
// import { configureVueProject } from '@vue/eslint-config-typescript'
|
|
11
|
+
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
|
|
12
|
+
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
|
|
13
|
+
|
|
14
|
+
export default defineConfigWithVueTs(
|
|
15
|
+
{
|
|
16
|
+
name: 'app/files-to-lint',
|
|
17
|
+
files: ['**/*.{vue,ts,mts,tsx}'],
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),
|
|
21
|
+
|
|
22
|
+
...pluginVue.configs['flat/essential'],
|
|
23
|
+
vueTsConfigs.recommended,
|
|
24
|
+
|
|
25
|
+
{
|
|
26
|
+
...pluginPlaywright.configs['flat/recommended'],
|
|
27
|
+
files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'],
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
{
|
|
31
|
+
...pluginVitest.configs.recommended,
|
|
32
|
+
files: ['src/**/__tests__/*'],
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
...pluginOxlint.buildFromOxlintConfigFile('.oxlintrc.json'),
|
|
36
|
+
|
|
37
|
+
skipFormatting,
|
|
38
|
+
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"scripts": {
|
|
3
|
+
"lint": "run-s \"lint:*\"",
|
|
4
|
+
"lint:oxlint": "oxlint . --fix",
|
|
5
|
+
"lint:eslint": "eslint . --fix --cache",
|
|
6
|
+
"format": "oxfmt src/"
|
|
7
|
+
},
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
"@vitest/eslint-plugin": "^1.6.27",
|
|
10
|
+
"@vue/eslint-config-typescript": "^14.9.0",
|
|
11
|
+
"eslint": "^10.10.0",
|
|
12
|
+
"eslint-config-prettier": "^10.1.8",
|
|
13
|
+
"eslint-plugin-oxlint": "~1.82.0",
|
|
14
|
+
"eslint-plugin-playwright": "^2.12.0",
|
|
15
|
+
"eslint-plugin-vue": "~10.11.0",
|
|
16
|
+
"jiti": "^2.7.0",
|
|
17
|
+
"oxfmt": "^0.67.0",
|
|
18
|
+
"oxlint": "~1.82.0",
|
|
19
|
+
"vue-eslint-parser": "^10.4.1"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { test, expect } from '@playwright/test'
|
|
2
|
+
|
|
3
|
+
// See here how to get started:
|
|
4
|
+
// https://playwright.dev/docs/intro
|
|
5
|
+
test('visits the app root url', async ({ page }) => {
|
|
6
|
+
await page.goto('/')
|
|
7
|
+
await expect(page.locator('h1')).toHaveText('You did it!')
|
|
8
|
+
})
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { defineConfig, devices } from '@playwright/test'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Read environment variables from file.
|
|
6
|
+
* https://github.com/motdotla/dotenv
|
|
7
|
+
*/
|
|
8
|
+
// require('dotenv').config();
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* See https://playwright.dev/docs/test-configuration.
|
|
12
|
+
*/
|
|
13
|
+
export default defineConfig({
|
|
14
|
+
testDir: './e2e',
|
|
15
|
+
/* Maximum time one test can run for. */
|
|
16
|
+
timeout: 30 * 1000,
|
|
17
|
+
expect: {
|
|
18
|
+
/**
|
|
19
|
+
* Maximum time expect() should wait for the condition to be met.
|
|
20
|
+
* For example in `await expect(locator).toHaveText();`
|
|
21
|
+
*/
|
|
22
|
+
timeout: 5000,
|
|
23
|
+
},
|
|
24
|
+
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
25
|
+
forbidOnly: !!process.env.CI,
|
|
26
|
+
/* Retry on CI only */
|
|
27
|
+
retries: process.env.CI ? 2 : 0,
|
|
28
|
+
/* Opt out of parallel tests on CI. */
|
|
29
|
+
workers: process.env.CI ? 1 : undefined,
|
|
30
|
+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
31
|
+
reporter: 'html',
|
|
32
|
+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
33
|
+
use: {
|
|
34
|
+
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
|
|
35
|
+
actionTimeout: 0,
|
|
36
|
+
/* Base URL to use in actions like `await page.goto('/')`. */
|
|
37
|
+
baseURL: process.env.CI ? 'http://localhost:4173' : 'http://localhost:5173',
|
|
38
|
+
|
|
39
|
+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
40
|
+
trace: 'on-first-retry',
|
|
41
|
+
|
|
42
|
+
/* Only on CI systems run the tests headless */
|
|
43
|
+
headless: !!process.env.CI,
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
/* Configure projects for major browsers */
|
|
47
|
+
projects: [
|
|
48
|
+
{
|
|
49
|
+
name: 'chromium',
|
|
50
|
+
use: {
|
|
51
|
+
...devices['Desktop Chrome'],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'firefox',
|
|
56
|
+
use: {
|
|
57
|
+
...devices['Desktop Firefox'],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'webkit',
|
|
62
|
+
use: {
|
|
63
|
+
...devices['Desktop Safari'],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
/* Test against mobile viewports. */
|
|
68
|
+
// {
|
|
69
|
+
// name: 'Mobile Chrome',
|
|
70
|
+
// use: {
|
|
71
|
+
// ...devices['Pixel 5'],
|
|
72
|
+
// },
|
|
73
|
+
// },
|
|
74
|
+
// {
|
|
75
|
+
// name: 'Mobile Safari',
|
|
76
|
+
// use: {
|
|
77
|
+
// ...devices['iPhone 12'],
|
|
78
|
+
// },
|
|
79
|
+
// },
|
|
80
|
+
|
|
81
|
+
/* Test against branded browsers. */
|
|
82
|
+
// {
|
|
83
|
+
// name: 'Microsoft Edge',
|
|
84
|
+
// use: {
|
|
85
|
+
// channel: 'msedge',
|
|
86
|
+
// },
|
|
87
|
+
// },
|
|
88
|
+
// {
|
|
89
|
+
// name: 'Google Chrome',
|
|
90
|
+
// use: {
|
|
91
|
+
// channel: 'chrome',
|
|
92
|
+
// },
|
|
93
|
+
// },
|
|
94
|
+
],
|
|
95
|
+
|
|
96
|
+
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
|
|
97
|
+
// outputDir: 'test-results/',
|
|
98
|
+
|
|
99
|
+
/* Run your local dev server before starting the tests */
|
|
100
|
+
webServer: {
|
|
101
|
+
/**
|
|
102
|
+
* Use the dev server by default for faster feedback loop.
|
|
103
|
+
* Use the preview server on CI for more realistic testing.
|
|
104
|
+
* Playwright will re-use the local server if there is already a dev-server running.
|
|
105
|
+
*/
|
|
106
|
+
command: process.env.CI ? 'npm run preview' : 'npm run dev',
|
|
107
|
+
port: process.env.CI ? 4173 : 5173,
|
|
108
|
+
reuseExistingServer: !process.env.CI,
|
|
109
|
+
},
|
|
110
|
+
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { mount } from '@vue/test-utils'
|
|
4
|
+
import HelloWorld from '../HelloWorld.vue'
|
|
5
|
+
|
|
6
|
+
describe('HelloWorld', () => {
|
|
7
|
+
it('renders properly', () => {
|
|
8
|
+
const wrapper = mount(HelloWorld, { props: { msg: 'Hello Vitest' } })
|
|
9
|
+
expect(wrapper.text()).toContain('Hello Vitest')
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.app.json",
|
|
3
|
+
|
|
4
|
+
// Override to include only test files and clear exclusions.
|
|
5
|
+
// Application code imported in tests is automatically included via module resolution.
|
|
6
|
+
"include": ["src/**/__tests__/*", "env.d.ts"],
|
|
7
|
+
"exclude": [],
|
|
8
|
+
|
|
9
|
+
"compilerOptions": {
|
|
10
|
+
// Vitest runs in a different environment than the application code.
|
|
11
|
+
// Adjust lib and types accordingly.
|
|
12
|
+
"lib": [],
|
|
13
|
+
"types": ["node", "jsdom"],
|
|
14
|
+
|
|
15
|
+
// `vue-tsc --build` produces a .tsbuildinfo file for incremental type-checking.
|
|
16
|
+
// Specified here to keep it out of the root directory.
|
|
17
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
import { mergeConfig, defineConfig, configDefaults } from 'vitest/config'
|
|
3
|
+
import viteConfig from './vite.config.ts'
|
|
4
|
+
|
|
5
|
+
export default mergeConfig(
|
|
6
|
+
viteConfig,
|
|
7
|
+
defineConfig({
|
|
8
|
+
test: {
|
|
9
|
+
environment: 'jsdom',
|
|
10
|
+
exclude: [...configDefaults.exclude, 'e2e/**'],
|
|
11
|
+
root: fileURLToPath(new URL('./', import.meta.url)),
|
|
12
|
+
},
|
|
13
|
+
}),
|
|
14
|
+
)
|