@midwayjs/web 3.1.4 → 3.1.7-alpha.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/cluster.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ var _a, _b;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const core_1 = require("@midwayjs/core");
4
5
  const path_1 = require("path");
@@ -13,7 +14,7 @@ function runInAgent() {
13
14
  process.env['EGG_CLUSTER_MODE'] = 'true';
14
15
  const isAgent = runInAgent();
15
16
  debug('[egg]: run with egg-scripts in worker and init midway container in cluster mode');
16
- const appDir = process.cwd();
17
+ const appDir = (_b = (_a = JSON.parse(process.argv[2])) === null || _a === void 0 ? void 0 : _a.baseDir) !== null && _b !== void 0 ? _b : process.cwd();
17
18
  let baseDir;
18
19
  if ((0, utils_1.isTypeScriptEnvironment)()) {
19
20
  baseDir = (0, path_1.join)(appDir, 'src');
@@ -21,11 +22,10 @@ if ((0, utils_1.isTypeScriptEnvironment)()) {
21
22
  else {
22
23
  baseDir = (0, path_1.join)(appDir, 'dist');
23
24
  }
24
- (0, core_1.initializeGlobalApplicationContext)({
25
+ (0, core_1.prepareGlobalApplicationContext)({
25
26
  appDir,
26
27
  baseDir,
27
28
  ignore: ['**/app/extend/**'],
28
- lazyInitializeFramework: true,
29
29
  });
30
30
  if (!isAgent) {
31
31
  debug('[egg]: run with egg-scripts in worker and init midway container complete');
@@ -1,8 +1,8 @@
1
1
  import { BaseFramework, IMidwayBootstrapOptions, RouterInfo, WebControllerGenerator } from '@midwayjs/core';
2
2
  import { MidwayFrameworkType } from '@midwayjs/decorator';
3
- import { IMidwayWebConfigurationOptions } from '../interface';
3
+ import { IMidwayWebConfigurationOptions, Application, Context } from '../interface';
4
4
  import { EggRouter } from '@eggjs/router';
5
- import { Application, Context, EggLogger } from 'egg';
5
+ import { EggLogger } from 'egg';
6
6
  declare class EggControllerGenerator extends WebControllerGenerator<EggRouter> {
7
7
  readonly app: any;
8
8
  constructor(app: any);
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
- import { Context as EggContext, Application as EggApplication, EggAppConfig } from 'egg';
3
- import { IMidwayContainer, IMidwayContext, Context as IMidwayBaseContext, IMidwayApplication, IMidwayBaseApplication, IConfigurationOptions, NextFunction as BaseNextFunction } from '@midwayjs/core';
2
+ import { Context as EggContext, Application as EggApplication } from 'egg';
3
+ import { IMidwayContainer, IMidwayContext, IMidwayApplication, IConfigurationOptions, NextFunction as BaseNextFunction } from '@midwayjs/core';
4
4
  import { DefaultState, Middleware } from 'koa';
5
5
  import { ILogger, LoggerOptions } from '@midwayjs/logger';
6
6
  export interface IMidwayWebBaseApplication {
@@ -10,20 +10,6 @@ export interface IMidwayWebBaseApplication {
10
10
  generateMiddleware?(middlewareId: any): Promise<Middleware<DefaultState, EggContext>>;
11
11
  createLogger(name: string, options: LoggerOptions): ILogger;
12
12
  }
13
- declare module 'egg' {
14
- interface EggAppInfo {
15
- appDir: string;
16
- }
17
- interface Application extends IMidwayBaseApplication<Context>, IMidwayWebBaseApplication {
18
- createAnonymousContext(...args: any[]): EggContext;
19
- getCoreLogger(): EggLogger & ILogger;
20
- getLogger(name?: string): EggLogger & ILogger;
21
- createLogger(name: string, options: LoggerOptions): EggLogger & ILogger;
22
- }
23
- interface Context<ResponseBodyT = any> extends IMidwayBaseContext {
24
- getLogger(name?: string): ILogger;
25
- }
26
- }
27
13
  export declare type IMidwayWebApplication = IMidwayApplication<Context, EggApplication & IMidwayWebBaseApplication>;
28
14
  export interface Application extends IMidwayWebApplication {
29
15
  }
@@ -85,9 +71,4 @@ export declare type MidwayWebMiddleware = Middleware<DefaultState, Context>;
85
71
  export interface IWebMiddleware {
86
72
  resolve(): MidwayWebMiddleware;
87
73
  }
88
- declare module '@midwayjs/core/dist/interface' {
89
- interface MidwayConfig extends PowerPartial<EggAppConfig> {
90
- egg?: IMidwayWebConfigurationOptions;
91
- }
92
- }
93
74
  //# sourceMappingURL=interface.d.ts.map
package/dist/logger.js CHANGED
@@ -11,10 +11,7 @@ const util_1 = require("util");
11
11
  const debug = (0, util_1.debuglog)('midway:debug');
12
12
  const isWindows = os.platform() === 'win32';
13
13
  function isEmptyFile(p) {
14
- const content = (0, fs_1.readFileSync)(p, {
15
- encoding: 'utf8',
16
- });
17
- return content === null || content === undefined || content === '';
14
+ return (0, fs_1.statSync)(p).size === 0;
18
15
  }
19
16
  const levelTransform = level => {
20
17
  if (!level) {
package/index.d.ts ADDED
@@ -0,0 +1,36 @@
1
+ import {
2
+ Context as IMidwayBaseContext,
3
+ IMidwayBaseApplication,
4
+ } from '@midwayjs/core';
5
+ import {
6
+ IMidwayWebBaseApplication,
7
+ IMidwayWebConfigurationOptions,
8
+ } from './dist';
9
+
10
+ export * from './dist/index';
11
+
12
+ declare module 'egg' {
13
+ interface EggAppInfo {
14
+ appDir: string;
15
+ }
16
+
17
+ // 这里再次覆盖和 egg 不同的定义,不然 egg 插件里可能会报错
18
+ interface Application
19
+ extends IMidwayBaseApplication<Context>,
20
+ IMidwayWebBaseApplication {
21
+ createAnonymousContext(...args: any[]): EggContext;
22
+ getCoreLogger(): EggLogger & ILogger;
23
+ getLogger(name?: string): EggLogger & ILogger;
24
+ createLogger(name: string, options: LoggerOptions): EggLogger & ILogger;
25
+ }
26
+
27
+ interface Context<ResponseBodyT = any> extends IMidwayBaseContext {
28
+ getLogger(name?: string): ILogger;
29
+ }
30
+ }
31
+
32
+ declare module '@midwayjs/core' {
33
+ interface MidwayConfig extends PowerPartial<EggAppConfig> {
34
+ egg?: IMidwayWebConfigurationOptions;
35
+ }
36
+ }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@midwayjs/web",
3
- "version": "3.1.4",
3
+ "version": "3.1.7-alpha.0",
4
4
  "description": "Midway Web Framework for Egg.js",
5
5
  "main": "dist/index",
6
- "typings": "dist/index.d.ts",
6
+ "typings": "index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
9
  "test": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand",
@@ -23,13 +23,14 @@
23
23
  "agent.js",
24
24
  "app.js",
25
25
  "dist/**/*.js",
26
- "dist/**/*.d.ts"
26
+ "dist/**/*.d.ts",
27
+ "index.d.ts"
27
28
  ],
28
29
  "license": "MIT",
29
30
  "devDependencies": {
30
- "@midwayjs/decorator": "^3.0.10",
31
+ "@midwayjs/decorator": "^3.1.6",
31
32
  "@midwayjs/logger": "^2.15.0",
32
- "@midwayjs/mock": "^3.1.2",
33
+ "@midwayjs/mock": "^3.1.7-alpha.0",
33
34
  "axios": "0.26.1",
34
35
  "dayjs": "1.10.8",
35
36
  "egg-logger": "2.7.1",
@@ -46,7 +47,7 @@
46
47
  },
47
48
  "dependencies": {
48
49
  "@eggjs/router": "^2.0.0",
49
- "@midwayjs/core": "^3.1.2",
50
+ "@midwayjs/core": "^3.1.7-alpha.0",
50
51
  "egg": "^2.28.0",
51
52
  "egg-cluster": "^1.27.1",
52
53
  "find-up": "5.0.0",
@@ -60,5 +61,5 @@
60
61
  "engines": {
61
62
  "node": ">=12"
62
63
  },
63
- "gitHead": "ca98130962ab629a65912870f82f64bd0e44566d"
64
+ "gitHead": "8cb6db25f7eb794d9c61aaf69a43ac6506a289b5"
64
65
  }