-
Notifications
You must be signed in to change notification settings - Fork 122
Initial release #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
35d7d79
to
cd4aa4f
Compare
48609fc
to
fc68d6e
Compare
306fb03
to
0259f0a
Compare
Codecov & Greenkeeper enabled, tokens set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks all great, just a few comments and a question 👍
lib/get-client-config.js
Outdated
@@ -0,0 +1,26 @@ | |||
module.exports = config => { | |||
// Form https://github.com/npm/npm/blob/master/lib/cache/caching-client.js#L194 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add permanent link? https://github.com/npm/npm/blob/d081cc6c8d73f2aa698aab36605377c95e916224/lib/cache/caching-client.js#L194
When you press y
on any file page, it will redirect to permalink
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I didn't know that :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/get-client-config.js
Outdated
userAgent: config.get('user-agent'), | ||
defaultTag: config.get('tag'), | ||
couchToken: config.get('_token'), | ||
maxSockets: parseInt(config.get('maxsockets')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add radix argument to all parseInt
statements. I’m surprised the linking doesn’t catch that. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt#Octal_interpretations_with_no_radix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.
There is an eslint rule for that: https://eslint.org/docs/rules/radix
But it's not enabled in standard
: https://github.com/standard/eslint-config-standard/blob/master/eslintrc.json
This is one of the reason I prefer other solution to standard
as they enable mostly style rules and disable a lot of really useful rules to detect these type of bug...Anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/get-last-release.js
Outdated
@@ -0,0 +1,40 @@ | |||
const {promisify} = require('util'); | |||
const {resolve} = require('url'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe change this to {resolve: urlResolve}
. Line 16 is rather confusing with the promisify
and then the resolve
call, I was looking for a Promise resolve function :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/get-last-release.js
Outdated
const registry = await getRegistry(publishConfig, name); | ||
|
||
try { | ||
const data = await promisify(client.get.bind(client))(resolve(registry, name.replace('/', '%2F')), { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is quite a lot at once to read easily, can you maybe split it up into multiple lines? At least move the value that resolve(...)
returns into an own variable for better readability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/get-last-release.js
Outdated
const data = await promisify(client.get.bind(client))(resolve(registry, name.replace('/', '%2F')), { | ||
auth: NPM_TOKEN ? {token: NPM_TOKEN} : {username: NPM_USERNAME, password: NPM_PASSWORD, email: NPM_EMAIL}, | ||
}); | ||
if (data && !data['dist-tags']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you check for data
her? Should this maybe be !data || !data['dist-tags']
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something that come from the old plugin. It's to handle a weird case that happen on npm when the call return data
but no dist-tags
.
Normally when a package doesn't exist it returns a 404.
If I remember well this situation happens when you publish a version with a scope and you unpublish it, the registry return {}
instead of a 404.
lib/set-npmrc-auth.js
Outdated
logger.log('Verify authentication for registry %s', registry); | ||
const {NPM_TOKEN, NPM_USERNAME, NPM_PASSWORD, NPM_EMAIL} = process.env; | ||
|
||
if (!getAuthToken(registry)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe return early instead of wrapping the rest of the code into the if statemen?
if (getAuthToken(registry)) {
return
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/set-npmrc-auth.js
Outdated
if (!getAuthToken(registry)) { | ||
if (NPM_USERNAME && NPM_PASSWORD && NPM_EMAIL) { | ||
// Using the old auth token format is not considered part of the public API | ||
// This might go away anytime (i.e. once we have a better testing strategy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we drop support for NPM_USERNAME
& NPM_PASSWORD
and only support NPM_TOKEN
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No unfortunately....It's because https://github.com/npm/npm-registry-couchapp doesn't accept login with a token. It accept only the legacy auth (username:password in base 64 + email).
I couldn't find a way to make https://github.com/npm/npm-registry-couchapp authentication works like https://www.npmjs.com/ with a token.
1bd51c6
to
7d5ab00
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9b318c8
to
e65e82b
Compare
e65e82b
to
577a189
Compare
577a189
to
d9f3feb
Compare
Implementation as discussed in semantic-release/semantic-release#484.
@gr2m can you enable Codecov and Greenkeeper for the repo and add
GH_TOKEN
andNPM_TOKEN
to Travis ? ThanksFix semantic-release/semantic-release#126