fix(cli): incorrect version when release

This commit is contained in:
陈嘉涵
2019-12-17 20:49:18 +08:00
parent b56e1ba217
commit 7db27a1b79
6 changed files with 30 additions and 9 deletions
@@ -1,9 +1,7 @@
import { get } from 'lodash';
import { join } from 'path';
import { pascalize, getComponents, smartOutputFile } from '../common';
import { SRC_DIR, PACKAGE_JSON, getVantConfig } from '../common/constant';
const version = process.env.PACKAGE_VERSION || PACKAGE_JSON.version;
import { SRC_DIR, getPackageJson, getVantConfig } from '../common/constant';
type Options = {
outputPath: string;
@@ -31,6 +29,7 @@ export function genPackageEntry(options: Options) {
const names = getComponents();
const vantConfig = getVantConfig();
const skipInstall = get(vantConfig, 'build.skipInstall', []).map(pascalize);
const version = process.env.PACKAGE_VERSION || getPackageJson().version;
const components = names.map(pascalize);
const content = `${genImports(names, options)}
@@ -10,7 +10,7 @@ import {
import {
SRC_DIR,
DOCS_DIR,
PACKAGE_JSON,
getPackageJson,
VANT_CONFIG_FILE,
SITE_DESKTOP_SHARED_FILE
} from '../common/constant';
@@ -96,7 +96,7 @@ function genExportConfig() {
}
function genExportVersion() {
return `export const packageVersion = '${PACKAGE_JSON.version}';`;
return `export const packageVersion = '${getPackageJson().version}';`;
}
export function genSiteDesktopShared() {
@@ -0,0 +1,14 @@
// @ts-ignore
import releaseIt from 'release-it';
import { build } from '../commands/build';
class VantCliReleasePlugin extends releaseIt.Plugin {
async beforeRelease() {
// log an empty line
console.log('');
await build();
}
}
module.exports = VantCliReleasePlugin;