@semantic-release/last-release-npm
Advanced tools
Comparing version 1.2.1 to 2.0.0
'use strict'; | ||
var SemanticReleaseError = require('@semantic-release/error'); | ||
var _error = require('@semantic-release/error'); | ||
var npmlog = require('npmlog'); | ||
var RegClient = require('npm-registry-client'); | ||
var _error2 = _interopRequireDefault(_error); | ||
var _npmRegistryClient = require('npm-registry-client'); | ||
var _npmRegistryClient2 = _interopRequireDefault(_npmRegistryClient); | ||
var _npmlog = require('npmlog'); | ||
var _npmlog2 = _interopRequireDefault(_npmlog); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
module.exports = function (pluginConfig, _ref, cb) { | ||
var pkg = _ref.pkg; | ||
var npm = _ref.npm; | ||
var plugins = _ref.plugins; | ||
var options = _ref.options; | ||
var pkg = _ref.pkg, | ||
npm = _ref.npm, | ||
plugins = _ref.plugins, | ||
options = _ref.options; | ||
npmlog.level = npm.loglevel || 'warn'; | ||
var clientConfig = { log: npmlog }; | ||
_npmlog2.default.level = npm.loglevel || 'warn'; | ||
var clientConfig = { log: _npmlog2.default }; | ||
// disable retries for tests | ||
if (pluginConfig && pluginConfig.retry) clientConfig.retry = pluginConfig.retry; | ||
var client = new RegClient(clientConfig); | ||
var client = new _npmRegistryClient2.default(clientConfig); | ||
@@ -23,3 +32,6 @@ client.get('' + npm.registry + pkg.name.replace('/', '%2F'), { | ||
}, function (err, data) { | ||
if (err && (err.statusCode === 404 || /not found/i.test(err.message))) { | ||
var isNotFound = err && (err.statusCode === 404 || /not found/i.test(err.message)); | ||
var isCompletelyUnpublished = data && !data['dist-tags']; | ||
if (isNotFound || isCompletelyUnpublished) { | ||
return cb(null, {}); | ||
@@ -30,26 +42,22 @@ } | ||
var version = data['dist-tags'][npm.tag]; | ||
var distTags = data['dist-tags']; | ||
var version = distTags[npm.tag]; | ||
if (!version && options && options.fallbackTags && options.fallbackTags[npm.tag] && data['dist-tags'][options.fallbackTags[npm.tag]]) { | ||
version = data['dist-tags'][options.fallbackTags[npm.tag]]; | ||
if (!version && options && options.fallbackTags && options.fallbackTags[npm.tag] && distTags[options.fallbackTags[npm.tag]]) { | ||
version = distTags[options.fallbackTags[npm.tag]]; | ||
} | ||
if (!version) { | ||
return cb(new SemanticReleaseError('There is no release with the dist-tag "' + npm.tag + '" yet.\nTag a version manually or define "fallbackTags".', 'ENODISTTAG')); | ||
return cb(new _error2.default('There is no release with the dist-tag "' + npm.tag + '" yet.\nTag a version manually or define "fallbackTags".', 'ENODISTTAG')); | ||
} | ||
cb(null, Object.defineProperties({ | ||
cb(null, { | ||
version: version, | ||
gitHead: data.versions[version].gitHead | ||
}, { | ||
tag: { | ||
get: function get() { | ||
npmlog.warn('deprecated', 'tag will be removed with the next major release'); | ||
return npm.tag; | ||
}, | ||
configurable: true, | ||
enumerable: true | ||
gitHead: data.versions[version].gitHead, | ||
get tag() { | ||
_npmlog2.default.warn('deprecated', 'tag will be removed with the next major release'); | ||
return npm.tag; | ||
} | ||
})); | ||
}); | ||
}); | ||
}; |
{ | ||
"name": "@semantic-release/last-release-npm", | ||
"description": "determine the version of the last release via the npm registry", | ||
"version": "2.0.0", | ||
"author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)", | ||
"babel": { | ||
"presets": [ | ||
"es2015" | ||
] | ||
}, | ||
"bugs": { | ||
@@ -19,16 +25,20 @@ "url": "https://github.com/semantic-release/last-release-npm/issues" | ||
"npm-registry-client": "^7.0.1", | ||
"npmlog": "^1.2.1" | ||
"npmlog": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"babel": "^5.8.21", | ||
"babel-cli": "^6.6.5", | ||
"babel-preset-es2015": "^6.6.0", | ||
"coveralls": "^2.11.2", | ||
"lodash": "^3.10.1", | ||
"lodash": "^4.2.1", | ||
"mkdirp": "^0.5.1", | ||
"nock": "^2.10.0", | ||
"nyc": "^3.0.0", | ||
"nock": "^9.0.0", | ||
"nyc": "^10.0.0", | ||
"rimraf": "^2.4.2", | ||
"semantic-release": "^4.0.3", | ||
"standard": "^5.1.0", | ||
"tap": "^1.3.2" | ||
"semantic-release": "^6.3.2", | ||
"standard": "^8.5.0", | ||
"tap": "^8.0.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "standard" | ||
}, | ||
"homepage": "https://github.com/semantic-release/last-release-npm#readme", | ||
@@ -64,4 +74,3 @@ "keywords": [ | ||
"test:suite": "nyc tap --no-cov .test/specs/*.js" | ||
}, | ||
"version": "1.2.1" | ||
} | ||
} |
@@ -18,2 +18,12 @@ const nock = require('nock') | ||
const completelyUnpublishedModule = { | ||
name: 'i-am-completely-unpublished', | ||
time: { | ||
'2.0.0': '2016-12-01T17:50:30.699Z', | ||
unpublished: { | ||
time: '2016-12-01T17:53:45.940Z' | ||
} | ||
} | ||
} | ||
module.exports = nock('http://registry.npmjs.org') | ||
@@ -29,2 +39,4 @@ .get('/available') | ||
.reply(200, availableModule) | ||
.get('/completely-unpublished') | ||
.reply(200, completelyUnpublishedModule) | ||
.get('/unavailable') | ||
@@ -31,0 +43,0 @@ .reply(404, {}) |
@@ -14,3 +14,3 @@ const { defaults } = require('lodash') | ||
test('last release from registry', (t) => { | ||
t.plan(6) | ||
t.plan(7) | ||
@@ -89,2 +89,13 @@ t.test('get release from package name', (tt) => { | ||
t.test('get nothing from completely unpublished package name', (tt) => { | ||
lastRelease({}, { | ||
pkg: {name: 'completely-unpublished'}, | ||
npm | ||
}, (err, release) => { | ||
tt.error(err) | ||
tt.is(release.version, undefined, 'no version') | ||
tt.end() | ||
}) | ||
}) | ||
t.test('get nothing from not yet published package name', (tt) => { | ||
@@ -91,0 +102,0 @@ tt.plan(3) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9744
204
11
1
- Removedansi@0.3.1(transitive)
- Removedare-we-there-yet@1.0.6(transitive)
- Removedgauge@1.2.7(transitive)
- Removedlodash.pad@4.5.1(transitive)
- Removedlodash.padend@4.6.1(transitive)
- Removedlodash.padstart@4.6.1(transitive)
- Removednpmlog@1.2.1(transitive)
Updatednpmlog@^4.0.0