@component-hook/create-app 1.5.0 → 1.6.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/README.md +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +86 -80
- package/package.json +12 -12
- package/template-react/.vscode/extensions.json +9 -0
- package/template-react/.vscode/settings.json +18 -0
- package/template-react/README.md.art +85 -0
- package/template-react/e2e/home.spec.ts +40 -0
- package/template-react/eslint.config.js +18 -0
- package/template-react/index.html.art +13 -0
- package/template-react/lint-staged.config.js +6 -0
- package/template-react/package.json +70 -0
- package/template-react/public/vite.svg +1 -0
- package/template-react/src/App.tsx +6 -0
- package/template-react/src/assets/svg-icons/react.svg +1 -0
- package/template-react/src/components/common/index.ts +1 -0
- package/template-react/src/components/common/svg-icon/index.ts +1 -0
- package/template-react/src/components/common/svg-icon/src/index.tsx +23 -0
- package/template-react/src/main.tsx +26 -0
- package/template-react/src/mocks/browser.ts +4 -0
- package/template-react/src/mocks/handlers/index.ts +1 -0
- package/template-react/src/mocks/server.ts +4 -0
- package/template-react/src/pages/home/components/hello-world/index.test.tsx +45 -0
- package/template-react/src/pages/home/components/hello-world/index.tsx +49 -0
- package/template-react/src/pages/home/index.module.css +8 -0
- package/template-react/src/pages/home/index.test.tsx +19 -0
- package/template-react/src/pages/home/index.tsx +37 -0
- package/template-react/src/plugins/i18n/index.ts +19 -0
- package/template-react/src/plugins/i18n/locales/en-US.json +3 -0
- package/template-react/src/plugins/i18n/locales/zh-TW.json +3 -0
- package/template-react/src/router/index.tsx +22 -0
- package/template-react/src/stores/constants.ts +1 -0
- package/template-react/src/stores/index.ts +1 -0
- package/template-react/src/stores/middleware.ts +17 -0
- package/template-react/src/stores/modules/config.ts +27 -0
- package/template-react/src/styles/base.css +68 -0
- package/template-react/src/styles/common/all.css +1 -0
- package/template-react/src/styles/common/button.css +26 -0
- package/template-react/src/styles/index.css +3 -0
- package/template-react/src/styles/tailwind.css +14 -0
- package/template-react/src/test-utils/index.tsx +15 -0
- package/template-react/src/vite-env.d.ts +9 -0
- package/template-react/tsconfig.app.json +32 -0
- package/template-react/tsconfig.vitest.json +10 -0
- package/template-react/vite.config.ts +40 -0
- package/template-react/vitest.config.ts +18 -0
- package/template-react/vitest.setup.ts +13 -0
- package/template-shared/.browserslistrc +10 -0
- package/template-shared/.github/actions/setup-environment/action.yml +21 -0
- package/template-shared/.github/renovate.json +14 -0
- package/template-shared/.github/workflows/ci.yml +22 -0
- package/template-shared/.github/workflows/deploy.yml +27 -0
- package/template-shared/.github/workflows/preview.yml +17 -0
- package/template-shared/.gitlab/setup.yml +18 -0
- package/template-shared/.husky/commit-msg +1 -0
- package/template-shared/.husky/pre-commit +1 -0
- package/{LICENSE → template-shared/LICENSE} +1 -1
- package/template-shared/_gitignore +32 -0
- package/template-shared/_gitlab-ci.yml +22 -0
- package/template-shared/commitlint.config.js +3 -0
- package/template-shared/playwright.config.ts +49 -0
- package/template-shared/postcss.config.js +15 -0
- package/template-shared/prettier.config.js +13 -0
- package/template-shared/scripts/build-info/index.ts +21 -0
- package/template-shared/tsconfig.json +14 -0
- package/template-shared/tsconfig.node.json +12 -0
- package/template-vue/.vscode/extensions.json +10 -0
- package/template-vue/.vscode/settings.json +18 -0
- package/template-vue/README.md.art +81 -0
- package/template-vue/e2e/home.spec.ts +59 -0
- package/template-vue/eslint.config.js +18 -0
- package/template-vue/index.html.art +28 -0
- package/template-vue/lint-staged.config.js +6 -0
- package/template-vue/package.json +69 -0
- package/template-vue/public/vite.svg +1 -0
- package/template-vue/src/App.vue +7 -0
- package/template-vue/src/assets/svg-icons/vue.svg +1 -0
- package/template-vue/src/components/common/index.ts +1 -0
- package/template-vue/src/components/common/svg-icon/index.ts +1 -0
- package/template-vue/src/components/common/svg-icon/src/index.vue +29 -0
- package/template-vue/src/locales/en-US.json +3 -0
- package/template-vue/src/locales/zh-TW.json +3 -0
- package/template-vue/src/main.ts +21 -0
- package/template-vue/src/mocks/browser.ts +4 -0
- package/template-vue/src/mocks/handlers/index.ts +1 -0
- package/template-vue/src/mocks/server.ts +4 -0
- package/template-vue/src/pages/home/components/HelloWorld.test.ts +57 -0
- package/template-vue/src/pages/home/components/HelloWorld.vue +54 -0
- package/template-vue/src/pages/home/index.test.ts +17 -0
- package/template-vue/src/pages/home/index.vue +46 -0
- package/template-vue/src/plugins/i18n.ts +11 -0
- package/template-vue/src/router/index.ts +23 -0
- package/template-vue/src/stores/constants.ts.art +1 -0
- package/template-vue/src/stores/index.ts +15 -0
- package/template-vue/src/stores/modules/config.ts +20 -0
- package/template-vue/src/styles/base.css +59 -0
- package/template-vue/src/styles/common/all.css +1 -0
- package/template-vue/src/styles/common/button.css +15 -0
- package/template-vue/src/styles/index.css +3 -0
- package/template-vue/src/styles/tailwind.css +1 -0
- package/template-vue/src/test-utils/index.ts +33 -0
- package/template-vue/src/vite-env.d.ts +9 -0
- package/template-vue/tsconfig.app.json +12 -0
- package/template-vue/tsconfig.vitest.json +10 -0
- package/template-vue/vite.config.ts +46 -0
- package/template-vue/vitest.config.ts +18 -0
- package/template-vue/vitest.setup.ts +12 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { HelloWorld } from '@/pages/home/components/hello-world';
|
|
4
|
+
import i18n from '@/plugins/i18n';
|
|
5
|
+
import { useConfigStore } from '@/stores';
|
|
6
|
+
import { renderComponent } from '@/test-utils';
|
|
7
|
+
|
|
8
|
+
describe('home page HelloWorld component', () => {
|
|
9
|
+
const { t } = i18n;
|
|
10
|
+
|
|
11
|
+
it('renders the correct content', () => {
|
|
12
|
+
const title = 'Hello World!';
|
|
13
|
+
const { appMeta } = useConfigStore.getState();
|
|
14
|
+
|
|
15
|
+
renderComponent(<HelloWorld title={title} />);
|
|
16
|
+
expect(screen.getByRole('heading', { name: title })).toBeInTheDocument();
|
|
17
|
+
expect(screen.getByRole('button', { name: /count is 0/i })).toBeInTheDocument();
|
|
18
|
+
expect(screen.getByText(/edit/i)).toBeInTheDocument();
|
|
19
|
+
expect(screen.getByText(/src\/app\.tsx/i)).toBeInTheDocument();
|
|
20
|
+
expect(screen.getByText(/save to test hmr/i)).toBeInTheDocument();
|
|
21
|
+
expect(screen.getByText(/click on the vite and react logos to learn more/i)).toBeInTheDocument();
|
|
22
|
+
expect(screen.getByText(`${appMeta.version} - Built at: ${appMeta.builtAt.toLocaleString()}`)).toBeInTheDocument();
|
|
23
|
+
expect(screen.getByRole('button', { name: t('language') })).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('count button interact', async () => {
|
|
27
|
+
renderComponent(<HelloWorld />);
|
|
28
|
+
const countButton = screen.getByRole('button', { name: /count is 0/i });
|
|
29
|
+
|
|
30
|
+
await userEvent.click(countButton);
|
|
31
|
+
expect(countButton).toHaveTextContent(/count is 1/i);
|
|
32
|
+
await userEvent.click(countButton);
|
|
33
|
+
await userEvent.click(countButton);
|
|
34
|
+
expect(countButton).toHaveTextContent(/count is 3/i);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('locale change interact', async () => {
|
|
38
|
+
renderComponent(<HelloWorld />);
|
|
39
|
+
const localeButton = screen.getByRole('button', { name: t('language') });
|
|
40
|
+
|
|
41
|
+
expect(localeButton).toHaveTextContent('English');
|
|
42
|
+
await userEvent.click(localeButton);
|
|
43
|
+
expect(localeButton).toHaveTextContent('中文');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { useConfigStore } from '@/stores';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
title?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function HelloWorld({ title = '' }: Props) {
|
|
10
|
+
const [count, setCount] = useState(0);
|
|
11
|
+
const { t, i18n } = useTranslation();
|
|
12
|
+
const { appMeta } = useConfigStore();
|
|
13
|
+
|
|
14
|
+
function changeLanguage() {
|
|
15
|
+
const language = i18n.language === 'zh-TW' ? 'en-US' : 'zh-TW';
|
|
16
|
+
|
|
17
|
+
i18n.changeLanguage(language);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<h1>{title}</h1>
|
|
23
|
+
|
|
24
|
+
<div className="p-8">
|
|
25
|
+
<button
|
|
26
|
+
className="mb-4"
|
|
27
|
+
onClick={() => setCount(originCount => originCount + 1)}
|
|
28
|
+
>
|
|
29
|
+
count is {count}
|
|
30
|
+
</button>
|
|
31
|
+
<p>
|
|
32
|
+
Edit <code>src/App.tsx</code> and save to test HMR
|
|
33
|
+
</p>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<p className="text-[#888]">Click on the Vite and React logos to learn more</p>
|
|
37
|
+
<p className="mt-1 text-[#888]">
|
|
38
|
+
{appMeta.version} - Built at: {appMeta.builtAt.toLocaleString()}
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
<button
|
|
42
|
+
className="my-4"
|
|
43
|
+
onClick={() => changeLanguage()}
|
|
44
|
+
>
|
|
45
|
+
{t('language')}
|
|
46
|
+
</button>
|
|
47
|
+
</>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { screen } from '@testing-library/react';
|
|
2
|
+
import { Home } from '@/pages/home';
|
|
3
|
+
import { renderComponent } from '@/test-utils';
|
|
4
|
+
|
|
5
|
+
describe('home page', () => {
|
|
6
|
+
it('renders the correct content', () => {
|
|
7
|
+
renderComponent(<Home />);
|
|
8
|
+
const viteLink = screen.getByRole('link', { name: /vite logo/i });
|
|
9
|
+
const reactLink = screen.getByLabelText(/react link/i);
|
|
10
|
+
|
|
11
|
+
expect(viteLink).toHaveAttribute('href', 'https://vite.dev');
|
|
12
|
+
expect(viteLink).toHaveAttribute('rel', 'noreferrer');
|
|
13
|
+
expect(viteLink).toHaveAttribute('target', '_blank');
|
|
14
|
+
|
|
15
|
+
expect(reactLink).toHaveAttribute('href', 'https://react.dev');
|
|
16
|
+
expect(reactLink).toHaveAttribute('rel', 'noreferrer');
|
|
17
|
+
expect(reactLink).toHaveAttribute('target', '_blank');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { SvgIcon } from '@/components/common';
|
|
2
|
+
import { HelloWorld } from './components/hello-world';
|
|
3
|
+
import styles from './index.module.css';
|
|
4
|
+
import viteLogo from '/vite.svg';
|
|
5
|
+
|
|
6
|
+
export function Home() {
|
|
7
|
+
return (
|
|
8
|
+
<>
|
|
9
|
+
<div>
|
|
10
|
+
<a
|
|
11
|
+
href="https://vite.dev"
|
|
12
|
+
target="_blank"
|
|
13
|
+
rel="noreferrer"
|
|
14
|
+
>
|
|
15
|
+
<img
|
|
16
|
+
src={viteLogo}
|
|
17
|
+
className={`${styles.logo} hover:filter-[drop-shadow(0_0_2em_#646cffaa)]`}
|
|
18
|
+
alt="Vite logo"
|
|
19
|
+
/>
|
|
20
|
+
</a>
|
|
21
|
+
<a
|
|
22
|
+
href="https://react.dev"
|
|
23
|
+
target="_blank"
|
|
24
|
+
rel="noreferrer"
|
|
25
|
+
aria-label="React link"
|
|
26
|
+
>
|
|
27
|
+
<SvgIcon
|
|
28
|
+
name="react"
|
|
29
|
+
className={`${styles.logo} hover:filter-[drop-shadow(0_0_2em_#61dafbaa)] motion-safe:animate-logo-spin`}
|
|
30
|
+
/>
|
|
31
|
+
</a>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<HelloWorld title="Vite + React" />
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import i18n from 'i18next';
|
|
2
|
+
import { initReactI18next } from 'react-i18next';
|
|
3
|
+
import enUS from './locales/en-US.json' with { type: 'json' };
|
|
4
|
+
import zhTW from './locales/zh-TW.json' with { type: 'json' };
|
|
5
|
+
|
|
6
|
+
function setupI18n() {
|
|
7
|
+
i18n.use(initReactI18next).init({
|
|
8
|
+
lng: navigator.language,
|
|
9
|
+
fallbackLng: 'en-US',
|
|
10
|
+
resources: {
|
|
11
|
+
'zh-TW': { translation: zhTW },
|
|
12
|
+
'en-US': { translation: enUS },
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return i18n;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default setupI18n();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createBrowserRouter, Navigate } from 'react-router-dom';
|
|
2
|
+
import { Home } from '@/pages/home';
|
|
3
|
+
|
|
4
|
+
export const routes = [
|
|
5
|
+
{
|
|
6
|
+
path: '*',
|
|
7
|
+
element: (
|
|
8
|
+
<Navigate
|
|
9
|
+
to="/"
|
|
10
|
+
replace
|
|
11
|
+
/>
|
|
12
|
+
),
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
path: '/',
|
|
16
|
+
element: <Home />,
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const router = createBrowserRouter(routes);
|
|
21
|
+
|
|
22
|
+
export default router;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const STORAGE_PREFIX = 'react-starter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useConfigStore } from './modules/config';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { create, type StateCreator } from 'zustand';
|
|
2
|
+
import { createJSONStorage, persist, type PersistOptions } from 'zustand/middleware';
|
|
3
|
+
import { STORAGE_PREFIX } from './constants';
|
|
4
|
+
|
|
5
|
+
export function createPersistedStore<T, S = Partial<T>>(
|
|
6
|
+
id: string,
|
|
7
|
+
initializer: StateCreator<T>,
|
|
8
|
+
persistOptions?: Partial<PersistOptions<T, S>>,
|
|
9
|
+
) {
|
|
10
|
+
return create(
|
|
11
|
+
persist<T, [], [], S>(initializer, {
|
|
12
|
+
name: `${STORAGE_PREFIX}-${id}`,
|
|
13
|
+
storage: createJSONStorage(() => localStorage),
|
|
14
|
+
...persistOptions,
|
|
15
|
+
}),
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createPersistedStore } from '../middleware';
|
|
2
|
+
|
|
3
|
+
interface ConfigState {
|
|
4
|
+
appMeta: {
|
|
5
|
+
version: string;
|
|
6
|
+
builtAt: Date;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const versionString = `${import.meta.env.VITE_APP_VERSION}-${import.meta.env.VITE_APP_LAST_COMMIT_HASH}`;
|
|
11
|
+
|
|
12
|
+
const defaultState = {
|
|
13
|
+
appMeta: {
|
|
14
|
+
version: import.meta.env.MODE === 'development' ? `${versionString}-dev` : versionString,
|
|
15
|
+
builtAt: new Date(Number(import.meta.env.VITE_APP_BUILD_EPOCH)),
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const useConfigStore = createPersistedStore<ConfigState>(
|
|
20
|
+
'config',
|
|
21
|
+
() => ({
|
|
22
|
+
...defaultState,
|
|
23
|
+
}),
|
|
24
|
+
{
|
|
25
|
+
partialize: () => ({}),
|
|
26
|
+
},
|
|
27
|
+
);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: 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
|
+
overscroll-behavior: none none;
|
|
11
|
+
touch-action: manipulation;
|
|
12
|
+
user-select: none;
|
|
13
|
+
text-rendering: optimizeLegibility;
|
|
14
|
+
-moz-osx-font-smoothing: grayscale;
|
|
15
|
+
-moz-touch-callout: none;
|
|
16
|
+
-ms-touch-callout: none;
|
|
17
|
+
-webkit-font-smoothing: antialiased;
|
|
18
|
+
-webkit-touch-callout: none;
|
|
19
|
+
-webkit-overflow-scrolling: touch;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
a {
|
|
23
|
+
font-weight: 500;
|
|
24
|
+
color: #646cff;
|
|
25
|
+
text-decoration: inherit;
|
|
26
|
+
|
|
27
|
+
&:hover {
|
|
28
|
+
color: #535bf2;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
body {
|
|
33
|
+
margin: 0;
|
|
34
|
+
display: flex;
|
|
35
|
+
place-items: center;
|
|
36
|
+
min-width: 320px;
|
|
37
|
+
min-height: 100vh;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
img {
|
|
41
|
+
-webkit-touch-callout: none;
|
|
42
|
+
-webkit-user-drag: none;
|
|
43
|
+
user-select: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
h1 {
|
|
47
|
+
font-size: 3.2em;
|
|
48
|
+
line-height: 1.1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#root {
|
|
52
|
+
max-width: 1280px;
|
|
53
|
+
width: 100%;
|
|
54
|
+
margin: 0 auto;
|
|
55
|
+
padding: 2rem;
|
|
56
|
+
text-align: center;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@media (prefers-color-scheme: light) {
|
|
60
|
+
:root {
|
|
61
|
+
color: #213547;
|
|
62
|
+
background-color: #ffffff;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
a:hover {
|
|
66
|
+
color: #747bff;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import './button.css';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
button {
|
|
2
|
+
border-radius: 8px;
|
|
3
|
+
border: 1px solid transparent;
|
|
4
|
+
padding: 0.6em 1.2em;
|
|
5
|
+
font-size: 1em;
|
|
6
|
+
font-weight: 500;
|
|
7
|
+
font-family: inherit;
|
|
8
|
+
background-color: #1a1a1a;
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
transition: border-color 0.25s;
|
|
11
|
+
|
|
12
|
+
&:hover {
|
|
13
|
+
border-color: #646cff;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&:focus,
|
|
17
|
+
&:focus-visible {
|
|
18
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@media (prefers-color-scheme: light) {
|
|
23
|
+
button {
|
|
24
|
+
background-color: #f9f9f9;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
3
|
+
import type { RenderOptions } from '@testing-library/react/types';
|
|
4
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
function ProvidersWrapper({ children }: { children: ReactNode }) {
|
|
7
|
+
return <MemoryRouter>{children}</MemoryRouter>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function renderComponent(
|
|
11
|
+
component: ReactElement,
|
|
12
|
+
options?: Omit<RenderOptions, 'wrapper'>,
|
|
13
|
+
): ReturnType<typeof render> {
|
|
14
|
+
return render(component, { wrapper: ProvidersWrapper, ...options });
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
declare module 'virtual:svg-icons-register';
|
|
4
|
+
|
|
5
|
+
interface ImportMetaEnv extends Readonly<Record<string, string>> {
|
|
6
|
+
readonly VITE_APP_VERSION: string;
|
|
7
|
+
readonly VITE_APP_MOCK?: 'service-worker';
|
|
8
|
+
readonly VITE_APP_BUILD_EPOCH?: string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"composite": true,
|
|
4
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
5
|
+
"target": "ES2020",
|
|
6
|
+
"jsx": "react-jsx",
|
|
7
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
8
|
+
"moduleDetection": "force",
|
|
9
|
+
"useDefineForClassFields": true,
|
|
10
|
+
"module": "ESNext",
|
|
11
|
+
|
|
12
|
+
/* Bundler mode */
|
|
13
|
+
"moduleResolution": "bundler",
|
|
14
|
+
"paths": {
|
|
15
|
+
"@/*": ["./src/*"]
|
|
16
|
+
},
|
|
17
|
+
"allowImportingTsExtensions": true,
|
|
18
|
+
|
|
19
|
+
/* Linting */
|
|
20
|
+
"strict": true,
|
|
21
|
+
"noFallthroughCasesInSwitch": true,
|
|
22
|
+
"noUncheckedSideEffectImports": true,
|
|
23
|
+
"noUnusedLocals": true,
|
|
24
|
+
"noUnusedParameters": true,
|
|
25
|
+
"noEmit": true,
|
|
26
|
+
"verbatimModuleSyntax": true,
|
|
27
|
+
"erasableSyntaxOnly": true,
|
|
28
|
+
"skipLibCheck": true
|
|
29
|
+
},
|
|
30
|
+
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx"],
|
|
31
|
+
"exclude": ["src/**/*.test.*", "src/test-utils"]
|
|
32
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.app.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"composite": true,
|
|
5
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo",
|
|
6
|
+
"types": ["vitest/globals"]
|
|
7
|
+
},
|
|
8
|
+
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "vitest.setup.ts"],
|
|
9
|
+
"exclude": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
3
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
4
|
+
import react from '@vitejs/plugin-react-swc';
|
|
5
|
+
import { defineConfig } from 'vite';
|
|
6
|
+
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
|
|
7
|
+
import './scripts/build-info';
|
|
8
|
+
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
base: './',
|
|
11
|
+
plugins: [
|
|
12
|
+
react(),
|
|
13
|
+
tailwindcss(),
|
|
14
|
+
createSvgIconsPlugin({
|
|
15
|
+
iconDirs: [resolve(process.cwd(), 'src/assets/svg-icons')],
|
|
16
|
+
}),
|
|
17
|
+
],
|
|
18
|
+
esbuild: {
|
|
19
|
+
pure: ['console.log'],
|
|
20
|
+
drop: ['debugger'],
|
|
21
|
+
},
|
|
22
|
+
resolve: {
|
|
23
|
+
alias: {
|
|
24
|
+
'@': fileURLToPath(new URL('src', import.meta.url)),
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
build: {
|
|
28
|
+
rollupOptions: {
|
|
29
|
+
output: {
|
|
30
|
+
chunkFileNames: 'chunks/[name]-[hash].js',
|
|
31
|
+
assetFileNames: 'assets/[name].[hash].[ext]',
|
|
32
|
+
entryFileNames: 'entries/[name].[hash].js',
|
|
33
|
+
manualChunks: {
|
|
34
|
+
core: ['react', 'react-dom', 'react-i18next', 'react-router-dom', 'zustand', 'i18next'],
|
|
35
|
+
vender: ['axios'],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineConfig, mergeConfig } from 'vitest/config';
|
|
2
|
+
import viteConfig from './vite.config';
|
|
3
|
+
|
|
4
|
+
export default mergeConfig(
|
|
5
|
+
viteConfig,
|
|
6
|
+
defineConfig({
|
|
7
|
+
test: {
|
|
8
|
+
globals: true,
|
|
9
|
+
environment: 'jsdom',
|
|
10
|
+
include: ['src/**/*.test.tsx'],
|
|
11
|
+
setupFiles: ['./vitest.setup.ts'],
|
|
12
|
+
coverage: {
|
|
13
|
+
provider: 'v8',
|
|
14
|
+
include: ['!src/main.tsx', 'src/**/*.tsx', 'src/**/*.ts'],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
}),
|
|
18
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cleanup } from '@testing-library/react';
|
|
2
|
+
import { mswServer } from '@/mocks/server';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import '@/plugins/i18n';
|
|
5
|
+
|
|
6
|
+
beforeAll(() => mswServer.listen());
|
|
7
|
+
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
cleanup();
|
|
10
|
+
mswServer.resetHandlers();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
afterAll(() => mswServer.close());
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Click this link to view browser coverage https://browsersl.ist/#q=%3E+1.5%25%0Aios+%3E%3D+13%0Achrome+%3E%3D+60%0Anot+ie+%3C%3D+11%0Alast+2+versions%0Anot+dead
|
|
2
|
+
|
|
3
|
+
# Browsers that support
|
|
4
|
+
|
|
5
|
+
> 1.5%
|
|
6
|
+
ios >= 13
|
|
7
|
+
chrome >= 60
|
|
8
|
+
not ie <= 11
|
|
9
|
+
last 2 versions
|
|
10
|
+
not dead
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: Setup environment
|
|
2
|
+
|
|
3
|
+
description: Install dependencies
|
|
4
|
+
|
|
5
|
+
runs:
|
|
6
|
+
using: composite
|
|
7
|
+
steps:
|
|
8
|
+
- name: install pnpm
|
|
9
|
+
uses: pnpm/action-setup@v6
|
|
10
|
+
with:
|
|
11
|
+
run_install: false
|
|
12
|
+
|
|
13
|
+
- name: install Node.js
|
|
14
|
+
uses: actions/setup-node@v7
|
|
15
|
+
with:
|
|
16
|
+
node-version: 24.12.0
|
|
17
|
+
cache: pnpm
|
|
18
|
+
|
|
19
|
+
- name: install dependencies
|
|
20
|
+
shell: bash
|
|
21
|
+
run: pnpm install
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
3
|
+
"extends": ["config:recommended", "schedule:weekly", "group:allNonMajor"],
|
|
4
|
+
"labels": ["dependencies"],
|
|
5
|
+
"rangeStrategy": "bump",
|
|
6
|
+
"ignoreDeps": ["node"],
|
|
7
|
+
"packageRules": [
|
|
8
|
+
{
|
|
9
|
+
"matchDepTypes": ["peerDependencies"],
|
|
10
|
+
"enabled": false
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"postUpdateOptions": ["pnpmDedupe"]
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: CI Pipeline
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_call:
|
|
5
|
+
workflow_dispatch:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
CI:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v7
|
|
12
|
+
- name: setup environment
|
|
13
|
+
uses: ./.github/actions/setup-environment
|
|
14
|
+
|
|
15
|
+
- name: install Playwright browsers
|
|
16
|
+
run: npx playwright install --with-deps
|
|
17
|
+
|
|
18
|
+
- name: run unit test
|
|
19
|
+
run: pnpm test:unit
|
|
20
|
+
|
|
21
|
+
- name: run e2e test
|
|
22
|
+
run: pnpm test:ci-e2e
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Deploy to Production
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
paths:
|
|
7
|
+
- 'src/**'
|
|
8
|
+
- pnpm-lock.yaml
|
|
9
|
+
- package.json
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
CI:
|
|
13
|
+
uses: ./.github/workflows/ci.yml
|
|
14
|
+
|
|
15
|
+
deploy:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
needs: CI
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v7
|
|
20
|
+
# - name: setup environment
|
|
21
|
+
# uses: './.github/actions/setup-environment'
|
|
22
|
+
|
|
23
|
+
# - name: build production
|
|
24
|
+
# run: pnpm build:production
|
|
25
|
+
|
|
26
|
+
# - name: deploy to production
|
|
27
|
+
# run: pnpm deploy
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
name: Preview Pull Request
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types: [opened, synchronize, reopened]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
CI:
|
|
9
|
+
uses: ./.github/workflows/ci.yml
|
|
10
|
+
|
|
11
|
+
preview:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
needs: CI
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v7
|
|
16
|
+
# - name: setup environment
|
|
17
|
+
# uses: './.github/actions/setup-environment'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
variables:
|
|
2
|
+
NODE_VERSION: '22'
|
|
3
|
+
CACHE_KEY: '${CI_PROJECT_PATH_SLUG}-${CI_COMMIT_REF_SLUG}'
|
|
4
|
+
|
|
5
|
+
image: node:${NODE_VERSION}-alpine
|
|
6
|
+
|
|
7
|
+
cache:
|
|
8
|
+
key: ${CACHE_KEY}
|
|
9
|
+
paths:
|
|
10
|
+
- .pnpm-store
|
|
11
|
+
- node_modules/
|
|
12
|
+
policy: pull-push
|
|
13
|
+
|
|
14
|
+
before_script:
|
|
15
|
+
- corepack enable
|
|
16
|
+
- corepack prepare --activate
|
|
17
|
+
- pnpm config set store-dir .pnpm-store
|
|
18
|
+
- pnpm install
|