diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..cda0704 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,35 @@ +name: Deploy + +on: + push: + branches: + - master + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +permissions: + contents: read + id-token: write + +jobs: + # Build job + build: + environment: CI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - run: npm ci + - run: npm run build + - name: Deploy bookstore to S3 production + uses: jakejarvis/s3-sync-action@v0.5.1 + with: + args: --acl public-read --follow-symlinks + env: + AWS_S3_BUCKET: testplane-bookstore + AWS_ACCESS_KEY_ID: ${{ secrets.S3_PRODUCTION_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_PRODUCTION_SECRET_ACCESS_KEY }} + AWS_S3_ENDPOINT: https://s3.yandexcloud.net/ + SOURCE_DIR: "dist" diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..0546be8 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [22.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + - run: npm ci + - run: npm run build + - run: npm run lint + - run: npm run format:check diff --git a/.nvmrc b/.nvmrc index 8fdd954..2bd5a0a 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -22 \ No newline at end of file +22 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..a9b956e --- /dev/null +++ b/.prettierignore @@ -0,0 +1,8 @@ +node_modules +dist +build +coverage +.next +*.min.js +package-lock.json +public/mockServiceWorker.js diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..dd24c1a --- /dev/null +++ b/.prettierrc @@ -0,0 +1,11 @@ +{ + "semi": true, + "singleQuote": true, + "printWidth": 120, + "tabWidth": 2, + "useTabs": false, + "trailingComma": "es5", + "bracketSpacing": true, + "arrowParens": "avoid", + "endOfLine": "lf" +} diff --git a/.storybook/main.js b/.storybook/main.js index 4b1b0b9..ed313e7 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -1,11 +1,7 @@ /** @type { import('@storybook/react-vite').StorybookConfig } */ const config = { stories: ['../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'], - addons: [ - '@storybook/addon-links', - '@storybook/addon-essentials', - '@storybook/addon-interactions', - ], + addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions'], framework: { name: '@storybook/react-vite', options: {}, @@ -14,4 +10,4 @@ const config = { autodocs: 'tag', }, }; -export default config; \ No newline at end of file +export default config; diff --git a/.storybook/preview.js b/.storybook/preview.js index 2e4ef5c..737326f 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -13,4 +13,4 @@ const preview = { }, }; -export default preview; \ No newline at end of file +export default preview; diff --git a/README.md b/README.md index 7522047..7d0ea37 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ [Book Store](https://testplane-bookstore.website.yandexcloud.net/) for Testplane examples ### Getting started + 1. nvm use 2. npm ci 3. npm run build diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..4d5d97d --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,90 @@ +import js from '@eslint/js'; +import react from 'eslint-plugin-react'; +import reactHooks from 'eslint-plugin-react-hooks'; +import reactRefresh from 'eslint-plugin-react-refresh'; +import prettierConfig from 'eslint-config-prettier'; + +export default [ + { + ignores: ['dist', 'node_modules', 'public/mockServiceWorker.js'], + }, + // Config files (Node.js environment) + { + files: ['*.config.js', '*.config.cjs'], + languageOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + globals: { + __dirname: 'readonly', + __filename: 'readonly', + require: 'readonly', + module: 'readonly', + exports: 'writable', + process: 'readonly', + }, + }, + rules: { + ...js.configs.recommended.rules, + }, + }, + // React application files + { + files: ['src/**/*.{js,jsx}'], + languageOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + }, + globals: { + window: 'readonly', + document: 'readonly', + navigator: 'readonly', + console: 'readonly', + setTimeout: 'readonly', + clearTimeout: 'readonly', + setInterval: 'readonly', + clearInterval: 'readonly', + fetch: 'readonly', + localStorage: 'readonly', + sessionStorage: 'readonly', + FormData: 'readonly', + URL: 'readonly', + URLSearchParams: 'readonly', + alert: 'readonly', + confirm: 'readonly', + prompt: 'readonly', + }, + }, + plugins: { + react, + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh, + }, + rules: { + ...js.configs.recommended.rules, + ...react.configs.recommended.rules, + ...react.configs['jsx-runtime'].rules, + ...reactHooks.configs.recommended.rules, + 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], + 'react/prop-types': 'off', + 'react/no-unescaped-entities': 'off', + 'no-unused-vars': [ + 'error', + { + varsIgnorePattern: '^React$', + argsIgnorePattern: '^_', + }, + ], + // Disable formatting rules that conflict with Prettier + ...prettierConfig.rules, + }, + settings: { + react: { + version: 'detect', + }, + }, + }, +]; diff --git a/index.html b/index.html index 15e83fc..5754e94 100644 --- a/index.html +++ b/index.html @@ -1,22 +1,16 @@ - + - -
+ - - - - + +