Skip to content

Commit

Permalink
chore: update dep & lib compile w/ ts4
Browse files Browse the repository at this point in the history
  • Loading branch information
rumblefrog committed Oct 14, 2020
1 parent 5eb379e commit 52bce41
Show file tree
Hide file tree
Showing 29 changed files with 503 additions and 346 deletions.
78 changes: 45 additions & 33 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const installer_1 = require("./installer");
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const range = core.getInput('version', { required: true });
let version = yield installer_1.installCompiler(range);
core.setOutput('version', version);
}
catch (error) {
core.setFailed(error.message);
}
});
}
run();
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const installer_1 = require("./installer");
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const range = core.getInput('version', { required: true });
let version = yield installer_1.installCompiler(range);
core.setOutput('version', version);
}
catch (error) {
core.setFailed(error.message);
}
});
}
run();
97 changes: 49 additions & 48 deletions lib/installer.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const tool_cache_1 = require("@actions/tool-cache");
const core_1 = require("@actions/core");
const semver_1 = require("semver");
const path_1 = require("path");
const scraper_1 = require("./utils/scraper");
let versions;
function installCompiler(range) {
return __awaiter(this, void 0, void 0, function* () {
versions = yield scraper_1.getVersions();
let version = semver_1.maxSatisfying(Object.keys(versions), range);
if (version === null) {
throw new Error(`Unable to find a version matching ${range}`);
}
let cache = tool_cache_1.find('sourcepawn', version);
if (!cache) {
cache = yield downloadCompiler(version);
}
core_1.addPath(cache);
core_1.exportVariable('includePath', path_1.join(cache, 'include'));
return version;
});
}
exports.installCompiler = installCompiler;
function downloadCompiler(version) {
return __awaiter(this, void 0, void 0, function* () {
const spPath = yield tool_cache_1.downloadTool(versions[version].toEndpoint());
let extracted;
if (process.platform === 'linux') {
extracted = yield tool_cache_1.extractTar(spPath);
}
else {
extracted = yield tool_cache_1.extractZip(spPath);
}
let spRoot = path_1.join(extracted, 'addons', 'sourcemod', 'scripting');
return yield tool_cache_1.cacheDir(spRoot, 'sourcepawn', version);
});
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.installCompiler = void 0;
const tool_cache_1 = require("@actions/tool-cache");
const core_1 = require("@actions/core");
const semver_1 = require("semver");
const path_1 = require("path");
const scraper_1 = require("./utils/scraper");
let versions;
function installCompiler(range) {
return __awaiter(this, void 0, void 0, function* () {
versions = yield scraper_1.getVersions();
let version = semver_1.maxSatisfying(Object.keys(versions), range);
if (version === null) {
throw new Error(`Unable to find a version matching ${range}`);
}
let cache = tool_cache_1.find('sourcepawn', version);
if (!cache) {
cache = yield downloadCompiler(version);
}
core_1.addPath(cache);
core_1.exportVariable('includePath', path_1.join(cache, 'include'));
return version;
});
}
exports.installCompiler = installCompiler;
function downloadCompiler(version) {
return __awaiter(this, void 0, void 0, function* () {
const spPath = yield tool_cache_1.downloadTool(versions[version].toEndpoint());
let extracted;
if (process.platform === 'linux') {
extracted = yield tool_cache_1.extractTar(spPath);
}
else {
extracted = yield tool_cache_1.extractZip(spPath);
}
let spRoot = path_1.join(extracted, 'addons', 'sourcemod', 'scripting');
return yield tool_cache_1.cacheDir(spRoot, 'sourcepawn', version);
});
}
79 changes: 40 additions & 39 deletions lib/structures/versioning.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("../utils/constants");
var Platform;
(function (Platform) {
Platform["Linux"] = "linux";
Platform["Windows"] = "windows";
Platform["Mac"] = "mac";
Platform["Unknown"] = "unknown";
})(Platform = exports.Platform || (exports.Platform = {}));
function parsePlatform(plat) {
switch (plat) {
case 'linux':
return Platform.Linux;
case 'windows':
return Platform.Windows;
case 'mac':
return Platform.Mac;
default:
return Platform.Unknown;
}
}
exports.parsePlatform = parsePlatform;
class Version {
constructor(major, minor, build, platform, archiveExt) {
this.major = major;
this.minor = minor;
this.build = build;
this.platform = platform;
this.archiveExt = archiveExt;
}
toString() {
return `${this.major}.${this.minor}.${this.build}`;
}
toEndpoint() {
return `${constants_1.ENDPOINT}/${this.major}.${this.minor}/sourcemod-${this.major}.${this.minor}.0-git${this.build}-${this.platform}.${this.archiveExt}`;
}
}
exports.Version = Version;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Version = exports.parsePlatform = exports.Platform = void 0;
const constants_1 = require("../utils/constants");
var Platform;
(function (Platform) {
Platform["Linux"] = "linux";
Platform["Windows"] = "windows";
Platform["Mac"] = "mac";
Platform["Unknown"] = "unknown";
})(Platform = exports.Platform || (exports.Platform = {}));
function parsePlatform(plat) {
switch (plat) {
case 'linux':
return Platform.Linux;
case 'windows':
return Platform.Windows;
case 'mac':
return Platform.Mac;
default:
return Platform.Unknown;
}
}
exports.parsePlatform = parsePlatform;
class Version {
constructor(major, minor, build, platform, archiveExt) {
this.major = major;
this.minor = minor;
this.build = build;
this.platform = platform;
this.archiveExt = archiveExt;
}
toString() {
return `${this.major}.${this.minor}.${this.build}`;
}
toEndpoint() {
return `${constants_1.ENDPOINT}/${this.major}.${this.minor}/sourcemod-${this.major}.${this.minor}.0-git${this.build}-${this.platform}.${this.archiveExt}`;
}
}
exports.Version = Version;
11 changes: 6 additions & 5 deletions lib/utils/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ENDPOINT = 'https://www.sourcemod.net/smdrop';
exports.MM_REGEX = /href="(.*?)"/g;
exports.BUILD_REGEX = /href="sourcemod-[0-9]+.[0-9]+.[0-9]+-git([0-9]+)-(linux|windows|mac).(.*?)"/g;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BUILD_REGEX = exports.MM_REGEX = exports.ENDPOINT = void 0;
exports.ENDPOINT = 'https://www.sourcemod.net/smdrop';
exports.MM_REGEX = /href="(.*?)"/g;
exports.BUILD_REGEX = /href="sourcemod-[0-9]+.[0-9]+.[0-9]+-git([0-9]+)-(linux|windows|mac).(.*?)"/g;
Loading

0 comments on commit 52bce41

Please sign in to comment.