-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathllama-rlsr.config.js
66 lines (57 loc) · 1.94 KB
/
llama-rlsr.config.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
58
59
60
61
62
63
64
65
66
const child_process = require('child_process');
const fs = require('fs')
const path = require('path');
const LlamaRlsrKeepAChangelog = require('llama-rlsr-keep-a-changelog');
const LlamaRlsrNpm = require('llama-rlsr-npm');
const simpleGit = require('simple-git')(process.cwd());
const GitHubApi = require('github-api');
const rimraf = require('rimraf');
const gitHubCredentials = require('./credentials/github.json');
const username = 'HopefulLlama';
const repoName = 'UnitTestSCAD';
if(!gitHubCredentials) {
throw new Error('GitHub credentials not found.');
}
module.exports = {
preRelease: [
LlamaRlsrNpm.updateVersion(),
(_, done) => {
const packageLock = path.join(__dirname, 'package-lock.json');
rimraf.sync(path.join(__dirname, 'node_modules'));
if(fs.existsSync(packageLock)) {
fs.unlinkSync(packageLock);
}
child_process.execSync('npm i');
done();
},
LlamaRlsrKeepAChangelog.updateChangelog({
placeholder: '- Nothing yet'
}),
LlamaRlsrKeepAChangelog.updateDiff({
urlGenerator: (oldVersion, newVersion) => `https://github.com/${username}/${repoName}/compare/${oldVersion}...${newVersion}`,
latest: 'HEAD',
tag: {
prefix: 'v'
}
})
],
release: [
(versionMetadata, done) => {
simpleGit.add(['package.json', 'package-lock.json', 'CHANGELOG.md', 'llama-rlsr.metadata.json'], () => {
simpleGit.commit(`Update to version ${versionMetadata.newVersion}`, () => {
simpleGit.addTag(`v${versionMetadata.newVersion}`, () => {
simpleGit.push('origin', 'master', () => {
simpleGit.pushTags('origin', () => done());
});
});
});
});
},
(versionMetadata, done) => {
const gitHub = new GitHubApi(gitHubCredentials);
gitHub
.getRepo(username, repoName)
.createRelease({"tag_name": `v${versionMetadata.newVersion}`}, () => done());
}
]
};