@eggjs/tegg-config 4.0.0-beta.8 → 4.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/agent.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { App } from "./app-DV97Jgvz.js";
1
+ import App from "./app.js";
2
2
  export { App as default };
package/dist/agent.js CHANGED
@@ -1,5 +1,4 @@
1
- import "./ModuleScanner-bAAIC9jB.js";
2
- import { App } from "./app-CK_mbdMb.js";
1
+ import App from "./app.js";
3
2
 
4
3
  //#region src/agent.ts
5
4
  var agent_default = App;
package/dist/app.d.ts CHANGED
@@ -1,2 +1,11 @@
1
- import { App } from "./app-DV97Jgvz.js";
1
+ import { Application, ILifecycleBoot } from "egg";
2
+
3
+ //#region src/app.d.ts
4
+ declare class App implements ILifecycleBoot {
5
+ private readonly app;
6
+ constructor(app: Application);
7
+ configWillLoad(): void;
8
+ beforeClose(): Promise<void>;
9
+ }
10
+ //#endregion
2
11
  export { App as default };
package/dist/app.js CHANGED
@@ -1,4 +1,41 @@
1
- import "./ModuleScanner-bAAIC9jB.js";
2
- import { App } from "./app-CK_mbdMb.js";
1
+ import { ModuleScanner } from "./lib/ModuleScanner.js";
2
+ import { debuglog } from "node:util";
3
+ import { ModuleConfigUtil } from "@eggjs/tegg-common-util";
3
4
 
5
+ //#region src/app.ts
6
+ const debug = debuglog("egg/tegg/plugin/config/app");
7
+ var App = class {
8
+ app;
9
+ constructor(app) {
10
+ this.app = app;
11
+ const configNames = this.app.loader.getTypeFiles("module");
12
+ ModuleConfigUtil.setConfigNames(configNames);
13
+ }
14
+ configWillLoad() {
15
+ const { readModuleOptions } = this.app.config.tegg;
16
+ const moduleScanner = new ModuleScanner(this.app.baseDir, readModuleOptions);
17
+ this.app.moduleReferences = moduleScanner.loadModuleReferences();
18
+ debug("load moduleReferences: %o", this.app.moduleReferences);
19
+ this.app.moduleConfigs = {};
20
+ for (const reference of this.app.moduleReferences) {
21
+ const absoluteRef = {
22
+ path: ModuleConfigUtil.resolveModuleDir(reference.path, this.app.baseDir),
23
+ name: reference.name,
24
+ optional: reference.optional
25
+ };
26
+ const moduleName = ModuleConfigUtil.readModuleNameSync(absoluteRef.path);
27
+ this.app.moduleConfigs[moduleName] = {
28
+ name: moduleName,
29
+ reference: absoluteRef,
30
+ config: ModuleConfigUtil.loadModuleConfigSync(absoluteRef.path)
31
+ };
32
+ }
33
+ debug("load moduleConfigs: %o", this.app.moduleConfigs);
34
+ }
35
+ async beforeClose() {
36
+ ModuleConfigUtil.setConfigNames(void 0);
37
+ }
38
+ };
39
+
40
+ //#endregion
4
41
  export { App as default };
@@ -1,2 +1,6 @@
1
- import { _default } from "../config.default-DDmvKpMT.js";
2
- export { _default as default };
1
+ import { EggAppInfo, PartialEggConfig } from "egg";
2
+
3
+ //#region src/config/config.default.d.ts
4
+ declare function configFactory(appInfo: EggAppInfo): PartialEggConfig;
5
+ //#endregion
6
+ export { configFactory as default };
@@ -1,3 +1,11 @@
1
- import { config_default_default } from "../config.default-DePuDzML.js";
1
+ //#region src/config/config.default.ts
2
+ function configFactory(appInfo) {
3
+ return { tegg: { readModuleOptions: {
4
+ deep: 10,
5
+ cwd: appInfo.baseDir
6
+ } } };
7
+ }
8
+ var config_default_default = configFactory;
2
9
 
10
+ //#endregion
3
11
  export { config_default_default as default };
package/dist/index.d.ts CHANGED
@@ -1,3 +1 @@
1
- import "./app-DV97Jgvz.js";
2
- import "./config.default-DDmvKpMT.js";
3
- import "./types-DZQk5nVn.js";
1
+ import "./types.js";
package/dist/index.js CHANGED
@@ -1,6 +1 @@
1
- import "./ModuleScanner-bAAIC9jB.js";
2
- import "./app-CK_mbdMb.js";
3
- import "./config.default-DePuDzML.js";
4
- import "./types-DtTnp0o0.js";
5
-
6
1
  export { };
@@ -6,9 +6,9 @@ declare class ModuleScanner {
6
6
  private readonly readModuleOptions;
7
7
  constructor(baseDir: string, readModuleOptions: ReadModuleReferenceOptions);
8
8
  /**
9
- * - load module references from config or scan from baseDir
10
- * - load framework module as optional module reference
11
- */
9
+ * - load module references from config or scan from baseDir
10
+ * - load framework module as optional module reference
11
+ */
12
12
  loadModuleReferences(): readonly ModuleReference[];
13
13
  }
14
14
  //#endregion
@@ -1,3 +1,37 @@
1
- import { ModuleScanner } from "../ModuleScanner-bAAIC9jB.js";
1
+ import { debuglog } from "node:util";
2
+ import { ModuleConfigUtil } from "@eggjs/tegg-common-util";
3
+ import { readFileSync } from "node:fs";
4
+ import path from "node:path";
5
+ import { importResolve } from "@eggjs/utils";
2
6
 
7
+ //#region src/lib/ModuleScanner.ts
8
+ const debug = debuglog("egg/tegg/plugin/config/ModuleScanner");
9
+ var ModuleScanner = class {
10
+ baseDir;
11
+ readModuleOptions;
12
+ constructor(baseDir, readModuleOptions) {
13
+ this.baseDir = baseDir;
14
+ this.readModuleOptions = readModuleOptions;
15
+ }
16
+ /**
17
+ * - load module references from config or scan from baseDir
18
+ * - load framework module as optional module reference
19
+ */
20
+ loadModuleReferences() {
21
+ const moduleReferences = ModuleConfigUtil.readModuleReference(this.baseDir, this.readModuleOptions || {});
22
+ const framework = JSON.parse(readFileSync(path.join(this.baseDir, "package.json"), "utf-8")).egg?.framework;
23
+ if (!framework) return ModuleConfigUtil.deduplicateModules(moduleReferences);
24
+ const frameworkPkg = importResolve(`${framework}/package.json`, { paths: [this.baseDir] });
25
+ const frameworkDir = path.dirname(frameworkPkg);
26
+ debug("loadModuleReferences from framework:%o, frameworkDir:%o", framework, frameworkDir);
27
+ const optionalModuleReferences = ModuleConfigUtil.readModuleReference(frameworkDir, this.readModuleOptions || {});
28
+ const allModuleReferences = [...moduleReferences, ...optionalModuleReferences.map((ref) => ({
29
+ ...ref,
30
+ optional: true
31
+ }))];
32
+ return ModuleConfigUtil.deduplicateModules(allModuleReferences);
33
+ }
34
+ };
35
+
36
+ //#endregion
3
37
  export { ModuleScanner };
package/dist/types.d.ts CHANGED
@@ -1,3 +1,18 @@
1
- import "./app-DV97Jgvz.js";
2
- import "./config.default-DDmvKpMT.js";
3
- import "./types-DZQk5nVn.js";
1
+ import { ModuleConfigHolder, ModuleReference, ReadModuleReferenceOptions } from "@eggjs/tegg-common-util";
2
+
3
+ //#region src/types.d.ts
4
+ declare module "egg" {
5
+ interface EggAppConfig {
6
+ /**
7
+ * tegg config
8
+ */
9
+ tegg: {
10
+ readModuleOptions: ReadModuleReferenceOptions;
11
+ };
12
+ }
13
+ interface ModuleConfig {}
14
+ interface EggApplicationCore {
15
+ moduleReferences: readonly ModuleReference[];
16
+ moduleConfigs: Record<string, ModuleConfigHolder>;
17
+ }
18
+ }
package/dist/types.js CHANGED
@@ -1,6 +1 @@
1
- import "./ModuleScanner-bAAIC9jB.js";
2
- import "./app-CK_mbdMb.js";
3
- import "./config.default-DePuDzML.js";
4
- import "./types-DtTnp0o0.js";
5
-
6
1
  export { };
package/package.json CHANGED
@@ -1,22 +1,31 @@
1
1
  {
2
2
  "name": "@eggjs/tegg-config",
3
- "eggPlugin": {
4
- "name": "teggConfig"
5
- },
6
- "version": "4.0.0-beta.8",
3
+ "version": "4.0.1-beta.0",
7
4
  "description": "module config plugin for egg",
8
5
  "keywords": [
6
+ "config",
9
7
  "egg",
10
- "plugin",
11
- "typescript",
12
8
  "module",
13
- "config",
14
- "tegg"
9
+ "plugin",
10
+ "tegg",
11
+ "typescript"
15
12
  ],
13
+ "homepage": "https://github.com/eggjs/egg/tree/next/tegg/plugin/config",
14
+ "bugs": {
15
+ "url": "https://github.com/eggjs/egg/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/eggjs/egg.git",
20
+ "directory": "tegg/plugin/config"
21
+ },
16
22
  "files": [
17
23
  "dist"
18
24
  ],
19
25
  "type": "module",
26
+ "main": "./dist/index.js",
27
+ "module": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
20
29
  "exports": {
21
30
  ".": "./dist/index.js",
22
31
  "./agent": "./dist/agent.js",
@@ -26,42 +35,29 @@
26
35
  "./types": "./dist/types.js",
27
36
  "./package.json": "./package.json"
28
37
  },
29
- "homepage": "https://github.com/eggjs/tegg",
30
- "bugs": {
31
- "url": "https://github.com/eggjs/tegg/issues"
32
- },
33
- "repository": {
34
- "type": "git",
35
- "url": "git@github.com:eggjs/tegg.git",
36
- "directory": "plugin/config"
37
- },
38
- "engines": {
39
- "node": ">=22.18.0"
38
+ "publishConfig": {
39
+ "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@eggjs/utils": "beta",
43
- "@eggjs/tegg-common-util": "4.0.0-beta.8"
44
- },
45
- "peerDependencies": {
46
- "egg": "beta"
42
+ "@eggjs/utils": "5.0.1-beta.0",
43
+ "@eggjs/tegg-common-util": "4.0.1-beta.0"
47
44
  },
48
45
  "devDependencies": {
49
- "@eggjs/mock": "beta",
50
- "@types/node": "^22.10.5",
51
- "egg": "beta",
46
+ "@types/node": "^24.10.2",
52
47
  "typescript": "^5.9.3",
53
- "tsdown": "^0.15.6",
54
- "unplugin-unused": "^0.5.3"
48
+ "@eggjs/mock": "7.0.1-beta.0",
49
+ "egg": "4.1.1-beta.0"
55
50
  },
56
- "publishConfig": {
57
- "access": "public"
51
+ "peerDependencies": {
52
+ "egg": "4.1.1-beta.0"
53
+ },
54
+ "engines": {
55
+ "node": ">=22.18.0"
56
+ },
57
+ "eggPlugin": {
58
+ "name": "teggConfig"
58
59
  },
59
- "main": "./dist/index.js",
60
- "module": "./dist/index.js",
61
- "types": "./dist/index.d.ts",
62
60
  "scripts": {
63
- "clean": "rimraf dist",
64
- "build": "tsdown",
65
- "typecheck": "tsc --noEmit"
61
+ "typecheck": "tsgo --noEmit"
66
62
  }
67
63
  }
@@ -1,38 +0,0 @@
1
- import { debuglog } from "node:util";
2
- import { ModuleConfigUtil } from "@eggjs/tegg-common-util";
3
- import path from "node:path";
4
- import { readFileSync } from "node:fs";
5
- import { importResolve } from "@eggjs/utils";
6
-
7
- //#region src/lib/ModuleScanner.ts
8
- const debug = debuglog("tegg/plugin/config/ModuleScanner");
9
- var ModuleScanner = class {
10
- baseDir;
11
- readModuleOptions;
12
- constructor(baseDir, readModuleOptions) {
13
- this.baseDir = baseDir;
14
- this.readModuleOptions = readModuleOptions;
15
- }
16
- /**
17
- * - load module references from config or scan from baseDir
18
- * - load framework module as optional module reference
19
- */
20
- loadModuleReferences() {
21
- const moduleReferences = ModuleConfigUtil.readModuleReference(this.baseDir, this.readModuleOptions || {});
22
- const framework = JSON.parse(readFileSync(path.join(this.baseDir, "package.json"), "utf-8")).egg?.framework;
23
- if (!framework) return moduleReferences;
24
- const frameworkPkg = importResolve(`${framework}/package.json`, { paths: [this.baseDir] });
25
- const frameworkDir = path.dirname(frameworkPkg);
26
- debug("loadModuleReferences from framework:%o, frameworkDir:%o", framework, frameworkDir);
27
- const optionalModuleReferences = ModuleConfigUtil.readModuleReference(frameworkDir, this.readModuleOptions || {});
28
- const result = [...moduleReferences];
29
- for (const optionalModuleReference of optionalModuleReferences) if (!result.some((t) => t.path === optionalModuleReference.path)) result.push({
30
- ...optionalModuleReference,
31
- optional: true
32
- });
33
- return result;
34
- }
35
- };
36
-
37
- //#endregion
38
- export { ModuleScanner };
@@ -1,41 +0,0 @@
1
- import { ModuleScanner } from "./ModuleScanner-bAAIC9jB.js";
2
- import { debuglog } from "node:util";
3
- import { ModuleConfigUtil } from "@eggjs/tegg-common-util";
4
-
5
- //#region src/app.ts
6
- const debug = debuglog("tegg/plugin/config/app");
7
- var App = class {
8
- app;
9
- constructor(app) {
10
- this.app = app;
11
- const configNames = this.app.loader.getTypeFiles("module");
12
- ModuleConfigUtil.setConfigNames(configNames);
13
- }
14
- configWillLoad() {
15
- const { readModuleOptions } = this.app.config.tegg;
16
- const moduleScanner = new ModuleScanner(this.app.baseDir, readModuleOptions);
17
- this.app.moduleReferences = moduleScanner.loadModuleReferences();
18
- debug("load moduleReferences: %o", this.app.moduleReferences);
19
- this.app.moduleConfigs = {};
20
- for (const reference of this.app.moduleReferences) {
21
- const absoluteRef = {
22
- path: ModuleConfigUtil.resolveModuleDir(reference.path, this.app.baseDir),
23
- name: reference.name,
24
- optional: reference.optional
25
- };
26
- const moduleName = ModuleConfigUtil.readModuleNameSync(absoluteRef.path);
27
- this.app.moduleConfigs[moduleName] = {
28
- name: moduleName,
29
- reference: absoluteRef,
30
- config: ModuleConfigUtil.loadModuleConfigSync(absoluteRef.path)
31
- };
32
- }
33
- debug("load moduleConfigs: %o", this.app.moduleConfigs);
34
- }
35
- async beforeClose() {
36
- ModuleConfigUtil.setConfigNames(void 0);
37
- }
38
- };
39
-
40
- //#endregion
41
- export { App };
@@ -1,19 +0,0 @@
1
- import { ModuleConfigHolder, ModuleReference } from "@eggjs/tegg-common-util";
2
- import { Application, ILifecycleBoot } from "egg";
3
-
4
- //#region src/app.d.ts
5
- declare class App implements ILifecycleBoot {
6
- private readonly app;
7
- constructor(app: Application);
8
- configWillLoad(): void;
9
- beforeClose(): Promise<void>;
10
- }
11
- declare module 'egg' {
12
- interface ModuleConfig {}
13
- interface EggApplicationCore {
14
- moduleReferences: readonly ModuleReference[];
15
- moduleConfigs: Record<string, ModuleConfigHolder>;
16
- }
17
- }
18
- //#endregion
19
- export { App };
@@ -1,17 +0,0 @@
1
- import { ReadModuleReferenceOptions } from "@eggjs/tegg-common-util";
2
- import * as egg0 from "egg";
3
-
4
- //#region src/config/config.default.d.ts
5
- declare const _default: egg0.EggConfigFactory;
6
- declare module 'egg' {
7
- interface EggAppConfig {
8
- /**
9
- * tegg config
10
- */
11
- tegg: {
12
- readModuleOptions: ReadModuleReferenceOptions;
13
- };
14
- }
15
- }
16
- //#endregion
17
- export { _default };
@@ -1,13 +0,0 @@
1
- import "@eggjs/tegg-common-util";
2
- import { defineConfigFactory } from "egg";
3
-
4
- //#region src/config/config.default.ts
5
- var config_default_default = defineConfigFactory((appInfo) => {
6
- return { tegg: { readModuleOptions: {
7
- deep: 10,
8
- cwd: appInfo.baseDir
9
- } } };
10
- });
11
-
12
- //#endregion
13
- export { config_default_default };
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- export { };