This commit is contained in:
Primakov Alexandr Alexandrovich 2024-07-25 22:14:20 +03:00
commit a55fe9914b
32 changed files with 15966 additions and 0 deletions

32
.eslintrc.js Normal file
View File

@ -0,0 +1,32 @@
module.exports = {
env: {
browser: true,
node: true,
es2021: true,
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
cmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: 'module',
},
plugins: ['react', '@typescript-eslint'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'react/prop-types': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_', caughtErrors: 'none' },
],
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-var-requires': 'off',
},
};

51
.gitignore vendored Normal file
View File

@ -0,0 +1,51 @@
# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
# Node artifact files
node_modules/
dist/
coverage/
# Compiled Java class files
*.class
# Compiled Python bytecode
*.py[cod]
# Log files
*.log
# Package files
*.jar
# Maven
target/
dist/
# JetBrains IDE
.idea/
# Unit test reports
TEST*.xml
# Generated by MacOS
.DS_Store
# Generated by Windows
Thumbs.db
# Applications
*.app
*.exe
*.war
# Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv

1
.npmrc Normal file
View File

@ -0,0 +1 @@
package-lock=true

7
.prettierignore Normal file
View File

@ -0,0 +1,7 @@
# Ignore artifacts:
build
dist
coverage
stubs
logs
d-scripts

7
.prettierrc.json Normal file
View File

@ -0,0 +1,7 @@
{
"tabWidth": 2,
"semi": true,
"jsxBracketSameLine": true,
"arrowParens": "avoid",
"singleQuote": true
}

26
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach by Process ID",
"processId": "${command:PickProcess}",
"request": "attach",
"skipFiles": ["<node_internals>/**"],
"type": "pwa-node"
},
{
"type": "node",
"name": "vscode-jest-tests",
"request": "launch",
"args": ["--runInBand", "--no-cache"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
]
}

10
@types/emotion.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
import '@emotion/react';
import { lightTheme } from '../src/app.theme';
declare module '@emotion/react' {
export interface Theme {
colors: typeof lightTheme.colors,
shadows: typeof lightTheme.shadows
}
}

19
@types/index.d.ts vendored Normal file
View File

@ -0,0 +1,19 @@
declare const IS_PROD: string;
declare module '*.svg' {
const value: string;
export default value;
}
declare module '*.jpg' {
const value: string;
export default value;
}
declare module '*.png' {
const value: string;
export default value;
}

31
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,31 @@
pipeline {
agent {
docker {
image 'node:16'
}
}
stages {
stage('install') {
steps {
sh 'node -v'
sh 'npm -v'
sh 'npm ci'
}
}
stage('eslint') {
steps {
sh 'npm run eslint'
}
}
stage('clean-all') {
steps {
sh 'rm -rf .[!.]*'
sh 'rm -rf ./*'
sh 'ls -a'
}
}
}
}

6
babel.config.js Normal file
View File

@ -0,0 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
};

2
d-scripts/re-run.sh Normal file
View File

@ -0,0 +1,2 @@
sh stop.sh;
sh up-nginx.sh;

1
d-scripts/stop.sh Normal file
View File

@ -0,0 +1 @@
docker stop adminka_nginx2;

1
d-scripts/up-nginx.sh Normal file
View File

@ -0,0 +1 @@
docker run --name adminka_nginx2 -v $PWD/nginx.conf:/etc/nginx/nginx.conf:ro -v $PWD/dist:/usr/share/nginx/html --rm -d -p 3072:80 nginx;

17
ijl.config.js Normal file
View File

@ -0,0 +1,17 @@
const pkg = require('./package')
module.exports = {
apiPath: 'stubs/api',
webpackConfig: {
output: {
publicPath: `/static/${pkg.name}/${process.env.VERSION || pkg.version}/`
}
},
/* use https://kc.admin.inno-js.ru/ to create config, navigations and features */
navigations: {
},
features: {
},
config: {
}
}

9
jest.config.js Normal file
View File

@ -0,0 +1,9 @@
module.exports = {
clearMocks: true,
collectCoverage: true,
collectCoverageFrom: ['./src/**/*.ts?(x)'],
coverageDirectory: 'coverage',
coverageProvider: 'v8',
preset: 'ts-jest',
testEnvironment: 'jsdom',
};

1
locales/en-EN.json Normal file
View File

@ -0,0 +1 @@
{}

3
locales/en.json Normal file
View File

@ -0,0 +1,3 @@
{
}

1
locales/ru-RU.json Normal file
View File

@ -0,0 +1 @@
{}

3
locales/ru.json Normal file
View File

@ -0,0 +1,3 @@
{
}

15512
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

55
package.json Normal file
View File

@ -0,0 +1,55 @@
{
"name": "bro.landing",
"version": "2.0.1",
"description": "",
"main": "./src/index.tsx",
"scripts": {
"docker:rerun": "docker stop adminka_nginx2 && sh d-scripts/up-nginx.sh",
"predeploy": "npm i && npm run build:prod",
"redeploy": "npm run predeploy && npm run docker:rerun || sh d-scripts/up-nginx.sh",
"clean": "rimraf dist",
"eslint": "npx eslint src",
"prettier": "prettier --write .",
"test": "jest --coverage",
"start": "brojs server --port=8099 --with-open-browser",
"build": "npm run clean && brojs build --dev",
"build:prod": "npm run clean && brojs build"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@babel/preset-typescript": "7.24.7",
"@brojs/cli": "^0.0.4-alpha.6",
"@chakra-ui/icons": "^2.1.1",
"@chakra-ui/react": "^2.8.2",
"@emotion/css": "^11.13.0",
"@emotion/react": "^11.13.0",
"@emotion/styled": "^11.13.0",
"@reduxjs/toolkit": "^2.2.6",
"dayjs": "^1.11.12",
"express": "^4.19.2",
"i18next": "^23.12.2",
"i18next-browser-languagedetector": "^8.0.0",
"i18next-xhr-backend": "^3.2.2",
"lottie-react": "^2.4.0",
"prettier": "^3.3.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-helmet": "^6.1.0",
"react-i18next": "^15.0.0",
"react-redux": "^9.1.2",
"react-router-dom": "^6.25.1",
"redux": "^5.0.1"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"babel-jest": "^29.7.0",
"eslint": "8.57.0",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^4.6.2",
"html-webpack-plugin": "^5.6.0",
"jest": "^29.7.0",
"ts-jest": "^29.2.3"
}
}

31
readme.md Normal file
View File

@ -0,0 +1,31 @@
# PL админки ijl
Данный проект является презентационным слоем админки от стендов ijl
## Установка зависимостей
```shell
npm install
```
## Запуск
```shell
npm start
```
## Собрать
```shell
npm run build:prod
```
## Деплой
Для деплоя используется простой докер образ nginx раздающий директорию dist. Для запуска необходимо воспользоваться скриптами из директории d-scripts.
Команда запуска на сервере
```shell
sh d-scripts/up-nginx.sh
```

File diff suppressed because one or more lines are too long

20
src/app.tsx Normal file
View File

@ -0,0 +1,20 @@
import React, { Suspense } from "react";
import { BrowserRouter } from "react-router-dom";
import {Helmet} from 'react-helmet';
import { Dashboard } from './dashboard';
const App = () => {
return (
<>
<Helmet>
<title>bro js</title>
</Helmet>
<BrowserRouter>
<Dashboard />
</BrowserRouter>
</>
);
};
export default App;

22
src/dashboard.tsx Normal file
View File

@ -0,0 +1,22 @@
import React, { Suspense } from 'react';
import { Routes, Route } from 'react-router-dom';
import { Spinner } from '@chakra-ui/react';
import { UnderConstructionPage } from './pages';
const Hello = () => <h1>Hello</h1>;
export const Dashboard = () => {
return (
<Routes>
<Route
path={'*'}
element={
<Suspense fallback={<Spinner />}>
<UnderConstructionPage />
</Suspense>
}
/>
<Route path={'*'} element={<h1>Страница не найдена</h1>} />
</Routes>
);
};

18
src/index.ejs Normal file
View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,600,700,900&amp;subset=cyrillic,cyrillic-ext" rel="stylesheet" />
<title>bro-js admin</title>
<style>body {margin: 0; padding: 0;}</style>
</head>
<body>
<noscript><div><img src="https://mc.yandex.ru/watch/87860751" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<div id="app"></div>
</body>
</html>

26
src/index.tsx Normal file
View File

@ -0,0 +1,26 @@
import React from 'react';
import i18next from 'i18next';
import { i18nextReactInitConfig } from '@brojs/cli/lib/i18next';
import { createRoot } from 'react-dom/client'
import App from './app';
i18next.t = i18next.t.bind(i18next);
const i18nextPromise = i18nextReactInitConfig(i18next);
const MOUNT_NODE = document.getElementById('app');
(async () => {
await Promise.all([i18nextPromise]);
const rootElement = createRoot(MOUNT_NODE)
rootElement.render(<App />);
if (module.hot) {
module.hot.accept('./app', async () => {
await i18next.reloadResources();
rootElement.render(<App />);
});
}
})();
export const mount = () => console.log('mounted');
export const unmount = () => console.log('unmounted');

3
src/pages/index.ts Normal file
View File

@ -0,0 +1,3 @@
import { lazy } from 'react';
export const UnderConstructionPage = lazy(() => import('./under-construction'));

View File

@ -0,0 +1,3 @@
import { UnderConstruction } from './underConstruction';
export default UnderConstruction;

View File

@ -0,0 +1,14 @@
import React from 'react';
import Lottie from "lottie-react";
import animation from '../../__data__/assets/lottie/under-construction.json';
export const UnderConstruction = () => {
return (
<div>
<Lottie animationData={animation} />
<h3><center>Сайт в разработке</center></h3>
</div>
)
}

8
stubs/api/index.js Normal file
View File

@ -0,0 +1,8 @@
const router = require('express').Router();
const timer = (time = 300) => (req, res, next) => setTimeout(next, time);
router.use(timer());
module.exports = router;

25
tsconfig.json Normal file
View File

@ -0,0 +1,25 @@
{
"compilerOptions": {
"lib": [
"dom",
"es2017"
],
"outDir": "./dist/",
"sourceMap": true,
"esModuleInterop": true,
"noImplicitAny": false,
"module": "esnext",
"moduleResolution": "node",
"target": "es6",
"jsx": "react",
"typeRoots": ["node_modules/@types", "src/typings"],
"types" : ["webpack-env", "node"],
"resolveJsonModule": true
},
"exclude": [
"node_modules",
"**/*.test.ts",
"**/*.test.tsx",
"node_modules/@types/jest"
]
}