pax_global_header 0000666 0000000 0000000 00000000064 14323532274 0014517 g ustar 00root root 0000000 0000000 52 comment=ad7b36f68d3a602d38794720531f31d3586baf64
npm-package-arg-10.0.0/ 0000775 0000000 0000000 00000000000 14323532274 0014527 5 ustar 00root root 0000000 0000000 npm-package-arg-10.0.0/.commitlintrc.js 0000664 0000000 0000000 00000000553 14323532274 0017652 0 ustar 00root root 0000000 0000000 /* This file is automatically added by @npmcli/template-oss. Do not edit. */
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'deps', 'chore']],
'header-max-length': [2, 'always', 80],
'subject-case': [0, 'always', ['lower-case', 'sentence-case', 'start-case']],
},
}
npm-package-arg-10.0.0/.eslintrc.js 0000664 0000000 0000000 00000000545 14323532274 0016772 0 ustar 00root root 0000000 0000000 /* This file is automatically added by @npmcli/template-oss. Do not edit. */
'use strict'
const { readdirSync: readdir } = require('fs')
const localConfigs = readdir(__dirname)
.filter((file) => file.startsWith('.eslintrc.local.'))
.map((file) => `./${file}`)
module.exports = {
root: true,
extends: [
'@npmcli',
...localConfigs,
],
}
npm-package-arg-10.0.0/.github/ 0000775 0000000 0000000 00000000000 14323532274 0016067 5 ustar 00root root 0000000 0000000 npm-package-arg-10.0.0/.github/CODEOWNERS 0000664 0000000 0000000 00000000132 14323532274 0017456 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
* @npm/cli-team
npm-package-arg-10.0.0/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 14323532274 0020252 5 ustar 00root root 0000000 0000000 npm-package-arg-10.0.0/.github/ISSUE_TEMPLATE/bug.yml 0000664 0000000 0000000 00000002655 14323532274 0021562 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Bug
description: File a bug/issue
title: "[BUG]
"
labels: [ Bug, Needs Triage ]
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please [search here](./issues) to see if an issue already exists for your problem.
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: Current Behavior
description: A clear & concise description of what you're experiencing.
validations:
required: false
- type: textarea
attributes:
label: Expected Behavior
description: A clear & concise description of what you expected to happen.
validations:
required: false
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
value: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
validations:
required: false
- type: textarea
attributes:
label: Environment
description: |
examples:
- **npm**: 7.6.3
- **Node**: 13.14.0
- **OS**: Ubuntu 20.04
- **platform**: Macbook Pro
value: |
- npm:
- Node:
- OS:
- platform:
validations:
required: false
npm-package-arg-10.0.0/.github/ISSUE_TEMPLATE/config.yml 0000664 0000000 0000000 00000000145 14323532274 0022242 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
blank_issues_enabled: true
npm-package-arg-10.0.0/.github/dependabot.yml 0000664 0000000 0000000 00000000563 14323532274 0020723 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-package-arg-10.0.0/.github/matchers/ 0000775 0000000 0000000 00000000000 14323532274 0017675 5 ustar 00root root 0000000 0000000 npm-package-arg-10.0.0/.github/matchers/tap.json 0000664 0000000 0000000 00000001204 14323532274 0021351 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
}
]
}
]
}
npm-package-arg-10.0.0/.github/settings.yml 0000664 0000000 0000000 00000000055 14323532274 0020452 0 ustar 00root root 0000000 0000000 ---
_extends: '.github:npm-cli/settings.yml'
npm-package-arg-10.0.0/.github/workflows/ 0000775 0000000 0000000 00000000000 14323532274 0020124 5 ustar 00root root 0000000 0000000 npm-package-arg-10.0.0/.github/workflows/audit.yml 0000664 0000000 0000000 00000001775 14323532274 0021767 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:
name: Audit Dependencies
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
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: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund --package-lock
- name: Run Audit
run: npm audit
npm-package-arg-10.0.0/.github/workflows/ci-release.yml 0000664 0000000 0000000 00000015060 14323532274 0022662 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: CI - Release
on:
workflow_call:
inputs:
ref:
required: true
type: string
check-sha:
required: true
type: string
jobs:
lint-all:
name: Lint All
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Get Workflow Job
uses: actions/github-script@v6
id: check-output
env:
JOB_NAME: "Lint All"
MATRIX_NAME: ""
with:
script: |
const { owner, repo } = context.repo
const { data } = await github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id: context.runId,
per_page: 100
})
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
const job = data.jobs.find(j => j.name.endsWith(jobName))
const jobUrl = job?.html_url
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}`
let summary = `This check is assosciated with ${shaUrl}\n\n`
if (jobUrl) {
summary += `For run logs, click here: ${jobUrl}`
} else {
summary += `Run logs could not be found for a job with name: "${jobName}"`
}
return { summary }
- name: Create Check
uses: LouisBrunner/checks-action@v1.3.1
id: check
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: in_progress
name: Lint All
sha: ${{ inputs.check-sha }}
output: ${{ steps.check-output.outputs.result }}
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Lint
run: npm run lint --ignore-scripts
- name: Post Lint
run: npm run postlint --ignore-scripts
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.3.1
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ job.status }}
check_id: ${{ steps.check.outputs.check_id }}
test-all:
name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
platform:
- name: Linux
os: ubuntu-latest
shell: bash
- name: macOS
os: macos-latest
shell: bash
- name: Windows
os: windows-latest
shell: cmd
node-version:
- 14.17.0
- 14.x
- 16.13.0
- 16.x
- 18.0.0
- 18.x
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- name: Get Workflow Job
uses: actions/github-script@v6
id: check-output
env:
JOB_NAME: "Test All"
MATRIX_NAME: " - ${{ matrix.platform.name }} - ${{ matrix.node-version }}"
with:
script: |
const { owner, repo } = context.repo
const { data } = await github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id: context.runId,
per_page: 100
})
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
const job = data.jobs.find(j => j.name.endsWith(jobName))
const jobUrl = job?.html_url
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}`
let summary = `This check is assosciated with ${shaUrl}\n\n`
if (jobUrl) {
summary += `For run logs, click here: ${jobUrl}`
} else {
summary += `Run logs could not be found for a job with name: "${jobName}"`
}
return { summary }
- name: Create Check
uses: LouisBrunner/checks-action@v1.3.1
id: check
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: in_progress
name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
sha: ${{ inputs.check-sha }}
output: ${{ steps.check-output.outputs.result }}
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Update Windows npm
# 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: Install npm@7
if: startsWith(matrix.node-version, '10.')
run: npm i --prefer-online --no-fund --no-audit -g npm@7
- name: Install npm@latest
if: ${{ !startsWith(matrix.node-version, '10.') }}
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Add Problem Matcher
run: echo "::add-matcher::.github/matchers/tap.json"
- name: Test
run: npm test --ignore-scripts
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.3.1
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ job.status }}
check_id: ${{ steps.check.outputs.check_id }}
npm-package-arg-10.0.0/.github/workflows/ci.yml 0000664 0000000 0000000 00000011746 14323532274 0021253 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:
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:
engines:
name: Engines - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
platform:
- name: Linux
os: ubuntu-latest
shell: bash
node-version:
- 14.17.0
- 16.13.0
- 18.0.0
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- name: Checkout
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: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Update Windows npm
# 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: Install npm@7
if: startsWith(matrix.node-version, '10.')
run: npm i --prefer-online --no-fund --no-audit -g npm@7
- name: Install npm@latest
if: ${{ !startsWith(matrix.node-version, '10.') }}
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund --engines-strict
lint:
name: Lint
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
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: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Lint
run: npm run lint --ignore-scripts
- name: Post Lint
run: npm run postlint --ignore-scripts
test:
name: Test - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
platform:
- name: Linux
os: ubuntu-latest
shell: bash
- name: macOS
os: macos-latest
shell: bash
- name: Windows
os: windows-latest
shell: cmd
node-version:
- 14.17.0
- 14.x
- 16.13.0
- 16.x
- 18.0.0
- 18.x
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- name: Checkout
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: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Update Windows npm
# 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: Install npm@7
if: startsWith(matrix.node-version, '10.')
run: npm i --prefer-online --no-fund --no-audit -g npm@7
- name: Install npm@latest
if: ${{ !startsWith(matrix.node-version, '10.') }}
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Add Problem Matcher
run: echo "::add-matcher::.github/matchers/tap.json"
- name: Test
run: npm test --ignore-scripts
npm-package-arg-10.0.0/.github/workflows/codeql-analysis.yml 0000664 0000000 0000000 00000001605 14323532274 0023741 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:
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
steps:
- name: Checkout
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@v2
with:
languages: javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
npm-package-arg-10.0.0/.github/workflows/post-dependabot.yml 0000664 0000000 0000000 00000011634 14323532274 0023744 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Post Dependabot
on: pull_request
permissions:
contents: write
jobs:
template-oss:
name: template-oss
if: github.repository_owner == 'npm' && github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Fetch Dependabot Metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# Dependabot can update multiple directories so we output which directory
# it is acting on so we can run the command for the correct root or workspace
- name: Get Dependabot Directory
if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss')
id: flags
run: |
dependabot_dir="${{ steps.metadata.outputs.directory }}"
if [[ "$dependabot_dir" == "/" ]]; then
echo "::set-output name=workspace::-iwr"
else
# strip leading slash from directory so it works as a
# a path to the workspace flag
echo "::set-output name=workspace::-w ${dependabot_dir#/}"
fi
- name: Apply Changes
if: steps.flags.outputs.workspace
id: apply
run: |
npm run template-oss-apply ${{ steps.flags.outputs.workspace }}
if [[ `git status --porcelain` ]]; then
echo "::set-output name=changes::true"
fi
# This only sets the conventional commit prefix. This workflow can't reliably determine
# what the breaking change is though. If a BREAKING CHANGE message is required then
# this PR check will fail and the commit will be amended with stafftools
if [[ "${{ steps.metadata.outputs.update-type }}" == "version-update:semver-major" ]]; then
prefix='feat!'
else
prefix='chore!'
fi
echo "::set-output name=message::$prefix: postinstall for dependabot template-oss PR"
# This step will fail if template-oss has made any workflow updates. It is impossible
# for a workflow to update other workflows. In the case it does fail, we continue
# and then try to apply only a portion of the changes in the next step
- name: Push All Changes
if: steps.apply.outputs.changes
id: push
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git commit -am "${{ steps.apply.outputs.message }}"
git push
# If the previous step failed, then reset the commit and remove any workflow changes
# and attempt to commit and push again. This is helpful because we will have a commit
# with the correct prefix that we can then --amend with @npmcli/stafftools later.
- name: Push All Changes Except Workflows
if: steps.apply.outputs.changes && steps.push.outcome == 'failure'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git reset HEAD~
git checkout HEAD -- .github/workflows/
git clean -fd .github/workflows/
git commit -am "${{ steps.apply.outputs.message }}"
git push
# Check if all the necessary template-oss changes were applied. Since we continued
# on errors in one of the previous steps, this check will fail if our follow up
# only applied a portion of the changes and we need to followup manually.
#
# Note that this used to run `lint` and `postlint` but that will fail this action
# if we've also shipped any linting changes separate from template-oss. We do
# linting in another action, so we want to fail this one only if there are
# template-oss changes that could not be applied.
- name: Check Changes
if: steps.apply.outputs.changes
run: |
npm exec --offline ${{ steps.flags.outputs.workspace }} -- template-oss-check
- name: Fail on Breaking Change
if: steps.apply.outputs.changes && startsWith(steps.apply.outputs.message, 'feat!')
run: |
echo "This PR has a breaking change. Run 'npx -p @npmcli/stafftools gh template-oss-fix'"
echo "for more information on how to fix this with a BREAKING CHANGE footer."
exit 1
npm-package-arg-10.0.0/.github/workflows/pull-request.yml 0000664 0000000 0000000 00000002545 14323532274 0023317 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Pull Request
on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize
jobs:
commitlint:
name: Lint Commits
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
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"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Run Commitlint on Commits
id: commit
continue-on-error: true
run: |
npx --offline commitlint -V --from origin/${{ github.base_ref }} --to ${{ github.event.pull_request.head.sha }}
- name: Run Commitlint on PR Title
if: steps.commit.outcome == 'failure'
run: |
echo ${{ github.event.pull_request.title }} | npx --offline commitlint -V
npm-package-arg-10.0.0/.github/workflows/release.yml 0000664 0000000 0000000 00000023634 14323532274 0022277 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Release
on:
workflow_dispatch:
push:
branches:
- main
- latest
permissions:
contents: write
pull-requests: write
checks: write
jobs:
release:
outputs:
pr: ${{ steps.release.outputs.pr }}
releases: ${{ steps.release.outputs.releases }}
release-flags: ${{ steps.release.outputs.release-flags }}
branch: ${{ steps.release.outputs.pr-branch }}
pr-number: ${{ steps.release.outputs.pr-number }}
comment-id: ${{ steps.pr-comment.outputs.result }}
check-id: ${{ steps.check.outputs.check_id }}
name: Release
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
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: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Release Please
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx --offline template-oss-release-please ${{ github.ref_name }} ${{ github.event_name }}
- name: Post Pull Request Comment
if: steps.release.outputs.pr-number
uses: actions/github-script@v6
id: pr-comment
env:
PR_NUMBER: ${{ steps.release.outputs.pr-number }}
REF_NAME: ${{ github.ref_name }}
with:
script: |
const { REF_NAME, PR_NUMBER } = process.env
const repo = { owner: context.repo.owner, repo: context.repo.repo }
const issue = { ...repo, issue_number: PR_NUMBER }
const { data: workflow } = await github.rest.actions.getWorkflowRun({ ...repo, run_id: context.runId })
let body = '## Release Manager\n\n'
const comments = await github.paginate(github.rest.issues.listComments, issue)
let commentId = comments?.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id
body += `Release workflow run: ${workflow.html_url}\n\n#### Force CI to Rerun for This Release\n\n`
body += `This PR will be updated and CI will run for every non-\`chore:\` commit that is pushed to \`main\`. `
body += `To force CI to rerun, run this command:\n\n`
body += `\`\`\`\ngh workflow run release.yml -r ${REF_NAME}\n\`\`\``
if (commentId) {
await github.rest.issues.updateComment({ ...repo, comment_id: commentId, body })
} else {
const { data: comment } = await github.rest.issues.createComment({ ...issue, body })
commentId = comment?.id
}
return commentId
- name: Get Workflow Job
uses: actions/github-script@v6
if: steps.release.outputs.pr-number
id: check-output
env:
JOB_NAME: "Release"
MATRIX_NAME: ""
with:
script: |
const { owner, repo } = context.repo
const { data } = await github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id: context.runId,
per_page: 100
})
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
const job = data.jobs.find(j => j.name.endsWith(jobName))
const jobUrl = job?.html_url
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ steps.release.outputs.pr-sha }}`
let summary = `This check is assosciated with ${shaUrl}\n\n`
if (jobUrl) {
summary += `For run logs, click here: ${jobUrl}`
} else {
summary += `Run logs could not be found for a job with name: "${jobName}"`
}
return { summary }
- name: Create Check
uses: LouisBrunner/checks-action@v1.3.1
id: check
if: steps.release.outputs.pr-number
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: in_progress
name: Release
sha: ${{ steps.release.outputs.pr-sha }}
output: ${{ steps.check-output.outputs.result }}
update:
needs: release
outputs:
sha: ${{ steps.commit.outputs.sha }}
check-id: ${{ steps.check.outputs.check_id }}
name: Update - Release
if: github.repository_owner == 'npm' && needs.release.outputs.pr
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ needs.release.outputs.branch }}
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Run Post Pull Request Actions
env:
RELEASE_PR_NUMBER: ${{ needs.release.outputs.pr-number }}
RELEASE_COMMENT_ID: ${{ needs.release.outputs.comment-id }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm exec --offline -- template-oss-release-manager
npm run rp-pull-request --ignore-scripts --if-present
- name: Commit
id: commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git commit --all --amend --no-edit || true
git push --force-with-lease
echo "::set-output name=sha::$(git rev-parse HEAD)"
- name: Get Workflow Job
uses: actions/github-script@v6
id: check-output
env:
JOB_NAME: "Update - Release"
MATRIX_NAME: ""
with:
script: |
const { owner, repo } = context.repo
const { data } = await github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id: context.runId,
per_page: 100
})
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
const job = data.jobs.find(j => j.name.endsWith(jobName))
const jobUrl = job?.html_url
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ steps.commit.outputs.sha }}`
let summary = `This check is assosciated with ${shaUrl}\n\n`
if (jobUrl) {
summary += `For run logs, click here: ${jobUrl}`
} else {
summary += `Run logs could not be found for a job with name: "${jobName}"`
}
return { summary }
- name: Create Check
uses: LouisBrunner/checks-action@v1.3.1
id: check
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: in_progress
name: Release
sha: ${{ steps.commit.outputs.sha }}
output: ${{ steps.check-output.outputs.result }}
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.3.1
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ job.status }}
check_id: ${{ needs.release.outputs.check-id }}
ci:
name: CI - Release
needs: [ release, update ]
if: needs.release.outputs.pr
uses: ./.github/workflows/ci-release.yml
with:
ref: ${{ needs.release.outputs.branch }}
check-sha: ${{ needs.update.outputs.sha }}
post-ci:
needs: [ release, update, ci ]
name: Post CI - Release
if: github.repository_owner == 'npm' && needs.release.outputs.pr && always()
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Get Needs Result
id: needs-result
run: |
result=""
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
result="failure"
elif [[ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
result="cancelled"
else
result="success"
fi
echo "::set-output name=result::$result"
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.3.1
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ steps.needs-result.outputs.result }}
check_id: ${{ needs.update.outputs.check-id }}
post-release:
needs: release
name: Post Release - Release
if: github.repository_owner == 'npm' && needs.release.outputs.releases
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
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: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Run Post Release Actions
env:
RELEASES: ${{ needs.release.outputs.releases }}
run: |
npm run rp-release --ignore-scripts --if-present ${{ join(fromJSON(needs.release.outputs.release-flags), ' ') }}
npm-package-arg-10.0.0/.gitignore 0000664 0000000 0000000 00000000665 14323532274 0016526 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
!**/.gitignore
!/.commitlintrc.js
!/.eslintrc.js
!/.eslintrc.local.*
!/.github/
!/.gitignore
!/.npmrc
!/.release-please-manifest.json
!/bin/
!/CHANGELOG*
!/CODE_OF_CONDUCT.md
!/docs/
!/lib/
!/LICENSE*
!/map.js
!/package.json
!/README*
!/release-please-config.json
!/scripts/
!/SECURITY.md
!/tap-snapshots/
!/test/
npm-package-arg-10.0.0/.npmrc 0000664 0000000 0000000 00000000135 14323532274 0015646 0 ustar 00root root 0000000 0000000 ; This file is automatically added by @npmcli/template-oss. Do not edit.
package-lock=false
npm-package-arg-10.0.0/.release-please-manifest.json 0000664 0000000 0000000 00000000024 14323532274 0022167 0 ustar 00root root 0000000 0000000 {
".": "10.0.0"
}
npm-package-arg-10.0.0/CHANGELOG.md 0000664 0000000 0000000 00000012077 14323532274 0016347 0 ustar 00root root 0000000 0000000 # Changelog
## [10.0.0](https://github.com/npm/npm-package-arg/compare/v9.1.0...v10.0.0) (2022-10-18)
### ⚠️ BREAKING CHANGES
* `x` and `x@` now return the same spec as `x@*`
* `npm-package-arg` is now compatible with the following semver range for node: `^14.17.0 || ^16.13.0 || >=18.0.0`
### Features
* [`749ccad`](https://github.com/npm/npm-package-arg/commit/749ccad1516e0e61db989669326165bfdb6b7227) [#104](https://github.com/npm/npm-package-arg/pull/104) postinstall for dependabot template-oss PR (@lukekarrys)
### Bug Fixes
* [`d2b87c0`](https://github.com/npm/npm-package-arg/commit/d2b87c083f6f83d01d869281631a0d544190edcf) [#97](https://github.com/npm/npm-package-arg/pull/97) standardize `x` `x@` and `x@*` (#97) (@wraithgar)
* [`7b9cb25`](https://github.com/npm/npm-package-arg/commit/7b9cb25e2b2788ae7b0c9a9b33ca8701a030b8aa) [#108](https://github.com/npm/npm-package-arg/pull/108) resolve relative urls that start with file:// (@lukekarrys)
### Dependencies
* [`b3f0b93`](https://github.com/npm/npm-package-arg/commit/b3f0b93abae31e8e3a186c5f6ebedd3616b0764a) [#117](https://github.com/npm/npm-package-arg/pull/117) bump proc-log from 2.0.1 to 3.0.0 (#117)
* [`7162848`](https://github.com/npm/npm-package-arg/commit/71628486d9f96ef522e28cb32e15ff8d26cf3903) [#116](https://github.com/npm/npm-package-arg/pull/116) bump validate-npm-package-name from 4.0.0 to 5.0.0 (#116)
* [`3110d8f`](https://github.com/npm/npm-package-arg/commit/3110d8f954a76e237649bd478d0cb2fbc95f6afc) [#115](https://github.com/npm/npm-package-arg/pull/115) `hosted-git-info@6.0.0` (#115)
## [9.1.0](https://github.com/npm/npm-package-arg/compare/v9.0.2...v9.1.0) (2022-06-22)
### Features
* **git:** add support for :: in #committish ([#91](https://github.com/npm/npm-package-arg/issues/91)) ([246f1e9](https://github.com/npm/npm-package-arg/commit/246f1e919bd19302bbb907acbe87735f61392a9a))
### [9.0.2](https://github.com/npm/npm-package-arg/compare/v9.0.1...v9.0.2) (2022-03-29)
### Dependencies
* bump validate-npm-package-name from 3.0.0 to 4.0.0 ([#83](https://github.com/npm/npm-package-arg/issues/83)) ([05f40c5](https://github.com/npm/npm-package-arg/commit/05f40c512326c0047ef31259ddc231fc81d9a187))
### [9.0.1](https://www.github.com/npm/npm-package-arg/compare/v9.0.0...v9.0.1) (2022-03-15)
### Dependencies
* bump hosted-git-info from 4.1.0 to 5.0.0 ([#75](https://www.github.com/npm/npm-package-arg/issues/75)) ([c26876d](https://www.github.com/npm/npm-package-arg/commit/c26876d116285c8ab6a91f223b679155c91e60a0))
## [9.0.0](https://www.github.com/npm/npm-package-arg/compare/v8.1.5...v9.0.0) (2022-02-10)
### ⚠ BREAKING CHANGES
* This drops support for node10 and non-LTS versions of node 12 and node 14.
### Bug Fixes
* make error message more clear to locate which package is invalid ([8cb4527](https://www.github.com/npm/npm-package-arg/commit/8cb452760e9e0d7921ea59a1e4d3ec3db7994595))
### Dependencies
* @npmcli/template-oss@2.7.1 ([6975264](https://www.github.com/npm/npm-package-arg/commit/6975264f553471a21b4bb313290c226eb3aa8da3))
* update hosted-git-info requirement from ^4.0.1 to ^4.1.0 ([c6a9e12](https://www.github.com/npm/npm-package-arg/commit/c6a9e12c67d4209118dfabe6e110ece64a0ad1b7))
* update semver requirement from ^7.3.4 to ^7.3.5 ([73fc02e](https://www.github.com/npm/npm-package-arg/commit/73fc02e91ba887201880d37be81838df9b161f05))
### Documentation
* Update result object documentation for type=alias ([55907a9](https://www.github.com/npm/npm-package-arg/commit/55907a917979e566250428dc6da9aad8fd4fb65a))
## [8.0.0](https://github.com/npm/npm-package-arg/compare/v7.0.0...v8.0.0) (2019-12-15)
### ⚠ BREAKING CHANGES
* Dropping support for node 6 and 8. It'll probably
still work on those versions, but they are no longer supported or
tested, since npm v7 is moving away from them.
* drop support for node 6 and 8 ([ba85e68](https://github.com/npm/npm-package-arg/commit/ba85e68555d6270f672c3d59da17672f744d0376))
# [7.0.0](https://github.com/npm/npm-package-arg/compare/v6.1.1...v7.0.0) (2019-11-11)
### deps
* bump hosted-git-info to 3.0.2 ([68a4fc3](https://github.com/npm/npm-package-arg/commit/68a4fc3)), closes [/github.com/npm/hosted-git-info/pull/38#issuecomment-520243803](https://github.com//github.com/npm/hosted-git-info/pull/38/issues/issuecomment-520243803)
### BREAKING CHANGES
* this drops support for ancient node versions.
## [6.1.1](https://github.com/npm/npm-package-arg/compare/v6.1.0...v6.1.1) (2019-08-21)
### Bug Fixes
* preserve drive letter on windows git file:// urls ([3909203](https://github.com/npm/npm-package-arg/commit/3909203))
# [6.1.0](https://github.com/npm/npm-package-arg/compare/v6.0.0...v6.1.0) (2018-04-10)
### Bug Fixes
* **git:** Fix gitRange for git+ssh for private git ([#33](https://github.com/npm/npm-package-arg/issues/33)) ([647a0b3](https://github.com/npm/npm-package-arg/commit/647a0b3))
### Features
* **alias:** add `npm:` registry alias spec ([#34](https://github.com/npm/npm-package-arg/issues/34)) ([ab99f8e](https://github.com/npm/npm-package-arg/commit/ab99f8e))
npm-package-arg-10.0.0/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000000507 14323532274 0017330 0 ustar 00root root 0000000 0000000
All interactions in this repo are covered by the [npm Code of
Conduct](https://docs.npmjs.com/policies/conduct)
The npm cli team may, at its own discretion, moderate, remove, or edit
any interactions such as pull requests, issues, and comments.
npm-package-arg-10.0.0/LICENSE 0000664 0000000 0000000 00000001343 14323532274 0015535 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-package-arg-10.0.0/README.md 0000664 0000000 0000000 00000007435 14323532274 0016017 0 ustar 00root root 0000000 0000000 # npm-package-arg
[](https://travis-ci.org/npm/npm-package-arg)
Parses package name and specifier passed to commands like `npm install` or
`npm cache add`, or as found in `package.json` dependency sections.
## EXAMPLES
```javascript
var assert = require("assert")
var npa = require("npm-package-arg")
// Pass in the descriptor, and it'll return an object
try {
var parsed = npa("@bar/foo@1.2")
} catch (ex) {
…
}
```
## USING
`var npa = require('npm-package-arg')`
### var result = npa(*arg*[, *where*])
* *arg* - a string that you might pass to `npm install`, like:
`foo@1.2`, `@bar/foo@1.2`, `foo@user/foo`, `http://x.com/foo.tgz`,
`git+https://github.com/user/foo`, `bitbucket:user/foo`, `foo.tar.gz`,
`../foo/bar/` or `bar`. If the *arg* you provide doesn't have a specifier
part, eg `foo` then the specifier will default to `latest`.
* *where* - Optionally the path to resolve file paths relative to. Defaults to `process.cwd()`
**Throws** if the package name is invalid, a dist-tag is invalid or a URL's protocol is not supported.
### var result = npa.resolve(*name*, *spec*[, *where*])
* *name* - The name of the module you want to install. For example: `foo` or `@bar/foo`.
* *spec* - The specifier indicating where and how you can get this module. Something like:
`1.2`, `^1.7.17`, `http://x.com/foo.tgz`, `git+https://github.com/user/foo`,
`bitbucket:user/foo`, `file:foo.tar.gz` or `file:../foo/bar/`. If not
included then the default is `latest`.
* *where* - Optionally the path to resolve file paths relative to. Defaults to `process.cwd()`
**Throws** if the package name is invalid, a dist-tag is invalid or a URL's protocol is not supported.
## RESULT OBJECT
The objects that are returned by npm-package-arg contain the following
keys:
* `type` - One of the following strings:
* `git` - A git repo
* `tag` - A tagged version, like `"foo@latest"`
* `version` - A specific version number, like `"foo@1.2.3"`
* `range` - A version range, like `"foo@2.x"`
* `file` - A local `.tar.gz`, `.tar` or `.tgz` file.
* `directory` - A local directory.
* `remote` - An http url (presumably to a tgz)
* `alias` - A specifier with an alias, like `myalias@npm:foo@1.2.3`
* `registry` - If true this specifier refers to a resource hosted on a
registry. This is true for `tag`, `version` and `range` types.
* `name` - If known, the `name` field expected in the resulting pkg.
* `scope` - If a name is something like `@org/module` then the `scope`
field will be set to `@org`. If it doesn't have a scoped name, then
scope is `null`.
* `escapedName` - A version of `name` escaped to match the npm scoped packages
specification. Mostly used when making requests against a registry. When
`name` is `null`, `escapedName` will also be `null`.
* `rawSpec` - The specifier part that was parsed out in calls to `npa(arg)`,
or the value of `spec` in calls to `npa.resolve(name, spec).
* `saveSpec` - The normalized specifier, for saving to package.json files.
`null` for registry dependencies.
* `fetchSpec` - The version of the specifier to be used to fetch this
resource. `null` for shortcuts to hosted git dependencies as there isn't
just one URL to try with them.
* `gitRange` - If set, this is a semver specifier to match against git tags with
* `gitCommittish` - If set, this is the specific committish to use with a git dependency.
* `hosted` - If `from === 'hosted'` then this will be a `hosted-git-info`
object. This property is not included when serializing the object as
JSON.
* `raw` - The original un-modified string that was provided. If called as
`npa.resolve(name, spec)` then this will be `name + '@' + spec`.
* `subSpec` - If `type === 'alias'`, this is a Result Object for parsing the
target specifier for the alias.
npm-package-arg-10.0.0/SECURITY.md 0000664 0000000 0000000 00000000246 14323532274 0016322 0 ustar 00root root 0000000 0000000
Please send vulnerability reports through [hackerone](https://hackerone.com/github).
npm-package-arg-10.0.0/lib/ 0000775 0000000 0000000 00000000000 14323532274 0015275 5 ustar 00root root 0000000 0000000 npm-package-arg-10.0.0/lib/npa.js 0000664 0000000 0000000 00000030321 14323532274 0016410 0 ustar 00root root 0000000 0000000 'use strict'
module.exports = npa
module.exports.resolve = resolve
module.exports.Result = Result
const url = require('url')
const HostedGit = require('hosted-git-info')
const semver = require('semver')
const path = global.FAKE_WINDOWS ? require('path').win32 : require('path')
const validatePackageName = require('validate-npm-package-name')
const { homedir } = require('os')
const log = require('proc-log')
const isWindows = process.platform === 'win32' || global.FAKE_WINDOWS
const hasSlashes = isWindows ? /\\|[/]/ : /[/]/
const isURL = /^(?:git[+])?[a-z]+:/i
const isGit = /^[^@]+@[^:.]+\.[^:]+:.+$/i
const isFilename = /[.](?:tgz|tar.gz|tar)$/i
function npa (arg, where) {
let name
let spec
if (typeof arg === 'object') {
if (arg instanceof Result && (!where || where === arg.where)) {
return arg
} else if (arg.name && arg.rawSpec) {
return npa.resolve(arg.name, arg.rawSpec, where || arg.where)
} else {
return npa(arg.raw, where || arg.where)
}
}
const nameEndsAt = arg[0] === '@' ? arg.slice(1).indexOf('@') + 1 : arg.indexOf('@')
const namePart = nameEndsAt > 0 ? arg.slice(0, nameEndsAt) : arg
if (isURL.test(arg)) {
spec = arg
} else if (isGit.test(arg)) {
spec = `git+ssh://${arg}`
} else if (namePart[0] !== '@' && (hasSlashes.test(namePart) || isFilename.test(namePart))) {
spec = arg
} else if (nameEndsAt > 0) {
name = namePart
spec = arg.slice(nameEndsAt + 1) || '*'
} else {
const valid = validatePackageName(arg)
if (valid.validForOldPackages) {
name = arg
spec = '*'
} else {
spec = arg
}
}
return resolve(name, spec, where, arg)
}
const isFilespec = isWindows ? /^(?:[.]|~[/]|[/\\]|[a-zA-Z]:)/ : /^(?:[.]|~[/]|[/]|[a-zA-Z]:)/
function resolve (name, spec, where, arg) {
const res = new Result({
raw: arg,
name: name,
rawSpec: spec,
fromArgument: arg != null,
})
if (name) {
res.setName(name)
}
if (spec && (isFilespec.test(spec) || /^file:/i.test(spec))) {
return fromFile(res, where)
} else if (spec && /^npm:/i.test(spec)) {
return fromAlias(res, where)
}
const hosted = HostedGit.fromUrl(spec, {
noGitPlus: true,
noCommittish: true,
})
if (hosted) {
return fromHostedGit(res, hosted)
} else if (spec && isURL.test(spec)) {
return fromURL(res)
} else if (spec && (hasSlashes.test(spec) || isFilename.test(spec))) {
return fromFile(res, where)
} else {
return fromRegistry(res)
}
}
function invalidPackageName (name, valid, raw) {
// eslint-disable-next-line max-len
const err = new Error(`Invalid package name "${name}" of package "${raw}": ${valid.errors.join('; ')}.`)
err.code = 'EINVALIDPACKAGENAME'
return err
}
function invalidTagName (name, raw) {
// eslint-disable-next-line max-len
const err = new Error(`Invalid tag name "${name}" of package "${raw}": Tags may not have any characters that encodeURIComponent encodes.`)
err.code = 'EINVALIDTAGNAME'
return err
}
function Result (opts) {
this.type = opts.type
this.registry = opts.registry
this.where = opts.where
if (opts.raw == null) {
this.raw = opts.name ? opts.name + '@' + opts.rawSpec : opts.rawSpec
} else {
this.raw = opts.raw
}
this.name = undefined
this.escapedName = undefined
this.scope = undefined
this.rawSpec = opts.rawSpec || ''
this.saveSpec = opts.saveSpec
this.fetchSpec = opts.fetchSpec
if (opts.name) {
this.setName(opts.name)
}
this.gitRange = opts.gitRange
this.gitCommittish = opts.gitCommittish
this.gitSubdir = opts.gitSubdir
this.hosted = opts.hosted
}
Result.prototype.setName = function (name) {
const valid = validatePackageName(name)
if (!valid.validForOldPackages) {
throw invalidPackageName(name, valid, this.raw)
}
this.name = name
this.scope = name[0] === '@' ? name.slice(0, name.indexOf('/')) : undefined
// scoped packages in couch must have slash url-encoded, e.g. @foo%2Fbar
this.escapedName = name.replace('/', '%2f')
return this
}
Result.prototype.toString = function () {
const full = []
if (this.name != null && this.name !== '') {
full.push(this.name)
}
const spec = this.saveSpec || this.fetchSpec || this.rawSpec
if (spec != null && spec !== '') {
full.push(spec)
}
return full.length ? full.join('@') : this.raw
}
Result.prototype.toJSON = function () {
const result = Object.assign({}, this)
delete result.hosted
return result
}
function setGitCommittish (res, committish) {
if (!committish) {
res.gitCommittish = null
return res
}
// for each :: separated item:
for (const part of committish.split('::')) {
// if the item has no : the n it is a commit-ish
if (!part.includes(':')) {
if (res.gitRange) {
throw new Error('cannot override existing semver range with a committish')
}
if (res.gitCommittish) {
throw new Error('cannot override existing committish with a second committish')
}
res.gitCommittish = part
continue
}
// split on name:value
const [name, value] = part.split(':')
// if name is semver do semver lookup of ref or tag
if (name === 'semver') {
if (res.gitCommittish) {
throw new Error('cannot override existing committish with a semver range')
}
if (res.gitRange) {
throw new Error('cannot override existing semver range with a second semver range')
}
res.gitRange = decodeURIComponent(value)
continue
}
if (name === 'path') {
if (res.gitSubdir) {
throw new Error('cannot override existing path with a second path')
}
res.gitSubdir = `/${value}`
continue
}
log.warn('npm-package-arg', `ignoring unknown key "${name}"`)
}
return res
}
function fromFile (res, where) {
if (!where) {
where = process.cwd()
}
res.type = isFilename.test(res.rawSpec) ? 'file' : 'directory'
res.where = where
// always put the '/' on where when resolving urls, or else
// file:foo from /path/to/bar goes to /path/to/foo, when we want
// it to be /path/to/bar/foo
let specUrl
let resolvedUrl
const prefix = (!/^file:/.test(res.rawSpec) ? 'file:' : '')
const rawWithPrefix = prefix + res.rawSpec
let rawNoPrefix = rawWithPrefix.replace(/^file:/, '')
try {
resolvedUrl = new url.URL(rawWithPrefix, `file://${path.resolve(where)}/`)
specUrl = new url.URL(rawWithPrefix)
} catch (originalError) {
const er = new Error('Invalid file: URL, must comply with RFC 8909')
throw Object.assign(er, {
raw: res.rawSpec,
spec: res,
where,
originalError,
})
}
// environment switch for testing
if (process.env.NPM_PACKAGE_ARG_8909_STRICT !== '1') {
// XXX backwards compatibility lack of compliance with 8909
// Remove when we want a breaking change to come into RFC compliance.
if (resolvedUrl.host && resolvedUrl.host !== 'localhost') {
const rawSpec = res.rawSpec.replace(/^file:\/\//, 'file:///')
resolvedUrl = new url.URL(rawSpec, `file://${path.resolve(where)}/`)
specUrl = new url.URL(rawSpec)
rawNoPrefix = rawSpec.replace(/^file:/, '')
}
// turn file:/../foo into file:../foo
// for 1, 2 or 3 leading slashes since we attempted
// in the previous step to make it a file protocol url with a leading slash
if (/^\/{1,3}\.\.?(\/|$)/.test(rawNoPrefix)) {
const rawSpec = res.rawSpec.replace(/^file:\/{1,3}/, 'file:')
resolvedUrl = new url.URL(rawSpec, `file://${path.resolve(where)}/`)
specUrl = new url.URL(rawSpec)
rawNoPrefix = rawSpec.replace(/^file:/, '')
}
// XXX end 8909 violation backwards compatibility section
}
// file:foo - relative url to ./foo
// file:/foo - absolute path /foo
// file:///foo - absolute path to /foo, no authority host
// file://localhost/foo - absolute path to /foo, on localhost
// file://foo - absolute path to / on foo host (error!)
if (resolvedUrl.host && resolvedUrl.host !== 'localhost') {
const msg = `Invalid file: URL, must be absolute if // present`
throw Object.assign(new Error(msg), {
raw: res.rawSpec,
parsed: resolvedUrl,
})
}
// turn /C:/blah into just C:/blah on windows
let specPath = decodeURIComponent(specUrl.pathname)
let resolvedPath = decodeURIComponent(resolvedUrl.pathname)
if (isWindows) {
specPath = specPath.replace(/^\/+([a-z]:\/)/i, '$1')
resolvedPath = resolvedPath.replace(/^\/+([a-z]:\/)/i, '$1')
}
// replace ~ with homedir, but keep the ~ in the saveSpec
// otherwise, make it relative to where param
if (/^\/~(\/|$)/.test(specPath)) {
res.saveSpec = `file:${specPath.substr(1)}`
resolvedPath = path.resolve(homedir(), specPath.substr(3))
} else if (!path.isAbsolute(rawNoPrefix)) {
res.saveSpec = `file:${path.relative(where, resolvedPath)}`
} else {
res.saveSpec = `file:${path.resolve(resolvedPath)}`
}
res.fetchSpec = path.resolve(where, resolvedPath)
return res
}
function fromHostedGit (res, hosted) {
res.type = 'git'
res.hosted = hosted
res.saveSpec = hosted.toString({ noGitPlus: false, noCommittish: false })
res.fetchSpec = hosted.getDefaultRepresentation() === 'shortcut' ? null : hosted.toString()
return setGitCommittish(res, hosted.committish)
}
function unsupportedURLType (protocol, spec) {
const err = new Error(`Unsupported URL Type "${protocol}": ${spec}`)
err.code = 'EUNSUPPORTEDPROTOCOL'
return err
}
function matchGitScp (spec) {
// git ssh specifiers are overloaded to also use scp-style git
// specifiers, so we have to parse those out and treat them special.
// They are NOT true URIs, so we can't hand them to `url.parse`.
//
// This regex looks for things that look like:
// git+ssh://git@my.custom.git.com:username/project.git#deadbeef
//
// ...and various combinations. The username in the beginning is *required*.
const matched = spec.match(/^git\+ssh:\/\/([^:#]+:[^#]+(?:\.git)?)(?:#(.*))?$/i)
return matched && !matched[1].match(/:[0-9]+\/?.*$/i) && {
fetchSpec: matched[1],
gitCommittish: matched[2] == null ? null : matched[2],
}
}
function fromURL (res) {
// eslint-disable-next-line node/no-deprecated-api
const urlparse = url.parse(res.rawSpec)
res.saveSpec = res.rawSpec
// check the protocol, and then see if it's git or not
switch (urlparse.protocol) {
case 'git:':
case 'git+http:':
case 'git+https:':
case 'git+rsync:':
case 'git+ftp:':
case 'git+file:':
case 'git+ssh:': {
res.type = 'git'
const match = urlparse.protocol === 'git+ssh:' ? matchGitScp(res.rawSpec)
: null
if (match) {
setGitCommittish(res, match.gitCommittish)
res.fetchSpec = match.fetchSpec
} else {
setGitCommittish(res, urlparse.hash != null ? urlparse.hash.slice(1) : '')
urlparse.protocol = urlparse.protocol.replace(/^git[+]/, '')
if (urlparse.protocol === 'file:' && /^git\+file:\/\/[a-z]:/i.test(res.rawSpec)) {
// keep the drive letter : on windows file paths
urlparse.host += ':'
urlparse.hostname += ':'
}
delete urlparse.hash
res.fetchSpec = url.format(urlparse)
}
break
}
case 'http:':
case 'https:':
res.type = 'remote'
res.fetchSpec = res.saveSpec
break
default:
throw unsupportedURLType(urlparse.protocol, res.rawSpec)
}
return res
}
function fromAlias (res, where) {
const subSpec = npa(res.rawSpec.substr(4), where)
if (subSpec.type === 'alias') {
throw new Error('nested aliases not supported')
}
if (!subSpec.registry) {
throw new Error('aliases only work for registry deps')
}
res.subSpec = subSpec
res.registry = true
res.type = 'alias'
res.saveSpec = null
res.fetchSpec = null
return res
}
function fromRegistry (res) {
res.registry = true
const spec = res.rawSpec.trim()
// no save spec for registry components as we save based on the fetched
// version, not on the argument so this can't compute that.
res.saveSpec = null
res.fetchSpec = spec
const version = semver.valid(spec, true)
const range = semver.validRange(spec, true)
if (version) {
res.type = 'version'
} else if (range) {
res.type = 'range'
} else {
if (encodeURIComponent(spec) !== spec) {
throw invalidTagName(spec, res.raw)
}
res.type = 'tag'
}
return res
}
npm-package-arg-10.0.0/package.json 0000664 0000000 0000000 00000002655 14323532274 0017025 0 ustar 00root root 0000000 0000000 {
"name": "npm-package-arg",
"version": "10.0.0",
"description": "Parse the things that can be arguments to `npm install`",
"main": "./lib/npa.js",
"directories": {
"test": "test"
},
"files": [
"bin/",
"lib/"
],
"dependencies": {
"hosted-git-info": "^6.0.0",
"proc-log": "^3.0.0",
"semver": "^7.3.5",
"validate-npm-package-name": "^5.0.0"
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.6.1",
"tap": "^16.0.1"
},
"scripts": {
"test": "tap",
"snap": "tap",
"npmclilint": "npmcli-lint",
"lint": "eslint \"**/*.js\"",
"lintfix": "npm run lint -- --fix",
"posttest": "npm run lint",
"postsnap": "npm run lintfix --",
"postlint": "template-oss-check",
"template-oss-apply": "template-oss-apply --force"
},
"repository": {
"type": "git",
"url": "https://github.com/npm/npm-package-arg.git"
},
"author": "GitHub Inc.",
"license": "ISC",
"bugs": {
"url": "https://github.com/npm/npm-package-arg/issues"
},
"homepage": "https://github.com/npm/npm-package-arg",
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
},
"tap": {
"branches": 97,
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.6.1"
}
}
npm-package-arg-10.0.0/release-please-config.json 0000664 0000000 0000000 00000001254 14323532274 0021556 0 ustar 00root root 0000000 0000000 {
"exclude-packages-from-root": true,
"group-pull-request-title-pattern": "chore: release ${version}",
"pull-request-title-pattern": "chore: release${component} ${version}",
"changelog-sections": [
{
"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
}
],
"packages": {
".": {
"package-name": ""
}
}
}
npm-package-arg-10.0.0/test/ 0000775 0000000 0000000 00000000000 14323532274 0015506 5 ustar 00root root 0000000 0000000 npm-package-arg-10.0.0/test/basic.js 0000664 0000000 0000000 00000052264 14323532274 0017136 0 ustar 00root root 0000000 0000000 const path = require('path').posix
const os = require('os')
const normalizePath = p => p && p.replace(/^[a-zA-Z]:/, '').replace(/\\/g, '/')
const cwd = normalizePath(process.cwd())
process.cwd = () => cwd
const normalizePaths = spec => {
spec.saveSpec = normalizePath(spec.saveSpec)
spec.fetchSpec = normalizePath(spec.fetchSpec)
return spec
}
const t = require('tap')
const npa = t.mock('..', { path })
t.on('bailout', () => process.exit(1))
t.test('basic', function (t) {
t.setMaxListeners(999)
const tests = {
'foo@1.2': {
name: 'foo',
escapedName: 'foo',
type: 'range',
saveSpec: null,
fetchSpec: '1.2',
raw: 'foo@1.2',
rawSpec: '1.2',
},
'foo@~1.2': {
name: 'foo',
escapedName: 'foo',
type: 'range',
saveSpec: null,
fetchSpec: '~1.2',
raw: 'foo@~1.2',
rawSpec: '~1.2',
},
'@foo/bar': {
raw: '@foo/bar',
name: '@foo/bar',
escapedName: '@foo%2fbar',
scope: '@foo',
rawSpec: '*',
saveSpec: null,
fetchSpec: '*',
type: 'range',
},
'@foo/bar@': {
raw: '@foo/bar@',
name: '@foo/bar',
escapedName: '@foo%2fbar',
scope: '@foo',
rawSpec: '*',
saveSpec: null,
fetchSpec: '*',
type: 'range',
},
'@foo/bar@baz': {
raw: '@foo/bar@baz',
name: '@foo/bar',
escapedName: '@foo%2fbar',
scope: '@foo',
rawSpec: 'baz',
saveSpec: null,
fetchSpec: 'baz',
type: 'tag',
},
'@f fo o al/ a d s ;f': {
raw: '@f fo o al/ a d s ;f',
name: null,
escapedName: null,
rawSpec: '@f fo o al/ a d s ;f',
saveSpec: 'file:@f fo o al/ a d s ;f',
fetchSpec: '/test/a/b/@f fo o al/ a d s ;f',
type: 'directory',
},
'foo@1.2.3': {
name: 'foo',
escapedName: 'foo',
type: 'version',
saveSpec: null,
fetchSpec: '1.2.3',
raw: 'foo@1.2.3',
},
'foo@=v1.2.3': {
name: 'foo',
escapedName: 'foo',
type: 'version',
saveSpec: null,
fetchSpec: '=v1.2.3',
raw: 'foo@=v1.2.3',
rawSpec: '=v1.2.3',
},
'foo@npm:bar': {
name: 'foo',
escapedName: 'foo',
type: 'alias',
saveSpec: null,
fetchSpec: null,
raw: 'foo@npm:bar',
rawSpec: 'npm:bar',
subSpec: {
registry: true,
name: 'bar',
escapedName: 'bar',
type: 'range',
raw: 'bar',
rawSpec: '*',
saveSpec: null,
fetchSpec: '*',
},
},
'git+ssh://git@notgithub.com/user/foo#1.2.3': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git+ssh://git@notgithub.com/user/foo#1.2.3',
fetchSpec: 'ssh://git@notgithub.com/user/foo',
gitCommittish: '1.2.3',
raw: 'git+ssh://git@notgithub.com/user/foo#1.2.3',
},
'git+ssh://git@notgithub.com/user/foo': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git+ssh://git@notgithub.com/user/foo',
fetchSpec: 'ssh://git@notgithub.com/user/foo',
gitCommittish: null,
raw: 'git+ssh://git@notgithub.com/user/foo',
},
'git+ssh://git@notgithub.com:user/foo': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git+ssh://git@notgithub.com:user/foo',
fetchSpec: 'git@notgithub.com:user/foo',
gitCommittish: null,
raw: 'git+ssh://git@notgithub.com:user/foo',
},
'git+ssh://mydomain.com:foo': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git+ssh://mydomain.com:foo',
fetchSpec: 'mydomain.com:foo',
gitCommittish: null,
raw: 'git+ssh://mydomain.com:foo',
},
'git+ssh://git@notgithub.com:user/foo#1.2.3': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git+ssh://git@notgithub.com:user/foo#1.2.3',
fetchSpec: 'git@notgithub.com:user/foo',
gitCommittish: '1.2.3',
raw: 'git+ssh://git@notgithub.com:user/foo#1.2.3',
},
'git+ssh://mydomain.com:foo#1.2.3': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git+ssh://mydomain.com:foo#1.2.3',
fetchSpec: 'mydomain.com:foo',
gitCommittish: '1.2.3',
raw: 'git+ssh://mydomain.com:foo#1.2.3',
},
'git+ssh://mydomain.com:foo/bar#1.2.3': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git+ssh://mydomain.com:foo/bar#1.2.3',
fetchSpec: 'mydomain.com:foo/bar',
gitCommittish: '1.2.3',
raw: 'git+ssh://mydomain.com:foo/bar#1.2.3',
},
'git+ssh://mydomain.com:1234#1.2.3': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git+ssh://mydomain.com:1234#1.2.3',
fetchSpec: 'ssh://mydomain.com:1234',
gitCommittish: '1.2.3',
raw: 'git+ssh://mydomain.com:1234#1.2.3',
},
'git+ssh://mydomain.com:1234/hey#1.2.3': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git+ssh://mydomain.com:1234/hey#1.2.3',
fetchSpec: 'ssh://mydomain.com:1234/hey',
gitCommittish: '1.2.3',
raw: 'git+ssh://mydomain.com:1234/hey#1.2.3',
},
'git+ssh://mydomain.com:1234/hey': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git+ssh://mydomain.com:1234/hey',
fetchSpec: 'ssh://mydomain.com:1234/hey',
gitCommittish: null,
raw: 'git+ssh://mydomain.com:1234/hey',
},
'git+ssh://username:password@mydomain.com:1234/hey#1.2.3': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git+ssh://username:password@mydomain.com:1234/hey#1.2.3',
fetchSpec: 'ssh://username:password@mydomain.com:1234/hey',
gitCommittish: '1.2.3',
raw: 'git+ssh://username:password@mydomain.com:1234/hey#1.2.3',
},
'git+ssh://git@github.com/user/foo#1.2.3': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git+ssh://git@github.com/user/foo.git#1.2.3',
fetchSpec: 'ssh://git@github.com/user/foo.git',
gitCommittish: '1.2.3',
raw: 'git+ssh://git@github.com/user/foo#1.2.3',
},
'git+ssh://git@notgithub.com/user/foo#semver:^1.2.3': {
name: null,
escapedName: null,
type: 'git',
hosted: null,
saveSpec: 'git+ssh://git@notgithub.com/user/foo#semver:^1.2.3',
fetchSpec: 'ssh://git@notgithub.com/user/foo',
gitCommittish: null,
gitRange: '^1.2.3',
raw: 'git+ssh://git@notgithub.com/user/foo#semver:^1.2.3',
},
'git+ssh://git@notgithub.com:user/foo#semver:^1.2.3': {
name: null,
escapedName: null,
type: 'git',
hosted: null,
saveSpec: 'git+ssh://git@notgithub.com:user/foo#semver:^1.2.3',
fetchSpec: 'git@notgithub.com:user/foo',
gitCommittish: null,
gitRange: '^1.2.3',
raw: 'git+ssh://git@notgithub.com:user/foo#semver:^1.2.3',
},
'git+ssh://git@github.com/user/foo#semver:^1.2.3': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git+ssh://git@github.com/user/foo.git#semver:^1.2.3',
fetchSpec: 'ssh://git@github.com/user/foo.git',
gitCommittish: null,
gitRange: '^1.2.3',
raw: 'git+ssh://git@github.com/user/foo#semver:^1.2.3',
},
'git+ssh://git@github.com:user/foo#semver:^1.2.3': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git+ssh://git@github.com/user/foo.git#semver:^1.2.3',
fetchSpec: 'ssh://git@github.com/user/foo.git',
gitCommittish: null,
gitRange: '^1.2.3',
raw: 'git+ssh://git@github.com:user/foo#semver:^1.2.3',
},
'user/foo#semver:^1.2.3': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'github:user/foo#semver:^1.2.3',
fetchSpec: null,
gitCommittish: null,
gitRange: '^1.2.3',
raw: 'user/foo#semver:^1.2.3',
},
'user/foo#path:dist': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'github:user/foo#path:dist',
fetchSpec: null,
gitCommittish: null,
gitSubdir: '/dist',
raw: 'user/foo#path:dist',
},
'user/foo#1234::path:dist': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'github:user/foo#1234::path:dist',
fetchSpec: null,
gitCommittish: '1234',
gitRange: null,
gitSubdir: '/dist',
raw: 'user/foo#1234::path:dist',
},
'user/foo#notimplemented:value': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'github:user/foo#notimplemented:value',
fetchSpec: null,
gitCommittish: null,
gitRange: null,
gitSubdir: null,
raw: 'user/foo#notimplemented:value',
},
'git+file://path/to/repo#1.2.3': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git+file://path/to/repo#1.2.3',
fetchSpec: 'file://path/to/repo',
gitCommittish: '1.2.3',
raw: 'git+file://path/to/repo#1.2.3',
},
'git://notgithub.com/user/foo': {
name: null,
escapedName: null,
type: 'git',
saveSpec: 'git://notgithub.com/user/foo',
fetchSpec: 'git://notgithub.com/user/foo',
raw: 'git://notgithub.com/user/foo',
},
'@foo/bar@git+ssh://notgithub.com/user/foo': {
name: '@foo/bar',
escapedName: '@foo%2fbar',
scope: '@foo',
saveSpec: 'git+ssh://notgithub.com/user/foo',
fetchSpec: 'ssh://notgithub.com/user/foo',
rawSpec: 'git+ssh://notgithub.com/user/foo',
raw: '@foo/bar@git+ssh://notgithub.com/user/foo',
},
'git@npm:not-git': {
name: 'git',
type: 'alias',
subSpec: {
type: 'range',
registry: true,
name: 'not-git',
fetchSpec: '*',
},
raw: 'git@npm:not-git',
},
'not-git@hostname.com:some/repo': {
name: null,
type: 'git',
saveSpec: 'git+ssh://not-git@hostname.com:some/repo',
fetchSpec: 'not-git@hostname.com:some/repo',
raw: 'not-git@hostname.com:some/repo',
},
'/path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:/path/to/foo',
fetchSpec: '/path/to/foo',
raw: '/path/to/foo',
},
'/path/to/foo.tar': {
name: null,
escapedName: null,
type: 'file',
saveSpec: 'file:/path/to/foo.tar',
fetchSpec: '/path/to/foo.tar',
raw: '/path/to/foo.tar',
},
'/path/to/foo.tgz': {
name: null,
escapedName: null,
type: 'file',
saveSpec: 'file:/path/to/foo.tgz',
fetchSpec: '/path/to/foo.tgz',
raw: '/path/to/foo.tgz',
},
'file:path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:path/to/foo',
fetchSpec: '/test/a/b/path/to/foo',
raw: 'file:path/to/foo',
},
'file:path/to/foo.tar.gz': {
name: null,
escapedName: null,
type: 'file',
saveSpec: 'file:path/to/foo',
fetchSpec: '/test/a/b/path/to/foo.tar.gz',
raw: 'file:path/to/foo.tar.gz',
},
'file:~/path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:~/path/to/foo',
fetchSpec: normalizePath(path.join(os.homedir(), '/path/to/foo')),
raw: 'file:~/path/to/foo',
},
'file:/~/path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:~/path/to/foo',
fetchSpec: normalizePath(path.join(os.homedir(), '/path/to/foo')),
raw: 'file:/~/path/to/foo',
},
'file:/~path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:/~path/to/foo',
fetchSpec: '/~path/to/foo',
raw: 'file:/~path/to/foo',
},
'file:/.path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:/.path/to/foo',
fetchSpec: '/.path/to/foo',
raw: 'file:/.path/to/foo',
},
'file:./path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:path/to/foo',
fetchSpec: '/test/a/b/path/to/foo',
raw: 'file:./path/to/foo',
},
'file:/./path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:path/to/foo',
fetchSpec: '/test/a/b/path/to/foo',
raw: 'file:/./path/to/foo',
},
'file://./path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:path/to/foo',
fetchSpec: '/test/a/b/path/to/foo',
raw: 'file://./path/to/foo',
},
'file:../path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:../path/to/foo',
fetchSpec: '/test/a/path/to/foo',
raw: 'file:../path/to/foo',
},
'file:/../path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:../path/to/foo',
fetchSpec: '/test/a/path/to/foo',
raw: 'file:/../path/to/foo',
},
'file://../path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:../path/to/foo',
fetchSpec: '/test/a/path/to/foo',
raw: 'file://../path/to/foo',
},
'file:///path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:/path/to/foo',
fetchSpec: '/path/to/foo',
raw: 'file:///path/to/foo',
},
'file:/path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:/path/to/foo',
fetchSpec: '/path/to/foo',
raw: 'file:/path/to/foo',
},
'file://path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:/path/to/foo',
fetchSpec: '/path/to/foo',
raw: 'file://path/to/foo',
},
'file:////path/to/foo': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:/path/to/foo',
fetchSpec: '/path/to/foo',
raw: 'file:////path/to/foo',
},
'file://.': {
name: null,
escapedName: null,
type: 'directory',
saveSpec: 'file:',
fetchSpec: '/test/a/b',
raw: 'file://.',
},
'http://insecure.com/foo.tgz': {
name: null,
escapedName: null,
type: 'remote',
saveSpec: 'http://insecure.com/foo.tgz',
fetchSpec: 'http://insecure.com/foo.tgz',
raw: 'http://insecure.com/foo.tgz',
},
'https://server.com/foo.tgz': {
name: null,
escapedName: null,
type: 'remote',
saveSpec: 'https://server.com/foo.tgz',
fetchSpec: 'https://server.com/foo.tgz',
raw: 'https://server.com/foo.tgz',
},
'foo@latest': {
name: 'foo',
escapedName: 'foo',
type: 'tag',
saveSpec: null,
fetchSpec: 'latest',
raw: 'foo@latest',
},
foo: {
name: 'foo',
escapedName: 'foo',
type: 'range',
saveSpec: null,
fetchSpec: '*',
raw: 'foo',
},
'foo@ 1.2 ': {
name: 'foo',
escapedName: 'foo',
type: 'range',
saveSpec: null,
fetchSpec: '1.2',
raw: 'foo@ 1.2 ',
rawSpec: ' 1.2 ',
},
'foo@ 1.2.3 ': {
name: 'foo',
escapedName: 'foo',
type: 'version',
saveSpec: null,
fetchSpec: '1.2.3',
raw: 'foo@ 1.2.3 ',
rawSpec: ' 1.2.3 ',
},
'foo@1.2.3 ': {
name: 'foo',
escapedName: 'foo',
type: 'version',
saveSpec: null,
fetchSpec: '1.2.3',
raw: 'foo@1.2.3 ',
rawSpec: '1.2.3 ',
},
'foo@ 1.2.3': {
name: 'foo',
escapedName: 'foo',
type: 'version',
saveSpec: null,
fetchSpec: '1.2.3',
raw: 'foo@ 1.2.3',
rawSpec: ' 1.2.3',
},
}
Object.keys(tests).forEach(function (arg) {
const res = normalizePaths(npa(arg, '/test/a/b'))
t.ok(res instanceof npa.Result, arg + ' is a result')
Object.keys(tests[arg]).forEach(function (key) {
t.match(res[key], tests[arg][key], arg + ' [' + key + ']')
})
})
let objSpec = { name: 'foo', rawSpec: '1.2.3' }
t.equal(npa(objSpec, '/whatnot').toString(), 'foo@1.2.3', 'parsed object')
objSpec.where = '/whatnot'
t.equal(npa(objSpec).toString(), 'foo@1.2.3', 'parsed object w/o where arg')
t.equal(npa('git+http://foo.com/bar').toString(),
'git+http://foo.com/bar', 'parsed git toString')
objSpec = { raw: './foo/bar', where: '/here' }
t.equal(normalizePath(npa(objSpec).fetchSpec), '/here/foo/bar', '`where` is reused')
let res = new npa.Result({ name: 'bar', rawSpec: './foo/bar' })
t.equal(res.toString(), 'bar@./foo/bar', 'toString with only rawSpec')
res = new npa.Result({ rawSpec: './x/y' })
t.equal(normalizePath(res.toString()), './x/y', 'toString with only rawSpec, no name')
res = new npa.Result({ rawSpec: '' })
t.equal(res.toString(), '', 'toString with nothing')
objSpec = { raw: './foo/bar', where: '/here' }
t.equal(
normalizePath(npa(objSpec, '/whatnot').fetchSpec),
'/whatnot/foo/bar',
'`where` arg overrides the one in the spec object'
)
t.equal(npa(npa('foo@1.2.3')).toString(), 'foo@1.2.3', 'spec is passthrough')
const parsedSpec = npa('./foo', './here')
t.equal(npa(parsedSpec), parsedSpec, 'reused if no where')
t.equal(npa(parsedSpec, './here'), parsedSpec, 'reused if where matches')
t.not(npa(parsedSpec, './there'), parsedSpec, 'new instance if where does not match')
t.not(npa(parsedSpec, './there').fetchSpec, '/there/foo', 'new instance has new where')
// Completely unreasonable invalid garbage throws an error
t.throws(function () {
t.comment(npa('this is not a \0 valid package name or url'))
})
t.throws(function () {
npa('gopher://yea right')
}, 'Unsupported URL Type: gopher://yea right')
t.throws(function () {
npa.resolve('invalid/name', '1.0.0')
}, 'Invalid names throw errrors')
t.throws(() => {
npa('foo@npm:bar@npm:baz')
}, 'nested aliases not supported')
t.throws(() => {
npa('foo@npm:foo/bar')
}, 'aliases only work for registry deps')
t.has(npa.resolve('foo', '^1.2.3', '/test/a/b'), {
type: 'range',
}, 'npa.resolve')
t.has(normalizePaths(npa.resolve('foo', 'file:foo', '/test/a/b')), {
type: 'directory',
fetchSpec: '/test/a/b/foo',
}, 'npa.resolve file:')
t.has(npa.resolve('foo', '../foo/bar', '/test/a/b'), {
type: 'directory',
}, 'npa.resolve no protocol')
t.has(npa.resolve('foo', 'file:../foo/bar', '/test/a/b'), {
type: 'directory',
}, 'npa.resolve file protocol')
t.has(npa.resolve('foo', 'file:../foo/bar.tgz', '/test/a/b'), {
type: 'file',
}, 'npa.resolve file protocol w/ tgz')
t.has(npa.resolve(null, '4.0.0', '/test/a/b'), {
type: 'version',
name: null,
}, 'npa.resolve with no name')
t.has(npa.resolve('foo', 'file:abc'), {
type: 'directory',
raw: 'foo@file:abc',
}, 'npa.resolve sets raw right')
t.has(npa('./path/to/thing/package@1.2.3/'), {
name: null,
type: 'directory',
}, 'npa with path in @ in it')
t.has(npa('path/to/thing/package@1.2.3'), {
name: null,
type: 'directory',
}, 'npa w/o leading or trailing slash')
t.end()
})
t.test('strict 8909 compliance mode', t => {
t.teardown(() => process.env.NPM_PACKAGE_ARG_8909_STRICT = '0')
process.env.NPM_PACKAGE_ARG_8909_STRICT = '1'
t.throws(() => npa('file://.'), {
message: 'Invalid file: URL, must be absolute if // present',
raw: 'file://.',
})
t.throws(() => npa('file://some/relative/path'), {
message: 'Invalid file: URL, must be absolute if // present',
raw: 'file://some/relative/path',
})
// I cannot for the life of me figure out how to make new URL('file:...')
// actually fail to parse. it seems like it accepts any garbage you can
// throw at it. However, because it theoretically CAN throw, here's a test.
t.throws(() => {
const broken = t.mock('..', {
url: {
URL: class {
constructor () {
throw new Error('thansk i haet it')
}
},
},
})
broken('file:thansk i haet it')
}, {
message: 'Invalid file: URL, must comply with RFC 8909',
})
t.end()
})
t.test('error message', t => {
t.throws(() => npa('lodash.has@>=^4'), {
// eslint-disable-next-line max-len
message: 'Invalid tag name ">=^4" of package "lodash.has@>=^4": Tags may not have any characters that encodeURIComponent encodes.',
})
t.throws(() => npa('lodash.has @^4'), {
// eslint-disable-next-line max-len
message: 'Invalid package name "lodash.has " of package "lodash.has @^4": name cannot contain leading or trailing spaces; name can only contain URL-friendly characters.',
})
t.throws(() => npa('user/foo#1234::semver:^1.2.3'), {
message: 'cannot override existing committish with a semver range',
})
t.throws(() => npa('user/foo#semver:^1.2.3::1234'), {
message: 'cannot override existing semver range with a committish',
})
t.throws(() => npa('user/foo#path:skipped::path:dist'), {
message: 'cannot override existing path with a second path',
})
t.throws(() => npa('user/foo#1234::5678'), {
message: 'cannot override existing committish with a second committish',
})
t.throws(() => npa('user/foo#semver:^1.0.0::semver:^2.0.0'), {
message: 'cannot override existing semver range with a second semver range',
})
t.end()
})
npm-package-arg-10.0.0/test/bitbucket.js 0000664 0000000 0000000 00000003673 14323532274 0020031 0 ustar 00root root 0000000 0000000 var npa = require('..')
require('tap').test('basic', function (t) {
t.setMaxListeners(999)
var tests = {
'bitbucket:user/foo-js': {
name: null,
type: 'git',
saveSpec: 'bitbucket:user/foo-js',
raw: 'bitbucket:user/foo-js',
},
'bitbucket:user/foo-js#bar/baz': {
name: null,
type: 'git',
saveSpec: 'bitbucket:user/foo-js#bar/baz',
raw: 'bitbucket:user/foo-js#bar/baz',
},
'bitbucket:user..blerg--/..foo-js# . . . . . some . tags / / /': {
name: null,
type: 'git',
saveSpec: 'bitbucket:user..blerg--/..foo-js# . . . . . some . tags / / /',
raw: 'bitbucket:user..blerg--/..foo-js# . . . . . some . tags / / /',
},
'bitbucket:user/foo-js#bar/baz/bin': {
name: null,
type: 'git',
saveSpec: 'bitbucket:user/foo-js#bar/baz/bin',
raw: 'bitbucket:user/foo-js#bar/baz/bin',
},
'foo@bitbucket:user/foo-js': {
name: 'foo',
type: 'git',
saveSpec: 'bitbucket:user/foo-js',
raw: 'foo@bitbucket:user/foo-js',
},
'git+ssh://git@bitbucket.org/user/foo#1.2.3': {
name: null,
type: 'git',
saveSpec: 'git+ssh://git@bitbucket.org/user/foo.git#1.2.3',
raw: 'git+ssh://git@bitbucket.org/user/foo#1.2.3',
},
'https://bitbucket.org/user/foo.git': {
name: null,
type: 'git',
saveSpec: 'git+https://bitbucket.org/user/foo.git',
raw: 'https://bitbucket.org/user/foo.git',
},
'@foo/bar@git+ssh://bitbucket.org/user/foo': {
name: '@foo/bar',
scope: '@foo',
type: 'git',
saveSpec: 'git+ssh://git@bitbucket.org/user/foo.git',
rawSpec: 'git+ssh://bitbucket.org/user/foo',
raw: '@foo/bar@git+ssh://bitbucket.org/user/foo',
},
}
Object.keys(tests).forEach(function (arg) {
var res = npa(arg)
t.ok(res instanceof npa.Result, arg + ' is a result')
t.has(res, tests[arg], arg + ' matches expectations')
})
t.end()
})
npm-package-arg-10.0.0/test/github.js 0000664 0000000 0000000 00000005064 14323532274 0017333 0 ustar 00root root 0000000 0000000 var npa = require('..')
require('tap').test('basic', function (t) {
t.setMaxListeners(999)
var tests = {
'user/foo-js': {
name: null,
type: 'git',
saveSpec: 'github:user/foo-js',
raw: 'user/foo-js',
},
'user/foo-js#bar/baz': {
name: null,
type: 'git',
saveSpec: 'github:user/foo-js#bar/baz',
raw: 'user/foo-js#bar/baz',
},
'user..blerg--/..foo-js# . . . . . some . tags / / /': {
name: null,
type: 'git',
saveSpec: 'github:user..blerg--/..foo-js# . . . . . some . tags / / /',
raw: 'user..blerg--/..foo-js# . . . . . some . tags / / /',
},
'user/foo-js#bar/baz/bin': {
name: null,
type: 'git',
raw: 'user/foo-js#bar/baz/bin',
},
'foo@user/foo-js': {
name: 'foo',
type: 'git',
saveSpec: 'github:user/foo-js',
raw: 'foo@user/foo-js',
},
'github:user/foo-js': {
name: null,
type: 'git',
saveSpec: 'github:user/foo-js',
raw: 'github:user/foo-js',
},
'git+ssh://git@github.com/user/foo#1.2.3': {
name: null,
type: 'git',
saveSpec: 'git+ssh://git@github.com/user/foo.git#1.2.3',
raw: 'git+ssh://git@github.com/user/foo#1.2.3',
},
'git+ssh://git@github.com:user/foo#1.2.3': {
name: null,
type: 'git',
saveSpec: 'git+ssh://git@github.com/user/foo.git#1.2.3',
raw: 'git+ssh://git@github.com:user/foo#1.2.3',
},
'git://github.com/user/foo': {
name: null,
type: 'git',
saveSpec: 'git://github.com/user/foo.git',
raw: 'git://github.com/user/foo',
},
'https://github.com/user/foo.git': {
name: null,
type: 'git',
saveSpec: 'git+https://github.com/user/foo.git',
raw: 'https://github.com/user/foo.git',
},
'@foo/bar@git+ssh://github.com/user/foo': {
name: '@foo/bar',
scope: '@foo',
type: 'git',
saveSpec: 'git+ssh://git@github.com/user/foo.git',
rawSpec: 'git+ssh://github.com/user/foo',
raw: '@foo/bar@git+ssh://github.com/user/foo',
},
'foo@bar/foo': {
name: 'foo',
type: 'git',
saveSpec: 'github:bar/foo',
raw: 'foo@bar/foo',
},
'git@github.com:12345/foo': {
name: undefined,
type: 'git',
saveSpec: 'git+ssh://git@github.com:12345/foo',
raw: 'git@github.com:12345/foo',
},
}
Object.keys(tests).forEach(function (arg) {
var res = npa(arg)
t.ok(res instanceof npa.Result, arg + ' is a result')
t.has(res, tests[arg], arg + ' matches expectations')
})
t.end()
})
npm-package-arg-10.0.0/test/gitlab.js 0000664 0000000 0000000 00000003470 14323532274 0017312 0 ustar 00root root 0000000 0000000 var npa = require('..')
require('tap').test('basic', function (t) {
t.setMaxListeners(999)
var tests = {
'gitlab:user/foo-js': {
name: null,
type: 'git',
raw: 'gitlab:user/foo-js',
},
'gitlab:user/foo-js#bar/baz': {
name: null,
type: 'git',
raw: 'gitlab:user/foo-js#bar/baz',
},
'gitlab:user..blerg--/..foo-js# . . . . . some . tags / / /': {
name: null,
type: 'git',
saveSpec: 'gitlab:user..blerg--/..foo-js# . . . . . some . tags / / /',
raw: 'gitlab:user..blerg--/..foo-js# . . . . . some . tags / / /',
},
'gitlab:user/foo-js#bar/baz/bin': {
name: null,
type: 'git',
saveSpec: 'gitlab:user/foo-js#bar/baz/bin',
raw: 'gitlab:user/foo-js#bar/baz/bin',
},
'foo@gitlab:user/foo-js': {
name: 'foo',
type: 'git',
saveSpec: 'gitlab:user/foo-js',
raw: 'foo@gitlab:user/foo-js',
},
'git+ssh://git@gitlab.com/user/foo#1.2.3': {
name: null,
type: 'git',
saveSpec: 'git+ssh://git@gitlab.com/user/foo.git#1.2.3',
raw: 'git+ssh://git@gitlab.com/user/foo#1.2.3',
},
'https://gitlab.com/user/foo.git': {
name: null,
type: 'git',
saveSpec: 'git+https://gitlab.com/user/foo.git',
raw: 'https://gitlab.com/user/foo.git',
},
'@foo/bar@git+ssh://gitlab.com/user/foo': {
name: '@foo/bar',
scope: '@foo',
type: 'git',
saveSpec: 'git+ssh://git@gitlab.com/user/foo.git',
rawSpec: 'git+ssh://gitlab.com/user/foo',
raw: '@foo/bar@git+ssh://gitlab.com/user/foo',
},
}
Object.keys(tests).forEach(function (arg) {
var res = npa(arg)
t.ok(res instanceof npa.Result, arg + ' is a result')
t.has(JSON.parse(JSON.stringify(res)), tests[arg], arg + ' matches expectations')
})
t.end()
})
npm-package-arg-10.0.0/test/invalid-url.js 0000664 0000000 0000000 00000000215 14323532274 0020270 0 ustar 00root root 0000000 0000000 const npa = require('..')
const t = require('tap')
t.throws(() => npa('foo@gopher://goodluckwiththat'), {
code: 'EUNSUPPORTEDPROTOCOL',
})
npm-package-arg-10.0.0/test/realize-package-specifier.js 0000664 0000000 0000000 00000003563 14323532274 0023046 0 ustar 00root root 0000000 0000000 'use strict'
var test = require('tap').test
var npa = require('..')
test('realize-package-specifier', function (t) {
t.plan(6)
var result
result = npa('a.tar.gz', '/test/a/b')
t.equal(result.type, 'file', 'local tarball')
result = npa('d', '/test/a/b')
t.equal(result.type, 'range', 'remote package')
result = npa('file:./a.tar.gz', '/test/a/b')
t.equal(result.type, 'file', 'local tarball')
result = npa('file:./b', '/test/a/b')
t.equal(result.type, 'directory', 'local package directory')
result = npa('file:./c', '/test/a/b')
t.equal(result.type, 'directory', 'non-package local directory, specified with a file URL')
result = npa('file:./d', '/test/a/b')
t.equal(result.type, 'directory', 'no local directory, specified with a file URL')
})
test('named realize-package-specifier', function (t) {
t.plan(10)
var result
result = npa('a@a.tar.gz', '/test/a/b')
t.equal(result.type, 'file', 'named local tarball')
result = npa('d@d', '/test/a/b')
t.equal(result.type, 'tag', 'remote package')
result = npa('a@file:./a.tar.gz', '/test/a/b')
t.equal(result.type, 'file', 'local tarball')
result = npa('b@file:./b', '/test/a/b')
t.equal(result.type, 'directory', 'local package directory')
result = npa('c@file:./c', '/test/a/b')
t.equal(result.type, 'directory', 'non-package local directory, specified with a file URL')
result = npa('d@file:./d', '/test/a/b')
t.equal(result.type, 'directory', 'no local directory, specified with a file URL')
result = npa('e@e/2', 'test/a/b')
t.equal(result.type, 'git', 'hosted package dependency is git')
t.equal(result.hosted.type, 'github', 'github package dependency')
result = npa('e@1', '/test/a/b')
t.equal(result.type, 'range', 'range like specifier is never a local file')
result = npa('e@1.0.0', '/test/a/b')
t.equal(result.type, 'version', 'version like specifier is never a local file')
})
npm-package-arg-10.0.0/test/windows.js 0000664 0000000 0000000 00000004153 14323532274 0017541 0 ustar 00root root 0000000 0000000 global.FAKE_WINDOWS = true
const npa = require('..')
const t = require('tap')
t.on('bailout', () => process.exit(1))
const cases = {
'C:\\x\\y\\z': {
raw: 'C:\\x\\y\\z',
scope: null,
name: null,
escapedName: null,
rawSpec: 'C:\\x\\y\\z',
fetchSpec: 'C:\\x\\y\\z',
type: 'directory',
},
'foo@C:\\x\\y\\z': {
raw: 'foo@C:\\x\\y\\z',
scope: null,
name: 'foo',
escapedName: 'foo',
rawSpec: 'C:\\x\\y\\z',
fetchSpec: 'C:\\x\\y\\z',
type: 'directory',
},
'foo@file:///C:\\x\\y\\z': {
raw: 'foo@file:///C:\\x\\y\\z',
scope: null,
name: 'foo',
escapedName: 'foo',
rawSpec: 'file:///C:\\x\\y\\z',
fetchSpec: 'C:\\x\\y\\z',
type: 'directory',
},
'foo@file://C:\\x\\y\\z': {
raw: 'foo@file://C:\\x\\y\\z',
scope: null,
name: 'foo',
escapedName: 'foo',
rawSpec: 'file://C:\\x\\y\\z',
fetchSpec: 'C:\\x\\y\\z',
type: 'directory',
},
'file:///C:\\x\\y\\z': {
raw: 'file:///C:\\x\\y\\z',
scope: null,
name: null,
escapedName: null,
rawSpec: 'file:///C:\\x\\y\\z',
fetchSpec: 'C:\\x\\y\\z',
type: 'directory',
},
'file://C:\\x\\y\\z': {
raw: 'file://C:\\x\\y\\z',
scope: null,
name: null,
escapedName: null,
rawSpec: 'file://C:\\x\\y\\z',
fetchSpec: 'C:\\x\\y\\z',
type: 'directory',
},
'foo@/foo/bar/baz': {
raw: 'foo@/foo/bar/baz',
scope: null,
name: 'foo',
escapedName: 'foo',
rawSpec: '/foo/bar/baz',
fetchSpec: 'C:\\foo\\bar\\baz',
type: 'directory',
},
'foo@git+file://C:\\x\\y\\z': {
type: 'git',
registry: null,
where: null,
raw: 'foo@git+file://C:\\x\\y\\z',
name: 'foo',
escapedName: 'foo',
scope: null,
rawSpec: 'git+file://C:\\x\\y\\z',
saveSpec: 'git+file://C:\\x\\y\\z',
fetchSpec: 'file://c:/x/y/z',
gitRange: null,
gitCommittish: null,
hosted: null,
},
}
t.test('parse a windows path', function (t) {
Object.keys(cases).forEach(function (c) {
const expect = cases[c]
const actual = npa(c, 'C:\\test\\path')
t.has(actual, expect, c)
})
t.end()
})