mirror of
https://github.com/youzan/vant.git
synced 2026-01-28 01:10:04 +08:00
perf(cli): improve cli boot time (#10780)
* chore: test * perf(cli): improve cli boot time
This commit is contained in:
@@ -1,25 +1,26 @@
|
||||
import { Command } from 'commander';
|
||||
|
||||
import {
|
||||
dev,
|
||||
lint,
|
||||
test,
|
||||
clean,
|
||||
build,
|
||||
release,
|
||||
changelog,
|
||||
buildSite,
|
||||
commitLint,
|
||||
cliVersion,
|
||||
} from './index.js';
|
||||
import { cliVersion } from './index.js';
|
||||
|
||||
const program = new Command();
|
||||
|
||||
program.version(`@vant/cli ${cliVersion}`);
|
||||
|
||||
program.command('dev').description('Run dev server').action(dev);
|
||||
program
|
||||
.command('dev')
|
||||
.description('Run dev server')
|
||||
.action(async () => {
|
||||
const { dev } = await import('./commands/dev.js');
|
||||
return dev();
|
||||
});
|
||||
|
||||
program.command('lint').description('Run eslint and stylelint').action(lint);
|
||||
program
|
||||
.command('lint')
|
||||
.description('Run eslint and stylelint')
|
||||
.action(async () => {
|
||||
const { lint } = await import('./commands/lint.js');
|
||||
return lint();
|
||||
});
|
||||
|
||||
program
|
||||
.command('test')
|
||||
@@ -45,34 +46,58 @@ program
|
||||
'Run all tests serially in the current process, rather than creating a worker pool of child processes that run tests'
|
||||
)
|
||||
.option('--debug', 'Print debugging info about your Jest config')
|
||||
.action(test);
|
||||
.action(async (options) => {
|
||||
const { test } = await import('./commands/jest.js');
|
||||
return test(options);
|
||||
});
|
||||
|
||||
program.command('clean').description('Clean all dist files').action(clean);
|
||||
program
|
||||
.command('clean')
|
||||
.description('Clean all dist files')
|
||||
.action(async () => {
|
||||
const { clean } = await import('./commands/clean.js');
|
||||
return clean();
|
||||
});
|
||||
|
||||
program
|
||||
.command('build')
|
||||
.description('Compile components in production mode')
|
||||
.action(build);
|
||||
.action(async () => {
|
||||
const { build } = await import('./commands/build.js');
|
||||
return build();
|
||||
});
|
||||
|
||||
program
|
||||
.command('release')
|
||||
.description('Compile components and release it')
|
||||
.option('--tag <tag>', 'Release tag')
|
||||
.action(release);
|
||||
.action(async (options) => {
|
||||
const { release } = await import('./commands/release.js');
|
||||
return release(options);
|
||||
});
|
||||
|
||||
program
|
||||
.command('build-site')
|
||||
.description('Compile site in production mode')
|
||||
.action(buildSite);
|
||||
.action(async () => {
|
||||
const { buildSite } = await import('./commands/build-site.js');
|
||||
return buildSite();
|
||||
});
|
||||
|
||||
program
|
||||
.command('changelog')
|
||||
.description('Generate changelog')
|
||||
.action(changelog);
|
||||
.action(async () => {
|
||||
const { changelog } = await import('./commands/changelog.js');
|
||||
return changelog();
|
||||
});
|
||||
|
||||
program
|
||||
.command('commit-lint <gitParams>')
|
||||
.description('Lint commit message')
|
||||
.action(commitLint);
|
||||
.action(async (gitParams) => {
|
||||
const { commitLint } = await import('./commands/commit-lint.js');
|
||||
return commitLint(gitParams);
|
||||
});
|
||||
|
||||
program.parse();
|
||||
|
||||
Reference in New Issue
Block a user