Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

feat(tarball): add shasum from tarball when appropriate #149

Merged
merged 7 commits into from Apr 18, 2018

Conversation

imsnif
Copy link
Contributor

@imsnif imsnif commented Apr 17, 2018

Heya!

This is the result some work done in relation to the discussion here: yarnpkg/yarn#5654

When I started writing it, I thought this was an issue but then saw the tests specifically looking for that null value (mentioning: // shasums are only when provided). So I hope this is a wanted change! In my eyes it would be consistent with the rest of the behaviour. (I personally need this to facilitate lockfile conversion). But of course, if there's something I'm missing...

Current Behavior:

pacote.manifest('ansi-regex@https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz')

// Manifest {
//  ...
//  _integrity: 'sha512-TIGnTpdo+...',
//  _shasum: null
// }

After this PR:

pacote.manifest('ansi-regex@https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz')

// Manifest {
//  ...
//  _integrity: 'sha512-TIGnTpdo+...',
//  _shasum: 'c3b33ab5ee360d86e0e628f0468ae7ef27d654df'
// }

Copy link
Owner

@zkat zkat left a comment

Choose a reason for hiding this comment

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

You may want to add a similar exception for when the shasum is completely missing so we calculate it. See: https://github.com/zkat/pacote/blob/latest/lib/finalize-manifest.js#L143

@imsnif
Copy link
Contributor Author

imsnif commented Apr 17, 2018

@zkat - right! So I made the adjustment (and also adjusted some fixtures in the process).
I thought about optimizing this further by only requesting the relevant algorithms from ssri.fromStream here: https://github.com/zkat/pacote/pull/149/files#diff-d97a032389356a12ced608284b9c55edR158
I decided against it because I had the feeling it would mostly complicate the code. What do you think?

Copy link
Owner

@zkat zkat left a comment

Choose a reason for hiding this comment

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

Tests seem to be passing pretty consistently now.

Why are node streams so bad?!

zkat
zkat previously requested changes Apr 18, 2018
Copy link
Owner

@zkat zkat left a comment

Choose a reason for hiding this comment

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

This mostly looks good! One tiny change left that I missed 👍

@@ -188,7 +194,8 @@ function tarballedProps (pkg, spec, opts) {
_resolved: (mani && mani._resolved) ||
(pkg && pkg._resolved) ||
spec.fetchSpec,
_integrity: hash && hash.toString()
_integrity: needsIntegrity && hash && hash.toString(),
Copy link
Owner

Choose a reason for hiding this comment

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

This should probably be hash.sha512.toString(), since we don't currently put sha1s into the integrity field.

@zkat
Copy link
Owner

zkat commented Apr 18, 2018

Actually I'll just patch this myself real quick. This is good to merge in general. No need for more back-and-forth :)

@zkat zkat dismissed their stale review April 18, 2018 18:51

fixed it meself

@imsnif
Copy link
Contributor Author

imsnif commented Apr 18, 2018

@zkat - that's great! Just one more suggestion if I may: With your change, maybe we can toss this line? https://github.com/zkat/pacote/pull/149/files#diff-d97a032389356a12ced608284b9c55edR169

@zkat
Copy link
Owner

zkat commented Apr 18, 2018

oh! That's how you were doing it. I wondered why the tests were still passing. haha

@zkat
Copy link
Owner

zkat commented Apr 18, 2018

sorry for the rush -- didn't realize you were available and I just wanted to merge this, since I'm starting to put the release together. npm@6 is going out tomorrow :)

@imsnif
Copy link
Contributor Author

imsnif commented Apr 18, 2018

I actually just happened to walk in through the door. :)
On the contrary though - I very much appreciate the expedience!

@zkat
Copy link
Owner

zkat commented Apr 18, 2018

omg this is what I get for editing everything on github

@imsnif
Copy link
Contributor Author

imsnif commented Apr 18, 2018

Wait, doesn't everyone code like that?

@zkat zkat merged commit ccc6e90 into zkat:latest Apr 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants