@terascope/fetch-github-release 0.8.5 → 0.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -4
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +65 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/download.d.ts +4 -0
- package/dist/src/download.d.ts.map +1 -0
- package/dist/src/download.js +50 -0
- package/dist/src/download.js.map +1 -0
- package/dist/src/downloadRelease.d.ts +13 -0
- package/dist/src/downloadRelease.d.ts.map +1 -0
- package/dist/src/downloadRelease.js +80 -0
- package/dist/src/downloadRelease.js.map +1 -0
- package/dist/src/getLatest.d.ts +3 -0
- package/dist/src/getLatest.d.ts.map +1 -0
- package/dist/src/getLatest.js +24 -0
- package/dist/src/getLatest.js.map +1 -0
- package/dist/src/getReleases.d.ts +3 -0
- package/dist/src/getReleases.d.ts.map +1 -0
- package/dist/src/getReleases.js +24 -0
- package/dist/src/getReleases.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces.d.ts +28 -0
- package/dist/src/interfaces.d.ts.map +1 -0
- package/dist/src/interfaces.js +3 -0
- package/dist/src/interfaces.js.map +1 -0
- package/dist/src/rpad.d.ts +2 -0
- package/dist/src/rpad.d.ts.map +1 -0
- package/dist/src/rpad.js +12 -0
- package/dist/src/rpad.js.map +1 -0
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -3,10 +3,6 @@
|
|
|
3
3
|
A node module to download Github release assets. It will also uncompress zip
|
|
4
4
|
files and skip downloading if a file already exists.
|
|
5
5
|
|
|
6
|
-
[](https://travis-ci.org/terascope/fetch-github-release)
|
|
7
|
-
[](https://codecov.io/gh/terascope/fetch-github-release)
|
|
8
|
-
[](https://david-dm.org/terascope/fetch-github-release)
|
|
9
|
-
|
|
10
6
|
```
|
|
11
7
|
$ fetch-github-release -s darwin-x64 electron electron
|
|
12
8
|
Downloading electron/electron@v1.3.1...
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/src/cli.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
7
|
+
const downloadRelease_1 = require("./downloadRelease");
|
|
8
|
+
const command = yargs_1.default
|
|
9
|
+
.option('prerelease', {
|
|
10
|
+
description: 'download prerelease',
|
|
11
|
+
type: 'boolean',
|
|
12
|
+
alias: 'p',
|
|
13
|
+
default: false
|
|
14
|
+
})
|
|
15
|
+
.option('search', {
|
|
16
|
+
description: 'filter assets name, this can be regex',
|
|
17
|
+
alias: 's',
|
|
18
|
+
type: 'string',
|
|
19
|
+
})
|
|
20
|
+
.option('quiet', {
|
|
21
|
+
description: 'don\'t log to console',
|
|
22
|
+
type: 'boolean',
|
|
23
|
+
alias: 'q',
|
|
24
|
+
default: false
|
|
25
|
+
})
|
|
26
|
+
.option('zipped', {
|
|
27
|
+
description: 'don\'t extract zip files',
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
alias: 'z',
|
|
30
|
+
default: false
|
|
31
|
+
})
|
|
32
|
+
.positional('user', {
|
|
33
|
+
description: 'The Github user',
|
|
34
|
+
type: 'string',
|
|
35
|
+
})
|
|
36
|
+
.requiresArg('user')
|
|
37
|
+
.positional('repo', {
|
|
38
|
+
description: 'The Github repo',
|
|
39
|
+
type: 'string',
|
|
40
|
+
})
|
|
41
|
+
.requiresArg('repo')
|
|
42
|
+
.positional('outputdir', {
|
|
43
|
+
description: 'The directory to download the assets to',
|
|
44
|
+
type: 'string',
|
|
45
|
+
})
|
|
46
|
+
.argv;
|
|
47
|
+
const user = command._[0];
|
|
48
|
+
const repo = command._[1];
|
|
49
|
+
const outputdir = command._[2] || process.cwd();
|
|
50
|
+
function filterRelease(release) {
|
|
51
|
+
return release.draft === false && release.prerelease === !!command.prerelease;
|
|
52
|
+
}
|
|
53
|
+
function filterAsset(asset) {
|
|
54
|
+
if (!command.search) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return new RegExp(command.search).test(asset.name);
|
|
58
|
+
}
|
|
59
|
+
(0, downloadRelease_1.downloadRelease)(user, repo, outputdir, filterRelease, filterAsset, !!command.zipped, !!command.quiet).catch((err) => {
|
|
60
|
+
console.error(err);
|
|
61
|
+
process.exitCode = 1;
|
|
62
|
+
}).finally(() => {
|
|
63
|
+
process.exit();
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAC1B,uDAAoD;AAGpD,MAAM,OAAO,GAAG,eAAK;KAChB,MAAM,CAAC,YAAY,EAAE;IAClB,WAAW,EAAE,qBAAqB;IAClC,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,GAAG;IACV,OAAO,EAAE,KAAK;CACjB,CAAC;KACD,MAAM,CAAC,QAAQ,EAAE;IACd,WAAW,EAAE,uCAAuC;IACpD,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,QAAQ;CACjB,CAAC;KACD,MAAM,CAAC,OAAO,EAAE;IACb,WAAW,EAAE,uBAAuB;IACpC,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,GAAG;IACV,OAAO,EAAE,KAAK;CACjB,CAAC;KACD,MAAM,CAAC,QAAQ,EAAE;IACd,WAAW,EAAE,0BAA0B;IACvC,IAAI,EAAE,SAAS;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CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;IACZ,OAAO,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/download.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAmBlC,wBAAgB,QAAQ,CACpB,GAAG,EAAE,MAAM,EACX,CAAC,EAAE,QAAQ,EACX,QAAQ,GAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAe,GAClD,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.download = void 0;
|
|
7
|
+
const http_1 = __importDefault(require("http"));
|
|
8
|
+
const https_1 = __importDefault(require("https"));
|
|
9
|
+
const url_1 = __importDefault(require("url"));
|
|
10
|
+
const { GITHUB_TOKEN } = process.env;
|
|
11
|
+
function getRequestOptions(urlString) {
|
|
12
|
+
const url = url_1.default.parse(urlString);
|
|
13
|
+
const headers = {
|
|
14
|
+
Accept: 'application/octet-stream',
|
|
15
|
+
'User-Agent': '@terascope/fetch-github-release',
|
|
16
|
+
};
|
|
17
|
+
if (GITHUB_TOKEN) {
|
|
18
|
+
headers.Authorization = `token ${GITHUB_TOKEN}`;
|
|
19
|
+
}
|
|
20
|
+
return Object.assign({}, url, { headers });
|
|
21
|
+
}
|
|
22
|
+
function download(url, w, progress = () => { }) {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
let protocol = /^https:/.exec(url) ? https_1.default : http_1.default;
|
|
25
|
+
const options = getRequestOptions(url);
|
|
26
|
+
progress(0);
|
|
27
|
+
protocol
|
|
28
|
+
.get(options, (res1) => {
|
|
29
|
+
protocol = /^https:/.exec(res1.headers.location) ? https_1.default : http_1.default;
|
|
30
|
+
protocol
|
|
31
|
+
.get(res1.headers.location, (res2) => {
|
|
32
|
+
var _a;
|
|
33
|
+
const total = parseInt((_a = res2.headers['content-length']) !== null && _a !== void 0 ? _a : '0', 10);
|
|
34
|
+
let completed = 0;
|
|
35
|
+
res2.pipe(w);
|
|
36
|
+
res2.on('data', (data) => {
|
|
37
|
+
completed += data.length;
|
|
38
|
+
progress(completed / total);
|
|
39
|
+
});
|
|
40
|
+
res2.on('progress', progress);
|
|
41
|
+
res2.on('error', reject);
|
|
42
|
+
res2.on('end', resolve);
|
|
43
|
+
})
|
|
44
|
+
.on('error', reject);
|
|
45
|
+
})
|
|
46
|
+
.on('error', reject);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
exports.download = download;
|
|
50
|
+
//# sourceMappingURL=download.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download.js","sourceRoot":"","sources":["../../src/download.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,kDAA0B;AAE1B,8CAAsB;AAEtB,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAErC,SAAS,iBAAiB,CAAC,SAAiB;IACxC,MAAM,GAAG,GAAG,aAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,OAAO,GAA2B;QACpC,MAAM,EAAE,0BAA0B;QAClC,YAAY,EAAE,iCAAiC;KAClD,CAAC;IAEF,IAAI,YAAY,EAAE;QACd,OAAO,CAAC,aAAa,GAAG,SAAS,YAAY,EAAE,CAAC;KACnD;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,C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E,OAAO,CAAC,CAAC;YAC5B,CAAC,CAAC;iBACD,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7B,CAAC,CAAC;aACD,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACP,CAAC;AAhCD,4BAgCC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GithubRelease, GithubReleaseAsset } from './interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Download a specific github release
|
|
4
|
+
* @param user The name of the github user or organization
|
|
5
|
+
* @param repo The name of the github repository
|
|
6
|
+
* @param outputDir The directory to write the release to
|
|
7
|
+
* @param filterRelease Optionally filter the release
|
|
8
|
+
* @param filterAsset Optionally filter the asset for a given release
|
|
9
|
+
* @param leaveZipped Optionally leave the file zipped
|
|
10
|
+
* @param leaveZipped Optionally disable logging for quiet output
|
|
11
|
+
*/
|
|
12
|
+
export declare function downloadRelease(user: string, repo: string, outputDir: string, filterRelease?: (release: GithubRelease) => boolean, filterAsset?: (release: GithubReleaseAsset) => boolean, leaveZipped?: boolean, disableLogging?: boolean): Promise<string[]>;
|
|
13
|
+
//# sourceMappingURL=downloadRelease.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"downloadRelease.d.ts","sourceRoot":"","sources":["../../src/downloadRelease.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAQjE;;;;;;;;;EASE;AACF,wBAAsB,eAAe,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,aAAa,GAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAc,EACzD,WAAW,GAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAc,EAC5D,WAAW,UAAQ,EACnB,cAAc,UAAQ,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC,CA2DnB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.downloadRelease = void 0;
|
|
7
|
+
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const extract_zip_1 = __importDefault(require("extract-zip"));
|
|
11
|
+
const getReleases_1 = require("./getReleases");
|
|
12
|
+
const getLatest_1 = require("./getLatest");
|
|
13
|
+
const download_1 = require("./download");
|
|
14
|
+
const rpad_1 = require("./rpad");
|
|
15
|
+
function pass() {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
const MultiProgress = require('multi-progress');
|
|
19
|
+
/**
|
|
20
|
+
* Download a specific github release
|
|
21
|
+
* @param user The name of the github user or organization
|
|
22
|
+
* @param repo The name of the github repository
|
|
23
|
+
* @param outputDir The directory to write the release to
|
|
24
|
+
* @param filterRelease Optionally filter the release
|
|
25
|
+
* @param filterAsset Optionally filter the asset for a given release
|
|
26
|
+
* @param leaveZipped Optionally leave the file zipped
|
|
27
|
+
* @param leaveZipped Optionally disable logging for quiet output
|
|
28
|
+
*/
|
|
29
|
+
async function downloadRelease(user, repo, outputDir, filterRelease = pass, filterAsset = pass, leaveZipped = false, disableLogging = false) {
|
|
30
|
+
if (!user) {
|
|
31
|
+
throw new Error('Missing user argument');
|
|
32
|
+
}
|
|
33
|
+
if (!repo) {
|
|
34
|
+
throw new Error('Missing user argument');
|
|
35
|
+
}
|
|
36
|
+
const bars = new MultiProgress(process.stderr);
|
|
37
|
+
const releases = await (0, getReleases_1.getReleases)(user, repo);
|
|
38
|
+
const release = (0, getLatest_1.getLatest)(releases, filterRelease, filterAsset);
|
|
39
|
+
if (!release) {
|
|
40
|
+
throw new Error(`Could not find a release for ${user}/${repo} (${os_1.default.platform()} ${os_1.default.arch()})`);
|
|
41
|
+
}
|
|
42
|
+
if (!disableLogging) {
|
|
43
|
+
console.error(`Downloading ${user}/${repo}@${release.tag_name}...`);
|
|
44
|
+
}
|
|
45
|
+
const promises = release.assets.map(async (asset) => {
|
|
46
|
+
let progress;
|
|
47
|
+
if (process.stdout.isTTY && !disableLogging) {
|
|
48
|
+
const bar = bars.newBar(`${(0, rpad_1.rpad)(asset.name, 24)} :bar :etas`, {
|
|
49
|
+
complete: '▇',
|
|
50
|
+
incomplete: '-',
|
|
51
|
+
width: process.stdout.columns - 36,
|
|
52
|
+
total: 100
|
|
53
|
+
});
|
|
54
|
+
progress = bar.update.bind(bar);
|
|
55
|
+
}
|
|
56
|
+
// eslint-disable-next-line no-param-reassign
|
|
57
|
+
outputDir = path_1.default.isAbsolute(outputDir) ? outputDir : path_1.default.resolve(outputDir);
|
|
58
|
+
if (!fs_1.default.existsSync(outputDir)) {
|
|
59
|
+
fs_1.default.mkdirSync(outputDir);
|
|
60
|
+
}
|
|
61
|
+
if (!fs_1.default.statSync(outputDir).isDirectory()) {
|
|
62
|
+
throw new Error(`Output path "${outputDir}" must be a directory`);
|
|
63
|
+
}
|
|
64
|
+
const destf = path_1.default.join(outputDir, asset.name);
|
|
65
|
+
if (!fs_1.default.existsSync(destf)) {
|
|
66
|
+
const dest = fs_1.default.createWriteStream(destf);
|
|
67
|
+
await (0, download_1.download)(asset.url, dest, progress);
|
|
68
|
+
if (!leaveZipped && /\.zip$/.exec(destf)) {
|
|
69
|
+
await (0, extract_zip_1.default)(destf, {
|
|
70
|
+
dir: outputDir
|
|
71
|
+
});
|
|
72
|
+
fs_1.default.unlinkSync(destf);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return destf;
|
|
76
|
+
});
|
|
77
|
+
return Promise.all(promises);
|
|
78
|
+
}
|
|
79
|
+
exports.downloadRelease = downloadRelease;
|
|
80
|
+
//# sourceMappingURL=downloadRelease.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"downloadRelease.js","sourceRoot":"","sources":["../../src/downloadRelease.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,8DAAkC;AAClC,+CAA4C;AAC5C,2CAAwC;AACxC,yCAAsC;AACtC,iCAA8B;AAG9B,SAAS,IAAI;IACT,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,MAAM,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAEhD;;;;;;;;;EASE;AACK,KAAK,UAAU,eAAe,CACjC,IAAY,EACZ,IAAY,EACZ,SAAiB,EACjB,gBAAqD,IAAI,EACzD,cAAwD,IAAI,EAC5D,WAAW,GAAG,KAAK,EACnB,cAAc,GAAG,KAAK;IAEtB,IAAI,CAAC,IAAI,EAAE;QACP,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;KAC5C;IACD,IAAI,CAAC,IAAI,EAAE;QACP,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;KAC5C;IACD,MAAM,IAAI,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE/C,MAAM,QAAQ,GAAG,MAAM,IAAA,yBAAW,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,IAAA,qBAAS,EAAC,QAAQ,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;IAChE,IAAI,CAAC,OAAO,EAAE;QACV,MAAM,IAAI,KAAK,CACX,gCAAgC,IAAI,IAAI,IAAI,KAAK,YAAE,CAAC,QAAQ,EAAE,IAAI,YAAE,CAAC,IAAI,EAAE,GAAG,CACjF,CAAC;KACL;IAED,IAAI,CAAC,cAAc,EAAE;QACjB,OAAO,CAAC,KAAK,CAAC,eAAe,IAAI,IAAI,IAAI,IAAI,OAAO,CAAC,QAAQ,KAAK,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CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;YAC1C,IAAI,CAAC,WAAW,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;gBACtC,MAAM,IAAA,qBAAO,EAAC,KAAK,EAAE;oBACjB,GAAG,EAAE,SAAS;iBACjB,CAAC,CAAC;gBACH,YAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;aACxB;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC;AAnED,0CAmEC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { GithubRelease, GithubReleaseAsset } from './interfaces';
|
|
2
|
+
export declare function getLatest(releases: GithubRelease[], filterRelease?: (release: GithubRelease) => boolean, filterAsset?: (release: GithubReleaseAsset) => boolean): GithubRelease | null;
|
|
3
|
+
//# sourceMappingURL=getLatest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLatest.d.ts","sourceRoot":"","sources":["../../src/getLatest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAMjE,wBAAgB,SAAS,CACrB,QAAQ,EAAE,aAAa,EAAE,EACzB,aAAa,GAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAc,EACzD,WAAW,GAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAc,GAC7D,aAAa,GAAC,IAAI,CAoBpB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLatest = void 0;
|
|
4
|
+
function pass() {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
function getLatest(releases, filterRelease = pass, filterAsset = pass) {
|
|
8
|
+
if (!releases) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const filtered = releases.filter(filterRelease);
|
|
12
|
+
if (!filtered.length) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
for (const release of filtered) {
|
|
16
|
+
const assets = release.assets.filter(filterAsset);
|
|
17
|
+
if (assets.length) {
|
|
18
|
+
return Object.assign({}, release, { assets });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
exports.getLatest = getLatest;
|
|
24
|
+
//# sourceMappingURL=getLatest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLatest.js","sourceRoot":"","sources":["../../src/getLatest.ts"],"names":[],"mappings":";;;AAEA,SAAS,IAAI;IACT,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAgB,SAAS,CACrB,QAAyB,EACzB,gBAAqD,IAAI,EACzD,cAAwD,IAAI;IAE5D,IAAI,CAAC,QAAQ,EAAE;QACX,OAAO,IAAI,CAAC;KACf;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAEhD,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;QAClB,OAAO,IAAI,CAAC;KACf;IAED,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC5B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAElD,IAAI,MAAM,CAAC,MAAM,EAAE;YACf,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;SACjD;KACJ;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAxBD,8BAwBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getReleases.d.ts","sourceRoot":"","sources":["../../src/getReleases.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAgBtF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getReleases = void 0;
|
|
7
|
+
const got_1 = __importDefault(require("got"));
|
|
8
|
+
const { GITHUB_TOKEN } = process.env;
|
|
9
|
+
async function getReleases(user, repo) {
|
|
10
|
+
const url = `https://api.github.com/repos/${user}/${repo}/releases`;
|
|
11
|
+
const requestConfig = {
|
|
12
|
+
headers: {
|
|
13
|
+
'User-Agent': '@terascope/fetch-github-release'
|
|
14
|
+
},
|
|
15
|
+
responseType: 'json'
|
|
16
|
+
};
|
|
17
|
+
if (GITHUB_TOKEN) {
|
|
18
|
+
requestConfig.headers.Authorization = `token ${GITHUB_TOKEN}`;
|
|
19
|
+
}
|
|
20
|
+
const r = await got_1.default.get(url, requestConfig);
|
|
21
|
+
return r.body;
|
|
22
|
+
}
|
|
23
|
+
exports.getReleases = getReleases;
|
|
24
|
+
//# sourceMappingURL=getReleases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getReleases.js","sourceRoot":"","sources":["../../src/getReleases.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAqD;AAGrD,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAE9B,KAAK,UAAU,WAAW,CAAC,IAAY,EAAE,IAAY;IACxD,MAAM,GAAG,GAAG,gCAAgC,IAAI,IAAI,IAAI,WAAW,CAAC;IAEpE,MAAM,aAAa,GAA8B;QAC7C,OAAO,EAAE;YACL,YAAY,EAAE,iCAAiC;SACxB;QAC3B,YAAY,EAAE,MAAM;KACvB,CAAC;IAEF,IAAI,YAAY,EAAE;QACd,aAAa,CAAC,OAAQ,CAAC,aAAa,GAAG,SAAS,YAAY,EAAE,CAAC;KAClE;IAED,MAAM,CAAC,GAAG,MAAM,aAAG,CAAC,GAAG,CAAkB,GAAG,EAAE,aAAa,CAAC,CAAC;IAC7D,OAAO,CAAC,CAAC,IAAI,CAAC;AAClB,CAAC;AAhBD,kCAgBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.downloadRelease = void 0;
|
|
4
|
+
const downloadRelease_1 = require("./downloadRelease");
|
|
5
|
+
Object.defineProperty(exports, "downloadRelease", { enumerable: true, get: function () { return downloadRelease_1.downloadRelease; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAE3C,gGAFA,iCAAe,OAEA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See https://developer.github.com/v3/repos/releases/#get-a-single-release-asset
|
|
3
|
+
*/
|
|
4
|
+
export interface GithubRelease {
|
|
5
|
+
id: number;
|
|
6
|
+
url: string;
|
|
7
|
+
tag_name: string;
|
|
8
|
+
name: string;
|
|
9
|
+
body: string;
|
|
10
|
+
draft: boolean;
|
|
11
|
+
prerelease: boolean;
|
|
12
|
+
created_at: string;
|
|
13
|
+
published_at: string;
|
|
14
|
+
assets: GithubReleaseAsset[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* See https://developer.github.com/v3/repos/releases/#get-a-single-release-asset
|
|
18
|
+
*/
|
|
19
|
+
export interface GithubReleaseAsset {
|
|
20
|
+
id: number;
|
|
21
|
+
name: string;
|
|
22
|
+
url: string;
|
|
23
|
+
content_type: string;
|
|
24
|
+
size: number;
|
|
25
|
+
created_at: string;
|
|
26
|
+
updated_at: string;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAAA;;EAEE;AACF,MAAM,WAAW,aAAa;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpad.d.ts","sourceRoot":"","sources":["../../src/rpad.ts"],"names":[],"mappings":"AAAA,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAQtD"}
|
package/dist/src/rpad.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rpad = void 0;
|
|
4
|
+
function rpad(text, len) {
|
|
5
|
+
let t = text;
|
|
6
|
+
if (t.length > len) {
|
|
7
|
+
t = `${text.substr(0, len - 3)}...`;
|
|
8
|
+
}
|
|
9
|
+
return `${t}${new Array(len - t.length + 1).join(' ')}`;
|
|
10
|
+
}
|
|
11
|
+
exports.rpad = rpad;
|
|
12
|
+
//# sourceMappingURL=rpad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpad.js","sourceRoot":"","sources":["../../src/rpad.ts"],"names":[],"mappings":";;;AAAA,SAAgB,IAAI,CAAC,IAAY,EAAE,GAAW;IAC1C,IAAI,CAAC,GAAG,IAAI,CAAC;IAEb,IAAI,CAAC,CAAC,MAAM,GAAG,GAAG,EAAE;QAChB,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC;KACvC;IAED,OAAO,GAAG,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC5D,CAAC;AARD,oBAQC"}
|
package/package.json
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.8.
|
|
6
|
+
"version": "0.8.8",
|
|
7
7
|
"description": "Download a specific release from github",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist/src/**/*",
|
|
10
10
|
"bin/*"
|
|
11
11
|
],
|
|
12
|
-
"main": "
|
|
12
|
+
"main": "dist/src/index.js",
|
|
13
13
|
"typings": "dist/src/index.d.ts",
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "
|
|
15
|
+
"build": "tsc --project tsconfig.json",
|
|
16
16
|
"build:watch": "yarn build --watch",
|
|
17
17
|
"lint": "eslint --ignore-path .gitignore --ext .js,.ts .",
|
|
18
18
|
"lint:fix": "yarn lint --fix",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"test:watch": "jest --coverage=false --notify --watch --onlyChanged",
|
|
23
23
|
"test:debug": "env DEBUG=\"${DEBUG:-*teraslice*}\" jest --detectOpenHandles --coverage=false --runInBand",
|
|
24
24
|
"check": "yarn run lint && yarn run test",
|
|
25
|
-
"clean": "rimraf dist coverage"
|
|
25
|
+
"clean": "rimraf dist coverage",
|
|
26
|
+
"prepublishOnly": "yarn run clean && yarn run build"
|
|
26
27
|
},
|
|
27
28
|
"bin": {
|
|
28
29
|
"fetch-github-release": "bin/fetch-github-release"
|
|
@@ -43,21 +44,21 @@
|
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"extract-zip": "^2.0.1",
|
|
46
|
-
"gauge": "^
|
|
47
|
+
"gauge": "^4.0.0",
|
|
47
48
|
"got": "^11.4.0",
|
|
48
49
|
"multi-progress": "^4.0.0",
|
|
49
50
|
"progress": "^2.0.3",
|
|
50
51
|
"yargs": "^17.2.1"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
|
-
"@terascope/eslint-config": "^0.
|
|
54
|
+
"@terascope/eslint-config": "^0.7.0",
|
|
54
55
|
"@types/jest": "^27.0.2",
|
|
55
56
|
"@types/node": "^16.10.2",
|
|
56
57
|
"@types/stream-buffers": "^3.0.4",
|
|
57
58
|
"@types/tmp": "^0.2.1",
|
|
58
|
-
"eslint": "^
|
|
59
|
+
"eslint": "^8.1.0",
|
|
59
60
|
"jest": "^27.2.4",
|
|
60
|
-
"jest-extended": "^0.
|
|
61
|
+
"jest-extended": "^2.0.0",
|
|
61
62
|
"nock": "^13.0.2",
|
|
62
63
|
"node-notifier": "^10.0.0",
|
|
63
64
|
"rimraf": "^3.0.0",
|