Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server,webapp): modernize development tooling - replace webpack, craco, eslint and gulp with bun, vite, tailwindcss, biomejs #399

Draft
wants to merge 9 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ node_modules/
# Production env file
.env

test-results/
test-results/

bun.lockb
4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

3 changes: 1 addition & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
bunx commitlint --edit
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.20
v20
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"biomejs.biome"
]
}
27 changes: 11 additions & 16 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
{
"eslint.validate": [
{
"language":"vue",
"autoFix":true
},
{
"language":"html",
"autoFix":true
},
{
"language":"javascript",
"autoFix":true
},
{
"language":"typescript",
"autoFix":true
}
"vue",
"html",
"javascript",
"typescript"
],
"editor.defaultFormatter": "biomejs.biome",
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"eslint.alwaysShowStatus": true,
"eslint.workingDirectories": [
"./client",
"./server"
],
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit"
},
"editor.useTabStops": false,
"editor.tabSize": 2,
"editor.insertSpaces": true,
Expand Down
22 changes: 16 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ cp .env.example .env
- Install all npm dependencies of the monorepo, you don't have to change directory to the `backend` package. just hit the command on root directory and it will install dependencies of all packages.

```
pnpm install
bun install
```

- Run all required docker containers in the development, we already configured all containers under `docker-compose.yml`.
Expand All @@ -69,13 +69,13 @@ cefa73fe2881 bigcapital-redis "docker-entrypoint.s…" 7 seconds ago Up
- There're some CLI commands we should run before running the server like databaase migration, so we need to build the `server` app first.

```
pnpm run build:server
bun run build:server
```

- Run the database migration for system database.

```
node packages/server/build/commands.js system:migrate:latest
bun packages/server/build/commands/index.js system:migrate:latest
```

And you should get something like that.
Expand All @@ -87,7 +87,7 @@ Batch 1 run: 6 migrations
- Next, start the webapp application.

```
pnpm run dev:server
bun run dev:server
```

**[`^top^`](#)**
Expand All @@ -105,19 +105,29 @@ git clone https://github.com/bigcapital/bigcapital.git && cd bigcaptial
- Install all npm dependencies of the monorepo, you don't have to change directory to the `frontend` package. just hit that command and will install all packages across all application.

```
pnpm install
bun install
```

- Next, start the webapp application.

```
pnpm run dev:webapp
bun run dev:webapp
```

**[`^top^`](#)**

---

## Contribute to Backend & Frontend
- Or develop both the backend and frontend at the same time!

```
bun run dev
```

**[`^top^`](#)**

----
## Code Review

We welcome constructive criticism and feedback on code submitted by contributors. All feedback should be constructive and respectful, and should focus on the code rather than the contributor. Code review may include suggestions for improvement or changes to the code.
Expand Down
58 changes: 58 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"$schema": "https://biomejs.dev/schemas/1.6.0/schema.json",
"formatter": {
"enabled": true,
"ignore": ["apps/**/*.min.js", "apps/**/*.min.css", "apps/**/*-lock.yaml", "**/*.lock.json", "**/build/**"],
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf"
},
"javascript": {
"formatter": {
"enabled": true,
"lineWidth": 120,
"quoteStyle": "single",
"semicolons": "always",
"trailingComma": "all"
}
},
"json": {
"formatter": {
"enabled": true,
"lineWidth": 120
},
"parser": {
"allowComments": true
}
},
"linter": {
"enabled": true,
"rules": {
"correctness": {
"noUnusedImports": "off",
"noUnusedVariables": "warn",
"useExhaustiveDependencies": "warn"
},
"complexity": {
"noUselessConstructor": "warn",
"noBannedTypes": "warn"
},
"suspicious": {
"noExplicitAny": "warn"
},
"style": {
"useImportType": "off"
},
"recommended": true
}
},
"organizeImports": {
"enabled": true
},
"vcs": {
"clientKind": "git",
"defaultBranch": "master",
"enabled": true,
"useIgnoreFile": true
}
}
2 changes: 2 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[install]
peer = true
5 changes: 5 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bun.serve({
fetch(req) {
return new Response("Bun!");
},
});
7 changes: 4 additions & 3 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "independent",
"npmClient": "pnpm",
"useWorkspaces": true,
"packages": ["packages/*"]
}
"packages": [
"packages/*"
]
}
51 changes: 34 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,48 @@
"name": "bigcapital-monorepo",
"private": true,
"scripts": {
"dev": "lerna run dev",
"build": "lerna run build",
"dev:webapp": "lerna run dev --scope \"@bigcapital/webapp\"",
"build:server": "lerna run build --scope \"@bigcapital/server\"",
"build:webapp": "lerna run build --scope \"@bigcapital/webapp\"",
"dev": "lerna run dev",
"dev:server": "lerna run dev --scope \"@bigcapital/server\"",
"build:server": "lerna run build --scope \"@bigcapital/server\"",
"dev:webapp": "lerna run dev --scope \"@bigcapital/webapp\"",
"format": "lerna run format --scope \"@bigcapital/webapp\" --scope \"@bigcapital/server\"",
"lint": "lerna run lint --scope \"@bigcapital/webapp\" --scope \"@bigcapital/server\"",
"lint.server": "lerna run lint:eslint --scope \"@bigcapital/server\"",
"prepare": "husky",
"serve:server": "lerna run serve --scope \"@bigcapital/server\"",
"test:e2e": "playwright test",
"prepare": "husky install"
},
"devDependencies": {
"@commitlint/cli": "^17.4.2",
"@commitlint/config-conventional": "^17.4.2",
"@commitlint/config-lerna-scopes": "^17.4.2",
"@faker-js/faker": "^8.0.2",
"@playwright/test": "^1.32.3",
"husky": "^8.0.3",
"lerna": "^6.4.1"
},
"engines": {
"node": "16.x || 17.x || 18.x"
"test:e2e": "playwright test"
},
"workspaces": [
"packages/*"
],
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"devDependencies": {
"@biomejs/biome": "^1.6.4",
"@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"@commitlint/config-lerna-scopes": "^19.0.0",
"@faker-js/faker": "^8.4.1",
"@playwright/test": "^1.43.0",
"@types/bcryptjs": "^2.4.6",
"@types/node": "^20.12.5",
"bun": "^1.1.2",
"bun-types": "^1.1.2",
"dotenv": "^16.4.5",
"dotenv-cli": "^7.4.1",
"husky": "^9.0.11",
"lerna": "^8.1.2",
"nx": "^18.2.3"
},
"engines": {
"node": "16.x || 17.x || 18.x || 20.x || 21.x"
},
"dependencies": {
"objection": "^3.1.4"
}
}
Binary file added packages/server/.DS_Store
Binary file not shown.
7 changes: 2 additions & 5 deletions packages/server/.babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"presets": ["@babel/preset-env"],
"retainLines": true,
"plugins": [
"@babel/plugin-transform-runtime",
"@babel/plugin-syntax-dynamic-import"
]
}
"plugins": ["@babel/plugin-transform-runtime", "@babel/plugin-syntax-dynamic-import"]
}
6 changes: 5 additions & 1 deletion packages/server/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
browser: true,
es6: true,
},
extends: ['airbnb-base', 'airbnb-typescript'],
extends: ['airbnb-base', 'airbnb-typescript', 'plugin:react/recommended'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
Expand All @@ -19,6 +19,10 @@ module.exports = {
rules: {
'import/no-unresolved': 'error',
'import/prefer-default-export': 'off',
'no-underscore-dangle': [
'error',
{ allow: ['__root_dir', '__resources_dir', '__locales_dir', '__views_dir', '__storage_dir'] },
],
},
settings: {
'import/parsers': {
Expand Down
15 changes: 15 additions & 0 deletions packages/server/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://biomejs.dev/schemas/1.6.0/schema.json",
"extends": ["../../biome.json"],
"linter": {
"enabled": true,
"rules": {
"style": {
"useImportType": "error"
},
"correctness": {
"noUnusedImports": "error"
}
}
}
}
16 changes: 16 additions & 0 deletions packages/server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// We need this in order to use @Decorators
// DO NOT CHANGE THE LINE SPACING OF THE IMPORTS
// OR THE LINTER WILL REORDER THEM
import 'reflect-metadata';

import { startServer } from './src/server';

// Additional initializations can go here
console.log('Additional initializations or logic before starting the server.');

// Now explicitly start the server
startServer().then(() => {
console.log('Server started successfully.');
}).catch((error) => {
console.error('Failed to start the server:', error);
});
Loading