mozilla-get-url
Advanced tools
Comparing version 0.0.1-alpha to 0.0.1
@@ -8,3 +8,3 @@ var fsPath = require('path'), | ||
var CHANNEL_MAPPING = { | ||
var BRANCH_MAPPING = { | ||
aurora: 'nightly/latest-mozilla-aurora', | ||
@@ -17,3 +17,3 @@ 'mozilla-central': 'nightly/latest-mozilla-central', | ||
/** | ||
Channel handler for the firefox "release" channel this is not used | ||
Channel handler for the firefox "release" branch this is not used | ||
for b2g as we don't have a formal versioned release channel there | ||
@@ -25,8 +25,6 @@ | ||
function locate(options, callback) { | ||
options = handleOpts(options); | ||
if (!CHANNEL_MAPPING[options.channel]) { | ||
if (!BRANCH_MAPPING[options.branch]) { | ||
throw new Error( | ||
'must pass valid channel: ' + | ||
Object.keys(CHANNEL_MAPPING).join(', ') | ||
'must pass valid branch: ' + | ||
Object.keys(BRANCH_MAPPING).join(', ') | ||
); | ||
@@ -38,7 +36,7 @@ } | ||
options.product, | ||
CHANNEL_MAPPING[options.channel], | ||
BRANCH_MAPPING[options.branch], | ||
'/' | ||
); | ||
debug('fetching channel', path); | ||
debug('fetching branch', path); | ||
@@ -45,0 +43,0 @@ // verify it actually exists and return path |
var fsPath = require('path'), | ||
urls = require('../urls'), | ||
handleOpts = require('../options'), | ||
debug = require('debug')('mozilla-get-url:channel:release'); | ||
FTPFilter = require('../ftp_filter'); | ||
@@ -19,8 +20,6 @@ | ||
function locate(options, callback) { | ||
options = handleOpts(options); | ||
// special case beta (sorry world!) | ||
if (options.version === 'beta') { | ||
if (options.branch === 'beta') { | ||
// we copy in handleOpts so its safe to do this. | ||
options.version = 'latest-beta'; | ||
options.branch = 'latest-beta'; | ||
} | ||
@@ -32,3 +31,3 @@ | ||
'releases', | ||
options.version, | ||
options.branch, | ||
options.os, | ||
@@ -41,2 +40,3 @@ options.language, | ||
debug('searching for release', path); | ||
ftpFilter.locate(path, filter, function(err, path) { | ||
@@ -43,0 +43,0 @@ ftpFilter.close(); |
var fsPath = require('path'), | ||
urls = require('../urls'), | ||
debug = require('debug')('mozilla-get-url:release:tinderbox'), | ||
handleOpts = require('../options'), | ||
@@ -16,4 +17,2 @@ buildFilter = require('../tinderbox_build_filter'), | ||
function locate(options, callback) { | ||
options = handleOpts(options); | ||
// construct a base url | ||
@@ -42,2 +41,3 @@ var buildsPath = urls.ftpPath( | ||
if (err) return fireCallback(new Error('could not find a recent release')); | ||
debug('locating recent build', path); | ||
ftpHelper.locate(path, timeFilter, locateBuildBinary); | ||
@@ -49,2 +49,3 @@ } | ||
debug('locating binary', path); | ||
ftpHelper.locate(path, prereleaseFilter, function(err, path) { | ||
@@ -56,2 +57,3 @@ if (err) return fireCallback(new Error('could not find a binary')); | ||
debug('locating tinderbox builds', buildsPath); | ||
ftpHelper.locate(buildsPath, buildFilter, locateRecentBuild); | ||
@@ -58,0 +60,0 @@ } |
@@ -1,23 +0,6 @@ | ||
function detectChannel(options) { | ||
options = options || {}; | ||
var debug = require('debug')('mozilla-get-url:locate'), | ||
optionHandler = require('./options'); | ||
// pre-release | ||
if (options.channel) { | ||
// we special case beta... its actually in the release channel but I think | ||
// of it as part of aurora and nightly | ||
if (options.channel === 'beta') { | ||
return require('./channels/release'); | ||
} | ||
return require('./channels/prerelease'); | ||
} | ||
var CHANNELS = ['tinderbox', 'release', 'prerelease']; | ||
// tinderbox | ||
if (options.tinderbox) { | ||
return require('./channels/tinderbox'); | ||
} | ||
// release channel | ||
return require('./channels/release'); | ||
} | ||
/** | ||
@@ -28,6 +11,16 @@ Top level channel manager can detect which | ||
function locate(options, callback) { | ||
var channel = detectChannel(options); | ||
channel(options, callback); | ||
options = optionHandler(options); | ||
var channel = options.channel; | ||
if (CHANNELS.indexOf(channel) === -1) { | ||
throw new Error( | ||
'invalid channel: ' + channel + 'use one of: ' + | ||
CHANNELS.join(', ') | ||
); | ||
} | ||
require('./channels/' + channel)(options, callback); | ||
} | ||
module.exports = locate; |
@@ -13,4 +13,5 @@ /** | ||
product: 'firefox', | ||
version: 'latest', | ||
language: 'en-US' | ||
branch: 'latest', | ||
language: 'en-US', | ||
channel: 'release' | ||
}; | ||
@@ -17,0 +18,0 @@ |
@@ -16,4 +16,4 @@ // all builds which contain a gecko product end in _gecko. | ||
return ( | ||
// must start with tinderbox channel name | ||
name.indexOf(options.tinderbox) === 0 && | ||
// must start with tinderbox branch name | ||
name.indexOf(options.branch) === 0 && | ||
// must end with the gecko string if its b2g | ||
@@ -20,0 +20,0 @@ (options.product !== 'b2g' || SUFFIX.test(name)) && |
{ | ||
"name": "mozilla-get-url", | ||
"version": "0.0.1-alpha", | ||
"version": "0.0.1", | ||
"description": "Utility to get the url of a particular version/release of a mozilla product (like firefox/b2g)", | ||
"main": "index.js", | ||
"main": "lib/locate.js", | ||
"scripts": { | ||
@@ -7,0 +7,0 @@ "test": "make test" |
@@ -5,3 +5,3 @@ # mozilla-get-url | ||
Inspired by (firefox-get)[https://github.com/jsantell/node-firefox-get] which I initially contributed to for the | ||
Inspired by [firefox-get](https://github.com/jsantell/node-firefox-get) which I initially contributed to for the | ||
b2g-support... The primary difference is mozilla-get-url is designed to handle most mozilla products up front and | ||
@@ -14,5 +14,15 @@ uses ftp rather then html scraping. | ||
```js | ||
var locate = require('mozilla-get-url').locate; | ||
var locate = require('mozilla-get-url'); | ||
var options = { | ||
/** | ||
- optional | ||
- default: release | ||
- examples: ['release', 'prerelease', 'tinderbox'] | ||
Channels determine how builds are fetched and map to lib/channels/$CHANNEL. | ||
Not all options are available across all channels | ||
*/ | ||
channel: null, | ||
/* | ||
@@ -23,10 +33,13 @@ - required | ||
os: 'mac', | ||
/* | ||
- optional | ||
- default: 'latest' | ||
- examples: '17.0', '3.6' | ||
- examples (release channel): '17.0', '3.6', 'latest', 'beta' | ||
- examples (prerelease channel): 'aurora', 'nightly', 'mozilla-central' | ||
- examples (tinderbox channel): 'mozilla-central', 'mozilla-inbound' | ||
this only is used with releases (not channel opts, not tinderbox opts) | ||
What type of available branches vary on the channel. | ||
*/ | ||
version: '17.0', | ||
branch: '17.0', | ||
/* | ||
@@ -36,3 +49,4 @@ - optional | ||
this only is used with releases (not channel opts, not tinderbox opts) | ||
Only used in the "release" channel. | ||
List of languages: http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/latest/linux-x86_64/ | ||
*/ | ||
@@ -50,19 +64,2 @@ language: 'en-US', | ||
/** | ||
- optional | ||
- default: none | ||
- examples: ['beta', 'aurora', 'nightly', 'mozilla-central'] | ||
"nightly" (as in built every 24 hours) builds on various channels. | ||
*/ | ||
channel: null, | ||
/** | ||
- optional | ||
- default: none | ||
- examples: ['mozilla-central', 'mozilla-inbound', 'mozilla-inbound-b2g'] | ||
Latest and greatest (current) builds... These are the same builds used in TBPL test runs. | ||
*/ | ||
tinderbox: null | ||
}; | ||
@@ -82,3 +79,3 @@ | ||
# get latest b2g-desktop from mozilla central | ||
mozilla-get-url --os mac --tinderbox mozilla-central --product b2g | ||
mozilla-get-url --channel tinderbox --os mac --branch mozilla-central --product b2g | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
14105
18
323
76
1