@modern-js/module-tools 1.4.2 → 1.4.3
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/CHANGELOG.md +20 -0
- package/dist/js/modern/cli/build.js +2 -2
- package/dist/js/modern/cli/dev.js +2 -2
- package/dist/js/modern/commands/build.js +4 -5
- package/dist/js/modern/commands/dev.js +6 -7
- package/dist/js/modern/features/build/build-platform.js +3 -3
- package/dist/js/modern/features/build/build-watch.js +5 -6
- package/dist/js/modern/features/build/build.js +5 -6
- package/dist/js/modern/features/build/index.js +5 -5
- package/dist/js/modern/features/build/utils.js +9 -10
- package/dist/js/modern/features/dev/index.js +9 -7
- package/dist/js/modern/index.js +37 -37
- package/dist/js/node/cli/build.js +2 -2
- package/dist/js/node/cli/dev.js +2 -2
- package/dist/js/node/commands/build.js +4 -6
- package/dist/js/node/commands/dev.js +6 -8
- package/dist/js/node/features/build/build-platform.js +3 -4
- package/dist/js/node/features/build/build-watch.js +5 -7
- package/dist/js/node/features/build/build.js +5 -7
- package/dist/js/node/features/build/index.js +5 -5
- package/dist/js/node/features/build/utils.js +9 -11
- package/dist/js/node/features/dev/index.js +9 -8
- package/dist/js/node/index.js +50 -42
- package/dist/types/cli/build.d.ts +2 -1
- package/dist/types/cli/dev.d.ts +2 -1
- package/dist/types/commands/build.d.ts +2 -1
- package/dist/types/commands/dev.d.ts +2 -1
- package/dist/types/features/build/build-platform.d.ts +2 -1
- package/dist/types/features/build/build-watch.d.ts +2 -2
- package/dist/types/features/build/build.d.ts +2 -2
- package/dist/types/features/build/index.d.ts +2 -2
- package/dist/types/features/build/utils.d.ts +4 -3
- package/dist/types/features/dev/index.d.ts +4 -3
- package/dist/types/index.d.ts +3 -19
- package/package.json +8 -8
- package/tests/dev-cli.test.ts +42 -8
- package/tests/dev-command.test.ts +36 -10
- package/tests/dev-feature.test.ts +45 -13
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
import { manager } from '@modern-js/core';
|
|
1
2
|
import { runSubCmd } from '../src/features/dev';
|
|
2
3
|
|
|
3
4
|
const mockModuleToolsMenu = jest.fn();
|
|
4
5
|
const mockDevMeta = jest.fn();
|
|
5
6
|
const exit = jest.spyOn(process, 'exit').mockImplementation();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const mockAPI = {
|
|
8
|
+
useAppContext: jest.fn((): any => ({})),
|
|
9
|
+
useResolvedConfigContext: jest.fn(),
|
|
10
|
+
useHookRunners: (): any => ({
|
|
9
11
|
moduleToolsMenu: mockModuleToolsMenu,
|
|
10
|
-
})
|
|
11
|
-
}
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
12
14
|
|
|
13
15
|
describe('dev feature with subCmd', () => {
|
|
14
16
|
beforeEach(() => {
|
|
@@ -18,29 +20,59 @@ describe('dev feature with subCmd', () => {
|
|
|
18
20
|
mockModuleToolsMenu.mockReturnValue([
|
|
19
21
|
{ value: 'storybook', runTask: mockDevMeta },
|
|
20
22
|
]);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
const cloned = manager.clone(mockAPI);
|
|
24
|
+
cloned.usePlugin({
|
|
25
|
+
async setup(api) {
|
|
26
|
+
await runSubCmd(api, 'storybook', {
|
|
27
|
+
isTsProject: true,
|
|
28
|
+
appDirectory: '',
|
|
29
|
+
});
|
|
30
|
+
expect(mockDevMeta.mock.calls.length).toBe(1);
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
await cloned.init();
|
|
23
34
|
});
|
|
24
35
|
|
|
25
36
|
it('should run task with "storybook" params when storybook plugin not exist', async () => {
|
|
26
37
|
mockModuleToolsMenu.mockReturnValue([]);
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
const cloned = manager.clone(mockAPI);
|
|
39
|
+
cloned.usePlugin({
|
|
40
|
+
async setup(api) {
|
|
41
|
+
await runSubCmd(api, 'storybook', {
|
|
42
|
+
isTsProject: true,
|
|
43
|
+
appDirectory: '',
|
|
44
|
+
});
|
|
45
|
+
expect(exit).toHaveBeenCalled();
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
await cloned.init();
|
|
29
49
|
});
|
|
30
50
|
|
|
31
51
|
it('should run task with alias name "story" params when storybook plugin exist', async () => {
|
|
32
52
|
mockModuleToolsMenu.mockReturnValue([
|
|
33
53
|
{ value: 'storybook', aliasValues: ['story'], runTask: mockDevMeta },
|
|
34
54
|
]);
|
|
35
|
-
|
|
36
|
-
|
|
55
|
+
const cloned = manager.clone(mockAPI);
|
|
56
|
+
cloned.usePlugin({
|
|
57
|
+
async setup(api) {
|
|
58
|
+
await runSubCmd(api, 'story', { isTsProject: true, appDirectory: '' });
|
|
59
|
+
expect(mockDevMeta.mock.calls.length).toBe(1);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
await cloned.init();
|
|
37
63
|
});
|
|
38
64
|
|
|
39
65
|
it('should run task with alias name "story1" params when storybook plugin exist', async () => {
|
|
40
66
|
mockModuleToolsMenu.mockReturnValue([
|
|
41
67
|
{ value: 'storybook', aliasValues: ['story'], runTask: mockDevMeta },
|
|
42
68
|
]);
|
|
43
|
-
|
|
44
|
-
|
|
69
|
+
const cloned = manager.clone(mockAPI);
|
|
70
|
+
cloned.usePlugin({
|
|
71
|
+
async setup(api) {
|
|
72
|
+
await runSubCmd(api, 'story1', { isTsProject: true, appDirectory: '' });
|
|
73
|
+
expect(mockDevMeta.mock.calls.length).toBe(0);
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
await cloned.init();
|
|
45
77
|
});
|
|
46
78
|
});
|