Skip to content

Commit

Permalink
Remove build key requirement and update platform download URL
Browse files Browse the repository at this point in the history
Tabris build service is shutting down, and therefor a build key can no
longer be aquired by the user. Platforms can now be downloaded without
any authentication.
  • Loading branch information
tbuschto committed Jun 29, 2023
1 parent 4489b7d commit a7728c4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 306 deletions.
68 changes: 0 additions & 68 deletions src/services/BuildKeyProvider.js

This file was deleted.

14 changes: 6 additions & 8 deletions src/services/PlatformProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ const progress = require('cli-progress');
const log = require('../helpers/log');
const zip = require('../helpers/zip');
const {FileDownloader} = require('../helpers/download');
const BuildKeyProvider = require('./BuildKeyProvider');
const PlatformsCache = require('./PlatformsCache');
const proc = require('../helpers/proc');

const PATH = '/api/v1/downloads/cli';
const PATH = '/downloads';
const HOST = process.env.TABRIS_HOST || 'tabrisjs.com';

module.exports = class PlatformProvider {

constructor(cliDataDir) {
this._platformsDir = join(cliDataDir, 'platforms');
this._buildKeyProvider = new BuildKeyProvider(cliDataDir);
this._platformsCache = new PlatformsCache(cliDataDir);
}

Expand Down Expand Up @@ -46,21 +44,21 @@ module.exports = class PlatformProvider {
const extractedZipPath = join(this._platformsDir, `.extracted-${platform.name}-${platform.version}`);
const platformDir = join(extractedZipPath, `tabris-${platform.name}`);
await fs.mkdirs(this._platformsDir);
const buildKey = await this._buildKeyProvider.getBuildKey();
await this._downloadPlatformZip(zipPath, buildKey, platform);
await this._downloadPlatformZip(zipPath, platform);
await this._unzipPlatform(zipPath, extractedZipPath);
this._platformsCache.set(platform, platformDir);
await fs.remove(extractedZipPath);
await fs.remove(zipPath);
return this._platformsCache.get(platform);
}

async _downloadPlatformZip(platformZipPath, buildKey, platform) {
async _downloadPlatformZip(platformZipPath, platform) {
log.command(`Downloading ${platform.name} platform version ${platform.version}...`);
console.info(`${PATH}/${platform.version}/platforms/tabris-${platform.name}.zip`);
const options = {
host: HOST,
path: `${PATH}/${platform.version}/${platform.name}`,
headers: {'X-Tabris-Build-Key': buildKey}
path: `${PATH}/${platform.version}/platforms/tabris-${platform.name}.zip`,
headers: {}
};
const progressBar = new progress.Bar({
clearOnComplete: true,
Expand Down
198 changes: 0 additions & 198 deletions test/BuildKeyProvider.test.js

This file was deleted.

34 changes: 2 additions & 32 deletions test/PlatformProvider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ describe('PlatformProvider', function() {
stub(log, 'command');
stub(console, 'error');
stub(https, 'get');
process.env.TABRIS_BUILD_KEY = 'key';
cliDataDir = temp.mkdirSync('cliDataDir');
platformPath = join(cliDataDir, 'platforms', name, version);
provider = new PlatformProvider(cliDataDir);
});

afterEach(() => {
delete process.env.TABRIS_BUILD_KEY;
restore();
});

Expand Down Expand Up @@ -119,34 +117,6 @@ describe('PlatformProvider', function() {

});

describe('when platform download rejects build key', function() {

beforeEach(function() {
fakeResponse(401);
});

it('prompts build key again', async function() {
stub(provider._buildKeyProvider, 'promptBuildKey').callsFake(() => {
fakeResponse(200);
return Promise.resolve('key');
});
await provider.getPlatform({name, version});
expect(readFileSync(join(platformPath, 'foo.file'), 'utf8')).to.equal('hello');
});

it('prompts build key again more than once', async function() {
stub(provider._buildKeyProvider, 'promptBuildKey')
.onCall(0).returns(Promise.resolve('key'))
.onCall(1).callsFake(() => {
fakeResponse(200);
return Promise.resolve('key');
});
await provider.getPlatform({name, version});
expect(readFileSync(join(platformPath, 'foo.file'), 'utf8')).to.equal('hello');
});

});

});

});
Expand All @@ -155,8 +125,8 @@ function fakeResponse(statusCode) {
https.get
.withArgs({
host: 'tabrisjs.com',
path: `/api/v1/downloads/cli/${version}/${name}`,
headers: {'X-Tabris-Build-Key': 'key'}
path: `/downloads/${version}/platforms/tabris-${name}.zip`,
headers: {}
}, match.func)
.callsArgWith(1, statusCode === 200 ? createPlatformResponseStream(statusCode) : {statusCode, headers: {}})
.returns({get: https.get, on: stub().returnsThis()});
Expand Down

0 comments on commit a7728c4

Please sign in to comment.