-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
57 lines (47 loc) · 1.73 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const branchArguments = process.argv.slice(2).map(a => a.split('='));
const config = require('./config.json');
const log = require('./log');
const pullLatestGitCommits = require('./pullLatestGitCommits');
const generateReleaseNotes = require('./generateReleaseNotes');
const fs = require('fs');
const currentDateTime = require('./currentDateTime');
let fromBranch = branchArguments.find((a => a[0] === 'fromBranch'));
let toBranch = branchArguments.find((a => a[0] === 'toBranch'));
if (!fromBranch) {
log(`fromBranch not provided, using "${config.defaults.fromBranch}"`);
fromBranch = config.defaults.fromBranch;
} else {
fromBranch = fromBranch[1];
}
if (!toBranch) {
log(`toBranch not provided, using "${config.defaults.toBranch}"`);
toBranch = config.defaults.toBranch;
} else {
toBranch = toBranch[1];
}
async function clauseGitReleaseNotes() {
let output = `# Git release notes ${currentDateTime()}\n\n`
let noChangesRepos = '';
for (let repositoryName in config.repositories) {
const relativePath = config.repositories[repositoryName];
log(`Fetching latest git commits for ${repositoryName}`);
await pullLatestGitCommits(relativePath, [fromBranch, toBranch]);
log(`Generating git release notes...`);
await generateReleaseNotes(relativePath, fromBranch, toBranch).then(releaseNotes => {
if (releaseNotes) {
output += `## ${repositoryName}\n${releaseNotes}\n`;
} else {
noChangesRepos += `## ${repositoryName}\nNo changes since last deploy\n\n`;
}
});
}
output += noChangesRepos;
fs.writeFile("./output.md", output, (err) => {
if (err) {
console.log(err);
} else {
log('Done. See output.md for release notes');
}
});
}
clauseGitReleaseNotes();