Skip to content

Commit

Permalink
Merge pull request #134 from novasamatech/tech/refactor
Browse files Browse the repository at this point in the history
Remove Next.js, Yarn, Jest
  • Loading branch information
johnthecat authored Jun 20, 2024
2 parents a4c81f1 + 098dcbb commit fa21247
Show file tree
Hide file tree
Showing 262 changed files with 25,063 additions and 11,508 deletions.
18 changes: 18 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:lts-buster-slim

WORKDIR /app
COPY . .
COPY .docker/entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh

ARG PUBLIC_BOT_API_URL
ARG PUBLIC_BOT_ADDRESS
ARG PUBLIC_WEB_APP_ADDRESS
ARG PUBLIC_WEB_APP_URL
ARG PUBLIC_WIDGET_SECRET
ARG PUBLIC_SECURE_LOCAL_STORAGE_DISABLED_KEYS

RUN npm ci --no-audit
RUN npm run build

CMD ["entrypoint.sh"]
6 changes: 2 additions & 4 deletions docker/entrypoint.sh → .docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

set -e

sh scripts/replace-variable.sh

if echo "$DOCKER_TAGS" | grep -q "dev"; then
echo "Running in development mode"
exec yarn dev
exec npm run dev
else
echo "Running in production mode"
exec yarn start
exec npm start
fi
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
tab_width = 2
114 changes: 114 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
const fs = require('node:fs');
const path = require('node:path');

const prettierConfig = fs.readFileSync('./.prettierrc', 'utf8');
const prettierOptions = JSON.parse(prettierConfig);
const checkI18n = process.env.I18N === 'true';
const localesDir = './src/common/utils/locales';
const enLocalePath = path.resolve(localesDir, 'en.json');

/**
* @type {import('eslint').Linter.Config}
*/
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
globals: {
JSX: 'readonly',
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:import/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'prettier',
],
plugins: ['prettier', 'import'],
parserOptions: { ecmaVersion: 2022 },
settings: {
react: { version: 'detect' },
'import/resolver': {
typescript: {},
},
},
overrides: [
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: ['plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended'],
rules: {
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
fixStyle: 'inline-type-imports',
},
],
},
},
{
files: ['**/*.json'],
plugins: ['json'],
},
{
files: [`${localesDir}/*.json`],
plugins: ['plugin:i18n-json/recommended'],
extends: ['plugin:i18next/recommended'],
rules: {
'i18n-json/identical-keys': ['error', { filePath: enLocalePath }],
'i18n-json/identical-placeholders': ['error', { filePath: enLocalePath }],
'i18next/no-literal-string': [
checkI18n ? 'error' : 'off',
{
mode: 'jsx-text-only',
'should-validate-template': true,
'jsx-attributes': {
include: ['alt', 'aria-label', 'title', 'placeholder', 'label', 'description'],
exclude: ['data-testid', 'className'],
},
callees: {
exclude: ['Error', 'log', 'warn'],
},
words: {
exclude: ['[0-9!-/:-@[-`{-~]+', '[A-Z_-]+'],
},
},
],
},
},
],
rules: {
'import/order': [
'error',
{
alphabetize: { order: 'asc' },
groups: ['type', 'builtin', 'external', 'parent', ['sibling', 'index']],
'newlines-between': 'always',
pathGroups: [
{ group: 'external', pattern: 'react**', position: 'before' },
{ group: 'external', pattern: '@remix-run/**', position: 'before' },
{ group: 'external', pattern: '@polkadot/**', position: 'before' },
{ group: 'sibling', pattern: '@/**', position: 'before' },
],
pathGroupsExcludedImportTypes: [],
},
],
'sort-imports': ['error', { ignoreDeclarationSort: true }],

'newline-before-return': 'error',
'prettier/prettier': ['error', prettierOptions],
'react/no-array-index-key': 'warn',
'react/display-name': 'off',
'react/react-in-jsx-scope': 'off',
'react/jsx-sort-props': ['error', { callbacksLast: true, noSortAlphabetically: true }],
'react/function-component-definition': 'off',
},
ignorePatterns: ['.vscode', '.idea', 'coverage', 'node_modules', 'package.json'],
};
91 changes: 0 additions & 91 deletions .eslintrc.js

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/build_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}


- name: Build
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ./docker/Dockerfile
file: .docker/Dockerfile

notify-dev:
runs-on: ubuntu-latest
Expand All @@ -68,6 +68,6 @@ jobs:
with:
TELEGRAM_TO: ${{ secrets.TELEGRAM_TO }}
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
DEPLOYED_BOT: ${{ secrets.NEXT_PUBLIC_BOT_ADDRESS_DEV }}
DEPLOYED_BOT: ${{ secrets.PUBLIC_BOT_ADDRESS_DEV }}
IMAGE_TO_DEPLOY: ${{ needs.build-docker.outputs.docker_tags }}
APP_LINK: https://t.me/nova_wallet_dev_bot/novawallet_dev
22 changes: 11 additions & 11 deletions .github/workflows/pr_run_test_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ jobs:
uses: actions/checkout@v4

- name: Install dependencies
run: yarn install
run: npm ci --no-audit

- name: Type checking
run: npm run typecheck

- name: Linting
run: npm run lint

- name: Run test
run: yarn test

- name: 📄 Post results
if: always()
uses: im-open/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
results-file: jest-unit-results.json
report-name: 'Jest Unit tests results'
create-status-check: true
run: npm run test:ci

- name: Post results
uses: davelosert/vitest-coverage-report-action@v2
42 changes: 12 additions & 30 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,40 +1,22 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# IDE
.idea
.vscode

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage
jest-unit-results.json

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
# logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local
.env

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# temp files
vite.config.ts.timestamp*

# project directories
coverage
build
node_modules
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run precommit
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"singleQuote": true,
"useTabs": false,
"trailingComma": "all",
"arrowParens": "always",
"arrowParens": "avoid",
"endOfLine": "auto"
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
To install all dependencies:

```bash
yarn install
npm install
```
To start the project in dev mode:

```bash
yarn dev
npm run dev
```

### Start the application locally:
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: '3'
services:
app:
build:
dockerfile: ./docker/Dockerfile
build:
dockerfile: .docker/Dockerfile
context: .
ports:
- 3000:3000
volumes:
- .:/app
- /app/node_modules
- /app/node_modules
Loading

0 comments on commit fa21247

Please sign in to comment.