From ea292e58188f3ab05dfacd20fadeff5a6434b1ad Mon Sep 17 00:00:00 2001 From: Krystof Date: Tue, 3 Dec 2024 23:16:37 +0100 Subject: [PATCH] refactor: remove constants package --- .prettierignore | 5 ++- apps/backend/package.json | 1 - apps/backend/src/app.module.ts | 2 +- .../src => apps/backend/src/constants}/api.ts | 9 ++++- apps/backend/src/constants/swagger.const.ts | 2 +- apps/backend/src/main.ts | 2 +- apps/web/package.json | 1 - apps/web/src/app/page.tsx | 2 +- apps/web/src/app/robots.ts | 2 +- apps/web/src/app/sitemap.ts | 2 +- apps/web/src/constants/api.ts | 17 +++++++++ apps/web/theme.config.tsx | 2 +- package.json | 1 - packages/constants/.gitignore | 1 - packages/constants/package.json | 20 ----------- packages/constants/src/external.ts | 8 ----- packages/constants/src/index.ts | 15 -------- packages/constants/tsconfig.cjs.json | 7 ---- packages/constants/tsconfig.esm.json | 7 ---- packages/constants/tsconfig.json | 18 ---------- pnpm-lock.yaml | 35 ++----------------- pnpm-workspace.yaml | 1 - 22 files changed, 38 insertions(+), 122 deletions(-) rename {packages/constants/src => apps/backend/src/constants}/api.ts (50%) create mode 100644 apps/web/src/constants/api.ts delete mode 100644 packages/constants/.gitignore delete mode 100644 packages/constants/package.json delete mode 100644 packages/constants/src/external.ts delete mode 100644 packages/constants/src/index.ts delete mode 100644 packages/constants/tsconfig.cjs.json delete mode 100644 packages/constants/tsconfig.esm.json delete mode 100644 packages/constants/tsconfig.json diff --git a/.prettierignore b/.prettierignore index abff7b55..b564ed20 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,4 +5,7 @@ node_modules .next pnpm-lock.yaml -schema.gql \ No newline at end of file +schema.gql + +apps/backend/dist +apps/mobile/metro-now/build \ No newline at end of file diff --git a/apps/backend/package.json b/apps/backend/package.json index 00b401bd..bb78aa1f 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -25,7 +25,6 @@ }, "dependencies": { "@apollo/server": "^4.11.0", - "@metro-now/constants": "workspace:*", "@nestjs/apollo": "^12.2.0", "@nestjs/cache-manager": "^2.2.2", "@nestjs/common": "^10.4.4", diff --git a/apps/backend/src/app.module.ts b/apps/backend/src/app.module.ts index 35582c6c..bce2de1f 100644 --- a/apps/backend/src/app.module.ts +++ b/apps/backend/src/app.module.ts @@ -1,4 +1,3 @@ -import { GRAPHQL_PATH } from "@metro-now/constants"; import { ApolloDriver, type ApolloDriverConfig } from "@nestjs/apollo"; import { CacheModule } from "@nestjs/cache-manager"; import { Module } from "@nestjs/common"; @@ -8,6 +7,7 @@ import { ScheduleModule } from "@nestjs/schedule"; import { cacheModuleConfig } from "src/config/cache-module.config"; import { configModuleConfig } from "src/config/config-module.config"; +import { GRAPHQL_PATH } from "src/constants/api"; import { DepartureModule } from "src/modules/departure/departure.module"; import { ImportModule } from "src/modules/import/import.module"; import { LoggerModule } from "src/modules/logger/logger.module"; diff --git a/packages/constants/src/api.ts b/apps/backend/src/constants/api.ts similarity index 50% rename from packages/constants/src/api.ts rename to apps/backend/src/constants/api.ts index 87bb9c65..bb7a0336 100644 --- a/packages/constants/src/api.ts +++ b/apps/backend/src/constants/api.ts @@ -1,4 +1,11 @@ -import { API_URL } from "./external"; +export const API_URL = "https://api.metronow.dev"; + +export const APPSTORE_URL = + "https://apps.apple.com/cz/app/metro-now/id6504659402?platform=appleWatch"; + +export const HOMEPAGE_URL = "https://metronow.dev"; + +export const SOURCE_CODE_URL = "https://github.com/krystxf/metro-now"; export const SWAGGER_JSON_PATH = "/swagger-json"; export const SWAGGER_JSON_URL = API_URL + SWAGGER_JSON_PATH; diff --git a/apps/backend/src/constants/swagger.const.ts b/apps/backend/src/constants/swagger.const.ts index 4c304ee7..ab02cfe4 100644 --- a/apps/backend/src/constants/swagger.const.ts +++ b/apps/backend/src/constants/swagger.const.ts @@ -2,7 +2,7 @@ import { GRAPHQL_PATH, SOURCE_CODE_URL, SWAGGER_JSON_PATH, -} from "@metro-now/constants"; +} from "src/constants/api"; export const SWAGGER_TITLE = "Metro Now API"; export const SWAGGER_VERSION = "1.0"; diff --git a/apps/backend/src/main.ts b/apps/backend/src/main.ts index 7db6ca9c..f7dcaa0f 100644 --- a/apps/backend/src/main.ts +++ b/apps/backend/src/main.ts @@ -1,9 +1,9 @@ -import { SWAGGER_JSON_PATH, SWAGGER_PATH } from "@metro-now/constants"; import { VersioningType } from "@nestjs/common"; import { NestFactory } from "@nestjs/core"; import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger"; import { AppModule } from "src/app.module"; +import { SWAGGER_JSON_PATH, SWAGGER_PATH } from "src/constants/api"; import { SWAGGER_DESCRIPTION, SWAGGER_TITLE, diff --git a/apps/web/package.json b/apps/web/package.json index 5758d7c8..df15c167 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -12,7 +12,6 @@ }, "dependencies": { "@heroicons/react": "^2.1.5", - "@metro-now/constants": "workspace:*", "@next/mdx": "^14.2.2", "clsx": "^2.1.1", "framer-motion": "^11.11.17", diff --git a/apps/web/src/app/page.tsx b/apps/web/src/app/page.tsx index d359b51f..10641e83 100644 --- a/apps/web/src/app/page.tsx +++ b/apps/web/src/app/page.tsx @@ -8,7 +8,7 @@ import { GRAPHQL_URL, SOURCE_CODE_URL, SWAGGER_URL, -} from "@metro-now/constants"; +} from "../constants/api"; import DownloadOnAppStoreLight from "../../public/download-on-appstore-light.svg"; import MetroNowIcon from "../../public/metro-now-icon.png"; import MetroNowIphoneMockup from "../../public/iphone-mockup.png"; diff --git a/apps/web/src/app/robots.ts b/apps/web/src/app/robots.ts index 48aa2d6d..614b3f8c 100644 --- a/apps/web/src/app/robots.ts +++ b/apps/web/src/app/robots.ts @@ -1,4 +1,4 @@ -import { HOMEPAGE_URL } from "@metro-now/constants"; +import { HOMEPAGE_URL } from "../constants/api"; import type { MetadataRoute } from "next"; const robots = (): MetadataRoute.Robots => ({ diff --git a/apps/web/src/app/sitemap.ts b/apps/web/src/app/sitemap.ts index 7168b530..5248d8b9 100644 --- a/apps/web/src/app/sitemap.ts +++ b/apps/web/src/app/sitemap.ts @@ -1,4 +1,4 @@ -import { HOMEPAGE_URL } from "@metro-now/constants"; +import { HOMEPAGE_URL } from "../constants/api"; import type { MetadataRoute } from "next"; const docsPaths = [ diff --git a/apps/web/src/constants/api.ts b/apps/web/src/constants/api.ts new file mode 100644 index 00000000..bb7a0336 --- /dev/null +++ b/apps/web/src/constants/api.ts @@ -0,0 +1,17 @@ +export const API_URL = "https://api.metronow.dev"; + +export const APPSTORE_URL = + "https://apps.apple.com/cz/app/metro-now/id6504659402?platform=appleWatch"; + +export const HOMEPAGE_URL = "https://metronow.dev"; + +export const SOURCE_CODE_URL = "https://github.com/krystxf/metro-now"; + +export const SWAGGER_JSON_PATH = "/swagger-json"; +export const SWAGGER_JSON_URL = API_URL + SWAGGER_JSON_PATH; + +export const SWAGGER_PATH = "/"; +export const SWAGGER_URL = API_URL + SWAGGER_PATH; + +export const GRAPHQL_PATH = "/graphql"; +export const GRAPHQL_URL = API_URL + GRAPHQL_PATH; diff --git a/apps/web/theme.config.tsx b/apps/web/theme.config.tsx index 6aba47f4..df80b584 100644 --- a/apps/web/theme.config.tsx +++ b/apps/web/theme.config.tsx @@ -1,4 +1,4 @@ -import { SOURCE_CODE_URL } from "@metro-now/constants"; +import { SOURCE_CODE_URL } from "./src/constants/api"; import React from "react"; diff --git a/package.json b/package.json index 8aa8ed79..9c1b49e4 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "scripts": { "xcode": "xed ./apps/mobile/metro-now", "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", diff --git a/packages/constants/.gitignore b/packages/constants/.gitignore deleted file mode 100644 index 53c37a16..00000000 --- a/packages/constants/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dist \ No newline at end of file diff --git a/packages/constants/package.json b/packages/constants/package.json deleted file mode 100644 index f55a07f3..00000000 --- a/packages/constants/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "@metro-now/constants", - "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/src/external.ts b/packages/constants/src/external.ts deleted file mode 100644 index 66623b65..00000000 --- a/packages/constants/src/external.ts +++ /dev/null @@ -1,8 +0,0 @@ -export const API_URL = "https://api.metronow.dev"; - -export const APPSTORE_URL = - "https://apps.apple.com/cz/app/metro-now/id6504659402?platform=appleWatch"; - -export const HOMEPAGE_URL = "https://metronow.dev"; - -export const SOURCE_CODE_URL = "https://github.com/krystxf/metro-now"; diff --git a/packages/constants/src/index.ts b/packages/constants/src/index.ts deleted file mode 100644 index 4a752be8..00000000 --- a/packages/constants/src/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -export { - GRAPHQL_PATH, - GRAPHQL_URL, - SWAGGER_JSON_PATH, - SWAGGER_JSON_URL, - SWAGGER_PATH, - SWAGGER_URL, -} from "./api"; - -export { - API_URL, - APPSTORE_URL, - HOMEPAGE_URL, - SOURCE_CODE_URL, -} from "./external"; diff --git a/packages/constants/tsconfig.cjs.json b/packages/constants/tsconfig.cjs.json deleted file mode 100644 index ec3353b3..00000000 --- a/packages/constants/tsconfig.cjs.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "CommonJS", - "outDir": "./dist/cjs/" - } -} diff --git a/packages/constants/tsconfig.esm.json b/packages/constants/tsconfig.esm.json deleted file mode 100644 index cc19e14d..00000000 --- a/packages/constants/tsconfig.esm.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "ESNext", - "outDir": "./dist/esm/" - } -} diff --git a/packages/constants/tsconfig.json b/packages/constants/tsconfig.json deleted file mode 100644 index bee35f68..00000000 --- a/packages/constants/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "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 11edf29f..f1c871cf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,9 +17,6 @@ importers: '@apollo/server': specifier: ^4.11.0 version: 4.11.0(graphql@16.9.0) - '@metro-now/constants': - specifier: workspace:* - version: link:../../packages/constants '@nestjs/apollo': specifier: ^12.2.0 version: 12.2.0(@apollo/server@4.11.0(graphql@16.9.0))(@nestjs/common@10.4.4(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.4(@nestjs/common@10.4.4(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.4)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/graphql@12.2.0(@nestjs/common@10.4.4(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.4(@nestjs/common@10.4.4(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.4)(reflect-metadata@0.2.2)(rxjs@7.8.1))(graphql@16.9.0)(reflect-metadata@0.2.2))(graphql@16.9.0) @@ -159,9 +156,6 @@ importers: '@heroicons/react': specifier: ^2.1.5 version: 2.1.5(react@18.3.1) - '@metro-now/constants': - specifier: workspace:* - version: link:../../packages/constants '@next/mdx': specifier: ^14.2.2 version: 14.2.11(@mdx-js/react@2.3.0(react@18.3.1)) @@ -221,12 +215,6 @@ importers: specifier: ^5 version: 5.6.2 - packages/constants: - devDependencies: - typescript: - specifier: ^5 - version: 5.6.2 - packages: '@alloc/quick-lru@5.2.0': @@ -8150,7 +8138,7 @@ snapshots: debug: 4.3.7 enhanced-resolve: 5.17.1 eslint: 8.57.1 - eslint-module-utils: 2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.6.2))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.6.2))(eslint-plugin-import@2.31.0)(eslint@8.57.1))(eslint@8.57.1) + eslint-module-utils: 2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.6.2))(eslint-plugin-import@2.31.0)(eslint@8.57.1))(eslint@8.57.1) fast-glob: 3.3.2 get-tsconfig: 4.8.1 is-bun-module: 1.2.1 @@ -8185,25 +8173,6 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-module-utils@2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.6.2))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.6.2))(eslint-plugin-import@2.31.0)(eslint@8.57.1))(eslint@8.57.1): - dependencies: - debug: 3.2.7 - optionalDependencies: - '@typescript-eslint/parser': 6.21.0(eslint@8.57.1)(typescript@5.6.2) - eslint: 8.57.1 - eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.6.2))(eslint-plugin-import@2.31.0)(eslint@8.57.1) - transitivePeerDependencies: - - supports-color - - eslint-module-utils@2.12.0(eslint-import-resolver-node@0.3.9)(eslint@8.57.1): - dependencies: - debug: 3.2.7 - optionalDependencies: - eslint: 8.57.1 - eslint-import-resolver-node: 0.3.9 - transitivePeerDependencies: - - supports-color - eslint-plugin-import@2.31.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.6.2))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1): dependencies: '@rtsao/scc': 1.1.0 @@ -8244,7 +8213,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.12.0(eslint-import-resolver-node@0.3.9)(eslint@8.57.1) + eslint-module-utils: 2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@8.57.1))(eslint@8.57.1) hasown: 2.0.2 is-core-module: 2.15.1 is-glob: 4.0.3 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 4af31626..c0329a9e 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,3 +1,2 @@ packages: - "apps/*" - - "packages/*"