diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 6c196ea0..a3572883 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -44,7 +44,7 @@ jobs: run: dotnet pack --no-build --configuration Release ./DbViewer.sln - name: Build front - run: yarn --cwd db-viewer-ui build + run: yarn --cwd db-viewer-ui build:test - name: Check C# code style run: dotnet jb cleanupcode DbViewer.sln --profile=CatalogueCleanup --exclude=./DbViewer.TestApi/Migrations/*.cs --verbosity=WARN && git diff --exit-code -- ':!db-viewer-ui' @@ -101,7 +101,10 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} registry-url: ${{ env.NPM_REGISTRY }} - + + - name: Build front for production + run: yarn --cwd db-viewer-ui build:prod + - name: Check version run: | tagName="${{github.ref_name}}" diff --git a/db-viewer-ui/package.json b/db-viewer-ui/package.json index 78172d04..b401ffd5 100644 --- a/db-viewer-ui/package.json +++ b/db-viewer-ui/package.json @@ -20,22 +20,25 @@ ], "author": "Den Mukhametianov, Pavel Vostretsov", "scripts": { - "build": "run-s build:types build:clean build:tsc build:vite \"build:copy:*\" build:patch build:pack", + "build:prod": "run-s build:prep build:vite:prod build:copy:src build:copy:meta build:patch build:pack", + "build:test": "run-s build:prep build:vite:test build:copy:test", + "build:prep": "run-s build:types build:clean build:tsc", "build:clean": "rimraf dist ../DbViewer.TestApi/wwwroot ../DbViewer.TestApi/bin/net6.0/wwwroot", "build:tsc": "tsc --project tsconfig.prod.json", - "build:vite": "vite build --emptyOutDir", + "build:vite:test": "vite build --mode test --emptyOutDir", + "build:vite:prod": "vite build", "build:patch": "node ./patch-version", "build:copy:src": "copyfiles --up 1 \"src/**/*.js\" dist", "build:copy:meta": "copyfiles --flat package.json \"../*.md\" ../LICENSE dist", "build:copy:test": "copyfiles -u 2 \"../DbViewer.TestApi/wwwroot/**/*\" ../DbViewer.TestApi/bin/net6.0", "build:pack": "cd dist && npm pack", "build:types": "dotnet ts-gen --assembly ./../DbViewer.TestApi/bin/net6.0/SkbKontur.DbViewer.TestApi.dll --outputDir ./src/Domain/Api --nullabilityMode NullableReference", - "start": "vite -m dev", + "start": "vite --mode dev", "start:prod": "vite", - "storybook": "storybook dev -p 6006", + "storybook": "sb dev -p 6006", "lint": "run-s \"lint:*\"", "lint:tsc": "tsc --noEmit", - "lint:eslint": "eslint ./ --ext .js,.jsx,.ts,.ts --cache --quiet", + "lint:eslint": "eslint ./ --ext .js,.jsx,.ts,.tsx --cache --quiet", "test": "vitest" }, "peerDependencies": { @@ -58,6 +61,7 @@ "@skbkontur/react-ui": "^4.1.0", "@storybook/addon-actions": "^7.0.7", "@storybook/addons": "^7.0.7", + "@storybook/cli": "^7.4.6", "@storybook/react": "^7.0.7", "@storybook/react-vite": "^7.4.6", "@types/lodash": "^4.14.171", @@ -83,7 +87,6 @@ "react-refresh": "^0.10.0", "react-router-dom": "^6.11.1", "rimraf": "^3.0.2", - "storybook": "7.4.6", "storybook-addon-react-router-v6": "^2.0.7", "typescript": "^4.3.5", "vite": "^4.4.9", diff --git a/db-viewer-ui/src/Components/ObjectViewer/ObjectKeys.tsx b/db-viewer-ui/src/Components/ObjectViewer/ObjectKeys.tsx index 01023355..b9c8389a 100644 --- a/db-viewer-ui/src/Components/ObjectViewer/ObjectKeys.tsx +++ b/db-viewer-ui/src/Components/ObjectViewer/ObjectKeys.tsx @@ -12,19 +12,17 @@ interface ObjectKeysProps { keys: ObjectKey[]; } -export function ObjectKeys({ keys }: ObjectKeysProps) { - return ( - - {keys.map(x => ( - - - {x.name}: - - {x.value} - - - - ))} - - ); -} +export const ObjectKeys = ({ keys }: ObjectKeysProps): React.JSX.Element => ( + + {keys.map(x => ( + + + {x.name}: + + {x.value} + + + + ))} + +); diff --git a/db-viewer-ui/stories/AdminTools/ObjectsTable.stories.tsx b/db-viewer-ui/stories/AdminTools/ObjectsTable.stories.tsx index 79a817c2..95256574 100644 --- a/db-viewer-ui/stories/AdminTools/ObjectsTable.stories.tsx +++ b/db-viewer-ui/stories/AdminTools/ObjectsTable.stories.tsx @@ -8,7 +8,7 @@ import { ObjectFilterSortOrder } from "../../src/Domain/Api/DataTypes/ObjectFilt import { PropertyMetaInformation } from "../../src/Domain/Api/DataTypes/PropertyMetaInformation"; import { TypeMetaInformation } from "../../src/Domain/Api/DataTypes/TypeMetaInformation"; -async function deleteObject(_index: number): Promise { +async function deleteObject(): Promise { // Ничего не делаем } diff --git a/db-viewer-ui/tsconfig.json b/db-viewer-ui/tsconfig.json index 25e32cbf..330f4ff6 100644 --- a/db-viewer-ui/tsconfig.json +++ b/db-viewer-ui/tsconfig.json @@ -1,39 +1,37 @@ { "compilerOptions": { "allowJs": false, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, + "esModuleInterop": false, "baseUrl": "./", "rootDir": "./", - "jsx": "react", "outDir": "dist", - "module": "commonjs", - "target": "es5", - "moduleResolution": "node", - "importHelpers": true, "noUnusedLocals": true, "downlevelIteration": true, + "importHelpers": true, "noUnusedParameters": false, "pretty": true, + "allowSyntheticDefaultImports": true, + "target": "ESNext", + "useDefineForClassFields": true, + "lib": ["DOM", "DOM.Iterable", "ESNext"], "skipLibCheck": true, "sourceMap": true, "declaration": true, "maxNodeModuleJsDepth": 5, - "strict": true, "experimentalDecorators": true, "noImplicitReturns": true, "suppressImplicitAnyIndexErrors": true, - "lib": ["es2020", "dom", "dom.iterable"], + "strict": true, + "forceConsistentCasingInFileNames": true, + "module": "ESNext", + "moduleResolution": "Node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", "paths": { "*": ["typings/*"] } }, - "include": [ - "stories/Api/DbViewerApiFake.ts", - "index.tsx", - "src/**/*", - "stories/**/*", - "tests/**/*", - "typings/**/*" - ] + "include": ["src", "vite.config.ts", "typings"], } diff --git a/db-viewer-ui/tsconfig.next.json b/db-viewer-ui/tsconfig.next.json deleted file mode 100644 index 6de7366f..00000000 --- a/db-viewer-ui/tsconfig.next.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "allowJs": false, - "esModuleInterop": false, - "allowSyntheticDefaultImports": true, - "target": "ESNext", - "useDefineForClassFields": true, - "lib": ["DOM", "DOM.Iterable", "ESNext"], - "skipLibCheck": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "module": "ESNext", - "moduleResolution": "Node", - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx" - }, - "include": ["src", "vite.config.ts"], -} diff --git a/db-viewer-ui/vite.config.ts b/db-viewer-ui/vite.config.ts index b2b8bf18..2a0290b2 100644 --- a/db-viewer-ui/vite.config.ts +++ b/db-viewer-ui/vite.config.ts @@ -2,33 +2,38 @@ import react from "@vitejs/plugin-react"; import { defineConfig } from "vite"; // https://vitejs.dev/config/ -export default defineConfig(({ mode }) => ({ - plugins: [react()], - define: process.env.VITEST - ? {} - : { - "process.env.API": mode === "dev" ? "'fake'" : "'real'", - "process.env.enableReactTesting": "true", - global: "window", - }, - server: { - proxy: { - "/db-viewer": "http://localhost:5000", +export default defineConfig(({ mode }) => { + const isTestMode = mode === "test"; + const isDevMode = mode === "dev"; + return { + plugins: [react()], + define: process.env.VITEST + ? {} + : { + "process.env.API": isDevMode ? "'fake'" : "'real'", + "process.env.enableReactTesting": "true", + global: "window", + }, + server: { + proxy: { + "/db-viewer": "http://localhost:5000", + }, }, - }, - test: { - include: ["./tests/**/*.tsx"], - globals: false, - environment: "jsdom", - }, - esbuild: { - keepNames: true, - minifyIdentifiers: false, - minifySyntax: true, - minifyWhitespace: true, - }, - build: { - outDir: "../DbViewer.TestApi/wwwroot", - chunkSizeWarningLimit: 1024, - }, -})); + test: { + include: ["./tests/**/*.tsx"], + globals: false, + environment: "jsdom", + }, + esbuild: isTestMode + ? { + minifyIdentifiers: false, + keepNames: true, + } + : {}, + build: { + minify: "esbuild", + outDir: isTestMode ? "../DbViewer.TestApi/wwwroot" : "./dist", + chunkSizeWarningLimit: isTestMode ? 2048 : 1024, + }, + }; +}); diff --git a/db-viewer-ui/yarn.lock b/db-viewer-ui/yarn.lock index 0a6324da..17504912 100644 --- a/db-viewer-ui/yarn.lock +++ b/db-viewer-ui/yarn.lock @@ -2655,6 +2655,7 @@ __metadata: "@skbkontur/react-ui-validations": ^1.8.3 "@storybook/addon-actions": ^7.0.7 "@storybook/addons": ^7.0.7 + "@storybook/cli": ^7.4.6 "@storybook/react": ^7.0.7 "@storybook/react-vite": ^7.4.6 "@types/lodash": ^4.14.171 @@ -2683,7 +2684,6 @@ __metadata: react-refresh: ^0.10.0 react-router-dom: ^6.11.1 rimraf: ^3.0.2 - storybook: 7.4.6 storybook-addon-react-router-v6: ^2.0.7 tslib: ^2.3.0 typescript: ^4.3.5 @@ -2881,7 +2881,7 @@ __metadata: languageName: node linkType: hard -"@storybook/cli@npm:7.4.6": +"@storybook/cli@npm:^7.4.6": version: 7.4.6 resolution: "@storybook/cli@npm:7.4.6" dependencies: @@ -6363,9 +6363,9 @@ __metadata: linkType: hard "flow-parser@npm:0.*": - version: 0.217.2 - resolution: "flow-parser@npm:0.217.2" - checksum: f209c9a24538edc6308d23e9611cf7bd7032c9f798600ca1b2ac9325be69758290d40516dd67def6c5c846521fea7fc3bab5c1ee00c05354886c83c04b63220a + version: 0.218.0 + resolution: "flow-parser@npm:0.218.0" + checksum: f8158ca172d168ce45f36d0141aabea9f7c37ab83398448a12fd43eb286b867612e66bfe02347f4abc06051455a2ab7a9372b8b574481f17151fe84ca4fecf60 languageName: node linkType: hard @@ -9850,7 +9850,7 @@ __metadata: languageName: node linkType: hard -"resolve@npm:^1.10.0, resolve@npm:^1.14.2, resolve@npm:^1.17.0, resolve@npm:^1.19.0, resolve@npm:^1.22.4": +"resolve@npm:^1.10.0, resolve@npm:^1.17.0, resolve@npm:^1.19.0, resolve@npm:^1.22.4": version: 1.22.6 resolution: "resolve@npm:1.22.6" dependencies: @@ -9863,6 +9863,19 @@ __metadata: languageName: node linkType: hard +"resolve@npm:^1.14.2": + version: 1.22.8 + resolution: "resolve@npm:1.22.8" + dependencies: + is-core-module: ^2.13.0 + path-parse: ^1.0.7 + supports-preserve-symlinks-flag: ^1.0.0 + bin: + resolve: bin/resolve + checksum: f8a26958aa572c9b064562750b52131a37c29d072478ea32e129063e2da7f83e31f7f11e7087a18225a8561cfe8d2f0df9dbea7c9d331a897571c0a2527dbb4c + languageName: node + linkType: hard + "resolve@npm:^2.0.0-next.4": version: 2.0.0-next.4 resolution: "resolve@npm:2.0.0-next.4" @@ -9876,7 +9889,7 @@ __metadata: languageName: node linkType: hard -"resolve@patch:resolve@^1.10.0#~builtin, resolve@patch:resolve@^1.14.2#~builtin, resolve@patch:resolve@^1.17.0#~builtin, resolve@patch:resolve@^1.19.0#~builtin, resolve@patch:resolve@^1.22.4#~builtin": +"resolve@patch:resolve@^1.10.0#~builtin, resolve@patch:resolve@^1.17.0#~builtin, resolve@patch:resolve@^1.19.0#~builtin, resolve@patch:resolve@^1.22.4#~builtin": version: 1.22.6 resolution: "resolve@patch:resolve@npm%3A1.22.6#~builtin::version=1.22.6&hash=c3c19d" dependencies: @@ -9889,6 +9902,19 @@ __metadata: languageName: node linkType: hard +"resolve@patch:resolve@^1.14.2#~builtin": + version: 1.22.8 + resolution: "resolve@patch:resolve@npm%3A1.22.8#~builtin::version=1.22.8&hash=c3c19d" + dependencies: + is-core-module: ^2.13.0 + path-parse: ^1.0.7 + supports-preserve-symlinks-flag: ^1.0.0 + bin: + resolve: bin/resolve + checksum: 5479b7d431cacd5185f8db64bfcb7286ae5e31eb299f4c4f404ad8aa6098b77599563ac4257cb2c37a42f59dfc06a1bec2bcf283bb448f319e37f0feb9a09847 + languageName: node + linkType: hard + "resolve@patch:resolve@^2.0.0-next.4#~builtin": version: 2.0.0-next.4 resolution: "resolve@patch:resolve@npm%3A2.0.0-next.4#~builtin::version=2.0.0-next.4&hash=c3c19d" @@ -10428,18 +10454,6 @@ __metadata: languageName: node linkType: hard -"storybook@npm:7.4.6": - version: 7.4.6 - resolution: "storybook@npm:7.4.6" - dependencies: - "@storybook/cli": 7.4.6 - bin: - sb: ./index.js - storybook: ./index.js - checksum: 248e5fa2e094e7a0d365f940cc75c036215ad710abb2e4ea33321ac5a2820e1ae991bed5f6c210ba885818e2d1b8f98cace61232e259ee56d969df1e9e8a266b - languageName: node - linkType: hard - "stream-shift@npm:^1.0.0": version: 1.0.1 resolution: "stream-shift@npm:1.0.1"