question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[8.0.0] published npm package contains unused files (tests; repo config)

See original GitHub issue
  • Node Version: node v14.16.1 (npm v6.14.12)
  • Platform: Fedora 33
  • Compiler: Irrelevant
  • Module: Irrelevant

Published npm package contains repo configuration/scripts, β€œtest” folder, etc. May want to use the β€œfiles” field in package.json and specify only the actually used files/folders.

$ tree node_modules/node-gyp/ -a
node_modules/node-gyp/
β”œβ”€β”€ addon.gypi
β”œβ”€β”€ bin
β”‚   └── node-gyp.js
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ .github
β”‚   β”œβ”€β”€ ISSUE_TEMPLATE.md
β”‚   β”œβ”€β”€ PULL_REQUEST_TEMPLATE.md
β”‚   └── workflows
β”‚       └── tests.yml
β”œβ”€β”€ gyp
β”‚   β”œβ”€β”€ AUTHORS
β”‚   β”œβ”€β”€ CHANGELOG.md
β”‚   β”œβ”€β”€ CODE_OF_CONDUCT.md
β”‚   β”œβ”€β”€ CONTRIBUTING.md
β”‚   β”œβ”€β”€ data
β”‚   β”‚   └── win
β”‚   β”‚       └── large-pdb-shim.cc
β”‚   β”œβ”€β”€ .flake8
β”‚   β”œβ”€β”€ .github
β”‚   β”‚   └── workflows
β”‚   β”‚       β”œβ”€β”€ node-gyp.yml
β”‚   β”‚       β”œβ”€β”€ nodejs-windows.yml
β”‚   β”‚       β”œβ”€β”€ Python_tests.yml
β”‚   β”‚       └── release-please.yml
β”‚   β”œβ”€β”€ gyp
β”‚   β”œβ”€β”€ gyp.bat
β”‚   β”œβ”€β”€ gyp_main.py
β”‚   β”œβ”€β”€ LICENSE
β”‚   β”œβ”€β”€ pylib
β”‚   β”‚   └── gyp
β”‚   β”‚       β”œβ”€β”€ common.py
β”‚   β”‚       β”œβ”€β”€ common_test.py
β”‚   β”‚       β”œβ”€β”€ easy_xml.py
β”‚   β”‚       β”œβ”€β”€ easy_xml_test.py
β”‚   β”‚       β”œβ”€β”€ flock_tool.py
β”‚   β”‚       β”œβ”€β”€ generator
β”‚   β”‚       β”‚   β”œβ”€β”€ analyzer.py
β”‚   β”‚       β”‚   β”œβ”€β”€ android.py
β”‚   β”‚       β”‚   β”œβ”€β”€ cmake.py
β”‚   β”‚       β”‚   β”œβ”€β”€ compile_commands_json.py
β”‚   β”‚       β”‚   β”œβ”€β”€ dump_dependency_json.py
β”‚   β”‚       β”‚   β”œβ”€β”€ eclipse.py
β”‚   β”‚       β”‚   β”œβ”€β”€ gypd.py
β”‚   β”‚       β”‚   β”œβ”€β”€ gypsh.py
β”‚   β”‚       β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚       β”‚   β”œβ”€β”€ make.py
β”‚   β”‚       β”‚   β”œβ”€β”€ msvs.py
β”‚   β”‚       β”‚   β”œβ”€β”€ msvs_test.py
β”‚   β”‚       β”‚   β”œβ”€β”€ ninja.py
β”‚   β”‚       β”‚   β”œβ”€β”€ ninja_test.py
β”‚   β”‚       β”‚   β”œβ”€β”€ xcode.py
β”‚   β”‚       β”‚   └── xcode_test.py
β”‚   β”‚       β”œβ”€β”€ __init__.py
β”‚   β”‚       β”œβ”€β”€ input.py
β”‚   β”‚       β”œβ”€β”€ input_test.py
β”‚   β”‚       β”œβ”€β”€ mac_tool.py
β”‚   β”‚       β”œβ”€β”€ msvs_emulation.py
β”‚   β”‚       β”œβ”€β”€ MSVSNew.py
β”‚   β”‚       β”œβ”€β”€ MSVSProject.py
β”‚   β”‚       β”œβ”€β”€ MSVSSettings.py
β”‚   β”‚       β”œβ”€β”€ MSVSSettings_test.py
β”‚   β”‚       β”œβ”€β”€ MSVSToolFile.py
β”‚   β”‚       β”œβ”€β”€ MSVSUserFile.py
β”‚   β”‚       β”œβ”€β”€ MSVSUtil.py
β”‚   β”‚       β”œβ”€β”€ MSVSVersion.py
β”‚   β”‚       β”œβ”€β”€ ninja_syntax.py
β”‚   β”‚       β”œβ”€β”€ simple_copy.py
β”‚   β”‚       β”œβ”€β”€ win_tool.py
β”‚   β”‚       β”œβ”€β”€ xcode_emulation.py
β”‚   β”‚       β”œβ”€β”€ xcode_ninja.py
β”‚   β”‚       β”œβ”€β”€ xcodeproj_file.py
β”‚   β”‚       └── xml_fix.py
β”‚   β”œβ”€β”€ README.md
β”‚   β”œβ”€β”€ requirements_dev.txt
β”‚   β”œβ”€β”€ setup.py
β”‚   β”œβ”€β”€ test_gyp.py
β”‚   └── tools
β”‚       β”œβ”€β”€ emacs
β”‚       β”‚   β”œβ”€β”€ gyp.el
β”‚       β”‚   β”œβ”€β”€ gyp-tests.el
β”‚       β”‚   β”œβ”€β”€ README
β”‚       β”‚   β”œβ”€β”€ run-unit-tests.sh
β”‚       β”‚   └── testdata
β”‚       β”‚       β”œβ”€β”€ media.gyp
β”‚       β”‚       └── media.gyp.fontified
β”‚       β”œβ”€β”€ graphviz.py
β”‚       β”œβ”€β”€ pretty_gyp.py
β”‚       β”œβ”€β”€ pretty_sln.py
β”‚       β”œβ”€β”€ pretty_vcproj.py
β”‚       β”œβ”€β”€ README
β”‚       └── Xcode
β”‚           β”œβ”€β”€ README
β”‚           └── Specifications
β”‚               β”œβ”€β”€ gyp.pbfilespec
β”‚               └── gyp.xclangspec
β”œβ”€β”€ lib
β”‚   β”œβ”€β”€ build.js
β”‚   β”œβ”€β”€ clean.js
β”‚   β”œβ”€β”€ configure.js
β”‚   β”œβ”€β”€ find-node-directory.js
β”‚   β”œβ”€β”€ find-python.js
β”‚   β”œβ”€β”€ Find-VisualStudio.cs
β”‚   β”œβ”€β”€ find-visualstudio.js
β”‚   β”œβ”€β”€ install.js
β”‚   β”œβ”€β”€ list.js
β”‚   β”œβ”€β”€ node-gyp.js
β”‚   β”œβ”€β”€ process-release.js
β”‚   β”œβ”€β”€ rebuild.js
β”‚   β”œβ”€β”€ remove.js
β”‚   └── util.js
β”œβ”€β”€ LICENSE
β”œβ”€β”€ macOS_Catalina_acid_test.sh
β”œβ”€β”€ macOS_Catalina.md
β”œβ”€β”€ package.json
β”œβ”€β”€ README.md
β”œβ”€β”€ src
β”‚   └── win_delay_load_hook.cc
β”œβ”€β”€ test
β”‚   β”œβ”€β”€ common.js
β”‚   β”œβ”€β”€ fixtures
β”‚   β”‚   β”œβ”€β”€ ca-bundle.crt
β”‚   β”‚   β”œβ”€β”€ ca.crt
β”‚   β”‚   β”œβ”€β”€ server.crt
β”‚   β”‚   β”œβ”€β”€ server.key
β”‚   β”‚   β”œβ”€β”€ test-charmap.py
β”‚   β”‚   β”œβ”€β”€ VS_2017_BuildTools_minimal.txt
β”‚   β”‚   β”œβ”€β”€ VS_2017_Community_workload.txt
β”‚   β”‚   β”œβ”€β”€ VS_2017_Express.txt
β”‚   β”‚   β”œβ”€β”€ VS_2017_Unusable.txt
β”‚   β”‚   β”œβ”€β”€ VS_2019_BuildTools_minimal.txt
β”‚   β”‚   β”œβ”€β”€ VS_2019_Community_workload.txt
β”‚   β”‚   └── VS_2019_Preview.txt
β”‚   β”œβ”€β”€ process-exec-sync.js
β”‚   β”œβ”€β”€ simple-proxy.js
β”‚   β”œβ”€β”€ test-addon.js
β”‚   β”œβ”€β”€ test-configure-python.js
β”‚   β”œβ”€β”€ test-download.js
β”‚   β”œβ”€β”€ test-find-accessible-sync.js
β”‚   β”œβ”€β”€ test-find-node-directory.js
β”‚   β”œβ”€β”€ test-find-python.js
β”‚   β”œβ”€β”€ test-find-visualstudio.js
β”‚   β”œβ”€β”€ test-install.js
β”‚   β”œβ”€β”€ test-options.js
β”‚   └── test-process-release.js
└── update-gyp.py

20 directories, 126 files

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
rvaggcommented, May 20, 2021

Here’s my take: Tests etc. represent part of the documentation and are components of the complete project which we occasionally snapshot and publish as a version to npm. On that basis, packages in npm should include stand-alone snapshots of a project. I know this is not a view held by everyone who publises to npm and some want to obsessively remove everything except that which touches the execution path–which is arguably reasonable in a world of trivial dependencies that bloat our development folders. I just think maybe the problem of needless dependency tree bloat should be tackled with greater priority. So I’m personally not in favour of removing things from a publish unless we’re dealing with unreasonably large items. 2Mb is not unreasonable for us to be able to ship a complete snapshot of the package. If we have extraneous things in the repo then we should be able to add them to .gitignore.

Re server.key, if this is a critical problem for you then perhaps you could help out by contributing a change that shuffles it out of view of low quality auto-audits? Either generate it as required for tests, or maybe more practically, embed it as a string in a test file that can be extracted and removed on each run? Alternatively find a better auditor that isn’t upset by test fixtures?

0reactions
david-golightly-leapyearcommented, May 20, 2021

This is more than a space-saving move. An automated security audit tool found and flagged the presence of https://github.com/nodejs/node-gyp/blob/master/test/fixtures/server.key which, although probably harmless, creates noise for the auditor and makes for an awkward conversation. Is there an estimated time to remove these files from the build?

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm-publish - npm Docs
Description. Publishes a package to the registry so that it can be installed by name. By default npm will publish to the public...
Read more >
lerna/CHANGELOG.md at main - GitHub
dragon: Lerna is a fast, modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository.
Read more >
Semantic Release publishing on package.json - Stack Overflow
I assume when you build locally, you have a build folder with package.json and a cjs folder, but only the file itself is...
Read more >
Supported hooks - pre-commit
check-json - checks json files for parseable syntax. check-shebang-scripts-are-executable - ensures that (non-binary) files with a shebang are executable.
Read more >
Node.js v19.3.0 Documentation
calls() and will throw an error for functions that have not been called the expected number of times. import assert from 'node:assert'; //...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found