-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: node service has bad colors #4809
- Loading branch information
Showing
9 changed files
with
231 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict' | ||
|
||
const NodeVersionBase = require('./node-base') | ||
const { versionColorForRangeCurrent } = require('./node-version-color') | ||
|
||
module.exports = class NodeCurrentVersion extends NodeVersionBase { | ||
static get path() { | ||
return 'v' | ||
} | ||
|
||
static get type() { | ||
return 'current' | ||
} | ||
|
||
static get colorResolver() { | ||
return versionColorForRangeCurrent | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict' | ||
|
||
const { test, given } = require('sazerac') | ||
const NodeVersion = require('./node-current.service') | ||
|
||
describe('renderStaticPreview', function() { | ||
it('should have parity with render()', async function() { | ||
const nodeVersionRange = '>= 6.0.0' | ||
|
||
const expectedNoTag = await NodeVersion.renderStaticPreview({ | ||
nodeVersionRange, | ||
}) | ||
const expectedLatestTag = await NodeVersion.renderStaticPreview({ | ||
nodeVersionRange, | ||
tag: 'latest', | ||
}) | ||
|
||
test(NodeVersion.renderStaticPreview, () => { | ||
given({ nodeVersionRange }).expect(expectedNoTag) | ||
given({ nodeVersionRange, tag: 'latest' }).expect(expectedLatestTag) | ||
}) | ||
}) | ||
}) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict' | ||
|
||
const NodeVersionBase = require('./node-base') | ||
const { versionColorForRangeLts } = require('./node-version-color') | ||
|
||
module.exports = class NodeLtsVersion extends NodeVersionBase { | ||
static get path() { | ||
return 'v-lts' | ||
} | ||
|
||
static get type() { | ||
return 'lts' | ||
} | ||
|
||
static get colorResolver() { | ||
return versionColorForRangeLts | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict' | ||
|
||
const { expect } = require('chai') | ||
const { Range } = require('semver') | ||
const t = (module.exports = require('../tester').createServiceTester()) | ||
|
||
function expectSemverRange(message) { | ||
expect(() => new Range(message)).not.to.throw() | ||
} | ||
|
||
t.create('gets the node version of passport') | ||
.get('/passport.json') | ||
.expectBadge({ label: 'node' }) | ||
.afterJSON(json => { | ||
expectSemverRange(json.message) | ||
}) | ||
|
||
t.create('gets the node version of @stdlib/stdlib') | ||
.get('/@stdlib/stdlib.json') | ||
.expectBadge({ label: 'node' }) | ||
.afterJSON(json => { | ||
expectSemverRange(json.message) | ||
}) | ||
|
||
t.create("gets the tagged release's node version version of ionic") | ||
.get('/ionic/next.json') | ||
.expectBadge({ label: 'node@next' }) | ||
.afterJSON(json => { | ||
expectSemverRange(json.message) | ||
}) | ||
|
||
t.create('gets the node version of passport from a custom registry') | ||
.get('/passport.json?registry_uri=https://registry.npmjs.com') | ||
.expectBadge({ label: 'node' }) | ||
.afterJSON(json => { | ||
expectSemverRange(json.message) | ||
}) | ||
|
||
t.create("gets the tagged release's node version of @cycle/core") | ||
.get('/@cycle/core/canary.json') | ||
.expectBadge({ label: 'node@canary' }) | ||
.afterJSON(json => { | ||
expectSemverRange(json.message) | ||
}) | ||
|
||
t.create('invalid package name') | ||
.get('/frodo-is-not-a-package.json') | ||
.expectBadge({ label: 'node', message: 'package not found' }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
'use strict' | ||
|
||
const { expect } = require('chai') | ||
const { | ||
getStableVersions, | ||
getCurrentVersion, | ||
versionColorForRangeLts, | ||
versionColorForRangeCurrent, | ||
} = require('./node-version-color') | ||
|
||
describe('node version color', function() { | ||
describe(`stable`, function() { | ||
it('should only return lts versions', async function() { | ||
this.timeout(4000) | ||
const versions = await getStableVersions() | ||
versions.sort() | ||
const major = parseInt( | ||
versions[versions.length - 1].match(/(\d+)/)[0], | ||
10 | ||
) | ||
expect(major % 2).to.eql(0) | ||
}) | ||
it('should print green on lts versions', async function() { | ||
const versions = await getStableVersions() | ||
const range = versions.reduce( | ||
(range, version) => `${range} || ${version}` | ||
) | ||
const color = await versionColorForRangeLts(range) | ||
expect(color).to.eql('brightgreen') | ||
}) | ||
it('should print yellow on lts bigger than range', async function() { | ||
const versions = await getStableVersions() | ||
versions.sort() | ||
const major = parseInt(versions[0].match(/(\d+)/)[0], 10) - 1 | ||
const range = `^${major}` | ||
const color = await versionColorForRangeLts(range) | ||
expect(color).to.eql('yellow') | ||
}) | ||
}) | ||
describe(`latest`, function() { | ||
it('should print green on latest version', async function() { | ||
const version = await getCurrentVersion() | ||
const color = await versionColorForRangeCurrent(version) | ||
expect(color).to.eql('brightgreen') | ||
}) | ||
it('should print yellow on latest bigger than range', async function() { | ||
const version = await getCurrentVersion() | ||
const major = parseInt(version.match(/(\d+)/)[0], 10) - 1 | ||
const range = `^${major}` | ||
const color = await versionColorForRangeCurrent(range) | ||
expect(color).to.eql('yellow') | ||
}) | ||
}) | ||
}) |