mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(cli): incorrect version when release
This commit is contained in:
parent
b56e1ba217
commit
7db27a1b79
@ -1,11 +1,15 @@
|
|||||||
/* eslint-disable no-template-curly-in-string */
|
/* eslint-disable no-template-curly-in-string */
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import releaseIt from 'release-it';
|
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() {
|
export async function release() {
|
||||||
await build();
|
|
||||||
await releaseIt({
|
await releaseIt({
|
||||||
|
plugins: {
|
||||||
|
[PLUGIN_PATH]: {}
|
||||||
|
},
|
||||||
git: {
|
git: {
|
||||||
tagName: 'v${version}',
|
tagName: 'v${version}',
|
||||||
commitMessage: 'chore: release ${version}'
|
commitMessage: 'chore: release ${version}'
|
||||||
|
@ -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 SCRIPT_EXTS = ['.js', '.jsx', '.vue', '.ts', '.tsx'];
|
||||||
export const STYLE_EXTS = ['.css', '.less', '.scss'];
|
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() {
|
export function getVantConfig() {
|
||||||
delete require.cache[VANT_CONFIG_FILE];
|
delete require.cache[VANT_CONFIG_FILE];
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { pascalize, getComponents, smartOutputFile } from '../common';
|
import { pascalize, getComponents, smartOutputFile } from '../common';
|
||||||
import { SRC_DIR, PACKAGE_JSON, getVantConfig } from '../common/constant';
|
import { SRC_DIR, getPackageJson, getVantConfig } from '../common/constant';
|
||||||
|
|
||||||
const version = process.env.PACKAGE_VERSION || PACKAGE_JSON.version;
|
|
||||||
|
|
||||||
type Options = {
|
type Options = {
|
||||||
outputPath: string;
|
outputPath: string;
|
||||||
@ -31,6 +29,7 @@ export function genPackageEntry(options: Options) {
|
|||||||
const names = getComponents();
|
const names = getComponents();
|
||||||
const vantConfig = getVantConfig();
|
const vantConfig = getVantConfig();
|
||||||
const skipInstall = get(vantConfig, 'build.skipInstall', []).map(pascalize);
|
const skipInstall = get(vantConfig, 'build.skipInstall', []).map(pascalize);
|
||||||
|
const version = process.env.PACKAGE_VERSION || getPackageJson().version;
|
||||||
|
|
||||||
const components = names.map(pascalize);
|
const components = names.map(pascalize);
|
||||||
const content = `${genImports(names, options)}
|
const content = `${genImports(names, options)}
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
SRC_DIR,
|
SRC_DIR,
|
||||||
DOCS_DIR,
|
DOCS_DIR,
|
||||||
PACKAGE_JSON,
|
getPackageJson,
|
||||||
VANT_CONFIG_FILE,
|
VANT_CONFIG_FILE,
|
||||||
SITE_DESKTOP_SHARED_FILE
|
SITE_DESKTOP_SHARED_FILE
|
||||||
} from '../common/constant';
|
} from '../common/constant';
|
||||||
@ -96,7 +96,7 @@ function genExportConfig() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function genExportVersion() {
|
function genExportVersion() {
|
||||||
return `export const packageVersion = '${PACKAGE_JSON.version}';`;
|
return `export const packageVersion = '${getPackageJson().version}';`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function genSiteDesktopShared() {
|
export function genSiteDesktopShared() {
|
||||||
|
14
packages/vant-cli/src/compiler/vant-cli-release-plugin.ts
Normal file
14
packages/vant-cli/src/compiler/vant-cli-release-plugin.ts
Normal 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;
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es5",
|
"target": "es6",
|
||||||
"outDir": "./lib",
|
"outDir": "./lib",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user