forked from microsoft/vscode-pull-request-github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci.js
51 lines (40 loc) · 1.83 KB
/
ci.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
const fs = require('fs');
const argv = require('minimist')(process.argv.slice(2));
const json = JSON.parse(fs.readFileSync('./package.json').toString());
// update name, publisher and description
// calculate version
let version = argv['v'];
if (typeof(version) !== 'string') {
const date = new Date();
const major = date.getFullYear() - 2018;
const yearStart = new Date(date.getFullYear(), 0, 0);
const diff = date - yearStart;
const minor = Math.floor(diff / (1000 * 60 * 60 * 24));
version = `${major}.${minor}.0`;
}
const id = argv['i'];
const displayName = argv['n'];
const description = argv['d'];
const publisher = argv['p'];
if (!id || !displayName || !description || !publisher) {
return;
}
const insiderPackageJson = Object.assign(json, {
name: id,
version: version,
displayName: displayName,
description: description,
publisher: publisher
});
fs.writeFileSync('./package.insiders.json', JSON.stringify(insiderPackageJson));
const readme = fs.readFileSync('./README.md');
const previewReadme = `
# GitHub Pull Request Nightly Build
This is the nightly build of [GitHub Pull Request extension](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github) for early feedback and testing.
The extension can be installed side-by-side with the current GitHub Pull Request extension, use the Extensions Viewlet to disable this version of the extension you do not want to use.
${readme}
`;
fs.writeFileSync('./README.insiders.md', previewReadme);
const constants = fs.readFileSync('./src/constants.ts').toString();
const insiderConstants = constants.replace(`export const EXTENSION_ID = 'GitHub.vscode-pull-request-github';`, `export const EXTENSION_ID = 'GitHub.vscode-pull-request-github-insiders';`);
fs.writeFileSync('./src/constants.insiders.ts', insiderConstants);