Skip to content

Commit

Permalink
Merge pull request #176 from dracor-org/162-vite
Browse files Browse the repository at this point in the history
Migrate to vite
  • Loading branch information
cmil authored Sep 1, 2024
2 parents 466ca16 + c3defac commit e15899a
Show file tree
Hide file tree
Showing 74 changed files with 7,731 additions and 11,588 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

44 changes: 22 additions & 22 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@ name: CD

on:
push:
branches: [ main, production ]
branches: [main, production]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '20.x'
- name: Restore node_modules
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '20.x'
- name: Restore node_modules
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}

- run: yarn install
- run: yarn test --watchAll=false
- run: yarn build
- run: yarn install
- run: yarn test --watch=false
- run: yarn build

- uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0
with:
ssh-private-key: ${{ secrets.DRACOR_ORG_DEPLOY_KEY }}
- uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0
with:
ssh-private-key: ${{ secrets.DRACOR_ORG_DEPLOY_KEY }}

- name: Deploy to staging
run: rsync -rlvz --delete -e 'ssh -o StrictHostKeyChecking=no' build/ ${{ secrets.DRACOR_ORG_DEPLOY_USER }}@staging.dracor.org:${{ secrets.DEPLOY_PATH }}/
if: github.ref == 'refs/heads/main'
- name: Deploy to staging
run: rsync -rlvz --delete -e 'ssh -o StrictHostKeyChecking=no' build/ ${{ secrets.DRACOR_ORG_DEPLOY_USER }}@staging.dracor.org:${{ secrets.DEPLOY_PATH }}/
if: github.ref == 'refs/heads/main'

- name: Deploy to production
run: rsync -rlvz --delete -e 'ssh -o StrictHostKeyChecking=no' build/ ${{ secrets.DRACOR_ORG_DEPLOY_USER }}@dracor.org:${{ secrets.DEPLOY_PATH }}/
if: github.ref == 'refs/heads/production'
- name: Deploy to production
run: rsync -rlvz --delete -e 'ssh -o StrictHostKeyChecking=no' build/ ${{ secrets.DRACOR_ORG_DEPLOY_USER }}@dracor.org:${{ secrets.DEPLOY_PATH }}/
if: github.ref == 'refs/heads/production'
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ name: CI

on:
pull_request:
branches: [ main ]
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Restore node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- run: yarn install
- run: yarn test --watchAll=false
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Restore node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- run: yarn install
- run: yarn test --watch=false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ public/data.json
public/wikidata.txt

src/locales/*/*.js
src/locales/*/*.ts
src/locales/*/*.mo
9 changes: 0 additions & 9 deletions .linguirc

This file was deleted.

2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/locations.json
lingui.config.js
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"singleQuote": true,
"jsxSingleQuote": false,
"semi": true,
"tabWidth": 2,
"bracketSpacing": false,
"arrowParens": "always",
"trailingComma": "es5"
}
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ This project was bootstrapped with [Create React App](https://github.com/faceboo
### Quick start

After installing [nodejs](https://nodejs.org/en/download/package-manager/) and
[yarn](https://classic.yarnpkg.com/en/docs/install) you can start the *Einakter*
[yarn](https://classic.yarnpkg.com/en/docs/install) you can start the _Einakter_
database by running the following commands:

```bash
git clone [email protected]:dracor-org/einakter.git
cd einakter
yarn
yarn compile
yarn start
```

Expand All @@ -25,7 +26,7 @@ In the project directory, you can run:
### `yarn start`

Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
Open [http://localhost:5173](http://localhost:5173) to view it in the browser.

The page will reload if you make edits.<br />
You will also see any lint errors in the console.
Expand Down Expand Up @@ -72,7 +73,7 @@ new location IDs in `data.yaml` and adds them to `src/locations.json`.
### `yarn extract`

Extracts translatable text from Javascript code and updates `.po` files in
the `src/locales` directory.
the `src/locales` directory.

### `yarn compile`

Expand All @@ -83,7 +84,7 @@ for testing new translations in a development server without re-running

## Translations

*Einakter* uses [LinguiJS](https://lingui.js.org) to provide a multi-lingual
_Einakter_ uses [LinguiJS](https://lingui.js.org) to provide a multi-lingual
user interface. Translations are maintained in `.po` files in the
[src/locales](src/locales). For updating translations the
[yarn extract](#yarn-extract) and [yarn compile](#yarn-compile) commands can be
Expand Down
21 changes: 0 additions & 21 deletions craco.config.js

This file was deleted.

22 changes: 22 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import pluginReact from 'eslint-plugin-react';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';

export default [
{ files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'] },
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat['jsx-runtime'],
eslintPluginPrettierRecommended,
{
rules: {
camelcase: 'warn',
'no-console': 'warn',
'spaced-comment': ['error', 'always'],
},
ignores: ['src/vite-env.d.ts'],
},
];
26 changes: 26 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Database of German one-act plays" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="/manifest.json" />
<title>Einakter</title>
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
crossorigin=""
/>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
25 changes: 25 additions & 0 deletions lingui.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/** @type {import('@lingui/conf').LinguiConfig} */
module.exports = {
locales: [
'en',
'de',
'es',
'fa',
'fr',
'ja',
'ko',
'ku',
'ru',
'uk',
'zh',
'jbo-tok',
],
sourceLocale: 'en',
catalogs: [
{
path: '<rootDir>/src/locales/{locale}/messages',
include: ['src'],
},
],
format: 'po',
};
66 changes: 41 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@
"version": "1.2.1",
"private": true,
"dependencies": {
"@craco/craco": "^6.4.5",
"@fortawesome/fontawesome-svg-core": "^6.2.0",
"@fortawesome/free-brands-svg-icons": "^6.2.0",
"@fortawesome/free-solid-svg-icons": "^6.2.0",
"@fortawesome/react-fontawesome": "^0.2.0",
"@headlessui/react": "^1.7.2",
"@lingui/detect-locale": "^3.14.0",
"@lingui/react": "^3.14.0",
"@lingui/detect-locale": "^4.11.3",
"@lingui/macro": "^4.11.3",
"@lingui/react": "^4.11.3",
"@tailwindcss/typography": "^0.5.7",
"@tanstack/react-table": "^8.5.13",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^13.0.0",
"@testing-library/user-event": "^13.2.1",
"@types/jest": "^29.5.5",
"@types/leaflet": "^1.5.23",
"@types/node": "^16.7.13",
"@types/node": "^22.2.0",
"@types/react": "^18.0.0",
"@types/react-copy-to-clipboard": "^5.0.4",
"@types/react-dom": "^18.0.0",
Expand All @@ -32,25 +28,54 @@
"react-leaflet": "^4.1.0",
"react-markdown": "^8.0.3",
"react-router-dom": "^6.4.1",
"react-scripts": "5.0.1",
"sass": "^1.55.0",
"tailwindcss": "^3.1.8",
"tailwindcss-classnames": "^2.2.5",
"typescript": "5.1.6",
"web-vitals": "^2.1.0"
"typescript": "5.1.6"
},
"devDependencies": {
"@babel/core": "^7.25.2",
"@eslint/js": "^9.9.0",
"@lingui/cli": "^4.11.3",
"@lingui/vite-plugin": "^4.11.3",
"@mdx-js/loader": "^2.1.3",
"@mdx-js/rollup": "^3.0.1",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.4.8",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.2",
"@types/eslint__js": "^8.42.3",
"@types/js-yaml": "^4.0.5",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.20",
"axios": "^1.6.0",
"babel-plugin-macros": "^3.1.0",
"eslint": "^9.9.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-mdx": "^3.1.5",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.35.0",
"globals": "^15.9.0",
"jsdom": "^24.1.1",
"prettier": "^3.3.3",
"ts-node": "^10.9.1",
"typescript-eslint": "^8.0.1",
"vite": "^5.4.0",
"vite-plugin-eslint": "^1.8.1",
"vitest": "^2.0.5"
},
"scripts": {
"csv": "ts-node -O '{\"isolatedModules\":false,\"module\":\"CommonJS\"}' yml2csv.ts && cp ./data.csv ./public/",
"json": "ts-node -O '{\"isolatedModules\":false,\"module\":\"CommonJS\"}' yml2json.ts && cp ./data.json ./src/ && cp ./data.json ./public/",
"beacon": "ts-node -O '{\"isolatedModules\":false,\"module\":\"CommonJS\"}' yml2beacon.ts",
"authors": "ts-node -O '{\"isolatedModules\":false,\"module\":\"CommonJS\"}' fetch-authors.ts",
"locations": "ts-node -O '{\"isolatedModules\":false,\"module\":\"CommonJS\"}' fetch-locations.ts",
"start": "yarn compile && yarn csv && yarn json && craco start",
"build": "yarn compile && yarn csv && yarn json && yarn beacon && craco build",
"test": "yarn compile && yarn csv && yarn json && craco test",
"start": "yarn csv && yarn json && vite",
"build": "yarn csv && yarn json && yarn beacon && vite build",
"test": "yarn compile && yarn csv && yarn json && vitest",
"lint": "eslint src",
"extract": "lingui extract",
"compile": "lingui compile",
"eject": "react-scripts eject"
"compile": "lingui compile --typescript"
},
"eslintConfig": {
"extends": [
Expand Down Expand Up @@ -85,14 +110,5 @@
"transformIgnorePatterns": [
"node_modules/(?!axios)"
]
},
"devDependencies": {
"@babel/core": "^7.19.1",
"@lingui/cli": "^3.14.0",
"@lingui/macro": "^3.14.0",
"@mdx-js/loader": "^2.1.3",
"@types/js-yaml": "^4.0.5",
"axios": "^1.6.0",
"ts-node": "^10.9.1"
}
}
Loading

0 comments on commit e15899a

Please sign in to comment.