@modern-js/module-tools 1.4.5 → 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.
- package/CHANGELOG.md +34 -0
- package/package.json +15 -15
- package/tests/dev-cli.test.ts +0 -59
- package/tests/dev-command.test.ts +0 -70
- package/tests/dev-feature.test.ts +0 -78
- package/tests/fixtures/tspaths/a.ts +0 -1
- package/tests/fixtures/tspaths/b.ts +0 -1
- package/tests/generate-dts.test.ts +0 -9
- package/tests/generator-dts-utils.test.ts +0 -10
- package/tests/generator-dts.test.ts +0 -37
- package/tests/index.test.ts +0 -7
- package/tests/tsconfig.json +0 -11
- package/tests/tspaths-transform.test.ts +0 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @modern-js/module-tools
|
|
2
2
|
|
|
3
|
+
## 1.4.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 04ae5262: chore: bump @modern-js/utils to v1.4.1 in dependencies
|
|
8
|
+
- 60f7d8bf: feat: add tests dir to npmignore
|
|
9
|
+
- 3bf4f8b0: feat: support start api server only
|
|
10
|
+
- 305e0bb4: fix: commander.commandsMap typing not work
|
|
11
|
+
- Updated dependencies [a4330c73]
|
|
12
|
+
- Updated dependencies [b8599d09]
|
|
13
|
+
- Updated dependencies [6cffe99d]
|
|
14
|
+
- Updated dependencies [04ae5262]
|
|
15
|
+
- Updated dependencies [60f7d8bf]
|
|
16
|
+
- Updated dependencies [e4cec1ce]
|
|
17
|
+
- Updated dependencies [3b7aa8bb]
|
|
18
|
+
- Updated dependencies [5dbbeb57]
|
|
19
|
+
- Updated dependencies [ebfcbb35]
|
|
20
|
+
- Updated dependencies [3bf4f8b0]
|
|
21
|
+
- Updated dependencies [305e0bb4]
|
|
22
|
+
- Updated dependencies [ebfcbb35]
|
|
23
|
+
- @modern-js/core@1.8.0
|
|
24
|
+
- @modern-js/utils@1.5.0
|
|
25
|
+
- @modern-js/babel-preset-module@1.3.2
|
|
26
|
+
- @modern-js/css-config@1.2.4
|
|
27
|
+
- @modern-js/i18n-cli-language-detector@1.2.2
|
|
28
|
+
- @modern-js/plugin-changeset@1.2.5
|
|
29
|
+
- @modern-js/plugin-fast-refresh@1.2.4
|
|
30
|
+
- @modern-js/plugin-i18n@1.2.4
|
|
31
|
+
- @modern-js/new-action@1.3.6
|
|
32
|
+
- @modern-js/babel-compiler@1.2.3
|
|
33
|
+
- @modern-js/style-compiler@1.2.4
|
|
34
|
+
- @modern-js/plugin@1.3.3
|
|
35
|
+
- @modern-js/plugin-analyze@1.4.0
|
|
36
|
+
|
|
3
37
|
## 1.4.5
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.4.
|
|
14
|
+
"version": "1.4.6",
|
|
15
15
|
"bin": {
|
|
16
16
|
"modern": "./bin/modern.js"
|
|
17
17
|
},
|
|
@@ -54,19 +54,19 @@
|
|
|
54
54
|
"@babel/runtime": "^7",
|
|
55
55
|
"@babel/traverse": "^7.15.0",
|
|
56
56
|
"@babel/types": "^7.17.0",
|
|
57
|
-
"@modern-js/babel-compiler": "^1.2.
|
|
58
|
-
"@modern-js/babel-preset-module": "^1.3.
|
|
59
|
-
"@modern-js/core": "^1.
|
|
60
|
-
"@modern-js/css-config": "^1.2.
|
|
61
|
-
"@modern-js/i18n-cli-language-detector": "^1.2.
|
|
62
|
-
"@modern-js/new-action": "^1.3.
|
|
63
|
-
"@modern-js/plugin": "^1.3.
|
|
64
|
-
"@modern-js/plugin-analyze": "^1.
|
|
65
|
-
"@modern-js/plugin-changeset": "^1.2.
|
|
66
|
-
"@modern-js/plugin-fast-refresh": "^1.2.
|
|
67
|
-
"@modern-js/plugin-i18n": "^1.2.
|
|
68
|
-
"@modern-js/style-compiler": "^1.2.
|
|
69
|
-
"@modern-js/utils": "^1.
|
|
57
|
+
"@modern-js/babel-compiler": "^1.2.3",
|
|
58
|
+
"@modern-js/babel-preset-module": "^1.3.2",
|
|
59
|
+
"@modern-js/core": "^1.8.0",
|
|
60
|
+
"@modern-js/css-config": "^1.2.4",
|
|
61
|
+
"@modern-js/i18n-cli-language-detector": "^1.2.2",
|
|
62
|
+
"@modern-js/new-action": "^1.3.6",
|
|
63
|
+
"@modern-js/plugin": "^1.3.3",
|
|
64
|
+
"@modern-js/plugin-analyze": "^1.4.0",
|
|
65
|
+
"@modern-js/plugin-changeset": "^1.2.5",
|
|
66
|
+
"@modern-js/plugin-fast-refresh": "^1.2.4",
|
|
67
|
+
"@modern-js/plugin-i18n": "^1.2.4",
|
|
68
|
+
"@modern-js/style-compiler": "^1.2.4",
|
|
69
|
+
"@modern-js/utils": "^1.5.0",
|
|
70
70
|
"dotenv": "^10.0.0",
|
|
71
71
|
"fast-glob": "^3.2.5",
|
|
72
72
|
"globby": "^11",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@babel/preset-typescript": "^7.15.0",
|
|
82
|
-
"@modern-js/babel-chain": "^1.2.
|
|
82
|
+
"@modern-js/babel-chain": "^1.2.2",
|
|
83
83
|
"@scripts/build": "0.0.0",
|
|
84
84
|
"@scripts/jest-config": "0.0.0",
|
|
85
85
|
"@types/babel__core": "^7.1.15",
|
package/tests/dev-cli.test.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { manager } from '@modern-js/core';
|
|
2
|
-
import { program } from '@modern-js/utils';
|
|
3
|
-
import { devCli } from '../src/cli/dev';
|
|
4
|
-
|
|
5
|
-
const mockCommandDev = jest.fn();
|
|
6
|
-
|
|
7
|
-
describe('dev cli subCmd', () => {
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
jest.resetAllMocks();
|
|
10
|
-
jest.mock('../src/commands', () => ({
|
|
11
|
-
__esModule: true,
|
|
12
|
-
dev: mockCommandDev,
|
|
13
|
-
}));
|
|
14
|
-
});
|
|
15
|
-
it('should be storybook with "dev storybook"', async () => {
|
|
16
|
-
const mockAPI = {
|
|
17
|
-
useAppContext: jest.fn((): any => ({
|
|
18
|
-
existSrc: false,
|
|
19
|
-
distDirectory: '',
|
|
20
|
-
})),
|
|
21
|
-
useResolvedConfigContext: jest.fn(),
|
|
22
|
-
useHookRunners: (): any => ({}),
|
|
23
|
-
};
|
|
24
|
-
const cloned = manager.clone(mockAPI);
|
|
25
|
-
cloned.usePlugin({
|
|
26
|
-
setup(api) {
|
|
27
|
-
devCli(program, api);
|
|
28
|
-
program.parse(['', '', 'dev', 'storybook']);
|
|
29
|
-
expect(mockCommandDev.mock.calls[0][2]).toBe('storybook');
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
await cloned.init();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should be undefined with "dev"', async () => {
|
|
36
|
-
const mockBeforeBuild = jest.fn();
|
|
37
|
-
const mockAfterBuild = jest.fn();
|
|
38
|
-
const mockAPI = {
|
|
39
|
-
useAppContext: jest.fn((): any => ({
|
|
40
|
-
existSrc: false,
|
|
41
|
-
distDirectory: '',
|
|
42
|
-
})),
|
|
43
|
-
useResolvedConfigContext: jest.fn(),
|
|
44
|
-
useHookRunners: (): any => ({
|
|
45
|
-
afterBuild: mockAfterBuild,
|
|
46
|
-
beforeBuild: mockBeforeBuild,
|
|
47
|
-
}),
|
|
48
|
-
};
|
|
49
|
-
const cloned = manager.clone(mockAPI);
|
|
50
|
-
cloned.usePlugin({
|
|
51
|
-
setup(api) {
|
|
52
|
-
devCli(program, api);
|
|
53
|
-
program.parse(['', '', 'dev']);
|
|
54
|
-
expect(mockCommandDev.mock.calls[0][2]).toBe(undefined);
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
await cloned.init();
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { manager } from '@modern-js/core';
|
|
2
|
-
import { dev } from '../src/commands/dev';
|
|
3
|
-
|
|
4
|
-
const mockRunSubCmd = jest.fn();
|
|
5
|
-
jest.mock('../src/features/dev', () => ({
|
|
6
|
-
__esModule: true,
|
|
7
|
-
runSubCmd: mockRunSubCmd,
|
|
8
|
-
devStorybook: jest.fn(),
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
jest.mock('dotenv', () => ({
|
|
12
|
-
__esModule: true,
|
|
13
|
-
config: jest.fn(),
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
jest.mock('../src/utils/valide', () => ({
|
|
17
|
-
__esModule: true,
|
|
18
|
-
valideBeforeTask: jest.fn(),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
jest.mock('../src/utils/tsconfig', () => ({
|
|
22
|
-
__esModule: true,
|
|
23
|
-
existTsConfigFile: jest.fn(),
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
describe('dev command with subCmd', () => {
|
|
27
|
-
beforeEach(() => {
|
|
28
|
-
jest.clearAllMocks();
|
|
29
|
-
});
|
|
30
|
-
it('should call runSubCmd with storybook param', async () => {
|
|
31
|
-
const mockAPI = {
|
|
32
|
-
useAppContext: jest.fn((): any => ({
|
|
33
|
-
existSrc: false,
|
|
34
|
-
distDirectory: '',
|
|
35
|
-
appDirectory: '',
|
|
36
|
-
})),
|
|
37
|
-
useResolvedConfigContext: jest.fn(),
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const cloned = manager.clone(mockAPI);
|
|
41
|
-
cloned.usePlugin({
|
|
42
|
-
async setup(api) {
|
|
43
|
-
await dev(api, { tsconfig: 'tsconfig.json' }, 'storybook');
|
|
44
|
-
expect(mockRunSubCmd.mock.calls.length).toBe(1);
|
|
45
|
-
expect(mockRunSubCmd.mock.calls[0][1]).toBe('storybook');
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
await cloned.init();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should not call runSubCmd with nothing param', async () => {
|
|
52
|
-
const mockAPI = {
|
|
53
|
-
useAppContext: jest.fn((): any => ({
|
|
54
|
-
existSrc: false,
|
|
55
|
-
distDirectory: '',
|
|
56
|
-
appDirectory: '',
|
|
57
|
-
})),
|
|
58
|
-
useResolvedConfigContext: jest.fn(),
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const cloned = manager.clone(mockAPI);
|
|
62
|
-
cloned.usePlugin({
|
|
63
|
-
async setup(api) {
|
|
64
|
-
await dev(api, { tsconfig: 'tsconfig.json' });
|
|
65
|
-
expect(mockRunSubCmd.mock.calls.length).toBe(0);
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
await cloned.init();
|
|
69
|
-
});
|
|
70
|
-
});
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { manager } from '@modern-js/core';
|
|
2
|
-
import { runSubCmd } from '../src/features/dev';
|
|
3
|
-
|
|
4
|
-
const mockModuleToolsMenu = jest.fn();
|
|
5
|
-
const mockDevMeta = jest.fn();
|
|
6
|
-
const exit = jest.spyOn(process, 'exit').mockImplementation();
|
|
7
|
-
const mockAPI = {
|
|
8
|
-
useAppContext: jest.fn((): any => ({})),
|
|
9
|
-
useResolvedConfigContext: jest.fn(),
|
|
10
|
-
useHookRunners: (): any => ({
|
|
11
|
-
moduleToolsMenu: mockModuleToolsMenu,
|
|
12
|
-
}),
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
describe('dev feature with subCmd', () => {
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
jest.clearAllMocks();
|
|
18
|
-
});
|
|
19
|
-
it('should run task with "storybook" params when storybook plugin exist', async () => {
|
|
20
|
-
mockModuleToolsMenu.mockReturnValue([
|
|
21
|
-
{ value: 'storybook', runTask: mockDevMeta },
|
|
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();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should run task with "storybook" params when storybook plugin not exist', async () => {
|
|
37
|
-
mockModuleToolsMenu.mockReturnValue([]);
|
|
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();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should run task with alias name "story" params when storybook plugin exist', async () => {
|
|
52
|
-
mockModuleToolsMenu.mockReturnValue([
|
|
53
|
-
{ value: 'storybook', aliasValues: ['story'], runTask: mockDevMeta },
|
|
54
|
-
]);
|
|
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();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should run task with alias name "story1" params when storybook plugin exist', async () => {
|
|
66
|
-
mockModuleToolsMenu.mockReturnValue([
|
|
67
|
-
{ value: 'storybook', aliasValues: ['story'], runTask: mockDevMeta },
|
|
68
|
-
]);
|
|
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();
|
|
77
|
-
});
|
|
78
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@/b.ts';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const b = 10;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
|
-
import { generatorTsConfig } from '../src/tasks/generator-dts/utils';
|
|
3
|
-
|
|
4
|
-
describe('test generator dts utils', () => {
|
|
5
|
-
it('test generatorTsConfig', () => {
|
|
6
|
-
const appDir = path.join(__dirname, './fixtures/tsconfig');
|
|
7
|
-
const ret = generatorTsConfig({}, { appDirectory: appDir, distDir: '' });
|
|
8
|
-
expect(ret).toContain('tsconfig.temp.json');
|
|
9
|
-
});
|
|
10
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
jest.mock('@modern-js/core', () => ({
|
|
2
|
-
manager: {
|
|
3
|
-
run: async (fn: any) => {
|
|
4
|
-
await fn();
|
|
5
|
-
},
|
|
6
|
-
},
|
|
7
|
-
cli: {
|
|
8
|
-
init: () => ({}),
|
|
9
|
-
},
|
|
10
|
-
}));
|
|
11
|
-
jest.mock('process.argv', () => () => (o: any) => ({ ...o, tsCheck: false }));
|
|
12
|
-
jest.mock('../src/tasks/generator-dts/utils');
|
|
13
|
-
jest.mock('@modern-js/utils', () => {
|
|
14
|
-
const originalModule = jest.requireActual('@modern-js/utils');
|
|
15
|
-
return {
|
|
16
|
-
__esModule: true, // Use it when dealing with esModules
|
|
17
|
-
...originalModule,
|
|
18
|
-
fs: {
|
|
19
|
-
...originalModule.fs,
|
|
20
|
-
removeSync: jest.fn(),
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
process.argv = [];
|
|
25
|
-
|
|
26
|
-
describe('generator dts test', () => {
|
|
27
|
-
it('test tsCheck is true', () => {
|
|
28
|
-
console.info = jest.fn(str => {
|
|
29
|
-
expect(str).toBe(
|
|
30
|
-
"There are some type warnings, which can be checked by configuring 'output.disableTsChecker = false'",
|
|
31
|
-
);
|
|
32
|
-
});
|
|
33
|
-
require('../src/tasks/generator-dts');
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
export {};
|
package/tests/index.test.ts
DELETED
package/tests/tsconfig.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { transformDtsAlias } from '../src/utils/tspaths-transform';
|
|
3
|
-
|
|
4
|
-
describe('tspaths-transform', () => {
|
|
5
|
-
it('transformDtsAlias', () => {
|
|
6
|
-
const filepath = path.join(__dirname, 'fixtures/tspaths/a.ts');
|
|
7
|
-
const options = {
|
|
8
|
-
filenames: [filepath],
|
|
9
|
-
baseUrl: './',
|
|
10
|
-
paths: {
|
|
11
|
-
'@/*': ['./*'],
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
expect(transformDtsAlias(options)).toEqual([
|
|
15
|
-
{
|
|
16
|
-
path: filepath,
|
|
17
|
-
content: "import '@/b.ts';",
|
|
18
|
-
},
|
|
19
|
-
]);
|
|
20
|
-
});
|
|
21
|
-
});
|