Match-id-c70ffb984c901f8c537667d7d0415e9a19cacde8
This commit is contained in:
parent
f4e0636541
commit
c813940a3e
|
@ -7,7 +7,6 @@ const path = require('path');
|
||||||
const childProcess = require('child_process');
|
const childProcess = require('child_process');
|
||||||
|
|
||||||
const version = process.env.releaseVersion;
|
const version = process.env.releaseVersion;
|
||||||
const HORIZON_PACKAGE_JSON = path.resolve(__dirname, '../libs/horizon/package.json');
|
|
||||||
const DIST_PATH = path.resolve(__dirname, '../build/horizon');
|
const DIST_PATH = path.resolve(__dirname, '../build/horizon');
|
||||||
|
|
||||||
const NPMRC = `registry=https://cmc.centralrepo.rnd.huawei.com/npm
|
const NPMRC = `registry=https://cmc.centralrepo.rnd.huawei.com/npm
|
||||||
|
@ -17,11 +16,11 @@ always-auth = true
|
||||||
email = cloudsop@huawei.com
|
email = cloudsop@huawei.com
|
||||||
`;
|
`;
|
||||||
if (!version) {
|
if (!version) {
|
||||||
return;
|
process.exit();
|
||||||
}
|
}
|
||||||
if (!/\d+\.\d+\.\d+/.test(version)) {
|
if (!/\d+\.\d+\.\d+/.test(version)) {
|
||||||
console.log('请输入正确版本号');
|
console.log('请输入正确版本号');
|
||||||
return;
|
process.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
const exec = (cmd, cwd) => {
|
const exec = (cmd, cwd) => {
|
||||||
|
@ -44,37 +43,18 @@ const exec = (cmd, cwd) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const writeVersion = version => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const file = HORIZON_PACKAGE_JSON;
|
|
||||||
fs.readFile(file, 'utf8', function (err, data) {
|
|
||||||
if (err) {
|
|
||||||
console.log(`${file}: write version failed`);
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
const packageJson = JSON.parse(data);
|
|
||||||
packageJson.version = version;
|
|
||||||
fs.writeFileSync(file, JSON.stringify(packageJson, null, 2));
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
|
try {
|
||||||
console.log(`==== Horizon Upgrade ${version} ====`);
|
console.log(`==== Horizon Upgrade ${version} ====`);
|
||||||
await writeVersion(version);
|
await exec(`npm version ${version}`, DIST_PATH);
|
||||||
|
|
||||||
if (!version.includes('SNAPSHOT')) {
|
|
||||||
console.log('==== Create git tag =====');
|
|
||||||
const tagName = `v${version}-h1`;
|
|
||||||
await exec(`git tag ${tagName}`);
|
|
||||||
await exec('git push --tags');
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.writeFileSync(path.resolve(DIST_PATH, '.npmrc'), NPMRC);
|
fs.writeFileSync(path.resolve(DIST_PATH, '.npmrc'), NPMRC);
|
||||||
|
|
||||||
console.log('==== Publish new version====');
|
console.log('==== Publish new version====');
|
||||||
await exec('npm publish', DIST_PATH);
|
await exec('npm publish', DIST_PATH);
|
||||||
|
process.exit();
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
main();
|
main();
|
||||||
|
|
Loading…
Reference in New Issue