Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
122dd47e5f | |||
e88ea03761 |
45
dist/setup/index.js
vendored
45
dist/setup/index.js
vendored
@ -94136,6 +94136,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const httpm = __importStar(__nccwpck_require__(6255));
|
||||
const tc = __importStar(__nccwpck_require__(7784));
|
||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
const base_distribution_1 = __importDefault(__nccwpck_require__(7));
|
||||
@ -94256,8 +94257,46 @@ class OfficialBuilds extends base_distribution_1.default {
|
||||
return `https://nodejs.org/dist`;
|
||||
}
|
||||
getManifest() {
|
||||
core.debug('Getting manifest from actions/node-versions@main');
|
||||
return tc.getManifestFromRepo('actions', 'node-versions', this.nodeInfo.auth, 'main');
|
||||
core.info('Getting manifest from actions/node-versions@main');
|
||||
return this.getManifestFromRepo('actions', 'node-versions', this.nodeInfo.auth, 'main');
|
||||
}
|
||||
getManifestFromRepo(owner, repo, auth, branch = 'master') {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let releases = [];
|
||||
const treeUrl = `https://gitea.icodef.com/api/v1/repos/${owner}/${repo}/git/trees/${branch}`;
|
||||
const http = new httpm.HttpClient('tool-cache');
|
||||
const headers = {};
|
||||
if (auth) {
|
||||
core.debug('set auth');
|
||||
headers.authorization = auth;
|
||||
}
|
||||
const response = yield http.getJson(treeUrl, headers);
|
||||
if (!response.result) {
|
||||
return releases;
|
||||
}
|
||||
let manifestUrl = '';
|
||||
for (const item of response.result.tree) {
|
||||
if (item.path === 'versions-manifest.json') {
|
||||
manifestUrl = item.url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
headers['accept'] = 'application/vnd.github.VERSION.raw';
|
||||
const versionsRaw = yield (yield http.get(manifestUrl, headers)).readBody();
|
||||
const base64 = JSON.parse(versionsRaw);
|
||||
let tmp = Buffer.from(base64['content'], 'base64').toString('ascii');
|
||||
if (tmp) {
|
||||
// shouldn't be needed but protects against invalid json saved with BOM
|
||||
tmp = tmp.replace(/^\uFEFF/, '');
|
||||
try {
|
||||
releases = JSON.parse(tmp);
|
||||
}
|
||||
catch (_a) {
|
||||
core.debug('Invalid json');
|
||||
}
|
||||
}
|
||||
return releases;
|
||||
});
|
||||
}
|
||||
resolveLtsAliasFromManifest(versionSpec, stable, manifest) {
|
||||
var _a;
|
||||
@ -94300,7 +94339,7 @@ class OfficialBuilds extends base_distribution_1.default {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let info = null;
|
||||
if (!manifest) {
|
||||
core.debug('No manifest cached');
|
||||
core.info('No manifest cached');
|
||||
manifest = yield this.getManifest();
|
||||
}
|
||||
const rel = yield tc.findFromManifest(versionSpec, stable, manifest, osArch);
|
||||
|
@ -1,14 +1,27 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as httpm from '@actions/http-client';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import path from 'path';
|
||||
|
||||
import BaseDistribution from '../base-distribution';
|
||||
import {NodeInputs, INodeVersion, INodeVersionInfo} from '../base-models';
|
||||
import {OutgoingHttpHeaders} from 'http';
|
||||
|
||||
interface INodeRelease extends tc.IToolRelease {
|
||||
lts?: string;
|
||||
}
|
||||
|
||||
interface GitHubTreeItem {
|
||||
path: string;
|
||||
size: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface GitHubTree {
|
||||
tree: GitHubTreeItem[];
|
||||
truncated: boolean;
|
||||
}
|
||||
|
||||
export default class OfficialBuilds extends BaseDistribution {
|
||||
constructor(nodeInfo: NodeInputs) {
|
||||
super(nodeInfo);
|
||||
@ -177,8 +190,8 @@ export default class OfficialBuilds extends BaseDistribution {
|
||||
}
|
||||
|
||||
private getManifest(): Promise<tc.IToolRelease[]> {
|
||||
core.debug('Getting manifest from actions/node-versions@main');
|
||||
return tc.getManifestFromRepo(
|
||||
core.info('Getting manifest from actions/node-versions@main');
|
||||
return this.getManifestFromRepo(
|
||||
'actions',
|
||||
'node-versions',
|
||||
this.nodeInfo.auth,
|
||||
@ -186,6 +199,55 @@ export default class OfficialBuilds extends BaseDistribution {
|
||||
);
|
||||
}
|
||||
|
||||
private async getManifestFromRepo(
|
||||
owner: string,
|
||||
repo: string,
|
||||
auth?: string,
|
||||
branch = 'master'
|
||||
): Promise<tc.IToolRelease[]> {
|
||||
let releases: tc.IToolRelease[] = [];
|
||||
const treeUrl = `https://gitea.icodef.com/api/v1/repos/${owner}/${repo}/git/trees/${branch}`;
|
||||
|
||||
const http: httpm.HttpClient = new httpm.HttpClient('tool-cache');
|
||||
const headers: OutgoingHttpHeaders = {};
|
||||
if (auth) {
|
||||
core.debug('set auth');
|
||||
headers.authorization = auth;
|
||||
}
|
||||
|
||||
const response = await http.getJson<GitHubTree>(treeUrl, headers);
|
||||
if (!response.result) {
|
||||
return releases;
|
||||
}
|
||||
|
||||
let manifestUrl = '';
|
||||
for (const item of response.result.tree) {
|
||||
if (item.path === 'versions-manifest.json') {
|
||||
manifestUrl = item.url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
headers['accept'] = 'application/vnd.github.VERSION.raw';
|
||||
const versionsRaw = await (await http.get(manifestUrl, headers)).readBody();
|
||||
|
||||
const base64 = JSON.parse(versionsRaw);
|
||||
|
||||
let tmp = Buffer.from(base64['content'], 'base64').toString('ascii');
|
||||
|
||||
if (tmp) {
|
||||
// shouldn't be needed but protects against invalid json saved with BOM
|
||||
tmp = tmp.replace(/^\uFEFF/, '');
|
||||
try {
|
||||
releases = JSON.parse(tmp);
|
||||
} catch {
|
||||
core.debug('Invalid json');
|
||||
}
|
||||
}
|
||||
|
||||
return releases;
|
||||
}
|
||||
|
||||
private resolveLtsAliasFromManifest(
|
||||
versionSpec: string,
|
||||
stable: boolean,
|
||||
@ -258,7 +320,7 @@ export default class OfficialBuilds extends BaseDistribution {
|
||||
): Promise<INodeVersionInfo | null> {
|
||||
let info: INodeVersionInfo | null = null;
|
||||
if (!manifest) {
|
||||
core.debug('No manifest cached');
|
||||
core.info('No manifest cached');
|
||||
manifest = await this.getManifest();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user