mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 19:52:51 +00:00
chore: use the branch name as release version
This commit is contained in:
parent
0d40db2581
commit
27ce430a6c
@ -1,8 +1,18 @@
|
||||
const { execSync } = require('child_process');
|
||||
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
||||
const fse = require('fs-extra');
|
||||
// read from lerna
|
||||
const lernaConfig = JSON.parse(fse.readFileSync('../../lerna.json', 'utf8'));
|
||||
const { version } = lernaConfig;
|
||||
|
||||
function getReleaseVersion() {
|
||||
const gitBranchName = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf-8' });
|
||||
const reBranchVersion = /^(?:[\w-]+\/)(\d+\.\d+\.\d+)$/im;
|
||||
const match = reBranchVersion.exec(gitBranchName);
|
||||
if (!match) {
|
||||
throw new Error(`[engine] gitBranchName: ${gitBranchName} is not valid`);
|
||||
}
|
||||
|
||||
return match[1];
|
||||
}
|
||||
|
||||
const version = getReleaseVersion();
|
||||
|
||||
module.exports = ({ context, onGetWebpackConfig }) => {
|
||||
onGetWebpackConfig((config) => {
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||
const { join } = require('path');
|
||||
const fse = require('fs-extra');
|
||||
// read from lerna
|
||||
const lernaConfig = JSON.parse(fse.readFileSync('../../lerna.json', 'utf8'));
|
||||
const { version } = lernaConfig;
|
||||
|
||||
let releaseVersion = version;
|
||||
|
||||
const distDir = join(__dirname, '../dist');
|
||||
|
||||
const distFileNames = ['engine-core.js'];
|
||||
|
||||
distFileNames.forEach(name => {
|
||||
const distFile = join(distDir, 'js', name);
|
||||
if (!fse.existsSync(distFile)) {
|
||||
console.warn(`[engine] distFile: ${distFile} doesn\'t exist`);
|
||||
return;
|
||||
}
|
||||
|
||||
const indexContent = fse.readFileSync(distFile, 'utf-8');
|
||||
|
||||
fse.writeFileSync(distFile, indexContent.replace('{{VERSION_PLACEHOLDER}}', releaseVersion));
|
||||
});
|
||||
|
||||
console.log('[engine] update engine version successfully!');
|
||||
Loading…
x
Reference in New Issue
Block a user