feat(cli): optimize gen style deps map
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { start, error, success } from 'signale';
|
||||
import { join } from 'path';
|
||||
import { clean } from './clean';
|
||||
import { remove, copy, readdirSync } from 'fs-extra';
|
||||
@@ -11,6 +10,7 @@ import { genStyleDepsMap } from '../compiler/gen-style-deps-map';
|
||||
import { genComponentStyle } from '../compiler/gen-component-style';
|
||||
import { SRC_DIR, LIB_DIR, ES_DIR } from '../common/constant';
|
||||
import {
|
||||
logger,
|
||||
isDir,
|
||||
isSfc,
|
||||
isStyle,
|
||||
@@ -53,56 +53,56 @@ async function compileDir(dir: string) {
|
||||
);
|
||||
}
|
||||
|
||||
export async function buildESModuleOutputs() {
|
||||
async function buildESModuleOutputs() {
|
||||
await copy(SRC_DIR, ES_DIR);
|
||||
|
||||
start('Build esmodule outputs');
|
||||
logger.start('Build esmodule outputs');
|
||||
|
||||
try {
|
||||
setModuleEnv('esmodule');
|
||||
await compileDir(ES_DIR);
|
||||
success('Build esmodule outputs');
|
||||
logger.success('Build esmodule outputs');
|
||||
} catch (err) {
|
||||
error('Build esmodule outputs');
|
||||
logger.error('Build esmodule outputs');
|
||||
}
|
||||
}
|
||||
|
||||
export async function buildCommonjsOutputs() {
|
||||
async function buildCommonjsOutputs() {
|
||||
await copy(SRC_DIR, LIB_DIR);
|
||||
|
||||
start('Build commonjs outputs');
|
||||
logger.start('Build commonjs outputs');
|
||||
|
||||
try {
|
||||
setModuleEnv('commonjs');
|
||||
await compileDir(LIB_DIR);
|
||||
success('Build commonjs outputs');
|
||||
logger.success('Build commonjs outputs');
|
||||
} catch (err) {
|
||||
error('Build commonjs outputs');
|
||||
logger.error('Build commonjs outputs');
|
||||
}
|
||||
}
|
||||
|
||||
export async function buildStyleEntry() {
|
||||
start('Build style entry');
|
||||
async function buildStyleEntry() {
|
||||
logger.start('Build style entry');
|
||||
|
||||
try {
|
||||
genStyleDepsMap();
|
||||
await genStyleDepsMap();
|
||||
genComponentStyle();
|
||||
success('Build style entry');
|
||||
logger.success('Build style entry');
|
||||
} catch (err) {
|
||||
error('Build style entry');
|
||||
logger.error('Build style entry');
|
||||
}
|
||||
}
|
||||
|
||||
export async function buildPackedOutputs() {
|
||||
start('Build packed outputs');
|
||||
async function buildPackedOutputs() {
|
||||
logger.start('Build packed outputs');
|
||||
|
||||
try {
|
||||
genPackageEntry();
|
||||
await compilePackage(false);
|
||||
await compilePackage(true);
|
||||
success('Build packed outputs');
|
||||
logger.success('Build packed outputs');
|
||||
} catch (err) {
|
||||
error('Build packed outputs');
|
||||
logger.error('Build packed outputs');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import signale from 'signale';
|
||||
import { readFileSync } from 'fs';
|
||||
import { logger } from '../common';
|
||||
import { readFileSync } from 'fs-extra';
|
||||
|
||||
const commitRE = /^(revert: )?(fix|feat|docs|perf|test|types|build|chore|refactor|breaking change)(\(.+\))?: .{1,50}/;
|
||||
const mergeRE = /Merge branch /;
|
||||
@@ -9,7 +9,7 @@ export function commitLint() {
|
||||
const commitMsg = readFileSync(gitParams, 'utf-8').trim();
|
||||
|
||||
if (!commitRE.test(commitMsg) || !mergeRE.test(commitMsg)) {
|
||||
signale.error(`Error: invalid commit message: "${commitMsg}".
|
||||
logger.error(`Error: invalid commit message: "${commitMsg}".
|
||||
|
||||
Proper commit message format is required for automated changelog generation.
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { start, error, success } from 'signale';
|
||||
import { lint as stylelint } from 'stylelint';
|
||||
import { CLIEngine } from 'eslint';
|
||||
import { logger } from '../common';
|
||||
import { SCRIPT_EXTS } from '../common/constant';
|
||||
|
||||
function lintScript() {
|
||||
start('ESLint Start');
|
||||
logger.start('ESLint Start');
|
||||
|
||||
const cli = new CLIEngine({
|
||||
fix: true,
|
||||
@@ -19,15 +19,15 @@ function lintScript() {
|
||||
// output lint errors
|
||||
const formatted = formatter(report.results);
|
||||
if (formatted) {
|
||||
error('ESLint Failed');
|
||||
logger.error('ESLint Failed');
|
||||
console.log(formatter(report.results));
|
||||
} else {
|
||||
success('ESLint Passed');
|
||||
logger.success('ESLint Passed');
|
||||
}
|
||||
}
|
||||
|
||||
function lintStyle() {
|
||||
start('Stylelint Start');
|
||||
logger.start('Stylelint Start');
|
||||
|
||||
stylelint({
|
||||
fix: true,
|
||||
@@ -35,10 +35,10 @@ function lintStyle() {
|
||||
files: ['src/**/*.css', 'src/**/*.less', 'src/**/*.scss', 'src/**/*.vue']
|
||||
}).then(result => {
|
||||
if (result.errored) {
|
||||
error('Stylelint Failed');
|
||||
logger.error('Stylelint Failed');
|
||||
console.log(result.output);
|
||||
} else {
|
||||
success('Stylelint Passed');
|
||||
logger.success('Stylelint Passed');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user