diff --git a/setup-taskfile/__tests__/main.test.ts b/setup-taskfile/__tests__/main.test.ts index 13260737..eb67e8e3 100644 --- a/setup-taskfile/__tests__/main.test.ts +++ b/setup-taskfile/__tests__/main.test.ts @@ -31,7 +31,7 @@ describe("installer tests", () => { }); it("Downloads version of Task if no matching version is installed", async () => { - await installer.getTask("2.6.0"); + await installer.getTask("2.6.0", ""); const taskDir = path.join(toolDir, "task", "2.6.0", os.arch()); expect(fs.existsSync(`${taskDir}.complete`)).toBe(true); @@ -56,7 +56,7 @@ describe("installer tests", () => { }); it("Gets the latest version of Task 2.5 using 2.5 and no matching version is installed", async () => { - await installer.getTask("2.5"); + await installer.getTask("2.5", ""); const taskDir = path.join(toolDir, "task", "2.5.2", os.arch()); expect(fs.existsSync(`${taskDir}.complete`)).toBe(true); @@ -68,7 +68,7 @@ describe("installer tests", () => { }); it("Gets latest version of Task using 2.x and no matching version is installed", async () => { - await installer.getTask("2.x"); + await installer.getTask("2.x", ""); const taskdir = path.join(toolDir, "task", "2.6.0", os.arch()); expect(fs.existsSync(`${taskdir}.complete`)).toBe(true); @@ -80,7 +80,7 @@ describe("installer tests", () => { }); it("Gets preview version of Task using 3.x and no matching version is installed", async () => { - await installer.getTask("3.x"); + await installer.getTask("3.x", ""); const taskdir = path.join(toolDir, "task", "3.0.0-preview1", os.arch()); expect(fs.existsSync(`${taskdir}.complete`)).toBe(true); diff --git a/setup-taskfile/lib/installer.js b/setup-taskfile/lib/installer.js index b7b997bf..1f11d82a 100644 --- a/setup-taskfile/lib/installer.js +++ b/setup-taskfile/lib/installer.js @@ -16,7 +16,7 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); // Load tempDirectory before it gets wiped by tool-cache -let tempDirectory = process.env['RUNNER_TEMP'] || ''; +let tempDirectory = process.env["RUNNER_TEMP"] || ""; const os = __importStar(require("os")); const path = __importStar(require("path")); const util = __importStar(require("util")); @@ -24,41 +24,41 @@ const restm = __importStar(require("typed-rest-client/RestClient")); const semver = __importStar(require("semver")); if (!tempDirectory) { let baseLocation; - if (process.platform === 'win32') { + if (process.platform === "win32") { // On windows use the USERPROFILE env variable - baseLocation = process.env['USERPROFILE'] || 'C:\\'; + baseLocation = process.env["USERPROFILE"] || "C:\\"; } else { - if (process.platform === 'darwin') { - baseLocation = '/Users'; + if (process.platform === "darwin") { + baseLocation = "/Users"; } else { - baseLocation = '/home'; + baseLocation = "/home"; } } - tempDirectory = path.join(baseLocation, 'actions', 'temp'); + tempDirectory = path.join(baseLocation, "actions", "temp"); } const core = __importStar(require("@actions/core")); const tc = __importStar(require("@actions/tool-cache")); const io = require("@actions/io"); let osPlat = os.platform(); let osArch = os.arch(); -function getTask(version) { +function getTask(version, repoToken) { return __awaiter(this, void 0, void 0, function* () { // resolve the version number - const targetVersion = yield computeVersion(version); + const targetVersion = yield computeVersion(version, repoToken); if (targetVersion) { version = targetVersion; } // look if the binary is cached let toolPath; - toolPath = tc.find('task', version); + toolPath = tc.find("task", version); // if not: download, extract and cache if (!toolPath) { toolPath = yield downloadRelease(version); - core.debug('Task cached under ' + toolPath); + core.debug("Task cached under " + toolPath); } - toolPath = path.join(toolPath, 'bin'); + toolPath = path.join(toolPath, "bin"); core.addPath(toolPath); }); } @@ -67,7 +67,7 @@ function downloadRelease(version) { return __awaiter(this, void 0, void 0, function* () { // Download let fileName = getFileName(); - let downloadUrl = util.format('https://github.com/go-task/task/releases/download/%s/%s', version, fileName); + let downloadUrl = util.format("https://github.com/go-task/task/releases/download/%s/%s", version, fileName); let downloadPath = null; try { downloadPath = yield tc.downloadTool(downloadUrl); @@ -78,51 +78,59 @@ function downloadRelease(version) { } // Extract let extPath = null; - if (osPlat == 'win32') { + if (osPlat == "win32") { extPath = yield tc.extractZip(downloadPath); // Create a bin/ folder and move `task` there - yield io.mkdirP(path.join(extPath, 'bin')); - yield io.mv(path.join(extPath, 'task.exe'), path.join(extPath, 'bin')); + yield io.mkdirP(path.join(extPath, "bin")); + yield io.mv(path.join(extPath, "task.exe"), path.join(extPath, "bin")); } else { extPath = yield tc.extractTar(downloadPath); // Create a bin/ folder and move `task` there - yield io.mkdirP(path.join(extPath, 'bin')); - yield io.mv(path.join(extPath, 'task'), path.join(extPath, 'bin')); + yield io.mkdirP(path.join(extPath, "bin")); + yield io.mv(path.join(extPath, "task"), path.join(extPath, "bin")); } // Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded - return yield tc.cacheDir(extPath, 'task', version); + return yield tc.cacheDir(extPath, "task", version); }); } function getFileName() { - const platform = osPlat == 'win32' ? 'windows' : osPlat; - const arch = osArch == 'x64' ? 'amd64' : '386'; - const ext = osPlat == 'win32' ? 'zip' : 'tar.gz'; - const filename = util.format('task_%s_%s.%s', platform, arch, ext); + const platform = osPlat == "win32" ? "windows" : osPlat; + const arch = osArch == "x64" ? "amd64" : "386"; + const ext = osPlat == "win32" ? "zip" : "tar.gz"; + const filename = util.format("task_%s_%s.%s", platform, arch, ext); return filename; } // Retrieve a list of versions scraping tags from the Github API -function fetchVersions() { +function fetchVersions(repoToken) { return __awaiter(this, void 0, void 0, function* () { - let rest = new restm.RestClient('setup-taskfile'); - let tags = (yield rest.get('https://api.github.com/repos/go-task/task/git/refs/tags')).result || []; + let rest; + if (repoToken != "") { + rest = new restm.RestClient("setup-taskfile", "", [], { + headers: { Authorization: "Bearer " + repoToken } + }); + } + else { + rest = new restm.RestClient("setup-taskfile"); + } + let tags = (yield rest.get("https://api.github.com/repos/go-task/task/git/refs/tags")).result || []; return tags .filter(tag => tag.ref.match(/v\d+\.[\w\.]+/g)) - .map(tag => tag.ref.replace('refs/tags/v', '')); + .map(tag => tag.ref.replace("refs/tags/v", "")); }); } // Compute an actual version starting from the `version` configuration param. -function computeVersion(version) { +function computeVersion(version, repoToken) { return __awaiter(this, void 0, void 0, function* () { // strip leading `v` char (will be re-added later) - if (version.startsWith('v')) { + if (version.startsWith("v")) { version = version.slice(1, version.length); } // strip trailing .x chars - if (version.endsWith('.x')) { + if (version.endsWith(".x")) { version = version.slice(0, version.length - 2); } - const allVersions = yield fetchVersions(); + const allVersions = yield fetchVersions(repoToken); const possibleVersions = allVersions.filter(v => v.startsWith(version)); const versionMap = new Map(); possibleVersions.forEach(v => versionMap.set(normalizeVersion(v), v)); @@ -131,46 +139,46 @@ function computeVersion(version) { .map(v => versionMap.get(v)); core.debug(`evaluating ${versions.length} versions`); if (versions.length === 0) { - throw new Error('unable to get latest version'); + throw new Error("unable to get latest version"); } core.debug(`matched: ${versions[0]}`); - return 'v' + versions[0]; + return "v" + versions[0]; }); } // Make partial versions semver compliant. function normalizeVersion(version) { - const preStrings = ['beta', 'rc', 'preview']; - const versionPart = version.split('.'); + const preStrings = ["beta", "rc", "preview"]; + const versionPart = version.split("."); if (versionPart[1] == null) { //append minor and patch version if not available // e.g. 2 -> 2.0.0 - return version.concat('.0.0'); + return version.concat(".0.0"); } else { // handle beta and rc // e.g. 1.10beta1 -? 1.10.0-beta1, 1.10rc1 -> 1.10.0-rc1 if (preStrings.some(el => versionPart[1].includes(el))) { versionPart[1] = versionPart[1] - .replace('beta', '.0-beta') - .replace('rc', '.0-rc') - .replace('preview', '.0-preview'); - return versionPart.join('.'); + .replace("beta", ".0-beta") + .replace("rc", ".0-rc") + .replace("preview", ".0-preview"); + return versionPart.join("."); } } if (versionPart[2] == null) { //append patch version if not available // e.g. 2.1 -> 2.1.0 - return version.concat('.0'); + return version.concat(".0"); } else { // handle beta and rc // e.g. 1.8.5beta1 -> 1.8.5-beta1, 1.8.5rc1 -> 1.8.5-rc1 - if (preStrings.some(el => versionPart[1].includes(el))) { + if (preStrings.some(el => versionPart[2].includes(el))) { versionPart[2] = versionPart[2] - .replace('beta', '-beta') - .replace('rc', '-rc') - .replace('preview', '-preview'); - return versionPart.join('.'); + .replace("beta", "-beta") + .replace("rc", "-rc") + .replace("preview", "-preview"); + return versionPart.join("."); } } return version; diff --git a/setup-taskfile/lib/main.js b/setup-taskfile/lib/main.js index 432f7396..65b8f20d 100644 --- a/setup-taskfile/lib/main.js +++ b/setup-taskfile/lib/main.js @@ -20,12 +20,13 @@ const installer = __importStar(require("./installer")); function run() { return __awaiter(this, void 0, void 0, function* () { try { - let version = core.getInput('version'); + let version = core.getInput("version"); + let repoToken = core.getInput("repo-token"); if (!version) { - version = '2.x'; + version = "2.x"; } if (version) { - yield installer.getTask(version); + yield installer.getTask(version, repoToken); } } catch (error) { diff --git a/setup-taskfile/node_modules/@actions/core/package.json b/setup-taskfile/node_modules/@actions/core/package.json index 64b8bbf7..dc8e9d18 100644 --- a/setup-taskfile/node_modules/@actions/core/package.json +++ b/setup-taskfile/node_modules/@actions/core/package.json @@ -2,7 +2,7 @@ "_args": [ [ "@actions/core@1.0.0", - "/home/massi/dev/actions/setup-taskfile" + "/home/rsora/code/projects/arduino/actions/setup-taskfile" ] ], "_from": "@actions/core@1.0.0", @@ -28,7 +28,7 @@ ], "_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.0.0.tgz", "_spec": "1.0.0", - "_where": "/home/massi/dev/actions/setup-taskfile", + "_where": "/home/rsora/code/projects/arduino/actions/setup-taskfile", "bugs": { "url": "https://github.com/actions/toolkit/issues" }, diff --git a/setup-taskfile/node_modules/@actions/exec/package.json b/setup-taskfile/node_modules/@actions/exec/package.json index abbb5b35..6713d12b 100644 --- a/setup-taskfile/node_modules/@actions/exec/package.json +++ b/setup-taskfile/node_modules/@actions/exec/package.json @@ -1,33 +1,36 @@ { - "_from": "@actions/exec@^1.0.0", + "_args": [ + [ + "@actions/exec@1.0.0", + "/home/rsora/code/projects/arduino/actions/setup-taskfile" + ] + ], + "_from": "@actions/exec@1.0.0", "_id": "@actions/exec@1.0.0", "_inBundle": false, "_integrity": "sha512-nquH0+XKng+Ll7rZfCojN7NWSbnGh+ltwUJhzfbLkmOJgxocGX2/yXcZLMyT9fa7+tByEow/NSTrBExNlEj9fw==", "_location": "/@actions/exec", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "@actions/exec@^1.0.0", + "raw": "@actions/exec@1.0.0", "name": "@actions/exec", "escapedName": "@actions%2fexec", "scope": "@actions", - "rawSpec": "^1.0.0", + "rawSpec": "1.0.0", "saveSpec": null, - "fetchSpec": "^1.0.0" + "fetchSpec": "1.0.0" }, "_requiredBy": [ "/@actions/tool-cache" ], "_resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.0.tgz", - "_shasum": "70c8b698c9baa02965c07da5f0b185ca56f0a955", - "_spec": "@actions/exec@^1.0.0", - "_where": "/home/massi/dev/actions/setup-taskfile/node_modules/@actions/tool-cache", + "_spec": "1.0.0", + "_where": "/home/rsora/code/projects/arduino/actions/setup-taskfile", "bugs": { "url": "https://github.com/actions/toolkit/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Actions exec lib", "devDependencies": { "@actions/io": "^1.0.0" diff --git a/setup-taskfile/node_modules/@actions/io/package.json b/setup-taskfile/node_modules/@actions/io/package.json index 8f9e47ee..3b916df0 100644 --- a/setup-taskfile/node_modules/@actions/io/package.json +++ b/setup-taskfile/node_modules/@actions/io/package.json @@ -2,7 +2,7 @@ "_args": [ [ "@actions/io@1.0.0", - "/home/massi/dev/actions/setup-taskfile" + "/home/rsora/code/projects/arduino/actions/setup-taskfile" ] ], "_from": "@actions/io@1.0.0", @@ -28,7 +28,7 @@ ], "_resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.0.tgz", "_spec": "1.0.0", - "_where": "/home/massi/dev/actions/setup-taskfile", + "_where": "/home/rsora/code/projects/arduino/actions/setup-taskfile", "bugs": { "url": "https://github.com/actions/toolkit/issues" }, diff --git a/setup-taskfile/node_modules/@actions/tool-cache/package.json b/setup-taskfile/node_modules/@actions/tool-cache/package.json index 7c7470d0..83bce493 100644 --- a/setup-taskfile/node_modules/@actions/tool-cache/package.json +++ b/setup-taskfile/node_modules/@actions/tool-cache/package.json @@ -1,32 +1,36 @@ { - "_from": "@actions/tool-cache@^1.1.0", + "_args": [ + [ + "@actions/tool-cache@1.1.0", + "/home/rsora/code/projects/arduino/actions/setup-taskfile" + ] + ], + "_from": "@actions/tool-cache@1.1.0", "_id": "@actions/tool-cache@1.1.0", "_inBundle": false, "_integrity": "sha512-Oe/R1Gxv0G699OUL9ypxk9cTwHf1uXHhpcK7kpZt8d/Sbw915ktMkfxXt9+awOfLDwyl54sLi86KGCuSvnRuIQ==", "_location": "/@actions/tool-cache", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "@actions/tool-cache@^1.1.0", + "raw": "@actions/tool-cache@1.1.0", "name": "@actions/tool-cache", "escapedName": "@actions%2ftool-cache", "scope": "@actions", - "rawSpec": "^1.1.0", + "rawSpec": "1.1.0", "saveSpec": null, - "fetchSpec": "^1.1.0" + "fetchSpec": "1.1.0" }, "_requiredBy": [ "/" ], "_resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.1.0.tgz", - "_shasum": "1a0e29f244f2b5c6989fc264581068689f9c219e", - "_spec": "@actions/tool-cache@^1.1.0", - "_where": "/home/massi/dev/actions/setup-taskfile", + "_spec": "1.1.0", + "_where": "/home/rsora/code/projects/arduino/actions/setup-taskfile", "bugs": { "url": "https://github.com/actions/toolkit/issues" }, - "bundleDependencies": false, "dependencies": { "@actions/core": "^1.0.0", "@actions/exec": "^1.0.0", @@ -35,7 +39,6 @@ "typed-rest-client": "^1.4.0", "uuid": "^3.3.2" }, - "deprecated": false, "description": "Actions tool-cache lib", "devDependencies": { "@types/nock": "^10.0.3", diff --git a/setup-taskfile/node_modules/semver/package.json b/setup-taskfile/node_modules/semver/package.json index c2471523..8edc71c3 100644 --- a/setup-taskfile/node_modules/semver/package.json +++ b/setup-taskfile/node_modules/semver/package.json @@ -2,7 +2,7 @@ "_args": [ [ "semver@6.3.0", - "/home/massi/dev/actions/setup-taskfile" + "/home/rsora/code/projects/arduino/actions/setup-taskfile" ] ], "_from": "semver@6.3.0", @@ -28,7 +28,7 @@ ], "_resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", "_spec": "6.3.0", - "_where": "/home/massi/dev/actions/setup-taskfile", + "_where": "/home/rsora/code/projects/arduino/actions/setup-taskfile", "bin": { "semver": "./bin/semver.js" }, diff --git a/setup-taskfile/node_modules/tunnel/package.json b/setup-taskfile/node_modules/tunnel/package.json index 01323bfa..264d70f6 100644 --- a/setup-taskfile/node_modules/tunnel/package.json +++ b/setup-taskfile/node_modules/tunnel/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "tunnel@0.0.4", + "/home/rsora/code/projects/arduino/actions/setup-taskfile" + ] + ], "_from": "tunnel@0.0.4", "_id": "tunnel@0.0.4", "_inBundle": false, @@ -19,9 +25,8 @@ "/typed-rest-client" ], "_resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.4.tgz", - "_shasum": "2d3785a158c174c9a16dc2c046ec5fc5f1742213", - "_spec": "tunnel@0.0.4", - "_where": "/home/massi/dev/actions/setup-taskfile/node_modules/typed-rest-client", + "_spec": "0.0.4", + "_where": "/home/rsora/code/projects/arduino/actions/setup-taskfile", "author": { "name": "Koichi Kobayashi", "email": "koichik@improvement.jp" @@ -29,8 +34,6 @@ "bugs": { "url": "https://github.com/koichik/node-tunnel/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Node HTTP/HTTPS Agents for tunneling proxies", "devDependencies": { "mocha": "*", diff --git a/setup-taskfile/node_modules/typed-rest-client/package.json b/setup-taskfile/node_modules/typed-rest-client/package.json index 893f0b72..cc4f21db 100644 --- a/setup-taskfile/node_modules/typed-rest-client/package.json +++ b/setup-taskfile/node_modules/typed-rest-client/package.json @@ -1,39 +1,42 @@ { - "_from": "typed-rest-client@^1.4.0", + "_args": [ + [ + "typed-rest-client@1.5.0", + "/home/rsora/code/projects/arduino/actions/setup-taskfile" + ] + ], + "_from": "typed-rest-client@1.5.0", "_id": "typed-rest-client@1.5.0", "_inBundle": false, "_integrity": "sha512-DVZRlmsfnTjp6ZJaatcdyvvwYwbWvR4YDNFDqb+qdTxpvaVP99YCpBkA8rxsLtAPjBVoDe4fNsnMIdZTiPuKWg==", "_location": "/typed-rest-client", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "typed-rest-client@^1.4.0", + "raw": "typed-rest-client@1.5.0", "name": "typed-rest-client", "escapedName": "typed-rest-client", - "rawSpec": "^1.4.0", + "rawSpec": "1.5.0", "saveSpec": null, - "fetchSpec": "^1.4.0" + "fetchSpec": "1.5.0" }, "_requiredBy": [ "/@actions/tool-cache" ], "_resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.5.0.tgz", - "_shasum": "c0dda6e775b942fd46a2d99f2160a94953206fc2", - "_spec": "typed-rest-client@^1.4.0", - "_where": "/home/massi/dev/actions/setup-taskfile/node_modules/@actions/tool-cache", + "_spec": "1.5.0", + "_where": "/home/rsora/code/projects/arduino/actions/setup-taskfile", "author": { "name": "Microsoft Corporation" }, "bugs": { "url": "https://github.com/Microsoft/typed-rest-client/issues" }, - "bundleDependencies": false, "dependencies": { "tunnel": "0.0.4", "underscore": "1.8.3" }, - "deprecated": false, "description": "Node Rest and Http Clients for use with TypeScript", "devDependencies": { "@types/mocha": "^2.2.44", diff --git a/setup-taskfile/node_modules/underscore/package.json b/setup-taskfile/node_modules/underscore/package.json index 45dd133a..a6506651 100644 --- a/setup-taskfile/node_modules/underscore/package.json +++ b/setup-taskfile/node_modules/underscore/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "underscore@1.8.3", + "/home/rsora/code/projects/arduino/actions/setup-taskfile" + ] + ], "_from": "underscore@1.8.3", "_id": "underscore@1.8.3", "_inBundle": false, @@ -19,9 +25,8 @@ "/typed-rest-client" ], "_resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", - "_shasum": "4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022", - "_spec": "underscore@1.8.3", - "_where": "/home/massi/dev/actions/setup-taskfile/node_modules/typed-rest-client", + "_spec": "1.8.3", + "_where": "/home/rsora/code/projects/arduino/actions/setup-taskfile", "author": { "name": "Jeremy Ashkenas", "email": "jeremy@documentcloud.org" @@ -29,8 +34,6 @@ "bugs": { "url": "https://github.com/jashkenas/underscore/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "JavaScript's functional programming helper library.", "devDependencies": { "docco": "*", diff --git a/setup-taskfile/node_modules/uuid/package.json b/setup-taskfile/node_modules/uuid/package.json index 3c81cdc7..03278a04 100644 --- a/setup-taskfile/node_modules/uuid/package.json +++ b/setup-taskfile/node_modules/uuid/package.json @@ -2,7 +2,7 @@ "_args": [ [ "uuid@3.3.2", - "/home/massi/dev/actions/setup-taskfile" + "/home/rsora/code/projects/arduino/actions/setup-taskfile" ] ], "_from": "uuid@3.3.2", @@ -27,7 +27,7 @@ ], "_resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", "_spec": "3.3.2", - "_where": "/home/massi/dev/actions/setup-taskfile", + "_where": "/home/rsora/code/projects/arduino/actions/setup-taskfile", "bin": { "uuid": "./bin/uuid" }, diff --git a/setup-taskfile/package-lock.json b/setup-taskfile/package-lock.json index 5940ce1b..02c1d3f8 100644 --- a/setup-taskfile/package-lock.json +++ b/setup-taskfile/package-lock.json @@ -1135,9 +1135,9 @@ } }, "commander": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", - "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true, "optional": true }, @@ -2369,9 +2369,9 @@ "dev": true }, "handlebars": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.2.tgz", - "integrity": "sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==", + "version": "4.4.5", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.4.5.tgz", + "integrity": "sha512-0Ce31oWVB7YidkaTq33ZxEbN+UDxMMgThvCe8ptgQViymL5DPis9uLdTA13MiRPhgvqyxIegugrP97iK3JeBHg==", "dev": true, "requires": { "neo-async": "^2.6.0", @@ -5089,13 +5089,13 @@ "dev": true }, "uglify-js": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz", - "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==", + "version": "3.6.4", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.4.tgz", + "integrity": "sha512-9Yc2i881pF4BPGhjteCXQNaXx1DCwm3dtOyBaG2hitHjLWOczw/ki8vD1bqyT3u6K0Ms/FpCShkmfg+FtlOfYA==", "dev": true, "optional": true, "requires": { - "commander": "~2.20.0", + "commander": "~2.20.3", "source-map": "~0.6.1" } }, diff --git a/setup-taskfile/src/installer.ts b/setup-taskfile/src/installer.ts index 57d9b1dc..2059f56a 100644 --- a/setup-taskfile/src/installer.ts +++ b/setup-taskfile/src/installer.ts @@ -33,9 +33,9 @@ interface ITaskRef { ref: string; } -export async function getTask(version: string) { +export async function getTask(version: string, repoToken: string) { // resolve the version number - const targetVersion = await computeVersion(version); + const targetVersion = await computeVersion(version, repoToken); if (targetVersion) { version = targetVersion; } @@ -98,8 +98,16 @@ function getFileName() { } // Retrieve a list of versions scraping tags from the Github API -async function fetchVersions(): Promise { - let rest: restm.RestClient = new restm.RestClient("setup-taskfile"); +async function fetchVersions(repoToken: string): Promise { + let rest: restm.RestClient; + if (repoToken != "") { + rest = new restm.RestClient("setup-taskfile", "", [], { + headers: { Authorization: "Bearer " + repoToken } + }); + } else { + rest = new restm.RestClient("setup-taskfile"); + } + let tags: ITaskRef[] = (await rest.get( "https://api.github.com/repos/go-task/task/git/refs/tags" @@ -111,7 +119,10 @@ async function fetchVersions(): Promise { } // Compute an actual version starting from the `version` configuration param. -async function computeVersion(version: string): Promise { +async function computeVersion( + version: string, + repoToken: string +): Promise { // strip leading `v` char (will be re-added later) if (version.startsWith("v")) { version = version.slice(1, version.length); @@ -122,7 +133,7 @@ async function computeVersion(version: string): Promise { version = version.slice(0, version.length - 2); } - const allVersions = await fetchVersions(); + const allVersions = await fetchVersions(repoToken); const possibleVersions = allVersions.filter(v => v.startsWith(version)); const versionMap = new Map(); diff --git a/setup-taskfile/src/main.ts b/setup-taskfile/src/main.ts index 1cf77f56..91cdd656 100644 --- a/setup-taskfile/src/main.ts +++ b/setup-taskfile/src/main.ts @@ -4,12 +4,13 @@ import * as installer from "./installer"; async function run() { try { let version = core.getInput("version"); + let repoToken = core.getInput("repo-token"); if (!version) { version = "2.x"; } if (version) { - await installer.getTask(version); + await installer.getTask(version, repoToken); } } catch (error) { core.setFailed(error.message);