@component-hook/create-app 1.0.4 → 1.1.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.
Files changed (55) hide show
  1. package/README.md +106 -82
  2. package/dist/index.js +35 -18
  3. package/package.json +1 -1
  4. package/template-vue/.github/actions/setup-environment/action.yml +45 -45
  5. package/template-vue/.github/renovate.json +12 -12
  6. package/template-vue/.github/workflows/ci.yml +22 -22
  7. package/template-vue/.github/workflows/deploy.yml +27 -27
  8. package/template-vue/.github/workflows/preview.yml +17 -17
  9. package/template-vue/.gitlab/setup.yml +18 -18
  10. package/template-vue/.husky/commit-msg +3 -3
  11. package/template-vue/.husky/pre-commit +3 -3
  12. package/template-vue/.vscode/extensions.json +10 -10
  13. package/template-vue/.vscode/settings.json +27 -27
  14. package/template-vue/LICENSE +21 -21
  15. package/template-vue/README.md.art +81 -100
  16. package/template-vue/_gitignore +38 -38
  17. package/template-vue/_gitlab-ci.yml +22 -22
  18. package/template-vue/index.html.art +28 -26
  19. package/template-vue/lint-staged.config.js +2 -0
  20. package/template-vue/package.json +71 -73
  21. package/template-vue/playwright.config.ts +12 -23
  22. package/template-vue/postcss.config.js +11 -10
  23. package/template-vue/src/__tests__/e2e/{IndexPage.spec.ts → home.spec.ts} +9 -5
  24. package/template-vue/src/__tests__/setup/unit-test.ts +1 -1
  25. package/template-vue/src/__tests__/unit/components/{indexPage → home}/HelloWorld.test.ts +3 -3
  26. package/template-vue/src/__tests__/unit/render/index.ts +4 -4
  27. package/template-vue/src/components/svg-icon/index.ts +1 -0
  28. package/template-vue/src/locales/en-US.json +3 -3
  29. package/template-vue/src/locales/zh-TW.json +3 -3
  30. package/template-vue/src/main.ts +6 -7
  31. package/template-vue/src/{components/indexPage → pages/home/components}/HelloWorld.vue +3 -8
  32. package/template-vue/src/pages/{IndexPage.vue → home/index.vue} +14 -3
  33. package/template-vue/src/router/index.ts +2 -2
  34. package/template-vue/src/stores/modules/{config.ts → config.ts.art} +1 -1
  35. package/template-vue/src/styles/base.css +48 -0
  36. package/template-vue/src/styles/common/all.css +1 -0
  37. package/template-vue/src/styles/common/button.css +15 -0
  38. package/template-vue/src/styles/index.css +3 -0
  39. package/template-vue/src/styles/tailwind.css +1 -0
  40. package/template-vue/src/vite-env.d.ts +13 -12
  41. package/template-vue/tsconfig.app.json +13 -13
  42. package/template-vue/tsconfig.json +14 -14
  43. package/template-vue/tsconfig.node.json +12 -12
  44. package/template-vue/tsconfig.vitest.json +8 -8
  45. package/template-vue/vite.config.ts +12 -11
  46. package/template-vue/vitest.config.ts +1 -1
  47. package/template-vue/public/mockServiceWorker.js +0 -307
  48. package/template-vue/src/components.d.ts +0 -14
  49. package/template-vue/src/styles/common/all.postcss +0 -1
  50. package/template-vue/src/styles/common/button.postcss +0 -12
  51. package/template-vue/src/styles/index.postcss +0 -1
  52. package/template-vue/src/styles/tailwind.postcss +0 -39
  53. package/template-vue/tailwind.config.js +0 -20
  54. /package/template-vue/src/assets/images/{svgIcons → svg-icons}/vue.svg +0 -0
  55. /package/template-vue/src/components/{common/SvgIcon.vue → svg-icon/src/index.vue} +0 -0
@@ -24,37 +24,26 @@ export default defineConfig({
24
24
  projects: [
25
25
  {
26
26
  name: 'chromium',
27
- use: { ...devices['Desktop Chrome'] },
27
+ use: {
28
+ browserName: 'chromium',
29
+ ...devices['Macbook Pro'],
30
+ },
28
31
  },
29
32
 
30
33
  {
31
34
  name: 'firefox',
32
- use: { ...devices['Desktop Firefox'] },
35
+ use: {
36
+ browserName: 'firefox',
37
+ ...devices['Macbook 11'],
38
+ },
33
39
  },
34
40
 
35
41
  {
36
42
  name: 'webkit',
37
- use: { ...devices['Desktop Safari'] },
43
+ use: {
44
+ browserName: 'webkit',
45
+ ...devices['iPhone SE'],
46
+ },
38
47
  },
39
-
40
- /* Test against mobile viewports. */
41
- // {
42
- // name: 'Mobile Chrome',
43
- // use: { ...devices['Pixel 5'] },
44
- // },
45
- // {
46
- // name: 'Mobile Safari',
47
- // use: { ...devices['iPhone 12'] },
48
- // },
49
-
50
- /* Test against branded browsers. */
51
- // {
52
- // name: 'Microsoft Edge',
53
- // use: { ...devices['Desktop Edge'], channel: 'msedge' },
54
- // },
55
- // {
56
- // name: 'Google Chrome',
57
- // use: { ...devices['Desktop Chrome'], channel: 'chrome' },
58
- // },
59
48
  ],
60
49
  });
@@ -1,14 +1,15 @@
1
+ import autoprefixer from 'autoprefixer';
2
+ import cssnano from 'cssnano';
3
+ import postcssPxtorem from 'postcss-pxtorem';
4
+
1
5
  export default {
2
- plugins: {
3
- 'postcss-import': {},
4
- 'tailwindcss/nesting': {},
5
- 'postcss-nesting': {},
6
- tailwindcss: {},
7
- autoprefixer: {},
8
- 'postcss-pxtorem': {
6
+ plugins: [
7
+ autoprefixer(),
8
+ postcssPxtorem({
9
9
  rootValue: 16,
10
10
  propList: ['*'],
11
- },
12
- ...(process.env.NODE_ENV === 'production' ? { cssnano: {} } : {}),
13
- },
11
+ selectorBlackList: ['norem'],
12
+ }),
13
+ ...(process.env.NODE_ENV === 'production' ? [cssnano({ preset: 'default' })] : []),
14
+ ],
14
15
  };
@@ -1,4 +1,4 @@
1
- import { test, expect } from '@playwright/test';
1
+ import { expect, test } from '@playwright/test';
2
2
 
3
3
  test.beforeEach(async ({ page }) => {
4
4
  await page.goto('/');
@@ -7,14 +7,16 @@ test.beforeEach(async ({ page }) => {
7
7
  test('click Vite logo open Vite official website blank tab', async ({ page, context }) => {
8
8
  await page.getByRole('link', { name: 'Vite logo' }).click();
9
9
  const newPage = await context.waitForEvent('page');
10
- await newPage.waitForLoadState();
10
+
11
+ await newPage.waitForLoadState('load');
11
12
  await expect(newPage).toHaveTitle('Vite | Next Generation Frontend Tooling');
12
13
  });
13
14
 
14
15
  test('click Vue logo open Vue official website blank tab', async ({ page, context }) => {
15
16
  await page.getByTitle('#icon-vue').click();
16
17
  const newPage = await context.waitForEvent('page');
17
- await newPage.waitForLoadState();
18
+
19
+ await newPage.waitForLoadState('load');
18
20
  await expect(newPage).toHaveTitle('Vue.js - The Progressive JavaScript Framework | Vue.js');
19
21
  });
20
22
 
@@ -35,14 +37,16 @@ test('locale change interact', async ({ page }) => {
35
37
  test('click create-vue link open Vue quick start blank tab', async ({ page, context }) => {
36
38
  await page.getByRole('link', { name: 'create-vue' }).click();
37
39
  const newPage = await context.waitForEvent('page');
38
- await newPage.waitForLoadState();
40
+
41
+ await newPage.waitForLoadState('load');
39
42
  await expect(newPage).toHaveTitle('Quick Start | Vue.js');
40
43
  });
41
44
 
42
45
  test('click Volar link open language-tools github blank tab', async ({ page, context }) => {
43
46
  await page.getByRole('link', { name: 'Volar' }).click();
44
47
  const newPage = await context.waitForEvent('page');
45
- await newPage.waitForLoadState();
48
+
49
+ await newPage.waitForLoadState('load');
46
50
  await expect(newPage).toHaveTitle(
47
51
  'GitHub - vuejs/language-tools: ⚡ High-performance Vue language tooling based-on Volar.js',
48
52
  );
@@ -1,5 +1,5 @@
1
- import '@testing-library/jest-dom';
2
1
  import { mswServer } from '@/mocks/server';
2
+ import '@testing-library/jest-dom';
3
3
 
4
4
  beforeAll(() => mswServer.listen());
5
5
  afterEach(() => mswServer.resetHandlers());
@@ -1,9 +1,9 @@
1
- import { screen } from '@testing-library/vue';
2
1
  import userEvent from '@testing-library/user-event';
3
- import HelloWorld from '@/components/indexPage/HelloWorld.vue';
2
+ import { screen } from '@testing-library/vue';
4
3
  import { renderComponent } from '@/__tests__/unit/render';
5
- import { useConfigStore } from '@/stores';
4
+ import HelloWorld from '@/pages/home/components/HelloWorld.vue';
6
5
  import i18n from '@/plugins/i18n';
6
+ import { useConfigStore } from '@/stores';
7
7
 
8
8
  describe('HelloWorld component', () => {
9
9
  const { t } = i18n.global;
@@ -1,10 +1,10 @@
1
- import type { Component } from 'vue';
2
- import { createRouter, createMemoryHistory } from 'vue-router';
3
1
  import { render } from '@testing-library/vue';
4
- import type { RenderOptions } from '@testing-library/vue/types';
5
- import { setActivePinia, createPinia } from 'pinia';
2
+ import { createPinia, setActivePinia } from 'pinia';
3
+ import { createMemoryHistory, createRouter } from 'vue-router';
6
4
  import i18n from '@/plugins/i18n';
7
5
  import { routes } from '@/router';
6
+ import type { RenderOptions } from '@testing-library/vue/types';
7
+ import type { Component } from 'vue';
8
8
 
9
9
  interface RenderComponentOptions extends RenderOptions<unknown> {
10
10
  provide?: Record<PropertyKey, unknown>;
@@ -0,0 +1 @@
1
+ export { default as SvgIcon } from './src/index.vue';
@@ -1,3 +1,3 @@
1
- {
2
- "language": "English"
3
- }
1
+ {
2
+ "language": "English"
3
+ }
@@ -1,3 +1,3 @@
1
- {
2
- "language": "中文"
3
- }
1
+ {
2
+ "language": "中文"
3
+ }
@@ -1,15 +1,14 @@
1
- import { createApp } from 'vue';
2
1
  import { createPinia } from 'pinia';
3
2
  import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
4
- import 'virtual:svg-icons-register';
3
+ import { createApp } from 'vue';
4
+ import i18NPlugin from '@/plugins/i18n';
5
5
 
6
- import '@/styles/tailwind.postcss';
7
- import '@/styles/index.postcss';
8
- import App from './App.vue';
9
6
  import router from '@/router';
10
- import i18NPlugin from '@/plugins/i18n';
7
+ import App from './App.vue';
8
+ import 'virtual:svg-icons-register';
9
+ import '@/styles/index.css';
11
10
 
12
- if (process.env.NODE_ENV === 'mockServiceWorker') {
11
+ if (import.meta.env.VITE_APP_MOCK === 'service-worker') {
13
12
  const { worker } = await import('@/mocks/browser');
14
13
 
15
14
  worker.start();
@@ -18,12 +18,7 @@ function changeLocale() {
18
18
  <h1>{{ msg }}</h1>
19
19
 
20
20
  <div class="p-8">
21
- <button
22
- type="button"
23
- @click="count++"
24
- >
25
- count is {{ count }}
26
- </button>
21
+ <button @click="count++">count is {{ count }}</button>
27
22
  </div>
28
23
 
29
24
  <p>
@@ -52,8 +47,8 @@ function changeLocale() {
52
47
  </button>
53
48
  </template>
54
49
 
55
- <style lang="postcss" scoped>
50
+ <style lang="css" scoped>
56
51
  .read-the-docs {
57
- @apply text-[#888];
52
+ color: #888;
58
53
  }
59
54
  </style>
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
- import HelloWorld from '@/components/indexPage/HelloWorld.vue';
2
+ import { SvgIcon } from '@/components/svg-icon';
3
+ import HelloWorld from './components/HelloWorld.vue';
3
4
  </script>
4
5
 
5
6
  <template>
@@ -24,11 +25,21 @@ import HelloWorld from '@/components/indexPage/HelloWorld.vue';
24
25
  />
25
26
  </a>
26
27
  </div>
28
+
27
29
  <hello-world msg="Vite + Vue" />
28
30
  </template>
29
31
 
30
- <style lang="postcss" scoped>
32
+ <style lang="css" scoped>
31
33
  .logo {
32
- @apply w-24 h-24 p-6 mx-auto will-change-[filter] transition-[filter] duration-300 hover:drop-shadow-[0_0_2em_#646cffaa];
34
+ width: 96px;
35
+ height: 96px;
36
+ margin: 0 auto;
37
+ padding: 24px;
38
+ will-change: filter;
39
+ transition: filter 300ms;
40
+
41
+ &:hover {
42
+ filter: drop-shadow(0 0 2em #646cffaa);
43
+ }
33
44
  }
34
45
  </style>
@@ -1,5 +1,5 @@
1
1
  import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router';
2
- import IndexPage from '@/pages/IndexPage.vue';
2
+ import HomePage from '@/pages/home/index.vue';
3
3
 
4
4
  export const routes: Array<RouteRecordRaw> = [
5
5
  {
@@ -8,7 +8,7 @@ export const routes: Array<RouteRecordRaw> = [
8
8
  },
9
9
  {
10
10
  path: '/',
11
- component: IndexPage,
11
+ component: HomePage,
12
12
  meta: {
13
13
  title: 'Vue3 Coding Standards',
14
14
  },
@@ -9,7 +9,7 @@ const defaultState = {
9
9
  version: versionString,
10
10
  };
11
11
 
12
- export default defineStore('coding-standards-config', {
12
+ export default defineStore('{{projectName}}-config', {
13
13
  state: () => defaultState,
14
14
  getters: {},
15
15
  actions: {},
@@ -0,0 +1,48 @@
1
+ :root {
2
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3
+ line-height: 1.5;
4
+ font-weight: 400;
5
+
6
+ color-scheme: light dark;
7
+ color: rgba(255, 255, 255, 0.87);
8
+ background-color: #242424;
9
+
10
+ font-synthesis: none;
11
+ text-rendering: optimizeLegibility;
12
+ -webkit-font-smoothing: antialiased;
13
+ -moz-osx-font-smoothing: grayscale;
14
+ -webkit-text-size-adjust: 100%;
15
+ }
16
+
17
+ @media (prefers-color-scheme: light) {
18
+ :root {
19
+ background-color: #ffffff;
20
+ color: #213547;
21
+ }
22
+ }
23
+
24
+ body {
25
+ margin: 0;
26
+ display: flex;
27
+ place-items: center;
28
+ min-width: 320px;
29
+ min-height: 100vh;
30
+ }
31
+
32
+ #app {
33
+ max-width: 80rem;
34
+ margin: auto;
35
+ padding: 32px;
36
+ text-align: center;
37
+ }
38
+
39
+ a {
40
+ font-weight: 500;
41
+ text-decoration-color: inherit;
42
+ color: #646cff;
43
+ transition: color 150ms;
44
+
45
+ &:hover {
46
+ color: #535bf2;
47
+ }
48
+ }
@@ -0,0 +1 @@
1
+ @import './button.css';
@@ -0,0 +1,15 @@
1
+ button {
2
+ border-radius: 8px;
3
+ padding: 8px;
4
+ border-width: 1px;
5
+ border-color: transparent;
6
+ transition-property: border-color;
7
+ transition-duration: 300ms;
8
+ &:hover {
9
+ border-color: #646cff;
10
+ }
11
+ &:focus {
12
+ outline-width: 4px;
13
+ outline-color: -webkit-focus-ring-color;
14
+ }
15
+ }
@@ -0,0 +1,3 @@
1
+ @import './tailwind.css';
2
+ @import './base.css';
3
+ @import './common/all.css';
@@ -0,0 +1 @@
1
+ @import 'tailwindcss';
@@ -1,12 +1,13 @@
1
- /// <reference types="vite/client" />
2
-
3
- declare module '*.vue' {
4
- import { DefineComponent } from 'vue';
5
- const component: DefineComponent<any, {}, any>;
6
- export default component;
7
- }
8
-
9
- interface ImportMetaEnv extends Readonly<Record<string, string>> {
10
- readonly VITE_APP_VERSION: string;
11
- readonly VITE_APP_BUILD_EPOCH?: string;
12
- }
1
+ /// <reference types="vite/client" />
2
+
3
+ declare module '*.vue' {
4
+ import { DefineComponent } from 'vue';
5
+ const component: DefineComponent<any, {}, any>;
6
+ export default component;
7
+ }
8
+
9
+ interface ImportMetaEnv extends Readonly<Record<string, string>> {
10
+ readonly VITE_APP_VERSION: string;
11
+ readonly VITE_APP_BUILD_EPOCH?: string;
12
+ readonly VITE_APP_MOCK?: string;
13
+ }
@@ -1,13 +1,13 @@
1
- {
2
- "extends": "@vue/tsconfig/tsconfig.dom.json",
3
- "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
4
- "exclude": ["src/**/__tests__/*"],
5
- "compilerOptions": {
6
- "composite": true,
7
- "noEmit": true,
8
- "baseUrl": "./",
9
- "paths": {
10
- "@/*": ["src/*"]
11
- }
12
- }
13
- }
1
+ {
2
+ "extends": "@vue/tsconfig/tsconfig.dom.json",
3
+ "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
4
+ "exclude": ["src/**/__tests__/*"],
5
+ "compilerOptions": {
6
+ "composite": true,
7
+ "noEmit": true,
8
+ "baseUrl": "./",
9
+ "paths": {
10
+ "@/*": ["src/*"]
11
+ }
12
+ }
13
+ }
@@ -1,14 +1,14 @@
1
- {
2
- "files": [],
3
- "references": [
4
- {
5
- "path": "./tsconfig.node.json"
6
- },
7
- {
8
- "path": "./tsconfig.app.json"
9
- },
10
- {
11
- "path": "./tsconfig.vitest.json"
12
- }
13
- ]
14
- }
1
+ {
2
+ "files": [],
3
+ "references": [
4
+ {
5
+ "path": "./tsconfig.node.json"
6
+ },
7
+ {
8
+ "path": "./tsconfig.app.json"
9
+ },
10
+ {
11
+ "path": "./tsconfig.vitest.json"
12
+ }
13
+ ]
14
+ }
@@ -1,12 +1,12 @@
1
- {
2
- "extends": "@tsconfig/node22/tsconfig.json",
3
- "compilerOptions": {
4
- "composite": true,
5
- "skipLibCheck": true,
6
- "module": "ESNext",
7
- "moduleResolution": "bundler",
8
- "resolveJsonModule": true,
9
- "types": ["node"]
10
- },
11
- "include": ["vite.config.ts", "package.json", "vitest.config.ts", "playwright.config.ts"]
12
- }
1
+ {
2
+ "extends": "@tsconfig/node22/tsconfig.json",
3
+ "compilerOptions": {
4
+ "composite": true,
5
+ "skipLibCheck": true,
6
+ "module": "ESNext",
7
+ "moduleResolution": "bundler",
8
+ "resolveJsonModule": true,
9
+ "types": ["node"]
10
+ },
11
+ "include": ["vite.config.ts", "package.json", "vitest.config.ts", "playwright.config.ts"]
12
+ }
@@ -1,8 +1,8 @@
1
- {
2
- "extends": "./tsconfig.app.json",
3
- "exclude": [],
4
- "compilerOptions": {
5
- "composite": true,
6
- "types": ["node", "vitest/globals"]
7
- }
8
- }
1
+ {
2
+ "extends": "./tsconfig.app.json",
3
+ "exclude": [],
4
+ "compilerOptions": {
5
+ "composite": true,
6
+ "types": ["node", "vitest/globals"]
7
+ }
8
+ }
@@ -1,15 +1,19 @@
1
- import { fileURLToPath, URL } from 'node:url';
2
1
  import { dirname, resolve } from 'node:path';
3
- import { defineConfig } from 'vite';
4
- import vue from '@vitejs/plugin-vue';
5
- import Components from 'unplugin-vue-components/vite';
2
+ import { fileURLToPath, URL } from 'node:url';
6
3
  import vueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
7
- import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
4
+ import tailwindcss from '@tailwindcss/vite';
5
+ import vue from '@vitejs/plugin-vue';
8
6
  import { visualizer } from 'rollup-plugin-visualizer';
7
+ import { defineConfig } from 'vite';
8
+ import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
9
9
  import packageJson from './package.json' with { type: 'json' };
10
10
 
11
11
  process.env.VITE_APP_VERSION = packageJson.version;
12
- process.env.NODE_ENV = process.env.MOCK ? 'mockServiceWorker' : process.env.NODE_ENV;
12
+
13
+ if (process.env.MOCK) {
14
+ process.env.VITE_APP_MOCK = 'service-worker';
15
+ }
16
+
13
17
  if (process.env.NODE_ENV === 'production') {
14
18
  process.env.VITE_APP_BUILD_EPOCH = Date.now().toString();
15
19
  }
@@ -18,15 +22,12 @@ export default defineConfig({
18
22
  base: './',
19
23
  plugins: [
20
24
  vue(),
21
- Components({
22
- dirs: ['src/components/common'],
23
- dts: 'src/components.d.ts',
24
- }),
25
+ tailwindcss(),
25
26
  vueI18nPlugin({
26
27
  include: resolve(dirname(fileURLToPath(import.meta.url)), 'src/locales/**'),
27
28
  }),
28
29
  createSvgIconsPlugin({
29
- iconDirs: [resolve(process.cwd(), 'src/assets/images/svgIcons')],
30
+ iconDirs: [resolve(process.cwd(), 'src/assets/images/svg-icons')],
30
31
  }),
31
32
  visualizer({ gzipSize: true }),
32
33
  ],
@@ -1,6 +1,6 @@
1
1
  /// <reference types="vitest" />
2
2
  import { fileURLToPath, URL } from 'node:url';
3
- import { mergeConfig, defineConfig } from 'vitest/config';
3
+ import { defineConfig, mergeConfig } from 'vitest/config';
4
4
  import viteConfig from './vite.config';
5
5
 
6
6
  export default mergeConfig(