From dcbfc0782accd07c8606423ce83257787b832f68 Mon Sep 17 00:00:00 2001 From: Krystof Date: Tue, 5 Nov 2024 12:07:43 +0100 Subject: [PATCH] fix(be): constants package --- .github/workflows/backend-ci.yaml | 4 ++++ .github/workflows/web-ci.yaml | 4 ++++ Dockerfile | 2 +- package.json | 5 +++-- packages/constants/.gitignore | 1 + packages/constants/package.json | 18 +++++++++++++++++- packages/constants/{ => src}/index.ts | 4 ++-- packages/constants/tsconfig.cjs.json | 7 +++++++ packages/constants/tsconfig.esm.json | 7 +++++++ packages/constants/tsconfig.json | 18 ++++++++++++++++++ pnpm-lock.yaml | 6 +++++- 11 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 packages/constants/.gitignore rename packages/constants/{ => src}/index.ts (81%) create mode 100644 packages/constants/tsconfig.cjs.json create mode 100644 packages/constants/tsconfig.esm.json create mode 100644 packages/constants/tsconfig.json diff --git a/.github/workflows/backend-ci.yaml b/.github/workflows/backend-ci.yaml index 3f67123..7e2e889 100644 --- a/.github/workflows/backend-ci.yaml +++ b/.github/workflows/backend-ci.yaml @@ -33,6 +33,10 @@ jobs: cd apps/backend pnpm prisma:generate + - name: Build dependencies + run: | + pnpm prebuild + - name: Build run: | cd apps/backend diff --git a/.github/workflows/web-ci.yaml b/.github/workflows/web-ci.yaml index faf0545..4072176 100644 --- a/.github/workflows/web-ci.yaml +++ b/.github/workflows/web-ci.yaml @@ -28,6 +28,10 @@ jobs: run: | pnpm install + - name: Build dependencies + run: | + pnpm prebuild + - name: Build run: | cd apps/web diff --git a/Dockerfile b/Dockerfile index f1842dc..b58cac1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ FROM base AS build COPY . /usr/src/app WORKDIR /usr/src/app RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile -RUN pnpm run -r --parallel build +RUN pnpm run build RUN pnpm deploy --filter=@metro-now/web --prod /prod/web RUN pnpm deploy --filter=@metro-now/backend --prod /prod/backend diff --git a/package.json b/package.json index e169b46..a24e7b1 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,14 @@ "packageManager": "pnpm@9.1.0", "scripts": { "xcode": "xed ./apps/mobile/metro-now", - "build": "pnpm --recursive --parallel run build", "dev": "pnpm --recursive --parallel run dev", + "prebuild": "pnpm run -r --filter @metro-now/constants build", + "build": "pnpm --recursive --parallel run build", "backend:build": "pnpm run -r --filter @metro-now/backend build", "backend:dev": "pnpm run -r --filter @metro-now/backend dev", "web:dev": "pnpm run -r --filter @metro-now/web dev", "precommit": "pnpm format", - "format": "pnpm -r format && pnpm exec prettier . --write", + "format": "pnpm --recursive --parallel format && pnpm exec prettier . --write", "format:check": "pnpm -r format:check && pnpm exec prettier . --check", "docker:up:dev": "docker compose up postgres redis-stack", "docker:up": "docker compose up -d --build", diff --git a/packages/constants/.gitignore b/packages/constants/.gitignore new file mode 100644 index 0000000..53c37a1 --- /dev/null +++ b/packages/constants/.gitignore @@ -0,0 +1 @@ +dist \ No newline at end of file diff --git a/packages/constants/package.json b/packages/constants/package.json index 6cbb53d..f55a07f 100644 --- a/packages/constants/package.json +++ b/packages/constants/package.json @@ -1,4 +1,20 @@ { "name": "@metro-now/constants", - "packageManager": "pnpm@9.1.0" + "packageManager": "pnpm@9.1.0", + "files": [ + "dist" + ], + "types": "./dist/esm/src/index.d.ts", + "exports": { + "require": "./dist/cjs/src/index.js", + "import": "./dist/esm/src/index.js" + }, + "scripts": { + "build": "pnpm run --parallel --filter @metro-now/constants \"/(build:cjs|build:esm)/\"", + "build:cjs": "tsc --project tsconfig.cjs.json", + "build:esm": "tsc --project tsconfig.esm.json" + }, + "devDependencies": { + "typescript": "^5" + } } diff --git a/packages/constants/index.ts b/packages/constants/src/index.ts similarity index 81% rename from packages/constants/index.ts rename to packages/constants/src/index.ts index b598f06..4a752be 100644 --- a/packages/constants/index.ts +++ b/packages/constants/src/index.ts @@ -5,11 +5,11 @@ export { SWAGGER_JSON_URL, SWAGGER_PATH, SWAGGER_URL, -} from "./src/api"; +} from "./api"; export { API_URL, APPSTORE_URL, HOMEPAGE_URL, SOURCE_CODE_URL, -} from "./src/external"; +} from "./external"; diff --git a/packages/constants/tsconfig.cjs.json b/packages/constants/tsconfig.cjs.json new file mode 100644 index 0000000..ec3353b --- /dev/null +++ b/packages/constants/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "CommonJS", + "outDir": "./dist/cjs/" + } +} diff --git a/packages/constants/tsconfig.esm.json b/packages/constants/tsconfig.esm.json new file mode 100644 index 0000000..cc19e14 --- /dev/null +++ b/packages/constants/tsconfig.esm.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "ESNext", + "outDir": "./dist/esm/" + } +} diff --git a/packages/constants/tsconfig.json b/packages/constants/tsconfig.json new file mode 100644 index 0000000..bee35f6 --- /dev/null +++ b/packages/constants/tsconfig.json @@ -0,0 +1,18 @@ +{ + "include": ["src/**/*"], + "compilerOptions": { + "moduleResolution": "Node", + "target": "ES2022", + "declaration": true, + "removeComments": true, + "allowSyntheticDefaultImports": true, + "incremental": true, + "composite": true, + + "strict": true, + "strictPropertyInitialization": false, + + "outDir": "dist", + "baseUrl": "." + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 09011a9..e67bb56 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -212,7 +212,11 @@ importers: specifier: ^5 version: 5.6.2 - packages/constants: {} + packages/constants: + devDependencies: + typescript: + specifier: ^5 + version: 5.6.2 packages: