@modern-js/app-tools 1.4.3 → 1.4.6

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 (38) hide show
  1. package/.eslintrc.js +8 -0
  2. package/CHANGELOG.md +75 -0
  3. package/dist/js/modern/commands/build.js +13 -14
  4. package/dist/js/modern/commands/deploy.js +4 -4
  5. package/dist/js/modern/commands/dev.js +12 -11
  6. package/dist/js/modern/commands/start.js +4 -8
  7. package/dist/js/modern/{lifecycle.js → hooks.js} +10 -13
  8. package/dist/js/modern/index.js +74 -73
  9. package/dist/js/modern/locale/zh.js +1 -1
  10. package/dist/js/modern/utils/createCompiler.js +7 -7
  11. package/dist/js/modern/utils/createServer.js +1 -2
  12. package/dist/js/modern/utils/printInstructions.js +3 -3
  13. package/dist/js/node/commands/build.js +9 -11
  14. package/dist/js/node/commands/deploy.js +4 -5
  15. package/dist/js/node/commands/dev.js +17 -16
  16. package/dist/js/node/commands/start.js +4 -9
  17. package/dist/js/node/{lifecycle.js → hooks.js} +12 -18
  18. package/dist/js/node/index.js +81 -77
  19. package/dist/js/node/locale/zh.js +1 -1
  20. package/dist/js/node/utils/createCompiler.js +7 -8
  21. package/dist/js/node/utils/createServer.js +1 -2
  22. package/dist/js/node/utils/printInstructions.js +3 -4
  23. package/dist/types/commands/build.d.ts +3 -5
  24. package/dist/types/commands/deploy.d.ts +2 -1
  25. package/dist/types/commands/dev.d.ts +2 -1
  26. package/dist/types/commands/start.d.ts +2 -1
  27. package/dist/types/{lifecycle.d.ts → hooks.d.ts} +19 -1
  28. package/dist/types/index.d.ts +2 -19
  29. package/dist/types/utils/createCompiler.d.ts +3 -1
  30. package/dist/types/utils/printInstructions.d.ts +2 -2
  31. package/dist/types/utils/routes.d.ts +1 -1
  32. package/dist/types/utils/types.d.ts +4 -1
  33. package/jest.config.js +0 -1
  34. package/modern.config.js +1 -0
  35. package/package.json +17 -21
  36. package/tests/.eslintrc.js +8 -0
  37. package/tests/commands/build.test.ts +25 -24
  38. package/tests/utils.test.ts +0 -1
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.4.3",
14
+ "version": "1.4.6",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -30,7 +30,7 @@
30
30
  "jsnext:source": "./src/index.ts",
31
31
  "default": "./dist/js/node/index.js"
32
32
  },
33
- "./type": {
33
+ "./types": {
34
34
  "jsnext:source": "./lib/types.d.ts",
35
35
  "default": "./lib/types.d.ts"
36
36
  }
@@ -49,45 +49,41 @@
49
49
  "modern": "./bin/modern.js"
50
50
  },
51
51
  "dependencies": {
52
- "@modern-js/core": "^1.4.4",
53
52
  "@babel/runtime": "^7",
54
- "@modern-js/types": "^1.3.4",
53
+ "@modern-js/core": "^1.6.1",
55
54
  "@modern-js/i18n-cli-language-detector": "^1.2.1",
56
55
  "@modern-js/new-action": "^1.3.3",
57
- "@modern-js/plugin": "^1.2.1",
58
- "@modern-js/plugin-analyze": "^1.3.3",
59
- "@modern-js/plugin-fast-refresh": "^1.2.1",
56
+ "@modern-js/plugin": "^1.3.2",
57
+ "@modern-js/plugin-analyze": "^1.3.5",
58
+ "@modern-js/plugin-fast-refresh": "^1.2.3",
60
59
  "@modern-js/plugin-i18n": "^1.2.1",
61
- "@modern-js/server": "^1.4.4",
62
- "@modern-js/prod-server": "^1.0.1",
63
- "@modern-js/utils": "^1.3.3",
64
- "@modern-js/webpack": "^1.4.1",
60
+ "@modern-js/prod-server": "^1.0.6",
61
+ "@modern-js/server": "^1.4.9",
62
+ "@modern-js/types": "^1.3.6",
63
+ "@modern-js/utils": "^1.3.7",
64
+ "@modern-js/webpack": "^1.5.3",
65
65
  "inquirer": "^8.2.0",
66
- "webpack": "^5.54.0"
66
+ "webpack": "^5.71.0"
67
67
  },
68
68
  "devDependencies": {
69
+ "@scripts/build": "0.0.0",
70
+ "@scripts/jest-config": "0.0.0",
71
+ "@types/inquirer": "^8.2.0",
69
72
  "@types/jest": "^26",
70
73
  "@types/node": "^14",
71
74
  "@types/react": "^17",
72
75
  "@types/react-dom": "^17",
73
- "typescript": "^4",
74
- "@scripts/build": "0.0.0",
75
76
  "jest": "^27",
76
- "@scripts/jest-config": "0.0.0",
77
- "@types/inquirer": "^8.2.0"
77
+ "typescript": "^4"
78
78
  },
79
79
  "sideEffects": false,
80
- "modernConfig": {
81
- "output": {
82
- "packageMode": "node-js"
83
- }
84
- },
85
80
  "publishConfig": {
86
81
  "registry": "https://registry.npmjs.org/",
87
82
  "access": "public"
88
83
  },
89
84
  "scripts": {
90
85
  "new": "modern new",
86
+ "dev": "modern build --watch",
91
87
  "build": "modern build",
92
88
  "test": "jest --passWithNoTests"
93
89
  },
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: ['@modern-js'],
4
+ parserOptions: {
5
+ tsconfigRootDir: __dirname,
6
+ project: ['./tsconfig.json'],
7
+ },
8
+ };
@@ -1,27 +1,8 @@
1
+ import { manager } from '@modern-js/core';
1
2
  import { build } from '../../src/commands/build';
2
3
 
3
- const mockBeforeBuild = jest.fn();
4
- const mockAfterBuild = jest.fn();
5
4
  const mockGenerateRoutes = jest.fn();
6
5
 
7
- // eslint-disable-next-line arrow-body-style
8
- jest.mock('@modern-js/core', () => {
9
- return {
10
- __esModule: true,
11
- mountHook() {
12
- return {
13
- beforeBuild: mockBeforeBuild,
14
- afterBuild: mockAfterBuild,
15
- };
16
- },
17
- useAppContext: jest.fn(() => ({
18
- existSrc: false,
19
- distDirectory: '',
20
- })),
21
- useResolvedConfigContext: jest.fn(),
22
- };
23
- });
24
-
25
6
  jest.mock('../../src/utils/routes', () => ({
26
7
  __esModule: true,
27
8
  generateRoutes: () => mockGenerateRoutes(),
@@ -33,9 +14,29 @@ describe('command build', () => {
33
14
  });
34
15
 
35
16
  test('existSrc is false', async () => {
36
- await build();
37
- expect(mockBeforeBuild).toBeCalled();
38
- expect(mockGenerateRoutes).toBeCalled();
39
- expect(mockAfterBuild).toBeCalled();
17
+ const mockBeforeBuild = jest.fn();
18
+ const mockAfterBuild = jest.fn();
19
+ const mockAPI = {
20
+ useAppContext: jest.fn((): any => ({
21
+ existSrc: false,
22
+ distDirectory: '',
23
+ })),
24
+ useResolvedConfigContext: jest.fn(),
25
+ useHookRunners: (): any => ({
26
+ afterBuild: mockAfterBuild,
27
+ beforeBuild: mockBeforeBuild,
28
+ }),
29
+ };
30
+
31
+ const cloned = manager.clone(mockAPI);
32
+ cloned.usePlugin({
33
+ async setup(api) {
34
+ await build(api);
35
+ expect(mockBeforeBuild).toBeCalled();
36
+ expect(mockGenerateRoutes).toBeCalled();
37
+ expect(mockAfterBuild).toBeCalled();
38
+ },
39
+ });
40
+ await cloned.init();
40
41
  });
41
42
  });
@@ -40,7 +40,6 @@ describe('test app-tools utils', () => {
40
40
  getSpecifiedEntries(['c'], [
41
41
  { entryName: 'a' },
42
42
  { entryName: 'b' },
43
- // eslint-disable-next-line promise/prefer-await-to-then
44
43
  ] as any).catch(e => {
45
44
  expect((e as Error).message).toMatch('can not found entry c');
46
45
  resolve();