@genesislcap/blank-app-seed 3.29.1-prerelease.11 → 3.29.1-prerelease.13
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/.genx/package.json +1 -1
- package/.genx/templates/react/component/component.hbs +12 -20
- package/.genx/utils/generateTile.js +1 -1
- package/.genx/versions.json +1 -1
- package/CHANGELOG.md +14 -0
- package/client-tmp/react/.eslintrc.cjs +3 -1
- package/client-tmp/react/env.development.json +3 -0
- package/client-tmp/react/index.html +1 -1
- package/client-tmp/react/lint-css.js +18 -0
- package/client-tmp/react/package.json +28 -5
- package/client-tmp/react/playwright.config.ts +17 -0
- package/client-tmp/react/src/App.tsx +5 -5
- package/client-tmp/react/src/components/ErrorMessage/ErrorMessage.jsx +1 -1
- package/client-tmp/react/src/components/ErrorMessage.test.js +80 -0
- package/client-tmp/react/src/config.ts +1 -1
- package/client-tmp/react/src/custom-elements.d.ts +1 -1
- package/client-tmp/react/src/svg-elements.d.ts +1 -1
- package/client-tmp/react/src/utils/fdc3.ts +1 -1
- package/client-tmp/react/src/utils/index.ts +2 -1
- package/client-tmp/react/src/utils/setApiHost.ts +9 -0
- package/client-tmp/react/test/e2e/fixture.ts +26 -0
- package/client-tmp/react/test/e2e/flows/001-protected.e2e.ts +6 -0
- package/client-tmp/react/test/e2e/index.ts +2 -0
- package/client-tmp/react/test/e2e/pages/index.ts +1 -0
- package/client-tmp/react/test/e2e/pages/protected.ts +16 -0
- package/client-tmp/react/tsconfig.node.json +1 -1
- package/client-tmp/react/vite.config.js +59 -0
- package/package.json +1 -1
- package/client-tmp/react/vite.config.ts +0 -14
package/.genx/package.json
CHANGED
|
@@ -1,38 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
{{#if tile.config.permissions.viewRight}}
|
|
3
1
|
import { getUser } from '@genesislcap/foundation-user';
|
|
4
2
|
import { getViewUpdateRightComponent } from '../../../utils';
|
|
5
3
|
import ErrorMessage from '../../../components/ErrorMessage/ErrorMessage';
|
|
6
|
-
{{else}}{{#if tile.config.permissions.updateRight}}
|
|
7
|
-
import { getViewUpdateRightComponent } from '../../../utils';
|
|
8
|
-
import { getUser } from '@genesislcap/foundation-user';
|
|
9
|
-
import ErrorMessage from '../../../components/ErrorMessage/ErrorMessage';
|
|
10
|
-
{{/if}}{{/if}}
|
|
11
4
|
{{#if tile.config.createFormUiSchema}}
|
|
12
|
-
import { createFormSchema } from './{{kebabCase tile.title}}.create.form.schema';
|
|
5
|
+
import { createFormSchema as createFormSchemaTile } from './{{kebabCase tile.title}}.create.form.schema';
|
|
13
6
|
{{/if}}
|
|
14
7
|
{{#if tile.config.uischema}}
|
|
15
|
-
import { createFormSchema } from './{{kebabCase tile.title}}.create.form.schema';
|
|
8
|
+
import { createFormSchema as createFormSchemaTile } from './{{kebabCase tile.title}}.create.form.schema';
|
|
16
9
|
{{/if}}
|
|
17
10
|
{{#if tile.config.updateFormUiSchema}}
|
|
18
|
-
import { updateFormSchema } from './{{kebabCase tile.title}}.update.form.schema';
|
|
11
|
+
import { updateFormSchema as updateFormSchemaTile } from './{{kebabCase tile.title}}.update.form.schema';
|
|
19
12
|
{{/if}}
|
|
20
13
|
{{#if tile.config.columns}}
|
|
21
|
-
import { columnDefs } from './{{kebabCase tile.title}}.column.defs';
|
|
14
|
+
import { columnDefs as columnDefsTile } from './{{kebabCase tile.title}}.column.defs';
|
|
22
15
|
{{/if}}
|
|
23
16
|
{{#if tile.config.gridOptions}}
|
|
24
|
-
import { gridOptions as
|
|
17
|
+
import { gridOptions as gridOptionsTile } from './{{kebabCase tile.title}}.gridOptions';
|
|
25
18
|
{{/if}}
|
|
26
19
|
import './{{kebabCase tile.title}}.component.css';
|
|
27
20
|
|
|
28
|
-
export const {{pascalCase tile.componentName}} = () => {
|
|
29
|
-
const hasUserPermission = (permissionCode) => getViewUpdateRightComponent(getUser(), permissionCode);{{
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const gridOptions = tileGridOptions;{{/if}}{{#if tile.config.reqrep}}
|
|
21
|
+
export const {{pascalCase tile.componentName}} = () => {
|
|
22
|
+
const hasUserPermission = (permissionCode) => getViewUpdateRightComponent(getUser(), permissionCode);{{#if tile.config.createFormUiSchema}}
|
|
23
|
+
const createFormSchema = createFormSchemaTile;{{/if}}{{#if tile.config.uischema}}
|
|
24
|
+
const uischema = createFormSchemaTile;{{/if}}{{#if tile.config.updateFormUiSchema}}
|
|
25
|
+
const updateFormSchema = updateFormSchemaTile;{{/if}}{{#if tile.config.columns}}
|
|
26
|
+
const columnDefs = columnDefsTile;{{/if}}{{#if tile.config.gridOptions}}
|
|
27
|
+
const gridOptions = gridOptionsTile;{{/if}}{{#if tile.config.reqrep}}
|
|
36
28
|
const reqrep = { pollingInterval: 5000 };{{/if}}{{#if tile.config.type}}
|
|
37
29
|
const chartConfig = { {{#ifEquals tile.config.type 'pie'}}
|
|
38
30
|
"radius": 0.75,
|
|
@@ -44,7 +44,7 @@ const getPathByFramework = {
|
|
|
44
44
|
},
|
|
45
45
|
[FRAMEWORK_REACT_ALIAS]: {
|
|
46
46
|
...defaultPathGetters,
|
|
47
|
-
index: (componentPath) => `${componentPath}/index.
|
|
47
|
+
index: (componentPath) => `${componentPath}/index.jsx`,
|
|
48
48
|
clientSrcPath: `../../client/src/pages`,
|
|
49
49
|
route: (clientSrcPath, tile, routeName) =>
|
|
50
50
|
`${clientSrcPath}/${routeName}/${tile.name}-${tile.componentType}`,
|
package/.genx/versions.json
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [3.29.1-prerelease.13](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v3.29.1-prerelease.12...v3.29.1-prerelease.13) (2024-09-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* automated dependency version update [skip-ci] [PSD-9](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/9) (#328) 626c48b
|
|
9
|
+
|
|
10
|
+
## [3.29.1-prerelease.12](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v3.29.1-prerelease.11...v3.29.1-prerelease.12) (2024-09-03)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* update unit test commands in package.json (#329) 290a3ab
|
|
16
|
+
|
|
3
17
|
## [3.29.1-prerelease.11](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v3.29.1-prerelease.10...v3.29.1-prerelease.11) (2024-08-28)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
root: true,
|
|
3
|
-
env: { browser: true, es2020: true },
|
|
3
|
+
env: { browser: true, es2020: true, node: true, jest: true },
|
|
4
4
|
extends: [
|
|
5
5
|
'eslint:recommended',
|
|
6
6
|
'plugin:@typescript-eslint/recommended',
|
|
@@ -10,6 +10,8 @@ module.exports = {
|
|
|
10
10
|
parser: '@typescript-eslint/parser',
|
|
11
11
|
plugins: ['react-refresh'],
|
|
12
12
|
rules: {
|
|
13
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
14
|
+
'@typescript-eslint/no-var-requires': 'off',
|
|
13
15
|
'react-refresh/only-export-components': [
|
|
14
16
|
'warn',
|
|
15
17
|
{ allowConstantExport: true },
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>{{
|
|
7
|
+
<title>{{capitalCase appName}}</title>
|
|
8
8
|
</head>
|
|
9
9
|
<body>
|
|
10
10
|
<div id="root"></div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
const glob = require('glob');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const cssFiles = glob.sync(path.join(__dirname, '**/*.css'));
|
|
5
|
+
|
|
6
|
+
if (cssFiles.length === 0) {
|
|
7
|
+
console.log('No CSS files found.');
|
|
8
|
+
process.exit(0);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const command = `genx lint -l stylelint ${cssFiles.join(' ')}`;
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
execSync(command, { stdio: 'inherit' });
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error('Error running stylelint:', error);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
@@ -5,12 +5,26 @@
|
|
|
5
5
|
"scripts": {
|
|
6
6
|
"baseline": "npm run clean && npm run bootstrap",
|
|
7
7
|
"bootstrap": "npm i --legacy-peer-deps",
|
|
8
|
+
"bootstrap:ci": "npm ci --no-fund --no-audit",
|
|
9
|
+
"build": "vite build",
|
|
10
|
+
"build:stats": "npm run build --stats-json",
|
|
11
|
+
"clean": "genx clean dist node_modules",
|
|
8
12
|
"dev": "vite",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
13
|
+
"dev:docker": "npm run dev -- --host 0.0.0.0",
|
|
14
|
+
"dev:no-open": "NO_OPEN=true npm run dev",
|
|
15
|
+
"dev:intellij": "npm run dev",
|
|
16
|
+
"dev:https": "HTTPS=true npm run dev",
|
|
17
|
+
"dsconfig": "dsconfig --path src/styles/design-tokens.json",
|
|
18
|
+
"lint": "eslint src/**/*.js src/**/*.jsx",
|
|
19
|
+
"lint:fix": "eslint src/**/*.js src/**/*.jsx --fix",
|
|
20
|
+
"lint:eslint": "npm lint",
|
|
21
|
+
"lint:stylelint": "node lint-css.js",
|
|
22
|
+
"test": "genx test",
|
|
23
|
+
"test:e2e": "genx test --e2e",
|
|
24
|
+
"test:e2e:debug": "genx test --e2e --debug",
|
|
25
|
+
"test:e2e:ui": "genx test --e2e --interactive",
|
|
26
|
+
"test:coverage": "genx test --no-watch --coverage",
|
|
27
|
+
"test:unit:watch": "genx test --watch"
|
|
14
28
|
},
|
|
15
29
|
"dependencies": {
|
|
16
30
|
"@ag-grid-community/client-side-row-model": "29.2.0",
|
|
@@ -37,6 +51,15 @@
|
|
|
37
51
|
"react-router-dom": "6.24.1"
|
|
38
52
|
},
|
|
39
53
|
"devDependencies": {
|
|
54
|
+
"@genesislcap/design-system-configurator": "{{versions.UI}}",
|
|
55
|
+
"@genesislcap/eslint-config": "{{versions.UI}}",
|
|
56
|
+
"@genesislcap/prettier-config": "{{versions.UI}}",
|
|
57
|
+
"@genesislcap/foundation-testing": "{{versions.UI}}",
|
|
58
|
+
"@genesislcap/genx": "{{versions.UI}}",
|
|
59
|
+
"@genesislcap/build-kit": "{{versions.UI}}",
|
|
60
|
+
"@testing-library/dom": "^10.4.0",
|
|
61
|
+
"@testing-library/jest-dom": "^6.5.0",
|
|
62
|
+
"@testing-library/react": "^16.0.0",
|
|
40
63
|
"@types/node": "^20.14.10",
|
|
41
64
|
"@types/react": "npm:types-react@alpha",
|
|
42
65
|
"@types/react-dom": "npm:types-react-dom@alpha",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { configDefaults } from '@genesislcap/foundation-testing/e2e';
|
|
2
|
+
|
|
3
|
+
export const PROTOCOL = process.env['PROTOCOL'] || 'http';
|
|
4
|
+
export const HOST = process.env['HOST'] || 'localhost';
|
|
5
|
+
export const PORT: number = Number(process.env['PORT']) || 5173;
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
...configDefaults,
|
|
9
|
+
webServer: {
|
|
10
|
+
...configDefaults.webServer,
|
|
11
|
+
url: `${PROTOCOL}://${HOST}:${PORT}`,
|
|
12
|
+
},
|
|
13
|
+
use: {
|
|
14
|
+
...configDefaults.use,
|
|
15
|
+
baseURL: `${PROTOCOL}://${HOST}:${PORT}`,
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
1
|
import {
|
|
3
2
|
unstable_HistoryRouter as HistoryRouter,
|
|
4
3
|
Routes,
|
|
5
4
|
Route,
|
|
6
5
|
useLocation,
|
|
7
6
|
} from 'react-router-dom';
|
|
8
|
-
import {
|
|
7
|
+
import { useEffect } from 'react';
|
|
8
|
+
import { history, setApiHost{{#if FDC3.channels.length}}, listenToChannel{{/if}} } from './utils';
|
|
9
9
|
import LayoutWrapper from './layouts/LayoutWrapper';
|
|
10
10
|
import { AUTH_PATH, NOT_PERMITTED_PATH, routeLayouts } from './config';
|
|
11
11
|
import AuthGuard from './guards/AuthGuard';
|
|
@@ -17,9 +17,7 @@ import NotPermittedPage from './pages/NotPermittedPage/NotPermittedPage';
|
|
|
17
17
|
{{#each routes}}
|
|
18
18
|
import {{pascalCase this.name}} from './pages/{{kebabCase this.name}}/{{pascalCase this.name}}';
|
|
19
19
|
{{/each}}
|
|
20
|
-
|
|
21
|
-
import { listenToChannel, onFDC3Ready } from './utils';
|
|
22
|
-
{{/if}}
|
|
20
|
+
|
|
23
21
|
// Genesis Components
|
|
24
22
|
import './share/genesis-components';
|
|
25
23
|
|
|
@@ -79,6 +77,8 @@ const LayoutWithLocation = () => {
|
|
|
79
77
|
};
|
|
80
78
|
|
|
81
79
|
const App: React.FC = () => {
|
|
80
|
+
setApiHost();
|
|
81
|
+
|
|
82
82
|
return (
|
|
83
83
|
<AuthProvider>
|
|
84
84
|
<HistoryRouter history={history}>
|
|
@@ -29,7 +29,7 @@ const styles = {
|
|
|
29
29
|
const ErrorMessage = ({ elementType = 'div', message = '' }) => {
|
|
30
30
|
const ElementType = elementType;
|
|
31
31
|
|
|
32
|
-
return (
|
|
32
|
+
return message && message !== '' && (
|
|
33
33
|
<section style={styles.errorMessageWrapper}>
|
|
34
34
|
<div style={styles.errorMessage}>
|
|
35
35
|
{(() => {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import ErrorMessage from './ErrorMessage';
|
|
5
|
+
|
|
6
|
+
describe('ErrorMessage Component', () => {
|
|
7
|
+
const message = 'Test Error Message';
|
|
8
|
+
|
|
9
|
+
test('renders the message as a div by default', () => {
|
|
10
|
+
render(<ErrorMessage message={message} />);
|
|
11
|
+
const displayedMessage = screen.getByText(message);
|
|
12
|
+
expect(displayedMessage.tagName).toBe('DIV');
|
|
13
|
+
expect(displayedMessage).toBeInTheDocument();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('renders the message as an h1 element when elementType is "h1"', () => {
|
|
17
|
+
render(<ErrorMessage message={message} elementType="h1" />);
|
|
18
|
+
const displayedMessage = screen.getByRole('heading', { level: 1 });
|
|
19
|
+
expect(displayedMessage.tagName).toBe('H1');
|
|
20
|
+
expect(displayedMessage).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('renders the message as a p element when elementType is "p"', () => {
|
|
24
|
+
render(<ErrorMessage message={message} elementType="p" />);
|
|
25
|
+
const displayedMessage = screen.getByText(message);
|
|
26
|
+
expect(displayedMessage.tagName).toBe('P');
|
|
27
|
+
expect(displayedMessage).toBeInTheDocument();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('applies the correct styles to the error message wrapper', () => {
|
|
31
|
+
render(<ErrorMessage message={message} />);
|
|
32
|
+
const wrapper = screen.getByText(message).closest('section');
|
|
33
|
+
expect(wrapper).toHaveStyle(`
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
align-items: center;
|
|
38
|
+
height: 100%;
|
|
39
|
+
width: 100%;
|
|
40
|
+
`);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('applies the correct styles to the error message itself', () => {
|
|
44
|
+
render(<ErrorMessage message={message} />);
|
|
45
|
+
const displayedMessage = screen.getByText(message);
|
|
46
|
+
const messageWrapper = displayedMessage.parentElement;
|
|
47
|
+
|
|
48
|
+
expect(messageWrapper).toBeInTheDocument();
|
|
49
|
+
expect(messageWrapper).toHaveStyle(`
|
|
50
|
+
color: var(--neutral-foreground-rest);
|
|
51
|
+
background-color: var(--neutral-layer-4);
|
|
52
|
+
border-color: var(--error-color);
|
|
53
|
+
border-radius: 7px;
|
|
54
|
+
border-style: solid;
|
|
55
|
+
border-width: 4px;
|
|
56
|
+
padding: 5px;
|
|
57
|
+
margin: 15px;
|
|
58
|
+
text-align: center;
|
|
59
|
+
width: fit-content;
|
|
60
|
+
align-self: center;
|
|
61
|
+
height: auto;
|
|
62
|
+
max-height: 100%;
|
|
63
|
+
`);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('renders nothing if the message is an empty string', () => {
|
|
67
|
+
const { container } = render(<ErrorMessage message="" />);
|
|
68
|
+
expect(container.firstChild).toBeNull();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('renders the correct element type for various elementType props', () => {
|
|
72
|
+
const elementTypes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'span', 'div'];
|
|
73
|
+
elementTypes.forEach((elementType) => {
|
|
74
|
+
const { container } = render(<ErrorMessage message={message} elementType={elementType} />);
|
|
75
|
+
const displayedMessage = container.querySelector(elementType);
|
|
76
|
+
expect(displayedMessage).toBeInTheDocument();
|
|
77
|
+
expect(displayedMessage.tagName).toBe(elementType.toUpperCase());
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -12,7 +12,7 @@ export const AUTH_PATH = 'auth';
|
|
|
12
12
|
export const NOT_PERMITTED_PATH = 'not-permitted';
|
|
13
13
|
|
|
14
14
|
export const API_DATA = {
|
|
15
|
-
URL:
|
|
15
|
+
URL: import.meta.env.VITE_API_HOST,
|
|
16
16
|
AUTH: {
|
|
17
17
|
username: '', // provide login to a user in given environment
|
|
18
18
|
password: '', // provide password to a user in given environment
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{{#if FDC3.includeDependencies}}
|
|
2
2
|
import { DefaultFDC3 } from '@genesislcap/foundation-fdc3';
|
|
3
3
|
{{/if}}
|
|
4
|
-
export const isFDC3 = (): boolean => !!(window as
|
|
4
|
+
export const isFDC3 = (): boolean => !!((window as unknown as { fdc3?: boolean }).fdc3);
|
|
5
5
|
{{#if FDC3.includeDependencies}}
|
|
6
6
|
|
|
7
7
|
export const onFDC3Ready = async (FDC3ReadyCb: () => any): Promise<void> => {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { base, Page } from '@genesislcap/foundation-testing/e2e';
|
|
2
|
+
import { ProtectedPage } from './pages';
|
|
3
|
+
import { PORT } from '../../playwright.config';
|
|
4
|
+
|
|
5
|
+
export type FixtureConfig = {
|
|
6
|
+
API_HOST: string;
|
|
7
|
+
DEFAULT_USER: string;
|
|
8
|
+
DEFAULT_PASSWORD: string;
|
|
9
|
+
PORT: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type Fixture = {
|
|
13
|
+
config: FixtureConfig;
|
|
14
|
+
protectedPage: ProtectedPage;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const API_HOST = process.env['API_HOST'] || 'localhost';
|
|
18
|
+
|
|
19
|
+
export const test = base.extend<Fixture>({
|
|
20
|
+
config: [{ PORT, API_HOST, DEFAULT_PASSWORD: '', DEFAULT_USER: '' }, { option: true }],
|
|
21
|
+
protectedPage: async ({ config, page }: { config: FixtureConfig, page: Page }, use: (page: ProtectedPage) => Promise<unknown>) => {
|
|
22
|
+
const protectedPage = new ProtectedPage(config, page);
|
|
23
|
+
await protectedPage.goto();
|
|
24
|
+
await use(protectedPage);
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './protected';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Page } from '@genesislcap/foundation-testing/e2e';
|
|
2
|
+
import type { FixtureConfig } from '../fixture';
|
|
3
|
+
|
|
4
|
+
export class ProtectedPage {
|
|
5
|
+
config: FixtureConfig;
|
|
6
|
+
page: Page;
|
|
7
|
+
|
|
8
|
+
constructor(config: FixtureConfig, page: Page) {
|
|
9
|
+
this.config = config;
|
|
10
|
+
this.page = page;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async goto() {
|
|
14
|
+
await this.page.goto('/');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { resolve, dirname } from 'path';
|
|
3
|
+
import { defineConfig } from 'vite';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import react from '@vitejs/plugin-react';
|
|
6
|
+
import visualizer from 'rollup-plugin-visualizer';
|
|
7
|
+
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
|
|
10
|
+
export default defineConfig(({ mode }) => {
|
|
11
|
+
const https = process.env.HTTPS === 'true';
|
|
12
|
+
const open = !(process.env.NO_OPEN === 'true');
|
|
13
|
+
const jsonFilePath = resolve(process.cwd(), `env.${mode}.json`);
|
|
14
|
+
const envConfig = {};
|
|
15
|
+
|
|
16
|
+
if (fs.existsSync(jsonFilePath)) {
|
|
17
|
+
const jsonContent = fs.readFileSync(jsonFilePath, 'utf-8');
|
|
18
|
+
const parsedConfig = JSON.parse(jsonContent);
|
|
19
|
+
|
|
20
|
+
for (const key in parsedConfig) {
|
|
21
|
+
envConfig[`import.meta.env.${key}`] = JSON.stringify(parsedConfig[key]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const config = {
|
|
26
|
+
define: envConfig,
|
|
27
|
+
server: {
|
|
28
|
+
https,
|
|
29
|
+
open,
|
|
30
|
+
},
|
|
31
|
+
plugins: [
|
|
32
|
+
react(),
|
|
33
|
+
],
|
|
34
|
+
build: {
|
|
35
|
+
rollupOptions: {
|
|
36
|
+
plugins: []
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
resolve: {
|
|
40
|
+
alias: {
|
|
41
|
+
'foundationZero/ZeroDesignSystem': resolve(__dirname, 'node_modules/@genesislcap/foundation-zero'),
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
if (mode === 'stats') {
|
|
47
|
+
config.build.rollupOptions.plugins.push(
|
|
48
|
+
visualizer({
|
|
49
|
+
template: 'raw-data',
|
|
50
|
+
filename: 'stats.json',
|
|
51
|
+
open: true,
|
|
52
|
+
gzipSize: true,
|
|
53
|
+
brotliSize: true,
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return config;
|
|
59
|
+
});
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import react from '@vitejs/plugin-react';
|
|
3
|
-
import { resolve } from 'path';
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
plugins: [
|
|
7
|
-
react(),
|
|
8
|
-
],
|
|
9
|
-
resolve: {
|
|
10
|
-
alias: {
|
|
11
|
-
'foundationZero/ZeroDesignSystem': resolve(__dirname, 'node_modules/@genesislcap/foundation-zero'),
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
});
|