pax_global_header00006660000000000000000000000064143010012370014501gustar00rootroot0000000000000052 comment=3a177d6b0d0063855612510c81ff9e2191517cde
npm-normalize-package-bin-2.0.0/000077500000000000000000000000001430100123700164275ustar00rootroot00000000000000npm-normalize-package-bin-2.0.0/.commitlintrc.js000066400000000000000000000005531430100123700215520ustar00rootroot00000000000000/* 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-normalize-package-bin-2.0.0/.eslintrc.js000066400000000000000000000005451430100123700206720ustar00rootroot00000000000000/* 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-normalize-package-bin-2.0.0/.github/000077500000000000000000000000001430100123700177675ustar00rootroot00000000000000npm-normalize-package-bin-2.0.0/.github/CODEOWNERS000066400000000000000000000001321430100123700213560ustar00rootroot00000000000000# This file is automatically added by @npmcli/template-oss. Do not edit.
* @npm/cli-team
npm-normalize-package-bin-2.0.0/.github/ISSUE_TEMPLATE/000077500000000000000000000000001430100123700221525ustar00rootroot00000000000000npm-normalize-package-bin-2.0.0/.github/ISSUE_TEMPLATE/bug.yml000066400000000000000000000026551430100123700234620ustar00rootroot00000000000000# 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-normalize-package-bin-2.0.0/.github/ISSUE_TEMPLATE/config.yml�����������������������������������0000664�0000000�0000000�00000000145�14301001237�0024142�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# This file is automatically added by @npmcli/template-oss. Do not edit.
blank_issues_enabled: true
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-normalize-package-bin-2.0.0/.github/dependabot.yml����������������������������������������������0000664�0000000�0000000�00000000565�14301001237�0022625�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-normalize-package-bin-2.0.0/.github/settings.yml������������������������������������������������0000664�0000000�0000000�00000000055�14301001237�0022352�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������---
_extends: '.github:npm-cli/settings.yml'
�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-normalize-package-bin-2.0.0/.github/workflows/��������������������������������������������������0000775�0000000�0000000�00000000000�14301001237�0022024�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-normalize-package-bin-2.0.0/.github/workflows/audit.yml�����������������������������������������0000664�0000000�0000000�00000001370�14301001237�0023656�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-normalize-package-bin-2.0.0/.github/workflows/ci.yml��������������������������������������������0000664�0000000�0000000�00000005114�14301001237�0023143�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-normalize-package-bin-2.0.0/.github/workflows/codeql-analysis.yml�������������������������������0000664�0000000�0000000�00000002001�14301001237�0025630�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-normalize-package-bin-2.0.0/.github/workflows/post-dependabot.yml�������������������������������0000664�0000000�0000000�00000002641�14301001237�0025642�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-normalize-package-bin-2.0.0/.github/workflows/pull-request.yml����������������������������������0000664�0000000�0000000�00000002143�14301001237�0025211�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-normalize-package-bin-2.0.0/.github/workflows/release-please.yml��������������������������������0000664�0000000�0000000�00000001314�14301001237�0025435�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-normalize-package-bin-2.0.0/.gitignore����������������������������������������������������������0000664�0000000�0000000�00000000570�14301001237�0020421�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-normalize-package-bin-2.0.0/.npmrc��������������������������������������������������������������0000664�0000000�0000000�00000000135�14301001237�0017546�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������; This file is automatically added by @npmcli/template-oss. Do not edit.
package-lock=false
�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-normalize-package-bin-2.0.0/CHANGELOG.md��������������������������������������������������������0000664�0000000�0000000�00000001112�14301001237�0020233�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Changelog
## [2.0.0](https://github.com/npm/npm-normalize-package-bin/compare/v1.0.1...v2.0.0) (2022-08-22)
### ⚠ BREAKING CHANGES
* make node engines ^12.13.0 || ^14.15.0 || >=16.0.0
### Bug Fixes
* replace deprecated String.prototype.substr() ([f7f3bc4](https://github.com/npm/npm-normalize-package-bin/commit/f7f3bc441299c755b25ebbd08e919c2da86f314e))
### Dependencies
* @npmcli/template-oss ([#12](https://github.com/npm/npm-normalize-package-bin/issues/12)) ([45a35c3](https://github.com/npm/npm-normalize-package-bin/commit/45a35c3d3ce0fb75247a4411a9ad03cac694bae4))
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-normalize-package-bin-2.0.0/CODE_OF_CONDUCT.md��������������������������������������������������0000664�0000000�0000000�00000000507�14301001237�0021230�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->
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-normalize-package-bin-2.0.0/LICENSE�������������������������������������������������������������0000664�0000000�0000000�00000001343�14301001237�0017435�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������The ISC License
Copyright (c) npm, Inc.
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-normalize-package-bin-2.0.0/README.md�����������������������������������������������������������0000664�0000000�0000000�00000000616�14301001237�0017711�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# npm-normalize-package-bin
Turn any flavor of allowable package.json bin into a normalized object.
## API
```js
const normalize = require('npm-normalize-package-bin')
const pkg = {name: 'foo', bin: 'bar'}
console.log(normalize(pkg)) // {name:'foo', bin:{foo: 'bar'}}
```
Also strips out weird dots and slashes to prevent accidental and/or
malicious bad behavior when the package is installed.
������������������������������������������������������������������������������������������������������������������npm-normalize-package-bin-2.0.0/SECURITY.md���������������������������������������������������������0000664�0000000�0000000�00000000246�14301001237�0020222�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->
Please send vulnerability reports through [hackerone](https://hackerone.com/github).
����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-normalize-package-bin-2.0.0/lib/����������������������������������������������������������������0000775�0000000�0000000�00000000000�14301001237�0017175�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-normalize-package-bin-2.0.0/lib/index.js��������������������������������������������������������0000664�0000000�0000000�00000002456�14301001237�0020651�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������// pass in a manifest with a 'bin' field here, and it'll turn it
// into a properly santized bin object
const { join, basename } = require('path')
const normalize = pkg =>
!pkg.bin ? removeBin(pkg)
: typeof pkg.bin === 'string' ? normalizeString(pkg)
: Array.isArray(pkg.bin) ? normalizeArray(pkg)
: typeof pkg.bin === 'object' ? normalizeObject(pkg)
: removeBin(pkg)
const normalizeString = pkg => {
if (!pkg.name) {
return removeBin(pkg)
}
pkg.bin = { [pkg.name]: pkg.bin }
return normalizeObject(pkg)
}
const normalizeArray = pkg => {
pkg.bin = pkg.bin.reduce((acc, k) => {
acc[basename(k)] = k
return acc
}, {})
return normalizeObject(pkg)
}
const removeBin = pkg => {
delete pkg.bin
return pkg
}
const normalizeObject = pkg => {
const orig = pkg.bin
const clean = {}
let hasBins = false
Object.keys(orig).forEach(binKey => {
const base = join('/', basename(binKey.replace(/\\|:/g, '/'))).slice(1)
if (typeof orig[binKey] !== 'string' || !base) {
return
}
const binTarget = join('/', orig[binKey])
.replace(/\\/g, '/').slice(1)
if (!binTarget) {
return
}
clean[base] = binTarget
hasBins = true
})
if (hasBins) {
pkg.bin = clean
} else {
delete pkg.bin
}
return pkg
}
module.exports = normalize
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-normalize-package-bin-2.0.0/package.json��������������������������������������������������������0000664�0000000�0000000�00000002207�14301001237�0020716�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{
"name": "npm-normalize-package-bin",
"version": "2.0.0",
"description": "Turn any flavor of allowable package.json bin into a normalized object",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "https://github.com/npm/npm-normalize-package-bin.git"
},
"author": "GitHub Inc.",
"license": "ISC",
"scripts": {
"test": "tap",
"snap": "tap",
"preversion": "npm test",
"postversion": "npm publish",
"postpublish": "git push origin --follow-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",
"posttest": "npm run lint"
},
"devDependencies": {
"@npmcli/eslint-config": "^3.1.0",
"@npmcli/template-oss": "3.5.0",
"tap": "^16.3.0"
},
"files": [
"bin/",
"lib/"
],
"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-normalize-package-bin-2.0.0/test/���������������������������������������������������������������0000775�0000000�0000000�00000000000�14301001237�0017406�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-normalize-package-bin-2.0.0/test/array.js�������������������������������������������������������0000664�0000000�0000000�00000002537�14301001237�0021071�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������const normalize = require('../')
const t = require('tap')
t.test('benign array', async t => {
const pkg = { name: 'hello', version: 'world', bin: ['./x/y', 'y/z', './a'] }
const expect = { name: 'hello',
version: 'world',
bin: {
y: 'x/y',
z: 'y/z',
a: 'a',
} }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('conflicting array', async t => {
const pkg = { name: 'hello', version: 'world', bin: ['./x/y', 'z/y', './a'] }
const expect = { name: 'hello',
version: 'world',
bin: {
y: 'z/y',
a: 'a',
} }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('slashy array', async t => {
const pkg = { name: 'hello', version: 'world', bin: ['/etc/passwd'] }
const expect = { name: 'hello', version: 'world', bin: { passwd: 'etc/passwd' } }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('dotty array', async t => {
const pkg = { name: 'hello', version: 'world', bin: ['../../../../etc/passwd'] }
const expect = { name: 'hello', version: 'world', bin: { passwd: 'etc/passwd' } }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
�����������������������������������������������������������������������������������������������������������������������������������������������������������������npm-normalize-package-bin-2.0.0/test/nobin.js�������������������������������������������������������0000664�0000000�0000000�00000002343�14301001237�0021053�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������const normalize = require('../')
const t = require('tap')
// all of these just delete the bins, so expect the same value
const expect = { name: 'hello', version: 'world' }
t.test('no bin in object', async t => {
const pkg = { name: 'hello', version: 'world' }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('empty string bin in object', async t => {
const pkg = { name: 'hello', version: 'world', bin: '' }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('false bin in object', async t => {
const pkg = { name: 'hello', version: 'world', bin: false }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('null bin in object', async t => {
const pkg = { name: 'hello', version: 'world', bin: null }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('number bin', async t => {
const pkg = { name: 'hello', version: 'world', bin: 42069 }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-normalize-package-bin-2.0.0/test/object.js������������������������������������������������������0000664�0000000�0000000�00000007241�14301001237�0021216�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������const normalize = require('../')
const t = require('tap')
t.test('benign object', async t => {
// just clean up the ./ in the targets and remove anything weird
const pkg = { name: 'hello',
version: 'world',
bin: {
y: './x/y',
z: './y/z',
a: './a',
} }
const expect = { name: 'hello',
version: 'world',
bin: {
y: 'x/y',
z: 'y/z',
a: 'a',
} }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('empty and non-string targets', async t => {
// just clean up the ./ in the targets and remove anything weird
const pkg = { name: 'hello',
version: 'world',
bin: {
z: './././',
y: '',
'./x': 'x.js',
re: /asdf/,
foo: { bar: 'baz' },
false: false,
null: null,
array: [1, 2, 3],
func: function () {},
} }
const expect = { name: 'hello',
version: 'world',
bin: {
x: 'x.js',
} }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('slashy object', async t => {
const pkg = { name: 'hello',
version: 'world',
bin: {
'/path/foo': '/etc/passwd',
bar: '/etc/passwd',
'/etc/glorb/baz': '/etc/passwd',
'/etc/passwd:/bin/usr/exec': '/etc/passwd',
} }
const expect = {
name: 'hello',
version: 'world',
bin: {
foo: 'etc/passwd',
bar: 'etc/passwd',
baz: 'etc/passwd',
exec: 'etc/passwd',
},
}
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('dotty object', async t => {
const pkg = {
name: 'hello',
version: 'world',
bin: {
nodots: '../../../../etc/passwd',
'../../../../../../dots': '../../../../etc/passwd',
'.././../\\./..//C:\\./': 'this is removed',
'.././../\\./..//C:\\/': 'super safe programming language',
'.././../\\./..//C:\\x\\y\\z/': 'xyz',
} }
const expect = { name: 'hello',
version: 'world',
bin: {
nodots: 'etc/passwd',
dots: 'etc/passwd',
C: 'super safe programming language',
z: 'xyz',
} }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('weird object', async t => {
const pkg = { name: 'hello', version: 'world', bin: /asdf/ }
const expect = { name: 'hello', version: 'world' }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('oddball keys', async t => {
const pkg = {
bin: {
'~': 'target',
'£': 'target',
ζ: 'target',
ぎ: 'target',
操: 'target',
'🎱': 'target',
'💎': 'target',
'💸': 'target',
'🦉': 'target',
'сheck-dom': 'target',
Ωpm: 'target',
ζλ: 'target',
мга: 'target',
пше: 'target',
тзч: 'target',
тзь: 'target',
нфкт: 'target',
ссср: 'target',
君の名は: 'target',
},
}
const expect = {
bin: {
'~': 'target',
'£': 'target',
ζ: 'target',
ぎ: 'target',
操: 'target',
'🎱': 'target',
'💎': 'target',
'💸': 'target',
'🦉': 'target',
'сheck-dom': 'target',
Ωpm: 'target',
ζλ: 'target',
мга: 'target',
пше: 'target',
тзч: 'target',
тзь: 'target',
нфкт: 'target',
ссср: 'target',
君の名は: 'target',
},
}
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-normalize-package-bin-2.0.0/test/string.js������������������������������������������������������0000664�0000000�0000000�00000002762�14301001237�0021261�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������const normalize = require('../')
const t = require('tap')
t.test('benign string', async t => {
const pkg = { name: 'hello', version: 'world', bin: 'hello.js' }
const expect = { name: 'hello', version: 'world', bin: { hello: 'hello.js' } }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('slashy string', async t => {
const pkg = { name: 'hello', version: 'world', bin: '/etc/passwd' }
const expect = { name: 'hello', version: 'world', bin: { hello: 'etc/passwd' } }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('dotty string', async t => {
const pkg = { name: 'hello', version: 'world', bin: '../../../../etc/passwd' }
const expect = { name: 'hello', version: 'world', bin: { hello: 'etc/passwd' } }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('double path', async t => {
const pkg = { name: 'hello', version: 'world', bin: '/etc/passwd:/bin/usr/exec' }
const expect = { name: 'hello', version: 'world', bin: { hello: 'etc/passwd:/bin/usr/exec' } }
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
t.test('string with no name', async t => {
const pkg = { bin: 'foobar.js' }
const expect = {}
t.strictSame(normalize(pkg), expect)
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
})
��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������