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

Standardize and normalize packages #21

Merged
merged 9 commits into from
Feb 25, 2017
Merged

Standardize and normalize packages #21

merged 9 commits into from
Feb 25, 2017

Conversation

zkat
Copy link
Owner

@zkat zkat commented Feb 14, 2017

Fixes #17 and #18.

With this PR, pacote.manifest will now return a single, immutable Manifest object that has a consistent set of fields, with normalized data and semantics. These fields are chosen based on their utility to the installer. Things that are missing are thus not considered necessary for installation.

Aside from a few handler-specific details, there's now a single place in the code where we do fallback to the package tarballs in order to fill in missing/unknown fields, including _shrinkwrap, bin, and even _shasum.

TODO

  • write dedicated tests for finalize-manifest. Include tests to check the bypassing of tarball extracts
  • convert extract-shrinkwrap tests to be used by finalize-manifest tests.

@zkat zkat added this to the 0.2.0 milestone Feb 14, 2017
@zkat zkat force-pushed the zkat/normalized-packages branch 3 times, most recently from 23ef7cf to b2dea92 Compare February 20, 2017 08:54
@coveralls
Copy link

coveralls commented Feb 20, 2017

Coverage Status

Coverage decreased (-4.0%) to 84.076% when pulling 5dba70a on zkat/normalized-packages into 37cddc5 on latest.

// This one depends entirely on each handler.
this._resolved = pkg._resolved

// We sometimes need to grab these from the tarball.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'll expand on this. I think it's worth explaining.

this.bin = pkg.bin || fromTarball.bin || null

if (this.bin && Array.isArray(this.bin)) {
// This isn't even documented?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this comment necessary?

Copy link
Owner Author

Choose a reason for hiding this comment

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

No. I was just sad.

Copy link
Collaborator

Choose a reason for hiding this comment

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

:( <3

// I don't want this why did you give it to me. Go away. 🔥🔥🔥🔥
delete this.readme

// Object.freeze(this)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need this comment? :)

Copy link
Owner Author

Choose a reason for hiding this comment

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

This is a reminder to myself of something I really want to do but npm doesn't let me do yet -- it'll be incommented once I figure a few things out, and I didn't want it to be forgotten.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, thanks :)

log: npmlog
}

test('basic extraction')
Copy link
Collaborator

Choose a reason for hiding this comment

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

If it hasn't already, let's create an issue to finish these tests lest we forget.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Not gonna forget. These are very visible if you run npm t. Also, #48 is the PR adding these tests (and registry.tarball.js)

Copy link
Collaborator

Choose a reason for hiding this comment

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

My bad. Thanks!

@iarna
Copy link
Collaborator

iarna commented Feb 24, 2017

The bin thing totally is documented. See the directories section of the package.json docs:

If you specify a bin directory in directories.bin, all the files in that folder will be added.

Because of the way the bin directive works, specifying both a bin path and setting directories.bin is an error. If you want to specify individual files, use bin, and for all the files in an existing bin directory, use directories.bin.

I would rather keep util for extractable/reusable/generic utilities.
extract-stream has domain-specific knowledge.
fix(manifest): prefer shasum in dist

fix(finalize-anifest): npm really does expect bundleDeps to be an array

refactor(finalize-manifest): completeFromTarball -> tarballedProps

and stop making it side-effectful.

fix(manifest): no need for where

fix(finalize-manifest): default this out to simplify tests

refactor(finalize-manifest): use external checksum-stream

fix(finalize-manifest): stop freezing, delete readme, put bin in extraProps

feat(finalize-manifest): handle array bin field
manifest._shasum = (
manifest.dist && manifest.dist.shasum
) || manifest._shasum
manifest._resolved = (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your lisp accent is showing. 😉 I feel like these expressions are waaay too big to be easy to follow in JS. If you don't want to do if-branched assignment then maybe put the different alternatives in functions?

@zkat zkat merged commit ea5fa7c into latest Feb 25, 2017
@zkat zkat deleted the zkat/normalized-packages branch February 25, 2017 02:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants