Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

use yarn, remove min/max env vars #63

Merged
merged 1 commit into from
Jan 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@ var MongoDBSource = require('./sources/mongodb');

module.exports = function App(resolvers) {
var app = express();
var env = process.env;
var resolvers = resolvers || {
node: new Resolver(new NodeSource(), env.MIN_STABLE_NODE, env.MAX_STABLE_NODE),
iojs: new Resolver(new IoJsSource(), env.MIN_STABLE_IOJS, env.MAX_STABLE_IOJS),
npm: new Resolver(new NpmSource(), env.MIN_STABLE_NPM, env.MAX_STABLE_NPM),
nginx: new Resolver(new NginxSource(), env.MIN_STABLE_NGINX, env.MAX_STABLE_NGINX),
mongodb: new Resolver(new MongoDBSource(), env.MIN_STABLE_MONGODB, env.MAX_STABLE_MONGODB),
yarn: new Resolver(new YarnSource(), env.MIN_STABLE_YARN, env.MAX_STABLE_YARN)
node: new Resolver(new NodeSource()),
iojs: new Resolver(new IoJsSource()),
npm: new Resolver(new NpmSource()),
nginx: new Resolver(new NginxSource()),
mongodb: new Resolver(new MongoDBSource()),
yarn: new Resolver(new YarnSource())
};

app.resolvers = resolvers;

if (env.NODE_ENV !== 'test') {
if (process.env.NODE_ENV !== 'test') {
app.use(logfmt.requestLogger());
}

Expand Down
13 changes: 2 additions & 11 deletions lib/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ var log = require('./logger');

module.exports = Resolver;

function Resolver(source, minStable, maxStable) {
function Resolver(source) {
this._poll = this._poll.bind(this);
this.frequency = 0;

this.inStableRange = this.inStableRange.bind(this);
this.source = source;
this.minStable = minStable;
this.maxStable = maxStable;
}

Resolver.prototype.update = function(done) {
Expand Down Expand Up @@ -54,7 +51,7 @@ Resolver.prototype.getAllVersions = function() {
};

Resolver.prototype.getStableVersions = function() {
return this.source.stable.filter(this.inStableRange);
return this.source.stable;
};

Resolver.prototype.getUpdatedTime = function() {
Expand All @@ -68,9 +65,3 @@ Resolver.prototype.satisfy = function(range) {
semver.maxSatisfying(this.getAllVersions(), range) ||
this.getLatestStable();
};

Resolver.prototype.inStableRange = function(version) {
if (this.maxStable && semver.gt(version, this.maxStable)) return false;
if (this.minStable && semver.lt(version, this.minStable)) return false;
return true;
}
8 changes: 4 additions & 4 deletions lib/sources/yarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ var NpmStats = require('npm-stats');
var TIMEOUT = 5000;
var NOOP = function() {};

module.exports = NpmSource;
module.exports = YarnSource;

function NpmSource(options) {
function YarnSource(options) {
_.extend(this, {
name: 'yarn',
registry: 'https://skimdb.npmjs.com/',
Expand All @@ -17,7 +17,7 @@ function NpmSource(options) {
}, options);
}

NpmSource.prototype.update = function(done) {
YarnSource.prototype.update = function(done) {
done = done || NOOP;

NpmStats(this.registry)
Expand All @@ -33,7 +33,7 @@ NpmSource.prototype.update = function(done) {
}
};

NpmSource.prototype._parse = function(info) {
YarnSource.prototype._parse = function(info) {
var versions = _.unique(Object.keys(info.versions));
var tags = _.unique(Object.keys(info['dist-tags'])); // omitting as this breaks semver, needs a 'tags' concept
var latestStable = info['dist-tags'].latest;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"superagent": "1.3.0"
},
"engines": {
"node": "5.1.1"
"node": "6.9.4"
},
"repository": {
"type": "git",
Expand Down
22 changes: 0 additions & 22 deletions test/resolver.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,6 @@ describe "Resolver", ->
assert.equal this.r.satisfy(""), this.r.getLatestStable()
assert.equal this.r.satisfy("boogers"), this.r.getLatestStable()

describe "with environment override", ->

it "obeys maximum stable limit", ->
r = new Resolver(new Source(), null, '0.10.15')
assert.equal r.getLatestStable(), '0.10.15'

it "obeys minimum stable limit", ->
r = new Resolver(new Source(), '0.2.6')
assert.equal r.getStableVersions()[0], '0.2.6'

it "satisfies stable-seeking ranges", ->
r = new Resolver(new Source(), null, '0.10.3')
assert.equal r.satisfy('>0.8'), '0.10.3'

it "still resolves unstable ranges", ->
r = new Resolver(new Source(), null, '0.8.20')
assert.equal semver.parse(r.satisfy('0.11.x')).minor, 11

it "still resolves versions at a higher patchlevel than the override", ->
r = new Resolver(new Source(), null, '0.10.18')
assert.equal r.satisfy('0.10.19'), '0.10.19'

describe "start(200)", ->

it "polls about 5 times in 1000ms", (done) ->
Expand Down
Loading