pax_global_header 0000666 0000000 0000000 00000000064 14301230170 0014501 g ustar 00root root 0000000 0000000 52 comment=dfb8dff4281d3c78921854c556210dd441b78d21
read-package-json-5.0.2/ 0000775 0000000 0000000 00000000000 14301230170 0014760 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/.commitlintrc.js 0000664 0000000 0000000 00000000553 14301230170 0020103 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']],
},
}
read-package-json-5.0.2/.eslintrc.js 0000664 0000000 0000000 00000000545 14301230170 0017223 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,
],
}
read-package-json-5.0.2/.eslintrc.local.json 0000664 0000000 0000000 00000000055 14301230170 0020645 0 ustar 00root root 0000000 0000000 {
"ignorePatterns": ["test/fixtures/**"]
}
read-package-json-5.0.2/.github/ 0000775 0000000 0000000 00000000000 14301230170 0016320 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/.github/CODEOWNERS 0000664 0000000 0000000 00000000132 14301230170 0017707 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
* @npm/cli-team
read-package-json-5.0.2/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 14301230170 0020503 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/.github/ISSUE_TEMPLATE/bug.yml 0000664 0000000 0000000 00000002655 14301230170 0022013 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
read-package-json-5.0.2/.github/ISSUE_TEMPLATE/config.yml 0000664 0000000 0000000 00000000145 14301230170 0022473 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
blank_issues_enabled: true
read-package-json-5.0.2/.github/dependabot.yml 0000664 0000000 0000000 00000000565 14301230170 0021156 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"
read-package-json-5.0.2/.github/matchers/ 0000775 0000000 0000000 00000000000 14301230170 0020126 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/.github/matchers/tap.json 0000664 0000000 0000000 00000001203 14301230170 0021601 0 ustar 00root root 0000000 0000000 {
"//@npmcli/template-oss": "This file is automatically added by @npmcli/template-oss. Do not edit.",
"problemMatcher": [
{
"owner": "tap",
"pattern": [
{
"regexp": "^\\s*not ok \\d+ - (.*)",
"message": 1
},
{
"regexp": "^\\s*---"
},
{
"regexp": "^\\s*at:"
},
{
"regexp": "^\\s*line:\\s*(\\d+)",
"line": 1
},
{
"regexp": "^\\s*column:\\s*(\\d+)",
"column": 1
},
{
"regexp": "^\\s*file:\\s*(.*)",
"file": 1
}
]
}
]
} read-package-json-5.0.2/.github/settings.yml 0000664 0000000 0000000 00000000055 14301230170 0020703 0 ustar 00root root 0000000 0000000 ---
_extends: '.github:npm-cli/settings.yml'
read-package-json-5.0.2/.github/workflows/ 0000775 0000000 0000000 00000000000 14301230170 0020355 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/.github/workflows/audit.yml 0000664 0000000 0000000 00000001407 14301230170 0022210 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 08:00 UTC (01:00 PT) on Monday" https://crontab.guru/#0_8_*_*_1
- cron: "0 8 * * 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
read-package-json-5.0.2/.github/workflows/ci.yml 0000664 0000000 0000000 00000005276 14301230170 0021505 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 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1
- cron: "0 9 * * 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
- name: add tap problem matcher
run: echo "::add-matcher::.github/matchers/tap.json"
- run: npm i --ignore-scripts --no-audit --no-fund
- run: npm test --ignore-scripts
read-package-json-5.0.2/.github/workflows/codeql-analysis.yml 0000664 0000000 0000000 00000002022 14301230170 0024164 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 10:00 UTC (03:00 PT) on Monday" https://crontab.guru/#0_10_*_*_1
- cron: "0 10 * * 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
read-package-json-5.0.2/.github/workflows/post-dependabot.yml 0000664 0000000 0000000 00000002641 14301230170 0024173 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
read-package-json-5.0.2/.github/workflows/pull-request.yml 0000664 0000000 0000000 00000002143 14301230170 0023542 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
read-package-json-5.0.2/.github/workflows/release-please.yml 0000664 0000000 0000000 00000001314 14301230170 0023766 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}
]
read-package-json-5.0.2/.gitignore 0000664 0000000 0000000 00000000570 14301230170 0016752 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
read-package-json-5.0.2/.npmrc 0000664 0000000 0000000 00000000135 14301230170 0016077 0 ustar 00root root 0000000 0000000 ; This file is automatically added by @npmcli/template-oss. Do not edit.
package-lock=false
read-package-json-5.0.2/CHANGELOG.md 0000664 0000000 0000000 00000010122 14301230170 0016565 0 ustar 00root root 0000000 0000000 # Changelog
# [4.0.0](https://github.com/npm/read-package-json/compare/v3.0.1...v4.0.0) (2021-08-18)
### Bug Fixes
* **parseError:** use file not path attribute ([5002e00](https://github.com/npm/read-package-json/commit/5002e00))
### BREAKING CHANGES
* **parseError:** rename file attribute to path
In order to align with the way our other "fast" json parsers work the
err.file attribute needs to be renamed to err.path.
Also other errors i.e. ENOENT attach a path attribute.
## [5.0.2](https://github.com/npm/read-package-json/compare/v5.0.1...v5.0.2) (2022-08-23)
### Dependencies
* bump npm-normalize-package-bin from 1.0.1 to 2.0.0 ([#129](https://github.com/npm/read-package-json/issues/129)) ([6ce5501](https://github.com/npm/read-package-json/commit/6ce55010e88f83a4d59097e5583e4a8715260a63))
### [5.0.1](https://github.com/npm/read-package-json/compare/v5.0.0...v5.0.1) (2022-04-20)
### Dependencies
* bump glob from 7.2.0 to 8.0.1 ([#124](https://github.com/npm/read-package-json/issues/124)) ([ddd4a2a](https://github.com/npm/read-package-json/commit/ddd4a2aecb327c0884e7d6641f20255abcc464c6))
## [5.0.0](https://www.github.com/npm/read-package-json/compare/v4.1.2...v5.0.0) (2022-03-15)
### ⚠ BREAKING CHANGES
* This drops support for node10 and non-LTS versions of node12 and node14
### Bug Fixes
* always use / in package.json paths ([18cc3fa](https://www.github.com/npm/read-package-json/commit/18cc3faafae4aa39d5c5243feb5240a55da64965))
* move files to lib ([bd7fac4](https://www.github.com/npm/read-package-json/commit/bd7fac4862a6f230bc0e37b3483079cf9a49c275))
* @npmcli/template-oss@2.9.2 ([2122bc2](https://www.github.com/npm/read-package-json/commit/2122bc20231dfd0d6cee85e014e118f12192cdfc))
### Dependencies
* bump normalize-package-data from 3.0.3 to 4.0.0 ([#113](https://www.github.com/npm/read-package-json/issues/113)) ([b905443](https://www.github.com/npm/read-package-json/commit/b90544351fea84cf557572509129e84c06e8be45))
* update glob requirement from ^7.1.1 to ^7.2.0 ([#115](https://www.github.com/npm/read-package-json/issues/115)) ([35482c4](https://www.github.com/npm/read-package-json/commit/35482c48afde7d7d3fc647416acfb30a9c753b1d))
* update json-parse-even-better-errors requirement ([#116](https://www.github.com/npm/read-package-json/issues/116)) ([1b1b3f0](https://www.github.com/npm/read-package-json/commit/1b1b3f0a979d1f6cd4a46b86b21abe020d849052))
* update npm-normalize-package-bin requirement from ^1.0.0 to ^1.0.1 ([#114](https://www.github.com/npm/read-package-json/issues/114)) ([d1f64a5](https://www.github.com/npm/read-package-json/commit/d1f64a5d8250cc96df2f21200f92c5633418b33e))
## [3.0.1](https://github.com/npm/read-package-json/compare/v3.0.0...v3.0.1) (2021-02-22)
### Bug Fixes
* Strip underscore prefixed fields from file contents ([ac771d8](https://github.com/npm/read-package-json/commit/ac771d8))
# [3.0.0](https://github.com/npm/read-package-json/compare/v2.1.2...v3.0.0) (2020-10-13)
### Bug Fixes
* check-in updated lockfile ([19d9fbe](https://github.com/npm/read-package-json/commit/19d9fbe))
## [2.1.2](https://github.com/npm/read-package-json/compare/v2.1.1...v2.1.2) (2020-08-20)
### Bug Fixes
* even better json errors, remove graceful-fs ([fdbf082](https://github.com/npm/read-package-json/commit/fdbf082))
## [2.1.1](https://github.com/npm/read-package-json/compare/v2.1.0...v2.1.1) (2019-12-09)
### Bug Fixes
* normalize and sanitize pkg bin entries ([b8cb5fa](https://github.com/npm/read-package-json/commit/b8cb5fa))
# [2.1.0](https://github.com/npm/read-package-json/compare/v2.0.13...v2.1.0) (2019-08-13)
### Features
* support bundleDependencies: true ([76f6f42](https://github.com/npm/read-package-json/commit/76f6f42))
## [2.0.13](https://github.com/npm/read-package-json/compare/v2.0.12...v2.0.13) (2018-03-08)
### Bug Fixes
* **git:** support git packed refs --all mode ([#77](https://github.com/npm/read-package-json/issues/77)) ([1869940](https://github.com/npm/read-package-json/commit/1869940))
read-package-json-5.0.2/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000000507 14301230170 0017561 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.
read-package-json-5.0.2/LICENSE 0000664 0000000 0000000 00000001354 14301230170 0015770 0 ustar 00root root 0000000 0000000 The ISC License
Copyright (c) Isaac Z. Schlueter
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.
read-package-json-5.0.2/README.md 0000664 0000000 0000000 00000011206 14301230170 0016237 0 ustar 00root root 0000000 0000000 # read-package-json
This is the thing that npm uses to read package.json files. It
validates some stuff, and loads some default things.
It keeps a cache of the files you've read, so that you don't end
up reading the same package.json file multiple times.
Note that if you just want to see what's literally in the package.json
file, you can usually do `var data = require('some-module/package.json')`.
This module is basically only needed by npm, but it's handy to see what
npm will see when it looks at your package.
## Usage
```javascript
var readJson = require('read-package-json')
// readJson(filename, [logFunction=noop], [strict=false], cb)
readJson('/path/to/package.json', console.error, false, function (er, data) {
if (er) {
console.error("There was an error reading the file")
return
}
console.error('the package data is', data)
});
```
## readJson(file, [logFn = noop], [strict = false], cb)
* `file` {String} The path to the package.json file
* `logFn` {Function} Function to handle logging. Defaults to a noop.
* `strict` {Boolean} True to enforce SemVer 2.0 version strings, and
other strict requirements.
* `cb` {Function} Gets called with `(er, data)`, as is The Node Way.
Reads the JSON file and does the things.
## `package.json` Fields
See `man 5 package.json` or `npm help json`.
## readJson.log
By default this is a reference to the `npmlog` module. But if that
module can't be found, then it'll be set to just a dummy thing that does
nothing.
Replace with your own `{log,warn,error}` object for fun loggy time.
## readJson.extras(file, data, cb)
Run all the extra stuff relative to the file, with the parsed data.
Modifies the data as it does stuff. Calls the cb when it's done.
## readJson.extraSet = [fn, fn, ...]
Array of functions that are called by `extras`. Each one receives the
arguments `fn(file, data, cb)` and is expected to call `cb(er, data)`
when done or when an error occurs.
Order is indeterminate, so each function should be completely
independent.
Mix and match!
## Other Relevant Files Besides `package.json`
Some other files have an effect on the resulting data object, in the
following ways:
### `README?(.*)`
If there is a `README` or `README.*` file present, then npm will attach
a `readme` field to the data with the contents of this file.
Owing to the fact that roughly 100% of existing node modules have
Markdown README files, it will generally be assumed to be Markdown,
regardless of the extension. Please plan accordingly.
### `server.js`
If there is a `server.js` file, and there is not already a
`scripts.start` field, then `scripts.start` will be set to `node
server.js`.
### `AUTHORS`
If there is not already a `contributors` field, then the `contributors`
field will be set to the contents of the `AUTHORS` file, split by lines,
and parsed.
### `bindings.gyp`
If a bindings.gyp file exists, and there is not already a
`scripts.install` field, then the `scripts.install` field will be set to
`node-gyp rebuild`.
### `index.js`
If the json file does not exist, but there is a `index.js` file
present instead, and that file has a package comment, then it will try
to parse the package comment, and use that as the data instead.
A package comment looks like this:
```javascript
/**package
* { "name": "my-bare-module"
* , "version": "1.2.3"
* , "description": "etc...." }
**/
// or...
/**package
{ "name": "my-bare-module"
, "version": "1.2.3"
, "description": "etc...." }
**/
```
The important thing is that it starts with `/**package`, and ends with
`**/`. If the package.json file exists, then the index.js is not
parsed.
### `{directories.man}/*.[0-9]`
If there is not already a `man` field defined as an array of files or a
single file, and
there is a `directories.man` field defined, then that directory will
be searched for manpages.
Any valid manpages found in that directory will be assigned to the `man`
array, and installed in the appropriate man directory at package install
time, when installed globally on a Unix system.
### `{directories.bin}/*`
If there is not already a `bin` field defined as a string filename or a
hash of ` : ` pairs, then the `directories.bin`
directory will be searched and all the files within it will be linked as
executables at install time.
When installing locally, npm links bins into `node_modules/.bin`, which
is in the `PATH` environ when npm runs scripts. When
installing globally, they are linked into `{prefix}/bin`, which is
presumably in the `PATH` environment variable.
### `types` field
If you do not have a `types` field, then it will check if a
corresponding `*.d.ts` file exists for your package entry file and add
it to the `package.json`.
read-package-json-5.0.2/SECURITY.md 0000664 0000000 0000000 00000000246 14301230170 0016553 0 ustar 00root root 0000000 0000000
Please send vulnerability reports through [hackerone](https://hackerone.com/github).
read-package-json-5.0.2/lib/ 0000775 0000000 0000000 00000000000 14301230170 0015526 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/lib/read-json.js 0000664 0000000 0000000 00000032664 14301230170 0017761 0 ustar 00root root 0000000 0000000 var fs = require('fs')
var path = require('path')
var glob = require('glob')
var normalizeData = require('normalize-package-data')
var safeJSON = require('json-parse-even-better-errors')
var util = require('util')
var normalizePackageBin = require('npm-normalize-package-bin')
module.exports = readJson
// put more stuff on here to customize.
readJson.extraSet = [
bundleDependencies,
gypfile,
serverjs,
scriptpath,
authors,
readme,
mans,
bins,
githead,
fillTypes,
]
var typoWarned = {}
var cache = {}
function readJson (file, log_, strict_, cb_) {
var log, strict, cb
for (var i = 1; i < arguments.length - 1; i++) {
if (typeof arguments[i] === 'boolean') {
strict = arguments[i]
} else if (typeof arguments[i] === 'function') {
log = arguments[i]
}
}
if (!log) {
log = function () {}
}
cb = arguments[arguments.length - 1]
readJson_(file, log, strict, cb)
}
function readJson_ (file, log, strict, cb) {
fs.readFile(file, 'utf8', function (er, d) {
parseJson(file, er, d, log, strict, cb)
})
}
function stripBOM (content) {
// Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
// because the buffer-to-string conversion in `fs.readFileSync()`
// translates it to FEFF, the UTF-16 BOM.
if (content.charCodeAt(0) === 0xFEFF) {
content = content.slice(1)
}
return content
}
function jsonClone (obj) {
if (obj == null) {
return obj
} else if (Array.isArray(obj)) {
var newarr = new Array(obj.length)
for (var ii in obj) {
newarr[ii] = obj[ii]
}
} else if (typeof obj === 'object') {
var newobj = {}
for (var kk in obj) {
newobj[kk] = jsonClone[kk]
}
} else {
return obj
}
}
function parseJson (file, er, d, log, strict, cb) {
if (er && er.code === 'ENOENT') {
return fs.stat(path.dirname(file), function (err, stat) {
if (!err && stat && !stat.isDirectory()) {
// ENOTDIR isn't used on Windows, but npm expects it.
er = Object.create(er)
er.code = 'ENOTDIR'
return cb(er)
} else {
return indexjs(file, er, log, strict, cb)
}
})
}
if (er) {
return cb(er)
}
if (cache[d]) {
return cb(null, jsonClone(cache[d]))
}
var data
try {
data = safeJSON(stripBOM(d))
for (var key in data) {
if (/^_/.test(key)) {
delete data[key]
}
}
} catch (jsonErr) {
data = parseIndex(d)
if (!data) {
return cb(parseError(jsonErr, file))
}
}
extrasCached(file, d, data, log, strict, cb)
}
function extrasCached (file, d, data, log, strict, cb) {
extras(file, data, log, strict, function (err, extrasData) {
if (!err) {
cache[d] = jsonClone(extrasData)
}
cb(err, extrasData)
})
}
function indexjs (file, er, log, strict, cb) {
if (path.basename(file) === 'index.js') {
return cb(er)
}
var index = path.resolve(path.dirname(file), 'index.js')
fs.readFile(index, 'utf8', function (er2, d) {
if (er2) {
return cb(er)
}
if (cache[d]) {
return cb(null, cache[d])
}
var data = parseIndex(d)
if (!data) {
return cb(er)
}
extrasCached(file, d, data, log, strict, cb)
})
}
readJson.extras = extras
function extras (file, data, log_, strict_, cb_) {
var log, strict, cb
for (var i = 2; i < arguments.length - 1; i++) {
if (typeof arguments[i] === 'boolean') {
strict = arguments[i]
} else if (typeof arguments[i] === 'function') {
log = arguments[i]
}
}
if (!log) {
log = function () {}
}
cb = arguments[i]
var set = readJson.extraSet
var n = set.length
var errState = null
set.forEach(function (fn) {
fn(file, data, then)
})
function then (er) {
if (errState) {
return
}
if (er) {
return cb(errState = er)
}
if (--n > 0) {
return
}
final(file, data, log, strict, cb)
}
}
function scriptpath (file, data, cb) {
if (!data.scripts) {
return cb(null, data)
}
var k = Object.keys(data.scripts)
k.forEach(scriptpath_, data.scripts)
cb(null, data)
}
function scriptpath_ (key) {
var s = this[key]
// This is never allowed, and only causes problems
if (typeof s !== 'string') {
return delete this[key]
}
var spre = /^(\.[/\\])?node_modules[/\\].bin[\\/]/
if (s.match(spre)) {
this[key] = this[key].replace(spre, '')
}
}
function gypfile (file, data, cb) {
var dir = path.dirname(file)
var s = data.scripts || {}
if (s.install || s.preinstall) {
return cb(null, data)
}
glob('*.gyp', { cwd: dir }, function (er, files) {
if (er) {
return cb(er)
}
if (data.gypfile === false) {
return cb(null, data)
}
gypfile_(file, data, files, cb)
})
}
function gypfile_ (file, data, files, cb) {
if (!files.length) {
return cb(null, data)
}
var s = data.scripts || {}
s.install = 'node-gyp rebuild'
data.scripts = s
data.gypfile = true
return cb(null, data)
}
function serverjs (file, data, cb) {
var dir = path.dirname(file)
var s = data.scripts || {}
if (s.start) {
return cb(null, data)
}
glob('server.js', { cwd: dir }, function (er, files) {
if (er) {
return cb(er)
}
serverjs_(file, data, files, cb)
})
}
function serverjs_ (file, data, files, cb) {
if (!files.length) {
return cb(null, data)
}
var s = data.scripts || {}
s.start = 'node server.js'
data.scripts = s
return cb(null, data)
}
function authors (file, data, cb) {
if (data.contributors) {
return cb(null, data)
}
var af = path.resolve(path.dirname(file), 'AUTHORS')
fs.readFile(af, 'utf8', function (er, ad) {
// ignore error. just checking it.
if (er) {
return cb(null, data)
}
authors_(file, data, ad, cb)
})
}
function authors_ (file, data, ad, cb) {
ad = ad.split(/\r?\n/g).map(function (line) {
return line.replace(/^\s*#.*$/, '').trim()
}).filter(function (line) {
return line
})
data.contributors = ad
return cb(null, data)
}
function readme (file, data, cb) {
if (data.readme) {
return cb(null, data)
}
var dir = path.dirname(file)
var globOpts = { cwd: dir, nocase: true, mark: true }
glob('{README,README.*}', globOpts, function (er, files) {
if (er) {
return cb(er)
}
// don't accept directories.
files = files.filter(function (filtered) {
return !filtered.match(/\/$/)
})
if (!files.length) {
return cb()
}
var fn = preferMarkdownReadme(files)
var rm = path.resolve(dir, fn)
readme_(file, data, rm, cb)
})
}
function preferMarkdownReadme (files) {
var fallback = 0
var re = /\.m?a?r?k?d?o?w?n?$/i
for (var i = 0; i < files.length; i++) {
if (files[i].match(re)) {
return files[i]
} else if (files[i].match(/README$/)) {
fallback = i
}
}
// prefer README.md, followed by README; otherwise, return
// the first filename (which could be README)
return files[fallback]
}
function readme_ (file, data, rm, cb) {
var rmfn = path.basename(rm)
fs.readFile(rm, 'utf8', function (er, rmData) {
// maybe not readable, or something.
if (er) {
return cb()
}
data.readme = rmData
data.readmeFilename = rmfn
return cb(er, data)
})
}
function mans (file, data, cb) {
let cwd = data.directories && data.directories.man
if (data.man || !cwd) {
return cb(null, data)
}
const dirname = path.dirname(file)
cwd = path.resolve(path.dirname(file), cwd)
glob('**/*.[0-9]', { cwd }, function (er, mansGlob) {
if (er) {
return cb(er)
}
data.man = mansGlob.map(man =>
path.relative(dirname, path.join(cwd, man)).split(path.sep).join('/')
)
return cb(null, data)
})
}
function bins (file, data, cb) {
data = normalizePackageBin(data)
var m = data.directories && data.directories.bin
if (data.bin || !m) {
return cb(null, data)
}
m = path.resolve(path.dirname(file), m)
glob('**', { cwd: m }, function (er, binsGlob) {
if (er) {
return cb(er)
}
bins_(file, data, binsGlob, cb)
})
}
function bins_ (file, data, binsGlob, cb) {
var m = (data.directories && data.directories.bin) || '.'
data.bin = binsGlob.reduce(function (acc, mf) {
if (mf && mf.charAt(0) !== '.') {
var f = path.basename(mf)
acc[f] = path.join(m, mf)
}
return acc
}, {})
return cb(null, normalizePackageBin(data))
}
function bundleDependencies (file, data, cb) {
var bd = 'bundleDependencies'
var bdd = 'bundledDependencies'
// normalize key name
if (data[bdd] !== undefined) {
if (data[bd] === undefined) {
data[bd] = data[bdd]
}
delete data[bdd]
}
if (data[bd] === false) {
delete data[bd]
} else if (data[bd] === true) {
data[bd] = Object.keys(data.dependencies || {})
} else if (data[bd] !== undefined && !Array.isArray(data[bd])) {
delete data[bd]
}
return cb(null, data)
}
function githead (file, data, cb) {
if (data.gitHead) {
return cb(null, data)
}
var dir = path.dirname(file)
var head = path.resolve(dir, '.git/HEAD')
fs.readFile(head, 'utf8', function (er, headData) {
if (er) {
var parent = path.dirname(dir)
if (parent === dir) {
return cb(null, data)
}
return githead(dir, data, cb)
}
githead_(data, dir, headData, cb)
})
}
function githead_ (data, dir, head, cb) {
if (!head.match(/^ref: /)) {
data.gitHead = head.trim()
return cb(null, data)
}
var headRef = head.replace(/^ref: /, '').trim()
var headFile = path.resolve(dir, '.git', headRef)
fs.readFile(headFile, 'utf8', function (er, headData) {
if (er || !headData) {
var packFile = path.resolve(dir, '.git/packed-refs')
return fs.readFile(packFile, 'utf8', function (readFileErr, refs) {
if (readFileErr || !refs) {
return cb(null, data)
}
refs = refs.split('\n')
for (var i = 0; i < refs.length; i++) {
var match = refs[i].match(/^([0-9a-f]{40}) (.+)$/)
if (match && match[2].trim() === headRef) {
data.gitHead = match[1]
break
}
}
return cb(null, data)
})
}
headData = headData.replace(/^ref: /, '').trim()
data.gitHead = headData
return cb(null, data)
})
}
/**
* Warn if the bin references don't point to anything. This might be better in
* normalize-package-data if it had access to the file path.
*/
function checkBinReferences_ (file, data, warn, cb) {
if (!(data.bin instanceof Object)) {
return cb()
}
var keys = Object.keys(data.bin)
var keysLeft = keys.length
if (!keysLeft) {
return cb()
}
function handleExists (relName, result) {
keysLeft--
if (!result) {
warn('No bin file found at ' + relName)
}
if (!keysLeft) {
cb()
}
}
keys.forEach(function (key) {
var dirName = path.dirname(file)
var relName = data.bin[key]
/* istanbul ignore if - impossible, bins have been normalized */
if (typeof relName !== 'string') {
var msg = 'Bin filename for ' + key +
' is not a string: ' + util.inspect(relName)
warn(msg)
delete data.bin[key]
handleExists(relName, true)
return
}
var binPath = path.resolve(dirName, relName)
fs.stat(binPath, (err) => handleExists(relName, !err))
})
}
function final (file, data, log, strict, cb) {
var pId = makePackageId(data)
function warn (msg) {
if (typoWarned[pId]) {
return
}
if (log) {
log('package.json', pId, msg)
}
}
try {
normalizeData(data, warn, strict)
} catch (error) {
return cb(error)
}
checkBinReferences_(file, data, warn, function () {
typoWarned[pId] = true
cb(null, data)
})
}
function fillTypes (file, data, cb) {
var index = data.main ? data.main : 'index.js'
if (typeof index !== 'string') {
return cb(new TypeError('The "main" attribute must be of type string.'))
}
// TODO exports is much more complicated than this in verbose format
// We need to support for instance
// "exports": {
// ".": [
// {
// "default": "./lib/npm.js"
// },
// "./lib/npm.js"
// ],
// "./package.json": "./package.json"
// },
// as well as conditional exports
// if (data.exports && typeof data.exports === 'string') {
// index = data.exports
// }
// if (data.exports && data.exports['.']) {
// index = data.exports['.']
// if (typeof index !== 'string') {
// }
// }
var extless =
path.join(path.dirname(index), path.basename(index, path.extname(index)))
var dts = `./${extless}.d.ts`
var dtsPath = path.join(path.dirname(file), dts)
var hasDTSFields = 'types' in data || 'typings' in data
if (!hasDTSFields && fs.existsSync(dtsPath)) {
data.types = dts.split(path.sep).join('/')
}
cb(null, data)
}
function makePackageId (data) {
var name = cleanString(data.name)
var ver = cleanString(data.version)
return name + '@' + ver
}
function cleanString (str) {
return (!str || typeof (str) !== 'string') ? '' : str.trim()
}
// /**package { "name": "foo", "version": "1.2.3", ... } **/
function parseIndex (data) {
data = data.split(/^\/\*\*package(?:\s|$)/m)
if (data.length < 2) {
return null
}
data = data[1]
data = data.split(/\*\*\/$/m)
if (data.length < 2) {
return null
}
data = data[0]
data = data.replace(/^\s*\*/mg, '')
try {
return safeJSON(data)
} catch (er) {
return null
}
}
function parseError (ex, file) {
var e = new Error('Failed to parse json\n' + ex.message)
e.code = 'EJSONPARSE'
e.path = file
return e
}
read-package-json-5.0.2/package.json 0000664 0000000 0000000 00000003054 14301230170 0017250 0 ustar 00root root 0000000 0000000 {
"name": "read-package-json",
"version": "5.0.2",
"author": "GitHub Inc.",
"description": "The thing npm uses to read package.json files with semantics and defaults and validation",
"repository": {
"type": "git",
"url": "https://github.com/npm/read-package-json.git"
},
"main": "lib/read-json.js",
"scripts": {
"prerelease": "npm t",
"postrelease": "npm publish && git push --follow-tags",
"release": "standard-version -s",
"test": "tap",
"npmclilint": "npmcli-lint",
"lint": "eslint \"**/*.js\"",
"lintfix": "npm run lint -- --fix",
"posttest": "npm run lint",
"postsnap": "npm run lintfix --",
"postlint": "template-oss-check",
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags",
"snap": "tap",
"template-oss-apply": "template-oss-apply --force"
},
"dependencies": {
"glob": "^8.0.1",
"json-parse-even-better-errors": "^2.3.1",
"normalize-package-data": "^4.0.0",
"npm-normalize-package-bin": "^2.0.0"
},
"devDependencies": {
"@npmcli/eslint-config": "^3.0.1",
"@npmcli/template-oss": "3.6.0",
"tap": "^16.0.1"
},
"license": "ISC",
"files": [
"bin/",
"lib/"
],
"engines": {
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
},
"tap": {
"branches": 68,
"functions": 83,
"lines": 76,
"statements": 77
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "3.6.0"
}
}
read-package-json-5.0.2/test/ 0000775 0000000 0000000 00000000000 14301230170 0015737 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/basic.js 0000664 0000000 0000000 00000002167 14301230170 0017364 0 ustar 00root root 0000000 0000000 var fs = require('fs')
var path = require('path')
var tap = require('tap')
var readJson = require('../')
var readme = fs.readFileSync(path.resolve(__dirname, '../README.md'), 'utf8')
var pkg = require('../package.json')
var isGit
try {
fs.readFileSync(path.resolve(__dirname, '../.git/HEAD'))
isGit = true
} catch (e) {
isGit = false
}
tap.test('basic test', function (t) {
var p = path.resolve(__dirname, '../package.json')
readJson(p, function (er, data) {
if (er) {
throw er
}
basic_(t, data)
})
})
function basic_ (t, data) {
t.ok(data)
t.equal(data.version, pkg.version)
t.equal(data._id, data.name + '@' + data.version)
t.equal(data.name, pkg.name)
t.type(data.author, 'object')
t.equal(data.readme, readme)
t.same(data.scripts, pkg.scripts)
t.equal(data.main, pkg.main)
t.equal(data.readmeFilename, 'README.md')
if (isGit) {
t.match(data.gitHead, /^[a-f0-9]{40}$/)
}
// optional deps are folded in.
t.same(data.optionalDependencies, pkg.optionalDependencies)
t.has(data.dependencies, pkg.dependencies)
t.same(data.devDependencies, pkg.devDependencies)
t.end()
}
read-package-json-5.0.2/test/bin-non-string.js 0000664 0000000 0000000 00000000737 14301230170 0021150 0 ustar 00root root 0000000 0000000 var tap = require('tap')
var readJson = require('../')
var path = require('path')
var p = path.resolve(__dirname, 'fixtures/badbinnonstring.json')
tap.test('non-string bin entries', function (t) {
var logmsgs = []
const warn = (...msg) => logmsgs.push(msg)
readJson(p, warn, function (er, data) {
t.comment(logmsgs.map(msg => 'Warning: ' + msg.join(' ')).join('\n'))
t.equal(er, null, 'no error from readJson')
t.equal(data.bin, undefined)
t.end()
})
})
read-package-json-5.0.2/test/bin.js 0000664 0000000 0000000 00000002162 14301230170 0017046 0 ustar 00root root 0000000 0000000 var path = require('path')
var tap = require('tap')
var readJson = require('../')
var createWarningCollector = function () {
var warn = function (msg) {
warn.warnings.push(arguments)
}
warn.warnings = []
return warn
}
tap.test('Bin test', function (t) {
var p = path.resolve(__dirname, 'fixtures/bin.json')
var warn = createWarningCollector()
readJson(p, warn, function (er, data) {
t.equal(warn.warnings.length, 0)
t.strictSame(data.bin, { 'bin-test': 'bin/echo' })
t.end()
})
})
tap.test('Bad bin test', function (t) {
var p = path.resolve(__dirname, 'fixtures/badbin.json')
var warn = createWarningCollector()
readJson(p, warn, function (er, data) {
t.equal(warn.warnings.length, 1)
t.equal(warn.warnings[0][2], 'No bin file found at bin/typo')
t.end()
})
})
tap.test('Empty bin test', function (t) {
var p = path.resolve(__dirname, 'fixtures/emptybin.json')
var warn = createWarningCollector()
readJson(p, warn, function (er, data) {
t.equal(warn.warnings.length, 0)
t.equal(data.bin, undefined, 'no mapping to bin because object was empty')
t.end()
})
})
read-package-json-5.0.2/test/bom.js 0000664 0000000 0000000 00000000702 14301230170 0017051 0 ustar 00root root 0000000 0000000 var tap = require('tap')
var readJson = require('../')
var path = require('path')
tap.test('BOM test', function (t) {
var p = path.resolve(__dirname, 'fixtures/bom.json')
readJson(p, function (er, data) {
if (er) {
throw er
}
p = path.resolve(__dirname, 'fixtures/nobom.json')
readJson(p, function (jsonErr, data2) {
if (jsonErr) {
throw jsonErr
}
t.same(data, data2)
t.end()
})
})
})
read-package-json-5.0.2/test/bundle.js 0000664 0000000 0000000 00000003334 14301230170 0017551 0 ustar 00root root 0000000 0000000 const t = require('tap')
const read = require('../')
const { resolve } = require('path')
t.test('bundle-true', t => {
const fixture = resolve(__dirname, 'fixtures/bundle-true.json')
read(fixture, (er, data) => {
if (er) {
throw er
}
t.match(data, {
name: 'bundletrue',
version: '1.2.3',
dependencies: { a: '', b: '' },
optionalDependencies: { b: '' },
devDependencies: { c: '' },
bundleDependencies: ['a'],
readme: 'ERROR: No README data found!',
_id: 'bundletrue@1.2.3',
})
t.end()
})
})
t.test('bundle-null', t => {
const fixture = resolve(__dirname, 'fixtures/bundle-null.json')
read(fixture, (er, data) => {
if (er) {
throw er
}
t.notOk(data.bundleDependencies, 'no bundleDependencies')
t.notOk(data.bundledDependencies, 'no bundledDependencies')
t.end()
})
})
t.test('bundle-array', t => {
const fixture = resolve(__dirname, 'fixtures/bundle-array.json')
read(fixture, (er, data) => {
t.match(data, {
name: 'bundlearray',
version: '1.2.3',
dependencies: { a: '', b: '' },
optionalDependencies: { b: '' },
devDependencies: { c: '' },
bundleDependencies: ['a', 'b', 'c'],
readme: 'ERROR: No README data found!',
_id: 'bundlearray@1.2.3',
})
t.end()
})
})
t.test('bundle-false', t => {
const fixture = resolve(__dirname, 'fixtures/bundle-false.json')
read(fixture, (er, data) => {
t.match(data, {
name: 'bundlefalse',
version: '1.2.3',
dependencies: { a: '', b: '' },
optionalDependencies: { b: '' },
devDependencies: { c: '' },
readme: 'ERROR: No README data found!',
_id: 'bundlefalse@1.2.3',
})
t.end()
})
})
read-package-json-5.0.2/test/fill-types.js 0000664 0000000 0000000 00000004322 14301230170 0020366 0 ustar 00root root 0000000 0000000 const t = require('tap')
const read = require('../')
const { resolve } = require('path')
t.test('adds types with a custom main field', t => {
const fixture = resolve(__dirname, 'fixtures/types/custom-dts/one-new-field.json')
read(fixture, (er, data) => {
if (er) {
throw er
}
t.match(data, {
main: './custom-path.js',
types: './custom-path.d.ts',
})
t.end()
})
})
t.test('handles the inferred index.js', t => {
const fixture = resolve(__dirname, 'fixtures/types/default-dts/inferred.json')
read(fixture, (er, data) => {
if (er) {
throw er
}
t.match(data, {
types: './index.d.ts',
})
t.end()
})
})
t.test('handles subpaths and starting with ./', t => {
const fixture = resolve(__dirname, 'fixtures/types/subpaths/subpath.json')
read(fixture, (er, data) => {
if (er) {
throw er
}
t.match(data, {
main: './a/b/c.js',
types: './a/b/c.d.ts',
})
t.end()
})
})
t.test('handles not overwriting existing fields', t => {
const fixture = resolve(__dirname, 'fixtures/types/with-field/has-types-field.json')
read(fixture, (er, data) => {
if (er) {
throw er
}
t.match(data, {
types: '@types/express',
})
t.end()
})
})
t.test('does not add types fields if not present', t => {
const fixture = resolve(__dirname, 'fixtures/readmes/package.json')
read(fixture, (er, data) => {
if (er) {
throw er
}
t.notOk(data.types, 'types field should not be added')
t.end()
})
})
// https://nodejs.org/api/esm.html#esm_writing_dual_packages_while_avoiding_or_minimizing_hazards
t.skip('handles esm modules', t => {
const fixture = resolve(__dirname, 'fixtures/types/esmodule-exports/exports.json')
read(fixture, (er, data) => {
if (er) {
throw er
}
t.match(data, {
types: './a/b/c.d.ts',
})
t.end()
})
})
// https://nodejs.org/api/esm.html#esm_exports_sugar
t.skip('handles esm modules with sugared exports', t => {
const fixture = resolve(__dirname, 'fixtures/types/esmodule-exports-sugar/sugar.json')
read(fixture, (er, data) => {
if (er) {
throw er
}
t.match(data, {
types: './a/b.d.ts',
})
t.end()
})
})
read-package-json-5.0.2/test/fixtures/ 0000775 0000000 0000000 00000000000 14301230170 0017610 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/badbin.json 0000664 0000000 0000000 00000000366 14301230170 0021727 0 ustar 00root root 0000000 0000000 {
"name": "badbin-test",
"description": "my desc",
"repository": {
"type": "git",
"url": "git://github.com/npm/read-package-json.git"
},
"version": "0.0.1",
"readme": "hello world",
"bin": "./bin/typo",
"license": "ISC"
}
read-package-json-5.0.2/test/fixtures/badbinnonstring.json 0000664 0000000 0000000 00000000406 14301230170 0023664 0 ustar 00root root 0000000 0000000 {
"name": "badbinnonstring-test",
"description": "my desc",
"repository": {
"type": "git",
"url": "git://github.com/npm/read-package-json.git"
},
"version": "0.0.1",
"readme": "hello world",
"bin": {
"key": {}
},
"license": "ISC"
}
read-package-json-5.0.2/test/fixtures/badmainnonstring.json 0000664 0000000 0000000 00000000140 14301230170 0024033 0 ustar 00root root 0000000 0000000 {
"name": "invalid_main",
"main": [
"why is this a thing",
"this can't work"
]
}
read-package-json-5.0.2/test/fixtures/bin.json 0000664 0000000 0000000 00000000363 14301230170 0021255 0 ustar 00root root 0000000 0000000 {
"name": "bin-test",
"description": "my desc",
"repository": {
"type": "git",
"url": "git://github.com/npm/read-package-json.git"
},
"version": "0.0.1",
"readme": "hello world",
"bin": "./bin/echo",
"license": "ISC"
}
read-package-json-5.0.2/test/fixtures/bin/ 0000775 0000000 0000000 00000000000 14301230170 0020360 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/bin/echo 0000664 0000000 0000000 00000000035 14301230170 0021217 0 ustar 00root root 0000000 0000000 #!/bin/sh
echo "Hello world" read-package-json-5.0.2/test/fixtures/bom.json 0000664 0000000 0000000 00000000155 14301230170 0021261 0 ustar 00root root 0000000 0000000 {
"name": "this",
"description": "file",
"author": "has ",
"version" : "0.0.1"
} read-package-json-5.0.2/test/fixtures/bundle-array.json 0000664 0000000 0000000 00000000346 14301230170 0023073 0 ustar 00root root 0000000 0000000 {
"name": "bundlearray",
"version": "1.2.3",
"dependencies": {
"a": ""
},
"optionalDependencies": {
"b": ""
},
"devDependencies": {
"c": ""
},
"bundledDependencies": [
"a",
"b",
"c"
]
}
read-package-json-5.0.2/test/fixtures/bundle-false.json 0000664 0000000 0000000 00000000352 14301230170 0023044 0 ustar 00root root 0000000 0000000 {
"name": "bundlefalse",
"version": "1.2.3",
"dependencies": {
"a": ""
},
"optionalDependencies": {
"b": ""
},
"devDependencies": {
"c": ""
},
"bundleDependencies": false,
"bundledDependencies": true
}
read-package-json-5.0.2/test/fixtures/bundle-null.json 0000664 0000000 0000000 00000000350 14301230170 0022722 0 ustar 00root root 0000000 0000000 {
"name": "bundlenull",
"version": "1.2.3",
"dependencies": {
"a": ""
},
"optionalDependencies": {
"b": ""
},
"devDependencies": {
"c": ""
},
"bundleDependencies": null,
"bundledDependencies": true
}
read-package-json-5.0.2/test/fixtures/bundle-true.json 0000664 0000000 0000000 00000000312 14301230170 0022725 0 ustar 00root root 0000000 0000000 {
"name": "bundletrue",
"version": "1.2.3",
"dependencies": {
"a": ""
},
"optionalDependencies": {
"b": ""
},
"devDependencies": {
"c": ""
},
"bundledDependencies": true
}
read-package-json-5.0.2/test/fixtures/emptybin.json 0000664 0000000 0000000 00000000356 14301230170 0022336 0 ustar 00root root 0000000 0000000 {
"name": "emptybin-test",
"description": "my desc",
"repository": {
"type": "git",
"url": "git://github.com/npm/read-package-json.git"
},
"version": "0.0.1",
"readme": "hello world",
"bin": {},
"license": "ISC"
}
read-package-json-5.0.2/test/fixtures/erroneous.json 0000664 0000000 0000000 00000000050 14301230170 0022517 0 ustar 00root root 0000000 0000000 {
'wrong': 'kind',
'of': 'quotes'
}
read-package-json-5.0.2/test/fixtures/indexjs-bad/ 0000775 0000000 0000000 00000000000 14301230170 0022000 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/indexjs-bad/index.js 0000664 0000000 0000000 00000000477 14301230170 0023455 0 ustar 00root root 0000000 0000000 /**package
* {
* "name": "indexjs-test",
* "version": "1.2.3",
* "description": "Did you know npm could do this, even?",
* "main": "index.js"
*
* but alas, 'twas not to be,
* for, when parse the comment we,
* json is not there to see
*
* }
**/
console.log('just a broken single-file package')
read-package-json-5.0.2/test/fixtures/indexjs-bad/package.json 0000664 0000000 0000000 00000000036 14301230170 0024265 0 ustar 00root root 0000000 0000000 {"this is
Not valid json!!
read-package-json-5.0.2/test/fixtures/indexjs/ 0000775 0000000 0000000 00000000000 14301230170 0021254 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/indexjs/index.js 0000664 0000000 0000000 00000000326 14301230170 0022722 0 ustar 00root root 0000000 0000000 /**package
* {
* "name": "indexjs-test",
* "version": "1.2.3",
* "description": "Did you know npm could do this, even?",
* "main": "index.js"
* }
**/
console.log('just a simple single-file package')
read-package-json-5.0.2/test/fixtures/invalid-version/ 0000775 0000000 0000000 00000000000 14301230170 0022721 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/invalid-version/package.json 0000664 0000000 0000000 00000000177 14301230170 0025214 0 ustar 00root root 0000000 0000000 {
"name": "bob-the-cat",
"version": "a live bobcat",
"description": "instead of semver, package contained live bobcat"
}
read-package-json-5.0.2/test/fixtures/man.json 0000664 0000000 0000000 00000000410 14301230170 0021251 0 ustar 00root root 0000000 0000000 {
"name": "man-test",
"description": "my desc",
"repository": {
"type": "git",
"url": "git://github.com/npm/read-package-json.git"
},
"version": "0.0.1",
"readme": "hello world",
"directories": {
"man": "./man"
},
"license": "ISC"
}
read-package-json-5.0.2/test/fixtures/man/ 0000775 0000000 0000000 00000000000 14301230170 0020363 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/man/man1/ 0000775 0000000 0000000 00000000000 14301230170 0021217 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/man/man1/test.1 0000664 0000000 0000000 00000000016 14301230170 0022255 0 ustar 00root root 0000000 0000000 test man file
read-package-json-5.0.2/test/fixtures/nobom.json 0000664 0000000 0000000 00000000152 14301230170 0021613 0 ustar 00root root 0000000 0000000 {
"name": "this",
"description": "file",
"author": "has ",
"version" : "0.0.1"
} read-package-json-5.0.2/test/fixtures/not-json.css 0000664 0000000 0000000 00000001361 14301230170 0022072 0 ustar 00root root 0000000 0000000 body {
height: super tall
}
/**package
{
"name": "read-package-json",
"version": "0.1.1",
"author": "Isaac Z. Schlueter (http://blog.izs.me/)",
"description": "The thing npm uses to read package.json files with semantics and defaults and validation",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/read-package-json.git"
},
"main": "read-json.js",
"scripts": {
"test": "./node_modules/.bin/tap test/*.js"
},
"dependencies": {
"glob": "~3.1.9",
"lru-cache": "~1.1.0",
"semver": "~1.0.14",
"slide": "~1.1.3"
},
"devDependencies": {
"tap": "~0.2.5"
},
"optionalDependencies": {
"npmlog": "0",
"graceful-fs": "~1.1.8"
}
}
**/
html {
width: wow so wide
}
read-package-json-5.0.2/test/fixtures/readmes/ 0000775 0000000 0000000 00000000000 14301230170 0021230 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/readmes/README 0000664 0000000 0000000 00000000004 14301230170 0022102 0 ustar 00root root 0000000 0000000 foo
read-package-json-5.0.2/test/fixtures/readmes/README.md 0000664 0000000 0000000 00000000013 14301230170 0022501 0 ustar 00root root 0000000 0000000 *markdown*
read-package-json-5.0.2/test/fixtures/readmes/package.json 0000664 0000000 0000000 00000000061 14301230170 0023513 0 ustar 00root root 0000000 0000000 {"name":"readmes", "version":"99.999.999999999"}
read-package-json-5.0.2/test/fixtures/readmes/readmexxx.yz 0000664 0000000 0000000 00000000014 14301230170 0023614 0 ustar 00root root 0000000 0000000 extra noise
read-package-json-5.0.2/test/fixtures/types/ 0000775 0000000 0000000 00000000000 14301230170 0020754 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/custom-dts/ 0000775 0000000 0000000 00000000000 14301230170 0023056 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/custom-dts/custom-path.d.ts 0000664 0000000 0000000 00000000060 14301230170 0026110 0 ustar 00root root 0000000 0000000 // Empty because implementation isn't important
read-package-json-5.0.2/test/fixtures/types/custom-dts/one-new-field.json 0000664 0000000 0000000 00000000161 14301230170 0026400 0 ustar 00root root 0000000 0000000 {
"$schema": "https://json.schemastore.org/package",
"name": "one-new-field",
"main": "./custom-path.js"
}
read-package-json-5.0.2/test/fixtures/types/default-dts/ 0000775 0000000 0000000 00000000000 14301230170 0023170 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/default-dts/index.d.ts 0000664 0000000 0000000 00000000060 14301230170 0025065 0 ustar 00root root 0000000 0000000 // Empty because implementation isn't important
read-package-json-5.0.2/test/fixtures/types/default-dts/inferred.json 0000664 0000000 0000000 00000000115 14301230170 0025656 0 ustar 00root root 0000000 0000000 {
"$schema": "https://json.schemastore.org/package",
"name": "no-main"
}
read-package-json-5.0.2/test/fixtures/types/esmodule-exports-sugar/ 0000775 0000000 0000000 00000000000 14301230170 0025412 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/esmodule-exports-sugar/a/ 0000775 0000000 0000000 00000000000 14301230170 0025632 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/esmodule-exports-sugar/a/b.d.ts 0000664 0000000 0000000 00000000000 14301230170 0026633 0 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/esmodule-exports-sugar/a/b.js 0000664 0000000 0000000 00000000000 14301230170 0026377 0 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/esmodule-exports-sugar/sugar.json 0000664 0000000 0000000 00000000034 14301230170 0027423 0 ustar 00root root 0000000 0000000 {
"exports": "./a/b.js"
}
read-package-json-5.0.2/test/fixtures/types/esmodule-exports/ 0000775 0000000 0000000 00000000000 14301230170 0024273 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/esmodule-exports/a/ 0000775 0000000 0000000 00000000000 14301230170 0024513 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/esmodule-exports/a/b/ 0000775 0000000 0000000 00000000000 14301230170 0024734 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/esmodule-exports/a/b/c.d.ts 0000664 0000000 0000000 00000000000 14301230170 0025736 0 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/esmodule-exports/a/b/c.js 0000664 0000000 0000000 00000000000 14301230170 0025502 0 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/esmodule-exports/exports.json 0000664 0000000 0000000 00000000127 14301230170 0026672 0 ustar 00root root 0000000 0000000 {
"type": "module",
"exports": {
".": "./a/b/c.js",
"./a": "./a.mjs"
}
}
read-package-json-5.0.2/test/fixtures/types/subpaths/ 0000775 0000000 0000000 00000000000 14301230170 0022605 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/subpaths/a/ 0000775 0000000 0000000 00000000000 14301230170 0023025 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/subpaths/a/b/ 0000775 0000000 0000000 00000000000 14301230170 0023246 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/subpaths/a/b/c.d.ts 0000664 0000000 0000000 00000000000 14301230170 0024250 0 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/subpaths/a/b/c.js 0000664 0000000 0000000 00000000000 14301230170 0024014 0 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/subpaths/subpath.json 0000664 0000000 0000000 00000000146 14301230170 0025147 0 ustar 00root root 0000000 0000000 {
"$schema": "https://json.schemastore.org/package",
"name": "subpaths",
"main": "./a/b/c.js"
}
read-package-json-5.0.2/test/fixtures/types/with-field/ 0000775 0000000 0000000 00000000000 14301230170 0023010 5 ustar 00root root 0000000 0000000 read-package-json-5.0.2/test/fixtures/types/with-field/has-types-field.json 0000664 0000000 0000000 00000000166 14301230170 0026704 0 ustar 00root root 0000000 0000000 {
"$schema": "https://json.schemastore.org/package",
"name": "has-types-reference",
"types": "@types/express"
}
read-package-json-5.0.2/test/fixtures/types/with-field/index.d.ts 0000664 0000000 0000000 00000000060 14301230170 0024705 0 ustar 00root root 0000000 0000000 // Empty because implementation isn't important
read-package-json-5.0.2/test/fixtures/underscores.json 0000664 0000000 0000000 00000000104 14301230170 0023032 0 ustar 00root root 0000000 0000000 {
"name": "underscore",
"version": "1.2.3",
"_lodash": true
}
read-package-json-5.0.2/test/git-head.js 0000664 0000000 0000000 00000003540 14301230170 0017761 0 ustar 00root root 0000000 0000000 var childProcess = require('child_process')
var fs = require('fs')
var path = require('path')
var tap = require('tap')
var readJson = require('../')
var isGit
try {
fs.readFileSync(path.resolve(__dirname, '../.git/HEAD'))
isGit = true
} catch (e) {
isGit = false
}
if (isGit) {
tap.test('gitHead tests', function (t) {
t.plan(4)
const repoProjectName = 'read-package-json'
const repo = 'https://github.com/npm/' + repoProjectName + '.git'
var repoDirs = []
t.test('detached case', function (tt) {
var p = path.resolve(__dirname, '..', 'package.json')
readJson(p, function (er, data) {
if (er) {
throw er
}
tt.ok(data)
tt.match(data.gitHead, /^[a-f0-9]{40}$/)
tt.end()
})
})
function testGitRepo (kind, file, extraRepoCommand, t) {
var repoDirName = repoProjectName + '-' + kind
var cmd = `cd ${__dirname} && git clone ${repo} ${repoDirName} && cd ${repoDirName}`
if (extraRepoCommand) {
cmd += ` && ${extraRepoCommand}`
}
childProcess.execSync(cmd)
repoDirs.push(repoDirName)
var p = path.resolve(__dirname, repoDirName, file)
readJson(p, function (er, data) {
if (er) {
throw er
}
t.ok(data)
t.match(data.gitHead, /^[a-f0-9]{40}$/)
t.end()
})
}
t.test('basic case', function (tt) {
testGitRepo('basic', 'package.json', '', tt)
})
t.test('subdirectory', function (tt) {
testGitRepo('subdir', 'test/fixtures/bin.json', '', tt)
})
t.test('git-pack-refs vs gitHead', function (tt) {
testGitRepo('git-pack-refs', 'package.json', 'git pack-refs --all', tt)
})
t.teardown(function () {
repoDirs.forEach(function (d) {
childProcess.execSync(`rm -rf ${path.resolve(__dirname, d)}`)
})
})
})
}
read-package-json-5.0.2/test/helpful.js 0000664 0000000 0000000 00000001035 14301230170 0017733 0 ustar 00root root 0000000 0000000 var tap = require('tap')
var readJson = require('../')
var path = require('path')
var p = path.resolve(__dirname, 'fixtures/erroneous.json')
tap.test('erroneous package data', function (t) {
readJson(p, function (er, data) {
t.ok(er instanceof Error)
t.ok(er.message.match(/Unexpected token "'" \(0x27\)/))
t.end()
})
})
tap.test('ENOTDIR for non-directory packages', function (t) {
readJson(path.resolve(__filename, 'package.json'), function (er, data) {
t.ok(er)
t.equal(er.code, 'ENOTDIR')
t.end()
})
})
read-package-json-5.0.2/test/indexjs.js 0000664 0000000 0000000 00000002046 14301230170 0017743 0 ustar 00root root 0000000 0000000 const t = require('tap')
const read = require('../')
const { resolve } = require('path')
t.test('read from an index.js file', t => {
const fixture = resolve(__dirname, 'fixtures/indexjs/package.json')
read(fixture, (er, data) => {
if (er) {
throw er
}
t.match(data, {
name: 'indexjs-test',
version: '1.2.3',
description: 'Did you know npm could do this, even?',
main: 'index.js',
readme: 'ERROR: No README data found!',
_id: 'indexjs-test@1.2.3',
})
t.end()
})
})
t.test('missing file', t => {
// this subdirectory does not exist
const fixture = resolve(__dirname, 'fixtures/indexjs-missing/package.json')
read(fixture, (er, data) => {
t.match(er, {
code: 'ENOENT',
path: fixture,
})
t.notOk(data)
t.end()
})
})
t.test('EJSONPARSE', t => {
const fixture = resolve(__dirname, 'fixtures/indexjs-bad/package.json')
read(fixture, (er, data) => {
t.match(er, {
code: 'EJSONPARSE',
path: fixture,
})
t.notOk(data)
t.end()
})
})
read-package-json-5.0.2/test/main-non-string.js 0000664 0000000 0000000 00000000737 14301230170 0021324 0 ustar 00root root 0000000 0000000 var tap = require('tap')
var readJson = require('../')
var path = require('path')
var p = path.resolve(__dirname, 'fixtures/badmainnonstring.json')
tap.test('non-string main entries', function (t) {
var logmsgs = []
const warn = (...msg) => logmsgs.push(msg)
readJson(p, warn, function (er, data) {
t.comment(logmsgs.map(msg => 'Warning: ' + msg.join(' ')).join('\n'))
t.match(er, new TypeError('The "main" attribute must be of type string.'))
t.end()
})
})
read-package-json-5.0.2/test/mans.js 0000664 0000000 0000000 00000000503 14301230170 0017231 0 ustar 00root root 0000000 0000000 var path = require('path')
var tap = require('tap')
var readJson = require('../')
tap.test('Mans test', function (t) {
var p = path.resolve(__dirname, 'fixtures/man.json')
readJson(p, function (er, data) {
t.same(data.man, ['man/man1/test.1'], 'man directory is translated but not resolved')
t.end()
})
})
read-package-json-5.0.2/test/non-json.js 0000664 0000000 0000000 00000004037 14301230170 0020042 0 ustar 00root root 0000000 0000000 var path = require('path')
var tap = require('tap')
var readJson = require('../')
var expect = {
name: 'read-package-json',
version: '0.1.1',
author: {
name: 'Isaac Z. Schlueter',
email: 'i@izs.me',
url: 'http://blog.izs.me/',
},
/* eslint-disable-next-line max-len */
description: 'The thing npm uses to read package.json files with semantics and defaults and validation',
repository: {
type: 'git',
url: 'git://github.com/isaacs/read-package-json.git',
},
bugs: {
url: 'https://github.com/isaacs/read-package-json/issues',
},
main: 'read-json.js',
scripts: { test: 'tap test/*.js' },
dependencies: {
glob: '~3.1.9',
'lru-cache': '~1.1.0',
semver: '~1.0.14',
slide: '~1.1.3',
npmlog: '0',
'graceful-fs': '~1.1.8',
},
devDependencies: { tap: '~0.2.5' },
homepage: 'https://github.com/isaacs/read-package-json#readme',
optionalDependencies: { npmlog: '0', 'graceful-fs': '~1.1.8' },
_id: 'read-package-json@0.1.1',
readme: 'ERROR: No README data found!',
}
tap.test('from css', function (t) {
var c = path.join(__dirname, 'fixtures', 'not-json.css')
readJson(c, function (er, d) {
delete d.gitHead
t.same(d, expect)
t.end()
})
})
tap.test('from js', function (t) {
readJson(__filename, function (er, d) {
delete d.gitHead
t.same(d, expect)
t.end()
})
})
/* eslint-disable max-len */
/**package
{
"name": "read-package-json",
"version": "0.1.1",
"author": "Isaac Z. Schlueter (http://blog.izs.me/)",
"description": "The thing npm uses to read package.json files with semantics and defaults and validation",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/read-package-json.git"
},
"main": "read-json.js",
"scripts": {
"test": "tap test/*.js"
},
"dependencies": {
"glob": "~3.1.9",
"lru-cache": "~1.1.0",
"semver": "~1.0.14",
"slide": "~1.1.3"
},
"devDependencies": {
"tap": "~0.2.5"
},
"optionalDependencies": {
"npmlog": "0",
"graceful-fs": "~1.1.8"
}
}
**/
read-package-json-5.0.2/test/readmes.js 0000664 0000000 0000000 00000001203 14301230170 0017711 0 ustar 00root root 0000000 0000000 var path = require('path')
var tap = require('tap')
var p = path.resolve(__dirname, 'fixtures/readmes/package.json')
var readJson = require('../')
var expect = {
name: 'readmes',
version: '99.999.999999999',
readme: '*markdown*\n',
readmeFilename: 'README.md',
description: '*markdown*',
_id: 'readmes@99.999.999999999',
}
if (process.platform === 'win32') {
expect.readme = '*markdown*\r\n'
}
tap.test('readme test', function (t) {
readJson(p, function (er, data) {
t.error(er, 'read README without error')
test(t, data)
})
})
function test (t, data) {
delete data.gitHead
t.same(data, expect)
t.end()
}
read-package-json-5.0.2/test/semver.js 0000664 0000000 0000000 00000000553 14301230170 0017601 0 ustar 00root root 0000000 0000000 const t = require('tap')
const readJson = require('../')
const path = require('path')
const file = path.resolve(__dirname, 'fixtures/invalid-version/package.json')
const logs = []
const warn = (...msg) => logs.push(msg)
readJson(file, warn, false, (er, data) => {
t.match(er, {
message: 'Invalid version: "a live bobcat"',
})
t.notOk(data)
t.end()
})
read-package-json-5.0.2/test/underscores.js 0000664 0000000 0000000 00000000710 14301230170 0020627 0 ustar 00root root 0000000 0000000 const t = require('tap')
const rpj = require('../')
const { resolve } = require('path')
const fixture = resolve(__dirname, 'fixtures/underscores.json')
t.test('strip underscores', t => {
rpj(fixture, (er, data) => {
if (er) {
throw er
}
delete data.gitHead
t.strictSame(data, {
_id: 'underscore@1.2.3',
name: 'underscore',
version: '1.2.3',
readme: 'ERROR: No README data found!',
})
t.end()
})
})