docs: update changelog (#7004)

This commit is contained in:
Svetoslav
2019-03-12 15:09:32 +02:00
committed by GitHub
parent cd66300e3a
commit 451026f44d
6 changed files with 84 additions and 19 deletions

View File

@@ -0,0 +1,18 @@
const { readFileSync } = require("fs");
const { resolve } = require("path");
const { createPR, argsParser, gitBranch } = require("./pr-helper");
const currentBranch = argsParser().currentBranch || gitBranch;
const modulesPackageVersion = argsParser().packageVersion || JSON.parse(readFileSync(resolve(process.cwd(), "tns-core-modules/package.json")).toString()).version;
const title = argsParser().title || `release: cut the ${modulesPackageVersion} release`;
const baseBranch = argsParser().base || "release";
const body = argsParser().body || "docs: update changelog";
const postQuery = {
"body": body,
"head": currentBranch,
"base": baseBranch,
"title": title
}
createPR(postQuery);

View File

@@ -0,0 +1,9 @@
const { createPR, gitBranch } = require("./pr-helper");
const postQuery = {
"head": gitBranch,
"base": "master",
"title": "chore: merge release in master"
}
createPR(postQuery);

39
build/pr-helper.js Normal file
View File

@@ -0,0 +1,39 @@
const { execSync } = require('child_process');
const { writeFileSync, unlinkSync } = require("fs");
const { resolve } = require("path");
exports.gitBranch = execSync("git branch").toString()
.split("\n")
.filter(f => f.trim().startsWith("*"))[0]
.replace("*", "").trim();
exports.createPR = (postQuery) => {
if (!process.env.GIT_TOKEN) {
console.error("Missing env variable GIT_TOKEN");
process.exit(1);
}
const releaseDataJsonPath = resolve(process.cwd(), "git-helper.json");
writeFileSync(releaseDataJsonPath, JSON.stringify(postQuery));
const result = execSync(` curl -d "@${releaseDataJsonPath}" -X POST https://api.github.com/repos/NativeScript/NativeScript/pulls -H "Authorization: token ${process.env.GIT_TOKEN}" `);
console.log(result.toString());
unlinkSync(releaseDataJsonPath);
const requesResultJson = JSON.parse(result);
execSync(`open ${requesResultJson.html_url}`);
return requesResultJson;
}
exports.argsParser = () => {
args = {};
process.argv
.filter(a => a.startsWith("--"))
.map(el => {
el = el.split("=");
const prop = el[0].replace("--", "").replace("-", "").trim();
const value = el[1].trim();
args[prop] = value;
});
return args;
}