@modern-js/module-tools 1.2.0 → 1.3.0
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/.eslintrc.js +4 -1
- package/CHANGELOG.md +18 -0
- package/dist/js/modern/cli/build.js +1 -1
- package/dist/js/modern/cli/dev.js +2 -2
- package/dist/js/modern/commands/dev.js +13 -1
- package/dist/js/modern/features/dev/index.js +11 -0
- package/dist/js/node/cli/build.js +1 -1
- package/dist/js/node/cli/dev.js +2 -2
- package/dist/js/node/commands/dev.js +12 -1
- package/dist/js/node/features/dev/index.js +16 -2
- package/dist/types/commands/dev.d.ts +1 -1
- package/dist/types/features/dev/index.d.ts +2 -1
- package/lib/types.d.ts +0 -1
- package/package.json +6 -6
- package/src/cli/build.ts +1 -1
- package/src/cli/dev.ts +3 -3
- package/src/commands/dev.ts +10 -1
- package/src/features/dev/index.ts +12 -0
- package/tests/dev-cli.test.ts +25 -0
- package/tests/dev-command.test.ts +44 -0
- package/tests/dev-feature.test.ts +30 -0
- package/tests/tsconfig.json +11 -0
- package/tsconfig.json +2 -1
package/.eslintrc.js
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @modern-js/module-tools
|
|
2
2
|
|
|
3
|
+
## 1.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c5973e7a: add dev sub commands
|
|
8
|
+
- 0d9516f3: fix resolve static file and add -p params
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- c1455cd6: fix module-tools type file
|
|
13
|
+
- Updated dependencies [823809c6]
|
|
14
|
+
- Updated dependencies [4584cc04]
|
|
15
|
+
- Updated dependencies [7c19fd94]
|
|
16
|
+
- Updated dependencies [0d9516f3]
|
|
17
|
+
- @modern-js/utils@1.2.1
|
|
18
|
+
- @modern-js/core@1.3.1
|
|
19
|
+
- @modern-js/babel-preset-module@1.3.0
|
|
20
|
+
|
|
3
21
|
## 1.2.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -3,7 +3,7 @@ const local = Import.lazy('../locale/index', require);
|
|
|
3
3
|
const commands = Import.lazy('../commands', require);
|
|
4
4
|
export const buildCli = program => {
|
|
5
5
|
// TODO: 初始化环境变量
|
|
6
|
-
program.command('build').usage('[options]').description(local.i18n.t(local.localeKeys.command.build.describe)).option('-w, --watch', local.i18n.t(local.localeKeys.command.build.watch)).option('--tsconfig [tsconfig]', local.i18n.t(local.localeKeys.command.build.tsconfig), './tsconfig.json').option('--style-only', local.i18n.t(local.localeKeys.command.build.style_only)).option('--platform [platform]', local.i18n.t(local.localeKeys.command.build.platform)).option('--no-tsc', local.i18n.t(local.localeKeys.command.build.no_tsc)).option('--no-clear', local.i18n.t(local.localeKeys.command.build.no_clear)).action(async subCommand => {
|
|
6
|
+
program.command('build').usage('[options]').description(local.i18n.t(local.localeKeys.command.build.describe)).option('-w, --watch', local.i18n.t(local.localeKeys.command.build.watch)).option('--tsconfig [tsconfig]', local.i18n.t(local.localeKeys.command.build.tsconfig), './tsconfig.json').option('--style-only', local.i18n.t(local.localeKeys.command.build.style_only)).option('-p, --platform [platform]', local.i18n.t(local.localeKeys.command.build.platform)).option('--no-tsc', local.i18n.t(local.localeKeys.command.build.no_tsc)).option('--no-clear', local.i18n.t(local.localeKeys.command.build.no_clear)).action(async subCommand => {
|
|
7
7
|
await commands.build(subCommand);
|
|
8
8
|
});
|
|
9
9
|
};
|
|
@@ -2,7 +2,7 @@ import { Import } from '@modern-js/utils';
|
|
|
2
2
|
const local = Import.lazy('../locale', require);
|
|
3
3
|
const commands = Import.lazy('../commands', require);
|
|
4
4
|
export const devCli = program => {
|
|
5
|
-
program.command('dev').usage('[options]').description(local.i18n.t(local.localeKeys.command.dev.describe)).option('--tsconfig [tsconfig]', local.i18n.t(local.localeKeys.command.build.tsconfig), './tsconfig.json').action(async params => {
|
|
6
|
-
await commands.dev(params);
|
|
5
|
+
program.command('dev [subCmd]').usage('[options]').description(local.i18n.t(local.localeKeys.command.dev.describe)).option('--tsconfig [tsconfig]', local.i18n.t(local.localeKeys.command.build.tsconfig), './tsconfig.json').action(async (subCmd, params) => {
|
|
6
|
+
await commands.dev(params, subCmd);
|
|
7
7
|
});
|
|
8
8
|
};
|
|
@@ -5,7 +5,10 @@ const core = Import.lazy('@modern-js/core', require);
|
|
|
5
5
|
const dotenv = Import.lazy('dotenv', require);
|
|
6
6
|
const tsConfigutils = Import.lazy('../utils/tsconfig', require);
|
|
7
7
|
const valid = Import.lazy('../utils/valide', require);
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
const existSubCmd = subCmd => subCmd.length > 0;
|
|
10
|
+
|
|
11
|
+
export const dev = async (option, subCmd = '') => {
|
|
9
12
|
const {
|
|
10
13
|
tsconfig: tsconfigName
|
|
11
14
|
} = option;
|
|
@@ -22,6 +25,15 @@ export const dev = async option => {
|
|
|
22
25
|
});
|
|
23
26
|
const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
|
|
24
27
|
|
|
28
|
+
if (existSubCmd(subCmd)) {
|
|
29
|
+
await devFeature.runSubCmd(subCmd, {
|
|
30
|
+
isTsProject,
|
|
31
|
+
appDirectory
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
} // Compatible with the use of jupiter, RUN_PLATFORM is used in jupiter
|
|
35
|
+
|
|
36
|
+
|
|
25
37
|
if (process.env.RUN_PLATFORM) {
|
|
26
38
|
await devFeature.showMenu({
|
|
27
39
|
isTsProject,
|
|
@@ -36,6 +36,17 @@ export const devStorybook = async config => {
|
|
|
36
36
|
} else {
|
|
37
37
|
console.info(chalk.yellow('No development features found.\nYou can use the `new` command to enable the development features')); // eslint-disable-next-line no-process-exit
|
|
38
38
|
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export const runSubCmd = async (subCmd, config) => {
|
|
43
|
+
const metas = await core.mountHook().moduleToolsMenu(undefined);
|
|
44
|
+
const devMeta = metas.find(meta => meta.value === subCmd);
|
|
45
|
+
|
|
46
|
+
if (devMeta) {
|
|
47
|
+
await devMeta.runTask(config);
|
|
48
|
+
} else {
|
|
49
|
+
// eslint-disable-next-line no-process-exit
|
|
39
50
|
process.exit(0);
|
|
40
51
|
}
|
|
41
52
|
};
|
|
@@ -13,7 +13,7 @@ const commands = _utils.Import.lazy('../commands', require);
|
|
|
13
13
|
|
|
14
14
|
const buildCli = program => {
|
|
15
15
|
// TODO: 初始化环境变量
|
|
16
|
-
program.command('build').usage('[options]').description(local.i18n.t(local.localeKeys.command.build.describe)).option('-w, --watch', local.i18n.t(local.localeKeys.command.build.watch)).option('--tsconfig [tsconfig]', local.i18n.t(local.localeKeys.command.build.tsconfig), './tsconfig.json').option('--style-only', local.i18n.t(local.localeKeys.command.build.style_only)).option('--platform [platform]', local.i18n.t(local.localeKeys.command.build.platform)).option('--no-tsc', local.i18n.t(local.localeKeys.command.build.no_tsc)).option('--no-clear', local.i18n.t(local.localeKeys.command.build.no_clear)).action(async subCommand => {
|
|
16
|
+
program.command('build').usage('[options]').description(local.i18n.t(local.localeKeys.command.build.describe)).option('-w, --watch', local.i18n.t(local.localeKeys.command.build.watch)).option('--tsconfig [tsconfig]', local.i18n.t(local.localeKeys.command.build.tsconfig), './tsconfig.json').option('--style-only', local.i18n.t(local.localeKeys.command.build.style_only)).option('-p, --platform [platform]', local.i18n.t(local.localeKeys.command.build.platform)).option('--no-tsc', local.i18n.t(local.localeKeys.command.build.no_tsc)).option('--no-clear', local.i18n.t(local.localeKeys.command.build.no_clear)).action(async subCommand => {
|
|
17
17
|
await commands.build(subCommand);
|
|
18
18
|
});
|
|
19
19
|
};
|
package/dist/js/node/cli/dev.js
CHANGED
|
@@ -12,8 +12,8 @@ const local = _utils.Import.lazy('../locale', require);
|
|
|
12
12
|
const commands = _utils.Import.lazy('../commands', require);
|
|
13
13
|
|
|
14
14
|
const devCli = program => {
|
|
15
|
-
program.command('dev').usage('[options]').description(local.i18n.t(local.localeKeys.command.dev.describe)).option('--tsconfig [tsconfig]', local.i18n.t(local.localeKeys.command.build.tsconfig), './tsconfig.json').action(async params => {
|
|
16
|
-
await commands.dev(params);
|
|
15
|
+
program.command('dev [subCmd]').usage('[options]').description(local.i18n.t(local.localeKeys.command.dev.describe)).option('--tsconfig [tsconfig]', local.i18n.t(local.localeKeys.command.build.tsconfig), './tsconfig.json').action(async (subCmd, params) => {
|
|
16
|
+
await commands.dev(params, subCmd);
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -23,7 +23,9 @@ const tsConfigutils = _utils.Import.lazy('../utils/tsconfig', require);
|
|
|
23
23
|
|
|
24
24
|
const valid = _utils.Import.lazy('../utils/valide', require);
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const existSubCmd = subCmd => subCmd.length > 0;
|
|
27
|
+
|
|
28
|
+
const dev = async (option, subCmd = '') => {
|
|
27
29
|
const {
|
|
28
30
|
tsconfig: tsconfigName
|
|
29
31
|
} = option;
|
|
@@ -40,6 +42,15 @@ const dev = async option => {
|
|
|
40
42
|
});
|
|
41
43
|
const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
|
|
42
44
|
|
|
45
|
+
if (existSubCmd(subCmd)) {
|
|
46
|
+
await devFeature.runSubCmd(subCmd, {
|
|
47
|
+
isTsProject,
|
|
48
|
+
appDirectory
|
|
49
|
+
});
|
|
50
|
+
return;
|
|
51
|
+
} // Compatible with the use of jupiter, RUN_PLATFORM is used in jupiter
|
|
52
|
+
|
|
53
|
+
|
|
43
54
|
if (process.env.RUN_PLATFORM) {
|
|
44
55
|
await devFeature.showMenu({
|
|
45
56
|
isTsProject,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.showMenu = exports.devStorybook = void 0;
|
|
6
|
+
exports.showMenu = exports.runSubCmd = exports.devStorybook = void 0;
|
|
7
7
|
|
|
8
8
|
var _utils = require("@modern-js/utils");
|
|
9
9
|
|
|
@@ -57,4 +57,18 @@ const devStorybook = async config => {
|
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
exports.devStorybook = devStorybook;
|
|
60
|
+
exports.devStorybook = devStorybook;
|
|
61
|
+
|
|
62
|
+
const runSubCmd = async (subCmd, config) => {
|
|
63
|
+
const metas = await core.mountHook().moduleToolsMenu(undefined);
|
|
64
|
+
const devMeta = metas.find(meta => meta.value === subCmd);
|
|
65
|
+
|
|
66
|
+
if (devMeta) {
|
|
67
|
+
await devMeta.runTask(config);
|
|
68
|
+
} else {
|
|
69
|
+
// eslint-disable-next-line no-process-exit
|
|
70
|
+
process.exit(0);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
exports.runSubCmd = runSubCmd;
|
|
@@ -4,4 +4,5 @@ export interface IDevConfig {
|
|
|
4
4
|
}
|
|
5
5
|
export declare type DevTaskType = 'storybook' | 'docsite' | 'unknow';
|
|
6
6
|
export declare const showMenu: (config: IDevConfig) => Promise<void>;
|
|
7
|
-
export declare const devStorybook: (config: IDevConfig) => Promise<void>;
|
|
7
|
+
export declare const devStorybook: (config: IDevConfig) => Promise<void>;
|
|
8
|
+
export declare const runSubCmd: (subCmd: string, config: IDevConfig) => Promise<void>;
|
package/lib/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.3.0",
|
|
15
15
|
"bin": {
|
|
16
16
|
"modern": "./bin/modern.js"
|
|
17
17
|
},
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
},
|
|
41
41
|
"typesVersions": {
|
|
42
42
|
"*": {
|
|
43
|
-
"
|
|
44
|
-
"./
|
|
43
|
+
"type": [
|
|
44
|
+
"./lib/types.d.ts"
|
|
45
45
|
]
|
|
46
46
|
}
|
|
47
47
|
},
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"@babel/traverse": "^7.15.0",
|
|
53
53
|
"@babel/types": "^7.15.0",
|
|
54
54
|
"@modern-js/babel-compiler": "^1.2.0",
|
|
55
|
-
"@modern-js/babel-preset-module": "^1.
|
|
56
|
-
"@modern-js/core": "^1.3.
|
|
55
|
+
"@modern-js/babel-preset-module": "^1.3.0",
|
|
56
|
+
"@modern-js/core": "^1.3.1",
|
|
57
57
|
"@modern-js/css-config": "^1.2.0",
|
|
58
58
|
"@modern-js/i18n-cli-language-detector": "^1.2.0",
|
|
59
59
|
"@modern-js/module-tools-hooks": "^1.2.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@modern-js/plugin-fast-refresh": "^1.2.0",
|
|
64
64
|
"@modern-js/plugin-i18n": "^1.2.0",
|
|
65
65
|
"@modern-js/style-compiler": "^1.2.0",
|
|
66
|
-
"@modern-js/utils": "^1.2.
|
|
66
|
+
"@modern-js/utils": "^1.2.1",
|
|
67
67
|
"chalk": "^4.1.2",
|
|
68
68
|
"chokidar": "^3.5.2",
|
|
69
69
|
"dotenv": "^10.0.0",
|
package/src/cli/build.ts
CHANGED
|
@@ -28,7 +28,7 @@ export const buildCli = (program: Command) => {
|
|
|
28
28
|
local.i18n.t(local.localeKeys.command.build.style_only),
|
|
29
29
|
)
|
|
30
30
|
.option(
|
|
31
|
-
'--platform [platform]',
|
|
31
|
+
'-p, --platform [platform]',
|
|
32
32
|
local.i18n.t(local.localeKeys.command.build.platform),
|
|
33
33
|
)
|
|
34
34
|
.option('--no-tsc', local.i18n.t(local.localeKeys.command.build.no_tsc))
|
package/src/cli/dev.ts
CHANGED
|
@@ -10,7 +10,7 @@ const commands: typeof import('../commands') = Import.lazy(
|
|
|
10
10
|
|
|
11
11
|
export const devCli = (program: Command) => {
|
|
12
12
|
program
|
|
13
|
-
.command('dev')
|
|
13
|
+
.command('dev [subCmd]')
|
|
14
14
|
.usage('[options]')
|
|
15
15
|
.description(local.i18n.t(local.localeKeys.command.dev.describe))
|
|
16
16
|
.option(
|
|
@@ -18,7 +18,7 @@ export const devCli = (program: Command) => {
|
|
|
18
18
|
local.i18n.t(local.localeKeys.command.build.tsconfig),
|
|
19
19
|
'./tsconfig.json',
|
|
20
20
|
)
|
|
21
|
-
.action(async (params: IDevOption) => {
|
|
22
|
-
await commands.dev(params);
|
|
21
|
+
.action(async (subCmd: string, params: IDevOption) => {
|
|
22
|
+
await commands.dev(params, subCmd);
|
|
23
23
|
});
|
|
24
24
|
};
|
package/src/commands/dev.ts
CHANGED
|
@@ -23,7 +23,9 @@ export interface IDevOption {
|
|
|
23
23
|
tsconfig: string;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const existSubCmd = (subCmd: string) => subCmd.length > 0;
|
|
27
|
+
|
|
28
|
+
export const dev = async (option: IDevOption, subCmd = '') => {
|
|
27
29
|
const { tsconfig: tsconfigName } = option;
|
|
28
30
|
const appContext = core.useAppContext();
|
|
29
31
|
const modernConfig = core.useResolvedConfigContext();
|
|
@@ -35,6 +37,13 @@ export const dev = async (option: IDevOption) => {
|
|
|
35
37
|
valid.valideBeforeTask({ modernConfig, tsconfigPath });
|
|
36
38
|
|
|
37
39
|
const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
|
|
40
|
+
|
|
41
|
+
if (existSubCmd(subCmd)) {
|
|
42
|
+
await devFeature.runSubCmd(subCmd, { isTsProject, appDirectory });
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Compatible with the use of jupiter, RUN_PLATFORM is used in jupiter
|
|
38
47
|
if (process.env.RUN_PLATFORM) {
|
|
39
48
|
await devFeature.showMenu({ isTsProject, appDirectory });
|
|
40
49
|
} else {
|
|
@@ -60,3 +60,15 @@ export const devStorybook = async (config: IDevConfig) => {
|
|
|
60
60
|
process.exit(0);
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
|
+
|
|
64
|
+
export const runSubCmd = async (subCmd: string, config: IDevConfig) => {
|
|
65
|
+
const metas = await (core.mountHook() as any).moduleToolsMenu(undefined);
|
|
66
|
+
|
|
67
|
+
const devMeta = metas.find((meta: any) => meta.value === subCmd);
|
|
68
|
+
if (devMeta) {
|
|
69
|
+
await devMeta.runTask(config);
|
|
70
|
+
} else {
|
|
71
|
+
// eslint-disable-next-line no-process-exit
|
|
72
|
+
process.exit(0);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { program } from 'commander';
|
|
2
|
+
import { devCli } from '../src/cli/dev';
|
|
3
|
+
|
|
4
|
+
const mockCommandDev = jest.fn();
|
|
5
|
+
|
|
6
|
+
describe('dev cli subCmd', () => {
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
jest.resetAllMocks();
|
|
9
|
+
jest.mock('../src/commands', () => ({
|
|
10
|
+
__esModule: true,
|
|
11
|
+
dev: mockCommandDev,
|
|
12
|
+
}));
|
|
13
|
+
});
|
|
14
|
+
it('should be storybook with "dev storybook"', () => {
|
|
15
|
+
devCli(program);
|
|
16
|
+
program.parse(['', '', 'dev', 'storybook']);
|
|
17
|
+
expect(mockCommandDev.mock.calls[0][1]).toBe('storybook');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should be undefined with "dev"', () => {
|
|
21
|
+
devCli(program);
|
|
22
|
+
program.parse(['', '', 'dev']);
|
|
23
|
+
expect(mockCommandDev.mock.calls[0][1]).toBe(undefined);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { dev } from '../src/commands/dev';
|
|
2
|
+
|
|
3
|
+
const mockRunSubCmd = jest.fn();
|
|
4
|
+
jest.mock('../src/features/dev', () => ({
|
|
5
|
+
__esModule: true,
|
|
6
|
+
runSubCmd: mockRunSubCmd,
|
|
7
|
+
devStorybook: jest.fn(),
|
|
8
|
+
}));
|
|
9
|
+
jest.mock('@modern-js/core', () => ({
|
|
10
|
+
__esModule: true,
|
|
11
|
+
useAppContext: jest.fn(() => ({ appDirectory: '' })),
|
|
12
|
+
useResolvedConfigContext: jest.fn(),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
jest.mock('dotenv', () => ({
|
|
16
|
+
__esModule: true,
|
|
17
|
+
config: jest.fn(),
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
jest.mock('../src/utils/valide', () => ({
|
|
21
|
+
__esModule: true,
|
|
22
|
+
valideBeforeTask: jest.fn(),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
jest.mock('../src/utils/tsconfig', () => ({
|
|
26
|
+
__esModule: true,
|
|
27
|
+
existTsConfigFile: jest.fn(),
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
describe('dev command with subCmd', () => {
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
jest.clearAllMocks();
|
|
33
|
+
});
|
|
34
|
+
it('should call runSubCmd with storybook param', async () => {
|
|
35
|
+
await dev({ tsconfig: 'tsconfig.json' }, 'storybook');
|
|
36
|
+
expect(mockRunSubCmd.mock.calls.length).toBe(1);
|
|
37
|
+
expect(mockRunSubCmd.mock.calls[0][0]).toBe('storybook');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should not call runSubCmd with nothing param', async () => {
|
|
41
|
+
await dev({ tsconfig: 'tsconfig.json' });
|
|
42
|
+
expect(mockRunSubCmd.mock.calls.length).toBe(0);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { runSubCmd } from '../src/features/dev';
|
|
2
|
+
|
|
3
|
+
const mockModuleToolsMenu = jest.fn();
|
|
4
|
+
const mockDevMeta = jest.fn();
|
|
5
|
+
const exit = jest.spyOn(process, 'exit').mockImplementation();
|
|
6
|
+
jest.mock('@modern-js/core', () => ({
|
|
7
|
+
__esModule: true,
|
|
8
|
+
mountHook: jest.fn(() => ({
|
|
9
|
+
moduleToolsMenu: mockModuleToolsMenu,
|
|
10
|
+
})),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
describe('dev feature with subCmd', () => {
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
console.info('asdas');
|
|
16
|
+
});
|
|
17
|
+
it('should run task with "storybook" params when storybook plugin exist', async () => {
|
|
18
|
+
mockModuleToolsMenu.mockReturnValue([
|
|
19
|
+
{ value: 'storybook', runTask: mockDevMeta },
|
|
20
|
+
]);
|
|
21
|
+
await runSubCmd('storybook', { isTsProject: true, appDirectory: '' });
|
|
22
|
+
expect(mockDevMeta.mock.calls.length).toBe(1);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should run task with "storybook" params when storybook plugin not exist', async () => {
|
|
26
|
+
mockModuleToolsMenu.mockReturnValue([]);
|
|
27
|
+
await runSubCmd('storybook', { isTsProject: true, appDirectory: '' });
|
|
28
|
+
expect(exit).toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
});
|