From 843fcd0fc6f1ee886578c9049f43965afb933357 Mon Sep 17 00:00:00 2001 From: killa Date: Tue, 26 Mar 2024 18:20:12 +0800 Subject: [PATCH] fix: move tegg to optional peer deps (#260) --- lib/cmd/dal/gen.js | 11 ++++++++++- lib/dal-gen.js | 4 ++-- package.json | 19 ++++++++++++------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/lib/cmd/dal/gen.js b/lib/cmd/dal/gen.js index 830c701..07ef180 100644 --- a/lib/cmd/dal/gen.js +++ b/lib/cmd/dal/gen.js @@ -1,5 +1,4 @@ const path = require('node:path'); -const { ModuleConfigUtil } = require('@eggjs/tegg-common-util'); const Command = require('../../command'); class DalGenCommand extends Command { @@ -17,6 +16,16 @@ class DalGenCommand extends Command { } async run(context) { + let ModuleConfigUtil; + try { + const commonUtilHelper = require('@eggjs/tegg/helper'); + ModuleConfigUtil = commonUtilHelper.ModuleConfigUtil; + } catch { + console.error('should install @eggjs/tegg first'); + process.exit(1); + } + + const { cwd, argv } = context; const baseDir = argv.baseDir || cwd; diff --git a/lib/dal-gen.js b/lib/dal-gen.js index aad0461..5616e89 100644 --- a/lib/dal-gen.js +++ b/lib/dal-gen.js @@ -1,7 +1,7 @@ const assert = require('node:assert'); -const { TableModel, TableInfoUtil } = require('@eggjs/dal-decorator'); +const { TableModel, TableInfoUtil } = require('@eggjs/tegg/dal'); const { CodeGenerator } = require('@eggjs/dal-runtime'); -const { LoaderFactory } = require('@eggjs/tegg-loader'); +const { LoaderFactory } = require('@eggjs/tegg/helper'); const moduleDir = process.argv[2]; assert(moduleDir, 'miss module dir'); diff --git a/package.json b/package.json index 49a2583..e4e1136 100644 --- a/package.json +++ b/package.json @@ -33,22 +33,27 @@ "test": "^3.0.0", "ts-node": "^10.8.0", "tsconfig-paths": "^4.1.1", - "ypkgfiles": "^1.6.0", - "@eggjs/tegg-common-util": "^3.33.0", - "@eggjs/dal-runtime": "^3.33.0", - "@eggjs/dal-decorator": "^3.33.0", - "@eggjs/tegg-loader": "^3.33.0", - "@eggjs/tegg": "^3.33.0" + "ypkgfiles": "^1.6.0" }, "peerDependencies": { - "egg-mock": ">=5.8.3" + "egg-mock": ">=5.8.3", + "@eggjs/tegg": "^3.33.0", + "@eggjs/dal-runtime": "^3.33.0" }, "peerDependenciesMeta": { "egg-mock": { "optional": true + }, + "@eggjs/tegg": { + "optional": true + }, + "@eggjs/dal-runtime": { + "optional": true } }, "devDependencies": { + "@eggjs/dal-runtime": "^3.33.0", + "@eggjs/tegg": "^3.33.0", "@eggjs/tsconfig": "^1.2.0", "@types/mocha": "^10.0.1", "@types/node": "^14.18.36",