Skip to content
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

Ensure that required files are packaged #82

Open
fregante opened this issue Aug 17, 2016 · 7 comments
Open

Ensure that required files are packaged #82

fregante opened this issue Aug 17, 2016 · 7 comments

Comments

@fregante
Copy link
Collaborator

fregante commented Aug 17, 2016

I just published a package with the wrong files and bin package.json settings. I'm surprised that npm doesn't check this at all since an incorrect bin causes a subsequent install to fail.

Possible checks:

  • files listed in files exist
  • files listed in bin exist
  • walk the dependency tree starting from main to make sure that all non-external requires are included in files or not npmignored
@sindresorhus
Copy link
Owner

files listed in files exist
files listed in bin exist

Good idea! For files, we can do it as long as it's not a glob pattern, which is allowed.

walk the dependency tree starting from main to make sure that all non-external requires are included in files or not npmignored

We talked about it previously, but it's very complicated, especially when you start having Babel and Webpack in the picture. I think we instead should get it implemented in eslint-plugin-import and recommend that.

// @benmosher @jfmengels

@benmosher
Copy link

eslint-plugin-node has no-unpublished-requires. I'd be up for something similiar in eslint-plugin-import but what's there in the node plugin might work as-is? (though I don't know if that plugin handles ES6 modules, I'd believe it doesn't)

@sindresorhus
Copy link
Owner

@bfred-it Would you mind reposting your npm/npm#13948 proposal on the Yarn issue tracker? I don't see it going anywhere with the npm client.

@fregante
Copy link
Collaborator Author

npm exposes a useful method: require('npm/libs/pack').getContents()

From this I think it's a matter of testing pkg.bin in getContents() and such

@fregante
Copy link
Collaborator Author

fregante commented Nov 2, 2020

Here: https://github.com/typicode/pkg-ok

Apparently it's pretty old, even

@tommy-mitchell
Copy link
Collaborator

I think with #682, this could be two checks:

  1. Use pkg-ok to ensure fields in package.json are setup correctly
  2. Validate that the files to be packed include the fields checked in pkg-ok

@fregante
Copy link
Collaborator Author

fregante commented Jun 27, 2024

This new tool also verifies the exports and the existence of each file. Given the complexity of the field, I think it's a worthwhile addition:

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

No branches or pull requests

4 participants