create-egg 4.0.1-beta.0 → 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.
Files changed (30) hide show
  1. package/dist/templates/egg3-simple-js/package.json +2 -2
  2. package/dist/templates/egg3-simple-ts/package.json +2 -2
  3. package/dist/templates/egg3-tegg/app/module/bar/controller/home.ts +1 -6
  4. package/dist/templates/egg3-tegg/app/module/bar/controller/user.ts +1 -7
  5. package/dist/templates/egg3-tegg/package.json +2 -2
  6. package/dist/templates/egg3-tegg/test/app/module/bar/controller/user.test.ts +1 -4
  7. package/dist/templates/simple-ts/config/config.default.ts +9 -10
  8. package/dist/templates/simple-ts/config/config.local.ts +4 -5
  9. package/dist/templates/simple-ts/config/config.prod.ts +4 -5
  10. package/dist/templates/simple-ts/test/app/controller/home.test.ts +1 -1
  11. package/dist/templates/simple-ts/test/app/service/Test.test.ts +1 -1
  12. package/dist/templates/simple-ts/test/setup.ts +5 -0
  13. package/dist/templates/simple-ts/vitest.config.ts +7 -0
  14. package/dist/templates/tegg/app/module/bar/controller/home.ts +2 -7
  15. package/dist/templates/tegg/app/module/bar/controller/user.ts +2 -8
  16. package/dist/templates/tegg/app/module/bar/package.json +2 -1
  17. package/dist/templates/tegg/app/module/foo/package.json +2 -1
  18. package/dist/templates/tegg/app/module/foo/service/HelloService.ts +1 -1
  19. package/dist/templates/tegg/config/config.default.ts +14 -15
  20. package/dist/templates/tegg/config/config.local.ts +4 -5
  21. package/dist/templates/tegg/config/config.prod.ts +4 -5
  22. package/dist/templates/tegg/config/config.unittest.ts +4 -5
  23. package/dist/templates/tegg/config/plugin.ts +1 -1
  24. package/dist/templates/tegg/package.json +15 -11
  25. package/dist/templates/tegg/test/app/module/bar/controller/user.test.ts +1 -4
  26. package/dist/templates/tegg/test/app/module/foo/service/{HelloService.test.ts → HelloService.test.skip.ts} +2 -1
  27. package/dist/templates/tegg/test/setup.ts +5 -0
  28. package/dist/templates/tegg/tsconfig.json +0 -3
  29. package/dist/templates/tegg/vitest.config.ts +7 -0
  30. package/package.json +2 -2
@@ -8,13 +8,13 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "egg": "^3.17.5",
11
- "egg-scripts": "2"
11
+ "egg-scripts": "3"
12
12
  },
13
13
  "devDependencies": {
14
14
  "egg-bin": "6",
15
15
  "egg-mock": "5",
16
16
  "eslint": "8",
17
- "eslint-config-egg": "13"
17
+ "eslint-config-egg": "14"
18
18
  },
19
19
  "engines": {
20
20
  "node": ">=18.0.0"
@@ -26,11 +26,11 @@
26
26
  "devDependencies": {
27
27
  "@types/mocha": "10",
28
28
  "@types/node": "24",
29
- "@eggjs/tsconfig": "1",
29
+ "@eggjs/tsconfig": "3",
30
30
  "egg-bin": "6",
31
31
  "egg-mock": "5",
32
32
  "eslint": "8",
33
- "eslint-config-egg": "13",
33
+ "eslint-config-egg": "14",
34
34
  "typescript": "5"
35
35
  },
36
36
  "engines": {
@@ -1,10 +1,5 @@
1
1
  import { EggLogger } from 'egg';
2
- import {
3
- Inject,
4
- HTTPController,
5
- HTTPMethod,
6
- HTTPMethodEnum,
7
- } from '@eggjs/tegg';
2
+ import { Inject, HTTPController, HTTPMethod, HTTPMethodEnum } from '@eggjs/tegg';
8
3
 
9
4
  @HTTPController({
10
5
  path: '/',
@@ -1,10 +1,4 @@
1
- import {
2
- Inject,
3
- HTTPController,
4
- HTTPMethod,
5
- HTTPMethodEnum,
6
- HTTPQuery,
7
- } from '@eggjs/tegg';
1
+ import { Inject, HTTPController, HTTPMethod, HTTPMethodEnum, HTTPQuery } from '@eggjs/tegg';
8
2
  import { HelloService } from '@/module/foo';
9
3
 
10
4
  @HTTPController({
@@ -28,14 +28,14 @@
28
28
  "@eggjs/tegg-eventbus-plugin": "^3.5.2",
29
29
  "@eggjs/tegg-plugin": "^3.5.2",
30
30
  "@eggjs/tegg-schedule-plugin": "^3.5.2",
31
- "egg-scripts": "^2.17.0",
31
+ "egg-scripts": "^3.0.0",
32
32
  "egg-tracer": "^2.0.0",
33
33
  "egg": "^3.31.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "egg-bin": "^6.13.0",
37
37
  "egg-mock": "^5.15.2",
38
- "@eggjs/tsconfig": "1",
38
+ "@eggjs/tsconfig": "3",
39
39
  "@types/mocha": "10",
40
40
  "@types/node": "24",
41
41
  "oxlint": "1",
@@ -4,10 +4,7 @@ import { app } from 'egg-mock/bootstrap';
4
4
 
5
5
  describe('test/app/module/bar/controller/user.test.ts', () => {
6
6
  it('should GET /bar/user status 200', async () => {
7
- const res = await app
8
- .httpRequest()
9
- .get('/bar/user')
10
- .query({ userId: '20170901' });
7
+ const res = await app.httpRequest().get('/bar/user').query({ userId: '20170901' });
11
8
  assert.equal(res.status, 200);
12
9
  assert.equal(res.text, 'hello, 20170901');
13
10
  });
@@ -1,14 +1,13 @@
1
- import type { EggAppConfig, EggAppInfo, PowerPartial } from 'egg';
1
+ import { defineConfig, type PartialEggConfig } from 'egg';
2
2
 
3
- export default (appInfo: EggAppInfo) => {
4
- const config = {} as PowerPartial<EggAppConfig>;
3
+ export default defineConfig(appInfo => {
4
+ const config = {
5
+ // use for cookie sign key, should change to your own and keep security
6
+ keys: appInfo.name + '_{{keys}}',
5
7
 
6
- // override config from framework / plugin
7
- // use for cookie sign key, should change to your own and keep security
8
- config.keys = appInfo.name + '_{{keys}}';
9
-
10
- // add your egg config in here
11
- config.middleware = [];
8
+ // add your egg config in here
9
+ middleware: [] as string[],
10
+ } as PartialEggConfig;
12
11
 
13
12
  // add your special config in here
14
13
  const bizConfig = {
@@ -20,4 +19,4 @@ export default (appInfo: EggAppInfo) => {
20
19
  ...config,
21
20
  ...bizConfig,
22
21
  };
23
- };
22
+ });
@@ -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,10 +1,5 @@
1
- import { EggLogger } from 'egg';
2
- import {
3
- Inject,
4
- HTTPController,
5
- HTTPMethod,
6
- HTTPMethodEnum,
7
- } from '@eggjs/tegg';
1
+ import type { EggLogger } from 'egg';
2
+ import { Inject, HTTPController, HTTPMethod, HTTPMethodEnum } from '@eggjs/tegg';
8
3
 
9
4
  @HTTPController({
10
5
  path: '/',
@@ -1,11 +1,5 @@
1
- import {
2
- Inject,
3
- HTTPController,
4
- HTTPMethod,
5
- HTTPMethodEnum,
6
- HTTPQuery,
7
- } from '@eggjs/tegg';
8
- import { HelloService } from '@/module/foo';
1
+ import { Inject, HTTPController, HTTPMethod, HTTPMethodEnum, HTTPQuery } from '@eggjs/tegg';
2
+ import { HelloService } from '../../foo/index.ts';
9
3
 
10
4
  @HTTPController({
11
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,20 +1,19 @@
1
- import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg';
1
+ import { defineConfig, type PartialEggConfig } from 'egg';
2
2
 
3
- export default (appInfo: EggAppInfo) => {
4
- const config = {} as PowerPartial<EggAppConfig>;
3
+ export default defineConfig(appInfo => {
4
+ const config = {
5
+ // use for cookie sign key, should change to your own and keep security
6
+ keys: appInfo.name + '_{{keys}}',
5
7
 
6
- // override config from framework / plugin
7
- // use for cookie sign key, should change to your own and keep security
8
- config.keys = appInfo.name + '_{{keys}}';
8
+ // add your egg config in here
9
+ middleware: [] as string[],
9
10
 
10
- // add your egg config in here
11
- config.middleware = [];
12
-
13
- // change multipart mode to file
14
- // @see https://github.com/eggjs/multipart/blob/master/src/config/config.default.ts#L104
15
- config.multipart = {
16
- mode: 'file',
17
- };
11
+ // change multipart mode to file
12
+ // @see https://github.com/eggjs/multipart/blob/master/src/config/config.default.ts#L104
13
+ multipart: {
14
+ mode: 'file' as const,
15
+ },
16
+ } as PartialEggConfig;
18
17
 
19
18
  // add your special config in here
20
19
  // Usage: `app.config.bizConfig.sourceUrl`
@@ -27,4 +26,4 @@ export default (appInfo: EggAppInfo) => {
27
26
  ...config,
28
27
  bizConfig,
29
28
  };
30
- };
29
+ });
@@ -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"
@@ -2,10 +2,7 @@ import { test, expect } from 'vitest';
2
2
  import { app } from '@eggjs/mock/bootstrap';
3
3
 
4
4
  test('should GET /bar/user status 200', async () => {
5
- const res = await app
6
- .httpRequest()
7
- .get('/bar/user')
8
- .query({ userId: '20170901' });
5
+ const res = await app.httpRequest().get('/bar/user').query({ userId: '20170901' });
9
6
  expect(res.status).toBe(200);
10
7
  expect(res.text).toBe('hello, 20170901');
11
8
  });
@@ -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.0.1-beta.0",
3
+ "version": "4.1.0-beta.11",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -10,7 +10,7 @@
10
10
  "@types/cross-spawn": "^6.0.6",
11
11
  "@types/node": "24.5.2",
12
12
  "execa": "^9.6.0",
13
- "tsdown": "0.15.3"
13
+ "tsdown": "^0.15.4"
14
14
  },
15
15
  "engines": {
16
16
  "node": ">=20.19.0"