create-egg 4.1.0-beta.10 → 4.1.0-beta.11

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.
@@ -1,13 +1,13 @@
1
- import { defineConfig, type EggAppInfo } from 'egg';
1
+ import { defineConfig, type PartialEggConfig } from 'egg';
2
2
 
3
- export default defineConfig((appInfo: EggAppInfo) => {
3
+ export default defineConfig(appInfo => {
4
4
  const config = {
5
5
  // use for cookie sign key, should change to your own and keep security
6
6
  keys: appInfo.name + '_{{keys}}',
7
7
 
8
8
  // add your egg config in here
9
9
  middleware: [] as string[],
10
- };
10
+ } as PartialEggConfig;
11
11
 
12
12
  // add your special config in here
13
13
  const bizConfig = {
@@ -1,6 +1,5 @@
1
- import type { EggAppConfig, PowerPartial } from 'egg';
1
+ import type { PartialEggConfig } from 'egg';
2
2
 
3
- export default () => {
4
- const config: PowerPartial<EggAppConfig> = {};
5
- return config;
6
- };
3
+ export default {
4
+ // add your config here
5
+ } as PartialEggConfig;
@@ -1,6 +1,5 @@
1
- import type { EggAppConfig, PowerPartial } from 'egg';
1
+ import type { PartialEggConfig } from 'egg';
2
2
 
3
- export default () => {
4
- const config: PowerPartial<EggAppConfig> = {};
5
- return config;
6
- };
3
+ export default {
4
+ // add your config here
5
+ } as PartialEggConfig;
@@ -4,5 +4,5 @@ import { app } from '@eggjs/mock/bootstrap';
4
4
 
5
5
  test('should GET / status 200', async () => {
6
6
  const res = await app.httpRequest().get('/').expect(200);
7
- expect(res.text).toBe('hi, egg');
7
+ expect(res.text).toBe('hi, egg, TypeScript');
8
8
  });
@@ -5,5 +5,5 @@ import { app } from '@eggjs/mock/bootstrap';
5
5
  test('sayHi should return hi, egg', async () => {
6
6
  const ctx = app.mockContext();
7
7
  const result = await ctx.service.test.sayHi('egg');
8
- expect(result).toBe('hi, egg');
8
+ expect(result).toBe('hi, egg, TypeScript');
9
9
  });
@@ -0,0 +1,5 @@
1
+ import { beforeAll, afterAll } from 'vitest';
2
+
3
+ // https://vitest.dev/config/#setupfiles
4
+ // export beforeAll and afterAll to globalThis, let @eggjs/mock/bootstrap use it
5
+ Object.assign(globalThis, { beforeAll, afterAll });
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ setupFiles: ['test/setup.ts'],
6
+ },
7
+ });
@@ -1,4 +1,4 @@
1
- import { EggLogger } from 'egg';
1
+ import type { EggLogger } from 'egg';
2
2
  import { Inject, HTTPController, HTTPMethod, HTTPMethodEnum } from '@eggjs/tegg';
3
3
 
4
4
  @HTTPController({
@@ -1,5 +1,5 @@
1
1
  import { Inject, HTTPController, HTTPMethod, HTTPMethodEnum, HTTPQuery } from '@eggjs/tegg';
2
- import { HelloService } from '@/module/foo';
2
+ import { HelloService } from '../../foo/index.ts';
3
3
 
4
4
  @HTTPController({
5
5
  path: '/bar',
@@ -2,5 +2,6 @@
2
2
  "name": "bar",
3
3
  "eggModule": {
4
4
  "name": "bar"
5
- }
5
+ },
6
+ "type": "module"
6
7
  }
@@ -2,5 +2,6 @@
2
2
  "name": "foo",
3
3
  "eggModule": {
4
4
  "name": "foo"
5
- }
5
+ },
6
+ "type": "module"
6
7
  }
@@ -1,4 +1,4 @@
1
- import { EggLogger } from 'egg';
1
+ import type { EggLogger } from 'egg';
2
2
  import { SingletonProto, AccessLevel, Inject } from '@eggjs/tegg';
3
3
 
4
4
  @SingletonProto({
@@ -1,6 +1,6 @@
1
- import { defineConfig, type EggAppInfo } from 'egg';
1
+ import { defineConfig, type PartialEggConfig } from 'egg';
2
2
 
3
- export default defineConfig((appInfo: EggAppInfo) => {
3
+ export default defineConfig(appInfo => {
4
4
  const config = {
5
5
  // use for cookie sign key, should change to your own and keep security
6
6
  keys: appInfo.name + '_{{keys}}',
@@ -13,7 +13,7 @@ export default defineConfig((appInfo: EggAppInfo) => {
13
13
  multipart: {
14
14
  mode: 'file' as const,
15
15
  },
16
- };
16
+ } as PartialEggConfig;
17
17
 
18
18
  // add your special config in here
19
19
  // Usage: `app.config.bizConfig.sourceUrl`
@@ -1,6 +1,5 @@
1
- import { EggAppConfig, PowerPartial } from 'egg';
1
+ import type { PartialEggConfig } from 'egg';
2
2
 
3
- export default () => {
4
- const config = {} as PowerPartial<EggAppConfig>;
5
- return config;
6
- };
3
+ export default {
4
+ // add your config here
5
+ } as PartialEggConfig;
@@ -1,6 +1,5 @@
1
- import { EggAppConfig, PowerPartial } from 'egg';
1
+ import type { PartialEggConfig } from 'egg';
2
2
 
3
- export default () => {
4
- const config = {} as PowerPartial<EggAppConfig>;
5
- return config;
6
- };
3
+ export default {
4
+ // add your config here
5
+ } as PartialEggConfig;
@@ -1,6 +1,5 @@
1
- import { EggAppConfig, PowerPartial } from 'egg';
1
+ import type { PartialEggConfig } from 'egg';
2
2
 
3
- export default () => {
4
- const config = {} as PowerPartial<EggAppConfig>;
5
- return config;
6
- };
3
+ export default {
4
+ // add your config here
5
+ } as PartialEggConfig;
@@ -1,4 +1,4 @@
1
- import { EggPlugin } from 'egg';
1
+ import type { EggPlugin } from 'egg';
2
2
 
3
3
  const plugin: EggPlugin = {
4
4
  tegg: {
@@ -2,6 +2,7 @@
2
2
  "name": "{{name}}",
3
3
  "description": "Hello Egg.js",
4
4
  "private": true,
5
+ "type": "module",
5
6
  "egg": {
6
7
  "typescript": true
7
8
  },
@@ -9,11 +10,11 @@
9
10
  "start": "eggctl start --daemon --title=egg-server-{{name}}",
10
11
  "stop": "eggctl stop --title=egg-server-{{name}}",
11
12
  "dev": "egg-bin dev",
12
- "test:local": "vitest run",
13
+ "test:local": "cross-env NODE_OPTIONS=\"--import @oxc-node/core/register\" vitest run",
13
14
  "pretest": "npm run clean && npm run lint -- --fix",
14
- "test": "vitest run",
15
+ "test": "npm run test:local",
15
16
  "preci": "npm run clean && npm run lint",
16
- "ci": "vitest run --coverage",
17
+ "ci": "npm run test:local -- --coverage",
17
18
  "postci": "npm run prepublishOnly && npm start && sleep 10 && npm stop && npm run clean",
18
19
  "lint": "oxlint --type-aware",
19
20
  "tsc": "tsc",
@@ -22,13 +23,13 @@
22
23
  },
23
24
  "dependencies": {
24
25
  "@eggjs/scripts": "^4.0.0",
25
- "@eggjs/tegg": "^3.5.2",
26
- "@eggjs/tegg-aop-plugin": "^3.5.2",
27
- "@eggjs/tegg-config": "^3.5.2",
28
- "@eggjs/tegg-controller-plugin": "^3.5.2",
29
- "@eggjs/tegg-eventbus-plugin": "^3.5.2",
30
- "@eggjs/tegg-plugin": "^3.5.2",
31
- "@eggjs/tegg-schedule-plugin": "^3.5.2",
26
+ "@eggjs/tegg": "beta",
27
+ "@eggjs/tegg-aop-plugin": "beta",
28
+ "@eggjs/tegg-config": "beta",
29
+ "@eggjs/tegg-controller-plugin": "beta",
30
+ "@eggjs/tegg-eventbus-plugin": "beta",
31
+ "@eggjs/tegg-plugin": "beta",
32
+ "@eggjs/tegg-schedule-plugin": "beta",
32
33
  "@eggjs/tracer": "^3.0.0",
33
34
  "egg": "beta"
34
35
  },
@@ -36,11 +37,14 @@
36
37
  "@eggjs/bin": "beta",
37
38
  "@eggjs/mock": "beta",
38
39
  "@eggjs/tsconfig": "beta",
40
+ "@oxc-node/core": "^0.0.32",
39
41
  "@types/node": "24",
42
+ "cross-env": "10",
40
43
  "oxlint": "1",
41
44
  "oxlint-tsgolint": "^0.2.0",
42
45
  "typescript": "5",
43
- "vitest": "beta"
46
+ "vitest": "beta",
47
+ "@vitest/coverage-v8": "beta"
44
48
  },
45
49
  "engines": {
46
50
  "node": ">=20.19.0"
@@ -1,6 +1,7 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { app } from '@eggjs/mock/bootstrap';
3
- import { HelloService } from '@/module/foo/service/HelloService';
3
+
4
+ import { HelloService } from '../../../../../app/module/foo/index.ts';
4
5
 
5
6
  test('should hello() work', async () => {
6
7
  const helloService = await app.getEggObject(HelloService);
@@ -0,0 +1,5 @@
1
+ import { beforeAll, afterAll } from 'vitest';
2
+
3
+ // https://vitest.dev/config/#setupfiles
4
+ // export beforeAll and afterAll to globalThis, let @eggjs/mock/bootstrap use it
5
+ Object.assign(globalThis, { beforeAll, afterAll });
@@ -5,9 +5,6 @@
5
5
  "module": "NodeNext",
6
6
  "moduleResolution": "NodeNext",
7
7
  "declaration": false,
8
- "paths": {
9
- "@/module/*": ["app/module/*"]
10
- },
11
8
  "baseUrl": "."
12
9
  }
13
10
  }
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ setupFiles: ['test/setup.ts'],
6
+ },
7
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-egg",
3
- "version": "4.1.0-beta.10",
3
+ "version": "4.1.0-beta.11",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },