Skip to content

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

Merged
merged 1 commit into from
Nov 20, 2017
Merged

Initial release #1

merged 1 commit into from
Nov 20, 2017

Conversation

pvdlg
Copy link
Member

@pvdlg pvdlg commented Nov 6, 2017

Implementation as discussed in semantic-release/semantic-release#484.

@gr2m can you enable Codecov and Greenkeeper for the repo and add GH_TOKEN and NPM_TOKEN to Travis ? Thanks

Fix semantic-release/semantic-release#126

@pvdlg pvdlg requested a review from gr2m November 6, 2017 06:48
@pvdlg pvdlg force-pushed the initial-release branch 7 times, most recently from 35d7d79 to cd4aa4f Compare November 6, 2017 07:27
@pvdlg pvdlg changed the title Initial release WIP: Initial release Nov 6, 2017
@pvdlg pvdlg force-pushed the initial-release branch 13 times, most recently from 48609fc to fc68d6e Compare November 6, 2017 16:57
@pvdlg pvdlg changed the title WIP: Initial release Initial release Nov 6, 2017
@pvdlg pvdlg force-pushed the initial-release branch 5 times, most recently from 306fb03 to 0259f0a Compare November 7, 2017 18:55
@gr2m
Copy link
Member

gr2m commented Nov 8, 2017

Codecov & Greenkeeper enabled, tokens set

Copy link
Member

@gr2m gr2m left a 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 👍

@@ -0,0 +1,26 @@
module.exports = config => {
// Form https://github.com/npm/npm/blob/master/lib/cache/caching-client.js#L194
Copy link
Member

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

Copy link
Member Author

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 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

userAgent: config.get('user-agent'),
defaultTag: config.get('tag'),
couchToken: config.get('_token'),
maxSockets: parseInt(config.get('maxsockets')),
Copy link
Member

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

Copy link
Member Author

@pvdlg pvdlg Nov 8, 2017

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,40 @@
const {promisify} = require('util');
const {resolve} = require('url');
Copy link
Member

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 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const registry = await getRegistry(publishConfig, name);

try {
const data = await promisify(client.get.bind(client))(resolve(registry, name.replace('/', '%2F')), {
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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']) {
Copy link
Member

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']?

Copy link
Member Author

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.

logger.log('Verify authentication for registry %s', registry);
const {NPM_TOKEN, NPM_USERNAME, NPM_PASSWORD, NPM_EMAIL} = process.env;

if (!getAuthToken(registry)) {
Copy link
Member

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
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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)
Copy link
Member

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?

Copy link
Member Author

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.

@pvdlg pvdlg force-pushed the initial-release branch 3 times, most recently from 1bd51c6 to 7d5ab00 Compare November 8, 2017 05:13
Copy link
Member

@gr2m gr2m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants