Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
LironEr committed May 2, 2024
1 parent 9390ee8 commit 73a1f20
Show file tree
Hide file tree
Showing 125 changed files with 332 additions and 404 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
.nx
dist/
lib/
**/__tests__/**/assets
.vercel
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,4 @@ deploy.env
.nx/cache
.tmp
tmp
lib
2 changes: 1 addition & 1 deletion apps/service/.test.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NODE_ENV=development
APP_DOMAIN=localhost:4000
MONGO_URL=mongodb://localhost:51652
MONGO_URL=mongodb://localhost:51651
MONGO_DB_NAME=test
MONGO_DB_USER=test-user
MONGO_DB_PASSWORD=password
Expand Down
2 changes: 1 addition & 1 deletion apps/service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN addgroup --system service && adduser --system -G service service
# Needed by @fastify/secure-session
RUN npm i sodium-native@^4.0.0

COPY dist/apps/service service
COPY dist service

RUN chown -R service:service .

Expand Down
2 changes: 1 addition & 1 deletion apps/service/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
mongo:
image: mongo:7.0
ports:
- '51652:27017'
- '51651:27017'
logging:
driver: 'none'
command: --quiet
3 changes: 2 additions & 1 deletion apps/service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"license": "MIT",
"scripts": {
"serve": "yarn nx serve service",
"start:server:watch": "nodemon --watch \"src/*\" --exec ts-node -r dotenv/config -r tsconfig-paths/register \"src/app.ts\"",
"start:watch": "nodemon --watch \"src/*\" --ignore \"src/consts/schemas.ts\" --ext \".ts\" --exec \"yarn generate-schemas && ts-node -r tsconfig-paths/register src/app.ts\"",
"watch": "tsc -p tsconfig.release.json --watch --preserveWatchOutput --pretty",
Expand All @@ -13,7 +14,7 @@
"prevercel-deploy": "yarn lint && yarn type-check && yarn generate-schemas && yarn build",
"vercel-deploy": "vercel deploy",
"start:mock-services": "docker-compose -f docker-compose.test.yml up --remove-orphans",
"gen-local-data": "ts-node ./scripts/generateLocalData.ts"
"gen-local-data": "node -r @swc-node/register -r dotenv/config ./scripts/generateLocalData.ts dotenv_config_path=.development.env"
},
"dependencies": {
"@fastify/cookie": "^9.3.1",
Expand Down
7 changes: 4 additions & 3 deletions apps/service/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"tags": [],
"targets": {
"generateSchemas": {
"dependsOn": ["^build"],
"executor": "nx:run-commands",
"inputs": ["{projectRoot}/src/types/schemas/**/*"],
"outputs": ["{projectRoot}/src/consts/schemas.ts"],
Expand All @@ -17,14 +18,14 @@
}
},
"build": {
"dependsOn": ["generateSchemas"],
"dependsOn": ["^build", "generateSchemas"],
"executor": "@nx/esbuild:esbuild",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"platform": "node",
"target": "node18",
"outputPath": "dist/apps/service",
"outputPath": "{projectRoot}/dist",
"format": ["cjs"],
"bundle": true,
"deleteOutputPath": true,
Expand Down Expand Up @@ -111,7 +112,7 @@
},
"docker-build": {
"dependsOn": ["build"],
"command": "docker build -f apps/service/Dockerfile . -t bundlemon-service"
"command": "docker build -f apps/service/Dockerfile apps/service -t bundlemon-service"
},
"lint": {
"executor": "@nx/eslint:lint",
Expand Down
7 changes: 4 additions & 3 deletions apps/service/scripts/generateLocalData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as path from 'path';
import * as dotenv from 'dotenv';
dotenv.config({ path: path.join(__dirname, '../dev.env') });
// import * as path from 'node:path';
// import * as dotenv from 'dotenv';
// console.log('TCL ~ __dirname:', __dirname);
// dotenv.config({ path: path.join(__dirname, '../.development.env') });

import { ObjectId } from 'mongodb';
import { getDB } from '../src/framework/mongo/client';
Expand Down
2 changes: 1 addition & 1 deletion apps/service/tests/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
const path = require('path');

require('dotenv').config({
path: path.resolve(__dirname, '../test.env'),
path: path.resolve(__dirname, '../.test.env'),
});
1 change: 0 additions & 1 deletion apps/service/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["node"]
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
Expand Down
1 change: 0 additions & 1 deletion apps/service/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
}
],
"compilerOptions": {
"esModuleInterop": true,
"baseUrl": ".",
"paths": {
"@tests/*": ["./tests/*"],
Expand Down
1 change: 0 additions & 1 deletion apps/service/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
Expand Down
4 changes: 3 additions & 1 deletion apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"license": "MIT",
"scripts": {
"build:bundlemon": "yarn --cwd ../ build-packages"
"serve": "yarn nx serve website"
},
"dependencies": {
"@emotion/react": "^11.11.1",
Expand All @@ -29,10 +29,12 @@
"@types/react-dom": "^18.2.13",
"@types/react-router-dom": "^5.3.3",
"@types/recharts": "^1.8.25",
"@vitejs/plugin-basic-ssl": "^1.1.0",
"esbuild-loader": "^4.0.2",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"netlify-cli": "^16.7.0",
"vite": "^5.2.11",
"vite-plugin-svgr": "^4.2.0",
"vite-tsconfig-paths": "^4.3.2"
}
Expand Down
10 changes: 2 additions & 8 deletions apps/website/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
"tags": [],
"targets": {
"build": {
"dependsOn": ["^build"],
"executor": "@nx/vite:build",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"outputPath": "dist/apps/website",
"outputPath": "{projectRoot}/dist",
"generatePackageJson": false
},
"configurations": {
Expand Down Expand Up @@ -53,13 +54,6 @@
"buildTarget": "website:build:production"
}
}
},
"test": {
"executor": "@nx/vite:test",
"outputs": ["{options.reportsDirectory}"],
"options": {
"reportsDirectory": "../../coverage/apps/website"
}
}
}
}
2 changes: 1 addition & 1 deletion apps/website/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"module": "ES2022",
"jsx": "react-jsx",
"allowJs": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"jsxImportSource": "@emotion/react",
Expand Down
14 changes: 10 additions & 4 deletions apps/website/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,32 @@ import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
import svgr from 'vite-plugin-svgr';
import basicSsl from '@vitejs/plugin-basic-ssl'


export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/apps/website',
publicDir: path.join(__dirname, 'public'),
server: {
port: 4200,
port: 4000,
host: 'localhost',
},
preview: {
port: 4300,
port: 4000,
host: 'localhost',
},
plugins: [react(), tsconfigPaths(), svgr()],
plugins: [react(), tsconfigPaths(), svgr(), basicSsl()],
build: {
outDir: '../../dist/apps/website',
outDir: 'dist',
emptyOutDir: true,
reportCompressedSize: true,
commonjsOptions: {
transformMixedEsModules: true,
include: [/node_modules/, /bundlemon\-utils/],
},
},
optimizeDeps: {
include: ['bundlemon-utils']
}
});
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"private": true,
"license": "MIT",
"scripts": {
"test-packages": "yarn nx run-many --target=test --all --verbose",
"build-packages": "nx run-many --target=build --all",
"lint-packages": "yarn nx run-many --target=lint --all",
"test-packages": "yarn nx run-many --target=test --projects bundlemon-utils,bundlemon-markdown-output,bundlemon --verbose",
"build-packages": "nx run-many --target=build --projects bundlemon-utils,bundlemon-markdown-output,bundlemon",
"build-packages:watch": "nx watch --projects bundlemon-utils,bundlemon-markdown-output,bundlemon -- nx run \\$NX_PROJECT_NAME:build",
"lint-packages": "yarn nx run-many --target=lint --projects bundlemon-utils,bundlemon-markdown-output,bundlemon",
"type-check-packages": "lerna run type-check --stream",
"start:service": "docker-compose -f docker-compose.dev.yml up --build",
"prepare": "husky install"
Expand All @@ -19,6 +20,8 @@
"@nx/react": "^18.3.3",
"@nx/vite": "18.3.3",
"@nx/web": "18.3.3",
"@swc-node/register": "^1.9.1",
"@swc/core": "^1.4.17",
"@types/jest": "^29.5.1",
"@types/jest-when": "^3.5.2",
"@types/node": "18.16.9",
Expand All @@ -40,10 +43,10 @@
"lint-staged": "^15.2.2",
"nx": "18.3.2",
"prettier": "^3.0.2",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4",
"vite": "~5.0.0"
"typescript": "^5.0.4"
},
"engines": {
"yarn": "^1.10.0"
Expand Down
14 changes: 9 additions & 5 deletions packages/bundlemon-markdown-output/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@
"directory": "packages/bundlemon-markdown-output"
},
"engines": {
"node": ">=14.16"
"node": ">=18"
},
"main": "lib/index",
"module": "lib/index",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {},
"scripts": {
"build": "rimraf lib && tsc -p tsconfig.lib.json"
},
"dependencies": {
"bundlemon-utils": "^1.2.1",
"bytes": "^3.1.0"
},
"devDependencies": {
"@types/bytes": "^3.1.0"
}
},
"files": [
"lib"
]
}
30 changes: 5 additions & 25 deletions packages/bundlemon-markdown-output/project.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,17 @@
{
"name": "bundlemon-markdown-output",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/bundlemon-markdown-output/lib",
"sourceRoot": "{projectRoot}/src",
"projectType": "library",
"tags": [],
"generators": {},
"targets": {
"build": {
"executor": "@nx/js:tsc",
"executor": "nx:run-script",
"outputs": ["{projectRoot}/lib"],
"options": {
"outputPath": "dist/packages/bundlemon-markdown-output",
"tsConfig": "packages/bundlemon-markdown-output/tsconfig.lib.json",
"packageJson": "packages/bundlemon-markdown-output/package.json",
"main": "packages/bundlemon-markdown-output/lib/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [
"README.md",
"LICENSE",
{
"input": "packages/bundlemon-markdown-output",
"glob": "**/*.json",
"ignore": ["**/tsconfig*.json", "project.json", "node_modules/**"],
"output": "/"
},
{
"input": "packages/bundlemon-markdown-output",
"glob": "**/*.d.ts",
"ignore": ["node_modules/**"],
"output": "/"
}
]
},
"outputs": ["{options.outputPath}"]
"script": "build"
}
},
"lint": {
"executor": "@nx/eslint:lint",
Expand Down
6 changes: 5 additions & 1 deletion packages/bundlemon-markdown-output/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "CommonJS",
"rootDir": "src"
},
"files": [],
"include": [],
"references": [
Expand All @@ -10,4 +14,4 @@
"path": "./tsconfig.spec.json"
}
]
}
}
7 changes: 3 additions & 4 deletions packages/bundlemon-markdown-output/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "es2020",
"outDir": "../../dist/out-tsc",
"outDir": "lib",
"declaration": true,
"types": ["node", "jest"]
"types": ["node"]
},
"exclude": ["**/*.spec.ts", "jest.config.ts"],
"include": ["**/*.ts"]
"include": ["src/**/*.ts"]
}
4 changes: 2 additions & 2 deletions packages/bundlemon-markdown-output/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node", "jest-extended", "standard-version"]
"types": ["jest", "node"]
},
"include": ["**/*.spec.ts", "**/*.spec.js", "**/*.d.ts", "jest.config.ts"]
"include": ["jest.config.ts", "lib/**/*.test.ts", "lib/**/*.spec.ts", "lib/**/*.d.ts"]
}
Loading

0 comments on commit 73a1f20

Please sign in to comment.