pax_global_header00006660000000000000000000000064150707667600014530gustar00rootroot0000000000000052 comment=5b5edc172f250a4e2df0b3d19661e03867f30888 npm-npm-package-arg-5b5edc1/000077500000000000000000000000001507076676000157445ustar00rootroot00000000000000npm-npm-package-arg-5b5edc1/.commitlintrc.js000066400000000000000000000005661507076676000210730ustar00rootroot00000000000000/* 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], 'body-max-line-length': [0], 'footer-max-line-length': [0], }, } npm-npm-package-arg-5b5edc1/.eslintrc.js000066400000000000000000000006231507076676000202040ustar00rootroot00000000000000/* 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, ignorePatterns: [ 'tap-testdir*/', ], extends: [ '@npmcli', ...localConfigs, ], } npm-npm-package-arg-5b5edc1/.github/000077500000000000000000000000001507076676000173045ustar00rootroot00000000000000npm-npm-package-arg-5b5edc1/.github/CODEOWNERS000066400000000000000000000001321507076676000206730ustar00rootroot00000000000000# This file is automatically added by @npmcli/template-oss. Do not edit. * @npm/cli-team npm-npm-package-arg-5b5edc1/.github/ISSUE_TEMPLATE/000077500000000000000000000000001507076676000214675ustar00rootroot00000000000000npm-npm-package-arg-5b5edc1/.github/ISSUE_TEMPLATE/bug.yml000066400000000000000000000026551507076676000227770ustar00rootroot00000000000000# 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-npm-package-arg-5b5edc1/.github/ISSUE_TEMPLATE/config.yml���������������������������������������0000664�0000000�0000000�00000000145�15070766760�0023457�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# This file is automatically added by @npmcli/template-oss. Do not edit. blank_issues_enabled: true ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.github/actions/��������������������������������������������������������0000775�0000000�0000000�00000000000�15070766760�0020744�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.github/actions/create-check/�������������������������������������������0000775�0000000�0000000�00000000000�15070766760�0023262�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.github/actions/create-check/action.yml���������������������������������0000664�0000000�0000000�00000002720�15070766760�0025263�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# This file is automatically added by @npmcli/template-oss. Do not edit. name: 'Create Check' inputs: name: required: true token: required: true sha: required: true check-name: default: '' outputs: check-id: value: ${{ steps.create-check.outputs.check_id }} runs: using: "composite" steps: - name: Get Workflow Job uses: actions/github-script@v7 id: workflow env: JOB_NAME: "${{ inputs.name }}" SHA: "${{ inputs.sha }}" with: result-encoding: string script: | const { repo: { owner, repo}, runId, serverUrl } = context const { JOB_NAME, SHA } = process.env const job = await github.rest.actions.listJobsForWorkflowRun({ owner, repo, run_id: runId, per_page: 100 }).then(r => r.data.jobs.find(j => j.name.endsWith(JOB_NAME))) return [ `This check is assosciated with ${serverUrl}/${owner}/${repo}/commit/${SHA}.`, 'Run logs:', job?.html_url || `could not be found for a job ending with: "${JOB_NAME}"`, ].join(' ') - name: Create Check uses: LouisBrunner/checks-action@v1.6.0 id: create-check with: token: ${{ inputs.token }} sha: ${{ inputs.sha }} status: in_progress name: ${{ inputs.check-name || inputs.name }} output: | {"summary":"${{ steps.workflow.outputs.result }}"} ������������������������������������������������npm-npm-package-arg-5b5edc1/.github/actions/install-latest-npm/�������������������������������������0000775�0000000�0000000�00000000000�15070766760�0024474�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.github/actions/install-latest-npm/action.yml���������������������������0000664�0000000�0000000�00000003406�15070766760�0026477�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# This file is automatically added by @npmcli/template-oss. Do not edit. name: 'Install Latest npm' description: 'Install the latest version of npm compatible with the Node version' inputs: node: description: 'Current Node version' required: true runs: using: "composite" steps: # node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows - name: Update Windows npm if: | runner.os == 'Windows' && ( startsWith(inputs.node, 'v10.') || startsWith(inputs.node, 'v12.') || startsWith(inputs.node, 'v14.') ) shell: cmd 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 Latest npm shell: bash env: NODE_VERSION: ${{ inputs.node }} working-directory: ${{ runner.temp }} run: | MATCH="" SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6") echo "node@$NODE_VERSION" for SPEC in ${SPECS[@]}; do ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node') echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)" if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then MATCH=$SPEC echo "Found compatible version: npm@$MATCH" break fi done if [ -z $MATCH ]; then echo "Could not find a compatible version of npm for node@$NODE_VERSION" exit 1 fi npm i --prefer-online --no-fund --no-audit -g npm@$MATCH - name: npm Version shell: bash run: npm -v ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.github/dependabot.yml��������������������������������������������������0000664�0000000�0000000�00000000656�15070766760�0022143�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 target-branch: "main" allow: - dependency-type: direct versioning-strategy: increase-if-necessary commit-message: prefix: deps prefix-development: chore labels: - "Dependencies" open-pull-requests-limit: 10 ����������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.github/matchers/�������������������������������������������������������0000775�0000000�0000000�00000000000�15070766760�0021112�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.github/matchers/tap.json�����������������������������������������������0000664�0000000�0000000�00000001204�15070766760�0022566�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-npm-package-arg-5b5edc1/.github/settings.yml����������������������������������������������������0000664�0000000�0000000�00000001377�15070766760�0021677�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# This file is automatically added by @npmcli/template-oss. Do not edit. repository: allow_merge_commit: false allow_rebase_merge: true allow_squash_merge: true squash_merge_commit_title: PR_TITLE squash_merge_commit_message: PR_BODY delete_branch_on_merge: true enable_automated_security_fixes: true enable_vulnerability_alerts: true branches: - name: main protection: required_status_checks: null enforce_admins: true block_creations: true required_pull_request_reviews: required_approving_review_count: 1 require_code_owner_reviews: true require_last_push_approval: true dismiss_stale_reviews: true restrictions: apps: [] users: [] teams: [ "cli-team" ] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.github/workflows/������������������������������������������������������0000775�0000000�0000000�00000000000�15070766760�0021341�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.github/workflows/audit.yml���������������������������������������������0000664�0000000�0000000�00000002236�15070766760�0023175�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@v4 - 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@v4 id: node with: node-version: 22.x check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: node: ${{ steps.node.outputs.node-version }} - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund --package-lock - name: Run Production Audit run: npm audit --omit=dev - name: Run Full Audit run: npm audit --audit-level=none ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.github/workflows/ci-release.yml����������������������������������������0000664�0000000�0000000�00000010630�15070766760�0024075�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# This file is automatically added by @npmcli/template-oss. Do not edit. name: CI - Release on: workflow_dispatch: inputs: ref: required: true type: string default: main 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: Checkout uses: actions/checkout@v4 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: Create Check id: create-check if: ${{ inputs.check-sha }} uses: ./.github/actions/create-check with: name: "Lint All" token: ${{ secrets.GITHUB_TOKEN }} sha: ${{ inputs.check-sha }} - name: Setup Node uses: actions/setup-node@v4 id: node with: node-version: 22.x check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: node: ${{ steps.node.outputs.node-version }} - 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.6.0 if: steps.create-check.outputs.check-id && always() with: token: ${{ secrets.GITHUB_TOKEN }} conclusion: ${{ job.status }} check_id: ${{ steps.create-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: macOS os: macos-13 shell: bash - name: Windows os: windows-latest shell: cmd node-version: - 20.17.0 - 20.x - 22.9.0 - 22.x exclude: - platform: { name: macOS, os: macos-13, shell: bash } node-version: 20.17.0 - platform: { name: macOS, os: macos-13, shell: bash } node-version: 20.x - platform: { name: macOS, os: macos-13, shell: bash } node-version: 22.9.0 - platform: { name: macOS, os: macos-13, shell: bash } node-version: 22.x runs-on: ${{ matrix.platform.os }} defaults: run: shell: ${{ matrix.platform.shell }} steps: - name: Checkout uses: actions/checkout@v4 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: Create Check id: create-check if: ${{ inputs.check-sha }} uses: ./.github/actions/create-check with: name: "Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}" token: ${{ secrets.GITHUB_TOKEN }} sha: ${{ inputs.check-sha }} - name: Setup Node uses: actions/setup-node@v4 id: node with: node-version: ${{ matrix.node-version }} check-latest: contains(matrix.node-version, '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: node: ${{ steps.node.outputs.node-version }} - 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.6.0 if: steps.create-check.outputs.check-id && always() with: token: ${{ secrets.GITHUB_TOKEN }} conclusion: ${{ job.status }} check_id: ${{ steps.create-check.outputs.check-id }} ��������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.github/workflows/ci.yml������������������������������������������������0000664�0000000�0000000�00000006102�15070766760�0022456�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 schedule: # "At 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1 - cron: "0 9 * * 1" jobs: lint: name: Lint if: github.repository_owner == 'npm' runs-on: ubuntu-latest defaults: run: shell: bash steps: - name: Checkout uses: actions/checkout@v4 - 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@v4 id: node with: node-version: 22.x check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: node: ${{ steps.node.outputs.node-version }} - 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: macOS os: macos-13 shell: bash - name: Windows os: windows-latest shell: cmd node-version: - 20.17.0 - 20.x - 22.9.0 - 22.x exclude: - platform: { name: macOS, os: macos-13, shell: bash } node-version: 20.17.0 - platform: { name: macOS, os: macos-13, shell: bash } node-version: 20.x - platform: { name: macOS, os: macos-13, shell: bash } node-version: 22.9.0 - platform: { name: macOS, os: macos-13, shell: bash } node-version: 22.x runs-on: ${{ matrix.platform.os }} defaults: run: shell: ${{ matrix.platform.shell }} steps: - name: Checkout uses: actions/checkout@v4 - 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@v4 id: node with: node-version: ${{ matrix.node-version }} check-latest: contains(matrix.node-version, '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: node: ${{ steps.node.outputs.node-version }} - 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-npm-package-arg-5b5edc1/.github/workflows/codeql-analysis.yml�����������������������������������0000664�0000000�0000000�00000001547�15070766760�0025163�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# This file is automatically added by @npmcli/template-oss. Do not edit. name: CodeQL on: push: branches: - main pull_request: branches: - main 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@v4 - 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@v3 with: languages: javascript - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 ���������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.github/workflows/post-dependabot.yml�����������������������������������0000664�0000000�0000000�00000011773�15070766760�0025165�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@v4 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@v4 id: node with: node-version: 22.x check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: node: ${{ steps.node.outputs.node-version }} - 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" == "/" || "$dependabot_dir" == "/main" ]]; then echo "workspace=-iwr" >> $GITHUB_OUTPUT else # strip leading slash from directory so it works as a # a path to the workspace flag echo "workspace=-w ${dependabot_dir#/}" >> $GITHUB_OUTPUT 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 "changes=true" >> $GITHUB_OUTPUT 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 "message=$prefix: postinstall for dependabot template-oss PR" >> $GITHUB_OUTPUT # 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-npm-package-arg-5b5edc1/.github/workflows/pull-request.yml��������������������������������������0000664�0000000�0000000�00000002700�15070766760�0024525�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@v4 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@v4 id: node with: node-version: 22.x check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: node: ${{ steps.node.outputs.node-version }} - 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' env: PR_TITLE: ${{ github.event.pull_request.title }} run: echo "$PR_TITLE" | npx --offline commitlint -V ����������������������������������������������������������������npm-npm-package-arg-5b5edc1/.github/workflows/release-integration.yml�������������������������������0000664�0000000�0000000�00000004102�15070766760�0026022�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# This file is automatically added by @npmcli/template-oss. Do not edit. name: Release Integration on: workflow_dispatch: inputs: releases: required: true type: string description: 'A json array of releases. Required fields: publish: tagName, publishTag. publish check: pkgName, version' workflow_call: inputs: releases: required: true type: string description: 'A json array of releases. Required fields: publish: tagName, publishTag. publish check: pkgName, version' secrets: PUBLISH_TOKEN: required: true jobs: publish: name: Publish runs-on: ubuntu-latest defaults: run: shell: bash permissions: id-token: write steps: - name: Checkout uses: actions/checkout@v4 with: ref: ${{ fromJSON(inputs.releases)[0].tagName }} - 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@v4 id: node with: node-version: 22.x check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: node: ${{ steps.node.outputs.node-version }} - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund - name: Set npm authToken run: npm config set '//registry.npmjs.org/:_authToken'=\${PUBLISH_TOKEN} - name: Publish env: PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} RELEASES: ${{ inputs.releases }} run: | EXIT_CODE=0 for release in $(echo $RELEASES | jq -r '.[] | @base64'); do PUBLISH_TAG=$(echo "$release" | base64 --decode | jq -r .publishTag) npm publish --provenance --tag="$PUBLISH_TAG" STATUS=$? if [[ "$STATUS" -eq 1 ]]; then EXIT_CODE=$STATUS fi done exit $EXIT_CODE ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.github/workflows/release.yml�������������������������������������������0000664�0000000�0000000�00000026061�15070766760�0023511�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# This file is automatically added by @npmcli/template-oss. Do not edit. name: Release on: push: branches: - main permissions: contents: write pull-requests: write checks: write jobs: release: outputs: pr: ${{ steps.release.outputs.pr }} pr-branch: ${{ steps.release.outputs.pr-branch }} pr-number: ${{ steps.release.outputs.pr-number }} pr-sha: ${{ steps.release.outputs.pr-sha }} releases: ${{ steps.release.outputs.releases }} comment-id: ${{ steps.create-comment.outputs.comment-id || steps.update-comment.outputs.comment-id }} check-id: ${{ steps.create-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@v4 - 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@v4 id: node with: node-version: 22.x check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: node: ${{ steps.node.outputs.node-version }} - 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 --branch="${{ github.ref_name }}" --backport="" --defaultTag="latest" - name: Create Release Manager Comment Text if: steps.release.outputs.pr-number uses: actions/github-script@v7 id: comment-text with: result-encoding: string script: | const { runId, repo: { owner, repo } } = context const { data: workflow } = await github.rest.actions.getWorkflowRun({ owner, repo, run_id: runId }) return['## Release Manager', `Release workflow run: ${workflow.html_url}`].join('\n\n') - name: Find Release Manager Comment uses: peter-evans/find-comment@v2 if: steps.release.outputs.pr-number id: found-comment with: issue-number: ${{ steps.release.outputs.pr-number }} comment-author: 'github-actions[bot]' body-includes: '## Release Manager' - name: Create Release Manager Comment id: create-comment if: steps.release.outputs.pr-number && !steps.found-comment.outputs.comment-id uses: peter-evans/create-or-update-comment@v3 with: issue-number: ${{ steps.release.outputs.pr-number }} body: ${{ steps.comment-text.outputs.result }} - name: Update Release Manager Comment id: update-comment if: steps.release.outputs.pr-number && steps.found-comment.outputs.comment-id uses: peter-evans/create-or-update-comment@v3 with: comment-id: ${{ steps.found-comment.outputs.comment-id }} body: ${{ steps.comment-text.outputs.result }} edit-mode: 'replace' - name: Create Check id: create-check uses: ./.github/actions/create-check if: steps.release.outputs.pr-sha with: name: "Release" token: ${{ secrets.GITHUB_TOKEN }} sha: ${{ steps.release.outputs.pr-sha }} update: needs: release outputs: sha: ${{ steps.commit.outputs.sha }} check-id: ${{ steps.create-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@v4 with: fetch-depth: 0 ref: ${{ needs.release.outputs.pr-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@v4 id: node with: node-version: 22.x check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: node: ${{ steps.node.outputs.node-version }} - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund - name: Create Release Manager Checklist Text id: comment-text env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npm exec --offline -- template-oss-release-manager --pr="${{ needs.release.outputs.pr-number }}" --backport="" --defaultTag="latest" --publish - name: Append Release Manager Comment uses: peter-evans/create-or-update-comment@v3 with: comment-id: ${{ needs.release.outputs.comment-id }} body: ${{ steps.comment-text.outputs.result }} edit-mode: 'append' - name: Run Post Pull Request Actions env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npm run rp-pull-request --ignore-scripts --if-present -- --pr="${{ needs.release.outputs.pr-number }}" --commentId="${{ needs.release.outputs.comment-id }}" - name: Commit id: commit env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git commit --all --amend --no-edit || true git push --force-with-lease echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Create Check id: create-check uses: ./.github/actions/create-check with: name: "Update - Release" check-name: "Release" token: ${{ secrets.GITHUB_TOKEN }} sha: ${{ steps.commit.outputs.sha }} - name: Conclude Check uses: LouisBrunner/checks-action@v1.6.0 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.pr-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 CI Conclusion id: conclusion 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 "result=$result" >> $GITHUB_OUTPUT - name: Conclude Check uses: LouisBrunner/checks-action@v1.6.0 with: token: ${{ secrets.GITHUB_TOKEN }} conclusion: ${{ steps.conclusion.outputs.result }} check_id: ${{ needs.update.outputs.check-id }} post-release: needs: release outputs: comment-id: ${{ steps.create-comment.outputs.comment-id }} name: Post Release - Release if: github.repository_owner == 'npm' && needs.release.outputs.releases runs-on: ubuntu-latest defaults: run: shell: bash steps: - name: Create Release PR Comment Text id: comment-text uses: actions/github-script@v7 env: RELEASES: ${{ needs.release.outputs.releases }} with: result-encoding: string script: | const releases = JSON.parse(process.env.RELEASES) const { runId, repo: { owner, repo } } = context const issue_number = releases[0].prNumber const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${runId}` return [ '## Release Workflow\n', ...releases.map(r => `- \`${r.pkgName}@${r.version}\` ${r.url}`), `- Workflow run: :arrows_counterclockwise: ${runUrl}`, ].join('\n') - name: Create Release PR Comment id: create-comment uses: peter-evans/create-or-update-comment@v3 with: issue-number: ${{ fromJSON(needs.release.outputs.releases)[0].prNumber }} body: ${{ steps.comment-text.outputs.result }} release-integration: needs: release name: Release Integration if: needs.release.outputs.releases uses: ./.github/workflows/release-integration.yml permissions: id-token: write secrets: PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} with: releases: ${{ needs.release.outputs.releases }} post-release-integration: needs: [ release, release-integration, post-release ] name: Post Release Integration - Release if: github.repository_owner == 'npm' && needs.release.outputs.releases && always() runs-on: ubuntu-latest defaults: run: shell: bash steps: - name: Get Post Release Conclusion id: conclusion run: | if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then result="x" elif [[ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then result="heavy_multiplication_x" else result="white_check_mark" fi echo "result=$result" >> $GITHUB_OUTPUT - name: Find Release PR Comment uses: peter-evans/find-comment@v2 id: found-comment with: issue-number: ${{ fromJSON(needs.release.outputs.releases)[0].prNumber }} comment-author: 'github-actions[bot]' body-includes: '## Release Workflow' - name: Create Release PR Comment Text id: comment-text if: steps.found-comment.outputs.comment-id uses: actions/github-script@v7 env: RESULT: ${{ steps.conclusion.outputs.result }} BODY: ${{ steps.found-comment.outputs.comment-body }} with: result-encoding: string script: | const { RESULT, BODY } = process.env const body = [BODY.replace(/(Workflow run: :)[a-z_]+(:)/, `$1${RESULT}$2`)] if (RESULT !== 'white_check_mark') { body.push(':rotating_light::rotating_light::rotating_light:') body.push([ '@npm/cli-team: The post-release workflow failed for this release.', 'Manual steps may need to be taken after examining the workflow output.' ].join(' ')) body.push(':rotating_light::rotating_light::rotating_light:') } return body.join('\n\n').trim() - name: Update Release PR Comment if: steps.comment-text.outputs.result uses: peter-evans/create-or-update-comment@v3 with: comment-id: ${{ steps.found-comment.outputs.comment-id }} body: ${{ steps.comment-text.outputs.result }} edit-mode: 'replace' �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.gitignore��������������������������������������������������������������0000664�0000000�0000000�00000001024�15070766760�0017731�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# This file is automatically added by @npmcli/template-oss. Do not edit. # ignore everything in the root /* !**/.gitignore !/.commitlintrc.js !/.eslintrc.js !/.eslintrc.local.* !/.git-blame-ignore-revs !/.github/ !/.gitignore !/.npmrc !/.prettierignore !/.prettierrc.js !/.release-please-manifest.json !/bin/ !/CHANGELOG* !/CODE_OF_CONDUCT.md !/CONTRIBUTING.md !/docs/ !/lib/ !/LICENSE* !/map.js !/package.json !/README* !/release-please-config.json !/scripts/ !/SECURITY.md !/tap-snapshots/ !/test/ !/tsconfig.json tap-testdir*/ ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.npmrc������������������������������������������������������������������0000664�0000000�0000000�00000000135�15070766760�0017063�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������; This file is automatically added by @npmcli/template-oss. Do not edit. package-lock=false �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/.release-please-manifest.json�������������������������������������������0000664�0000000�0000000�00000000024�15070766760�0023404�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ ".": "13.0.1" } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/CHANGELOG.md������������������������������������������������������������0000664�0000000�0000000�00000033754�15070766760�0017571�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Changelog ## [13.0.1](https://github.com/npm/npm-package-arg/compare/v13.0.0...v13.0.1) (2025-10-06) ### Bug Fixes * [`f00dea0`](https://github.com/npm/npm-package-arg/commit/f00dea08e9bb30a4c0a1ed01274b63bdbe79c320) [#211](https://github.com/npm/npm-package-arg/pull/211) Correct tarball regex to detect literal dots (@markovejnovic) ## [13.0.0](https://github.com/npm/npm-package-arg/compare/v12.0.2...v13.0.0) (2025-07-24) ### ⚠️ BREAKING CHANGES * `npm-package-arg` now supports node `^20.17.0 || >=22.9.0` ### Bug Fixes * [`aa3ed29`](https://github.com/npm/npm-package-arg/commit/aa3ed290c5b935159818b7e1d7714f87819df0b6) [#207](https://github.com/npm/npm-package-arg/pull/207) align to npm 11 node engine range (@owlstronaut) ### Dependencies * [`fb6ea64`](https://github.com/npm/npm-package-arg/commit/fb6ea6416fc7e0be58162b07601bf359b522de5b) [#207](https://github.com/npm/npm-package-arg/pull/207) `hosted-git-info@9.0.0` ## [12.0.2](https://github.com/npm/npm-package-arg/compare/v12.0.1...v12.0.2) (2025-02-05) ### Bug Fixes * [`14cb8a1`](https://github.com/npm/npm-package-arg/commit/14cb8a18b32982a3be5c45331331cdbed78218c8) [#200](https://github.com/npm/npm-package-arg/pull/200) properly parse non-url encoded file specs (#200) (@wraithgar) ### Chores * [`1343a54`](https://github.com/npm/npm-package-arg/commit/1343a54064dd832befce32dff16d2736e307238e) [#199](https://github.com/npm/npm-package-arg/pull/199) bump @npmcli/template-oss from 4.23.4 to 4.23.5 (#199) (@dependabot[bot], @npm-cli-bot) ## [12.0.1](https://github.com/npm/npm-package-arg/compare/v12.0.0...v12.0.1) (2024-12-10) ### Bug Fixes * [`ea07a6e`](https://github.com/npm/npm-package-arg/commit/ea07a6edc71caae4db9342f90e03457edbb7bb24) [#197](https://github.com/npm/npm-package-arg/pull/197) allow for git usernames that start with a number (#197) (@wraithgar) ### Chores * [`41aa799`](https://github.com/npm/npm-package-arg/commit/41aa799ee562f97d4bef48d0d08be8d4320bb219) [#196](https://github.com/npm/npm-package-arg/pull/196) bump @npmcli/template-oss from 4.23.3 to 4.23.4 (#196) (@dependabot[bot], @npm-cli-bot) ## [12.0.0](https://github.com/npm/npm-package-arg/compare/v11.0.3...v12.0.0) (2024-09-25) ### ⚠️ BREAKING CHANGES * `npm-package-arg` now supports node `^18.17.0 || >=20.5.0` ### Bug Fixes * [`6bf84db`](https://github.com/npm/npm-package-arg/commit/6bf84db8c37990556fa8738d0985c5e904e44d02) [#194](https://github.com/npm/npm-package-arg/pull/194) align to npm 10 node engine range (@reggi) ### Dependencies * [`3361e59`](https://github.com/npm/npm-package-arg/commit/3361e594418a6ed6088367682e362042e4318811) [#194](https://github.com/npm/npm-package-arg/pull/194) `validate-npm-package-name@6.0.0` * [`06e3bd6`](https://github.com/npm/npm-package-arg/commit/06e3bd64cd4e727b9734e0e23be2b09afc3205cd) [#194](https://github.com/npm/npm-package-arg/pull/194) `proc-log@5.0.0` * [`96dd671`](https://github.com/npm/npm-package-arg/commit/96dd671a06d8b27cd48258d068bdaaa83161cf3c) [#194](https://github.com/npm/npm-package-arg/pull/194) `hosted-git-info@8.0.0` ### Chores * [`163925e`](https://github.com/npm/npm-package-arg/commit/163925e69326ef40d208f9789794dcdae6932cdd) [#194](https://github.com/npm/npm-package-arg/pull/194) run template-oss-apply (@reggi) * [`a8a9bdd`](https://github.com/npm/npm-package-arg/commit/a8a9bddc726802fb5ed30f6b113d57f0655bbd51) [#190](https://github.com/npm/npm-package-arg/pull/190) bump @npmcli/eslint-config from 4.0.5 to 5.0.0 (@dependabot[bot]) * [`f8d32ec`](https://github.com/npm/npm-package-arg/commit/f8d32ec3d0cb2d195084195664d48719060b6447) [#188](https://github.com/npm/npm-package-arg/pull/188) postinstall for dependabot template-oss PR (@hashtagchris) * [`a867f96`](https://github.com/npm/npm-package-arg/commit/a867f9644491a28560a8f751fa34320d7db14bde) [#188](https://github.com/npm/npm-package-arg/pull/188) bump @npmcli/template-oss from 4.23.1 to 4.23.3 (@dependabot[bot]) ## [11.0.3](https://github.com/npm/npm-package-arg/compare/v11.0.2...v11.0.3) (2024-07-22) ### Bug Fixes * [`59d53b3`](https://github.com/npm/npm-package-arg/commit/59d53b3ea2f66c7d35250b278b3ada551cef8741) [#184](https://github.com/npm/npm-package-arg/pull/184) throws an err when alias is without name (#184) (@milaninfy) ### Chores * [`911661e`](https://github.com/npm/npm-package-arg/commit/911661e2bde83ee4489179d75bcaf33a50ce38ad) [#176](https://github.com/npm/npm-package-arg/pull/176) bump @npmcli/template-oss to 4.22.0 (@lukekarrys) * [`575012e`](https://github.com/npm/npm-package-arg/commit/575012e19092c77995c35b015f2fd18bde5d5bf9) [#186](https://github.com/npm/npm-package-arg/pull/186) bump @npmcli/template-oss from 4.22.0 to 4.23.1 (#186) (@dependabot[bot], @wraithgar) * [`74d06ae`](https://github.com/npm/npm-package-arg/commit/74d06ae66df6b8a91f5b5e4b8ff001a887cf4851) [#176](https://github.com/npm/npm-package-arg/pull/176) postinstall for dependabot template-oss PR (@lukekarrys) ## [11.0.2](https://github.com/npm/npm-package-arg/compare/v11.0.1...v11.0.2) (2024-04-12) ### Documentation * [`1765111`](https://github.com/npm/npm-package-arg/commit/17651118e122ea7c95a930285b228ccb1609652c) [#171](https://github.com/npm/npm-package-arg/pull/171) readme: fix broken badge URL (#171) (@10xLaCroixDrinker) ### Dependencies * [`4ccd080`](https://github.com/npm/npm-package-arg/commit/4ccd08087e50c22a498498bbf2f27d2ffed346f3) [#173](https://github.com/npm/npm-package-arg/pull/173) `proc-log@4.0.0` (#173) ### Chores * [`207ba7d`](https://github.com/npm/npm-package-arg/commit/207ba7d5cf32c6daa4fd2aad644e8371dd33e0de) [#168](https://github.com/npm/npm-package-arg/pull/168) postinstall for dependabot template-oss PR (@lukekarrys) * [`604c1d2`](https://github.com/npm/npm-package-arg/commit/604c1d2011a2bb6be599f55fc0aeeb7ebe445517) [#168](https://github.com/npm/npm-package-arg/pull/168) bump @npmcli/template-oss from 4.21.1 to 4.21.3 (@dependabot[bot]) * [`82273b5`](https://github.com/npm/npm-package-arg/commit/82273b59bac85e13e130e270e3c1a0ea55c1bfff) [#165](https://github.com/npm/npm-package-arg/pull/165) postinstall for dependabot template-oss PR (@lukekarrys) * [`4228b37`](https://github.com/npm/npm-package-arg/commit/4228b378a41174b0671ea1a98b2426d86d3c50b3) [#165](https://github.com/npm/npm-package-arg/pull/165) bump @npmcli/template-oss from 4.19.0 to 4.21.1 (@dependabot[bot]) * [`d4b1447`](https://github.com/npm/npm-package-arg/commit/d4b144726c787dd5ef98fbcf9863c1dd64b74d6a) [#147](https://github.com/npm/npm-package-arg/pull/147) postinstall for dependabot template-oss PR (@lukekarrys) * [`c5920a9`](https://github.com/npm/npm-package-arg/commit/c5920a954577df498f3b0455aab35c3d3a8556a8) [#147](https://github.com/npm/npm-package-arg/pull/147) bump @npmcli/template-oss from 4.18.1 to 4.19.0 (@dependabot[bot]) * [`ee68f93`](https://github.com/npm/npm-package-arg/commit/ee68f93f7b4b661d6fcc1d5d9213f897cfd4bd55) [#146](https://github.com/npm/npm-package-arg/pull/146) postinstall for dependabot template-oss PR (@lukekarrys) * [`7901052`](https://github.com/npm/npm-package-arg/commit/79010526afd9d97435d0486c7ac76e70cbffa6fe) [#146](https://github.com/npm/npm-package-arg/pull/146) bump @npmcli/template-oss from 4.18.0 to 4.18.1 (@dependabot[bot]) ## [11.0.1](https://github.com/npm/npm-package-arg/compare/v11.0.0...v11.0.1) (2023-09-05) ### Bug Fixes * [`74b3c7e`](https://github.com/npm/npm-package-arg/commit/74b3c7e34a7ec16a6f9d36e3d8dfbc052f3ff5a8) [#141](https://github.com/npm/npm-package-arg/pull/141) use URL instead of url.parse (#141) (@wraithgar) ### Documentation * [`ea00495`](https://github.com/npm/npm-package-arg/commit/ea0049578355050e0f56cdd28809501326ba534b) [#142](https://github.com/npm/npm-package-arg/pull/142) fix readme typo (#142) (@rotu) * [`26705c5`](https://github.com/npm/npm-package-arg/commit/26705c5fefcd695a881635cf4ccbd7c27de91af3) [#143](https://github.com/npm/npm-package-arg/pull/143) Fix citations to RFC 8089 (not 8909) for file: url (#143) (@rotu) ## [11.0.0](https://github.com/npm/npm-package-arg/compare/v10.1.0...v11.0.0) (2023-08-15) ### ⚠️ BREAKING CHANGES * the strict RFC 8089 mode has been removed * support for node 14 has been removed ### Bug Fixes * [`9344167`](https://github.com/npm/npm-package-arg/commit/934416709cb14ad0a0bab6e544b8d42c62aa279f) [#135](https://github.com/npm/npm-package-arg/pull/135) remove strict 8909 mode (@wraithgar) * [`5042ff2`](https://github.com/npm/npm-package-arg/commit/5042ff2bba38bf3d8f62541960c808ac3230da08) [#139](https://github.com/npm/npm-package-arg/pull/139) drop node14 support (@lukekarrys) ### Dependencies * [`d2ab7ba`](https://github.com/npm/npm-package-arg/commit/d2ab7bade19f4594c828ee2a4d5942b2626123cb) [#138](https://github.com/npm/npm-package-arg/pull/138) bump hosted-git-info from 6.1.1 to 7.0.0 ## [10.1.0](https://github.com/npm/npm-package-arg/compare/v10.0.0...v10.1.0) (2022-12-01) ### Features * [`f2c243c`](https://github.com/npm/npm-package-arg/commit/f2c243c140a397d3054fe1ec84a091d237bbd6e9) [#122](https://github.com/npm/npm-package-arg/pull/122) add function to return pacakge purl (@bdehamer, @ljharb) ## [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)) <a name="7.0.0"></a> # [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. <a name="6.1.1"></a> ## [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)) <a name="6.1.0"></a> # [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-npm-package-arg-5b5edc1/CODE_OF_CONDUCT.md������������������������������������������������������0000664�0000000�0000000�00000000507�15070766760�0020545�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!-- This file is automatically added by @npmcli/template-oss. Do not edit. --> All interactions in this repo are covered by the [npm Code of Conduct](https://docs.npmjs.com/policies/conduct) The npm cli team may, at its own discretion, moderate, remove, or edit any interactions such as pull requests, issues, and comments. �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/CONTRIBUTING.md���������������������������������������������������������0000664�0000000�0000000�00000005133�15070766760�0020177�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!-- This file is automatically added by @npmcli/template-oss. Do not edit. --> # Contributing ## Code of Conduct All interactions in the **npm** organization on GitHub are considered to be covered by our standard [Code of Conduct](https://docs.npmjs.com/policies/conduct). ## Reporting Bugs Before submitting a new bug report please search for an existing or similar report. Use one of our existing issue templates if you believe you've come across a unique problem. Duplicate issues, or issues that don't use one of our templates may get closed without a response. ## Pull Request Conventions ### Commits We use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). When opening a pull request please be sure that either the pull request title, or each commit in the pull request, has one of the following prefixes: - `feat`: For when introducing a new feature. The result will be a new semver minor version of the package when it is next published. - `fix`: For bug fixes. The result will be a new semver patch version of the package when it is next published. - `docs`: For documentation updates. The result will be a new semver patch version of the package when it is next published. - `chore`: For changes that do not affect the published module. Often these are changes to tests. The result will be *no* change to the version of the package when it is next published (as the commit does not affect the published version). ### Test Coverage Pull requests made against this repo will run `npm test` automatically. Please make sure tests pass locally before submitting a PR. Every new feature or bug fix should come with a corresponding test or tests that validate the solutions. Testing also reports on code coverage and will fail if code coverage drops. ### Linting Linting is also done automatically once tests pass. `npm run lintfix` will fix most linting errors automatically. Please make sure linting passes before submitting a PR. ## What _not_ to contribute? ### Dependencies It should be noted that our team does not accept third-party dependency updates/PRs. If you submit a PR trying to update our dependencies we will close it with or without a reference to these contribution guidelines. ### Tools/Automation Our core team is responsible for the maintenance of the tooling/automation in this project and we ask contributors to not make changes to these when contributing (e.g. `.github/*`, `.eslintrc.json`, `.licensee.json`). Most of those files also have a header at the top to remind folks they are automatically generated. Pull requests that alter these will not be accepted. �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/LICENSE�����������������������������������������������������������������0000664�0000000�0000000�00000001343�15070766760�0016752�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-npm-package-arg-5b5edc1/README.md���������������������������������������������������������������0000664�0000000�0000000�00000012201�15070766760�0017217�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# npm-package-arg [![Build Status](https://img.shields.io/github/actions/workflow/status/npm/npm-package-arg/ci.yml?branch=main)](https://github.com/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 const assert = require("assert") const npa = require("npm-package-arg") // Pass in the descriptor, and it'll return an object try { const parsed = npa("@bar/foo@1.2") } catch (ex) { … } ``` ## USING `const npa = require('npm-package-arg')` ### const 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. ### const 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. ### const purl = npa.toPurl(*arg*, *reg*) Returns the [purl (package URL)](https://github.com/package-url/purl-spec) form of the given package name/spec. * *arg* - A package/version string. For example: `foo@1.0.0` or `@bar/foo@2.0.0-alpha.1`. * *reg* - Optionally the URL to the package registry. If not specified, assumes the default `https://registry.npmjs.org`. **Throws** if the package name is invalid, or the supplied arg can't be resolved to a purl. ## 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. See note below about how this is (not) encoded. * `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. ## SAVE SPECS TLDR: `file:` urls are NOT uri encoded. Historically, npm would uri decode file package args, but did not do any uri encoding for the `saveSpec`. This meant that it generated incorrect saveSpecs for directories with characters that *looked* like encoded uri characters, and also that it could not parse directories with some unencoded uri characters (such as `%`). In order to fix this, and to not break all existing versions of npm, this module now parses all file package args as not being uri encoded. And in order to not break all of the package.json files npm has made in the past, it also does not uri encode the saveSpec. This includes package args that start with `file:`. This does mean that npm `file:` package args are not RFC compliant, and making them so constitutes quite a breaking change. �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/SECURITY.md�������������������������������������������������������������0000664�0000000�0000000�00000002320�15070766760�0017532�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!-- This file is automatically added by @npmcli/template-oss. Do not edit. --> GitHub takes the security of our software products and services seriously, including the open source code repositories managed through our GitHub organizations, such as [GitHub](https://github.com/GitHub). If you believe you have found a security vulnerability in this GitHub-owned open source repository, you can report it to us in one of two ways. If the vulnerability you have found is *not* [in scope for the GitHub Bug Bounty Program](https://bounty.github.com/#scope) or if you do not wish to be considered for a bounty reward, please report the issue to us directly through [opensource-security@github.com](mailto:opensource-security@github.com). If the vulnerability you have found is [in scope for the GitHub Bug Bounty Program](https://bounty.github.com/#scope) and you would like for your finding to be considered for a bounty reward, please submit the vulnerability to us through [HackerOne](https://hackerone.com/github) in order to be eligible to receive a bounty award. **Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.** Thanks for helping make GitHub safe for everyone. ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/lib/��������������������������������������������������������������������0000775�0000000�0000000�00000000000�15070766760�0016512�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/lib/npa.js��������������������������������������������������������������0000664�0000000�0000000�00000033773�15070766760�0017643�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������'use strict' const isWindows = process.platform === 'win32' const { URL } = require('node:url') // We need to use path/win32 so that we get consistent results in tests, but this also means we need to manually convert backslashes to forward slashes when generating file: urls with paths. const path = isWindows ? require('node:path/win32') : require('node:path') const { homedir } = require('node:os') const HostedGit = require('hosted-git-info') const semver = require('semver') const validatePackageName = require('validate-npm-package-name') const { log } = require('proc-log') const hasSlashes = isWindows ? /\\|[/]/ : /[/]/ const isURL = /^(?:git[+])?[a-z]+:/i const isGit = /^[^@]+@[^:.]+\.[^:]+:.+$/i const isFileType = /[.](?:tgz|tar\.gz|tar)$/i const isPortNumber = /:[0-9]+(\/|$)/i const isWindowsFile = /^(?:[.]|~[/]|[/\\]|[a-zA-Z]:)/ const isPosixFile = /^(?:[.]|~[/]|[/]|[a-zA-Z]:)/ const defaultRegistry = 'https://registry.npmjs.org' 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.indexOf('@', 1) // Skip possible leading @ const namePart = nameEndsAt > 0 ? arg.slice(0, nameEndsAt) : arg if (isURL.test(arg)) { spec = arg } else if (isGit.test(arg)) { spec = `git+ssh://${arg}` // eslint-disable-next-line max-len } else if (!namePart.startsWith('@') && (hasSlashes.test(namePart) || isFileType.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) } function isFileSpec (spec) { if (!spec) { return false } if (spec.toLowerCase().startsWith('file:')) { return true } if (isWindows) { return isWindowsFile.test(spec) } // We never hit this in windows tests, obviously /* istanbul ignore next */ return isPosixFile.test(spec) } function isAliasSpec (spec) { if (!spec) { return false } return spec.toLowerCase().startsWith('npm:') } function resolve (name, spec, where, arg) { const res = new Result({ raw: arg, name: name, rawSpec: spec, fromArgument: arg != null, }) if (name) { res.name = name } if (!where) { where = process.cwd() } if (isFileSpec(spec)) { return fromFile(res, where) } else if (isAliasSpec(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) || isFileType.test(spec))) { return fromFile(res, where) } else { return fromRegistry(res) } } function toPurl (arg, reg = defaultRegistry) { const res = npa(arg) if (res.type !== 'version') { throw invalidPurlType(res.type, res.raw) } // URI-encode leading @ of scoped packages let purl = 'pkg:npm/' + res.name.replace(/^@/, '%40') + '@' + res.rawSpec if (reg !== defaultRegistry) { purl += '?repository_url=' + reg } return purl } 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 invalidPurlType (type, raw) { // eslint-disable-next-line max-len const err = new Error(`Invalid type "${type}" of package "${raw}": Purl can only be generated for "version" types.`) err.code = 'EINVALIDPURLTYPE' return err } class Result { constructor (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 } // TODO move this to a getter/setter in a semver major setName (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 } toString () { 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 } toJSON () { const result = Object.assign({}, this) delete result.hosted return result } } // sets res.gitCommittish, res.gitRange, and res.gitSubdir function setGitAttrs (res, committish) { if (!committish) { res.gitCommittish = null return } // 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}"`) } } // Taken from: EncodePathChars and lookup_table in src/node_url.cc // url.pathToFileURL only returns absolute references. We can't use it to encode paths. // encodeURI mangles windows paths. We can't use it to encode paths. // Under the hood, url.pathToFileURL does a limited set of encoding, with an extra windows step, and then calls path.resolve. // The encoding node does without path.resolve is not available outside of the source, so we are recreating it here. const encodedPathChars = new Map([ ['\0', '%00'], ['\t', '%09'], ['\n', '%0A'], ['\r', '%0D'], [' ', '%20'], ['"', '%22'], ['#', '%23'], ['%', '%25'], ['?', '%3F'], ['[', '%5B'], ['\\', isWindows ? '/' : '%5C'], [']', '%5D'], ['^', '%5E'], ['|', '%7C'], ['~', '%7E'], ]) function pathToFileURL (str) { let result = '' for (let i = 0; i < str.length; i++) { result = `${result}${encodedPathChars.get(str[i]) ?? str[i]}` } if (result.startsWith('file:')) { return result } return `file:${result}` } function fromFile (res, where) { res.type = isFileType.test(res.rawSpec) ? 'file' : 'directory' res.where = where let rawSpec = pathToFileURL(res.rawSpec) if (rawSpec.startsWith('file:/')) { // XXX backwards compatibility lack of compliance with RFC 8089 // turn file://path into file:/path if (/^file:\/\/[^/]/.test(rawSpec)) { rawSpec = `file:/${rawSpec.slice(5)}` } // turn file:/../path into file:../path // for 1 or 3 leading slashes (2 is already ruled out from handling file:// explicitly above) if (/^\/{1,3}\.\.?(\/|$)/.test(rawSpec.slice(5))) { rawSpec = rawSpec.replace(/^file:\/{1,3}/, 'file:') } } let resolvedUrl let specUrl try { // always put the '/' on "where", or else file:foo from /path/to/bar goes to /path/to/foo, when we want it to be /path/to/bar/foo resolvedUrl = new URL(rawSpec, `${pathToFileURL(path.resolve(where))}/`) specUrl = new URL(rawSpec) } catch (originalError) { const er = new Error('Invalid file: URL, must comply with RFC 8089') throw Object.assign(er, { raw: res.rawSpec, spec: res, where, originalError, }) } // 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(rawSpec.slice(5))) { res.saveSpec = `file:${path.relative(where, resolvedPath)}` } else { res.saveSpec = `file:${path.resolve(resolvedPath)}` } res.fetchSpec = path.resolve(where, resolvedPath) // re-normalize the slashes in saveSpec due to node:path/win32 behavior in windows res.saveSpec = res.saveSpec.split('\\').join('/') // Ignoring because this only happens in windows /* istanbul ignore next */ if (res.saveSpec.startsWith('file://')) { // normalization of \\win32\root paths can cause a double / which we don't want res.saveSpec = `file:/${res.saveSpec.slice(7)}` } 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() setGitAttrs(res, hosted.committish) return res } function unsupportedURLType (protocol, spec) { const err = new Error(`Unsupported URL Type "${protocol}": ${spec}`) err.code = 'EUNSUPPORTEDPROTOCOL' return err } function fromURL (res) { let rawSpec = res.rawSpec res.saveSpec = rawSpec if (rawSpec.startsWith('git+ssh:')) { // 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. // 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 = rawSpec.match(/^git\+ssh:\/\/([^:#]+:[^#]+(?:\.git)?)(?:#(.*))?$/i) // Filter out all-number "usernames" which are really port numbers // They can either be :1234 :1234/ or :1234/path but not :12abc if (matched && !matched[1].match(isPortNumber)) { res.type = 'git' setGitAttrs(res, matched[2]) res.fetchSpec = matched[1] return res } } else if (rawSpec.startsWith('git+file://')) { // URL can't handle windows paths rawSpec = rawSpec.replace(/\\/g, '/') } const parsedUrl = new URL(rawSpec) // check the protocol, and then see if it's git or not switch (parsedUrl.protocol) { case 'git:': case 'git+http:': case 'git+https:': case 'git+rsync:': case 'git+ftp:': case 'git+file:': case 'git+ssh:': res.type = 'git' setGitAttrs(res, parsedUrl.hash.slice(1)) if (parsedUrl.protocol === 'git+file:' && /^git\+file:\/\/[a-z]:/i.test(rawSpec)) { // URL can't handle drive letters on windows file paths, the host can't contain a : res.fetchSpec = `git+file://${parsedUrl.host.toLowerCase()}:${parsedUrl.pathname}` } else { parsedUrl.hash = '' res.fetchSpec = parsedUrl.toString() } if (res.fetchSpec.startsWith('git+')) { res.fetchSpec = res.fetchSpec.slice(4) } break case 'http:': case 'https:': res.type = 'remote' res.fetchSpec = res.saveSpec break default: throw unsupportedURLType(parsedUrl.protocol, 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') } if (!subSpec.name) { throw new Error('aliases must have a name') } 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 } module.exports = npa module.exports.resolve = resolve module.exports.toPurl = toPurl module.exports.Result = Result �����npm-npm-package-arg-5b5edc1/package.json������������������������������������������������������������0000664�0000000�0000000�00000002763�15070766760�0020242�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "name": "npm-package-arg", "version": "13.0.1", "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": "^9.0.0", "proc-log": "^5.0.0", "semver": "^7.3.5", "validate-npm-package-name": "^6.0.0" }, "devDependencies": { "@npmcli/eslint-config": "^5.0.0", "@npmcli/template-oss": "4.23.5", "tap": "^16.0.1" }, "scripts": { "test": "tap", "snap": "tap", "npmclilint": "npmcli-lint", "lint": "npm run eslint", "lintfix": "npm run eslint -- --fix", "posttest": "npm run lint", "postsnap": "npm run lintfix --", "postlint": "template-oss-check", "template-oss-apply": "template-oss-apply --force", "eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"" }, "repository": { "type": "git", "url": "git+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": "^20.17.0 || >=22.9.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.23.5", "publish": true } } �������������npm-npm-package-arg-5b5edc1/release-please-config.json����������������������������������������������0000664�0000000�0000000�00000001277�15070766760�0023000�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "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", "section": "Chores", "hidden": true } ], "packages": { ".": { "package-name": "" } }, "prerelease-type": "pre.0" } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/test/�������������������������������������������������������������������0000775�0000000�0000000�00000000000�15070766760�0016723�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/test/basic.js�����������������������������������������������������������0000664�0000000�0000000�00000055112�15070766760�0020346�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������const path = require('node:path').posix const os = require('node:os') const normalizePath = p => p && p.replace(/^[a-zA-Z]:/, '').replace(/\\/g, '/') const cwd = normalizePath(process.cwd()) process.cwd = () => cwd const normalizePaths = spec => { spec.fetchSpec = normalizePath(spec.fetchSpec) return spec } const t = require('tap') const npa = t.mock('..', { path }) t.test('basic', function (t) { 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) { t.test(arg, t => { 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 + ']') }) t.end() }) }) 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:') }, 'aliases must have a name') 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('directory with non URI compatible components', t => { t.has(normalizePaths(npa('/test%dir')), { type: 'directory', name: null, rawSpec: '/test%dir', fetchSpec: '/test%dir', saveSpec: 'file:/test%dir', }) t.end() }) t.test('file: spec with non URI compatible components', t => { t.has(normalizePaths(npa('file:/test%dir')), { type: 'directory', name: null, rawSpec: 'file:/test%dir', fetchSpec: '/test%dir', saveSpec: 'file:/test%dir', }) t.end() }) t.test('directory cwd has non URI compatible components', t => { // eslint-disable-next-line max-len const where = '/tmp/ !"$%&\'()*+,-.0123456789:;<=>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~' const originalCwd = process.cwd t.teardown(() => { process.cwd = originalCwd }) process.cwd = () => where t.has(normalizePaths(npa('./')), { type: 'directory', where, name: null, rawSpec: './', fetchSpec: normalizePath(where), }) t.end() }) t.test('invalid url', t => { const broken = t.mock('..', { 'node:url': { URL: class { constructor () { throw new Error('something went wrong') } }, }, }) t.throws(() => broken('file:./test'), { message: 'Invalid file: URL' } ) 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() }) t.test('tarball regex should only match literal dots', t => { // Valid tarball extensions - should match t.has(normalizePaths(npa('/path/to/package.tar.gz')), { type: 'file', name: null, }, '.tar.gz should match as file') t.has(normalizePaths(npa('/path/to/package.tgz')), { type: 'file', name: null, }, '.tgz should match as file') t.has(normalizePaths(npa('/path/to/package.tar')), { type: 'file', name: null, }, '.tar should match as file') // Invalid patterns with non-dot characters - should NOT match as file // These should be treated as directories, not files t.has(normalizePaths(npa('/path/to/package.tarXgz')), { type: 'directory', name: null, }, '.tarXgz should NOT match as file (X is not a dot)') t.has(normalizePaths(npa('/path/to/package.tar_gz')), { type: 'directory', name: null, }, '.tar_gz should NOT match as file (underscore is not a dot)') t.has(normalizePaths(npa('./package.tar gz')), { type: 'directory', name: null, }, '.tar gz should NOT match as file (space is not a dot)') t.end() }) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/test/bitbucket.js�������������������������������������������������������0000664�0000000�0000000�00000003673�15070766760�0021246�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-npm-package-arg-5b5edc1/test/github.js����������������������������������������������������������0000664�0000000�0000000�00000006355�15070766760�0020554�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': { name: undefined, type: 'git', saveSpec: 'git+ssh://git@github.com:12345', fetchSpec: 'ssh://git@github.com:12345', raw: 'git@github.com:12345', }, 'git@github.com:12345/': { name: undefined, type: 'git', saveSpec: 'git+ssh://git@github.com:12345/', fetchSpec: 'ssh://git@github.com:12345/', raw: 'git@github.com:12345/', }, 'git@github.com:12345/foo': { name: undefined, type: 'git', saveSpec: 'git+ssh://git@github.com:12345/foo', fetchSpec: 'ssh://git@github.com:12345/foo', raw: 'git@github.com:12345/foo', }, 'git@github.com:12345foo': { name: undefined, type: 'git', saveSpec: 'git+ssh://git@github.com:12345foo', fetchSpec: 'git@github.com:12345foo', raw: 'git@github.com:12345foo', }, } 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-npm-package-arg-5b5edc1/test/gitlab.js����������������������������������������������������������0000664�0000000�0000000�00000003470�15070766760�0020527�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-npm-package-arg-5b5edc1/test/invalid-url.js�����������������������������������������������������0000664�0000000�0000000�00000000215�15070766760�0021505�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������const npa = require('..') const t = require('tap') t.throws(() => npa('foo@gopher://goodluckwiththat'), { code: 'EUNSUPPORTEDPROTOCOL', }) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/test/purl.js������������������������������������������������������������0000664�0000000�0000000�00000002072�15070766760�0020244�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������'use strict' var test = require('tap').test var npa = require('..') test('toPurl - valid', function (t) { // Unscoped package t.equal(npa.toPurl('foo@1.2.3'), 'pkg:npm/foo@1.2.3') // Scoped package t.equal( npa.toPurl('@foo/bar@1.2.3-alpha.1'), 'pkg:npm/%40foo/bar@1.2.3-alpha.1') // Non-default registry t.equal( npa.toPurl({ name: '@foo/bar', rawSpec: '1.0.0' }, 'https://npm.pkg.github.com'), 'pkg:npm/%40foo/bar@1.0.0?repository_url=https://npm.pkg.github.com' ) // Default registry t.equal( npa.toPurl({ name: '@foo/bar', rawSpec: '1.0.0' }, 'https://registry.npmjs.org'), 'pkg:npm/%40foo/bar@1.0.0' ) t.end() }) test('toPurl - invalid', function (t) { // Invalid version t.throws(() => npa.toPurl({ name: 'foo/bar', rawSpec: '1.0.0' }), { code: 'EINVALIDPACKAGENAME', }) // Invalid version t.throws(() => npa.toPurl('foo@a.b.c'), { code: 'EINVALIDPURLTYPE', }) // Invalid type t.throws(() => npa.toPurl('git+ssh://git@github.com/user/foo#1.2.3'), { code: 'EINVALIDPURLTYPE', }) t.end() }) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npm-npm-package-arg-5b5edc1/test/realize-package-specifier.js���������������������������������������0000664�0000000�0000000�00000003563�15070766760�0024263�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-npm-package-arg-5b5edc1/test/windows.js���������������������������������������������������������0000664�0000000�0000000�00000004600�15070766760�0020753�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������// redefine process.platform before any requires so that we don't cache a require that got the non-redefined value const { platform } = process Object.defineProperty(process, 'platform', { value: 'win32' }) const t = require('tap') const npa = require('..') t.teardown(() => { Object.defineProperty(process, 'platform', { value: platform }) }) 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) { t.test(c, t => { const expect = cases[c] const actual = npa(c, 'C:\\test\\path') t.has(actual, expect, c) t.end() }) }) t.end() }) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������