From c13db020f6ef92fd3bde719a2dd36ac1c073167b Mon Sep 17 00:00:00 2001 From: zhumeisongsong Date: Mon, 18 Nov 2024 10:32:10 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20move=20config?= =?UTF-8?q?=20to=20shared/config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/config/eslint.config.js | 3 --- libs/config/project.json | 9 --------- libs/{ => shared}/config/README.md | 0 libs/shared/config/eslint.config.js | 3 +++ libs/{ => shared}/config/jest.config.ts | 4 ++-- libs/shared/config/project.json | 9 +++++++++ libs/{ => shared}/config/src/index.ts | 0 .../config/src/lib/applications.config.spec.ts | 0 libs/{ => shared}/config/src/lib/applications.config.ts | 0 libs/{ => shared}/config/src/lib/database.config.spec.ts | 0 libs/{ => shared}/config/src/lib/database.config.ts | 5 +++-- libs/{ => shared}/config/tsconfig.json | 2 +- libs/{ => shared}/config/tsconfig.lib.json | 0 libs/{ => shared}/config/tsconfig.spec.json | 2 +- 14 files changed, 19 insertions(+), 18 deletions(-) delete mode 100644 libs/config/eslint.config.js delete mode 100644 libs/config/project.json rename libs/{ => shared}/config/README.md (100%) create mode 100644 libs/shared/config/eslint.config.js rename libs/{ => shared}/config/jest.config.ts (68%) create mode 100644 libs/shared/config/project.json rename libs/{ => shared}/config/src/index.ts (100%) rename libs/{ => shared}/config/src/lib/applications.config.spec.ts (100%) rename libs/{ => shared}/config/src/lib/applications.config.ts (100%) rename libs/{ => shared}/config/src/lib/database.config.spec.ts (100%) rename libs/{ => shared}/config/src/lib/database.config.ts (71%) rename libs/{ => shared}/config/tsconfig.json (90%) rename libs/{ => shared}/config/tsconfig.lib.json (100%) rename libs/{ => shared}/config/tsconfig.spec.json (85%) diff --git a/libs/config/eslint.config.js b/libs/config/eslint.config.js deleted file mode 100644 index df7cfc2..0000000 --- a/libs/config/eslint.config.js +++ /dev/null @@ -1,3 +0,0 @@ -const baseConfig = require('../../eslint.config.js'); - -module.exports = [...baseConfig]; diff --git a/libs/config/project.json b/libs/config/project.json deleted file mode 100644 index 281a94f..0000000 --- a/libs/config/project.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "config", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/config/src", - "projectType": "library", - "tags": [], - "// targets": "to see all targets run: nx show project config --web", - "targets": {} -} diff --git a/libs/config/README.md b/libs/shared/config/README.md similarity index 100% rename from libs/config/README.md rename to libs/shared/config/README.md diff --git a/libs/shared/config/eslint.config.js b/libs/shared/config/eslint.config.js new file mode 100644 index 0000000..07e518f --- /dev/null +++ b/libs/shared/config/eslint.config.js @@ -0,0 +1,3 @@ +const baseConfig = require('../../../eslint.config.js'); + +module.exports = [...baseConfig]; diff --git a/libs/config/jest.config.ts b/libs/shared/config/jest.config.ts similarity index 68% rename from libs/config/jest.config.ts rename to libs/shared/config/jest.config.ts index bb3bf75..7919671 100644 --- a/libs/config/jest.config.ts +++ b/libs/shared/config/jest.config.ts @@ -1,10 +1,10 @@ export default { displayName: 'config', - preset: '../../jest.preset.js', + preset: '../../../jest.preset.js', testEnvironment: 'node', transform: { '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], }, moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/libs/config', + coverageDirectory: '../../../coverage/libs/shared/config', }; diff --git a/libs/shared/config/project.json b/libs/shared/config/project.json new file mode 100644 index 0000000..d921a12 --- /dev/null +++ b/libs/shared/config/project.json @@ -0,0 +1,9 @@ +{ + "name": "shared-config", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/shared/config/src", + "projectType": "library", + "tags": [], + "// targets": "to see all targets run: nx show project config --web", + "targets": {} +} diff --git a/libs/config/src/index.ts b/libs/shared/config/src/index.ts similarity index 100% rename from libs/config/src/index.ts rename to libs/shared/config/src/index.ts diff --git a/libs/config/src/lib/applications.config.spec.ts b/libs/shared/config/src/lib/applications.config.spec.ts similarity index 100% rename from libs/config/src/lib/applications.config.spec.ts rename to libs/shared/config/src/lib/applications.config.spec.ts diff --git a/libs/config/src/lib/applications.config.ts b/libs/shared/config/src/lib/applications.config.ts similarity index 100% rename from libs/config/src/lib/applications.config.ts rename to libs/shared/config/src/lib/applications.config.ts diff --git a/libs/config/src/lib/database.config.spec.ts b/libs/shared/config/src/lib/database.config.spec.ts similarity index 100% rename from libs/config/src/lib/database.config.spec.ts rename to libs/shared/config/src/lib/database.config.spec.ts diff --git a/libs/config/src/lib/database.config.ts b/libs/shared/config/src/lib/database.config.ts similarity index 71% rename from libs/config/src/lib/database.config.ts rename to libs/shared/config/src/lib/database.config.ts index 647a408..5194158 100644 --- a/libs/config/src/lib/database.config.ts +++ b/libs/shared/config/src/lib/database.config.ts @@ -10,8 +10,9 @@ export type DatabaseConfig = z.infer; export const databaseConfig = registerAs('database', () => { const config = { - host: process.env['DATABASE_HOST'], - port: process.env['DATABASE_PORT'] || 5432, + host: process.env['DATABASE_HOST'] || 'localhost', + port: process.env['DATABASE_PORT'] || 27017, + name: process.env['DATABASE_NAME'] || '', }; return databaseSchema.parse(config); diff --git a/libs/config/tsconfig.json b/libs/shared/config/tsconfig.json similarity index 90% rename from libs/config/tsconfig.json rename to libs/shared/config/tsconfig.json index 6f7169a..0dc79ca 100644 --- a/libs/config/tsconfig.json +++ b/libs/shared/config/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "../../../tsconfig.base.json", "compilerOptions": { "module": "commonjs", "forceConsistentCasingInFileNames": true, diff --git a/libs/config/tsconfig.lib.json b/libs/shared/config/tsconfig.lib.json similarity index 100% rename from libs/config/tsconfig.lib.json rename to libs/shared/config/tsconfig.lib.json diff --git a/libs/config/tsconfig.spec.json b/libs/shared/config/tsconfig.spec.json similarity index 85% rename from libs/config/tsconfig.spec.json rename to libs/shared/config/tsconfig.spec.json index 9b2a121..69a251f 100644 --- a/libs/config/tsconfig.spec.json +++ b/libs/shared/config/tsconfig.spec.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "module": "commonjs", "types": ["jest", "node"] },