fix(cli): incorrect version when release

This commit is contained in:
陈嘉涵 2019-12-17 19:36:43 +08:00
parent b56e1ba217
commit 7db27a1b79
6 changed files with 30 additions and 9 deletions

View File

@ -1,11 +1,15 @@
/* eslint-disable no-template-curly-in-string */
// @ts-ignore
import releaseIt from 'release-it';
import { build } from './build';
import { join } from 'path';
const PLUGIN_PATH = join(__dirname, '../compiler/vant-cli-release-plugin.js');
export async function release() {
await build();
await releaseIt({
plugins: {
[PLUGIN_PATH]: {}
},
git: {
tagName: 'v${version}',
commitMessage: 'chore: release ${version}'

View File

@ -44,7 +44,11 @@ export const JEST_STYLE_MOCK_FILE = join(CONFIG_DIR, 'jest.style-mock.js');
export const SCRIPT_EXTS = ['.js', '.jsx', '.vue', '.ts', '.tsx'];
export const STYLE_EXTS = ['.css', '.less', '.scss'];
export const PACKAGE_JSON = require(PACKAGE_JSON_FILE);
export function getPackageJson() {
delete require.cache[PACKAGE_JSON_FILE];
return require(PACKAGE_JSON_FILE);
}
export function getVantConfig() {
delete require.cache[VANT_CONFIG_FILE];

View File

@ -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)}

View File

@ -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() {

View File

@ -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;

View File

@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es6",
"outDir": "./lib",
"module": "commonjs",
"strict": true,