123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- const semver = require("semver");
- const config_source_1 = require("./config_source");
- class GeckoDriverGithub extends config_source_1.GithubApiConfigSource {
- constructor() {
- super('gecko', 'https://api.github.com/repos/mozilla/geckodriver/releases');
- }
- getUrl(version) {
- if (version === 'latest') {
- return this.getLatestGeckoDriverVersion();
- }
- else {
- return this.getSpecificGeckoDrierVersion(version);
- }
- }
- getVersionList() {
- return this.getJson().then(json => {
- let versions = [];
- for (let i = 0; i < json.length; i++) {
- let item = json[i];
- versions.push(item.tag_name);
- }
- return versions;
- });
- }
- getVersionsLookup() {
- return this.getJson().then(json => {
- let versionsLookup = [];
- for (let i = 0; i < json.length; i++) {
- let item = json[i];
- let index = i.toString();
- versionsLookup.push({ version: item.tag_name, index: index });
- }
- return versionsLookup;
- });
- }
- getLatestGeckoDriverVersion() {
- return this.getJson().then(json => {
- return this.getVersionsLookup().then(versionsLookup => {
- let latest = '';
- for (let item of versionsLookup) {
- let version = item.version.replace('v', '');
- let assetsArray = json[item.index].assets;
- // check to make sure the version found has the OS
- for (let asset of assetsArray) {
- if (asset.name.includes(this.oshelper())) {
- if (latest === '') {
- latest = version;
- }
- else if (semver.lt(latest, version)) {
- latest = version;
- }
- }
- }
- }
- return this.getSpecificGeckoDrierVersion('v' + latest);
- });
- });
- }
- getSpecificGeckoDrierVersion(inputVersion) {
- return this.getJson().then(json => {
- return this.getVersionsLookup().then(versionsLookup => {
- for (let item of versionsLookup) {
- // Get the asset from the matching version.
- if (item.version === inputVersion) {
- let assetsArray = json[item.index].assets;
- for (let asset of assetsArray) {
- if (asset.name.includes(this.oshelper())) {
- return { url: asset.browser_download_url, version: inputVersion };
- }
- }
- }
- }
- return null;
- });
- });
- }
- oshelper() {
- // Get the os type name.
- if (this.ostype === 'Darwin') {
- return 'macos';
- }
- else if (this.ostype === 'Windows_NT') {
- return this.osarch === 'x64' ? 'win64' : 'win32';
- }
- else {
- return this.osarch === 'x64' ? 'linux64' : 'linux32';
- }
- }
- }
- exports.GeckoDriverGithub = GeckoDriverGithub;
- //# sourceMappingURL=gecko_driver_github.js.map
|