diff --git a/.circleci/config.yml b/.circleci/config.yml index 9710162..317616a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ jobs: test-job: docker: - - image: "circleci/node:lts" + - image: "cimg/node:lts" working_directory: ~/repo @@ -33,7 +33,7 @@ jobs: command: yarn test environment: TZ: UTC - REACT_APP_COMMIT_SHA: some_sha + VITE_COMMIT_SHA: some_sha - store_artifacts: # For coverage report path: client/coverage diff --git a/build.sh b/build.sh index 5a4972d..8992a82 100755 --- a/build.sh +++ b/build.sh @@ -10,10 +10,10 @@ fi echo "building client..." cd client yarn --production=false -REACT_APP_COMMIT_SHA=$SOURCE_VERSION \ -REACT_APP_API_HOST=$api_host \ -REACT_APP_API_PROTOCOL=$API_PROTOCOL \ -REACT_APP_API_PORT=$API_PORT \ +VITE_COMMIT_SHA=$SOURCE_VERSION \ +VITE_API_HOST=$api_host \ +VITE_API_PROTOCOL=$API_PROTOCOL \ +VITE_API_PORT=$API_PORT \ yarn build cd ../ diff --git a/client/.env.dist b/client/.env.dist index f577e32..311bb67 100644 --- a/client/.env.dist +++ b/client/.env.dist @@ -1,14 +1,14 @@ # Api settings TZ=UTC -REACT_APP_API_HOST=localhost -REACT_APP_API_PROTOCOL=http -REACT_APP_API_PORT=3001 -REACT_APP_COMMIT_SHA=some_sha +VITE_API_HOST=localhost +VITE_API_PROTOCOL=http +VITE_API_PORT=3001 +VITE_COMMIT_SHA=some_sha # To display darkwire version -REACT_APP_COMMIT_SHA=some_sha +VITE_COMMIT_SHA=some_sha # Set max transferable file size in MB -REACT_APP_MAX_FILE_SIZE=4 +VITE_MAX_FILE_SIZE=4 diff --git a/client/.eslintrc b/client/.eslintrc deleted file mode 100644 index e96799e..0000000 --- a/client/.eslintrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": ["plugin:prettier/recommended"], - "parser": "babel-eslint", - "rules": { - "prettier/prettier": "error" - } -} diff --git a/client/.eslintrc.cjs b/client/.eslintrc.cjs new file mode 100644 index 0000000..6815699 --- /dev/null +++ b/client/.eslintrc.cjs @@ -0,0 +1,10 @@ +module.exports = { + extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + root: true, + env: { + browser: true, + node: true, + }, +}; diff --git a/client/.gitignore b/client/.gitignore index e2178dd..c7f41f7 100644 --- a/client/.gitignore +++ b/client/.gitignore @@ -1,9 +1,25 @@ -node_modules -.DS_Store -dist -coverage +# Logs +logs *.log -.env* -!.env.example -build/ -*sublime* \ No newline at end of file +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist/ +dist-ssr +*.local +coverage + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/client/__mocks__/styles.js b/client/__mocks__/styles.js deleted file mode 100644 index f053ebf..0000000 --- a/client/__mocks__/styles.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = {}; diff --git a/client/index.html b/client/index.html new file mode 100644 index 0000000..712990b --- /dev/null +++ b/client/index.html @@ -0,0 +1,17 @@ + + +
+ + + + + + + +Commit SHA:{' '} - - {process.env.REACT_APP_COMMIT_SHA} + + {COMMIT_SHA}
diff --git a/client/src/components/Chat/Chat.js b/client/src/components/Chat/Chat.jsx similarity index 96% rename from client/src/components/Chat/Chat.js rename to client/src/components/Chat/Chat.jsx index 9790b44..92e0b27 100644 --- a/client/src/components/Chat/Chat.js +++ b/client/src/components/Chat/Chat.jsx @@ -1,12 +1,11 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import sanitizeHtml from 'sanitize-html'; -import FileTransfer from 'components/FileTransfer'; import { CornerDownRight } from 'react-feather'; -import { getSelectedText, hasTouchSupport } from '../../utils/dom'; -// Disable for now -// import autosize from 'autosize' +import { getSelectedText, hasTouchSupport } from '@/utils/dom'; + +import FileTransfer from '@/components/FileTransfer'; export class Chat extends Component { constructor(props) { @@ -21,14 +20,14 @@ export class Chat extends Component { { command: 'nick', description: 'Changes nickname.', - paramaters: ['{username}'], + parameters: ['{username}'], usage: '/nick {username}', scope: 'global', action: params => { // eslint-disable-line let newUsername = params.join(' ') || ''; // eslint-disable-line - // Remove things that arent digits or chars + // Remove things that aren't digits or chars newUsername = newUsername.replace(/[^A-Za-z0-9]/g, '-'); const errors = []; diff --git a/client/src/components/Chat/Chat.test.js b/client/src/components/Chat/Chat.test.jsx similarity index 91% rename from client/src/components/Chat/Chat.test.js rename to client/src/components/Chat/Chat.test.jsx index b14a717..f38527d 100644 --- a/client/src/components/Chat/Chat.test.js +++ b/client/src/components/Chat/Chat.test.jsx @@ -1,19 +1,20 @@ import React from 'react'; import { render, screen, fireEvent } from '@testing-library/react'; +import { describe, it, expect, vi, afterEach } from 'vitest'; -import { Chat } from './Chat'; +import { Chat } from '@/components/Chat/Chat'; -import * as dom from 'utils/dom'; +import * as dom from '@/utils/dom'; const translations = { typePlaceholder: 'inputplaceholder', }; // Fake date -jest.spyOn(global.Date, 'now').mockImplementation(() => new Date('2020-03-14T11:01:58.135Z').valueOf()); +vi.spyOn(global.Date, 'now').mockImplementation(() => new Date('2020-03-14T11:01:58.135Z').valueOf()); // To change touch support -jest.mock('../../utils/dom'); +vi.mock('@/utils/dom'); describe('Chat component', () => { afterEach(() => { @@ -39,7 +40,7 @@ describe('Chat component', () => { }); it('can send message', () => { - const sendEncryptedMessage = jest.fn(); + const sendEncryptedMessage = vi.fn(); render(