pax_global_header 0000666 0000000 0000000 00000000064 14301751560 0014514 g ustar 00root root 0000000 0000000 52 comment=be15ab3679720c9d978f851a326a03cb35eb6b0c
npm-bundled-2.0.1/ 0000775 0000000 0000000 00000000000 14301751560 0013721 5 ustar 00root root 0000000 0000000 npm-bundled-2.0.1/.commitlintrc.js 0000664 0000000 0000000 00000000553 14301751560 0017044 0 ustar 00root root 0000000 0000000 /* This file is automatically added by @npmcli/template-oss. Do not edit. */
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'deps', 'chore']],
'header-max-length': [2, 'always', 80],
'subject-case': [0, 'always', ['lower-case', 'sentence-case', 'start-case']],
},
}
npm-bundled-2.0.1/.eslintrc.js 0000664 0000000 0000000 00000000545 14301751560 0016164 0 ustar 00root root 0000000 0000000 /* This file is automatically added by @npmcli/template-oss. Do not edit. */
'use strict'
const { readdirSync: readdir } = require('fs')
const localConfigs = readdir(__dirname)
.filter((file) => file.startsWith('.eslintrc.local.'))
.map((file) => `./${file}`)
module.exports = {
root: true,
extends: [
'@npmcli',
...localConfigs,
],
}
npm-bundled-2.0.1/.github/ 0000775 0000000 0000000 00000000000 14301751560 0015261 5 ustar 00root root 0000000 0000000 npm-bundled-2.0.1/.github/CODEOWNERS 0000664 0000000 0000000 00000000132 14301751560 0016650 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
* @npm/cli-team
npm-bundled-2.0.1/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 14301751560 0017444 5 ustar 00root root 0000000 0000000 npm-bundled-2.0.1/.github/ISSUE_TEMPLATE/bug.yml 0000664 0000000 0000000 00000002655 14301751560 0020754 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Bug
description: File a bug/issue
title: "[BUG]
"
labels: [ Bug, Needs Triage ]
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please [search here](./issues) to see if an issue already exists for your problem.
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: Current Behavior
description: A clear & concise description of what you're experiencing.
validations:
required: false
- type: textarea
attributes:
label: Expected Behavior
description: A clear & concise description of what you expected to happen.
validations:
required: false
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
value: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
validations:
required: false
- type: textarea
attributes:
label: Environment
description: |
examples:
- **npm**: 7.6.3
- **Node**: 13.14.0
- **OS**: Ubuntu 20.04
- **platform**: Macbook Pro
value: |
- npm:
- Node:
- OS:
- platform:
validations:
required: false
npm-bundled-2.0.1/.github/ISSUE_TEMPLATE/config.yml 0000664 0000000 0000000 00000000145 14301751560 0021434 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
blank_issues_enabled: true
npm-bundled-2.0.1/.github/dependabot.yml 0000664 0000000 0000000 00000000565 14301751560 0020117 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
allow:
- dependency-type: direct
versioning-strategy: increase-if-necessary
commit-message:
prefix: deps
prefix-development: chore
labels:
- "Dependencies"
npm-bundled-2.0.1/.github/settings.yml 0000664 0000000 0000000 00000000055 14301751560 0017644 0 ustar 00root root 0000000 0000000 ---
_extends: '.github:npm-cli/settings.yml'
npm-bundled-2.0.1/.github/workflows/ 0000775 0000000 0000000 00000000000 14301751560 0017316 5 ustar 00root root 0000000 0000000 npm-bundled-2.0.1/.github/workflows/audit.yml 0000664 0000000 0000000 00000001370 14301751560 0021150 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Audit
on:
workflow_dispatch:
schedule:
# "At 01:00 on Monday" https://crontab.guru/#0_1_*_*_1
- cron: "0 1 * * 1"
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Update npm to latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- run: npm i --ignore-scripts --no-audit --no-fund --package-lock
- run: npm audit
npm-bundled-2.0.1/.github/workflows/ci.yml 0000664 0000000 0000000 00000005114 14301751560 0020435 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: CI
on:
workflow_dispatch:
pull_request:
branches:
- '*'
push:
branches:
- main
- latest
schedule:
# "At 02:00 on Monday" https://crontab.guru/#0_2_*_*_1
- cron: "0 2 * * 1"
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Update npm to latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- run: npm i --ignore-scripts --no-audit --no-fund
- run: npm run lint
test:
strategy:
fail-fast: false
matrix:
node-version:
- 12.13.0
- 12.x
- 14.15.0
- 14.x
- 16.0.0
- 16.x
platform:
- os: ubuntu-latest
shell: bash
- os: macos-latest
shell: bash
- os: windows-latest
shell: cmd
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Update to workable npm (windows)
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.'))
run: |
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
tar xf npm-7.5.4.tgz
cd package
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
cd ..
rmdir /s /q package
- name: Update npm to 7
# If we do test on npm 10 it needs npm7
if: startsWith(matrix.node-version, '10.')
run: npm i --prefer-online --no-fund --no-audit -g npm@7
- name: Update npm to latest
if: ${{ !startsWith(matrix.node-version, '10.') }}
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- run: npm i --ignore-scripts --no-audit --no-fund
- run: npm test --ignore-scripts
npm-bundled-2.0.1/.github/workflows/codeql-analysis.yml 0000664 0000000 0000000 00000002001 14301751560 0023122 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: "CodeQL"
on:
push:
branches:
- main
- latest
pull_request:
# The branches below must be a subset of the branches above
branches:
- main
- latest
schedule:
# "At 03:00 on Monday" https://crontab.guru/#0_3_*_*_1
- cron: "0 3 * * 1"
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ javascript ]
steps:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
npm-bundled-2.0.1/.github/workflows/post-dependabot.yml 0000664 0000000 0000000 00000002641 14301751560 0023134 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Post Dependabot Actions
on: pull_request
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: write
jobs:
template-oss-apply:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Update npm to latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.1.1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: npm install and commit
if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr checkout ${{ github.event.pull_request.number }}
npm install --ignore-scripts --no-audit --no-fund
npm run template-oss-apply
git add .
git commit -am "chore: postinstall for dependabot template-oss PR"
git push
npm run lint
npm-bundled-2.0.1/.github/workflows/pull-request.yml 0000664 0000000 0000000 00000002143 14301751560 0022503 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Pull Request Linting
on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize
jobs:
check:
name: Check PR Title or Commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Update npm to latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- name: Install deps
run: npm i -D @commitlint/cli @commitlint/config-conventional
- name: Check commits OR PR title
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
npx --offline commitlint -V --from origin/main --to ${{ github.event.pull_request.head.sha }} \
|| echo $PR_TITLE | npx --offline commitlint -V
npm-bundled-2.0.1/.github/workflows/release-please.yml 0000664 0000000 0000000 00000001314 14301751560 0022727 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Release Please
on:
push:
branches:
- main
- latest
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
changelog-types: >
[
{"type":"feat","section":"Features","hidden":false},
{"type":"fix","section":"Bug Fixes","hidden":false},
{"type":"docs","section":"Documentation","hidden":false},
{"type":"deps","section":"Dependencies","hidden":false},
{"type":"chore","hidden":true}
]
npm-bundled-2.0.1/.gitignore 0000664 0000000 0000000 00000000570 14301751560 0015713 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
# ignore everything in the root
/*
# keep these
!/.eslintrc.local.*
!**/.gitignore
!/docs/
!/tap-snapshots/
!/test/
!/map.js
!/scripts/
!/README*
!/LICENSE*
!/CHANGELOG*
!/.commitlintrc.js
!/.eslintrc.js
!/.github/
!/.gitignore
!/.npmrc
!/CODE_OF_CONDUCT.md
!/SECURITY.md
!/bin/
!/lib/
!/package.json
npm-bundled-2.0.1/.npmrc 0000664 0000000 0000000 00000000135 14301751560 0015040 0 ustar 00root root 0000000 0000000 ; This file is automatically added by @npmcli/template-oss. Do not edit.
package-lock=false
npm-bundled-2.0.1/CHANGELOG.md 0000664 0000000 0000000 00000001634 14301751560 0015536 0 ustar 00root root 0000000 0000000 # Changelog
## [2.0.1](https://github.com/npm/npm-bundled/compare/v2.0.0...v2.0.1) (2022-08-25)
### Dependencies
* bump npm-normalize-package-bin from 1.0.1 to 2.0.0 ([#13](https://github.com/npm/npm-bundled/issues/13)) ([aec07c1](https://github.com/npm/npm-bundled/commit/aec07c1fff4dd0690e3792c6fe00b6d7e574c017))
## [2.0.0](https://github.com/npm/npm-bundled/compare/v1.1.2...v2.0.0) (2022-08-22)
### ⚠ BREAKING CHANGES
* This adds an engine field with support for node `^12.13.0 || ^14.15.0 || >=16.0.0`.
### Documentation
* fix incorrect example of sync usage ([#9](https://github.com/npm/npm-bundled/issues/9)) ([45ccdf4](https://github.com/npm/npm-bundled/commit/45ccdf4211e0552e3957fc6dd8134a6440a803c3))
### Dependencies
* @npmcli/template-oss@3.5.0 ([#10](https://github.com/npm/npm-bundled/issues/10)) ([3ea4848](https://github.com/npm/npm-bundled/commit/3ea48487c07992c9c589ee527423ef8e3e193a7c))
npm-bundled-2.0.1/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000000507 14301751560 0016522 0 ustar 00root root 0000000 0000000
All interactions in this repo are covered by the [npm Code of
Conduct](https://docs.npmjs.com/policies/conduct)
The npm cli team may, at its own discretion, moderate, remove, or edit
any interactions such as pull requests, issues, and comments.
npm-bundled-2.0.1/LICENSE 0000664 0000000 0000000 00000001364 14301751560 0014732 0 ustar 00root root 0000000 0000000 The ISC License
Copyright (c) npm, Inc. and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
npm-bundled-2.0.1/README.md 0000664 0000000 0000000 00000003304 14301751560 0015200 0 ustar 00root root 0000000 0000000 # npm-bundled
Run this in a node package, and it'll tell you which things in
node_modules are bundledDependencies, or transitive dependencies of
bundled dependencies.
[](https://travis-ci.org/npm/npm-bundled)
## USAGE
To get the list of deps at the top level that are bundled (or
transitive deps of a bundled dep) run this:
```js
const bundled = require('npm-bundled')
// async version
bundled({ path: '/path/to/pkg/defaults/to/cwd'}, (er, list) => {
// er means it had an error, which is _hella_ weird
// list is a list of package names, like `fooblz` or `@corp/blerg`
// the might not all be deps of the top level, because transitives
})
// async promise version
bundled({ path: '/path/to/pkg/defaults/to/cwd'}).then(list => {
// so promisey!
// actually the callback version returns a promise, too, it just
// attaches the supplied callback to the promise
})
// sync version, throws if there's an error
const list = bundled.sync({ path: '/path/to/pkg/defaults/to/cwd'})
```
That's basically all you need to know. If you care to dig into it,
you can also use the `bundled.Walker` and `bundled.WalkerSync`
classes to get fancy.
This library does not write anything to the filesystem, but it _may_
have undefined behavior if the structure of `node_modules` changes
while it's reading deps.
All symlinks are followed. This means that it can lead to surprising
results if a symlinked bundled dependency has a missing dependency
that is satisfied at the top level. Since package creation resolves
symlinks as well, this is an edge case where package creation and
development environment are not going to be aligned, and is best
avoided.
npm-bundled-2.0.1/SECURITY.md 0000664 0000000 0000000 00000000246 14301751560 0015514 0 ustar 00root root 0000000 0000000
Please send vulnerability reports through [hackerone](https://hackerone.com/github).
npm-bundled-2.0.1/lib/ 0000775 0000000 0000000 00000000000 14301751560 0014467 5 ustar 00root root 0000000 0000000 npm-bundled-2.0.1/lib/index.js 0000664 0000000 0000000 00000014552 14301751560 0016143 0 ustar 00root root 0000000 0000000 'use strict'
// walk the tree of deps starting from the top level list of bundled deps
// Any deps at the top level that are depended on by a bundled dep that
// does not have that dep in its own node_modules folder are considered
// bundled deps as well. This list of names can be passed to npm-packlist
// as the "bundled" argument. Additionally, packageJsonCache is shared so
// packlist doesn't have to re-read files already consumed in this pass
const fs = require('fs')
const path = require('path')
const EE = require('events').EventEmitter
// we don't care about the package bins, but we share a pj cache
// with other modules that DO care about it, so keep it nice.
const normalizePackageBin = require('npm-normalize-package-bin')
class BundleWalker extends EE {
constructor (opt) {
opt = opt || {}
super(opt)
this.path = path.resolve(opt.path || process.cwd())
this.parent = opt.parent || null
if (this.parent) {
this.result = this.parent.result
// only collect results in node_modules folders at the top level
// since the node_modules in a bundled dep is included always
if (!this.parent.parent) {
const base = path.basename(this.path)
const scope = path.basename(path.dirname(this.path))
this.result.add(/^@/.test(scope) ? scope + '/' + base : base)
}
this.root = this.parent.root
this.packageJsonCache = this.parent.packageJsonCache
} else {
this.result = new Set()
this.root = this.path
this.packageJsonCache = opt.packageJsonCache || new Map()
}
this.seen = new Set()
this.didDone = false
this.children = 0
this.node_modules = []
this.package = null
this.bundle = null
}
addListener (ev, fn) {
return this.on(ev, fn)
}
on (ev, fn) {
const ret = super.on(ev, fn)
if (ev === 'done' && this.didDone) {
this.emit('done', this.result)
}
return ret
}
done () {
if (!this.didDone) {
this.didDone = true
if (!this.parent) {
const res = Array.from(this.result)
this.result = res
this.emit('done', res)
} else {
this.emit('done')
}
}
}
start () {
const pj = path.resolve(this.path, 'package.json')
if (this.packageJsonCache.has(pj)) {
this.onPackage(this.packageJsonCache.get(pj))
} else {
this.readPackageJson(pj)
}
return this
}
readPackageJson (pj) {
fs.readFile(pj, (er, data) =>
er ? this.done() : this.onPackageJson(pj, data))
}
onPackageJson (pj, data) {
try {
this.package = normalizePackageBin(JSON.parse(data + ''))
} catch (er) {
return this.done()
}
this.packageJsonCache.set(pj, this.package)
this.onPackage(this.package)
}
allDepsBundled (pkg) {
return Object.keys(pkg.dependencies || {}).concat(
Object.keys(pkg.optionalDependencies || {}))
}
onPackage (pkg) {
// all deps are bundled if we got here as a child.
// otherwise, only bundle bundledDeps
// Get a unique-ified array with a short-lived Set
const bdRaw = this.parent ? this.allDepsBundled(pkg)
: pkg.bundleDependencies || pkg.bundledDependencies || []
const bd = Array.from(new Set(
Array.isArray(bdRaw) ? bdRaw
: bdRaw === true ? this.allDepsBundled(pkg)
: Object.keys(bdRaw)))
if (!bd.length) {
return this.done()
}
this.bundle = bd
this.readModules()
}
readModules () {
readdirNodeModules(this.path + '/node_modules', (er, nm) =>
er ? this.onReaddir([]) : this.onReaddir(nm))
}
onReaddir (nm) {
// keep track of what we have, in case children need it
this.node_modules = nm
this.bundle.forEach(dep => this.childDep(dep))
if (this.children === 0) {
this.done()
}
}
childDep (dep) {
if (this.node_modules.indexOf(dep) !== -1) {
if (!this.seen.has(dep)) {
this.seen.add(dep)
this.child(dep)
}
} else if (this.parent) {
this.parent.childDep(dep)
}
}
child (dep) {
const p = this.path + '/node_modules/' + dep
this.children += 1
const child = new BundleWalker({
path: p,
parent: this,
})
child.on('done', _ => {
if (--this.children === 0) {
this.done()
}
})
child.start()
}
}
class BundleWalkerSync extends BundleWalker {
start () {
super.start()
this.done()
return this
}
readPackageJson (pj) {
try {
this.onPackageJson(pj, fs.readFileSync(pj))
} catch {
// empty catch
}
return this
}
readModules () {
try {
this.onReaddir(readdirNodeModulesSync(this.path + '/node_modules'))
} catch {
this.onReaddir([])
}
}
child (dep) {
new BundleWalkerSync({
path: this.path + '/node_modules/' + dep,
parent: this,
}).start()
}
}
const readdirNodeModules = (nm, cb) => {
fs.readdir(nm, (er, set) => {
if (er) {
cb(er)
} else {
const scopes = set.filter(f => /^@/.test(f))
if (!scopes.length) {
cb(null, set)
} else {
const unscoped = set.filter(f => !/^@/.test(f))
let count = scopes.length
scopes.forEach(scope => {
fs.readdir(nm + '/' + scope, (readdirEr, pkgs) => {
if (readdirEr || !pkgs.length) {
unscoped.push(scope)
} else {
unscoped.push.apply(unscoped, pkgs.map(p => scope + '/' + p))
}
if (--count === 0) {
cb(null, unscoped)
}
})
})
}
}
})
}
const readdirNodeModulesSync = nm => {
const set = fs.readdirSync(nm)
const unscoped = set.filter(f => !/^@/.test(f))
const scopes = set.filter(f => /^@/.test(f)).map(scope => {
try {
const pkgs = fs.readdirSync(nm + '/' + scope)
return pkgs.length ? pkgs.map(p => scope + '/' + p) : [scope]
} catch (er) {
return [scope]
}
}).reduce((a, b) => a.concat(b), [])
return unscoped.concat(scopes)
}
const walk = (options, callback) => {
const p = new Promise((resolve, reject) => {
new BundleWalker(options).on('done', resolve).on('error', reject).start()
})
return callback ? p.then(res => callback(null, res), callback) : p
}
const walkSync = options => {
return new BundleWalkerSync(options).start().result
}
module.exports = walk
walk.sync = walkSync
walk.BundleWalker = BundleWalker
walk.BundleWalkerSync = BundleWalkerSync
npm-bundled-2.0.1/package.json 0000664 0000000 0000000 00000002437 14301751560 0016215 0 ustar 00root root 0000000 0000000 {
"name": "npm-bundled",
"version": "2.0.1",
"description": "list things in node_modules that are bundledDependencies, or transitive dependencies thereof",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "https://github.com/npm/npm-bundled.git"
},
"author": "GitHub Inc.",
"license": "ISC",
"devDependencies": {
"@npmcli/eslint-config": "^3.1.0",
"@npmcli/template-oss": "3.5.0",
"mkdirp": "^1.0.4",
"mutate-fs": "^2.1.1",
"rimraf": "^3.0.2",
"tap": "^16.3.0"
},
"scripts": {
"test": "tap",
"preversion": "npm test",
"postversion": "npm publish",
"postpublish": "git push origin --all; git push origin --tags",
"lint": "eslint \"**/*.js\"",
"postlint": "template-oss-check",
"template-oss-apply": "template-oss-apply --force",
"lintfix": "npm run lint -- --fix",
"prepublishOnly": "git push origin --follow-tags",
"snap": "tap",
"posttest": "npm run lint"
},
"files": [
"bin/",
"lib/"
],
"dependencies": {
"npm-normalize-package-bin": "^2.0.0"
},
"engines": {
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "3.5.0"
}
}
npm-bundled-2.0.1/test/ 0000775 0000000 0000000 00000000000 14301751560 0014700 5 ustar 00root root 0000000 0000000 npm-bundled-2.0.1/test/all-bundle.js 0000664 0000000 0000000 00000001705 14301751560 0017260 0 ustar 00root root 0000000 0000000 const t = require('tap')
const pkg = require('./pkgtree')(t, {
$package: {
name: 'a',
version: '1.2.3',
bundledDependencies: true,
dependencies: {
b: '1.2.3',
d: '1.2.3',
},
},
b: {
d: { $package: {
name: 'd',
version: '1.2.3',
dependencies: {
e: '1.2.3',
},
} },
$package: {
name: 'b',
version: '1.2.3',
dependencies: {
c: '1.2.3',
d: '1.2.3',
},
},
},
c: { $package: {
name: 'c',
version: '1.2.3',
} },
d: { $package: {
name: 'd',
version: '1.2.3',
dependencies: {
c: '1.2.3',
},
} },
e: { $package: {
name: 'e',
version: '1.2.3',
} },
})
const walk = require('../')
const check = (result, t) => {
t.same(result.sort(), ['b', 'c', 'd', 'e'])
t.end()
}
t.test('sync', t => check(walk.sync({ path: pkg }), t))
t.test('async', t => walk({ path: pkg }).then(res => check(res, t)))
npm-bundled-2.0.1/test/bad-json.js 0000664 0000000 0000000 00000001715 14301751560 0016737 0 ustar 00root root 0000000 0000000 const t = require('tap')
const pkg = require('./pkgtree')(t, {
$package: {
name: 'a',
version: '1.2.3',
dependencies: {
b: '1.2.3',
d: '1.2.3',
},
bundledDependencies: ['b'],
},
b: {
d: { $package: {
name: 'd',
version: '1.2.3',
dependencies: {
e: '1.2.3',
},
} },
$package: {
name: 'b',
version: '1.2.3',
dependencies: {
c: '1.2.3',
d: '1.2.3',
},
},
},
c: { $package: {
name: 'c',
version: '1.2.3',
} },
d: { $package: {
name: 'd',
version: '1.2.3',
dependencies: {
c: '1.2.3',
},
} },
e: { $package: {
name: 'e',
version: '1.2.3',
invalid: true,
} },
})
const walk = require('../')
const check = (result, t) => {
t.same(result, ['b', 'c', 'e'])
t.end()
}
t.test('sync', t => check(walk.sync({ path: pkg }), t))
t.test('async', t => walk({ path: pkg }).then(res => check(res, t)))
npm-bundled-2.0.1/test/basic.js 0000664 0000000 0000000 00000001672 14301751560 0016325 0 ustar 00root root 0000000 0000000 const t = require('tap')
const pkg = require('./pkgtree')(t, {
$package: {
name: 'a',
version: '1.2.3',
dependencies: {
b: '1.2.3',
d: '1.2.3',
},
bundledDependencies: ['b'],
},
b: {
d: { $package: {
name: 'd',
version: '1.2.3',
dependencies: {
e: '1.2.3',
},
} },
$package: {
name: 'b',
version: '1.2.3',
dependencies: {
c: '1.2.3',
d: '1.2.3',
},
},
},
c: { $package: {
name: 'c',
version: '1.2.3',
} },
d: { $package: {
name: 'd',
version: '1.2.3',
dependencies: {
c: '1.2.3',
},
} },
e: { $package: {
name: 'e',
version: '1.2.3',
} },
})
const walk = require('../')
const check = (result, t) => {
t.same(result, ['b', 'c', 'e'])
t.end()
}
t.test('sync', t => check(walk.sync({ path: pkg }), t))
t.test('async', t => walk({ path: pkg }).then(res => check(res, t)))
npm-bundled-2.0.1/test/caches.js 0000664 0000000 0000000 00000004323 14301751560 0016466 0 ustar 00root root 0000000 0000000 const t = require('tap')
const fs = require('fs')
const pkg = require('./pkgtree')(t, {
$package: {
name: 'a',
version: '1.2.3',
dependencies: {
b: '1.2.3',
d: '1.2.3',
},
bundledDependencies: ['b'],
},
b: {
d: { $package: {
name: 'd',
version: '1.2.3',
dependencies: {
e: '1.2.3',
},
} },
$package: {
name: 'b',
version: '1.2.3',
dependencies: {
c: '1.2.3',
d: '1.2.3',
},
},
},
c: { $package: {
name: 'c',
version: '1.2.3',
} },
d: { $package: {
name: 'd',
version: '1.2.3',
dependencies: {
c: '1.2.3',
},
} },
e: { $package: {
name: 'e',
version: '1.2.3',
} },
})
const walk = require('../')
const check = (result, t) => t.same(result, ['b', 'c', 'e'])
const checkEmpty = (result, t) => t.same(result, [])
t.test('sync', t => {
t.plan(2)
const bw = new walk.BundleWalkerSync({ path: pkg })
const bw2 = new walk.BundleWalkerSync({
path: pkg,
packageJsonCache: bw.packageJsonCache,
})
bw.start()
bw2.start()
check(bw.result, t)
check(bw2.result, t)
})
t.test('async', t => {
t.plan(2)
process.chdir(pkg)
const bw = new walk.BundleWalker()
const bw2 = new walk.BundleWalker({
packageJsonCache: bw.packageJsonCache,
})
bw.on('done', result => check(result, t))
bw2.on('done', result => check(result, t))
bw.start()
bw2.start()
})
t.test('mixed', t => {
t.plan(2)
process.chdir(pkg)
const bw = new walk.BundleWalkerSync({ path: pkg })
const bw2 = new walk.BundleWalker({
packageJsonCache: bw.packageJsonCache,
})
bw.start()
check(bw.result, t)
bw2.start()
bw2.on('done', result => check(result, t))
})
t.test('mixed, nothing to bundle', t => {
fs.writeFileSync(pkg + '/package.json', JSON.stringify({
name: 'a',
version: '1.2.3',
dependencies: {
b: '1.2.3',
d: '1.2.3',
},
}, null, 2))
t.plan(2)
process.chdir(pkg)
const bw = new walk.BundleWalkerSync({ path: pkg })
const bw2 = new walk.BundleWalker({
packageJsonCache: bw.packageJsonCache,
})
bw.start()
checkEmpty(bw.result, t)
bw2.start()
bw2.addListener('done', result => checkEmpty(result, t))
})
npm-bundled-2.0.1/test/cycle.js 0000664 0000000 0000000 00000001204 14301751560 0016332 0 ustar 00root root 0000000 0000000 const t = require('tap')
const pkg = require('./pkgtree')(t, {
$package: {
name: 'a',
version: '1.2.3',
dependencies: {
b: '1.2.3',
},
bundledDependencies: ['b'],
},
b: { $package: {
name: 'b',
version: '1.2.3',
dependencies: {
c: '1.2.3',
},
} },
c: { $package: {
name: 'c',
version: '1.2.3',
dependencies: {
b: '1.2.3',
},
} },
})
const walk = require('../')
const check = (result, t) => {
t.same(result, ['b', 'c'])
t.end()
}
t.test('sync', t => check(walk.sync({ path: pkg }), t))
t.test('async', t => walk({ path: pkg }).then(res => check(res, t)))
npm-bundled-2.0.1/test/metadeps.js 0000664 0000000 0000000 00000002576 14301751560 0017052 0 ustar 00root root 0000000 0000000 const t = require('tap')
// dep graph:
// root -> (a, b@1, c@1), BUNDLE(a)
// a -> (b@2, c@2)
// b@1 -> d@1
// c@1 -> d@1
// b@2 -> d@2
// c@2 -> d@2
//
// package tree:
// root
// +-- a (should bundle)
// | +-- b@2 (should bundle)
// | +-- c@2 (should bundle)
// | +-- d@2 (should bundle)
// +-- b@1
// +-- c@1
// +-- d@1
const pkg = require('./pkgtree')(t, {
$package: {
name: 'root',
version: '1.0.0',
dependencies: {
a: '',
b: '1',
c: '1',
},
bundleDependencies: ['a'],
},
a: {
$package: {
name: 'a',
version: '1.0.0',
dependencies: {
b: '2',
c: '2',
},
},
b: { $package: {
name: 'b',
version: '2.0.0',
dependencies: { d: '2.0.0' },
} },
c: { $package: {
name: 'c',
version: '2.0.0',
dependencies: { d: '2.0.0' },
} },
d: { $package: { name: 'd', version: '2.0.0' } },
},
b: { $package: {
name: 'b',
version: '1.0.0',
dependencies: { d: '1.0.0' },
} },
c: { $package: {
name: 'c',
version: '1.0.0',
dependencies: { d: '1.0.0' },
} },
d: { $package: { name: 'd', version: '1.0.0' } },
})
const walk = require('../')
const check = (result, t) => {
t.same(result, ['a'])
t.end()
}
t.test('sync', t => check(walk.sync({ path: pkg }), t))
t.test('async', t => walk({ path: pkg }).then(res => check(res, t)))
npm-bundled-2.0.1/test/missing-package-json.js 0000664 0000000 0000000 00000001604 14301751560 0021250 0 ustar 00root root 0000000 0000000 const t = require('tap')
const pkg = require('./pkgtree')(t, {
$package: {
name: 'a',
version: '1.2.3',
dependencies: {
b: '1.2.3',
d: '1.2.3',
},
bundledDependencies: ['b'],
},
b: {
d: { $package: {
name: 'd',
version: '1.2.3',
dependencies: {
e: '1.2.3',
},
} },
$package: {
name: 'b',
version: '1.2.3',
dependencies: {
c: '1.2.3',
d: '1.2.3',
},
},
},
c: { $package: {
name: 'c',
version: '1.2.3',
} },
d: { $package: {
name: 'd',
version: '1.2.3',
dependencies: {
c: '1.2.3',
},
} },
e: {},
})
const walk = require('../')
const check = (result, t) => {
t.same(result, ['b', 'c', 'e'])
t.end()
}
t.test('sync', t => check(walk.sync({ path: pkg }), t))
t.test('async', t => walk({ path: pkg }).then(res => check(res, t)))
npm-bundled-2.0.1/test/no-bundle.js 0000664 0000000 0000000 00000001716 14301751560 0017126 0 ustar 00root root 0000000 0000000 const t = require('tap')
const pkg = require('./pkgtree')(t, {
$package: {
name: 'a',
version: '1.2.3',
bundledDependencies: false,
dependencies: {
b: '1.2.3',
d: '1.2.3',
},
},
b: {
d: { $package: {
name: 'd',
version: '1.2.3',
bundleDependencies: false,
dependencies: {
e: '1.2.3',
},
} },
$package: {
name: 'b',
version: '1.2.3',
dependencies: {
c: '1.2.3',
d: '1.2.3',
},
},
},
c: { $package: {
name: 'c',
version: '1.2.3',
} },
d: { $package: {
name: 'd',
version: '1.2.3',
dependencies: {
c: '1.2.3',
},
} },
e: { $package: {
name: 'e',
version: '1.2.3',
} },
})
const walk = require('../')
const check = (result, t) => {
t.same(result, [])
t.end()
}
t.test('sync', t => check(walk.sync({ path: pkg }), t))
t.test('async', t => walk({ path: pkg }).then(res => check(res, t)))
npm-bundled-2.0.1/test/non-array-bundledeps.js 0000664 0000000 0000000 00000001716 14301751560 0021274 0 ustar 00root root 0000000 0000000 const t = require('tap')
const pkg = require('./pkgtree')(t, {
$package: {
name: 'a',
version: '1.2.3',
dependencies: {
b: '1.2.3',
d: '1.2.3',
},
bundledDependencies: {
b: '1.2.3',
},
},
b: {
d: { $package: {
name: 'd',
version: '1.2.3',
dependencies: {
e: '1.2.3',
},
} },
$package: {
name: 'b',
version: '1.2.3',
dependencies: {
c: '1.2.3',
d: '1.2.3',
},
},
},
c: { $package: {
name: 'c',
version: '1.2.3',
} },
d: { $package: {
name: 'd',
version: '1.2.3',
dependencies: {
c: '1.2.3',
},
} },
e: { $package: {
name: 'e',
version: '1.2.3',
} },
})
const walk = require('../')
const check = (result, t) => {
t.same(result, ['b', 'c', 'e'])
t.end()
}
t.test('sync', t => check(walk.sync({ path: pkg }), t))
t.test('async', t => walk({ path: pkg }).then(res => check(res, t)))
npm-bundled-2.0.1/test/pkgtree.js 0000664 0000000 0000000 00000001100 14301751560 0016667 0 ustar 00root root 0000000 0000000 'use strict'
// create a package tree for a test
// pass in the test object to rm on teardown
const generateTestdir = (tree) => {
return Object.entries(tree).reduce((acc, [dep, pkg]) => {
if (dep === '$package') {
acc['package.json'] = pkg.invalid
? '💩'
: (JSON.stringify(pkg, null, 2) + '\n')
} else {
acc.node_modules[dep] = generateTestdir(pkg)
}
return acc
}, { node_modules: {} })
}
module.exports = (t, tree) => t.testdir(generateTestdir(tree))
if (require.main === module) {
require('tap').pass('this is fine')
}
npm-bundled-2.0.1/test/readdir-fail.js 0000664 0000000 0000000 00000002125 14301751560 0017561 0 ustar 00root root 0000000 0000000 const t = require('tap')
const mutateFS = require('mutate-fs')
const pkg = require('./pkgtree')(t, {
$package: {
name: 'a',
version: '1.2.3',
dependencies: {
b: '1.2.3',
d: '1.2.3',
},
bundledDependencies: ['b'],
},
b: {
d: { $package: {
name: 'd',
version: '1.2.3',
dependencies: {
e: '1.2.3',
},
} },
$package: {
name: 'b',
version: '1.2.3',
dependencies: {
c: '1.2.3',
d: '1.2.3',
},
},
},
c: { $package: {
name: 'c',
version: '1.2.3',
} },
d: { $package: {
name: 'd',
version: '1.2.3',
dependencies: {
c: '1.2.3',
},
} },
e: { $package: {
name: 'e',
version: '1.2.3',
} },
})
const walk = require('../')
const check = (result, t) => {
t.same(result, [])
t.end()
}
t.test('fail the readdir', t => {
const poop = new Error('poop')
t.teardown(mutateFS.fail('readdir', poop))
t.test('sync', t => check(walk.sync({ path: pkg }), t))
t.test('async', t => walk({ path: pkg }).then(res => check(res, t)))
t.end()
})
npm-bundled-2.0.1/test/scoped.js 0000664 0000000 0000000 00000002000 14301751560 0016503 0 ustar 00root root 0000000 0000000 const t = require('tap')
const pkg = require('./pkgtree')(t, {
$package: {
name: '@a/a',
version: '1.2.3',
dependencies: {
'@x/b': '1.2.3',
'@y/d': '1.2.3',
},
bundledDependencies: ['@x/b'],
},
'@x/b': {
'@y/d': { $package: {
name: '@y/d',
version: '1.2.3',
dependencies: {
e: '1.2.3',
},
} },
$package: {
name: '@x/b',
version: '1.2.3',
dependencies: {
'@q/c': '1.2.3',
'@y/d': '1.2.3',
},
},
},
'@q/c': { $package: {
name: '@q/c',
version: '1.2.3',
} },
'@y/d': { $package: {
name: '@y/d',
version: '1.2.3',
dependencies: {
'@q/c': '1.2.3',
},
} },
e: { $package: {
name: 'e',
version: '1.2.3',
} },
})
const walk = require('../')
const check = (result, t) => {
t.same(result, ['@x/b', '@q/c', 'e'])
t.end()
}
t.test('sync', t => check(walk.sync({ path: pkg }), t))
t.test('async', t => walk({ path: pkg }, (er, res) => check(res, t)))
npm-bundled-2.0.1/test/weird-scope.js 0000664 0000000 0000000 00000002445 14301751560 0017464 0 ustar 00root root 0000000 0000000 const t = require('tap')
const pkg = require('./pkgtree')(t, {
$package: {
name: '@a/a',
version: '1.2.3',
dependencies: {
'@x/b': '1.2.3',
'@y/d': '1.2.3',
'@weird/asdf': '1.2.3',
'@missing/scope': '1.2.3',
},
bundleDependencies: ['@x/b', '@weird/asdf', '@missing/scope'],
},
'@x/b': {
'@y/d': { $package: {
name: '@y/d',
version: '1.2.3',
dependencies: {
e: '1.2.3',
},
} },
$package: {
name: '@x/b',
version: '1.2.3',
dependencies: {
'@q/c': '1.2.3',
'@y/d': '1.2.3',
},
},
},
'@q/c': { $package: {
name: '@q/c',
version: '1.2.3',
} },
'@y/d': { $package: {
name: '@y/d',
version: '1.2.3',
dependencies: {
'@q/c': '1.2.3',
},
} },
e: { $package: {
name: 'e',
version: '1.2.3',
} },
})
// put a weird not-package thing in a node_modules @-scope "folder"
const fs = require('fs')
fs.writeFileSync(pkg + '/node_modules/@weird', 'not a dir')
fs.mkdirSync(pkg + '/node_modules/@missing')
const walk = require('../')
const check = (result, t) => {
t.same(result, ['@x/b', '@q/c', 'e'])
t.end()
}
t.test('sync', t => check(walk.sync({ path: pkg }), t))
t.test('async', t => walk({ path: pkg }).then(res => check(res, t)))