pax_global_header 0000666 0000000 0000000 00000000064 15141150374 0014513 g ustar 00root root 0000000 0000000 52 comment=5993c2e42bdf17c5f03e6360da51bc707fcee460
npm-node-semver-5993c2e/ 0000775 0000000 0000000 00000000000 15141150374 0015074 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/.commitlintrc.js 0000664 0000000 0000000 00000000566 15141150374 0020223 0 ustar 00root root 0000000 0000000 /* This file is automatically added by @npmcli/template-oss. Do not edit. */
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'deps', 'chore']],
'header-max-length': [2, 'always', 80],
'subject-case': [0],
'body-max-line-length': [0],
'footer-max-line-length': [0],
},
}
npm-node-semver-5993c2e/.eslintrc.js 0000664 0000000 0000000 00000000623 15141150374 0017334 0 ustar 00root root 0000000 0000000 /* This file is automatically added by @npmcli/template-oss. Do not edit. */
'use strict'
const { readdirSync: readdir } = require('fs')
const localConfigs = readdir(__dirname)
.filter((file) => file.startsWith('.eslintrc.local.'))
.map((file) => `./${file}`)
module.exports = {
root: true,
ignorePatterns: [
'tap-testdir*/',
],
extends: [
'@npmcli',
...localConfigs,
],
}
npm-node-semver-5993c2e/.eslintrc.local.js 0000664 0000000 0000000 00000000615 15141150374 0020426 0 ustar 00root root 0000000 0000000 'use strict'
module.exports = {
overrides: [
{
files: ['bin/**', 'classes/**', 'functions/**', 'internal/**', 'ranges/**'],
rules: {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: false,
},
],
'import/no-nodejs-modules': ['error'],
strict: ['error', 'global'],
},
},
],
}
npm-node-semver-5993c2e/.github/ 0000775 0000000 0000000 00000000000 15141150374 0016434 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/.github/CODEOWNERS 0000664 0000000 0000000 00000000132 15141150374 0020023 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
* @npm/cli-team
npm-node-semver-5993c2e/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 15141150374 0020617 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/.github/ISSUE_TEMPLATE/bug.yml 0000664 0000000 0000000 00000002655 15141150374 0022127 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Bug
description: File a bug/issue
title: "[BUG]
"
labels: [ Bug, Needs Triage ]
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please [search here](./issues) to see if an issue already exists for your problem.
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: Current Behavior
description: A clear & concise description of what you're experiencing.
validations:
required: false
- type: textarea
attributes:
label: Expected Behavior
description: A clear & concise description of what you expected to happen.
validations:
required: false
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
value: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
validations:
required: false
- type: textarea
attributes:
label: Environment
description: |
examples:
- **npm**: 7.6.3
- **Node**: 13.14.0
- **OS**: Ubuntu 20.04
- **platform**: Macbook Pro
value: |
- npm:
- Node:
- OS:
- platform:
validations:
required: false
npm-node-semver-5993c2e/.github/ISSUE_TEMPLATE/config.yml 0000664 0000000 0000000 00000000145 15141150374 0022607 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
blank_issues_enabled: true
npm-node-semver-5993c2e/.github/actions/ 0000775 0000000 0000000 00000000000 15141150374 0020074 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/.github/actions/create-check/ 0000775 0000000 0000000 00000000000 15141150374 0022412 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/.github/actions/create-check/action.yml 0000664 0000000 0000000 00000002720 15141150374 0024413 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-node-semver-5993c2e/.github/actions/install-latest-npm/ 0000775 0000000 0000000 00000000000 15141150374 0023624 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/.github/actions/install-latest-npm/action.yml 0000664 0000000 0000000 00000003406 15141150374 0025627 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-node-semver-5993c2e/.github/dependabot.yml 0000664 0000000 0000000 00000002410 15141150374 0021261 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
- package-ecosystem: npm
directory: /
schedule:
interval: daily
target-branch: "release/v5"
allow:
- dependency-type: direct
dependency-name: "@npmcli/template-oss"
versioning-strategy: increase-if-necessary
commit-message:
prefix: deps
prefix-development: chore
labels:
- "Dependencies"
- "Backport"
- "release/v5"
open-pull-requests-limit: 10
- package-ecosystem: npm
directory: /
schedule:
interval: daily
target-branch: "release/v6"
allow:
- dependency-type: direct
dependency-name: "@npmcli/template-oss"
versioning-strategy: increase-if-necessary
commit-message:
prefix: deps
prefix-development: chore
labels:
- "Dependencies"
- "Backport"
- "release/v6"
open-pull-requests-limit: 10
npm-node-semver-5993c2e/.github/matchers/ 0000775 0000000 0000000 00000000000 15141150374 0020242 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/.github/matchers/tap.json 0000664 0000000 0000000 00000001204 15141150374 0021716 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-node-semver-5993c2e/.github/settings.yml 0000664 0000000 0000000 00000003063 15141150374 0021021 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" ]
- name: release/v5
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" ]
- name: release/v6
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-node-semver-5993c2e/.github/workflows/ 0000775 0000000 0000000 00000000000 15141150374 0020471 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/.github/workflows/audit.yml 0000664 0000000 0000000 00000002275 15141150374 0022330 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"
permissions:
contents: read
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-node-semver-5993c2e/.github/workflows/ci-release.yml 0000664 0000000 0000000 00000011663 15141150374 0023234 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
permissions:
contents: read
checks: write
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-15-intel
shell: bash
- name: Windows
os: windows-latest
shell: cmd
node-version:
- 10.0.0
- 10.x
- 12.x
- 14.x
- 16.x
- 18.x
- 20.x
- 22.x
exclude:
- platform: { name: macOS, os: macos-latest, shell: bash }
node-version: 10.0.0
- platform: { name: macOS, os: macos-latest, shell: bash }
node-version: 10.x
- platform: { name: macOS, os: macos-latest, shell: bash }
node-version: 12.x
- platform: { name: macOS, os: macos-latest, shell: bash }
node-version: 14.x
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 16.x
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 18.x
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 20.x
- platform: { name: macOS, os: macos-15-intel, 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-node-semver-5993c2e/.github/workflows/ci.yml 0000664 0000000 0000000 00000007140 15141150374 0021611 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
- release/v*
schedule:
# "At 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1
- cron: "0 9 * * 1"
permissions:
contents: read
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-15-intel
shell: bash
- name: Windows
os: windows-latest
shell: cmd
node-version:
- 10.0.0
- 10.x
- 12.x
- 14.x
- 16.x
- 18.x
- 20.x
- 22.x
exclude:
- platform: { name: macOS, os: macos-latest, shell: bash }
node-version: 10.0.0
- platform: { name: macOS, os: macos-latest, shell: bash }
node-version: 10.x
- platform: { name: macOS, os: macos-latest, shell: bash }
node-version: 12.x
- platform: { name: macOS, os: macos-latest, shell: bash }
node-version: 14.x
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 16.x
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 18.x
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 20.x
- platform: { name: macOS, os: macos-15-intel, 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-node-semver-5993c2e/.github/workflows/codeql-analysis.yml 0000664 0000000 0000000 00000001654 15141150374 0024312 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: CodeQL
on:
push:
branches:
- main
- release/v*
pull_request:
branches:
- main
- release/v*
schedule:
# "At 10:00 UTC (03:00 PT) on Monday" https://crontab.guru/#0_10_*_*_1
- cron: "0 10 * * 1"
permissions:
contents: read
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-node-semver-5993c2e/.github/workflows/post-dependabot.yml 0000664 0000000 0000000 00000012004 15141150374 0024301 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=--workspace ${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-node-semver-5993c2e/.github/workflows/pull-request.yml 0000664 0000000 0000000 00000002737 15141150374 0023667 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
permissions:
contents: read
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-node-semver-5993c2e/.github/workflows/release-integration.yml 0000664 0000000 0000000 00000004163 15141150374 0025161 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
permissions:
contents: read
id-token: write
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-node-semver-5993c2e/.github/workflows/release.yml 0000664 0000000 0000000 00000026131 15141150374 0022637 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Release
on:
push:
branches:
- main
- release/v*
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:
contents: read
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-node-semver-5993c2e/.gitignore 0000664 0000000 0000000 00000001207 15141150374 0017064 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
!/.eslint.config.js
!/.eslintrc.js
!/.eslintrc.local.*
!/.git-blame-ignore-revs
!/.github/
!/.gitignore
!/.npmrc
!/.prettierignore
!/.prettierrc.js
!/.release-please-manifest.json
!/benchmarks
!/bin/
!/CHANGELOG*
!/classes/
!/CODE_OF_CONDUCT.md
!/CONTRIBUTING.md
!/docs/
!/functions/
!/index.js
!/internal/
!/lib/
!/LICENSE*
!/map.js
!/package.json
!/preload.js
!/range.bnf
!/ranges/
!/README*
!/release-please-config.json
!/scripts/
!/SECURITY.md
!/tap-snapshots/
!/test/
!/tsconfig.json
tap-testdir*/
npm-node-semver-5993c2e/.npmrc 0000664 0000000 0000000 00000000135 15141150374 0016213 0 ustar 00root root 0000000 0000000 ; This file is automatically added by @npmcli/template-oss. Do not edit.
package-lock=false
npm-node-semver-5993c2e/.release-please-manifest.json 0000664 0000000 0000000 00000000023 15141150374 0022533 0 ustar 00root root 0000000 0000000 {
".": "7.7.4"
}
npm-node-semver-5993c2e/CHANGELOG.md 0000664 0000000 0000000 00000052674 15141150374 0016723 0 ustar 00root root 0000000 0000000 # Changelog
## [7.7.4](https://github.com/npm/node-semver/compare/v7.7.3...v7.7.4) (2026-01-16)
### Bug Fixes
* [`a29faa5`](https://github.com/npm/node-semver/commit/a29faa5f3309a01c8e5aeb965fb5c02c4c4e80e2) [#835](https://github.com/npm/node-semver/pull/835) cli: pass options to semver.valid() for loose version validation (#835) (@mldangelo)
### Documentation
* [`1d28d5e`](https://github.com/npm/node-semver/commit/1d28d5e82de16163daf721a7c76fff93e0d333ab) [#836](https://github.com/npm/node-semver/pull/836) fix typos and update -n CLI option documentation (#836) (@mldangelo)
### Dependencies
* [`120968b`](https://github.com/npm/node-semver/commit/120968b76760cb0db85a72bde2adedd0e9628793) [#840](https://github.com/npm/node-semver/pull/840) `@npmcli/template-oss@4.29.0` (#840)
### Chores
* [`44d7130`](https://github.com/npm/node-semver/commit/44d7130c60cedd3703048aa671bb1d659b79ab07) [#824](https://github.com/npm/node-semver/pull/824) bump @npmcli/eslint-config from 5.1.0 to 6.0.0 (#824) (@dependabot[bot])
* [`7073576`](https://github.com/npm/node-semver/commit/70735767b68a1775eb67ac816b183b4a422101f4) [#820](https://github.com/npm/node-semver/pull/820) reorder parameters in invalid-versions.js test (#820) (@reggi)
* [`5816d4c`](https://github.com/npm/node-semver/commit/5816d4cfd6d85169527a2bc22fbd5bf4c64f34e3) [#829](https://github.com/npm/node-semver/pull/829) bump @npmcli/template-oss from 4.28.0 to 4.28.1 (#829) (@dependabot[bot], @npm-cli-bot)
## [7.7.3](https://github.com/npm/node-semver/compare/v7.7.2...v7.7.3) (2025-10-06)
### Bug Fixes
* [`e37e0ca`](https://github.com/npm/node-semver/commit/e37e0ca0b5fc910d2b1948d25dbc83cc3a0921ea) [#813](https://github.com/npm/node-semver/pull/813) faster paths for compare (#813) (@H4ad)
* [`2471d75`](https://github.com/npm/node-semver/commit/2471d7543e2e63d9d95358e2405e7e1cde926c36) [#811](https://github.com/npm/node-semver/pull/811) x-range build metadata support (i529015)
### Chores
* [`8f05c87`](https://github.com/npm/node-semver/commit/8f05c87f56a4123259b8c6d9324f53eadb02e48f) [#807](https://github.com/npm/node-semver/pull/807) bump @npmcli/template-oss from 4.25.0 to 4.25.1 (#807) (@dependabot[bot], @owlstronaut)
## [7.7.2](https://github.com/npm/node-semver/compare/v7.7.1...v7.7.2) (2025-05-12)
### Bug Fixes
* [`fcafb61`](https://github.com/npm/node-semver/commit/fcafb61ed566ff8ccf24818dd94b76738f037aa4) [#780](https://github.com/npm/node-semver/pull/780) add missing `'use strict'` directives (#780) (@Fdawgs)
* [`c99f336`](https://github.com/npm/node-semver/commit/c99f336fa3bdff465652f9041eab2127d2f52eb2) [#781](https://github.com/npm/node-semver/pull/781) prerelease identifier starting with digits (#781) (@mbtools)
### Chores
* [`c760403`](https://github.com/npm/node-semver/commit/c760403b935d3ad35f83e9bbe5ebe1badef2fc71) [#784](https://github.com/npm/node-semver/pull/784) template-oss-apply for workflow permissions (#784) (@wraithgar)
* [`2677f2a`](https://github.com/npm/node-semver/commit/2677f2a88334b0e728dbfe9ad9f5f57458437c87) [#778](https://github.com/npm/node-semver/pull/778) bump @npmcli/template-oss from 4.23.6 to 4.24.3 (#778) (@dependabot[bot], @npm-cli-bot)
## [7.7.1](https://github.com/npm/node-semver/compare/v7.7.0...v7.7.1) (2025-02-03)
### Bug Fixes
* [`af761c0`](https://github.com/npm/node-semver/commit/af761c05bd53eef83b5e20f8b09360b0e70557dc) [#764](https://github.com/npm/node-semver/pull/764) inc: fully capture prerelease identifier (#764) (@wraithgar)
## [7.7.0](https://github.com/npm/node-semver/compare/v7.6.3...v7.7.0) (2025-01-29)
### Features
* [`0864b3c`](https://github.com/npm/node-semver/commit/0864b3ce7932667013e0c7c5ec764777d4682883) [#753](https://github.com/npm/node-semver/pull/753) add "release" inc type (#753) (@mbtools)
### Bug Fixes
* [`d588e37`](https://github.com/npm/node-semver/commit/d588e3782864b1cab2fe9f2452b848e8c7f609d1) [#755](https://github.com/npm/node-semver/pull/755) diff: fix prerelease to stable version diff logic (#755) (@eminberkayd, berkay.daglar)
* [`8a34bde`](https://github.com/npm/node-semver/commit/8a34bdecc783407f4e1a8a1ee1f67906b84a4b78) [#754](https://github.com/npm/node-semver/pull/754) add identifier validation to `inc()` (#754) (@mbtools)
### Documentation
* [`67e5478`](https://github.com/npm/node-semver/commit/67e54785a0f871361230f84323cbb631b9b6d834) [#756](https://github.com/npm/node-semver/pull/756) readme: added missing period for consistency (#756) (@shaymolcho)
* [`868d4bb`](https://github.com/npm/node-semver/commit/868d4bbe3d318c52544f38d5f9977a1103e924c2) [#749](https://github.com/npm/node-semver/pull/749) clarify comment about obsolete prefixes (#749) (@mbtools, @ljharb)
### Chores
* [`145c554`](https://github.com/npm/node-semver/commit/145c554b8c7b7ecfcb451153ad18bdb2f24ad10d) [#741](https://github.com/npm/node-semver/pull/741) bump @npmcli/eslint-config from 4.0.5 to 5.0.0 (@dependabot[bot])
* [`753e02b`](https://github.com/npm/node-semver/commit/753e02b9d0cb3ac23e085dc33efcab3e08d61f2b) [#747](https://github.com/npm/node-semver/pull/747) bump @npmcli/template-oss from 4.23.3 to 4.23.4 (#747) (@dependabot[bot], @npm-cli-bot)
* [`0b812d5`](https://github.com/npm/node-semver/commit/0b812d5fb5fbb208e89dc1250e2efafeaa549437) [#744](https://github.com/npm/node-semver/pull/744) postinstall for dependabot template-oss PR (@hashtagchris)
## [7.6.3](https://github.com/npm/node-semver/compare/v7.6.2...v7.6.3) (2024-07-16)
### Bug Fixes
* [`73a3d79`](https://github.com/npm/node-semver/commit/73a3d79c4ec32d5dd62c9d5f64e5af7fbdad9ec0) [#726](https://github.com/npm/node-semver/pull/726) optimize Range parsing and formatting (#726) (@jviide)
### Documentation
* [`2975ece`](https://github.com/npm/node-semver/commit/2975ece120e17660c9f1ef517de45c09ff821064) [#719](https://github.com/npm/node-semver/pull/719) fix extra backtick typo (#719) (@stdavis)
## [7.6.2](https://github.com/npm/node-semver/compare/v7.6.1...v7.6.2) (2024-05-09)
### Bug Fixes
* [`6466ba9`](https://github.com/npm/node-semver/commit/6466ba9b540252db405fdd2a289dd4651495beea) [#713](https://github.com/npm/node-semver/pull/713) lru: use map.delete() directly (#713) (@negezor, @lukekarrys)
## [7.6.1](https://github.com/npm/node-semver/compare/v7.6.0...v7.6.1) (2024-05-04)
### Bug Fixes
* [`c570a34`](https://github.com/npm/node-semver/commit/c570a348ffc6612af07fe94fa46b9affa5e4eff0) [#704](https://github.com/npm/node-semver/pull/704) linting: no-unused-vars (@wraithgar)
* [`ad8ff11`](https://github.com/npm/node-semver/commit/ad8ff11dd200dac3a05097d9a82d1977ccfa1535) [#704](https://github.com/npm/node-semver/pull/704) use internal cache implementation (@mbtools)
* [`ac9b357`](https://github.com/npm/node-semver/commit/ac9b35769ab0ddfefd5a3af4a3ecaf3da2012352) [#682](https://github.com/npm/node-semver/pull/682) typo in compareBuild debug message (#682) (@mbtools)
### Dependencies
* [`988a8de`](https://github.com/npm/node-semver/commit/988a8deb3ea76b9a314a740e66b5fc2f726822f8) [#709](https://github.com/npm/node-semver/pull/709) uninstall `lru-cache` (#709)
* [`3fabe4d`](https://github.com/npm/node-semver/commit/3fabe4dbfbd199fdb589c076a7f30bc1f18c6614) [#704](https://github.com/npm/node-semver/pull/704) remove lru-cache
### Chores
* [`dd09b60`](https://github.com/npm/node-semver/commit/dd09b60da1e618335d7c269426345b336fd5f63d) [#705](https://github.com/npm/node-semver/pull/705) bump @npmcli/template-oss to 4.22.0 (@lukekarrys)
* [`ec49cdc`](https://github.com/npm/node-semver/commit/ec49cdcece9db0020d6829b246681ff65a393644) [#701](https://github.com/npm/node-semver/pull/701) chore: chore: postinstall for dependabot template-oss PR (@lukekarrys)
* [`b236c3d`](https://github.com/npm/node-semver/commit/b236c3d2f357a16a733c96ec2ca8c57848b70091) [#696](https://github.com/npm/node-semver/pull/696) add benchmarks (#696) (@H4ad)
* [`692451b`](https://github.com/npm/node-semver/commit/692451bd6f75b38a71a99f39da405c94a5954a22) [#688](https://github.com/npm/node-semver/pull/688) various improvements to README (#688) (@mbtools)
* [`5feeb7f`](https://github.com/npm/node-semver/commit/5feeb7f4f63061e19a29087115b50cb04135b63e) [#705](https://github.com/npm/node-semver/pull/705) postinstall for dependabot template-oss PR (@lukekarrys)
* [`074156f`](https://github.com/npm/node-semver/commit/074156f64fa91723fe1ae6af8cc497014b9b7aff) [#701](https://github.com/npm/node-semver/pull/701) bump @npmcli/template-oss from 4.21.3 to 4.21.4 (@dependabot[bot])
## [7.6.0](https://github.com/npm/node-semver/compare/v7.5.4...v7.6.0) (2024-01-31)
### Features
* [`a7ab13a`](https://github.com/npm/node-semver/commit/a7ab13a46201e342d34e84a989632b380f755baf) [#671](https://github.com/npm/node-semver/pull/671) preserve pre-release and build parts of a version on coerce (#671) (@madtisa, madtisa, @wraithgar)
### Chores
* [`816c7b2`](https://github.com/npm/node-semver/commit/816c7b2cbfcb1986958a290f941eddfd0441139e) [#667](https://github.com/npm/node-semver/pull/667) postinstall for dependabot template-oss PR (@lukekarrys)
* [`0bd24d9`](https://github.com/npm/node-semver/commit/0bd24d943cbd1a7f6a2b8d384590bfa98559e1de) [#667](https://github.com/npm/node-semver/pull/667) bump @npmcli/template-oss from 4.21.1 to 4.21.3 (@dependabot[bot])
* [`e521932`](https://github.com/npm/node-semver/commit/e521932f115a81030f4e7c34e8631cdd3c6a108b) [#652](https://github.com/npm/node-semver/pull/652) postinstall for dependabot template-oss PR (@lukekarrys)
* [`8873991`](https://github.com/npm/node-semver/commit/88739918080debeb239aae840b35c07436148e50) [#652](https://github.com/npm/node-semver/pull/652) chore: chore: postinstall for dependabot template-oss PR (@lukekarrys)
* [`f317dc8`](https://github.com/npm/node-semver/commit/f317dc8689781bcfd98e2c32b46157276acdd47c) [#652](https://github.com/npm/node-semver/pull/652) bump @npmcli/template-oss from 4.19.0 to 4.21.0 (@dependabot[bot])
* [`7303db1`](https://github.com/npm/node-semver/commit/7303db1fe54d6905b23ccb0162878e37d73535ef) [#658](https://github.com/npm/node-semver/pull/658) add clean() test for build metadata (#658) (@jethrodaniel)
* [`6240d75`](https://github.com/npm/node-semver/commit/6240d75a7c620b0a222f05969a91fdc3dc2be0fb) [#656](https://github.com/npm/node-semver/pull/656) add missing quotes in README.md (#656) (@zyxkad)
* [`14d263f`](https://github.com/npm/node-semver/commit/14d263faa156e408a033b9b12a2f87735c2df42c) [#625](https://github.com/npm/node-semver/pull/625) postinstall for dependabot template-oss PR (@lukekarrys)
* [`7c34e1a`](https://github.com/npm/node-semver/commit/7c34e1ac1bcc0bc6579b30745c96075c69bd0332) [#625](https://github.com/npm/node-semver/pull/625) bump @npmcli/template-oss from 4.18.1 to 4.19.0 (@dependabot[bot])
* [`123e0b0`](https://github.com/npm/node-semver/commit/123e0b03287e1af295ef82d55f55c16805596f35) [#622](https://github.com/npm/node-semver/pull/622) postinstall for dependabot template-oss PR (@lukekarrys)
* [`737d5e1`](https://github.com/npm/node-semver/commit/737d5e1cf10e631bab8a28594aa2d5c9d4090814) [#622](https://github.com/npm/node-semver/pull/622) bump @npmcli/template-oss from 4.18.0 to 4.18.1 (@dependabot[bot])
* [`cce6180`](https://github.com/npm/node-semver/commit/cce61804ba6f997225a1267135c06676fe0524d2) [#598](https://github.com/npm/node-semver/pull/598) postinstall for dependabot template-oss PR (@lukekarrys)
* [`b914a3d`](https://github.com/npm/node-semver/commit/b914a3d0d26ca27d2685053d7d390af4e02eedd9) [#598](https://github.com/npm/node-semver/pull/598) bump @npmcli/template-oss from 4.17.0 to 4.18.0 (@dependabot[bot])
## [7.5.4](https://github.com/npm/node-semver/compare/v7.5.3...v7.5.4) (2023-07-07)
### Bug Fixes
* [`cc6fde2`](https://github.com/npm/node-semver/commit/cc6fde2d34b95cb600d126649d926901bd2a9703) [#588](https://github.com/npm/node-semver/pull/588) trim each range set before parsing (@lukekarrys)
* [`99d8287`](https://github.com/npm/node-semver/commit/99d8287516a1d2abf0286033e2e26eca6b69c09f) [#583](https://github.com/npm/node-semver/pull/583) correctly parse long build ids as valid (#583) (@lukekarrys)
## [7.5.3](https://github.com/npm/node-semver/compare/v7.5.2...v7.5.3) (2023-06-22)
### Bug Fixes
* [`abdd93d`](https://github.com/npm/node-semver/commit/abdd93d55496d22e3c15a454a5cf13f101e48bce) [#571](https://github.com/npm/node-semver/pull/571) set max lengths in regex for numeric and build identifiers (#571) (@lukekarrys)
### Documentation
* [`bf53dd8`](https://github.com/npm/node-semver/commit/bf53dd8da15a17eb6b8111115d0d8ef341fea5db) [#569](https://github.com/npm/node-semver/pull/569) add example for `>` comparator (#569) (@mbtools)
## [7.5.2](https://github.com/npm/node-semver/compare/v7.5.1...v7.5.2) (2023-06-15)
### Bug Fixes
* [`58c791f`](https://github.com/npm/node-semver/commit/58c791f40ba8cf4be35a5ca6644353ecd6249edc) [#566](https://github.com/npm/node-semver/pull/566) diff when detecting major change from prerelease (#566) (@lukekarrys)
* [`5c8efbc`](https://github.com/npm/node-semver/commit/5c8efbcb3c6c125af10746d054faff13e8c33fbd) [#565](https://github.com/npm/node-semver/pull/565) preserve build in raw after inc (#565) (@lukekarrys)
* [`717534e`](https://github.com/npm/node-semver/commit/717534ee353682f3bcf33e60a8af4292626d4441) [#564](https://github.com/npm/node-semver/pull/564) better handling of whitespace (#564) (@lukekarrys)
## [7.5.1](https://github.com/npm/node-semver/compare/v7.5.0...v7.5.1) (2023-05-12)
### Bug Fixes
* [`d30d25a`](https://github.com/npm/node-semver/commit/d30d25a5c1fb963c3cc9178cb1769fe45e4a3cab) [#559](https://github.com/npm/node-semver/pull/559) show type on invalid semver error (#559) (@tjenkinson)
## [7.5.0](https://github.com/npm/node-semver/compare/v7.4.0...v7.5.0) (2023-04-17)
### Features
* [`503a4e5`](https://github.com/npm/node-semver/commit/503a4e52fe2b1c6ed1400d33149f7733c8361eed) [#548](https://github.com/npm/node-semver/pull/548) allow identifierBase to be false (#548) (@lsvalina)
### Bug Fixes
* [`e219bb4`](https://github.com/npm/node-semver/commit/e219bb454036a0c23e34407591f921c8edb688e7) [#552](https://github.com/npm/node-semver/pull/552) throw on bad version with correct error message (#552) (@wraithgar)
* [`fc2f3df`](https://github.com/npm/node-semver/commit/fc2f3df0b5d25253b3580607e111a9a280d888ca) [#546](https://github.com/npm/node-semver/pull/546) incorrect results from diff sometimes with prerelease versions (#546) (@tjenkinson)
* [`2781767`](https://github.com/npm/node-semver/commit/27817677794f592b592bf6181a80a4824ff762b2) [#547](https://github.com/npm/node-semver/pull/547) avoid re-instantiating SemVer during diff compare (#547) (@macno)
## [7.4.0](https://github.com/npm/node-semver/compare/v7.3.8...v7.4.0) (2023-04-10)
### Features
* [`113f513`](https://github.com/npm/node-semver/commit/113f51312a1a6b6aa50d4f9486b4fde21782c1f5) [#532](https://github.com/npm/node-semver/pull/532) identifierBase parameter for .inc (#532) (@wraithgar, @b-bly)
* [`48d8f8f`](https://github.com/npm/node-semver/commit/48d8f8fa63bf6e35db70ff840b6da1a51596a5a8) [#530](https://github.com/npm/node-semver/pull/530) export new RELEASE_TYPES constant (@hcharley)
### Bug Fixes
* [`940723d`](https://github.com/npm/node-semver/commit/940723d22bca824993627c45ac30dd3d2854b8cd) [#538](https://github.com/npm/node-semver/pull/538) intersects with v0.0.0 and v0.0.0-0 (#538) (@wraithgar)
* [`aa516b5`](https://github.com/npm/node-semver/commit/aa516b50b32f5a144017d8fc1b9efe0540963c91) [#535](https://github.com/npm/node-semver/pull/535) faster parse options (#535) (@H4ad)
* [`61e6ea1`](https://github.com/npm/node-semver/commit/61e6ea1e9b7af01baf19ab0c0a63c8e3ebfac97c) [#536](https://github.com/npm/node-semver/pull/536) faster cache key factory for range (#536) (@H4ad)
* [`f8b8b61`](https://github.com/npm/node-semver/commit/f8b8b619e71746a47852a9d301f3087ab311444f) [#541](https://github.com/npm/node-semver/pull/541) optimistic parse (#541) (@H4ad)
* [`796cbe2`](https://github.com/npm/node-semver/commit/796cbe29b06d102e1b16f3ed78eaba210ece951e) [#533](https://github.com/npm/node-semver/pull/533) semver.diff prerelease to release recognition (#533) (@wraithgar, @dominique-blockchain)
* [`3f222b1`](https://github.com/npm/node-semver/commit/3f222b144033525ca9f8a2ce5bc6e02f0401881f) [#537](https://github.com/npm/node-semver/pull/537) reuse comparators on subset (#537) (@H4ad)
* [`f66cc45`](https://github.com/npm/node-semver/commit/f66cc45c6e82eebb4b5b51af73e7b8dcaeda7e21) [#539](https://github.com/npm/node-semver/pull/539) faster diff (#539) (@H4ad)
### Documentation
* [`c5d29df`](https://github.com/npm/node-semver/commit/c5d29df6f75741fea27fffe3b88c9c3b28e3ca73) [#530](https://github.com/npm/node-semver/pull/530) Add "Constants" section to README (@hcharley)
## [7.3.8](https://github.com/npm/node-semver/compare/v7.3.7...v7.3.8) (2022-10-04)
### Bug Fixes
* [`d8ef32c`](https://github.com/npm/node-semver/commit/d8ef32cee7a7e34310838f32451c9bcf52956b64) [#383](https://github.com/npm/node-semver/pull/383) add support for node.js esm auto exports (#383) (@MylesBorins)
### Documentation
* [`7209b14`](https://github.com/npm/node-semver/commit/7209b14ccd7ca35b9a1077a0b67d9ce884fe6d00) [#477](https://github.com/npm/node-semver/pull/477) update range.js comments to clarify the caret ranges examples (#477) (@amitse)
### [7.3.7](https://github.com/npm/node-semver/compare/v7.3.6...v7.3.7) (2022-04-11)
### Bug Fixes
* allow node >=10 ([85b269a](https://github.com/npm/node-semver/commit/85b269a90806713d2a41e8e990b0ea6bc274b171))
* **bin:** get correct value from arg separated by equals ([#449](https://github.com/npm/node-semver/issues/449)) ([4ceca76](https://github.com/npm/node-semver/commit/4ceca76729c577166395f19172854cbbcce3cec1)), closes [#431](https://github.com/npm/node-semver/issues/431)
* ensure SemVer instance passed to inc are not modified ([#427](https://github.com/npm/node-semver/issues/427)) ([f070dde](https://github.com/npm/node-semver/commit/f070dde0cc22894ac254e281cb36a79ab790272d))
* inc prerelease with numeric preid ([#380](https://github.com/npm/node-semver/issues/380)) ([802e161](https://github.com/npm/node-semver/commit/802e16174fe2a704dba16e97891ce36dc4f2ad76))
### Dependencies
* revert to lru-cache@6 ([22ae54d](https://github.com/npm/node-semver/commit/22ae54d66c2dec8200947066dbb9c33bb729b8a8))
### [7.3.6](https://github.com/npm/node-semver/compare/v7.3.5...v7.3.6) (2022-04-05)
### Bug Fixes
* https://github.com/npm/node-semver/issues/329 ([cb1ca1d](https://github.com/npm/node-semver/commit/cb1ca1d5480a6c07c12ac31ba5f2071ed530c4ed))
* properly escape dots in `GTE0` regexes ([#432](https://github.com/npm/node-semver/issues/432)) ([11494f1](https://github.com/npm/node-semver/commit/11494f1446a907c8fa5d9cfbc9fab04d553311f5))
* replace deprecated String.prototype.substr() ([#445](https://github.com/npm/node-semver/issues/445)) ([e2d55e7](https://github.com/npm/node-semver/commit/e2d55e79f0d288ea88c0e0ba6620fe5636a4a552))
* replace regex used to split ranges ([#434](https://github.com/npm/node-semver/issues/434)) ([9ab7b71](https://github.com/npm/node-semver/commit/9ab7b717dd7848c639b8ce3366d2241d430cdad2))
### Documentation
* clarify * range behavior ([cb1ca1d](https://github.com/npm/node-semver/commit/cb1ca1d5480a6c07c12ac31ba5f2071ed530c4ed))
### Dependencies
* lru-cache@7.4.0 ([#442](https://github.com/npm/node-semver/issues/442)) ([9a3064c](https://github.com/npm/node-semver/commit/9a3064c242cdce3c1c39cae37a83d93ead363b37))
* tap@16.0.0 ([#439](https://github.com/npm/node-semver/issues/439)) ([60cbb3f](https://github.com/npm/node-semver/commit/60cbb3fd4a4d32979f3aa0a2aa4e185753106545))
## 7.3.0
* Add `subset(r1, r2)` method to determine if `r1` range is entirely
contained by `r2` range.
## 7.2.3
* Fix handling of `includePrelease` mode where version ranges like `1.0.0 -
2.0.0` would include `3.0.0-pre` and not `1.0.0-pre`.
## 7.2.2
* Fix bug where `2.0.0-pre` would be included in `^1.0.0` if
`includePrerelease` was set to true.
## 7.2.0
* Add `simplifyRange` method to attempt to generate a more human-readable
range expression that is equivalent to a supplied range, for a given set
of versions.
## 7.1.2
* Remove fancy lazy-loading logic, as it was causing problems for webpack
users.
## 7.1.0
* Add `require('semver/preload')` to load the entire module without using
lazy getter methods.
## 7.0.0
* Refactor module into separate files for better tree-shaking
* Drop support for very old node versions, use const/let, `=>` functions,
and classes.
## 6.3.0
* Expose the token enum on the exports
## 6.2.0
* Coerce numbers to strings when passed to semver.coerce()
* Add `rtl` option to coerce from right to left
## 6.1.3
* Handle X-ranges properly in includePrerelease mode
## 6.1.2
* Do not throw when testing invalid version strings
## 6.1.1
* Add options support for semver.coerce()
* Handle undefined version passed to Range.test
## 6.1.0
* Add semver.compareBuild function
* Support `*` in semver.intersects
## 6.0
* Fix `intersects` logic.
This is technically a bug fix, but since it is also a change to behavior
that may require users updating their code, it is marked as a major
version increment.
## 5.7
* Add `minVersion` method
## 5.6
* Move boolean `loose` param to an options object, with
backwards-compatibility protection.
* Add ability to opt out of special prerelease version handling with
the `includePrerelease` option flag.
## 5.5
* Add version coercion capabilities
## 5.4
* Add intersection checking
## 5.3
* Add `minSatisfying` method
## 5.2
* Add `prerelease(v)` that returns prerelease components
## 5.1
* Add Backus-Naur for ranges
* Remove excessively cute inspection methods
## 5.0
* Remove AMD/Browserified build artifacts
* Fix ltr and gtr when using the `*` range
* Fix for range `*` with a prerelease identifier
npm-node-semver-5993c2e/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000000507 15141150374 0017675 0 ustar 00root root 0000000 0000000
All interactions in this repo are covered by the [npm Code of
Conduct](https://docs.npmjs.com/policies/conduct)
The npm cli team may, at its own discretion, moderate, remove, or edit
any interactions such as pull requests, issues, and comments.
npm-node-semver-5993c2e/CONTRIBUTING.md 0000664 0000000 0000000 00000005133 15141150374 0017327 0 ustar 00root root 0000000 0000000
# 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-node-semver-5993c2e/LICENSE 0000664 0000000 0000000 00000001375 15141150374 0016107 0 ustar 00root root 0000000 0000000 The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
npm-node-semver-5993c2e/README.md 0000664 0000000 0000000 00000060353 15141150374 0016362 0 ustar 00root root 0000000 0000000 semver(1) -- The semantic versioner for npm
===========================================
## Install
```bash
npm install semver
````
## Usage
As a node module:
```js
const semver = require('semver')
semver.valid('1.2.3') // '1.2.3'
semver.valid('a.b.c') // null
semver.clean(' =v1.2.3 ') // '1.2.3'
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
semver.gt('1.2.3', '9.8.7') // false
semver.lt('1.2.3', '9.8.7') // true
semver.minVersion('>=1.0.0') // '1.0.0'
semver.valid(semver.coerce('v2')) // '2.0.0'
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
```
You can also just load the module for the function that you care about if
you'd like to minimize your footprint.
```js
// load the whole API at once in a single object
const semver = require('semver')
// or just load the bits you need
// all of them listed here, just pick and choose what you want
// classes
const SemVer = require('semver/classes/semver')
const Comparator = require('semver/classes/comparator')
const Range = require('semver/classes/range')
// functions for working with versions
const semverParse = require('semver/functions/parse')
const semverValid = require('semver/functions/valid')
const semverClean = require('semver/functions/clean')
const semverInc = require('semver/functions/inc')
const semverDiff = require('semver/functions/diff')
const semverMajor = require('semver/functions/major')
const semverMinor = require('semver/functions/minor')
const semverPatch = require('semver/functions/patch')
const semverPrerelease = require('semver/functions/prerelease')
const semverCompare = require('semver/functions/compare')
const semverRcompare = require('semver/functions/rcompare')
const semverCompareLoose = require('semver/functions/compare-loose')
const semverCompareBuild = require('semver/functions/compare-build')
const semverSort = require('semver/functions/sort')
const semverRsort = require('semver/functions/rsort')
// low-level comparators between versions
const semverGt = require('semver/functions/gt')
const semverLt = require('semver/functions/lt')
const semverEq = require('semver/functions/eq')
const semverNeq = require('semver/functions/neq')
const semverGte = require('semver/functions/gte')
const semverLte = require('semver/functions/lte')
const semverCmp = require('semver/functions/cmp')
const semverCoerce = require('semver/functions/coerce')
// working with ranges
const semverSatisfies = require('semver/functions/satisfies')
const semverMaxSatisfying = require('semver/ranges/max-satisfying')
const semverMinSatisfying = require('semver/ranges/min-satisfying')
const semverToComparators = require('semver/ranges/to-comparators')
const semverMinVersion = require('semver/ranges/min-version')
const semverValidRange = require('semver/ranges/valid')
const semverOutside = require('semver/ranges/outside')
const semverGtr = require('semver/ranges/gtr')
const semverLtr = require('semver/ranges/ltr')
const semverIntersects = require('semver/ranges/intersects')
const semverSimplifyRange = require('semver/ranges/simplify')
const semverRangeSubset = require('semver/ranges/subset')
```
As a command-line utility:
```
$ semver -h
A JavaScript implementation of the https://semver.org/ specification
Copyright Isaac Z. Schlueter
Usage: semver [options] [ [...]]
Prints valid versions sorted by SemVer precedence
Options:
-r --range
Print versions that match the specified range.
-i --increment []
Increment a version by the specified level. Level can
be one of: major, minor, patch, premajor, preminor,
prepatch, prerelease, or release. Default level is 'patch'.
Only one version may be specified.
--preid
Identifier to be used to prefix premajor, preminor,
prepatch or prerelease version increments.
-l --loose
Interpret versions and ranges loosely
-n <0|1|false>
Base number for prerelease identifier (default: 0).
Use false to omit the number altogether.
-p --include-prerelease
Always include prerelease versions in range matching
-c --coerce
Coerce a string into SemVer if possible
(does not imply --loose)
--rtl
Coerce version strings right to left
--ltr
Coerce version strings left to right (default)
Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions.
If no satisfying versions are found, then exits failure.
Versions are printed in ascending order, so supplying
multiple versions to the utility will just sort them.
```
## Versions
A "version" is described by the `v2.0.0` specification found at
.
A leading `"="` or `"v"` character is stripped off and ignored.
Support for stripping a leading "v" is kept for compatibility with `v1.0.0` of the SemVer
specification but should not be used anymore.
## Ranges
A `version range` is a set of `comparators` that specify versions
that satisfy the range.
A `comparator` is composed of an `operator` and a `version`. The set
of primitive `operators` is:
* `<` Less than
* `<=` Less than or equal to
* `>` Greater than
* `>=` Greater than or equal to
* `=` Equal. If no operator is specified, then equality is assumed,
so this operator is optional but MAY be included.
For example, the comparator `>=1.2.7` would match the versions
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
or `1.1.0`. The comparator `>1` is equivalent to `>=2.0.0` and
would match the versions `2.0.0` and `3.1.0`, but not the versions
`1.0.1` or `1.1.0`.
Comparators can be joined by whitespace to form a `comparator set`,
which is satisfied by the **intersection** of all of the comparators
it includes.
A range is composed of one or more comparator sets, joined by `||`. A
version matches a range if and only if every comparator in at least
one of the `||`-separated comparator sets is satisfied by the version.
For example, the range `>=1.2.7 <1.3.0` would match the versions
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
or `1.1.0`.
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
### Prerelease Tags
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
it will only be allowed to satisfy comparator sets if at least one
comparator with the same `[major, minor, patch]` tuple also has a
prerelease tag.
For example, the range `>1.2.3-alpha.3` would be allowed to match the
version `1.2.3-alpha.7`, but it would *not* be satisfied by
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
range only accepts prerelease tags on the `1.2.3` version.
Version `3.4.5` *would* satisfy the range because it does not have a
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
The purpose of this behavior is twofold. First, prerelease versions
frequently are updated very quickly, and contain many breaking changes
that are (by the author's design) not yet fit for public consumption.
Therefore, by default, they are excluded from range-matching
semantics.
Second, a user who has opted into using a prerelease version has
indicated the intent to use *that specific* set of
alpha/beta/rc versions. By including a prerelease tag in the range,
the user is indicating that they are aware of the risk. However, it
is still not appropriate to assume that they have opted into taking a
similar risk on the *next* set of prerelease versions.
Note that this behavior can be suppressed (treating all prerelease
versions as if they were normal versions, for range-matching)
by setting the `includePrerelease` flag on the options
object to any
[functions](https://github.com/npm/node-semver#functions) that do
range matching.
#### Prerelease Identifiers
The method `.inc` takes an additional `identifier` string argument that
will append the value of the string as a prerelease identifier:
```javascript
semver.inc('1.2.3', 'prerelease', 'beta')
// '1.2.4-beta.0'
```
command-line example:
```bash
$ semver 1.2.3 -i prerelease --preid beta
1.2.4-beta.0
```
Which then can be used to increment further:
```bash
$ semver 1.2.4-beta.0 -i prerelease
1.2.4-beta.1
```
To get out of the prerelease phase, use the `release` option:
```bash
$ semver 1.2.4-beta.1 -i release
1.2.4
```
#### Prerelease Identifier Base
The method `.inc` takes an optional parameter 'identifierBase' string
that will let you let your prerelease number as zero-based or one-based.
Set to `false` to omit the prerelease number altogether.
If you do not specify this parameter, it will default to zero-based.
```javascript
semver.inc('1.2.3', 'prerelease', 'beta', '1')
// '1.2.4-beta.1'
```
```javascript
semver.inc('1.2.3', 'prerelease', 'beta', false)
// '1.2.4-beta'
```
command-line example:
```bash
$ semver 1.2.3 -i prerelease --preid beta -n 1
1.2.4-beta.1
```
```bash
$ semver 1.2.3 -i prerelease --preid beta -n false
1.2.4-beta
```
### Advanced Range Syntax
Advanced range syntax desugars to primitive comparators in
deterministic ways.
Advanced ranges may be combined in the same way as primitive
comparators using white space or `||`.
#### Hyphen Ranges `X.Y.Z - A.B.C`
Specifies an inclusive set.
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
If a partial version is provided as the first version in the inclusive
range, then the missing pieces are replaced with zeroes.
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
If a partial version is provided as the second version in the
inclusive range, then all versions that start with the supplied parts
of the tuple are accepted, but nothing that would be greater than the
provided tuple parts.
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0-0`
* `1.2.3 - 2` := `>=1.2.3 <3.0.0-0`
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
numeric values in the `[major, minor, patch]` tuple.
* `*` := `>=0.0.0` (Any non-prerelease version satisfies, unless
`includePrerelease` is specified, in which case any version at all
satisfies)
* `1.x` := `>=1.0.0 <2.0.0-0` (Matching major version)
* `1.2.x` := `>=1.2.0 <1.3.0-0` (Matching major and minor versions)
A partial version range is treated as an X-Range, so the special
character is in fact optional.
* `""` (empty string) := `*` := `>=0.0.0`
* `1` := `1.x.x` := `>=1.0.0 <2.0.0-0`
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0-0`
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
Allows patch-level changes if a minor version is specified on the
comparator. Allows minor-level changes if not.
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0-0`
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0-0` (Same as `1.2.x`)
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0-0` (Same as `1.x`)
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0-0`
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0-0` (Same as `0.2.x`)
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0-0` (Same as `0.x`)
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0-0` Note that prereleases in
the `1.2.3` version will be allowed, if they are greater than or
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
`1.2.4-beta.2` would not, because it is a prerelease of a
different `[major, minor, patch]` tuple.
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
Allows changes that do not modify the left-most non-zero element in the
`[major, minor, patch]` tuple. In other words, this allows patch and
minor updates for versions `1.0.0` and above, patch updates for
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
Many authors treat a `0.x` version as if the `x` were the major
"breaking-change" indicator.
Caret ranges are ideal when an author may make breaking changes
between `0.2.4` and `0.3.0` releases, which is a common practice.
However, it presumes that there will *not* be breaking changes between
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
additive (but non-breaking), according to commonly observed practices.
* `^1.2.3` := `>=1.2.3 <2.0.0-0`
* `^0.2.3` := `>=0.2.3 <0.3.0-0`
* `^0.0.3` := `>=0.0.3 <0.0.4-0`
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0-0` Note that prereleases in
the `1.2.3` version will be allowed, if they are greater than or
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
`1.2.4-beta.2` would not, because it is a prerelease of a
different `[major, minor, patch]` tuple.
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4-0` Note that prereleases in the
`0.0.3` version *only* will be allowed, if they are greater than or
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
When parsing caret ranges, a missing `patch` value desugars to the
number `0`, but will allow flexibility within that value, even if the
major and minor versions are both `0`.
* `^1.2.x` := `>=1.2.0 <2.0.0-0`
* `^0.0.x` := `>=0.0.0 <0.1.0-0`
* `^0.0` := `>=0.0.0 <0.1.0-0`
A missing `minor` and `patch` values will desugar to zero, but also
allow flexibility within those values, even if the major version is
zero.
* `^1.x` := `>=1.0.0 <2.0.0-0`
* `^0.x` := `>=0.0.0 <1.0.0-0`
### Range Grammar
Putting all this together, here is a Backus-Naur grammar for ranges,
for the benefit of parser authors:
```bnf
range-set ::= range ( logical-or range ) *
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
range ::= hyphen | simple ( ' ' simple ) * | ''
hyphen ::= partial ' - ' partial
simple ::= primitive | partial | tilde | caret
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
xr ::= 'x' | 'X' | '*' | nr
nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
tilde ::= '~' partial
caret ::= '^' partial
qualifier ::= ( '-' pre )? ( '+' build )?
pre ::= parts
build ::= parts
parts ::= part ( '.' part ) *
part ::= nr | [-0-9A-Za-z]+
```
## Functions
All methods and classes take a final `options` object argument. All
options in this object are `false` by default. The options supported
are:
- `loose`: Be more forgiving about not-quite-valid semver strings.
(Any resulting output will always be 100% strict compliant, of
course.) For backwards compatibility reasons, if the `options`
argument is a boolean value instead of an object, it is interpreted
to be the `loose` param.
- `includePrerelease`: Set to suppress the [default
behavior](https://github.com/npm/node-semver#prerelease-tags) of
excluding prerelease tagged versions from ranges unless they are
explicitly opted into.
Strict-mode Comparators and Ranges will be strict about the SemVer
strings that they parse.
* `valid(v)`: Return the parsed version, or null if it's not valid.
* `inc(v, releaseType, options, identifier, identifierBase)`:
Return the version incremented by the release
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
`prepatch`, `prerelease`, or `release`), or null if it's not valid
* `premajor` in one call will bump the version up to the next major
version and down to a prerelease of that major version.
`preminor`, and `prepatch` work the same way.
* If called from a non-prerelease version, `prerelease` will work the
same as `prepatch`. It increments the patch version and then makes a
prerelease. If the input version is already a prerelease it simply
increments it.
* `release` will remove any prerelease part of the version.
* `identifier` can be used to prefix `premajor`, `preminor`,
`prepatch`, or `prerelease` version increments. `identifierBase`
is the base to be used for the `prerelease` identifier.
* `prerelease(v)`: Returns an array of prerelease components, or null
if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]`
* `major(v)`: Return the major version number.
* `minor(v)`: Return the minor version number.
* `patch(v)`: Return the patch version number.
* `intersects(r1, r2, loose)`: Return true if the two supplied ranges
or comparators intersect.
* `parse(v)`: Attempt to parse a string as a semantic version, returning either
a `SemVer` object or `null`.
### Comparison
* `gt(v1, v2)`: `v1 > v2`
* `gte(v1, v2)`: `v1 >= v2`
* `lt(v1, v2)`: `v1 < v2`
* `lte(v1, v2)`: `v1 <= v2`
* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
even if they're not the same string. You already know how to
compare strings.
* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
the corresponding function above. `"==="` and `"!=="` do simple
string comparison, but are included for completeness. Throws if an
invalid comparison string is provided.
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
* `rcompare(v1, v2)`: The reverse of `compare`. Sorts an array of versions
in descending order when passed to `Array.sort()`.
* `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions
are equal. Sorts in ascending order if passed to `Array.sort()`.
* `compareLoose(v1, v2)`: Short for `compare(v1, v2, { loose: true })`.
* `diff(v1, v2)`: Returns the difference between two versions by the release type
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
or null if the versions are the same.
### Sorting
* `sort(versions)`: Returns a sorted array of versions based on the `compareBuild`
function.
* `rsort(versions)`: The reverse of `sort`. Returns an array of versions based on
the `compareBuild` function in descending order.
### Comparators
* `intersects(comparator)`: Return true if the comparators intersect
### Ranges
* `validRange(range)`: Return the valid range or null if it's not valid.
* `satisfies(version, range)`: Return true if the version satisfies the
range.
* `maxSatisfying(versions, range)`: Return the highest version in the list
that satisfies the range, or `null` if none of them do.
* `minSatisfying(versions, range)`: Return the lowest version in the list
that satisfies the range, or `null` if none of them do.
* `minVersion(range)`: Return the lowest version that can match
the given range.
* `gtr(version, range)`: Return `true` if the version is greater than all the
versions possible in the range.
* `ltr(version, range)`: Return `true` if the version is less than all the
versions possible in the range.
* `outside(version, range, hilo)`: Return true if the version is outside
the bounds of the range in either the high or low direction. The
`hilo` argument must be either the string `'>'` or `'<'`. (This is
the function called by `gtr` and `ltr`.)
* `intersects(range)`: Return true if any of the range comparators intersect.
* `simplifyRange(versions, range)`: Return a "simplified" range that
matches the same items in the `versions` list as the range specified. Note
that it does *not* guarantee that it would match the same versions in all
cases, only for the set of versions provided. This is useful when
generating ranges by joining together multiple versions with `||`
programmatically, to provide the user with something a bit more
ergonomic. If the provided range is shorter in string-length than the
generated range, then that is returned.
* `subset(subRange, superRange)`: Return `true` if the `subRange` range is
entirely contained by the `superRange` range.
Note that, since ranges may be non-contiguous, a version might not be
greater than a range, less than a range, *or* satisfy a range! For
example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
until `2.0.0`, so version `1.2.10` would not be greater than the
range (because `2.0.1` satisfies, which is higher), nor less than the
range (since `1.2.8` satisfies, which is lower), and it also does not
satisfy the range.
If you want to know if a version satisfies or does not satisfy a
range, use the `satisfies(version, range)` function.
### Coercion
* `coerce(version, options)`: Coerces a string to semver if possible
This aims to provide a very forgiving translation of a non-semver string to
semver. It looks for the first digit in a string and consumes all
remaining characters which satisfy at least a partial semver (e.g., `1`,
`1.2`, `1.2.3`) up to the max permitted length (256 characters). Longer
versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). All
surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes
`3.4.0`). Only text which lacks digits will fail coercion (`version one`
is not valid). The maximum length for any semver component considered for
coercion is 16 characters; longer components will be ignored
(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any
semver component is `Number.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
components are invalid (`9999999999999999.4.7.4` is likely invalid).
If the `options.rtl` flag is set, then `coerce` will return the right-most
coercible tuple that does not share an ending index with a longer coercible
tuple. For example, `1.2.3.4` will return `2.3.4` in rtl mode, not
`4.0.0`. `1.2.3/4` will return `4.0.0`, because the `4` is not a part of
any other overlapping SemVer tuple.
If the `options.includePrerelease` flag is set, then the `coerce` result will contain
prerelease and build parts of a version. For example, `1.2.3.4-rc.1+rev.2`
will preserve prerelease `rc.1` and build `rev.2` in the result.
### Clean
* `clean(version)`: Clean a string to be a valid semver if possible
This will return a cleaned and trimmed semver version. If the provided
version is not valid a null will be returned. This does not work for
ranges.
ex.
* `s.clean(' = v 2.1.5foo')`: `null`
* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'`
* `s.clean(' = v 2.1.5-foo')`: `null`
* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'`
* `s.clean('=v2.1.5')`: `'2.1.5'`
* `s.clean(' =v2.1.5')`: `'2.1.5'`
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
* `s.clean('~1.0.0')`: `null`
## Constants
As a convenience, helper constants are exported to provide information about what `node-semver` supports:
### `RELEASE_TYPES`
- major
- premajor
- minor
- preminor
- patch
- prepatch
- prerelease
```
const semver = require('semver');
if (semver.RELEASE_TYPES.includes(arbitraryUserInput)) {
console.log('This is a valid release type!');
} else {
console.warn('This is NOT a valid release type!');
}
```
### `SEMVER_SPEC_VERSION`
2.0.0
```
const semver = require('semver');
console.log('We are currently using the semver specification version:', semver.SEMVER_SPEC_VERSION);
```
## Exported Modules
You may pull in just the part of this semver utility that you need if you
are sensitive to packing and tree-shaking concerns. The main
`require('semver')` export uses getter functions to lazily load the parts
of the API that are used.
The following modules are available:
* `require('semver')`
* `require('semver/classes')`
* `require('semver/classes/comparator')`
* `require('semver/classes/range')`
* `require('semver/classes/semver')`
* `require('semver/functions/clean')`
* `require('semver/functions/cmp')`
* `require('semver/functions/coerce')`
* `require('semver/functions/compare')`
* `require('semver/functions/compare-build')`
* `require('semver/functions/compare-loose')`
* `require('semver/functions/diff')`
* `require('semver/functions/eq')`
* `require('semver/functions/gt')`
* `require('semver/functions/gte')`
* `require('semver/functions/inc')`
* `require('semver/functions/lt')`
* `require('semver/functions/lte')`
* `require('semver/functions/major')`
* `require('semver/functions/minor')`
* `require('semver/functions/neq')`
* `require('semver/functions/parse')`
* `require('semver/functions/patch')`
* `require('semver/functions/prerelease')`
* `require('semver/functions/rcompare')`
* `require('semver/functions/rsort')`
* `require('semver/functions/satisfies')`
* `require('semver/functions/sort')`
* `require('semver/functions/valid')`
* `require('semver/ranges/gtr')`
* `require('semver/ranges/intersects')`
* `require('semver/ranges/ltr')`
* `require('semver/ranges/max-satisfying')`
* `require('semver/ranges/min-satisfying')`
* `require('semver/ranges/min-version')`
* `require('semver/ranges/outside')`
* `require('semver/ranges/simplify')`
* `require('semver/ranges/subset')`
* `require('semver/ranges/to-comparators')`
* `require('semver/ranges/valid')`
npm-node-semver-5993c2e/SECURITY.md 0000664 0000000 0000000 00000002320 15141150374 0016662 0 ustar 00root root 0000000 0000000
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-node-semver-5993c2e/benchmarks/ 0000775 0000000 0000000 00000000000 15141150374 0017211 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/benchmarks/bench-compare.js 0000664 0000000 0000000 00000000712 15141150374 0022252 0 ustar 00root root 0000000 0000000 'use strict'
const Benchmark = require('benchmark')
const SemVer = require('../classes/semver')
const suite = new Benchmark.Suite()
const comparisons = require('../test/fixtures/comparisons')
for (const [v0, v1] of comparisons) {
suite.add(`compare ${v0} to ${v1}`, function () {
const semver = new SemVer(v0)
semver.compare(v1)
})
}
suite
.on('cycle', function (event) {
console.log(String(event.target))
})
.run({ async: false })
npm-node-semver-5993c2e/benchmarks/bench-diff.js 0000664 0000000 0000000 00000000727 15141150374 0021542 0 ustar 00root root 0000000 0000000 'use strict'
const Benchmark = require('benchmark')
const diff = require('../functions/diff')
const suite = new Benchmark.Suite()
const cases = [
['0.0.1', '0.0.1-pre', 'patch'],
['0.0.1', '0.0.1-pre-2', 'patch'],
['1.1.0', '1.1.0-pre', 'minor'],
]
for (const [v1, v2] of cases) {
suite.add(`diff(${v1}, ${v2})`, function () {
diff(v1, v2)
})
}
suite
.on('cycle', function (event) {
console.log(String(event.target))
})
.run({ async: false })
npm-node-semver-5993c2e/benchmarks/bench-parse-options.js 0000664 0000000 0000000 00000001263 15141150374 0023431 0 ustar 00root root 0000000 0000000 'use strict'
const Benchmark = require('benchmark')
const parseOptions = require('../internal/parse-options')
const suite = new Benchmark.Suite()
const options1 = {
includePrerelease: true,
}
const options2 = {
includePrerelease: true,
loose: true,
}
const options3 = {
includePrerelease: true,
loose: true,
rtl: false,
}
suite
.add('includePrerelease', function () {
parseOptions(options1)
})
.add('includePrerelease + loose', function () {
parseOptions(options2)
})
.add('includePrerelease + loose + rtl', function () {
parseOptions(options3)
})
.on('cycle', function (event) {
console.log(String(event.target))
})
.run({ async: false })
npm-node-semver-5993c2e/benchmarks/bench-parse.js 0000664 0000000 0000000 00000001111 15141150374 0021730 0 ustar 00root root 0000000 0000000 'use strict'
const Benchmark = require('benchmark')
const parse = require('../functions/parse')
const suite = new Benchmark.Suite()
const cases = require(`../test/fixtures/valid-versions`)
const invalidCases = require(`../test/fixtures/invalid-versions`)
for (const test of cases) {
suite.add(`parse(${test[0]})`, function () {
parse(test[0])
})
}
for (const test of invalidCases) {
suite.add(`invalid parse(${test[0]})`, function () {
parse(test[0])
})
}
suite
.on('cycle', function (event) {
console.log(String(event.target))
})
.run({ async: false })
npm-node-semver-5993c2e/benchmarks/bench-satisfies.js 0000664 0000000 0000000 00000002337 15141150374 0022623 0 ustar 00root root 0000000 0000000 'use strict'
const Benchmark = require('benchmark')
const satisfies = require('../functions/satisfies')
const suite = new Benchmark.Suite()
const versions = ['1.0.3||^2.0.0', '2.2.2||~3.0.0', '2.3.0||<4.0.0']
const versionToCompare = '1.0.6'
const option1 = { includePrelease: true }
const option2 = { includePrelease: true, loose: true }
const option3 = { includePrelease: true, loose: true, rtl: true }
for (const version of versions) {
suite.add(`satisfies(${versionToCompare}, ${version})`, function () {
satisfies(versionToCompare, version)
})
}
for (const version of versions) {
suite.add(`satisfies(${versionToCompare}, ${version}, ${JSON.stringify(option1)})`, function () {
satisfies(versionToCompare, version, option1)
})
}
for (const version of versions) {
suite.add(`satisfies(${versionToCompare}, ${version}, ${JSON.stringify(option2)})`, function () {
satisfies(versionToCompare, version, option2)
})
}
for (const version of versions) {
suite.add(`satisfies(${versionToCompare}, ${version}, ${JSON.stringify(option3)})`, function () {
satisfies(versionToCompare, version, option3)
})
}
suite
.on('cycle', function (event) {
console.log(String(event.target))
})
.run({ async: false })
npm-node-semver-5993c2e/benchmarks/bench-subset.js 0000664 0000000 0000000 00000001127 15141150374 0022132 0 ustar 00root root 0000000 0000000 'use strict'
const Benchmark = require('benchmark')
const subset = require('../ranges/subset')
const suite = new Benchmark.Suite()
// taken from tests
const cases = [
// everything is a subset of *
['1.2.3', '*', true],
['^1.2.3', '*', true],
['^1.2.3-pre.0', '*', false],
['^1.2.3-pre.0', '*', true, { includePrerelease: true }],
['1 || 2 || 3', '*', true],
]
for (const [sub, dom] of cases) {
suite.add(`subset(${sub}, ${dom})`, function () {
subset(sub, dom)
})
}
suite
.on('cycle', function (event) {
console.log(String(event.target))
})
.run({ async: false })
npm-node-semver-5993c2e/bin/ 0000775 0000000 0000000 00000000000 15141150374 0015644 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/bin/semver.js 0000775 0000000 0000000 00000011214 15141150374 0017505 0 ustar 00root root 0000000 0000000 #!/usr/bin/env node
// Standalone semver comparison program.
// Exits successfully and prints matching version(s) if
// any supplied version is valid and passes all tests.
'use strict'
const argv = process.argv.slice(2)
let versions = []
const range = []
let inc = null
const version = require('../package.json').version
let loose = false
let includePrerelease = false
let coerce = false
let rtl = false
let identifier
let identifierBase
const semver = require('../')
const parseOptions = require('../internal/parse-options')
let reverse = false
let options = {}
const main = () => {
if (!argv.length) {
return help()
}
while (argv.length) {
let a = argv.shift()
const indexOfEqualSign = a.indexOf('=')
if (indexOfEqualSign !== -1) {
const value = a.slice(indexOfEqualSign + 1)
a = a.slice(0, indexOfEqualSign)
argv.unshift(value)
}
switch (a) {
case '-rv': case '-rev': case '--rev': case '--reverse':
reverse = true
break
case '-l': case '--loose':
loose = true
break
case '-p': case '--include-prerelease':
includePrerelease = true
break
case '-v': case '--version':
versions.push(argv.shift())
break
case '-i': case '--inc': case '--increment':
switch (argv[0]) {
case 'major': case 'minor': case 'patch': case 'prerelease':
case 'premajor': case 'preminor': case 'prepatch':
case 'release':
inc = argv.shift()
break
default:
inc = 'patch'
break
}
break
case '--preid':
identifier = argv.shift()
break
case '-r': case '--range':
range.push(argv.shift())
break
case '-n':
identifierBase = argv.shift()
if (identifierBase === 'false') {
identifierBase = false
}
break
case '-c': case '--coerce':
coerce = true
break
case '--rtl':
rtl = true
break
case '--ltr':
rtl = false
break
case '-h': case '--help': case '-?':
return help()
default:
versions.push(a)
break
}
}
options = parseOptions({ loose, includePrerelease, rtl })
versions = versions.map((v) => {
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
}).filter((v) => {
return semver.valid(v, options)
})
if (!versions.length) {
return fail()
}
if (inc && (versions.length !== 1 || range.length)) {
return failInc()
}
for (let i = 0, l = range.length; i < l; i++) {
versions = versions.filter((v) => {
return semver.satisfies(v, range[i], options)
})
if (!versions.length) {
return fail()
}
}
versions
.sort((a, b) => semver[reverse ? 'rcompare' : 'compare'](a, b, options))
.map(v => semver.clean(v, options))
.map(v => inc ? semver.inc(v, inc, options, identifier, identifierBase) : v)
.forEach(v => console.log(v))
}
const failInc = () => {
console.error('--inc can only be used on a single version with no range')
fail()
}
const fail = () => process.exit(1)
const help = () => console.log(
`SemVer ${version}
A JavaScript implementation of the https://semver.org/ specification
Copyright Isaac Z. Schlueter
Usage: semver [options] [ [...]]
Prints valid versions sorted by SemVer precedence
Options:
-r --range
Print versions that match the specified range.
-i --increment []
Increment a version by the specified level. Level can
be one of: major, minor, patch, premajor, preminor,
prepatch, prerelease, or release. Default level is 'patch'.
Only one version may be specified.
--preid
Identifier to be used to prefix premajor, preminor,
prepatch or prerelease version increments.
-l --loose
Interpret versions and ranges loosely
-p --include-prerelease
Always include prerelease versions in range matching
-c --coerce
Coerce a string into SemVer if possible
(does not imply --loose)
--rtl
Coerce version strings right to left
--ltr
Coerce version strings left to right (default)
-n
Base number to be used for the prerelease identifier.
Can be either 0 or 1, or false to omit the number altogether.
Defaults to 0.
Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions.
If no satisfying versions are found, then exits failure.
Versions are printed in ascending order, so supplying
multiple versions to the utility will just sort them.`)
main()
npm-node-semver-5993c2e/classes/ 0000775 0000000 0000000 00000000000 15141150374 0016531 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/classes/comparator.js 0000664 0000000 0000000 00000007057 15141150374 0021247 0 ustar 00root root 0000000 0000000 'use strict'
const ANY = Symbol('SemVer ANY')
// hoisted class for cyclic dependency
class Comparator {
static get ANY () {
return ANY
}
constructor (comp, options) {
options = parseOptions(options)
if (comp instanceof Comparator) {
if (comp.loose === !!options.loose) {
return comp
} else {
comp = comp.value
}
}
comp = comp.trim().split(/\s+/).join(' ')
debug('comparator', comp, options)
this.options = options
this.loose = !!options.loose
this.parse(comp)
if (this.semver === ANY) {
this.value = ''
} else {
this.value = this.operator + this.semver.version
}
debug('comp', this)
}
parse (comp) {
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
const m = comp.match(r)
if (!m) {
throw new TypeError(`Invalid comparator: ${comp}`)
}
this.operator = m[1] !== undefined ? m[1] : ''
if (this.operator === '=') {
this.operator = ''
}
// if it literally is just '>' or '' then allow anything.
if (!m[2]) {
this.semver = ANY
} else {
this.semver = new SemVer(m[2], this.options.loose)
}
}
toString () {
return this.value
}
test (version) {
debug('Comparator.test', version, this.options.loose)
if (this.semver === ANY || version === ANY) {
return true
}
if (typeof version === 'string') {
try {
version = new SemVer(version, this.options)
} catch (er) {
return false
}
}
return cmp(version, this.operator, this.semver, this.options)
}
intersects (comp, options) {
if (!(comp instanceof Comparator)) {
throw new TypeError('a Comparator is required')
}
if (this.operator === '') {
if (this.value === '') {
return true
}
return new Range(comp.value, options).test(this.value)
} else if (comp.operator === '') {
if (comp.value === '') {
return true
}
return new Range(this.value, options).test(comp.semver)
}
options = parseOptions(options)
// Special cases where nothing can possibly be lower
if (options.includePrerelease &&
(this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {
return false
}
if (!options.includePrerelease &&
(this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {
return false
}
// Same direction increasing (> or >=)
if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {
return true
}
// Same direction decreasing (< or <=)
if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {
return true
}
// same SemVer and both sides are inclusive (<= or >=)
if (
(this.semver.version === comp.semver.version) &&
this.operator.includes('=') && comp.operator.includes('=')) {
return true
}
// opposite directions less than
if (cmp(this.semver, '<', comp.semver, options) &&
this.operator.startsWith('>') && comp.operator.startsWith('<')) {
return true
}
// opposite directions greater than
if (cmp(this.semver, '>', comp.semver, options) &&
this.operator.startsWith('<') && comp.operator.startsWith('>')) {
return true
}
return false
}
}
module.exports = Comparator
const parseOptions = require('../internal/parse-options')
const { safeRe: re, t } = require('../internal/re')
const cmp = require('../functions/cmp')
const debug = require('../internal/debug')
const SemVer = require('./semver')
const Range = require('./range')
npm-node-semver-5993c2e/classes/index.js 0000664 0000000 0000000 00000000217 15141150374 0020176 0 ustar 00root root 0000000 0000000 'use strict'
module.exports = {
SemVer: require('./semver.js'),
Range: require('./range.js'),
Comparator: require('./comparator.js'),
}
npm-node-semver-5993c2e/classes/range.js 0000664 0000000 0000000 00000035201 15141150374 0020164 0 ustar 00root root 0000000 0000000 'use strict'
const SPACE_CHARACTERS = /\s+/g
// hoisted class for cyclic dependency
class Range {
constructor (range, options) {
options = parseOptions(options)
if (range instanceof Range) {
if (
range.loose === !!options.loose &&
range.includePrerelease === !!options.includePrerelease
) {
return range
} else {
return new Range(range.raw, options)
}
}
if (range instanceof Comparator) {
// just put it in the set and return
this.raw = range.value
this.set = [[range]]
this.formatted = undefined
return this
}
this.options = options
this.loose = !!options.loose
this.includePrerelease = !!options.includePrerelease
// First reduce all whitespace as much as possible so we do not have to rely
// on potentially slow regexes like \s*. This is then stored and used for
// future error messages as well.
this.raw = range.trim().replace(SPACE_CHARACTERS, ' ')
// First, split on ||
this.set = this.raw
.split('||')
// map the range to a 2d array of comparators
.map(r => this.parseRange(r.trim()))
// throw out any comparator lists that are empty
// this generally means that it was not a valid range, which is allowed
// in loose mode, but will still throw if the WHOLE range is invalid.
.filter(c => c.length)
if (!this.set.length) {
throw new TypeError(`Invalid SemVer Range: ${this.raw}`)
}
// if we have any that are not the null set, throw out null sets.
if (this.set.length > 1) {
// keep the first one, in case they're all null sets
const first = this.set[0]
this.set = this.set.filter(c => !isNullSet(c[0]))
if (this.set.length === 0) {
this.set = [first]
} else if (this.set.length > 1) {
// if we have any that are *, then the range is just *
for (const c of this.set) {
if (c.length === 1 && isAny(c[0])) {
this.set = [c]
break
}
}
}
}
this.formatted = undefined
}
get range () {
if (this.formatted === undefined) {
this.formatted = ''
for (let i = 0; i < this.set.length; i++) {
if (i > 0) {
this.formatted += '||'
}
const comps = this.set[i]
for (let k = 0; k < comps.length; k++) {
if (k > 0) {
this.formatted += ' '
}
this.formatted += comps[k].toString().trim()
}
}
}
return this.formatted
}
format () {
return this.range
}
toString () {
return this.range
}
parseRange (range) {
// memoize range parsing for performance.
// this is a very hot path, and fully deterministic.
const memoOpts =
(this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |
(this.options.loose && FLAG_LOOSE)
const memoKey = memoOpts + ':' + range
const cached = cache.get(memoKey)
if (cached) {
return cached
}
const loose = this.options.loose
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
range = range.replace(hr, hyphenReplace(this.options.includePrerelease))
debug('hyphen replace', range)
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
debug('comparator trim', range)
// `~ 1.2.3` => `~1.2.3`
range = range.replace(re[t.TILDETRIM], tildeTrimReplace)
debug('tilde trim', range)
// `^ 1.2.3` => `^1.2.3`
range = range.replace(re[t.CARETTRIM], caretTrimReplace)
debug('caret trim', range)
// At this point, the range is completely trimmed and
// ready to be split into comparators.
let rangeList = range
.split(' ')
.map(comp => parseComparator(comp, this.options))
.join(' ')
.split(/\s+/)
// >=0.0.0 is equivalent to *
.map(comp => replaceGTE0(comp, this.options))
if (loose) {
// in loose mode, throw out any that are not valid comparators
rangeList = rangeList.filter(comp => {
debug('loose invalid filter', comp, this.options)
return !!comp.match(re[t.COMPARATORLOOSE])
})
}
debug('range list', rangeList)
// if any comparators are the null set, then replace with JUST null set
// if more than one comparator, remove any * comparators
// also, don't include the same comparator more than once
const rangeMap = new Map()
const comparators = rangeList.map(comp => new Comparator(comp, this.options))
for (const comp of comparators) {
if (isNullSet(comp)) {
return [comp]
}
rangeMap.set(comp.value, comp)
}
if (rangeMap.size > 1 && rangeMap.has('')) {
rangeMap.delete('')
}
const result = [...rangeMap.values()]
cache.set(memoKey, result)
return result
}
intersects (range, options) {
if (!(range instanceof Range)) {
throw new TypeError('a Range is required')
}
return this.set.some((thisComparators) => {
return (
isSatisfiable(thisComparators, options) &&
range.set.some((rangeComparators) => {
return (
isSatisfiable(rangeComparators, options) &&
thisComparators.every((thisComparator) => {
return rangeComparators.every((rangeComparator) => {
return thisComparator.intersects(rangeComparator, options)
})
})
)
})
)
})
}
// if ANY of the sets match ALL of its comparators, then pass
test (version) {
if (!version) {
return false
}
if (typeof version === 'string') {
try {
version = new SemVer(version, this.options)
} catch (er) {
return false
}
}
for (let i = 0; i < this.set.length; i++) {
if (testSet(this.set[i], version, this.options)) {
return true
}
}
return false
}
}
module.exports = Range
const LRU = require('../internal/lrucache')
const cache = new LRU()
const parseOptions = require('../internal/parse-options')
const Comparator = require('./comparator')
const debug = require('../internal/debug')
const SemVer = require('./semver')
const {
safeRe: re,
t,
comparatorTrimReplace,
tildeTrimReplace,
caretTrimReplace,
} = require('../internal/re')
const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require('../internal/constants')
const isNullSet = c => c.value === '<0.0.0-0'
const isAny = c => c.value === ''
// take a set of comparators and determine whether there
// exists a version which can satisfy it
const isSatisfiable = (comparators, options) => {
let result = true
const remainingComparators = comparators.slice()
let testComparator = remainingComparators.pop()
while (result && remainingComparators.length) {
result = remainingComparators.every((otherComparator) => {
return testComparator.intersects(otherComparator, options)
})
testComparator = remainingComparators.pop()
}
return result
}
// comprised of xranges, tildes, stars, and gtlt's at this point.
// already replaced the hyphen ranges
// turn into a set of JUST comparators.
const parseComparator = (comp, options) => {
comp = comp.replace(re[t.BUILD], '')
debug('comp', comp, options)
comp = replaceCarets(comp, options)
debug('caret', comp)
comp = replaceTildes(comp, options)
debug('tildes', comp)
comp = replaceXRanges(comp, options)
debug('xrange', comp)
comp = replaceStars(comp, options)
debug('stars', comp)
return comp
}
const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
// ~, ~> --> * (any, kinda silly)
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
// ~0.0.1 --> >=0.0.1 <0.1.0-0
const replaceTildes = (comp, options) => {
return comp
.trim()
.split(/\s+/)
.map((c) => replaceTilde(c, options))
.join(' ')
}
const replaceTilde = (comp, options) => {
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
return comp.replace(r, (_, M, m, p, pr) => {
debug('tilde', comp, _, M, m, p, pr)
let ret
if (isX(M)) {
ret = ''
} else if (isX(m)) {
ret = `>=${M}.0.0 <${+M + 1}.0.0-0`
} else if (isX(p)) {
// ~1.2 == >=1.2.0 <1.3.0-0
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`
} else if (pr) {
debug('replaceTilde pr', pr)
ret = `>=${M}.${m}.${p}-${pr
} <${M}.${+m + 1}.0-0`
} else {
// ~1.2.3 == >=1.2.3 <1.3.0-0
ret = `>=${M}.${m}.${p
} <${M}.${+m + 1}.0-0`
}
debug('tilde return', ret)
return ret
})
}
// ^ --> * (any, kinda silly)
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
// ^1.2.3 --> >=1.2.3 <2.0.0-0
// ^1.2.0 --> >=1.2.0 <2.0.0-0
// ^0.0.1 --> >=0.0.1 <0.0.2-0
// ^0.1.0 --> >=0.1.0 <0.2.0-0
const replaceCarets = (comp, options) => {
return comp
.trim()
.split(/\s+/)
.map((c) => replaceCaret(c, options))
.join(' ')
}
const replaceCaret = (comp, options) => {
debug('caret', comp, options)
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]
const z = options.includePrerelease ? '-0' : ''
return comp.replace(r, (_, M, m, p, pr) => {
debug('caret', comp, _, M, m, p, pr)
let ret
if (isX(M)) {
ret = ''
} else if (isX(m)) {
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`
} else if (isX(p)) {
if (M === '0') {
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`
} else {
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`
}
} else if (pr) {
debug('replaceCaret pr', pr)
if (M === '0') {
if (m === '0') {
ret = `>=${M}.${m}.${p}-${pr
} <${M}.${m}.${+p + 1}-0`
} else {
ret = `>=${M}.${m}.${p}-${pr
} <${M}.${+m + 1}.0-0`
}
} else {
ret = `>=${M}.${m}.${p}-${pr
} <${+M + 1}.0.0-0`
}
} else {
debug('no pr')
if (M === '0') {
if (m === '0') {
ret = `>=${M}.${m}.${p
}${z} <${M}.${m}.${+p + 1}-0`
} else {
ret = `>=${M}.${m}.${p
}${z} <${M}.${+m + 1}.0-0`
}
} else {
ret = `>=${M}.${m}.${p
} <${+M + 1}.0.0-0`
}
}
debug('caret return', ret)
return ret
})
}
const replaceXRanges = (comp, options) => {
debug('replaceXRanges', comp, options)
return comp
.split(/\s+/)
.map((c) => replaceXRange(c, options))
.join(' ')
}
const replaceXRange = (comp, options) => {
comp = comp.trim()
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
debug('xRange', comp, ret, gtlt, M, m, p, pr)
const xM = isX(M)
const xm = xM || isX(m)
const xp = xm || isX(p)
const anyX = xp
if (gtlt === '=' && anyX) {
gtlt = ''
}
// if we're including prereleases in the match, then we need
// to fix this to -0, the lowest possible prerelease value
pr = options.includePrerelease ? '-0' : ''
if (xM) {
if (gtlt === '>' || gtlt === '<') {
// nothing is allowed
ret = '<0.0.0-0'
} else {
// nothing is forbidden
ret = '*'
}
} else if (gtlt && anyX) {
// we know patch is an x, because we have any x at all.
// replace X with 0
if (xm) {
m = 0
}
p = 0
if (gtlt === '>') {
// >1 => >=2.0.0
// >1.2 => >=1.3.0
gtlt = '>='
if (xm) {
M = +M + 1
m = 0
p = 0
} else {
m = +m + 1
p = 0
}
} else if (gtlt === '<=') {
// <=0.7.x is actually <0.8.0, since any 0.7.x should
// pass. Similarly, <=7.x is actually <8.0.0, etc.
gtlt = '<'
if (xm) {
M = +M + 1
} else {
m = +m + 1
}
}
if (gtlt === '<') {
pr = '-0'
}
ret = `${gtlt + M}.${m}.${p}${pr}`
} else if (xm) {
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`
} else if (xp) {
ret = `>=${M}.${m}.0${pr
} <${M}.${+m + 1}.0-0`
}
debug('xRange return', ret)
return ret
})
}
// Because * is AND-ed with everything else in the comparator,
// and '' means "any version", just remove the *s entirely.
const replaceStars = (comp, options) => {
debug('replaceStars', comp, options)
// Looseness is ignored here. star is always as loose as it gets!
return comp
.trim()
.replace(re[t.STAR], '')
}
const replaceGTE0 = (comp, options) => {
debug('replaceGTE0', comp, options)
return comp
.trim()
.replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
}
// This function is passed to string.replace(re[t.HYPHENRANGE])
// M, m, patch, prerelease, build
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
// 1.2 - 3.4 => >=1.2.0 <3.5.0-0
// TODO build?
const hyphenReplace = incPr => ($0,
from, fM, fm, fp, fpr, fb,
to, tM, tm, tp, tpr) => {
if (isX(fM)) {
from = ''
} else if (isX(fm)) {
from = `>=${fM}.0.0${incPr ? '-0' : ''}`
} else if (isX(fp)) {
from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`
} else if (fpr) {
from = `>=${from}`
} else {
from = `>=${from}${incPr ? '-0' : ''}`
}
if (isX(tM)) {
to = ''
} else if (isX(tm)) {
to = `<${+tM + 1}.0.0-0`
} else if (isX(tp)) {
to = `<${tM}.${+tm + 1}.0-0`
} else if (tpr) {
to = `<=${tM}.${tm}.${tp}-${tpr}`
} else if (incPr) {
to = `<${tM}.${tm}.${+tp + 1}-0`
} else {
to = `<=${to}`
}
return `${from} ${to}`.trim()
}
const testSet = (set, version, options) => {
for (let i = 0; i < set.length; i++) {
if (!set[i].test(version)) {
return false
}
}
if (version.prerelease.length && !options.includePrerelease) {
// Find the set of versions that are allowed to have prereleases
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
// That should allow `1.2.3-pr.2` to pass.
// However, `1.2.4-alpha.notready` should NOT be allowed,
// even though it's within the range set by the comparators.
for (let i = 0; i < set.length; i++) {
debug(set[i].semver)
if (set[i].semver === Comparator.ANY) {
continue
}
if (set[i].semver.prerelease.length > 0) {
const allowed = set[i].semver
if (allowed.major === version.major &&
allowed.minor === version.minor &&
allowed.patch === version.patch) {
return true
}
}
}
// Version has a -pre, but it's not one of the ones we like.
return false
}
return true
}
npm-node-semver-5993c2e/classes/semver.js 0000664 0000000 0000000 00000022410 15141150374 0020367 0 ustar 00root root 0000000 0000000 'use strict'
const debug = require('../internal/debug')
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
const { safeRe: re, t } = require('../internal/re')
const parseOptions = require('../internal/parse-options')
const { compareIdentifiers } = require('../internal/identifiers')
class SemVer {
constructor (version, options) {
options = parseOptions(options)
if (version instanceof SemVer) {
if (version.loose === !!options.loose &&
version.includePrerelease === !!options.includePrerelease) {
return version
} else {
version = version.version
}
} else if (typeof version !== 'string') {
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
}
if (version.length > MAX_LENGTH) {
throw new TypeError(
`version is longer than ${MAX_LENGTH} characters`
)
}
debug('SemVer', version, options)
this.options = options
this.loose = !!options.loose
// this isn't actually relevant for versions, but keep it so that we
// don't run into trouble passing this.options around.
this.includePrerelease = !!options.includePrerelease
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])
if (!m) {
throw new TypeError(`Invalid Version: ${version}`)
}
this.raw = version
// these are actually numbers
this.major = +m[1]
this.minor = +m[2]
this.patch = +m[3]
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
throw new TypeError('Invalid major version')
}
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
throw new TypeError('Invalid minor version')
}
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
throw new TypeError('Invalid patch version')
}
// numberify any prerelease numeric ids
if (!m[4]) {
this.prerelease = []
} else {
this.prerelease = m[4].split('.').map((id) => {
if (/^[0-9]+$/.test(id)) {
const num = +id
if (num >= 0 && num < MAX_SAFE_INTEGER) {
return num
}
}
return id
})
}
this.build = m[5] ? m[5].split('.') : []
this.format()
}
format () {
this.version = `${this.major}.${this.minor}.${this.patch}`
if (this.prerelease.length) {
this.version += `-${this.prerelease.join('.')}`
}
return this.version
}
toString () {
return this.version
}
compare (other) {
debug('SemVer.compare', this.version, this.options, other)
if (!(other instanceof SemVer)) {
if (typeof other === 'string' && other === this.version) {
return 0
}
other = new SemVer(other, this.options)
}
if (other.version === this.version) {
return 0
}
return this.compareMain(other) || this.comparePre(other)
}
compareMain (other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options)
}
if (this.major < other.major) {
return -1
}
if (this.major > other.major) {
return 1
}
if (this.minor < other.minor) {
return -1
}
if (this.minor > other.minor) {
return 1
}
if (this.patch < other.patch) {
return -1
}
if (this.patch > other.patch) {
return 1
}
return 0
}
comparePre (other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options)
}
// NOT having a prerelease is > having one
if (this.prerelease.length && !other.prerelease.length) {
return -1
} else if (!this.prerelease.length && other.prerelease.length) {
return 1
} else if (!this.prerelease.length && !other.prerelease.length) {
return 0
}
let i = 0
do {
const a = this.prerelease[i]
const b = other.prerelease[i]
debug('prerelease compare', i, a, b)
if (a === undefined && b === undefined) {
return 0
} else if (b === undefined) {
return 1
} else if (a === undefined) {
return -1
} else if (a === b) {
continue
} else {
return compareIdentifiers(a, b)
}
} while (++i)
}
compareBuild (other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options)
}
let i = 0
do {
const a = this.build[i]
const b = other.build[i]
debug('build compare', i, a, b)
if (a === undefined && b === undefined) {
return 0
} else if (b === undefined) {
return 1
} else if (a === undefined) {
return -1
} else if (a === b) {
continue
} else {
return compareIdentifiers(a, b)
}
} while (++i)
}
// preminor will bump the version up to the next minor release, and immediately
// down to pre-release. premajor and prepatch work the same way.
inc (release, identifier, identifierBase) {
if (release.startsWith('pre')) {
if (!identifier && identifierBase === false) {
throw new Error('invalid increment argument: identifier is empty')
}
// Avoid an invalid semver results
if (identifier) {
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE])
if (!match || match[1] !== identifier) {
throw new Error(`invalid identifier: ${identifier}`)
}
}
}
switch (release) {
case 'premajor':
this.prerelease.length = 0
this.patch = 0
this.minor = 0
this.major++
this.inc('pre', identifier, identifierBase)
break
case 'preminor':
this.prerelease.length = 0
this.patch = 0
this.minor++
this.inc('pre', identifier, identifierBase)
break
case 'prepatch':
// If this is already a prerelease, it will bump to the next version
// drop any prereleases that might already exist, since they are not
// relevant at this point.
this.prerelease.length = 0
this.inc('patch', identifier, identifierBase)
this.inc('pre', identifier, identifierBase)
break
// If the input is a non-prerelease version, this acts the same as
// prepatch.
case 'prerelease':
if (this.prerelease.length === 0) {
this.inc('patch', identifier, identifierBase)
}
this.inc('pre', identifier, identifierBase)
break
case 'release':
if (this.prerelease.length === 0) {
throw new Error(`version ${this.raw} is not a prerelease`)
}
this.prerelease.length = 0
break
case 'major':
// If this is a pre-major version, bump up to the same major version.
// Otherwise increment major.
// 1.0.0-5 bumps to 1.0.0
// 1.1.0 bumps to 2.0.0
if (
this.minor !== 0 ||
this.patch !== 0 ||
this.prerelease.length === 0
) {
this.major++
}
this.minor = 0
this.patch = 0
this.prerelease = []
break
case 'minor':
// If this is a pre-minor version, bump up to the same minor version.
// Otherwise increment minor.
// 1.2.0-5 bumps to 1.2.0
// 1.2.1 bumps to 1.3.0
if (this.patch !== 0 || this.prerelease.length === 0) {
this.minor++
}
this.patch = 0
this.prerelease = []
break
case 'patch':
// If this is not a pre-release version, it will increment the patch.
// If it is a pre-release it will bump up to the same patch version.
// 1.2.0-5 patches to 1.2.0
// 1.2.0 patches to 1.2.1
if (this.prerelease.length === 0) {
this.patch++
}
this.prerelease = []
break
// This probably shouldn't be used publicly.
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
case 'pre': {
const base = Number(identifierBase) ? 1 : 0
if (this.prerelease.length === 0) {
this.prerelease = [base]
} else {
let i = this.prerelease.length
while (--i >= 0) {
if (typeof this.prerelease[i] === 'number') {
this.prerelease[i]++
i = -2
}
}
if (i === -1) {
// didn't increment anything
if (identifier === this.prerelease.join('.') && identifierBase === false) {
throw new Error('invalid increment argument: identifier already exists')
}
this.prerelease.push(base)
}
}
if (identifier) {
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
let prerelease = [identifier, base]
if (identifierBase === false) {
prerelease = [identifier]
}
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
if (isNaN(this.prerelease[1])) {
this.prerelease = prerelease
}
} else {
this.prerelease = prerelease
}
}
break
}
default:
throw new Error(`invalid increment argument: ${release}`)
}
this.raw = this.format()
if (this.build.length) {
this.raw += `+${this.build.join('.')}`
}
return this
}
}
module.exports = SemVer
npm-node-semver-5993c2e/functions/ 0000775 0000000 0000000 00000000000 15141150374 0017104 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/functions/clean.js 0000664 0000000 0000000 00000000315 15141150374 0020523 0 ustar 00root root 0000000 0000000 'use strict'
const parse = require('./parse')
const clean = (version, options) => {
const s = parse(version.trim().replace(/^[=v]+/, ''), options)
return s ? s.version : null
}
module.exports = clean
npm-node-semver-5993c2e/functions/cmp.js 0000664 0000000 0000000 00000001701 15141150374 0020220 0 ustar 00root root 0000000 0000000 'use strict'
const eq = require('./eq')
const neq = require('./neq')
const gt = require('./gt')
const gte = require('./gte')
const lt = require('./lt')
const lte = require('./lte')
const cmp = (a, op, b, loose) => {
switch (op) {
case '===':
if (typeof a === 'object') {
a = a.version
}
if (typeof b === 'object') {
b = b.version
}
return a === b
case '!==':
if (typeof a === 'object') {
a = a.version
}
if (typeof b === 'object') {
b = b.version
}
return a !== b
case '':
case '=':
case '==':
return eq(a, b, loose)
case '!=':
return neq(a, b, loose)
case '>':
return gt(a, b, loose)
case '>=':
return gte(a, b, loose)
case '<':
return lt(a, b, loose)
case '<=':
return lte(a, b, loose)
default:
throw new TypeError(`Invalid operator: ${op}`)
}
}
module.exports = cmp
npm-node-semver-5993c2e/functions/coerce.js 0000664 0000000 0000000 00000003724 15141150374 0020710 0 ustar 00root root 0000000 0000000 'use strict'
const SemVer = require('../classes/semver')
const parse = require('./parse')
const { safeRe: re, t } = require('../internal/re')
const coerce = (version, options) => {
if (version instanceof SemVer) {
return version
}
if (typeof version === 'number') {
version = String(version)
}
if (typeof version !== 'string') {
return null
}
options = options || {}
let match = null
if (!options.rtl) {
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE])
} else {
// Find the right-most coercible string that does not share
// a terminus with a more left-ward coercible string.
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
// With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'
//
// Walk through the string checking with a /g regexp
// Manually set the index so as to pick up overlapping matches.
// Stop when we get a match that ends at the string end, since no
// coercible string can be more right-ward without the same terminus.
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL]
let next
while ((next = coerceRtlRegex.exec(version)) &&
(!match || match.index + match[0].length !== version.length)
) {
if (!match ||
next.index + next[0].length !== match.index + match[0].length) {
match = next
}
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length
}
// leave it in a clean state
coerceRtlRegex.lastIndex = -1
}
if (match === null) {
return null
}
const major = match[2]
const minor = match[3] || '0'
const patch = match[4] || '0'
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : ''
const build = options.includePrerelease && match[6] ? `+${match[6]}` : ''
return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options)
}
module.exports = coerce
npm-node-semver-5993c2e/functions/compare-build.js 0000664 0000000 0000000 00000000431 15141150374 0022163 0 ustar 00root root 0000000 0000000 'use strict'
const SemVer = require('../classes/semver')
const compareBuild = (a, b, loose) => {
const versionA = new SemVer(a, loose)
const versionB = new SemVer(b, loose)
return versionA.compare(versionB) || versionA.compareBuild(versionB)
}
module.exports = compareBuild
npm-node-semver-5993c2e/functions/compare-loose.js 0000664 0000000 0000000 00000000204 15141150374 0022203 0 ustar 00root root 0000000 0000000 'use strict'
const compare = require('./compare')
const compareLoose = (a, b) => compare(a, b, true)
module.exports = compareLoose
npm-node-semver-5993c2e/functions/compare.js 0000664 0000000 0000000 00000000252 15141150374 0021067 0 ustar 00root root 0000000 0000000 'use strict'
const SemVer = require('../classes/semver')
const compare = (a, b, loose) =>
new SemVer(a, loose).compare(new SemVer(b, loose))
module.exports = compare
npm-node-semver-5993c2e/functions/diff.js 0000664 0000000 0000000 00000002617 15141150374 0020360 0 ustar 00root root 0000000 0000000 'use strict'
const parse = require('./parse.js')
const diff = (version1, version2) => {
const v1 = parse(version1, null, true)
const v2 = parse(version2, null, true)
const comparison = v1.compare(v2)
if (comparison === 0) {
return null
}
const v1Higher = comparison > 0
const highVersion = v1Higher ? v1 : v2
const lowVersion = v1Higher ? v2 : v1
const highHasPre = !!highVersion.prerelease.length
const lowHasPre = !!lowVersion.prerelease.length
if (lowHasPre && !highHasPre) {
// Going from prerelease -> no prerelease requires some special casing
// If the low version has only a major, then it will always be a major
// Some examples:
// 1.0.0-1 -> 1.0.0
// 1.0.0-1 -> 1.1.1
// 1.0.0-1 -> 2.0.0
if (!lowVersion.patch && !lowVersion.minor) {
return 'major'
}
// If the main part has no difference
if (lowVersion.compareMain(highVersion) === 0) {
if (lowVersion.minor && !lowVersion.patch) {
return 'minor'
}
return 'patch'
}
}
// add the `pre` prefix if we are going to a prerelease version
const prefix = highHasPre ? 'pre' : ''
if (v1.major !== v2.major) {
return prefix + 'major'
}
if (v1.minor !== v2.minor) {
return prefix + 'minor'
}
if (v1.patch !== v2.patch) {
return prefix + 'patch'
}
// high and low are prereleases
return 'prerelease'
}
module.exports = diff
npm-node-semver-5993c2e/functions/eq.js 0000664 0000000 0000000 00000000176 15141150374 0020053 0 ustar 00root root 0000000 0000000 'use strict'
const compare = require('./compare')
const eq = (a, b, loose) => compare(a, b, loose) === 0
module.exports = eq
npm-node-semver-5993c2e/functions/gt.js 0000664 0000000 0000000 00000000174 15141150374 0020056 0 ustar 00root root 0000000 0000000 'use strict'
const compare = require('./compare')
const gt = (a, b, loose) => compare(a, b, loose) > 0
module.exports = gt
npm-node-semver-5993c2e/functions/gte.js 0000664 0000000 0000000 00000000177 15141150374 0020226 0 ustar 00root root 0000000 0000000 'use strict'
const compare = require('./compare')
const gte = (a, b, loose) => compare(a, b, loose) >= 0
module.exports = gte
npm-node-semver-5993c2e/functions/inc.js 0000664 0000000 0000000 00000000736 15141150374 0020221 0 ustar 00root root 0000000 0000000 'use strict'
const SemVer = require('../classes/semver')
const inc = (version, release, options, identifier, identifierBase) => {
if (typeof (options) === 'string') {
identifierBase = identifier
identifier = options
options = undefined
}
try {
return new SemVer(
version instanceof SemVer ? version.version : version,
options
).inc(release, identifier, identifierBase).version
} catch (er) {
return null
}
}
module.exports = inc
npm-node-semver-5993c2e/functions/lt.js 0000664 0000000 0000000 00000000174 15141150374 0020063 0 ustar 00root root 0000000 0000000 'use strict'
const compare = require('./compare')
const lt = (a, b, loose) => compare(a, b, loose) < 0
module.exports = lt
npm-node-semver-5993c2e/functions/lte.js 0000664 0000000 0000000 00000000177 15141150374 0020233 0 ustar 00root root 0000000 0000000 'use strict'
const compare = require('./compare')
const lte = (a, b, loose) => compare(a, b, loose) <= 0
module.exports = lte
npm-node-semver-5993c2e/functions/major.js 0000664 0000000 0000000 00000000210 15141150374 0020543 0 ustar 00root root 0000000 0000000 'use strict'
const SemVer = require('../classes/semver')
const major = (a, loose) => new SemVer(a, loose).major
module.exports = major
npm-node-semver-5993c2e/functions/minor.js 0000664 0000000 0000000 00000000210 15141150374 0020557 0 ustar 00root root 0000000 0000000 'use strict'
const SemVer = require('../classes/semver')
const minor = (a, loose) => new SemVer(a, loose).minor
module.exports = minor
npm-node-semver-5993c2e/functions/neq.js 0000664 0000000 0000000 00000000200 15141150374 0020215 0 ustar 00root root 0000000 0000000 'use strict'
const compare = require('./compare')
const neq = (a, b, loose) => compare(a, b, loose) !== 0
module.exports = neq
npm-node-semver-5993c2e/functions/parse.js 0000664 0000000 0000000 00000000513 15141150374 0020553 0 ustar 00root root 0000000 0000000 'use strict'
const SemVer = require('../classes/semver')
const parse = (version, options, throwErrors = false) => {
if (version instanceof SemVer) {
return version
}
try {
return new SemVer(version, options)
} catch (er) {
if (!throwErrors) {
return null
}
throw er
}
}
module.exports = parse
npm-node-semver-5993c2e/functions/patch.js 0000664 0000000 0000000 00000000210 15141150374 0020532 0 ustar 00root root 0000000 0000000 'use strict'
const SemVer = require('../classes/semver')
const patch = (a, loose) => new SemVer(a, loose).patch
module.exports = patch
npm-node-semver-5993c2e/functions/prerelease.js 0000664 0000000 0000000 00000000352 15141150374 0021571 0 ustar 00root root 0000000 0000000 'use strict'
const parse = require('./parse')
const prerelease = (version, options) => {
const parsed = parse(version, options)
return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
}
module.exports = prerelease
npm-node-semver-5993c2e/functions/rcompare.js 0000664 0000000 0000000 00000000204 15141150374 0021246 0 ustar 00root root 0000000 0000000 'use strict'
const compare = require('./compare')
const rcompare = (a, b, loose) => compare(b, a, loose)
module.exports = rcompare
npm-node-semver-5993c2e/functions/rsort.js 0000664 0000000 0000000 00000000243 15141150374 0020612 0 ustar 00root root 0000000 0000000 'use strict'
const compareBuild = require('./compare-build')
const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose))
module.exports = rsort
npm-node-semver-5993c2e/functions/satisfies.js 0000664 0000000 0000000 00000000367 15141150374 0021442 0 ustar 00root root 0000000 0000000 'use strict'
const Range = require('../classes/range')
const satisfies = (version, range, options) => {
try {
range = new Range(range, options)
} catch (er) {
return false
}
return range.test(version)
}
module.exports = satisfies
npm-node-semver-5993c2e/functions/sort.js 0000664 0000000 0000000 00000000241 15141150374 0020426 0 ustar 00root root 0000000 0000000 'use strict'
const compareBuild = require('./compare-build')
const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose))
module.exports = sort
npm-node-semver-5993c2e/functions/valid.js 0000664 0000000 0000000 00000000260 15141150374 0020537 0 ustar 00root root 0000000 0000000 'use strict'
const parse = require('./parse')
const valid = (version, options) => {
const v = parse(version, options)
return v ? v.version : null
}
module.exports = valid
npm-node-semver-5993c2e/index.js 0000664 0000000 0000000 00000005106 15141150374 0016543 0 ustar 00root root 0000000 0000000 'use strict'
// just pre-load all the stuff that index.js lazily exports
const internalRe = require('./internal/re')
const constants = require('./internal/constants')
const SemVer = require('./classes/semver')
const identifiers = require('./internal/identifiers')
const parse = require('./functions/parse')
const valid = require('./functions/valid')
const clean = require('./functions/clean')
const inc = require('./functions/inc')
const diff = require('./functions/diff')
const major = require('./functions/major')
const minor = require('./functions/minor')
const patch = require('./functions/patch')
const prerelease = require('./functions/prerelease')
const compare = require('./functions/compare')
const rcompare = require('./functions/rcompare')
const compareLoose = require('./functions/compare-loose')
const compareBuild = require('./functions/compare-build')
const sort = require('./functions/sort')
const rsort = require('./functions/rsort')
const gt = require('./functions/gt')
const lt = require('./functions/lt')
const eq = require('./functions/eq')
const neq = require('./functions/neq')
const gte = require('./functions/gte')
const lte = require('./functions/lte')
const cmp = require('./functions/cmp')
const coerce = require('./functions/coerce')
const Comparator = require('./classes/comparator')
const Range = require('./classes/range')
const satisfies = require('./functions/satisfies')
const toComparators = require('./ranges/to-comparators')
const maxSatisfying = require('./ranges/max-satisfying')
const minSatisfying = require('./ranges/min-satisfying')
const minVersion = require('./ranges/min-version')
const validRange = require('./ranges/valid')
const outside = require('./ranges/outside')
const gtr = require('./ranges/gtr')
const ltr = require('./ranges/ltr')
const intersects = require('./ranges/intersects')
const simplifyRange = require('./ranges/simplify')
const subset = require('./ranges/subset')
module.exports = {
parse,
valid,
clean,
inc,
diff,
major,
minor,
patch,
prerelease,
compare,
rcompare,
compareLoose,
compareBuild,
sort,
rsort,
gt,
lt,
eq,
neq,
gte,
lte,
cmp,
coerce,
Comparator,
Range,
satisfies,
toComparators,
maxSatisfying,
minSatisfying,
minVersion,
validRange,
outside,
gtr,
ltr,
intersects,
simplifyRange,
subset,
SemVer,
re: internalRe.re,
src: internalRe.src,
tokens: internalRe.t,
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
RELEASE_TYPES: constants.RELEASE_TYPES,
compareIdentifiers: identifiers.compareIdentifiers,
rcompareIdentifiers: identifiers.rcompareIdentifiers,
}
npm-node-semver-5993c2e/internal/ 0000775 0000000 0000000 00000000000 15141150374 0016710 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/internal/constants.js 0000664 0000000 0000000 00000001551 15141150374 0021264 0 ustar 00root root 0000000 0000000 'use strict'
// Note: this is the semver.org version of the spec that it implements
// Not necessarily the package version of this code.
const SEMVER_SPEC_VERSION = '2.0.0'
const MAX_LENGTH = 256
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
/* istanbul ignore next */ 9007199254740991
// Max safe segment length for coercion.
const MAX_SAFE_COMPONENT_LENGTH = 16
// Max safe length for a build identifier. The max length minus 6 characters for
// the shortest version with a build 0.0.0+BUILD.
const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6
const RELEASE_TYPES = [
'major',
'premajor',
'minor',
'preminor',
'patch',
'prepatch',
'prerelease',
]
module.exports = {
MAX_LENGTH,
MAX_SAFE_COMPONENT_LENGTH,
MAX_SAFE_BUILD_LENGTH,
MAX_SAFE_INTEGER,
RELEASE_TYPES,
SEMVER_SPEC_VERSION,
FLAG_INCLUDE_PRERELEASE: 0b001,
FLAG_LOOSE: 0b010,
}
npm-node-semver-5993c2e/internal/debug.js 0000664 0000000 0000000 00000000360 15141150374 0020333 0 ustar 00root root 0000000 0000000 'use strict'
const debug = (
typeof process === 'object' &&
process.env &&
process.env.NODE_DEBUG &&
/\bsemver\b/i.test(process.env.NODE_DEBUG)
) ? (...args) => console.error('SEMVER', ...args)
: () => {}
module.exports = debug
npm-node-semver-5993c2e/internal/identifiers.js 0000664 0000000 0000000 00000001015 15141150374 0021550 0 ustar 00root root 0000000 0000000 'use strict'
const numeric = /^[0-9]+$/
const compareIdentifiers = (a, b) => {
if (typeof a === 'number' && typeof b === 'number') {
return a === b ? 0 : a < b ? -1 : 1
}
const anum = numeric.test(a)
const bnum = numeric.test(b)
if (anum && bnum) {
a = +a
b = +b
}
return a === b ? 0
: (anum && !bnum) ? -1
: (bnum && !anum) ? 1
: a < b ? -1
: 1
}
const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)
module.exports = {
compareIdentifiers,
rcompareIdentifiers,
}
npm-node-semver-5993c2e/internal/lrucache.js 0000664 0000000 0000000 00000001442 15141150374 0021035 0 ustar 00root root 0000000 0000000 'use strict'
class LRUCache {
constructor () {
this.max = 1000
this.map = new Map()
}
get (key) {
const value = this.map.get(key)
if (value === undefined) {
return undefined
} else {
// Remove the key from the map and add it to the end
this.map.delete(key)
this.map.set(key, value)
return value
}
}
delete (key) {
return this.map.delete(key)
}
set (key, value) {
const deleted = this.delete(key)
if (!deleted && value !== undefined) {
// If cache is full, delete the least recently used item
if (this.map.size >= this.max) {
const firstKey = this.map.keys().next().value
this.delete(firstKey)
}
this.map.set(key, value)
}
return this
}
}
module.exports = LRUCache
npm-node-semver-5993c2e/internal/parse-options.js 0000664 0000000 0000000 00000000522 15141150374 0022050 0 ustar 00root root 0000000 0000000 'use strict'
// parse out just the options we care about
const looseOption = Object.freeze({ loose: true })
const emptyOpts = Object.freeze({ })
const parseOptions = options => {
if (!options) {
return emptyOpts
}
if (typeof options !== 'object') {
return looseOption
}
return options
}
module.exports = parseOptions
npm-node-semver-5993c2e/internal/re.js 0000664 0000000 0000000 00000017712 15141150374 0017664 0 ustar 00root root 0000000 0000000 'use strict'
const {
MAX_SAFE_COMPONENT_LENGTH,
MAX_SAFE_BUILD_LENGTH,
MAX_LENGTH,
} = require('./constants')
const debug = require('./debug')
exports = module.exports = {}
// The actual regexps go on exports.re
const re = exports.re = []
const safeRe = exports.safeRe = []
const src = exports.src = []
const safeSrc = exports.safeSrc = []
const t = exports.t = {}
let R = 0
const LETTERDASHNUMBER = '[a-zA-Z0-9-]'
// Replace some greedy regex tokens to prevent regex dos issues. These regex are
// used internally via the safeRe object since all inputs in this library get
// normalized first to trim and collapse all extra whitespace. The original
// regexes are exported for userland consumption and lower level usage. A
// future breaking change could export the safer regex only with a note that
// all input should have extra whitespace removed.
const safeRegexReplacements = [
['\\s', 1],
['\\d', MAX_LENGTH],
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
]
const makeSafeRegex = (value) => {
for (const [token, max] of safeRegexReplacements) {
value = value
.split(`${token}*`).join(`${token}{0,${max}}`)
.split(`${token}+`).join(`${token}{1,${max}}`)
}
return value
}
const createToken = (name, value, isGlobal) => {
const safe = makeSafeRegex(value)
const index = R++
debug(name, index, value)
t[name] = index
src[index] = value
safeSrc[index] = safe
re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)
}
// The following Regular Expressions can be used for tokenizing,
// validating, and parsing SemVer version strings.
// ## Numeric Identifier
// A single `0`, or a non-zero digit followed by zero or more digits.
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*')
createToken('NUMERICIDENTIFIERLOOSE', '\\d+')
// ## Non-numeric Identifier
// Zero or more digits, followed by a letter or hyphen, and then zero or
// more letters, digits, or hyphens.
createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`)
// ## Main Version
// Three dot-separated numeric identifiers.
createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
`(${src[t.NUMERICIDENTIFIER]})\\.` +
`(${src[t.NUMERICIDENTIFIER]})`)
createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
`(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
`(${src[t.NUMERICIDENTIFIERLOOSE]})`)
// ## Pre-release Version Identifier
// A numeric identifier, or a non-numeric identifier.
// Non-numeric identifiers include numeric identifiers but can be longer.
// Therefore non-numeric identifiers must go first.
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]
}|${src[t.NUMERICIDENTIFIER]})`)
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER]
}|${src[t.NUMERICIDENTIFIERLOOSE]})`)
// ## Pre-release Version
// Hyphen, followed by one or more dot-separated pre-release version
// identifiers.
createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`)
createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`)
// ## Build Metadata Identifier
// Any combination of digits, letters, or hyphens.
createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`)
// ## Build Metadata
// Plus sign, followed by one or more period-separated build metadata
// identifiers.
createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
}(?:\\.${src[t.BUILDIDENTIFIER]})*))`)
// ## Full Version String
// A main version, followed optionally by a pre-release version and
// build metadata.
// Note that the only major, minor, patch, and pre-release sections of
// the version string are capturing groups. The build metadata is not a
// capturing group, because it should not ever be used in version
// comparison.
createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
}${src[t.PRERELEASE]}?${
src[t.BUILD]}?`)
createToken('FULL', `^${src[t.FULLPLAIN]}$`)
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
// common in the npm registry.
createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
}${src[t.PRERELEASELOOSE]}?${
src[t.BUILD]}?`)
createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`)
createToken('GTLT', '((?:<|>)?=?)')
// Something like "2.*" or "1.2.x".
// Note that "x.x" is a valid xRange identifer, meaning "any version"
// Only the first item is strictly required.
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`)
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`)
createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
`(?:${src[t.PRERELEASE]})?${
src[t.BUILD]}?` +
`)?)?`)
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
`(?:${src[t.PRERELEASELOOSE]})?${
src[t.BUILD]}?` +
`)?)?`)
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`)
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`)
// Coercion.
// Extract anything that could conceivably be a part of a valid semver
createToken('COERCEPLAIN', `${'(^|[^\\d])' +
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`)
createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`)
createToken('COERCEFULL', src[t.COERCEPLAIN] +
`(?:${src[t.PRERELEASE]})?` +
`(?:${src[t.BUILD]})?` +
`(?:$|[^\\d])`)
createToken('COERCERTL', src[t.COERCE], true)
createToken('COERCERTLFULL', src[t.COERCEFULL], true)
// Tilde ranges.
// Meaning is "reasonably at or greater than"
createToken('LONETILDE', '(?:~>?)')
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true)
exports.tildeTrimReplace = '$1~'
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`)
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`)
// Caret ranges.
// Meaning is "at least and backwards compatible with"
createToken('LONECARET', '(?:\\^)')
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true)
exports.caretTrimReplace = '$1^'
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`)
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`)
// A simple gt/lt/eq thing, or just "" to indicate "any version"
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`)
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`)
// An expression to strip any whitespace between the gtlt and the thing
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true)
exports.comparatorTrimReplace = '$1$2$3'
// Something like `1.2.3 - 1.2.4`
// Note that these all use the loose form, because they'll be
// checked against either the strict or loose comparator form
// later.
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
`\\s+-\\s+` +
`(${src[t.XRANGEPLAIN]})` +
`\\s*$`)
createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
`\\s+-\\s+` +
`(${src[t.XRANGEPLAINLOOSE]})` +
`\\s*$`)
// Star ranges basically just allow anything at all.
createToken('STAR', '(<|>)?=?\\s*\\*')
// >=0.0.0 is like a star
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$')
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$')
npm-node-semver-5993c2e/map.js 0000664 0000000 0000000 00000000112 15141150374 0016201 0 ustar 00root root 0000000 0000000 'use strict'
module.exports = testFile => testFile.replace(/test\//, '')
npm-node-semver-5993c2e/package.json 0000664 0000000 0000000 00000003177 15141150374 0017372 0 ustar 00root root 0000000 0000000 {
"name": "semver",
"version": "7.7.4",
"description": "The semantic version parser used by npm.",
"main": "index.js",
"scripts": {
"test": "tap",
"snap": "tap",
"lint": "npm run eslint",
"postlint": "template-oss-check",
"lintfix": "npm run eslint -- --fix",
"posttest": "npm run lint",
"template-oss-apply": "template-oss-apply --force",
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
},
"devDependencies": {
"@npmcli/eslint-config": "^6.0.0",
"@npmcli/template-oss": "4.29.0",
"benchmark": "^2.1.4",
"tap": "^16.0.0"
},
"license": "ISC",
"repository": {
"type": "git",
"url": "git+https://github.com/npm/node-semver.git"
},
"bin": {
"semver": "bin/semver.js"
},
"files": [
"bin/",
"lib/",
"classes/",
"functions/",
"internal/",
"ranges/",
"index.js",
"preload.js",
"range.bnf"
],
"tap": {
"timeout": 30,
"coverage-map": "map.js",
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
},
"engines": {
"node": ">=10"
},
"author": "GitHub Inc.",
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.29.0",
"engines": ">=10",
"distPaths": [
"classes/",
"functions/",
"internal/",
"ranges/",
"index.js",
"preload.js",
"range.bnf"
],
"allowPaths": [
"/classes/",
"/functions/",
"/internal/",
"/ranges/",
"/index.js",
"/preload.js",
"/range.bnf",
"/benchmarks"
],
"publish": "true"
}
}
npm-node-semver-5993c2e/preload.js 0000664 0000000 0000000 00000000123 15141150374 0017054 0 ustar 00root root 0000000 0000000 'use strict'
// XXX remove in v8 or beyond
module.exports = require('./index.js')
npm-node-semver-5993c2e/range.bnf 0000664 0000000 0000000 00000001153 15141150374 0016657 0 ustar 00root root 0000000 0000000 range-set ::= range ( logical-or range ) *
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
range ::= hyphen | simple ( ' ' simple ) * | ''
hyphen ::= partial ' - ' partial
simple ::= primitive | partial | tilde | caret
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
xr ::= 'x' | 'X' | '*' | nr
nr ::= '0' | [1-9] ( [0-9] ) *
tilde ::= '~' partial
caret ::= '^' partial
qualifier ::= ( '-' pre )? ( '+' build )?
pre ::= parts
build ::= parts
parts ::= part ( '.' part ) *
part ::= nr | [-0-9A-Za-z]+
npm-node-semver-5993c2e/ranges/ 0000775 0000000 0000000 00000000000 15141150374 0016353 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/ranges/gtr.js 0000664 0000000 0000000 00000000347 15141150374 0017511 0 ustar 00root root 0000000 0000000 'use strict'
// Determine if version is greater than all the versions possible in the range.
const outside = require('./outside')
const gtr = (version, range, options) => outside(version, range, '>', options)
module.exports = gtr
npm-node-semver-5993c2e/ranges/intersects.js 0000664 0000000 0000000 00000000340 15141150374 0021071 0 ustar 00root root 0000000 0000000 'use strict'
const Range = require('../classes/range')
const intersects = (r1, r2, options) => {
r1 = new Range(r1, options)
r2 = new Range(r2, options)
return r1.intersects(r2, options)
}
module.exports = intersects
npm-node-semver-5993c2e/ranges/ltr.js 0000664 0000000 0000000 00000000343 15141150374 0017512 0 ustar 00root root 0000000 0000000 'use strict'
const outside = require('./outside')
// Determine if version is less than all the versions possible in the range
const ltr = (version, range, options) => outside(version, range, '<', options)
module.exports = ltr
npm-node-semver-5993c2e/ranges/max-satisfying.js 0000664 0000000 0000000 00000001121 15141150374 0021647 0 ustar 00root root 0000000 0000000 'use strict'
const SemVer = require('../classes/semver')
const Range = require('../classes/range')
const maxSatisfying = (versions, range, options) => {
let max = null
let maxSV = null
let rangeObj = null
try {
rangeObj = new Range(range, options)
} catch (er) {
return null
}
versions.forEach((v) => {
if (rangeObj.test(v)) {
// satisfies(v, range, options)
if (!max || maxSV.compare(v) === -1) {
// compare(max, v, true)
max = v
maxSV = new SemVer(max, options)
}
}
})
return max
}
module.exports = maxSatisfying
npm-node-semver-5993c2e/ranges/min-satisfying.js 0000664 0000000 0000000 00000001117 15141150374 0021652 0 ustar 00root root 0000000 0000000 'use strict'
const SemVer = require('../classes/semver')
const Range = require('../classes/range')
const minSatisfying = (versions, range, options) => {
let min = null
let minSV = null
let rangeObj = null
try {
rangeObj = new Range(range, options)
} catch (er) {
return null
}
versions.forEach((v) => {
if (rangeObj.test(v)) {
// satisfies(v, range, options)
if (!min || minSV.compare(v) === 1) {
// compare(min, v, true)
min = v
minSV = new SemVer(min, options)
}
}
})
return min
}
module.exports = minSatisfying
npm-node-semver-5993c2e/ranges/min-version.js 0000664 0000000 0000000 00000002752 15141150374 0021165 0 ustar 00root root 0000000 0000000 'use strict'
const SemVer = require('../classes/semver')
const Range = require('../classes/range')
const gt = require('../functions/gt')
const minVersion = (range, loose) => {
range = new Range(range, loose)
let minver = new SemVer('0.0.0')
if (range.test(minver)) {
return minver
}
minver = new SemVer('0.0.0-0')
if (range.test(minver)) {
return minver
}
minver = null
for (let i = 0; i < range.set.length; ++i) {
const comparators = range.set[i]
let setMin = null
comparators.forEach((comparator) => {
// Clone to avoid manipulating the comparator's semver object.
const compver = new SemVer(comparator.semver.version)
switch (comparator.operator) {
case '>':
if (compver.prerelease.length === 0) {
compver.patch++
} else {
compver.prerelease.push(0)
}
compver.raw = compver.format()
/* fallthrough */
case '':
case '>=':
if (!setMin || gt(compver, setMin)) {
setMin = compver
}
break
case '<':
case '<=':
/* Ignore maximum versions */
break
/* istanbul ignore next */
default:
throw new Error(`Unexpected operation: ${comparator.operator}`)
}
})
if (setMin && (!minver || gt(minver, setMin))) {
minver = setMin
}
}
if (minver && range.test(minver)) {
return minver
}
return null
}
module.exports = minVersion
npm-node-semver-5993c2e/ranges/outside.js 0000664 0000000 0000000 00000004234 15141150374 0020370 0 ustar 00root root 0000000 0000000 'use strict'
const SemVer = require('../classes/semver')
const Comparator = require('../classes/comparator')
const { ANY } = Comparator
const Range = require('../classes/range')
const satisfies = require('../functions/satisfies')
const gt = require('../functions/gt')
const lt = require('../functions/lt')
const lte = require('../functions/lte')
const gte = require('../functions/gte')
const outside = (version, range, hilo, options) => {
version = new SemVer(version, options)
range = new Range(range, options)
let gtfn, ltefn, ltfn, comp, ecomp
switch (hilo) {
case '>':
gtfn = gt
ltefn = lte
ltfn = lt
comp = '>'
ecomp = '>='
break
case '<':
gtfn = lt
ltefn = gte
ltfn = gt
comp = '<'
ecomp = '<='
break
default:
throw new TypeError('Must provide a hilo val of "<" or ">"')
}
// If it satisfies the range it is not outside
if (satisfies(version, range, options)) {
return false
}
// From now on, variable terms are as if we're in "gtr" mode.
// but note that everything is flipped for the "ltr" function.
for (let i = 0; i < range.set.length; ++i) {
const comparators = range.set[i]
let high = null
let low = null
comparators.forEach((comparator) => {
if (comparator.semver === ANY) {
comparator = new Comparator('>=0.0.0')
}
high = high || comparator
low = low || comparator
if (gtfn(comparator.semver, high.semver, options)) {
high = comparator
} else if (ltfn(comparator.semver, low.semver, options)) {
low = comparator
}
})
// If the edge version comparator has a operator then our version
// isn't outside it
if (high.operator === comp || high.operator === ecomp) {
return false
}
// If the lowest version comparator has an operator and our version
// is less than it then it isn't higher than the range
if ((!low.operator || low.operator === comp) &&
ltefn(version, low.semver)) {
return false
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
return false
}
}
return true
}
module.exports = outside
npm-node-semver-5993c2e/ranges/simplify.js 0000664 0000000 0000000 00000002513 15141150374 0020546 0 ustar 00root root 0000000 0000000 'use strict'
// given a set of versions and a range, create a "simplified" range
// that includes the same versions that the original range does
// If the original range is shorter than the simplified one, return that.
const satisfies = require('../functions/satisfies.js')
const compare = require('../functions/compare.js')
module.exports = (versions, range, options) => {
const set = []
let first = null
let prev = null
const v = versions.sort((a, b) => compare(a, b, options))
for (const version of v) {
const included = satisfies(version, range, options)
if (included) {
prev = version
if (!first) {
first = version
}
} else {
if (prev) {
set.push([first, prev])
}
prev = null
first = null
}
}
if (first) {
set.push([first, null])
}
const ranges = []
for (const [min, max] of set) {
if (min === max) {
ranges.push(min)
} else if (!max && min === v[0]) {
ranges.push('*')
} else if (!max) {
ranges.push(`>=${min}`)
} else if (min === v[0]) {
ranges.push(`<=${max}`)
} else {
ranges.push(`${min} - ${max}`)
}
}
const simplified = ranges.join(' || ')
const original = typeof range.raw === 'string' ? range.raw : String(range)
return simplified.length < original.length ? simplified : range
}
npm-node-semver-5993c2e/ranges/subset.js 0000664 0000000 0000000 00000016544 15141150374 0020230 0 ustar 00root root 0000000 0000000 'use strict'
const Range = require('../classes/range.js')
const Comparator = require('../classes/comparator.js')
const { ANY } = Comparator
const satisfies = require('../functions/satisfies.js')
const compare = require('../functions/compare.js')
// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
// - Every simple range `r1, r2, ...` is a null set, OR
// - Every simple range `r1, r2, ...` which is not a null set is a subset of
// some `R1, R2, ...`
//
// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
// - If c is only the ANY comparator
// - If C is only the ANY comparator, return true
// - Else if in prerelease mode, return false
// - else replace c with `[>=0.0.0]`
// - If C is only the ANY comparator
// - if in prerelease mode, return true
// - else replace C with `[>=0.0.0]`
// - Let EQ be the set of = comparators in c
// - If EQ is more than one, return true (null set)
// - Let GT be the highest > or >= comparator in c
// - Let LT be the lowest < or <= comparator in c
// - If GT and LT, and GT.semver > LT.semver, return true (null set)
// - If any C is a = range, and GT or LT are set, return false
// - If EQ
// - If GT, and EQ does not satisfy GT, return true (null set)
// - If LT, and EQ does not satisfy LT, return true (null set)
// - If EQ satisfies every C, return true
// - Else return false
// - If GT
// - If GT.semver is lower than any > or >= comp in C, return false
// - If GT is >=, and GT.semver does not satisfy every C, return false
// - If GT.semver has a prerelease, and not in prerelease mode
// - If no C has a prerelease and the GT.semver tuple, return false
// - If LT
// - If LT.semver is greater than any < or <= comp in C, return false
// - If LT is <=, and LT.semver does not satisfy every C, return false
// - If LT.semver has a prerelease, and not in prerelease mode
// - If no C has a prerelease and the LT.semver tuple, return false
// - Else return true
const subset = (sub, dom, options = {}) => {
if (sub === dom) {
return true
}
sub = new Range(sub, options)
dom = new Range(dom, options)
let sawNonNull = false
OUTER: for (const simpleSub of sub.set) {
for (const simpleDom of dom.set) {
const isSub = simpleSubset(simpleSub, simpleDom, options)
sawNonNull = sawNonNull || isSub !== null
if (isSub) {
continue OUTER
}
}
// the null set is a subset of everything, but null simple ranges in
// a complex range should be ignored. so if we saw a non-null range,
// then we know this isn't a subset, but if EVERY simple range was null,
// then it is a subset.
if (sawNonNull) {
return false
}
}
return true
}
const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')]
const minimumVersion = [new Comparator('>=0.0.0')]
const simpleSubset = (sub, dom, options) => {
if (sub === dom) {
return true
}
if (sub.length === 1 && sub[0].semver === ANY) {
if (dom.length === 1 && dom[0].semver === ANY) {
return true
} else if (options.includePrerelease) {
sub = minimumVersionWithPreRelease
} else {
sub = minimumVersion
}
}
if (dom.length === 1 && dom[0].semver === ANY) {
if (options.includePrerelease) {
return true
} else {
dom = minimumVersion
}
}
const eqSet = new Set()
let gt, lt
for (const c of sub) {
if (c.operator === '>' || c.operator === '>=') {
gt = higherGT(gt, c, options)
} else if (c.operator === '<' || c.operator === '<=') {
lt = lowerLT(lt, c, options)
} else {
eqSet.add(c.semver)
}
}
if (eqSet.size > 1) {
return null
}
let gtltComp
if (gt && lt) {
gtltComp = compare(gt.semver, lt.semver, options)
if (gtltComp > 0) {
return null
} else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) {
return null
}
}
// will iterate one or zero times
for (const eq of eqSet) {
if (gt && !satisfies(eq, String(gt), options)) {
return null
}
if (lt && !satisfies(eq, String(lt), options)) {
return null
}
for (const c of dom) {
if (!satisfies(eq, String(c), options)) {
return false
}
}
return true
}
let higher, lower
let hasDomLT, hasDomGT
// if the subset has a prerelease, we need a comparator in the superset
// with the same tuple and a prerelease, or it's not a subset
let needDomLTPre = lt &&
!options.includePrerelease &&
lt.semver.prerelease.length ? lt.semver : false
let needDomGTPre = gt &&
!options.includePrerelease &&
gt.semver.prerelease.length ? gt.semver : false
// exception: <1.2.3-0 is the same as <1.2.3
if (needDomLTPre && needDomLTPre.prerelease.length === 1 &&
lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
needDomLTPre = false
}
for (const c of dom) {
hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>='
hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<='
if (gt) {
if (needDomGTPre) {
if (c.semver.prerelease && c.semver.prerelease.length &&
c.semver.major === needDomGTPre.major &&
c.semver.minor === needDomGTPre.minor &&
c.semver.patch === needDomGTPre.patch) {
needDomGTPre = false
}
}
if (c.operator === '>' || c.operator === '>=') {
higher = higherGT(gt, c, options)
if (higher === c && higher !== gt) {
return false
}
} else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) {
return false
}
}
if (lt) {
if (needDomLTPre) {
if (c.semver.prerelease && c.semver.prerelease.length &&
c.semver.major === needDomLTPre.major &&
c.semver.minor === needDomLTPre.minor &&
c.semver.patch === needDomLTPre.patch) {
needDomLTPre = false
}
}
if (c.operator === '<' || c.operator === '<=') {
lower = lowerLT(lt, c, options)
if (lower === c && lower !== lt) {
return false
}
} else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) {
return false
}
}
if (!c.operator && (lt || gt) && gtltComp !== 0) {
return false
}
}
// if there was a < or >, and nothing in the dom, then must be false
// UNLESS it was limited by another range in the other direction.
// Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
if (gt && hasDomLT && !lt && gtltComp !== 0) {
return false
}
if (lt && hasDomGT && !gt && gtltComp !== 0) {
return false
}
// we needed a prerelease range in a specific tuple, but didn't get one
// then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
// because it includes prereleases in the 1.2.3 tuple
if (needDomGTPre || needDomLTPre) {
return false
}
return true
}
// >=1.2.3 is lower than >1.2.3
const higherGT = (a, b, options) => {
if (!a) {
return b
}
const comp = compare(a.semver, b.semver, options)
return comp > 0 ? a
: comp < 0 ? b
: b.operator === '>' && a.operator === '>=' ? b
: a
}
// <=1.2.3 is higher than <1.2.3
const lowerLT = (a, b, options) => {
if (!a) {
return b
}
const comp = compare(a.semver, b.semver, options)
return comp < 0 ? a
: comp > 0 ? b
: b.operator === '<' && a.operator === '<=' ? b
: a
}
module.exports = subset
npm-node-semver-5993c2e/ranges/to-comparators.js 0000664 0000000 0000000 00000000432 15141150374 0021662 0 ustar 00root root 0000000 0000000 'use strict'
const Range = require('../classes/range')
// Mostly just for testing and legacy API reasons
const toComparators = (range, options) =>
new Range(range, options).set
.map(comp => comp.map(c => c.value).join(' ').trim().split(' '))
module.exports = toComparators
npm-node-semver-5993c2e/ranges/valid.js 0000664 0000000 0000000 00000000506 15141150374 0020011 0 ustar 00root root 0000000 0000000 'use strict'
const Range = require('../classes/range')
const validRange = (range, options) => {
try {
// Return '*' instead of '' so that truthiness works.
// This will throw if it's invalid anyway
return new Range(range, options).range || '*'
} catch (er) {
return null
}
}
module.exports = validRange
npm-node-semver-5993c2e/release-please-config.json 0000664 0000000 0000000 00000001277 15141150374 0022130 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-node-semver-5993c2e/tap-snapshots/ 0000775 0000000 0000000 00000000000 15141150374 0017700 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/tap-snapshots/test/ 0000775 0000000 0000000 00000000000 15141150374 0020657 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/tap-snapshots/test/bin/ 0000775 0000000 0000000 00000000000 15141150374 0021427 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/tap-snapshots/test/bin/semver.js.test.cjs 0000664 0000000 0000000 00000027207 15141150374 0025032 0 ustar 00root root 0000000 0000000 /* IMPORTANT
* This snapshot file is auto-generated, but designed for humans.
* It should be checked into source control and tracked carefully.
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`test/bin/semver.js TAP coercing > 1.2.3.4.5.6 -c --rtl --ltr 1`] = `
Object {
"code": 0,
"err": "",
"out": "1.2.3\\n",
"signal": null,
}
`
exports[`test/bin/semver.js TAP coercing > 1.2.3.4.5.6 -c --rtl 1`] = `
Object {
"code": 0,
"err": "",
"out": "4.5.6\\n",
"signal": null,
}
`
exports[`test/bin/semver.js TAP coercing > 1.2.3.4.5.6 -c 1`] = `
Object {
"code": 0,
"err": "",
"out": "1.2.3\\n",
"signal": null,
}
`
exports[`test/bin/semver.js TAP coercing > not a version -c 1`] = `
Object {
"code": 1,
"err": "",
"out": "",
"signal": null,
}
`
exports[`test/bin/semver.js TAP coercing > not a version 1.2.3 -c 1`] = `
Object {
"code": 0,
"err": "",
"out": "1.2.3\\n",
"signal": null,
}
`
exports[`test/bin/semver.js TAP help output > (no args) 1`] = `
Object {
"code": 0,
"err": "",
"out": String(
SemVer @@VERSION@@
A JavaScript implementation of the https://semver.org/ specification
Copyright Isaac Z. Schlueter
Usage: semver [options] [ [...]]
Prints valid versions sorted by SemVer precedence
Options:
-r --range
Print versions that match the specified range.
-i --increment []
Increment a version by the specified level. Level can
be one of: major, minor, patch, premajor, preminor,
prepatch, prerelease, or release. Default level is 'patch'.
Only one version may be specified.
--preid
Identifier to be used to prefix premajor, preminor,
prepatch or prerelease version increments.
-l --loose
Interpret versions and ranges loosely
-p --include-prerelease
Always include prerelease versions in range matching
-c --coerce
Coerce a string into SemVer if possible
(does not imply --loose)
--rtl
Coerce version strings right to left
--ltr
Coerce version strings left to right (default)
-n
Base number to be used for the prerelease identifier.
Can be either 0 or 1, or false to omit the number altogether.
Defaults to 0.
Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions.
If no satisfying versions are found, then exits failure.
Versions are printed in ascending order, so supplying
multiple versions to the utility will just sort them.
),
"signal": null,
}
`
exports[`test/bin/semver.js TAP help output > --help 1`] = `
Object {
"code": 0,
"err": "",
"out": String(
SemVer @@VERSION@@
A JavaScript implementation of the https://semver.org/ specification
Copyright Isaac Z. Schlueter
Usage: semver [options] [ [...]]
Prints valid versions sorted by SemVer precedence
Options:
-r --range
Print versions that match the specified range.
-i --increment []
Increment a version by the specified level. Level can
be one of: major, minor, patch, premajor, preminor,
prepatch, prerelease, or release. Default level is 'patch'.
Only one version may be specified.
--preid
Identifier to be used to prefix premajor, preminor,
prepatch or prerelease version increments.
-l --loose
Interpret versions and ranges loosely
-p --include-prerelease
Always include prerelease versions in range matching
-c --coerce
Coerce a string into SemVer if possible
(does not imply --loose)
--rtl
Coerce version strings right to left
--ltr
Coerce version strings left to right (default)
-n
Base number to be used for the prerelease identifier.
Can be either 0 or 1, or false to omit the number altogether.
Defaults to 0.
Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions.
If no satisfying versions are found, then exits failure.
Versions are printed in ascending order, so supplying
multiple versions to the utility will just sort them.
),
"signal": null,
}
`
exports[`test/bin/semver.js TAP help output > -? 1`] = `
Object {
"code": 0,
"err": "",
"out": String(
SemVer @@VERSION@@
A JavaScript implementation of the https://semver.org/ specification
Copyright Isaac Z. Schlueter
Usage: semver [options] [ [...]]
Prints valid versions sorted by SemVer precedence
Options:
-r --range
Print versions that match the specified range.
-i --increment []
Increment a version by the specified level. Level can
be one of: major, minor, patch, premajor, preminor,
prepatch, prerelease, or release. Default level is 'patch'.
Only one version may be specified.
--preid
Identifier to be used to prefix premajor, preminor,
prepatch or prerelease version increments.
-l --loose
Interpret versions and ranges loosely
-p --include-prerelease
Always include prerelease versions in range matching
-c --coerce
Coerce a string into SemVer if possible
(does not imply --loose)
--rtl
Coerce version strings right to left
--ltr
Coerce version strings left to right (default)
-n
Base number to be used for the prerelease identifier.
Can be either 0 or 1, or false to omit the number altogether.
Defaults to 0.
Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions.
If no satisfying versions are found, then exits failure.
Versions are printed in ascending order, so supplying
multiple versions to the utility will just sort them.
),
"signal": null,
}
`
exports[`test/bin/semver.js TAP help output > -h 1`] = `
Object {
"code": 0,
"err": "",
"out": String(
SemVer @@VERSION@@
A JavaScript implementation of the https://semver.org/ specification
Copyright Isaac Z. Schlueter
Usage: semver [options] [ [...]]
Prints valid versions sorted by SemVer precedence
Options:
-r --range
Print versions that match the specified range.
-i --increment []
Increment a version by the specified level. Level can
be one of: major, minor, patch, premajor, preminor,
prepatch, prerelease, or release. Default level is 'patch'.
Only one version may be specified.
--preid
Identifier to be used to prefix premajor, preminor,
prepatch or prerelease version increments.
-l --loose
Interpret versions and ranges loosely
-p --include-prerelease
Always include prerelease versions in range matching
-c --coerce
Coerce a string into SemVer if possible
(does not imply --loose)
--rtl
Coerce version strings right to left
--ltr
Coerce version strings left to right (default)
-n
Base number to be used for the prerelease identifier.
Can be either 0 or 1, or false to omit the number altogether.
Defaults to 0.
Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions.
If no satisfying versions are found, then exits failure.
Versions are printed in ascending order, so supplying
multiple versions to the utility will just sort them.
),
"signal": null,
}
`
exports[`test/bin/semver.js TAP inc tests > -i 1.2.3 1`] = `
Object {
"code": 0,
"err": "",
"out": "1.2.4\\n",
"signal": null,
}
`
exports[`test/bin/semver.js TAP inc tests > -i major 1.0.0 1`] = `
Object {
"code": 0,
"err": "",
"out": "2.0.0\\n",
"signal": null,
}
`
exports[`test/bin/semver.js TAP inc tests > -i major 1.0.0 1.0.1 1`] = `
Object {
"code": 1,
"err": "--inc can only be used on a single version with no range\\n",
"out": "",
"signal": null,
}
`
exports[`test/bin/semver.js TAP inc tests > -i premajor 1.0.0 --preid=beta -n 1 1`] = `
Object {
"code": 0,
"err": "",
"out": "2.0.0-beta.1\\n",
"signal": null,
}
`
exports[`test/bin/semver.js TAP inc tests > -i premajor 1.0.0 --preid=beta -n false 1`] = `
Object {
"code": 0,
"err": "",
"out": "2.0.0-beta\\n",
"signal": null,
}
`
exports[`test/bin/semver.js TAP inc tests > -i premajor 1.0.0 --preid=beta 1`] = `
Object {
"code": 0,
"err": "",
"out": "2.0.0-beta.0\\n",
"signal": null,
}
`
exports[`test/bin/semver.js TAP inc tests > -i release 1.0.0-pre 1`] = `
Object {
"code": 0,
"err": "",
"out": "1.0.0\\n",
"signal": null,
}
`
exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 -v 3.2.1 --version 2.3.4 -rv 1`] = `
Object {
"code": 0,
"err": "",
"out": String(
3.2.1
2.3.4
1.2.3
),
"signal": null,
}
`
exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 -v 3.2.1 --version 2.3.4 1`] = `
Object {
"code": 0,
"err": "",
"out": String(
1.2.3
2.3.4
3.2.1
),
"signal": null,
}
`
exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 3.2.1 -r 2.x 1`] = `
Object {
"code": 1,
"err": "",
"out": "",
"signal": null,
}
`
exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 3.2.1 -r 2.x 2.3.4 1`] = `
Object {
"code": 0,
"err": "",
"out": "2.3.4\\n",
"signal": null,
}
`
exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 3.2.1 2.3.4 1`] = `
Object {
"code": 0,
"err": "",
"out": String(
1.2.3
2.3.4
3.2.1
),
"signal": null,
}
`
exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 3.2.1 2.3.4 2.3.4-beta 1`] = `
Object {
"code": 0,
"err": "",
"out": String(
1.2.3
2.3.4-beta
2.3.4
3.2.1
),
"signal": null,
}
`
exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 3.2.1 2.3.4 2.3.4-beta 2.0.0asdf -r 2.x -p 1`] = `
Object {
"code": 0,
"err": "",
"out": String(
2.3.4-beta
2.3.4
),
"signal": null,
}
`
exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 3.2.1 2.3.4 2.3.4-beta 2.0.0asdf -r 2.x 1`] = `
Object {
"code": 0,
"err": "",
"out": "2.3.4\\n",
"signal": null,
}
`
exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3beta -l 1`] = `
Object {
"code": 0,
"err": "",
"out": "1.2.3-beta\\n",
"signal": null,
}
`
exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3foo 1.2.3-bar -l 1`] = `
Object {
"code": 0,
"err": "",
"out": String(
1.2.3-bar
1.2.3-foo
),
"signal": null,
}
`
exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3foo 1.2.3-bar 1`] = `
Object {
"code": 0,
"err": "",
"out": "1.2.3-bar\\n",
"signal": null,
}
`
exports[`test/bin/semver.js TAP sorting and filtering > 3.2.1 2.3.4 2.3.4-beta 2.0.0asdf -r 2.x -p -l 1`] = `
Object {
"code": 0,
"err": "",
"out": String(
2.0.0-asdf
2.3.4-beta
2.3.4
),
"signal": null,
}
`
npm-node-semver-5993c2e/test/ 0000775 0000000 0000000 00000000000 15141150374 0016053 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/test/bin/ 0000775 0000000 0000000 00000000000 15141150374 0016623 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/test/bin/semver.js 0000664 0000000 0000000 00000005525 15141150374 0020471 0 ustar 00root root 0000000 0000000 'use strict'
const t = require('tap')
const thisVersion = require('../../package.json').version
t.cleanSnapshot = str => str.split(thisVersion).join('@@VERSION@@')
const spawn = require('child_process').spawn
const bin = require.resolve('../../bin/semver')
const run = args => new Promise((resolve, reject) => {
const c = spawn(process.execPath, [bin].concat(args))
c.on('error', reject)
const out = []
const err = []
c.stdout.setEncoding('utf-8')
c.stdout.on('data', chunk => out.push(chunk))
c.stderr.setEncoding('utf-8')
c.stderr.on('data', chunk => err.push(chunk))
c.on('close', (code, signal) => {
resolve({
out: out.join(''),
err: err.join(''),
code: code,
signal: signal,
})
})
})
t.test('inc tests', t => Promise.all([
['-i', 'major', '1.0.0'],
['-i', 'major', '1.0.0', '1.0.1'],
['-i', 'premajor', '1.0.0', '--preid=beta'],
['-i', 'premajor', '1.0.0', '--preid=beta', '-n', '1'],
['-i', 'premajor', '1.0.0', '--preid=beta', '-n', 'false'],
['-i', '1.2.3'],
['-i', 'release', '1.0.0-pre'],
].map(args => t.resolveMatchSnapshot(run(args), args.join(' ')))))
t.test('help output', t => Promise.all([
['-h'],
['-?'],
['--help'],
[],
].map(h => t.resolveMatchSnapshot(run(h), h[0] || '(no args)'))))
t.test('sorting and filtering', t => Promise.all([
['1.2.3', '3.2.1', '2.3.4'],
['1.2.3', '3.2.1', '2.3.4', '2.3.4-beta'],
['1.2.3', '-v', '3.2.1', '--version', '2.3.4'],
['1.2.3', '-v', '3.2.1', '--version', '2.3.4', '-rv'],
['1.2.3foo', '1.2.3-bar'],
['1.2.3foo', '1.2.3-bar', '-l'],
['1.2.3beta', '-l'],
['1.2.3', '3.2.1', '-r', '2.x', '2.3.4'],
['1.2.3', '3.2.1', '2.3.4', '2.3.4-beta', '2.0.0asdf', '-r', '2.x'],
['1.2.3', '3.2.1', '2.3.4', '2.3.4-beta', '2.0.0asdf', '-r', '2.x', '-p'],
['3.2.1', '2.3.4', '2.3.4-beta', '2.0.0asdf', '-r', '2.x', '-p', '-l'],
['1.2.3', '3.2.1', '-r', '2.x'],
].map(args => t.resolveMatchSnapshot(run(args), args.join(' ')))))
t.test('coercing', t => Promise.all([
['1.2.3.4.5.6', '-c'],
['1.2.3.4.5.6', '-c', '--rtl'],
['1.2.3.4.5.6', '-c', '--rtl', '--ltr'],
['not a version', '1.2.3', '-c'],
['not a version', '-c'],
].map(args => t.resolveMatchSnapshot(run(args), args.join(' ')))))
t.test('args with equals', t => Promise.all([
[['--version', '1.2.3'], '1.2.3'],
[['--range', '1'], ['1.2.3'], ['2.3.4'], '1.2.3'],
[['--increment', 'major'], ['1.0.0'], '2.0.0'],
[['--increment', 'premajor'], ['--preid', 'beta'], ['1.0.0'], '2.0.0-beta.0'],
].map(async (args) => {
const expected = args.pop()
const equals = args.map((a) => a.join('='))
const spaces = args.reduce((acc, a) => acc.concat(a), [])
const res1 = await run(equals)
const res2 = await run(spaces)
t.equal(res1.signal, null)
t.equal(res1.code, 0)
t.equal(res1.err, '')
t.equal(res1.out.trim(), expected)
t.strictSame(res1, res2, args.join(' '))
})))
npm-node-semver-5993c2e/test/classes/ 0000775 0000000 0000000 00000000000 15141150374 0017510 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/test/classes/comparator.js 0000664 0000000 0000000 00000003447 15141150374 0022225 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const Comparator = require('../../classes/comparator')
const comparatorIntersection = require('../fixtures/comparator-intersection.js')
test('comparator testing', t => {
const c = new Comparator('>=1.2.3')
t.ok(c.test('1.2.4'))
const c2 = new Comparator(c)
t.ok(c2.test('1.2.4'))
const c3 = new Comparator(c, true)
t.ok(c3.test('1.2.4'))
// test an invalid version, should not throw
const c4 = new Comparator(c)
t.notOk(c4.test('not a version string'))
t.end()
})
test('tostrings', (t) => {
t.equal(new Comparator('>= v1.2.3').toString(), '>=1.2.3')
t.end()
})
test('intersect comparators', (t) => {
t.plan(comparatorIntersection.length)
comparatorIntersection.forEach(([c0, c1, expect, includePrerelease]) =>
t.test(`${c0} ${c1} ${expect}`, t => {
const comp0 = new Comparator(c0)
const comp1 = new Comparator(c1)
t.equal(comp0.intersects(comp1, { includePrerelease }), expect,
`${c0} intersects ${c1}`)
t.equal(comp1.intersects(comp0, { includePrerelease }), expect,
`${c1} intersects ${c0}`)
t.end()
}))
})
test('intersect demands another comparator', t => {
const c = new Comparator('>=1.2.3')
t.throws(() => c.intersects(), new TypeError('a Comparator is required'))
t.end()
})
test('ANY matches anything', t => {
const c = new Comparator('')
t.ok(c.test('1.2.3'), 'ANY matches anything')
const c1 = new Comparator('>=1.2.3')
const ANY = Comparator.ANY
t.ok(c1.test(ANY), 'anything matches ANY')
t.end()
})
test('invalid comparator parse throws', t => {
t.throws(() => new Comparator('foo bar baz'),
new TypeError('Invalid comparator: foo bar baz'))
t.end()
})
test('= is ignored', t => {
t.match(new Comparator('=1.2.3'), new Comparator('1.2.3'))
t.end()
})
npm-node-semver-5993c2e/test/classes/index.js 0000664 0000000 0000000 00000000374 15141150374 0021161 0 ustar 00root root 0000000 0000000 'use strict'
const t = require('tap')
t.same(require('../../classes'), {
SemVer: require('../../classes/semver'),
Range: require('../../classes/range'),
Comparator: require('../../classes/comparator'),
}, 'export all classes at semver/classes')
npm-node-semver-5993c2e/test/classes/range.js 0000664 0000000 0000000 00000007365 15141150374 0021155 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const Range = require('../../classes/range')
const Comparator = require('../../classes/comparator')
const rangeIntersection = require('../fixtures/range-intersection.js')
const rangeInclude = require('../fixtures/range-include.js')
const rangeExclude = require('../fixtures/range-exclude.js')
const rangeParse = require('../fixtures/range-parse.js')
test('range tests', t => {
t.plan(rangeInclude.length)
rangeInclude.forEach(([range, ver, options]) => {
const r = new Range(range, options)
t.ok(r.test(ver), `${range} satisfied by ${ver}`)
})
})
test('range parsing', t => {
t.plan(rangeParse.length)
rangeParse.forEach(([range, expect, options]) =>
t.test(`${range} ${expect} ${JSON.stringify(options)}`, t => {
if (expect === null) {
t.throws(() => new Range(range, options), TypeError, `invalid range: ${range}`)
} else {
t.equal(new Range(range, options).range || '*', expect, `${range} => ${expect}`)
t.equal(new Range(range, options).range, new Range(expect).range,
'parsing both yields same result')
}
t.end()
}))
})
test('throw for empty comparator set, even in loose mode', t => {
t.throws(() => new Range('sadf||asdf', { loose: true }),
TypeError('Invalid SemVer Range: sadf||asdf'))
t.end()
})
test('convert comparator to range', t => {
const c = new Comparator('>=1.2.3')
const r = new Range(c)
t.equal(r.raw, c.value, 'created range from comparator')
t.end()
})
test('range as argument to range ctor', t => {
const loose = new Range('1.2.3', { loose: true })
t.equal(new Range(loose, { loose: true }), loose, 'loose option')
t.equal(new Range(loose, true), loose, 'loose boolean')
t.not(new Range(loose), loose, 'created new range if not matched')
const incPre = new Range('1.2.3', { includePrerelease: true })
t.equal(new Range(incPre, { includePrerelease: true }), incPre,
'include prerelease, option match returns argument')
t.not(new Range(incPre), incPre,
'include prerelease, option mismatch does not return argument')
t.end()
})
test('negative range tests', t => {
t.plan(rangeExclude.length)
rangeExclude.forEach(([range, ver, options]) => {
const r = new Range(range, options)
t.notOk(r.test(ver), `${range} not satisfied by ${ver}`)
})
})
test('strict vs loose ranges', (t) => {
[
['>=01.02.03', '>=1.2.3'],
['~1.02.03beta', '>=1.2.3-beta <1.3.0-0'],
].forEach(([loose, comps]) => {
t.throws(() => new Range(loose))
t.equal(new Range(loose, true).range, comps)
})
t.end()
})
test('tostrings', (t) => {
t.equal(new Range('>= v1.2.3').toString(), '>=1.2.3')
t.end()
})
test('formatted value is calculated lazily and cached', (t) => {
const r = new Range('>= v1.2.3')
t.equal(r.formatted, undefined)
t.equal(r.format(), '>=1.2.3')
t.equal(r.formatted, '>=1.2.3')
t.equal(r.format(), '>=1.2.3')
t.end()
})
test('ranges intersect', (t) => {
rangeIntersection.forEach(([r0, r1, expect]) => {
t.test(`${r0} <~> ${r1}`, t => {
const range0 = new Range(r0)
const range1 = new Range(r1)
t.equal(range0.intersects(range1), expect,
`${r0} <~> ${r1} objects`)
t.equal(range1.intersects(range0), expect,
`${r1} <~> ${r0} objects`)
t.end()
})
})
t.end()
})
test('missing range parameter in range intersect', (t) => {
t.throws(() => {
new Range('1.0.0').intersects()
}, new TypeError('a Range is required'),
'throws type error')
t.end()
})
test('cache', (t) => {
const cached = Symbol('cached')
const r1 = new Range('1.0.0')
r1.set[0][cached] = true
const r2 = new Range('1.0.0')
t.equal(r1.set[0][cached], true)
t.equal(r2.set[0][cached], true) // Will be true, showing it's cached.
t.end()
})
npm-node-semver-5993c2e/test/classes/semver.js 0000664 0000000 0000000 00000012273 15141150374 0021354 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const SemVer = require('../../classes/semver')
const increments = require('../fixtures/increments.js')
const comparisons = require('../fixtures/comparisons.js')
const equality = require('../fixtures/equality.js')
const invalidVersions = require('../fixtures/invalid-versions.js')
const validVersions = require('../fixtures/valid-versions.js')
test('valid versions', t => {
t.plan(validVersions.length)
validVersions.forEach(([v, major, minor, patch, prerelease, build]) => t.test(v, t => {
const s = new SemVer(v)
t.strictSame(s.major, major)
t.strictSame(s.minor, minor)
t.strictSame(s.patch, patch)
t.strictSame(s.prerelease, prerelease)
t.strictSame(s.build, build)
t.strictSame(s.raw, v)
t.end()
}))
})
test('comparisons', t => {
t.plan(comparisons.length)
comparisons.forEach(([v0, v1, opt]) => t.test(`${v0} ${v1}`, t => {
const s0 = new SemVer(v0, opt)
const s1 = new SemVer(v1, opt)
t.equal(s0.compare(s1), 1)
t.equal(s0.compare(v1), 1)
t.equal(s1.compare(s0), -1)
t.equal(s1.compare(v0), -1)
t.equal(s0.compare(v0), 0)
t.equal(s1.compare(v1), 0)
t.end()
}))
})
test('equality', t => {
t.plan(equality.length)
equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
const s0 = new SemVer(v0, loose)
const s1 = new SemVer(v1, loose)
t.equal(s0.compare(s1), 0)
t.equal(s1.compare(s0), 0)
t.equal(s0.compare(v1), 0)
t.equal(s1.compare(v0), 0)
t.equal(s0.compare(s0), 0)
t.equal(s1.compare(s1), 0)
t.equal(s0.comparePre(s1), 0, 'comparePre just to hit that code path')
t.end()
}))
})
test('toString equals parsed version', t => {
t.equal(String(new SemVer('v1.2.3')), '1.2.3')
t.end()
})
test('throws when presented with garbage', t => {
t.plan(invalidVersions.length)
invalidVersions.forEach(([v, msg, opts]) =>
t.throws(() => new SemVer(v, opts), msg))
})
test('return SemVer arg to ctor if options match', t => {
const s = new SemVer('1.2.3', { loose: true, includePrerelease: true })
t.equal(new SemVer(s, { loose: true, includePrerelease: true }), s,
'get same object when options match')
t.not(new SemVer(s), s, 'get new object when options match')
t.end()
})
test('really big numeric prerelease value', (t) => {
const r = new SemVer(`1.2.3-beta.${Number.MAX_SAFE_INTEGER}0`)
t.strictSame(r.prerelease, ['beta', '90071992547409910'])
t.end()
})
test('invalid version numbers', (t) => {
['1.2.3.4', 'NOT VALID', 1.2, null, 'Infinity.NaN.Infinity'].forEach((v) => {
t.throws(
() => {
new SemVer(v) // eslint-disable-line no-new
},
{
name: 'TypeError',
message:
typeof v === 'string'
? `Invalid Version: ${v}`
: `Invalid version. Must be a string. Got type "${typeof v}".`,
}
)
})
t.end()
})
test('incrementing', t => {
t.plan(increments.length)
increments.forEach(([
version,
inc,
expect,
options,
id,
base,
]) => t.test(`${version} ${inc} ${id || ''}`.trim(), t => {
if (expect === null) {
t.plan(1)
t.throws(() => new SemVer(version, options).inc(inc, id, base))
} else {
t.plan(2)
const incremented = new SemVer(version, options).inc(inc, id, base)
t.equal(incremented.version, expect)
if (incremented.build.length) {
t.equal(incremented.raw, `${expect}+${incremented.build.join('.')}`)
} else {
t.equal(incremented.raw, expect)
}
}
}))
})
test('invalid increments', (t) => {
t.throws(
() => new SemVer('1.2.3').inc('prerelease', '', false),
Error('invalid increment argument: identifier is empty')
)
t.throws(
() => new SemVer('1.2.3-dev').inc('prerelease', 'dev', false),
Error('invalid increment argument: identifier already exists')
)
t.throws(
() => new SemVer('1.2.3').inc('prerelease', 'invalid/preid'),
Error('invalid identifier: invalid/preid')
)
t.end()
})
test('increment side-effects', (t) => {
const v = new SemVer('1.0.0')
try {
v.inc('prerelease', 'hot/mess')
} catch (er) {
// ignore but check that the version has not changed
}
t.equal(v.toString(), '1.0.0')
t.end()
})
test('compare main vs pre', (t) => {
const s = new SemVer('1.2.3')
t.equal(s.compareMain('2.3.4'), -1)
t.equal(s.compareMain('1.2.4'), -1)
t.equal(s.compareMain('0.1.2'), 1)
t.equal(s.compareMain('1.2.2'), 1)
t.equal(s.compareMain('1.2.3-pre'), 0)
const p = new SemVer('1.2.3-alpha.0.pr.1')
t.equal(p.comparePre('9.9.9-alpha.0.pr.1'), 0)
t.equal(p.comparePre('1.2.3'), -1)
t.equal(p.comparePre('1.2.3-alpha.0.pr.2'), -1)
t.equal(p.comparePre('1.2.3-alpha.0.2'), 1)
t.end()
})
test('compareBuild', (t) => {
const noBuild = new SemVer('1.0.0')
const build0 = new SemVer('1.0.0+0')
const build1 = new SemVer('1.0.0+1')
const build10 = new SemVer('1.0.0+1.0')
t.equal(noBuild.compareBuild(build0), -1)
t.equal(build0.compareBuild(build0), 0)
t.equal(build0.compareBuild(noBuild), 1)
t.equal(build0.compareBuild('1.0.0+0.0'), -1)
t.equal(build0.compareBuild(build1), -1)
t.equal(build1.compareBuild(build0), 1)
t.equal(build10.compareBuild(build1), 1)
t.end()
})
npm-node-semver-5993c2e/test/fixtures/ 0000775 0000000 0000000 00000000000 15141150374 0017724 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/test/fixtures/comparator-intersection.js 0000664 0000000 0000000 00000002446 15141150374 0025143 0 ustar 00root root 0000000 0000000 'use strict'
// c0, c1, expected intersection, includePrerelease
module.exports = [
// One is a Version
['1.3.0', '>=1.3.0', true],
['1.3.0', '>1.3.0', false],
['>=1.3.0', '1.3.0', true],
['>1.3.0', '1.3.0', false],
// Same direction increasing
['>1.3.0', '>1.2.0', true],
['>1.2.0', '>1.3.0', true],
['>=1.2.0', '>1.3.0', true],
['>1.2.0', '>=1.3.0', true],
// Same direction decreasing
['<1.3.0', '<1.2.0', true],
['<1.2.0', '<1.3.0', true],
['<=1.2.0', '<1.3.0', true],
['<1.2.0', '<=1.3.0', true],
// Different directions, same semver and inclusive operator
['>=1.3.0', '<=1.3.0', true],
['>=v1.3.0', '<=1.3.0', true],
['>=1.3.0', '>=1.3.0', true],
['<=1.3.0', '<=1.3.0', true],
['<=1.3.0', '<=v1.3.0', true],
['>1.3.0', '<=1.3.0', false],
['>=1.3.0', '<1.3.0', false],
// Opposite matching directions
['>1.0.0', '<2.0.0', true],
['>=1.0.0', '<2.0.0', true],
['>=1.0.0', '<=2.0.0', true],
['>1.0.0', '<=2.0.0', true],
['<=2.0.0', '>1.0.0', true],
['<=1.0.0', '>=2.0.0', false],
['', '', true],
['', '>1.0.0', true],
['<=2.0.0', '', true],
['<0.0.0', '<0.1.0', false],
['<0.1.0', '<0.0.0', false],
['<0.0.0-0', '<0.1.0', false],
['<0.1.0', '<0.0.0-0', false],
['<0.0.0-0', '<0.1.0', false, true],
['<0.1.0', '<0.0.0-0', false, true],
]
npm-node-semver-5993c2e/test/fixtures/comparisons.js 0000664 0000000 0000000 00000002065 15141150374 0022622 0 ustar 00root root 0000000 0000000 'use strict'
// [version1, version2]
// version1 should be greater than version2
// used by the cmp, eq, gt, lt, and neq tests
module.exports = [
['0.0.0', '0.0.0-foo'],
['0.0.1', '0.0.0'],
['1.0.0', '0.9.9'],
['0.10.0', '0.9.0'],
['0.99.0', '0.10.0', {}],
['2.0.0', '1.2.3', { loose: false }],
['v0.0.0', '0.0.0-foo', true],
['v0.0.1', '0.0.0', { loose: true }],
['v1.0.0', '0.9.9', true],
['v0.10.0', '0.9.0', true],
['v0.99.0', '0.10.0', true],
['v2.0.0', '1.2.3', true],
['0.0.0', 'v0.0.0-foo', true],
['0.0.1', 'v0.0.0', true],
['1.0.0', 'v0.9.9', true],
['0.10.0', 'v0.9.0', true],
['0.99.0', 'v0.10.0', true],
['2.0.0', 'v1.2.3', true],
['1.2.3', '1.2.3-asdf'],
['1.2.3', '1.2.3-4'],
['1.2.3', '1.2.3-4-foo'],
['1.2.3-5-foo', '1.2.3-5'],
['1.2.3-5', '1.2.3-4'],
['1.2.3-5-foo', '1.2.3-5-Foo'],
['3.0.0', '2.7.2+asdf'],
['1.2.3-a.10', '1.2.3-a.5'],
['1.2.3-a.b', '1.2.3-a.5'],
['1.2.3-a.b', '1.2.3-a'],
['1.2.3-a.b.c.10.d.5', '1.2.3-a.b.c.5.d.100'],
['1.2.3-r2', '1.2.3-r100'],
['1.2.3-r100', '1.2.3-R2'],
]
npm-node-semver-5993c2e/test/fixtures/equality.js 0000664 0000000 0000000 00000002644 15141150374 0022125 0 ustar 00root root 0000000 0000000 'use strict'
// [version1, version2]
// version1 should be equivalent to version2
module.exports = [
['1.2.3', 'v1.2.3', true],
['1.2.3', '=1.2.3', true],
['1.2.3', 'v 1.2.3', true],
['1.2.3', '= 1.2.3', true],
['1.2.3', ' v1.2.3', true],
['1.2.3', ' =1.2.3', true],
['1.2.3', ' v 1.2.3', true],
['1.2.3', ' = 1.2.3', true],
['1.2.3-0', 'v1.2.3-0', true],
['1.2.3-0', '=1.2.3-0', true],
['1.2.3-0', 'v 1.2.3-0', true],
['1.2.3-0', '= 1.2.3-0', true],
['1.2.3-0', ' v1.2.3-0', true],
['1.2.3-0', ' =1.2.3-0', true],
['1.2.3-0', ' v 1.2.3-0', true],
['1.2.3-0', ' = 1.2.3-0', true],
['1.2.3-1', 'v1.2.3-1', true],
['1.2.3-1', '=1.2.3-1', true],
['1.2.3-1', 'v 1.2.3-1', true],
['1.2.3-1', '= 1.2.3-1', true],
['1.2.3-1', ' v1.2.3-1', true],
['1.2.3-1', ' =1.2.3-1', true],
['1.2.3-1', ' v 1.2.3-1', true],
['1.2.3-1', ' = 1.2.3-1', true],
['1.2.3-beta', 'v1.2.3-beta', true],
['1.2.3-beta', '=1.2.3-beta', true],
['1.2.3-beta', 'v 1.2.3-beta', true],
['1.2.3-beta', '= 1.2.3-beta', true],
['1.2.3-beta', ' v1.2.3-beta', true],
['1.2.3-beta', ' =1.2.3-beta', true],
['1.2.3-beta', ' v 1.2.3-beta', true],
['1.2.3-beta', ' = 1.2.3-beta', true],
['1.2.3-beta+build', ' = 1.2.3-beta+otherbuild', true],
['1.2.3+build', ' = 1.2.3+otherbuild', true],
['1.2.3-beta+build', '1.2.3-beta+otherbuild'],
['1.2.3+build', '1.2.3+otherbuild'],
[' v1.2.3+build', '1.2.3+otherbuild'],
]
npm-node-semver-5993c2e/test/fixtures/increments.js 0000664 0000000 0000000 00000016406 15141150374 0022440 0 ustar 00root root 0000000 0000000 'use strict'
// [version, inc, result, options, identifier, identifierBase]
// inc(version, inc, options, identifier, identifierBase) -> result
module.exports = [
['1.2.3', 'major', '2.0.0'],
['1.2.3', 'minor', '1.3.0'],
['1.2.3', 'patch', '1.2.4'],
['1.2.3tag', 'major', '2.0.0', true],
['1.2.3-tag', 'major', '2.0.0'],
['1.2.3', 'fake', null],
['1.2.0-0', 'patch', '1.2.0'],
['fake', 'major', null],
['1.2.3-4', 'major', '2.0.0'],
['1.2.3-4', 'minor', '1.3.0'],
['1.2.3-4', 'patch', '1.2.3'],
['1.2.3-alpha.0.beta', 'major', '2.0.0'],
['1.2.3-alpha.0.beta', 'minor', '1.3.0'],
['1.2.3-alpha.0.beta', 'patch', '1.2.3'],
['1.2.4', 'prerelease', '1.2.5-0'],
['1.2.3-0', 'prerelease', '1.2.3-1'],
['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1'],
['1.2.3-alpha.1', 'prerelease', '1.2.3-alpha.2'],
['1.2.3-alpha.2', 'prerelease', '1.2.3-alpha.3'],
['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta'],
['1.2.3-alpha.1.beta', 'prerelease', '1.2.3-alpha.2.beta'],
['1.2.3-alpha.2.beta', 'prerelease', '1.2.3-alpha.3.beta'],
['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta'],
['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta'],
['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta'],
['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1'],
['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2'],
['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3'],
['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta'],
['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta'],
['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta'],
['1.0.0', 'prepatch', '1.0.1-alpha.1.1a.0', null, 'alpha.1.1a'],
['1.2.0', 'prepatch', '1.2.1-0'],
['1.2.0-1', 'prepatch', '1.2.1-0'],
['1.2.0', 'preminor', '1.3.0-0'],
['1.2.3-1', 'preminor', '1.3.0-0'],
['1.2.0', 'premajor', '2.0.0-0'],
['1.2.3-1', 'premajor', '2.0.0-0'],
['1.2.0-1', 'minor', '1.2.0'],
['1.0.0-1', 'major', '1.0.0'],
['1.0.0-1', 'release', '1.0.0'],
['1.2.0-1', 'release', '1.2.0'],
['1.2.3-1', 'release', '1.2.3'],
['1.2.3', 'release', null],
// [version, inc, result, identifierIndex, loose, identifier]
['1.2.3', 'major', '2.0.0', false, 'dev'],
['1.2.3', 'minor', '1.3.0', false, 'dev'],
['1.2.3', 'patch', '1.2.4', false, 'dev'],
['1.2.3tag', 'major', '2.0.0', true, 'dev'],
['1.2.3-tag', 'major', '2.0.0', false, 'dev'],
['1.2.3', 'fake', null, false, 'dev'],
['1.2.0-0', 'patch', '1.2.0', false, 'dev'],
['fake', 'major', null, false, 'dev'],
['1.2.3-4', 'major', '2.0.0', false, 'dev'],
['1.2.3-4', 'minor', '1.3.0', false, 'dev'],
['1.2.3-4', 'patch', '1.2.3', false, 'dev'],
['1.2.3-alpha.0.beta', 'major', '2.0.0', false, 'dev'],
['1.2.3-alpha.0.beta', 'minor', '1.3.0', false, 'dev'],
['1.2.3-alpha.0.beta', 'patch', '1.2.3', false, 'dev'],
['1.2.4', 'prerelease', '1.2.5-dev.0', false, 'dev'],
['1.2.3-0', 'prerelease', '1.2.3-dev.0', false, 'dev'],
['1.2.3-alpha.0', 'prerelease', '1.2.3-dev.0', false, 'dev'],
['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1', false, 'alpha'],
['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'],
['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta', false, 'alpha'],
['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'],
['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta', false, 'alpha'],
['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta', false, 'alpha'],
['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta', false, 'alpha'],
['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-dev.0', false, 'dev'],
['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1', false, 'alpha'],
['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2', false, 'alpha'],
['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3', false, 'alpha'],
['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'],
['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta', false, 'alpha'],
['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta', false, 'alpha'],
['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta', false, 'alpha'],
['1.2.0', 'prepatch', '1.2.1-dev.0', false, 'dev'],
['1.2.0-1', 'prepatch', '1.2.1-dev.0', false, 'dev'],
['1.2.0', 'preminor', '1.3.0-dev.0', false, 'dev'],
['1.2.3-1', 'preminor', '1.3.0-dev.0', false, 'dev'],
['1.2.0', 'premajor', '2.0.0-dev.0', false, 'dev'],
['1.2.3-1', 'premajor', '2.0.0-dev.0', false, 'dev'],
['1.2.3-1', 'premajor', '2.0.0-dev.1', false, 'dev', 1],
['1.2.0-1', 'minor', '1.2.0', false, 'dev'],
['1.0.0-1', 'major', '1.0.0', 'dev'],
['1.2.3-dev.bar', 'prerelease', '1.2.3-dev.0', false, 'dev'],
['1.2.3-0', 'prerelease', '1.2.3-1.0', false, '1'],
['1.2.3-1.0', 'prerelease', '1.2.3-1.1', false, '1'],
['1.2.3-1.1', 'prerelease', '1.2.3-1.2', false, '1'],
['1.2.3-1.1', 'prerelease', '1.2.3-2.0', false, '2'],
// [version, inc, result, identifierIndex, loose, identifier, identifierBase]
['1.2.0-1', 'prerelease', '1.2.0-alpha.0', false, 'alpha', '0'],
['1.2.1', 'prerelease', '1.2.2-alpha.0', false, 'alpha', '0'],
['0.2.0', 'prerelease', '0.2.1-alpha.0', false, 'alpha', '0'],
['1.2.2', 'prerelease', '1.2.3-alpha.1', false, 'alpha', '1'],
['1.2.3', 'prerelease', '1.2.4-alpha.1', false, 'alpha', '1'],
['1.2.4', 'prerelease', '1.2.5-alpha.1', false, 'alpha', '1'],
['1.2.0', 'prepatch', '1.2.1-dev.1', false, 'dev', '1'],
['1.2.0-1', 'prepatch', '1.2.1-dev.1', false, 'dev', '1'],
['1.2.0', 'premajor', '2.0.0-dev.0', false, 'dev', '0'],
['1.2.3-1', 'premajor', '2.0.0-dev.0', false, 'dev', '0'],
['1.2.3-dev.bar', 'prerelease', '1.2.3-dev.0', false, 'dev', '0'],
['1.2.3-dev.bar', 'prerelease', '1.2.3-dev.1', false, 'dev', '1'],
['1.2.3-dev.bar', 'prerelease', '1.2.3-dev.bar.0', false, '', '0'],
['1.2.3-dev.bar', 'prerelease', '1.2.3-dev.bar.1', false, '', '1'],
['1.2.0', 'preminor', '1.3.0-dev.1', false, 'dev', '1'],
['1.2.3-1', 'preminor', '1.3.0-dev.0', false, 'dev'],
['1.2.0', 'prerelease', '1.2.1-1', false, '', '1'],
['1.2.0-1', 'prerelease', '1.2.0-alpha', false, 'alpha', false],
['1.2.1', 'prerelease', '1.2.2-alpha', false, 'alpha', false],
['1.2.2', 'prerelease', '1.2.3-alpha', false, 'alpha', false],
['1.2.0', 'prepatch', '1.2.1-dev', false, 'dev', false],
['1.2.0-1', 'prepatch', '1.2.1-dev', false, 'dev', false],
['1.2.0', 'premajor', '2.0.0-dev', false, 'dev', false],
['1.2.3-1', 'premajor', '2.0.0-dev', false, 'dev', false],
['1.2.3-dev.bar', 'prerelease', '1.2.3-dev', false, 'dev', false],
['1.2.3-dev.bar', 'prerelease', '1.2.3-dev.baz', false, 'dev.baz', false],
['1.2.0', 'preminor', '1.3.0-dev', false, 'dev', false],
['1.2.3-1', 'preminor', '1.3.0-dev', false, 'dev', false],
['1.2.3-dev', 'prerelease', null, false, 'dev', false],
['1.2.0-dev', 'premajor', '2.0.0-dev', false, 'dev', false],
['1.2.0-dev', 'preminor', '1.3.0-beta', false, 'beta', false],
['1.2.0-dev', 'prepatch', '1.2.1-dev', false, 'dev', false],
['1.2.0', 'prerelease', null, false, '', false],
['1.0.0-rc.1+build.4', 'prerelease', '1.0.0-rc.2', 'rc', false],
['1.2.0', 'prerelease', null, false, 'invalid/preid'],
['1.2.0', 'prerelease', null, false, 'invalid+build'],
['1.2.0beta', 'prerelease', null, { loose: true }, 'invalid/preid'],
]
npm-node-semver-5993c2e/test/fixtures/invalid-versions.js 0000664 0000000 0000000 00000001233 15141150374 0023555 0 ustar 00root root 0000000 0000000 'use strict'
// none of these are semvers
// [value, reason, opt]
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../../internal/constants')
module.exports = [
[new Array(MAX_LENGTH).join('1') + '.0.0', 'too long'],
[`${MAX_SAFE_INTEGER}0.0.0`, 'too big'],
[`0.${MAX_SAFE_INTEGER}0.0`, 'too big'],
[`0.0.${MAX_SAFE_INTEGER}0`, 'too big'],
['hello, world', 'not a version'],
['hello, world', 'even loose, its still junk', true],
['xyz', 'even loose as an opt, same', { loose: true }],
[/a regexp/, 'regexp is not a string'],
[/1.2.3/, 'semver-ish regexp is not a string'],
[{ toString: () => '1.2.3' }, 'obj with a tostring is not a string'],
]
npm-node-semver-5993c2e/test/fixtures/range-exclude.js 0000664 0000000 0000000 00000006041 15141150374 0023006 0 ustar 00root root 0000000 0000000 'use strict'
// [range, version, options]
// version should not be included by range
module.exports = [
['1.0.0 - 2.0.0', '2.2.3'],
['1.2.3+asdf - 2.4.3+asdf', '1.2.3-pre.2'],
['1.2.3+asdf - 2.4.3+asdf', '2.4.3-alpha'],
['^1.2.3+build', '2.0.0'],
['^1.2.3+build', '1.2.0'],
['^1.2.3', '1.2.3-pre'],
['^1.2', '1.2.0-pre'],
['>1.2', '1.3.0-beta'],
['<=1.2.3', '1.2.3-beta'],
['^1.2.3', '1.2.3-beta'],
['=0.7.x', '0.7.0-asdf'],
['>=0.7.x', '0.7.0-asdf'],
['<=0.7.x', '0.7.0-asdf'],
['1', '1.0.0beta', { loose: 420 }],
['<1', '1.0.0beta', true],
['< 1', '1.0.0beta', true],
['1.0.0', '1.0.1'],
['>=1.0.0', '0.0.0'],
['>=1.0.0', '0.0.1'],
['>=1.0.0', '0.1.0'],
['>1.0.0', '0.0.1'],
['>1.0.0', '0.1.0'],
['<=2.0.0', '3.0.0'],
['<=2.0.0', '2.9999.9999'],
['<=2.0.0', '2.2.9'],
['<2.0.0', '2.9999.9999'],
['<2.0.0', '2.2.9'],
['>=0.1.97', 'v0.1.93', true],
['>=0.1.97', '0.1.93'],
['0.1.20 || 1.2.4', '1.2.3'],
['>=0.2.3 || <0.0.1', '0.0.3'],
['>=0.2.3 || <0.0.1', '0.2.2'],
['2.x.x', '1.1.3', { loose: NaN }],
['2.x.x', '3.1.3'],
['1.2.x', '1.3.3'],
['1.2.x || 2.x', '3.1.3'],
['1.2.x || 2.x', '1.1.3'],
['2.*.*', '1.1.3'],
['2.*.*', '3.1.3'],
['1.2.*', '1.3.3'],
['1.2.* || 2.*', '3.1.3'],
['1.2.* || 2.*', '1.1.3'],
['2', '1.1.2'],
['2.3', '2.4.1'],
['~0.0.1', '0.1.0-alpha'],
['~0.0.1', '0.1.0'],
['~2.4', '2.5.0'], // >=2.4.0 <2.5.0
['~2.4', '2.3.9'],
['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0
['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0
['~1', '0.2.3'], // >=1.0.0 <2.0.0
['~>1', '2.2.3'],
['~1.0', '1.1.0'], // >=1.0.0 <1.1.0
['<1', '1.0.0'],
['>=1.2', '1.1.1'],
['1', '2.0.0beta', true],
['~v0.5.4-beta', '0.5.4-alpha'],
['=0.7.x', '0.8.2'],
['>=0.7.x', '0.6.2'],
['<0.7.x', '0.7.2'],
['<1.2.3', '1.2.3-beta'],
['=1.2.3', '1.2.3-beta'],
['>1.2', '1.2.8'],
['^0.0.1', '0.0.2-alpha'],
['^0.0.1', '0.0.2'],
['^1.2.3', '2.0.0-alpha'],
['^1.2.3', '1.2.2'],
['^1.2', '1.1.9'],
['*', 'v1.2.3-foo', true],
// invalid versions never satisfy, but shouldn't throw
['*', 'not a version'],
['>=2', 'glorp'],
['>=2', false],
['2.x', '3.0.0-pre.0', { includePrerelease: true }],
['^1.0.0', '1.0.0-rc1', { includePrerelease: true }],
['^1.0.0', '2.0.0-rc1', { includePrerelease: true }],
['^1.2.3-rc2', '2.0.0', { includePrerelease: true }],
['^1.0.0', '2.0.0-rc1'],
['1 - 2', '3.0.0-pre', { includePrerelease: true }],
['1 - 2', '2.0.0-pre'],
['1 - 2', '1.0.0-pre'],
['1.0 - 2', '1.0.0-pre'],
['1.1.x', '1.0.0-a'],
['1.1.x', '1.1.0-a'],
['1.1.x', '1.2.0-a'],
['1.1.x', '1.2.0-a', { includePrerelease: true }],
['1.1.x', '1.0.0-a', { includePrerelease: true }],
['1.x', '1.0.0-a'],
['1.x', '1.1.0-a'],
['1.x', '1.2.0-a'],
['1.x', '0.0.0-a', { includePrerelease: true }],
['1.x', '2.0.0-a', { includePrerelease: true }],
['>=1.0.0 <1.1.0', '1.1.0'],
['>=1.0.0 <1.1.0', '1.1.0', { includePrerelease: true }],
['>=1.0.0 <1.1.0', '1.1.0-pre'],
['>=1.0.0 <1.1.0-pre', '1.1.0-pre'],
['== 1.0.0 || foo', '2.0.0', { loose: true }],
]
npm-node-semver-5993c2e/test/fixtures/range-include.js 0000664 0000000 0000000 00000007724 15141150374 0023011 0 ustar 00root root 0000000 0000000 'use strict'
// [range, version, options]
// version should be included by range
module.exports = [
['1.0.0 - 2.0.0', '1.2.3'],
['^1.2.3+build', '1.2.3'],
['^1.2.3+build', '1.3.0'],
['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3'],
['1.2.3pre+asdf - 2.4.3-pre+asdf', '1.2.3', true],
['1.2.3-pre+asdf - 2.4.3pre+asdf', '1.2.3', true],
['1.2.3pre+asdf - 2.4.3pre+asdf', '1.2.3', true],
['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3-pre.2'],
['1.2.3-pre+asdf - 2.4.3-pre+asdf', '2.4.3-alpha'],
['1.2.3+asdf - 2.4.3+asdf', '1.2.3'],
['1.0.0', '1.0.0'],
['>=*', '0.2.4'],
['', '1.0.0'],
['*', '1.2.3', {}],
['*', 'v1.2.3', { loose: 123 }],
['>=1.0.0', '1.0.0', /asdf/],
['>=1.0.0', '1.0.1', { loose: null }],
['>=1.0.0', '1.1.0', { loose: 0 }],
['>1.0.0', '1.0.1', { loose: undefined }],
['>1.0.0', '1.1.0'],
['<=2.0.0', '2.0.0'],
['<=2.0.0', '1.9999.9999'],
['<=2.0.0', '0.2.9'],
['<2.0.0', '1.9999.9999'],
['<2.0.0', '0.2.9'],
['>= 1.0.0', '1.0.0'],
['>= 1.0.0', '1.0.1'],
['>= 1.0.0', '1.1.0'],
['> 1.0.0', '1.0.1'],
['> 1.0.0', '1.1.0'],
['<= 2.0.0', '2.0.0'],
['<= 2.0.0', '1.9999.9999'],
['<= 2.0.0', '0.2.9'],
['< 2.0.0', '1.9999.9999'],
['<\t2.0.0', '0.2.9'],
['>=0.1.97', 'v0.1.97', true],
['>=0.1.97', '0.1.97'],
['0.1.20 || 1.2.4', '1.2.4'],
['>=0.2.3 || <0.0.1', '0.0.0'],
['>=0.2.3 || <0.0.1', '0.2.3'],
['>=0.2.3 || <0.0.1', '0.2.4'],
['||', '1.3.4'],
['2.x.x', '2.1.3'],
['1.2.x', '1.2.3'],
['1.2.x || 2.x', '2.1.3'],
['1.2.x || 2.x', '1.2.3'],
['x', '1.2.3'],
['2.*.*', '2.1.3'],
['1.2.*', '1.2.3'],
['1.2.* || 2.*', '2.1.3'],
['1.2.* || 2.*', '1.2.3'],
['*', '1.2.3'],
['2', '2.1.2'],
['2.3', '2.3.1'],
['~0.0.1', '0.0.1'],
['~0.0.1', '0.0.2'],
['~x', '0.0.9'], // >=2.4.0 <2.5.0
['~2', '2.0.9'], // >=2.4.0 <2.5.0
['~2.4', '2.4.0'], // >=2.4.0 <2.5.0
['~2.4', '2.4.5'],
['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0,
['~1', '1.2.3'], // >=1.0.0 <2.0.0
['~>1', '1.2.3'],
['~> 1', '1.2.3'],
['~1.0', '1.0.2'], // >=1.0.0 <1.1.0,
['~ 1.0', '1.0.2'],
['~ 1.0.3', '1.0.12'],
['~ 1.0.3alpha', '1.0.12', { loose: true }],
['>=1', '1.0.0'],
['>= 1', '1.0.0'],
['<1.2', '1.1.1'],
['< 1.2', '1.1.1'],
['~v0.5.4-pre', '0.5.5'],
['~v0.5.4-pre', '0.5.4'],
['=0.7.x', '0.7.2'],
['<=0.7.x', '0.7.2'],
['>=0.7.x', '0.7.2'],
['<=0.7.x', '0.6.2'],
['~1.2.1 >=1.2.3', '1.2.3'],
['~1.2.1 =1.2.3', '1.2.3'],
['~1.2.1 1.2.3', '1.2.3'],
['~1.2.1 >=1.2.3 1.2.3', '1.2.3'],
['~1.2.1 1.2.3 >=1.2.3', '1.2.3'],
['>=1.2.1 1.2.3', '1.2.3'],
['1.2.3 >=1.2.1', '1.2.3'],
['>=1.2.3 >=1.2.1', '1.2.3'],
['>=1.2.1 >=1.2.3', '1.2.3'],
['>=1.2', '1.2.8'],
['^1.2.3', '1.8.1'],
['^0.1.2', '0.1.2'],
['^0.1', '0.1.2'],
['^0.0.1', '0.0.1'],
['^1.2', '1.4.2'],
['^1.2 ^1', '1.4.2'],
['^1.2.3-alpha', '1.2.3-pre'],
['^1.2.0-alpha', '1.2.0-pre'],
['^0.0.1-alpha', '0.0.1-beta'],
['^0.0.1-alpha', '0.0.1'],
['^0.1.1-alpha', '0.1.1-beta'],
['^x', '1.2.3'],
['x - 1.0.0', '0.9.7'],
['x - 1.x', '0.9.7'],
['1.0.0 - x', '1.9.7'],
['1.x - x', '1.9.7'],
['<=7.x', '7.9.9'],
['2.x', '2.0.0-pre.0', { includePrerelease: true }],
['2.x', '2.1.0-pre.0', { includePrerelease: true }],
['1.1.x', '1.1.0-a', { includePrerelease: true }],
['1.1.x', '1.1.1-a', { includePrerelease: true }],
['*', '1.0.0-rc1', { includePrerelease: true }],
['^1.0.0-0', '1.0.1-rc1', { includePrerelease: true }],
['^1.0.0-rc2', '1.0.1-rc1', { includePrerelease: true }],
['^1.0.0', '1.0.1-rc1', { includePrerelease: true }],
['^1.0.0', '1.1.0-rc1', { includePrerelease: true }],
['1 - 2', '2.0.0-pre', { includePrerelease: true }],
['1 - 2', '1.0.0-pre', { includePrerelease: true }],
['1.0 - 2', '1.0.0-pre', { includePrerelease: true }],
['=0.7.x', '0.7.0-asdf', { includePrerelease: true }],
['>=0.7.x', '0.7.0-asdf', { includePrerelease: true }],
['<=0.7.x', '0.7.0-asdf', { includePrerelease: true }],
['>=1.0.0 <=1.1.0', '1.1.0-pre', { includePrerelease: true }],
]
npm-node-semver-5993c2e/test/fixtures/range-intersection.js 0000664 0000000 0000000 00000003645 15141150374 0024072 0 ustar 00root root 0000000 0000000 'use strict'
// r0, r1, expected intersection
module.exports = [
['1.3.0 || <1.0.0 >2.0.0', '1.3.0 || <1.0.0 >2.0.0', true],
['<1.0.0 >2.0.0', '>0.0.0', false],
['>0.0.0', '<1.0.0 >2.0.0', false],
['<1.0.0 >2.0.0', '>1.4.0 <1.6.0', false],
['<1.0.0 >2.0.0', '>1.4.0 <1.6.0 || 2.0.0', false],
['>1.0.0 <=2.0.0', '2.0.0', true],
['<1.0.0 >=2.0.0', '2.1.0', false],
['<1.0.0 >=2.0.0', '>1.4.0 <1.6.0 || 2.0.0', false],
['1.5.x', '<1.5.0 || >=1.6.0', false],
['<1.5.0 || >=1.6.0', '1.5.x', false],
['<1.6.16 || >=1.7.0 <1.7.11 || >=1.8.0 <1.8.2',
'>=1.6.16 <1.7.0 || >=1.7.11 <1.8.0 || >=1.8.2', false],
['<=1.6.16 || >=1.7.0 <1.7.11 || >=1.8.0 <1.8.2',
'>=1.6.16 <1.7.0 || >=1.7.11 <1.8.0 || >=1.8.2', true],
['>=1.0.0', '<=1.0.0', true],
['>1.0.0 <1.0.0', '<=0.0.0', false],
['*', '0.0.1', true],
['*', '>=1.0.0', true],
['*', '>1.0.0', true],
['*', '~1.0.0', true],
['*', '<1.6.0', true],
['*', '<=1.6.0', true],
['1.*', '0.0.1', false],
['1.*', '2.0.0', false],
['1.*', '1.0.0', true],
['1.*', '<2.0.0', true],
['1.*', '>1.0.0', true],
['1.*', '<=1.0.0', true],
['1.*', '^1.0.0', true],
['1.0.*', '0.0.1', false],
['1.0.*', '<0.0.1', false],
['1.0.*', '>0.0.1', true],
['*', '1.3.0 || <1.0.0 >2.0.0', true],
['1.3.0 || <1.0.0 >2.0.0', '*', true],
['1.*', '1.3.0 || <1.0.0 >2.0.0', true],
['x', '0.0.1', true],
['x', '>=1.0.0', true],
['x', '>1.0.0', true],
['x', '~1.0.0', true],
['x', '<1.6.0', true],
['x', '<=1.6.0', true],
['1.x', '0.0.1', false],
['1.x', '2.0.0', false],
['1.x', '1.0.0', true],
['1.x', '<2.0.0', true],
['1.x', '>1.0.0', true],
['1.x', '<=1.0.0', true],
['1.x', '^1.0.0', true],
['1.0.x', '0.0.1', false],
['1.0.x', '<0.0.1', false],
['1.0.x', '>0.0.1', true],
['x', '1.3.0 || <1.0.0 >2.0.0', true],
['1.3.0 || <1.0.0 >2.0.0', 'x', true],
['1.x', '1.3.0 || <1.0.0 >2.0.0', true],
['*', '*', true],
['x', '', true],
]
npm-node-semver-5993c2e/test/fixtures/range-parse.js 0000664 0000000 0000000 00000011006 15141150374 0022464 0 ustar 00root root 0000000 0000000 'use strict'
// [range, canonical result, options]
// null result means it's not a valid range
// '*' is the return value from functions.validRange(), but
// new Range().range will be '' in those cases
const { MAX_SAFE_INTEGER } = require('../../internal/constants')
module.exports = [
['1.0.0 - 2.0.0', '>=1.0.0 <=2.0.0'],
['1.0.0 - 2.0.0', '>=1.0.0-0 <2.0.1-0', { includePrerelease: true }],
['1 - 2', '>=1.0.0 <3.0.0-0'],
['1 - 2', '>=1.0.0-0 <3.0.0-0', { includePrerelease: true }],
['1.0 - 2.0', '>=1.0.0 <2.1.0-0'],
['1.0 - 2.0', '>=1.0.0-0 <2.1.0-0', { includePrerelease: true }],
['1.0.0', '1.0.0', { loose: false }],
['>=*', '*'],
['', '*'],
['*', '*'],
['>=1.0.0', '>=1.0.0'],
['>1.0.0', '>1.0.0'],
['<=2.0.0', '<=2.0.0'],
['1', '>=1.0.0 <2.0.0-0'],
['<2.0.0', '<2.0.0'],
['>= 1.0.0', '>=1.0.0'],
['>= 1.0.0', '>=1.0.0'],
['>= 1.0.0', '>=1.0.0'],
['> 1.0.0', '>1.0.0'],
['> 1.0.0', '>1.0.0'],
['<= 2.0.0', '<=2.0.0'],
['<= 2.0.0', '<=2.0.0'],
['<= 2.0.0', '<=2.0.0'],
['< 2.0.0', '<2.0.0'],
['<\t2.0.0', '<2.0.0'],
['>=0.1.97', '>=0.1.97'],
['0.1.20 || 1.2.4', '0.1.20||1.2.4'],
['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'],
['||', '*'],
['2.x.x', '>=2.0.0 <3.0.0-0'],
['1.2.x', '>=1.2.0 <1.3.0-0'],
['1.2.x || 2.x', '>=1.2.0 <1.3.0-0||>=2.0.0 <3.0.0-0'],
['x', '*'],
['2.*.*', '>=2.0.0 <3.0.0-0'],
['1.2.*', '>=1.2.0 <1.3.0-0'],
['1.2.* || 2.*', '>=1.2.0 <1.3.0-0||>=2.0.0 <3.0.0-0'],
['2', '>=2.0.0 <3.0.0-0'],
['2.3', '>=2.3.0 <2.4.0-0'],
['~2.4', '>=2.4.0 <2.5.0-0'],
['~>3.2.1', '>=3.2.1 <3.3.0-0'],
['~1', '>=1.0.0 <2.0.0-0'],
['~>1', '>=1.0.0 <2.0.0-0'],
['~> 1', '>=1.0.0 <2.0.0-0'],
['~1.0', '>=1.0.0 <1.1.0-0'],
['~ 1.0', '>=1.0.0 <1.1.0-0'],
['^0', '<1.0.0-0'],
['^ 1', '>=1.0.0 <2.0.0-0'],
['^0.1', '>=0.1.0 <0.2.0-0'],
['^1.0', '>=1.0.0 <2.0.0-0'],
['^1.2', '>=1.2.0 <2.0.0-0'],
['^0.0.1', '>=0.0.1 <0.0.2-0'],
['^0.0.1-beta', '>=0.0.1-beta <0.0.2-0'],
['^0.1.2', '>=0.1.2 <0.2.0-0'],
['^1.2.3', '>=1.2.3 <2.0.0-0'],
['^1.2.3-beta.4', '>=1.2.3-beta.4 <2.0.0-0'],
['<1', '<1.0.0-0'],
['< 1', '<1.0.0-0'],
['>=1', '>=1.0.0'],
['>= 1', '>=1.0.0'],
['<1.2', '<1.2.0-0'],
['< 1.2', '<1.2.0-0'],
['>01.02.03', '>1.2.3', true],
['>01.02.03', null],
['~1.2.3beta', '>=1.2.3-beta <1.3.0-0', { loose: true }],
['~1.2.3beta', null],
['^ 1.2 ^ 1', '>=1.2.0 <2.0.0-0 >=1.0.0'],
['1.2 - 3.4.5', '>=1.2.0 <=3.4.5'],
['1.2.3 - 3.4', '>=1.2.3 <3.5.0-0'],
['1.2 - 3.4', '>=1.2.0 <3.5.0-0'],
['>1', '>=2.0.0'],
['>1.2', '>=1.3.0'],
['>X', '<0.0.0-0'],
['* 2.x', '<0.0.0-0'],
['>x 2.x || * || =09090', null],
['>=09090', '>=9090.0.0', true],
['>=09090-0', null, { includePrerelease: true }],
['>=09090-0', null, { loose: true, includePrerelease: true }],
[`^${MAX_SAFE_INTEGER}.0.0`, null],
[`=${MAX_SAFE_INTEGER}.0.0`, `${MAX_SAFE_INTEGER}.0.0`],
[`^${MAX_SAFE_INTEGER - 1}.0.0`, `>=${MAX_SAFE_INTEGER - 1}.0.0 <${MAX_SAFE_INTEGER}.0.0-0`],
// x-ranges with build metadata
['1.x.x+build >2.x+build', '>=1.0.0 <2.0.0-0 >=3.0.0', null],
['>=1.x+build <2.x.x+build', '>=1.0.0 <2.0.0-0', null],
['1.x.x+build || 2.x.x+build', '>=1.0.0 <2.0.0-0||>=2.0.0 <3.0.0-0', null],
['1.x+build.123', '>=1.0.0 <2.0.0-0', null],
['1.x.x+meta-data', '>=1.0.0 <2.0.0-0', null],
['1.x.x+build.123 >2.x.x+meta-data', '>=1.0.0 <2.0.0-0 >=3.0.0', null],
['1.x.x+build <2.x.x+meta', '>=1.0.0 <2.0.0-0', null],
['>1.x+build <=2.x.x+meta', '>=2.0.0 <3.0.0-0', null],
[' 1.x.x+build >2.x.x+build ', '>=1.0.0 <2.0.0-0 >=3.0.0', null],
['^1.x+build', '>=1.0.0 <2.0.0-0', null],
['^1.x.x+build', '>=1.0.0 <2.0.0-0', null],
['^1.2.x+build', '>=1.2.0 <2.0.0-0', null],
['^1.x+meta-data', '>=1.0.0 <2.0.0-0', null],
['^1.x.x+build.123', '>=1.0.0 <2.0.0-0', null],
['~1.x+build', '>=1.0.0 <2.0.0-0', null],
['~1.x.x+build', '>=1.0.0 <2.0.0-0', null],
['~1.2.x+build', '>=1.2.0 <1.3.0-0', null],
['~1.x+meta-data', '>=1.0.0 <2.0.0-0', null],
['~1.x.x+build.123', '>=1.0.0 <2.0.0-0', null],
['^1.x.x+build || ~2.x.x+meta', '>=1.0.0 <2.0.0-0||>=2.0.0 <3.0.0-0', null],
['~1.x.x+build >2.x+meta', '>=1.0.0 <2.0.0-0 >=3.0.0', null],
['^1.x+build.123 <2.x.x+meta-data', '>=1.0.0 <2.0.0-0', null],
// // x-ranges with prerelease and build
['1.x.x-alpha+build', '>=1.0.0 <2.0.0-0', null],
['>1.x.x-alpha+build', '>=2.0.0', null],
['>=1.x.x-alpha+build <2.x.x+build', '>=1.0.0 <2.0.0-0', null],
['1.x.x-alpha+build || 2.x.x+build', '>=1.0.0 <2.0.0-0||>=2.0.0 <3.0.0-0', null],
]
npm-node-semver-5993c2e/test/fixtures/valid-versions.js 0000664 0000000 0000000 00000002111 15141150374 0023222 0 ustar 00root root 0000000 0000000 // [version, major, minor, patch, prerelease[], build[]]
module.exports = [
['1.0.0', 1, 0, 0, [], []],
['2.1.0', 2, 1, 0, [], []],
['3.2.1', 3, 2, 1, [], []],
['v1.2.3', 1, 2, 3, [], []],
// prerelease
['1.2.3-0', 1, 2, 3, [0], []],
['1.2.3-123', 1, 2, 3, [123], []],
['1.2.3-1.2.3', 1, 2, 3, [1, 2, 3], []],
['1.2.3-1a', 1, 2, 3, ['1a'], []],
['1.2.3-a1', 1, 2, 3, ['a1'], []],
['1.2.3-alpha', 1, 2, 3, ['alpha'], []],
['1.2.3-alpha.1', 1, 2, 3, ['alpha', 1], []],
['1.2.3-alpha-1', 1, 2, 3, ['alpha-1'], []],
['1.2.3-alpha-.-beta', 1, 2, 3, ['alpha-', '-beta'], []],
// build
['1.2.3+456', 1, 2, 3, [], ['456']],
['1.2.3+build', 1, 2, 3, [], ['build']],
['1.2.3+new-build', 1, 2, 3, [], ['new-build']],
['1.2.3+build.1', 1, 2, 3, [], ['build', '1']],
['1.2.3+build.1a', 1, 2, 3, [], ['build', '1a']],
['1.2.3+build.a1', 1, 2, 3, [], ['build', 'a1']],
['1.2.3+build.alpha', 1, 2, 3, [], ['build', 'alpha']],
['1.2.3+build.alpha.beta', 1, 2, 3, [], ['build', 'alpha', 'beta']],
// mixed
['1.2.3-alpha+build', 1, 2, 3, ['alpha'], ['build']],
]
npm-node-semver-5993c2e/test/fixtures/version-gt-range.js 0000664 0000000 0000000 00000003033 15141150374 0023450 0 ustar 00root root 0000000 0000000 'use strict'
// [range, version, options]
// Version should be greater than range
module.exports = [
['~1.2.2', '1.3.0'],
['~0.6.1-1', '0.7.1-1'],
['1.0.0 - 2.0.0', '2.0.1'],
['1.0.0', '1.0.1-beta1'],
['1.0.0', '2.0.0'],
['<=2.0.0', '2.1.1'],
['<=2.0.0', '3.2.9'],
['<2.0.0', '2.0.0'],
['0.1.20 || 1.2.4', '1.2.5'],
['2.x.x', '3.0.0'],
['1.2.x', '1.3.0'],
['1.2.x || 2.x', '3.0.0'],
['2.*.*', '5.0.1'],
['1.2.*', '1.3.3'],
['1.2.* || 2.*', '4.0.0'],
['2', '3.0.0'],
['2.3', '2.4.2'],
['~2.4', '2.5.0'], // >=2.4.0 <2.5.0
['~2.4', '2.5.5'],
['~>3.2.1', '3.3.0'], // >=3.2.1 <3.3.0
['~1', '2.2.3'], // >=1.0.0 <2.0.0
['~>1', '2.2.4'],
['~> 1', '3.2.3'],
['~1.0', '1.1.2'], // >=1.0.0 <1.1.0
['~ 1.0', '1.1.0'],
['<1.2', '1.2.0'],
['< 1.2', '1.2.1'],
['1', '2.0.0beta', true],
['~v0.5.4-pre', '0.6.0'],
['~v0.5.4-pre', '0.6.1-pre'],
['=0.7.x', '0.8.0'],
['=0.7.x', '0.8.0-asdf'],
['<0.7.x', '0.7.0'],
['1.0.0 - 2.0.0', '2.2.3'],
['1.0.0', '1.0.1'],
['<=2.0.0', '3.0.0'],
['<=2.0.0', '2.9999.9999'],
['<=2.0.0', '2.2.9'],
['<2.0.0', '2.9999.9999'],
['<2.0.0', '2.2.9'],
['2.x.x', '3.1.3'],
['1.2.x', '1.3.3'],
['1.2.x || 2.x', '3.1.3'],
['2.*.*', '3.1.3'],
['1.2.* || 2.*', '3.1.3'],
['2', '3.1.2'],
['2.3', '2.4.1'],
['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0
['~>1', '2.2.3'],
['~1.0', '1.1.0'], // >=1.0.0 <1.1.0
['<1', '1.0.0'],
['<1', '1.0.0beta', true],
['< 1', '1.0.0beta', true],
['=0.7.x', '0.8.2'],
['<0.7.x', '0.7.2'],
['0.7.x', '0.7.2-beta'],
]
npm-node-semver-5993c2e/test/fixtures/version-lt-range.js 0000664 0000000 0000000 00000003144 15141150374 0023460 0 ustar 00root root 0000000 0000000 'use strict'
// [range, version, options]
// Version should be less than range
module.exports = [
['~1.2.2', '1.2.1'],
['~0.6.1-1', '0.6.1-0'],
['1.0.0 - 2.0.0', '0.0.1'],
['1.0.0-beta.2', '1.0.0-beta.1'],
['1.0.0', '0.0.0'],
['>=2.0.0', '1.1.1'],
['>=2.0.0', '1.2.9'],
['>2.0.0', '2.0.0'],
['0.1.20 || 1.2.4', '0.1.5'],
['2.x.x', '1.0.0'],
['1.2.x', '1.1.0'],
['1.2.x || 2.x', '1.0.0'],
['2.*.*', '1.0.1'],
['1.2.*', '1.1.3'],
['1.2.* || 2.*', '1.1.9999'],
['2', '1.0.0'],
['2.3', '2.2.2'],
['~2.4', '2.3.0'], // >=2.4.0 <2.5.0
['~2.4', '2.3.5'],
['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0
['~1', '0.2.3'], // >=1.0.0 <2.0.0
['~>1', '0.2.4'],
['~> 1', '0.2.3'],
['~1.0', '0.1.2'], // >=1.0.0 <1.1.0
['~ 1.0', '0.1.0'],
['>1.2', '1.2.0'],
['> 1.2', '1.2.1'],
['1', '0.0.0beta', true],
['~v0.5.4-pre', '0.5.4-alpha'],
['=0.7.x', '0.6.0'],
['=0.7.x', '0.6.0-asdf'],
['>=0.7.x', '0.6.0'],
['1.0.0 - 2.0.0', '0.2.3'],
['1.0.0', '0.0.1'],
['>=2.0.0', '1.0.0'],
['>=2.0.0', '1.9999.9999'],
['>2.0.0', '1.2.9'],
['2.x.x', '1.1.3'],
['1.2.x', '1.1.3'],
['1.2.x || 2.x', '1.1.3'],
['2.*.*', '1.1.3'],
['1.2.* || 2.*', '1.1.3'],
['2', '1.9999.9999'],
['2.3', '2.2.1'],
['~>3.2.1', '2.3.2'], // >=3.2.1 <3.3.0
['~>1', '0.2.3'],
['~1.0', '0.0.0'], // >=1.0.0 <1.1.0
['>1', '1.0.0'],
['2', '1.0.0beta', true],
['>1', '1.0.0beta', true],
['> 1', '1.0.0beta', true],
['=0.7.x', '0.6.2'],
['=0.7.x', '0.7.0-asdf'],
['^1', '1.0.0-0'],
['>=0.7.x', '0.7.0-asdf'],
['1', '1.0.0beta', true],
['>=0.7.x', '0.6.2'],
['>1.2.3', '1.3.0-alpha'],
]
npm-node-semver-5993c2e/test/fixtures/version-not-gt-range.js 0000664 0000000 0000000 00000004447 15141150374 0024260 0 ustar 00root root 0000000 0000000 'use strict'
// [range, version, options]
// Version should NOT be greater than range
module.exports = [
['~0.6.1-1', '0.6.1-1'],
['1.0.0 - 2.0.0', '1.2.3'],
['1.0.0 - 2.0.0', '0.9.9'],
['1.0.0', '1.0.0'],
['>=*', '0.2.4'],
['', '1.0.0', true],
['*', '1.2.3'],
['*', 'v1.2.3-foo'],
['>=1.0.0', '1.0.0'],
['>=1.0.0', '1.0.1'],
['>=1.0.0', '1.1.0'],
['>1.0.0', '1.0.1'],
['>1.0.0', '1.1.0'],
['<=2.0.0', '2.0.0'],
['<=2.0.0', '1.9999.9999'],
['<=2.0.0', '0.2.9'],
['<2.0.0', '1.9999.9999'],
['<2.0.0', '0.2.9'],
['>= 1.0.0', '1.0.0'],
['>= 1.0.0', '1.0.1'],
['>= 1.0.0', '1.1.0'],
['> 1.0.0', '1.0.1'],
['> 1.0.0', '1.1.0'],
['<= 2.0.0', '2.0.0'],
['<= 2.0.0', '1.9999.9999'],
['<= 2.0.0', '0.2.9'],
['< 2.0.0', '1.9999.9999'],
['<\t2.0.0', '0.2.9'],
['>=0.1.97', 'v0.1.97'],
['>=0.1.97', '0.1.97'],
['0.1.20 || 1.2.4', '1.2.4'],
['0.1.20 || >1.2.4', '1.2.4'],
['0.1.20 || 1.2.4', '1.2.3'],
['0.1.20 || 1.2.4', '0.1.20'],
['>=0.2.3 || <0.0.1', '0.0.0'],
['>=0.2.3 || <0.0.1', '0.2.3'],
['>=0.2.3 || <0.0.1', '0.2.4'],
['||', '1.3.4'],
['2.x.x', '2.1.3'],
['1.2.x', '1.2.3'],
['1.2.x || 2.x', '2.1.3'],
['1.2.x || 2.x', '1.2.3'],
['x', '1.2.3'],
['2.*.*', '2.1.3'],
['1.2.*', '1.2.3'],
['1.2.* || 2.*', '2.1.3'],
['1.2.* || 2.*', '1.2.3'],
['2', '2.1.2'],
['2.3', '2.3.1'],
['~2.4', '2.4.0'], // >=2.4.0 <2.5.0
['~2.4', '2.4.5'],
['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0
['~1', '1.2.3'], // >=1.0.0 <2.0.0
['~>1', '1.2.3'],
['~> 1', '1.2.3'],
['~1.0', '1.0.2'], // >=1.0.0 <1.1.0
['~ 1.0', '1.0.2'],
['>=1', '1.0.0'],
['>= 1', '1.0.0'],
['<1.2', '1.1.1'],
['< 1.2', '1.1.1'],
['1', '1.0.0beta', true],
['~v0.5.4-pre', '0.5.5'],
['~v0.5.4-pre', '0.5.4'],
['=0.7.x', '0.7.2'],
['>=0.7.x', '0.7.2'],
['=0.7.x', '0.7.0-asdf'],
['>=0.7.x', '0.7.0-asdf'],
['<=0.7.x', '0.6.2'],
['>0.2.3 >0.2.4 <=0.2.5', '0.2.5'],
['>=0.2.3 <=0.2.4', '0.2.4'],
['1.0.0 - 2.0.0', '2.0.0'],
['^1', '0.0.0-0'],
['^3.0.0', '2.0.0'],
['^1.0.0 || ~2.0.1', '2.0.0'],
['^0.1.0 || ~3.0.1 || 5.0.0', '3.2.0'],
['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true],
['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true],
['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0'],
['0.7.x', '0.7.2-beta', { includePrerelease: true }],
]
npm-node-semver-5993c2e/test/fixtures/version-not-lt-range.js 0000664 0000000 0000000 00000004660 15141150374 0024262 0 ustar 00root root 0000000 0000000 'use strict'
// [range, version, options]
// Version should NOT be less than range
module.exports = [
['~ 1.0', '1.1.0'],
['~0.6.1-1', '0.6.1-1'],
['1.0.0 - 2.0.0', '1.2.3'],
['1.0.0 - 2.0.0', '2.9.9'],
['1.0.0', '1.0.0'],
['>=*', '0.2.4'],
['', '1.0.0', true],
['*', '1.2.3'],
['>=1.0.0', '1.0.0'],
['>=1.0.0', '1.0.1'],
['>=1.0.0', '1.1.0'],
['>1.0.0', '1.0.1'],
['>1.0.0', '1.1.0'],
['<=2.0.0', '2.0.0'],
['<=2.0.0', '1.9999.9999'],
['<=2.0.0', '0.2.9'],
['<2.0.0', '1.9999.9999'],
['<2.0.0', '0.2.9'],
['>= 1.0.0', '1.0.0'],
['>= 1.0.0', '1.0.1'],
['>= 1.0.0', '1.1.0'],
['> 1.0.0', '1.0.1'],
['> 1.0.0', '1.1.0'],
['<= 2.0.0', '2.0.0'],
['<= 2.0.0', '1.9999.9999'],
['<= 2.0.0', '0.2.9'],
['< 2.0.0', '1.9999.9999'],
['<\t2.0.0', '0.2.9'],
['>=0.1.97', 'v0.1.97'],
['>=0.1.97', '0.1.97'],
['0.1.20 || 1.2.4', '1.2.4'],
['0.1.20 || >1.2.4', '1.2.4'],
['0.1.20 || 1.2.4', '1.2.3'],
['0.1.20 || 1.2.4', '0.1.20'],
['>=0.2.3 || <0.0.1', '0.0.0'],
['>=0.2.3 || <0.0.1', '0.2.3'],
['>=0.2.3 || <0.0.1', '0.2.4'],
['||', '1.3.4'],
['2.x.x', '2.1.3'],
['1.2.x', '1.2.3'],
['1.2.x || 2.x', '2.1.3'],
['1.2.x || 2.x', '1.2.3'],
['x', '1.2.3'],
['2.*.*', '2.1.3'],
['1.2.*', '1.2.3'],
['1.2.* || 2.*', '2.1.3'],
['1.2.* || 2.*', '1.2.3'],
['2', '2.1.2'],
['2.3', '2.3.1'],
['~2.4', '2.4.0'], // >=2.4.0 <2.5.0
['~2.4', '2.4.5'],
['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0
['~1', '1.2.3'], // >=1.0.0 <2.0.0
['~>1', '1.2.3'],
['~> 1', '1.2.3'],
['~1.0', '1.0.2'], // >=1.0.0 <1.1.0
['~ 1.0', '1.0.2'],
['>=1', '1.0.0'],
['>= 1', '1.0.0'],
['<1.2', '1.1.1'],
['< 1.2', '1.1.1'],
['~v0.5.4-pre', '0.5.5'],
['~v0.5.4-pre', '0.5.4'],
['=0.7.x', '0.7.2'],
['>=0.7.x', '0.7.2'],
['<=0.7.x', '0.6.2'],
['>0.2.3 >0.2.4 <=0.2.5', '0.2.5'],
['>=0.2.3 <=0.2.4', '0.2.4'],
['1.0.0 - 2.0.0', '2.0.0'],
['^3.0.0', '4.0.0'],
['^1.0.0 || ~2.0.1', '2.0.0'],
['^0.1.0 || ~3.0.1 || 5.0.0', '3.2.0'],
['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true],
['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true],
['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0'],
['^1.0.0alpha', '1.0.0beta', true],
['~1.0.0alpha', '1.0.0beta', true],
['^1.0.0-alpha', '1.0.0beta', true],
['~1.0.0-alpha', '1.0.0beta', true],
['^1.0.0-alpha', '1.0.0-beta'],
['~1.0.0-alpha', '1.0.0-beta'],
['=0.1.0', '1.0.0'],
['>1.2.3', '1.3.0-alpha', { includePrerelease: true }],
]
npm-node-semver-5993c2e/test/functions/ 0000775 0000000 0000000 00000000000 15141150374 0020063 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/test/functions/clean.js 0000664 0000000 0000000 00000001312 15141150374 0021500 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const clean = require('../../functions/clean')
test('clean tests', (t) => {
// [range, version]
// Version should be detectable despite extra characters
[
['1.2.3', '1.2.3'],
[' 1.2.3 ', '1.2.3'],
[' 1.2.3-4 ', '1.2.3-4'],
[' 1.2.3-pre ', '1.2.3-pre'],
[' =v1.2.3 ', '1.2.3'],
['v1.2.3', '1.2.3'],
[' v1.2.3 ', '1.2.3'],
['\t1.2.3', '1.2.3'],
['>1.2.3', null],
['~1.2.3', null],
['<=1.2.3', null],
['1.2.x', null],
['0.12.0-dev.1150+3c22cecee', '0.12.0-dev.1150'],
].forEach(([range, version]) => {
const msg = `clean(${range}) = ${version}`
t.equal(clean(range), version, msg)
})
t.end()
})
npm-node-semver-5993c2e/test/functions/cmp.js 0000664 0000000 0000000 00000003511 15141150374 0021200 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const cmp = require('../../functions/cmp')
const comparisons = require('../fixtures/comparisons.js')
const equality = require('../fixtures/equality.js')
const SemVer = require('../../classes/semver')
test('invalid cmp usage', (t) => {
t.throws(() => {
cmp('1.2.3', 'a frog', '4.5.6')
}, new TypeError('Invalid operator: a frog'))
t.end()
})
test('comparison tests', t => {
t.plan(comparisons.length)
comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(8)
t.ok(cmp(v0, '>', v1, loose), `cmp('${v0}' > '${v1}')`)
t.ok(cmp(v1, '<', v0, loose), `cmp('${v1}' < '${v0}')`)
t.ok(!cmp(v1, '>', v0, loose), `!cmp('${v1}' > '${v0}')`)
t.ok(!cmp(v0, '<', v1, loose), `!cmp('${v0}' < '${v1}')`)
t.ok(cmp(v1, '==', v1, loose), `cmp('${v1}' == '${v1}')`)
t.ok(cmp(v0, '>=', v1, loose), `cmp('${v0}' >= '${v1}')`)
t.ok(cmp(v1, '<=', v0, loose), `cmp('${v1}' <= '${v0}')`)
t.ok(cmp(v0, '!=', v1, loose), `cmp('${v0}' != '${v1}')`)
}))
})
test('equality tests', t => {
t.plan(equality.length)
equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(8)
t.ok(cmp(v0, '', v1, loose), `cmp(${v0} "" ${v1})`)
t.ok(cmp(v0, '=', v1, loose), `cmp(${v0}=${v1})`)
t.ok(cmp(v0, '==', v1, loose), `cmp(${v0}==${v1})`)
t.ok(!cmp(v0, '!=', v1, loose), `!cmp(${v0}!=${v1})`)
t.ok(!cmp(v0, '===', v1, loose), `!cmp(${v0}===${v1})`)
// also test with an object. they are === because obj.version matches
t.ok(cmp(new SemVer(v0, { loose: loose }), '===',
new SemVer(v1, { loose: loose })),
`!cmp(${v0}===${v1}) object`)
t.ok(cmp(v0, '!==', v1, loose), `cmp(${v0}!==${v1})`)
t.ok(!cmp(new SemVer(v0, loose), '!==', new SemVer(v1, loose)),
`cmp(${v0}!==${v1}) object`)
}))
})
npm-node-semver-5993c2e/test/functions/coerce.js 0000664 0000000 0000000 00000014552 15141150374 0021670 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const coerce = require('../../functions/coerce')
const parse = require('../../functions/parse')
const valid = require('../../functions/valid')
test('coerce tests', (t) => {
// Expected to be null (cannot be coerced).
const coerceToNull = [
null,
{ version: '1.2.3' },
function () {
return '1.2.3'
},
'',
'.',
'version one',
'9'.repeat(16),
'1'.repeat(17),
`a${'9'.repeat(16)}`,
`a${'1'.repeat(17)}`,
`${'9'.repeat(16)}a`,
`${'1'.repeat(17)}a`,
`${'9'.repeat(16)}.4.7.4`,
`${'9'.repeat(16)}.${'2'.repeat(16)}.${'3'.repeat(16)}`,
`${'1'.repeat(16)}.${'9'.repeat(16)}.${'3'.repeat(16)}`,
`${'1'.repeat(16)}.${'2'.repeat(16)}.${'9'.repeat(16)}`,
]
coerceToNull.forEach((input) => {
const msg = `coerce(${input}) should be null`
t.same(coerce(input), null, msg)
})
// Expected to be valid.
const coerceToValid = [
[parse('1.2.3'), '1.2.3'],
['.1', '1.0.0'],
['.1.', '1.0.0'],
['..1', '1.0.0'],
['.1.1', '1.1.0'],
['1.', '1.0.0'],
['1.0', '1.0.0'],
['1.0.0', '1.0.0'],
['0', '0.0.0'],
['0.0', '0.0.0'],
['0.0.0', '0.0.0'],
['0.1', '0.1.0'],
['0.0.1', '0.0.1'],
['0.1.1', '0.1.1'],
['1', '1.0.0'],
['1.2', '1.2.0'],
['1.2.3', '1.2.3'],
['1.2.3.4', '1.2.3'],
['13', '13.0.0'],
['35.12', '35.12.0'],
['35.12.18', '35.12.18'],
['35.12.18.24', '35.12.18'],
['v1', '1.0.0'],
['v1.2', '1.2.0'],
['v1.2.3', '1.2.3'],
['v1.2.3.4', '1.2.3'],
[' 1', '1.0.0'],
['1 ', '1.0.0'],
['1 0', '1.0.0'],
['1 1', '1.0.0'],
['1.1 1', '1.1.0'],
['1.1-1', '1.1.0'],
['1.1-1', '1.1.0'],
['a1', '1.0.0'],
['a1a', '1.0.0'],
['1a', '1.0.0'],
['version 1', '1.0.0'],
['version1', '1.0.0'],
['version1.0', '1.0.0'],
['version1.1', '1.1.0'],
['42.6.7.9.3-alpha', '42.6.7'],
['v2', '2.0.0'],
['v3.4 replaces v3.3.1', '3.4.0'],
['4.6.3.9.2-alpha2', '4.6.3'],
[`${'1'.repeat(17)}.2`, '2.0.0'],
[`${'1'.repeat(17)}.2.3`, '2.3.0'],
[`1.${'2'.repeat(17)}.3`, '1.0.0'],
[`1.2.${'3'.repeat(17)}`, '1.2.0'],
[`${'1'.repeat(17)}.2.3.4`, '2.3.4'],
[`1.${'2'.repeat(17)}.3.4`, '1.0.0'],
[`1.2.${'3'.repeat(17)}.4`, '1.2.0'],
[`${'1'.repeat(17)}.${'2'.repeat(16)}.${'3'.repeat(16)}`,
`${'2'.repeat(16)}.${'3'.repeat(16)}.0`],
[`${'1'.repeat(16)}.${'2'.repeat(17)}.${'3'.repeat(16)}`,
`${'1'.repeat(16)}.0.0`],
[`${'1'.repeat(16)}.${'2'.repeat(16)}.${'3'.repeat(17)}`,
`${'1'.repeat(16)}.${'2'.repeat(16)}.0`],
[`11${'.1'.repeat(126)}`, '11.1.1'],
['1'.repeat(16), `${'1'.repeat(16)}.0.0`],
[`a${'1'.repeat(16)}`, `${'1'.repeat(16)}.0.0`],
[`${'1'.repeat(16)}.2.3.4`, `${'1'.repeat(16)}.2.3`],
[`1.${'2'.repeat(16)}.3.4`, `1.${'2'.repeat(16)}.3`],
[`1.2.${'3'.repeat(16)}.4`, `1.2.${'3'.repeat(16)}`],
[`${'1'.repeat(16)}.${'2'.repeat(16)}.${'3'.repeat(16)}`,
`${'1'.repeat(16)}.${'2'.repeat(16)}.${'3'.repeat(16)}`],
[`1.2.3.${'4'.repeat(252)}.5`, '1.2.3'],
[`1.2.3.${'4'.repeat(1024)}`, '1.2.3'],
[`${'1'.repeat(17)}.4.7.4`, '4.7.4'],
[10, '10.0.0'],
['1.2.3/a/b/c/2.3.4', '2.3.4', { rtl: true }],
['1.2.3.4.5.6', '4.5.6', { rtl: true }],
['1.2.3.4.5/6', '6.0.0', { rtl: true }],
['1.2.3.4./6', '6.0.0', { rtl: true }],
['1.2.3.4/6', '6.0.0', { rtl: true }],
['1.2.3./6', '6.0.0', { rtl: true }],
['1.2.3/6', '6.0.0', { rtl: true }],
['1.2.3.4', '2.3.4', { rtl: true }],
['1.2.3.4xyz', '2.3.4', { rtl: true }],
['1-rc.5', '1.0.0-rc.5', { includePrerelease: true }],
['1.2-rc.5', '1.2.0-rc.5', { includePrerelease: true }],
['1.2.3-rc.5', '1.2.3-rc.5', { includePrerelease: true }],
['1.2.3-rc.5/a', '1.2.3-rc.5', { includePrerelease: true }],
['1.2.3.4-rc.5', '1.2.3', { includePrerelease: true }],
['1.2.3.4+rev.6', '1.2.3', { includePrerelease: true }],
['1.0.0-1a', '1.0.0-1a', { includePrerelease: true }],
['1.0.0-alpha.12ab', '1.0.0-alpha.12ab', { includePrerelease: true }],
['1.0.0-alpha.1234.23cd', '1.0.0-alpha.1234.23cd', { includePrerelease: true }],
['1.0.0-nightly.abc123', '1.0.0-nightly.abc123', { includePrerelease: true }],
['1.0.0-nightly.abcdef', '1.0.0-nightly.abcdef', { includePrerelease: true }],
['1.0.0-nightly.123456', '1.0.0-nightly.123456', { includePrerelease: true }],
['1+rev.6', '1.0.0+rev.6', { includePrerelease: true }],
['1.2+rev.6', '1.2.0+rev.6', { includePrerelease: true }],
['1.2.3+rev.6', '1.2.3+rev.6', { includePrerelease: true }],
['1.2.3+rev.6/a', '1.2.3+rev.6', { includePrerelease: true }],
['1.2.3.4-rc.5', '1.2.3', { includePrerelease: true }],
['1.2.3.4+rev.6', '1.2.3', { includePrerelease: true }],
['1-rc.5+rev.6', '1.0.0-rc.5+rev.6', { includePrerelease: true }],
['1.2-rc.5+rev.6', '1.2.0-rc.5+rev.6', { includePrerelease: true }],
['1.2.3-rc.5+rev.6', '1.2.3-rc.5+rev.6', { includePrerelease: true }],
['1.2.3-rc.5+rev.6/a', '1.2.3-rc.5+rev.6', { includePrerelease: true }],
['1.2-rc.5+rev.6', '1.2.0-rc.5+rev.6', { rtl: true, includePrerelease: true }],
['1.2.3-rc.5+rev.6', '1.2.3-rc.5+rev.6', { rtl: true, includePrerelease: true }],
['1.2.3.4-rc.5+rev.6', '2.3.4-rc.5+rev.6', { rtl: true, includePrerelease: true }],
['1.2.3.4-rc.5', '2.3.4-rc.5', { rtl: true, includePrerelease: true }],
['1.2.3.4+rev.6', '2.3.4+rev.6', { rtl: true, includePrerelease: true }],
['1.2.3.4-rc.5+rev.6/7', '7.0.0', { rtl: true, includePrerelease: true }],
['1.2.3.4-rc/7.5+rev.6', '7.5.0+rev.6', { rtl: true, includePrerelease: true }],
['1.2.3.4/7-rc.5+rev.6', '7.0.0-rc.5+rev.6', { rtl: true, includePrerelease: true }],
]
coerceToValid.forEach(([input, expected, options]) => {
const coerceExpression = `coerce(${input}, ${JSON.stringify(options)})`
const coercedVersion = coerce(input, options) || {}
const expectedVersion = parse(expected)
t.equal(expectedVersion.compare(coercedVersion), 0,
`${coerceExpression} should be equal to ${expectedVersion}`)
t.equal(expectedVersion.compareBuild(coercedVersion), 0,
`${coerceExpression} build should be equal to ${expectedVersion}`)
})
t.same(valid(coerce('42.6.7.9.3-alpha')), '42.6.7')
t.same(valid(coerce('42.6.7-alpha+rev.1', { includePrerelease: true })), '42.6.7-alpha')
t.same(valid(coerce('v2')), '2.0.0')
t.end()
})
npm-node-semver-5993c2e/test/functions/compare-build.js 0000664 0000000 0000000 00000001100 15141150374 0023134 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const compareBuild = require('../../functions/compare-build')
test('compareBuild', (t) => {
const noBuild = '1.0.0'
const build0 = '1.0.0+0'
const build1 = '1.0.0+1'
const build10 = '1.0.0+1.0'
t.equal(compareBuild(noBuild, build0), -1)
t.equal(compareBuild(build0, build0), 0)
t.equal(compareBuild(build0, noBuild), 1)
t.equal(compareBuild(build0, '1.0.0+0.0'), -1)
t.equal(compareBuild(build0, build1), -1)
t.equal(compareBuild(build1, build0), 1)
t.equal(compareBuild(build10, build1), 1)
t.end()
})
npm-node-semver-5993c2e/test/functions/compare-loose.js 0000664 0000000 0000000 00000001471 15141150374 0023171 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const compareLoose = require('../../functions/compare-loose')
const SemVer = require('../../classes/semver')
const eq = require('../../functions/eq')
test('strict vs loose version numbers', (t) => {
[['=1.2.3', '1.2.3'],
['01.02.03', '1.2.3'],
['1.2.3-beta.01', '1.2.3-beta.1'],
[' =1.2.3', '1.2.3'],
['1.2.3foo', '1.2.3-foo'],
].forEach((v) => {
const loose = v[0]
const strict = v[1]
t.throws(() => {
SemVer(loose) // eslint-disable-line no-new
})
const lv = new SemVer(loose, true)
t.equal(lv.version, strict)
t.ok(eq(loose, strict, true))
t.throws(() => {
eq(loose, strict)
})
t.throws(() => {
new SemVer(strict).compare(loose)
})
t.equal(compareLoose(v[0], v[1]), 0)
})
t.end()
})
npm-node-semver-5993c2e/test/functions/compare.js 0000664 0000000 0000000 00000002527 15141150374 0022055 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const compare = require('../../functions/compare.js')
const comparisons = require('../fixtures/comparisons.js')
const equality = require('../fixtures/equality.js')
const SemVer = require('../../classes/semver.js')
test('comparison tests', t => {
t.plan(comparisons.length)
comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(4)
t.equal(compare(v0, v1, loose), 1, `compare('${v0}', '${v1}')`)
t.equal(compare(v1, v0, loose), -1, `compare('${v1}', '${v0}')`)
t.equal(compare(v0, v0, loose), 0, `compare('${v0}', '${v0}')`)
t.equal(compare(v1, v1, loose), 0, `compare('${v1}', '${v1}')`)
}))
})
test('equality tests', (t) => {
// [version1, version2]
// version1 should be equivalent to version2
t.plan(equality.length)
equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(5)
t.equal(compare(v0, v1, loose), 0, `${v0} ${v1}`)
t.equal(compare(v1, v0, loose), 0, `${v1} ${v0}`)
t.equal(compare(v0, v0, loose), 0, `${v0} ${v0}`)
t.equal(compare(v1, v1, loose), 0, `${v1} ${v1}`)
// also test with an object. they are === because obj.version matches
t.equal(compare(new SemVer(v0, { loose: loose }),
new SemVer(v1, { loose: loose })), 0,
`compare(${v0}, ${v1}) object`)
}))
t.end()
})
npm-node-semver-5993c2e/test/functions/diff.js 0000664 0000000 0000000 00000003631 15141150374 0021334 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const diff = require('../../functions/diff')
test('diff versions test', (t) => {
// [version1, version2, result]
// diff(version1, version2) -> result
[
['1.2.3', '0.2.3', 'major'],
['0.2.3', '1.2.3', 'major'],
['1.4.5', '0.2.3', 'major'],
['1.2.3', '2.0.0-pre', 'premajor'],
['2.0.0-pre', '1.2.3', 'premajor'],
['1.2.3', '1.3.3', 'minor'],
['1.0.1', '1.1.0-pre', 'preminor'],
['1.2.3', '1.2.4', 'patch'],
['1.2.3', '1.2.4-pre', 'prepatch'],
['0.0.1', '0.0.1-pre', 'patch'],
['0.0.1', '0.0.1-pre-2', 'patch'],
['1.1.0', '1.1.0-pre', 'minor'],
['1.1.0-pre-1', '1.1.0-pre-2', 'prerelease'],
['1.0.0', '1.0.0', null],
['1.0.0-1', '1.0.0-1', null],
['0.0.2-1', '0.0.2', 'patch'],
['0.0.2-1', '0.0.3', 'patch'],
['0.0.2-1', '0.1.0', 'minor'],
['0.0.2-1', '1.0.0', 'major'],
['0.1.0-1', '0.1.0', 'minor'],
['1.0.0-1', '1.0.0', 'major'],
['1.0.0-1', '1.1.1', 'major'],
['1.0.0-1', '2.1.1', 'major'],
['1.0.1-1', '1.0.1', 'patch'],
['0.0.0-1', '0.0.0', 'major'],
['1.0.0-1', '2.0.0', 'major'],
['1.0.0-1', '2.0.0-1', 'premajor'],
['1.0.0-1', '1.1.0-1', 'preminor'],
['1.0.0-1', '1.0.1-1', 'prepatch'],
['1.7.2-1', '1.8.1', 'minor'],
['1.1.1-pre', '2.1.1-pre', 'premajor'],
['1.1.1-pre', '2.1.1', 'major'],
['1.2.3-1', '1.2.3', 'patch'],
['1.4.0-1', '2.3.5', 'major'],
['1.6.1-5', '1.7.2', 'minor'],
['2.0.0-1', '2.1.1', 'major'],
].forEach((v) => {
const version1 = v[0]
const version2 = v[1]
const wanted = v[2]
const found = diff(version1, version2)
const cmd = `diff(${version1}, ${version2})`
t.equal(found, wanted, `${cmd} === ${wanted}`)
})
t.end()
})
test('throws on bad version', (t) => {
t.throws(() => {
diff('bad', '1.2.3')
}, {
message: 'Invalid Version: bad',
name: 'TypeError',
})
t.end()
})
npm-node-semver-5993c2e/test/functions/eq.js 0000664 0000000 0000000 00000001631 15141150374 0021027 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const eq = require('../../functions/eq')
const comparisons = require('../fixtures/comparisons.js')
const equality = require('../fixtures/equality.js')
test('comparison tests', t => {
t.plan(comparisons.length)
comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(4)
t.notOk(eq(v0, v1, loose), `!eq(${v0}, ${v1})`)
t.notOk(eq(v1, v0, loose), `!eq(${v1}, ${v0})`)
t.ok(eq(v1, v1, loose), `eq('${v1}', '${v1}')`)
t.ok(eq(v0, v0, loose), `eq('${v0}', '${v0}')`)
}))
})
test('equality tests', t => {
t.plan(equality.length)
equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(4)
t.ok(eq(v0, v1, loose), `eq(${v0}, ${v1})`)
t.ok(eq(v1, v0, loose), `eq(${v1}, ${v0})`)
t.ok(eq(v0, v0, loose), `eq(${v0}, ${v0})`)
t.ok(eq(v1, v1, loose), `eq(${v1}, ${v1})`)
}))
})
npm-node-semver-5993c2e/test/functions/gt.js 0000664 0000000 0000000 00000001503 15141150374 0021032 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const gt = require('../../functions/gt')
const comparisons = require('../fixtures/comparisons.js')
const equality = require('../fixtures/equality.js')
test('comparison tests', t => {
t.plan(comparisons.length)
comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(4)
t.ok(gt(v0, v1, loose), `gt('${v0}', '${v1}')`)
t.ok(!gt(v1, v0, loose), `!gt('${v1}', '${v0}')`)
t.ok(!gt(v1, v1, loose), `!gt('${v1}', '${v1}')`)
t.ok(!gt(v0, v0, loose), `!gt('${v0}', '${v0}')`)
}))
})
test('equality tests', t => {
t.plan(equality.length)
equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(2)
t.ok(!gt(v0, v1, loose), `!gt(${v0}, ${v1})`)
t.ok(!gt(v1, v0, loose), `!gt(${v1}, ${v0})`)
}))
})
npm-node-semver-5993c2e/test/functions/gte.js 0000664 0000000 0000000 00000001511 15141150374 0021176 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const gte = require('../../functions/gte')
const comparisons = require('../fixtures/comparisons.js')
const equality = require('../fixtures/equality.js')
test('comparison tests', t => {
t.plan(comparisons.length)
comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(4)
t.ok(gte(v0, v1, loose), `gte('${v0}', '${v1}')`)
t.ok(!gte(v1, v0, loose), `!gte('${v1}', '${v0}')`)
t.ok(gte(v1, v1, loose), `gte('${v1}', '${v1}')`)
t.ok(gte(v0, v0, loose), `gte('${v0}', '${v0}')`)
}))
})
test('equality tests', t => {
t.plan(equality.length)
equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(2)
t.ok(gte(v0, v1, loose), `gte(${v0}, ${v1})`)
t.ok(gte(v1, v0, loose), `gte(${v1}, ${v0})`)
}))
})
npm-node-semver-5993c2e/test/functions/inc.js 0000664 0000000 0000000 00000002544 15141150374 0021177 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const inc = require('../../functions/inc')
const parse = require('../../functions/parse')
const increments = require('../fixtures/increments.js')
test('increment versions test', (t) => {
increments.forEach(([pre, what, wanted, options, id, base]) => {
const found = inc(pre, what, options, id, base)
const cmd = `inc(${pre}, ${what}, ${id}, ${base})`
t.equal(found, wanted, `${cmd} === ${wanted}`)
const parsed = parse(pre, options)
const parsedAsInput = parse(pre, options)
if (wanted) {
parsed.inc(what, id, base)
t.equal(parsed.version, wanted, `${cmd} object version updated`)
if (parsed.build.length) {
t.equal(
parsed.raw,
`${wanted}+${parsed.build.join('.')}`,
`${cmd} object raw field updated with build`
)
} else {
t.equal(parsed.raw, wanted, `${cmd} object raw field updated`)
}
const preIncObject = JSON.stringify(parsedAsInput)
inc(parsedAsInput, what, options, id, base)
const postIncObject = JSON.stringify(parsedAsInput)
t.equal(
postIncObject,
preIncObject,
`${cmd} didn't modify its input`
)
} else if (parsed) {
t.throws(() => {
parsed.inc(what, id, base)
})
} else {
t.equal(parsed, null)
}
})
t.end()
})
npm-node-semver-5993c2e/test/functions/lt.js 0000664 0000000 0000000 00000001503 15141150374 0021037 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const lt = require('../../functions/lt')
const comparisons = require('../fixtures/comparisons.js')
const equality = require('../fixtures/equality.js')
test('comparison tests', t => {
t.plan(comparisons.length)
comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(4)
t.ok(!lt(v0, v1, loose), `!lt('${v0}', '${v1}')`)
t.ok(lt(v1, v0, loose), `lt('${v1}', '${v0}')`)
t.ok(!lt(v1, v1, loose), `!lt('${v1}', '${v1}')`)
t.ok(!lt(v0, v0, loose), `!lt('${v0}', '${v0}')`)
}))
})
test('equality tests', t => {
t.plan(equality.length)
equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(2)
t.ok(!lt(v0, v1, loose), `!lt(${v0}, ${v1})`)
t.ok(!lt(v1, v0, loose), `!lt(${v1}, ${v0})`)
}))
})
npm-node-semver-5993c2e/test/functions/lte.js 0000664 0000000 0000000 00000001511 15141150374 0021203 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const lte = require('../../functions/lte')
const comparisons = require('../fixtures/comparisons.js')
const equality = require('../fixtures/equality.js')
test('comparison tests', t => {
t.plan(comparisons.length)
comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(4)
t.ok(!lte(v0, v1, loose), `!lte('${v0}', '${v1}')`)
t.ok(lte(v1, v0, loose), `lte('${v1}', '${v0}')`)
t.ok(lte(v1, v1, loose), `lte('${v1}', '${v1}')`)
t.ok(lte(v0, v0, loose), `lte('${v0}', '${v0}')`)
}))
})
test('equality tests', t => {
t.plan(equality.length)
equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(2)
t.ok(lte(v0, v1, loose), `lte(${v0}, ${v1})`)
t.ok(lte(v1, v0, loose), `lte(${v1}, ${v0})`)
}))
})
npm-node-semver-5993c2e/test/functions/major.js 0000664 0000000 0000000 00000001176 15141150374 0021536 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const major = require('../../functions/major')
test('major tests', (t) => {
// [range, version]
// Version should be detectable despite extra characters
[
['1.2.3', 1],
[' 1.2.3 ', 1],
[' 2.2.3-4 ', 2],
[' 3.2.3-pre ', 3],
['v5.2.3', 5],
[' v8.2.3 ', 8],
['\t13.2.3', 13],
['=21.2.3', 21, true],
['v=34.2.3', 34, true],
].forEach((tuple) => {
const range = tuple[0]
const version = tuple[1]
const loose = tuple[2] || false
const msg = `major(${range}) = ${version}`
t.equal(major(range, loose), version, msg)
})
t.end()
})
npm-node-semver-5993c2e/test/functions/minor.js 0000664 0000000 0000000 00000001176 15141150374 0021552 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const minor = require('../../functions/minor')
test('minor tests', (t) => {
// [range, version]
// Version should be detectable despite extra characters
[
['1.1.3', 1],
[' 1.1.3 ', 1],
[' 1.2.3-4 ', 2],
[' 1.3.3-pre ', 3],
['v1.5.3', 5],
[' v1.8.3 ', 8],
['\t1.13.3', 13],
['=1.21.3', 21, true],
['v=1.34.3', 34, true],
].forEach((tuple) => {
const range = tuple[0]
const version = tuple[1]
const loose = tuple[2] || false
const msg = `minor(${range}) = ${version}`
t.equal(minor(range, loose), version, msg)
})
t.end()
})
npm-node-semver-5993c2e/test/functions/neq.js 0000664 0000000 0000000 00000001673 15141150374 0021213 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const neq = require('../../functions/neq')
const comparisons = require('../fixtures/comparisons.js')
const equality = require('../fixtures/equality.js')
test('comparison tests', t => {
t.plan(comparisons.length)
comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(4)
t.ok(neq(v0, v1, loose), `neq(${v0}, ${v1})`)
t.ok(neq(v1, v0, loose), `neq(${v1}, ${v0})`)
t.notOk(neq(v1, v1, loose), `!neq('${v1}', '${v1}')`)
t.notOk(neq(v0, v0, loose), `!neq('${v0}', '${v0}')`)
}))
})
test('equality tests', t => {
t.plan(equality.length)
equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => {
t.plan(4)
t.notOk(neq(v0, v1, loose), `!neq(${v0}, ${v1})`)
t.notOk(neq(v1, v0, loose), `!neq(${v1}, ${v0})`)
t.notOk(neq(v0, v0, loose), `!neq(${v0}, ${v0})`)
t.notOk(neq(v1, v1, loose), `!neq(${v1}, ${v1})`)
}))
})
npm-node-semver-5993c2e/test/functions/parse.js 0000664 0000000 0000000 00000002146 15141150374 0021536 0 ustar 00root root 0000000 0000000 'use strict'
const t = require('tap')
const parse = require('../../functions/parse')
const SemVer = require('../../classes/semver')
const invalidVersions = require('../fixtures/invalid-versions')
t.test('returns null instead of throwing when presented with garbage', t => {
t.plan(invalidVersions.length)
invalidVersions.forEach(([v, msg, opts]) =>
t.equal(parse(v, opts), null, msg))
})
t.test('throw errors if asked to', t => {
t.throws(() => {
parse('bad', null, true)
}, {
name: 'TypeError',
message: 'Invalid Version: bad',
})
t.throws(() => {
parse([], null, true)
}, {
name: 'TypeError',
message: 'Invalid version. Must be a string. Got type "object".',
})
t.end()
})
t.test('parse a version into a SemVer object', t => {
t.match(parse('1.2.3'), new SemVer('1.2.3'))
const s = new SemVer('4.5.6')
t.equal(parse(s), s, 'just return it if its a SemVer obj')
const loose = new SemVer('4.2.0', { loose: true })
t.match(parse('4.2.0', true), loose, 'looseness as a boolean')
t.match(parse('4.2.0', { loose: true }), loose, 'looseness as an option')
t.end()
})
npm-node-semver-5993c2e/test/functions/patch.js 0000664 0000000 0000000 00000001176 15141150374 0021525 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const patch = require('../../functions/patch')
test('patch tests', (t) => {
// [range, version]
// Version should be detectable despite extra characters
[
['1.2.1', 1],
[' 1.2.1 ', 1],
[' 1.2.2-4 ', 2],
[' 1.2.3-pre ', 3],
['v1.2.5', 5],
[' v1.2.8 ', 8],
['\t1.2.13', 13],
['=1.2.21', 21, true],
['v=1.2.34', 34, true],
].forEach((tuple) => {
const range = tuple[0]
const version = tuple[1]
const loose = tuple[2] || false
const msg = `patch(${range}) = ${version}`
t.equal(patch(range, loose), version, msg)
})
t.end()
})
npm-node-semver-5993c2e/test/functions/prerelease.js 0000664 0000000 0000000 00000001270 15141150374 0022550 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const prerelease = require('../../functions/prerelease')
test('prerelease', (t) => {
// [prereleaseParts, version, loose]
[
[['alpha', 1], '1.2.2-alpha.1'],
[[1], '0.6.1-1'],
[['beta', 2], '1.0.0-beta.2'],
[['pre'], 'v0.5.4-pre'],
[['alpha', 1], '1.2.2-alpha.1', false],
[['beta'], '0.6.1beta', true],
[null, '1.0.0', true],
[null, '~2.0.0-alpha.1', false],
[null, 'invalid version'],
].forEach((tuple) => {
const expected = tuple[0]
const version = tuple[1]
const loose = tuple[2]
const msg = `prerelease(${version})`
t.same(prerelease(version, loose), expected, msg)
})
t.end()
})
npm-node-semver-5993c2e/test/functions/rcompare.js 0000664 0000000 0000000 00000000463 15141150374 0022234 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const rcompare = require('../../functions/rcompare')
test('rcompare', (t) => {
t.equal(rcompare('1.0.0', '1.0.1'), 1)
t.equal(rcompare('1.0.0', '1.0.0'), 0)
t.equal(rcompare('1.0.0+0', '1.0.0'), 0)
t.equal(rcompare('1.0.1', '1.0.0'), -1)
t.end()
})
npm-node-semver-5993c2e/test/functions/rsort.js 0000664 0000000 0000000 00000000532 15141150374 0021572 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const rsort = require('../../functions/rsort')
test('sorting', (t) => {
const list = [
'1.2.3+1',
'1.2.3+0',
'1.2.3',
'5.9.6',
'0.1.2',
]
const rsorted = [
'5.9.6',
'1.2.3+1',
'1.2.3+0',
'1.2.3',
'0.1.2',
]
t.same(rsort(list), rsorted)
t.end()
})
npm-node-semver-5993c2e/test/functions/satisfies.js 0000664 0000000 0000000 00000001754 15141150374 0022422 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const satisfies = require('../../functions/satisfies')
const rangeInclude = require('../fixtures/range-include.js')
const rangeExclude = require('../fixtures/range-exclude.js')
test('range tests', t => {
t.plan(rangeInclude.length)
rangeInclude.forEach(([range, ver, options]) =>
t.ok(satisfies(ver, range, options), `${range} satisfied by ${ver}`))
})
test('negative range tests', t => {
t.plan(rangeExclude.length)
rangeExclude.forEach(([range, ver, options]) =>
t.notOk(satisfies(ver, range, options), `${range} not satisfied by ${ver}`))
})
test('invalid ranges never satisfied (but do not throw)', t => {
const cases = [
['blerg', '1.2.3'],
['git+https://user:password0123@github.com/foo', '123.0.0', true],
['^1.2.3', '2.0.0-pre'],
['0.x', undefined],
['*', undefined],
]
t.plan(cases.length)
cases.forEach(([range, ver]) =>
t.notOk(satisfies(ver, range), `${range} not satisfied because invalid`))
})
npm-node-semver-5993c2e/test/functions/sort.js 0000664 0000000 0000000 00000000526 15141150374 0021413 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const sort = require('../../functions/sort')
test('sorting', (t) => {
const list = [
'1.2.3+1',
'1.2.3+0',
'1.2.3',
'5.9.6',
'0.1.2',
]
const sorted = [
'0.1.2',
'1.2.3',
'1.2.3+0',
'1.2.3+1',
'5.9.6',
]
t.same(sort(list), sorted)
t.end()
})
npm-node-semver-5993c2e/test/functions/valid.js 0000664 0000000 0000000 00000002263 15141150374 0021523 0 ustar 00root root 0000000 0000000 'use strict'
const t = require('tap')
const valid = require('../../functions/valid')
const SemVer = require('../../classes/semver')
const invalidVersions = require('../fixtures/invalid-versions')
const { MAX_SAFE_INTEGER } = require('../../internal/constants')
t.test('returns null instead of throwing when presented with garbage', t => {
t.plan(invalidVersions.length)
invalidVersions.forEach(([v, msg, opts]) =>
t.equal(valid(v, opts), null, msg))
})
t.test('validate a version into a SemVer object', t => {
t.equal(valid('1.2.3'), '1.2.3')
const s = new SemVer('4.5.6')
t.equal(valid(s), '4.5.6', 'return the version if a SemVer obj')
t.equal(valid('4.2.0foo', true), '4.2.0-foo', 'looseness as a boolean')
t.equal(valid('4.2.0foo', { loose: true }), '4.2.0-foo', 'looseness as an option')
t.end()
})
t.test('long build id', t => {
const longBuild = '-928490632884417731e7af463c92b034d6a78268fc993bcb88a57944'
const shortVersion = '1.1.1'
const longVersion = `${MAX_SAFE_INTEGER}.${MAX_SAFE_INTEGER}.${MAX_SAFE_INTEGER}`
t.equal(valid(shortVersion + longBuild), shortVersion + longBuild)
t.equal(valid(longVersion + longBuild), longVersion + longBuild)
t.end()
})
npm-node-semver-5993c2e/test/index.js 0000664 0000000 0000000 00000000540 15141150374 0017517 0 ustar 00root root 0000000 0000000 'use strict'
const t = require('tap')
const semver = require('../')
const { SEMVER_SPEC_VERSION } = require('../internal/constants')
t.match(Object.getOwnPropertyDescriptor(semver, 'SEMVER_SPEC_VERSION'), {
get: undefined,
set: undefined,
value: SEMVER_SPEC_VERSION,
configurable: true,
enumerable: true,
}, 'just a normal value property')
npm-node-semver-5993c2e/test/integration/ 0000775 0000000 0000000 00000000000 15141150374 0020376 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/test/integration/whitespace.js 0000664 0000000 0000000 00000003304 15141150374 0023070 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const Range = require('../../classes/range')
const SemVer = require('../../classes/semver')
const Comparator = require('../../classes/comparator')
const validRange = require('../../ranges/valid')
const minVersion = require('../../ranges/min-version')
const minSatisfying = require('../../ranges/min-satisfying')
const maxSatisfying = require('../../ranges/max-satisfying')
const wsMedium = ' '.repeat(125)
const wsLarge = ' '.repeat(500000)
const zeroLarge = '0'.repeat(500000)
test('range with whitespace', (t) => {
// a range with these extra characters would take a few minutes to process if
// any redos susceptible regexes were used. there is a global tap timeout per
// file set in the package.json that will error if this test takes too long.
const r = `1.2.3 ${wsLarge} <1.3.0`
t.equal(new Range(r).range, '1.2.3 <1.3.0')
t.equal(validRange(r), '1.2.3 <1.3.0')
t.equal(minVersion(r).version, '1.2.3')
t.equal(minSatisfying(['1.2.3'], r), '1.2.3')
t.equal(maxSatisfying(['1.2.3'], r), '1.2.3')
t.end()
})
test('range with 0', (t) => {
const r = `1.2.3 ${zeroLarge} <1.3.0`
t.throws(() => new Range(r).range)
t.equal(validRange(r), null)
t.throws(() => minVersion(r).version)
t.equal(minSatisfying(['1.2.3'], r), null)
t.equal(maxSatisfying(['1.2.3'], r), null)
t.end()
})
test('semver version', (t) => {
const v = `${wsMedium}1.2.3${wsMedium}`
const tooLong = `${wsLarge}1.2.3${wsLarge}`
t.equal(new SemVer(v).version, '1.2.3')
t.throws(() => new SemVer(tooLong))
t.end()
})
test('comparator', (t) => {
const comparator = `${wsLarge}<${wsLarge}1.2.3${wsLarge}`
t.equal(new Comparator(comparator).value, '<1.2.3')
t.end()
})
npm-node-semver-5993c2e/test/internal/ 0000775 0000000 0000000 00000000000 15141150374 0017667 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/test/internal/constants.js 0000664 0000000 0000000 00000000453 15141150374 0022243 0 ustar 00root root 0000000 0000000 'use strict'
const t = require('tap')
const constants = require('../../internal/constants')
t.match(constants, {
MAX_LENGTH: Number,
MAX_SAFE_COMPONENT_LENGTH: Number,
MAX_SAFE_INTEGER: Number,
RELEASE_TYPES: Array,
SEMVER_SPEC_VERSION: String,
}, 'got appropriate data types exported')
npm-node-semver-5993c2e/test/internal/debug.js 0000664 0000000 0000000 00000002217 15141150374 0021315 0 ustar 00root root 0000000 0000000 'use strict'
const main = () => {
const t = require('tap')
const { spawn } = require('child_process')
t.plan(2)
t.test('without env set', t => {
const c = spawn(process.execPath, [__filename, 'child'], { env: {
...process.env,
NODE_DEBUG: '',
} })
const err = []
c.stderr.on('data', chunk => err.push(chunk))
c.on('close', (code, signal) => {
t.equal(code, 0, 'success exit status')
t.equal(signal, null, 'no signal')
t.equal(Buffer.concat(err).toString('utf8'), '', 'got no output')
t.end()
})
})
t.test('with env set', t => {
const c = spawn(process.execPath, [__filename, 'child'], { env: {
...process.env,
NODE_DEBUG: 'semver',
} })
const err = []
c.stderr.on('data', chunk => err.push(chunk))
c.on('close', (code, signal) => {
t.equal(code, 0, 'success exit status')
t.equal(signal, null, 'no signal')
t.equal(Buffer.concat(err).toString('utf8'), 'SEMVER hello, world\n', 'got expected output')
t.end()
})
})
t.end()
}
if (process.argv[2] === 'child') {
require('../../internal/debug')('hello, world')
} else {
main()
}
npm-node-semver-5993c2e/test/internal/identifiers.js 0000664 0000000 0000000 00000001153 15141150374 0022532 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const { compareIdentifiers, rcompareIdentifiers } = require('../../internal/identifiers')
test('rcompareIdentifiers and compareIdentifiers', (t) => {
const set = [
['1', '2'],
['alpha', 'beta'],
['0', 'beta'],
[1, 2],
]
set.forEach((ab) => {
const a = ab[0]
const b = ab[1]
t.equal(compareIdentifiers(a, b), -1)
t.equal(rcompareIdentifiers(a, b), 1)
})
t.equal(compareIdentifiers('0', '0'), 0)
t.equal(rcompareIdentifiers('0', '0'), 0)
t.equal(compareIdentifiers(1, 1), 0)
t.equal(rcompareIdentifiers(1, 1), 0)
t.end()
})
npm-node-semver-5993c2e/test/internal/lrucache.js 0000664 0000000 0000000 00000000654 15141150374 0022020 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const LRUCache = require('../../internal/lrucache')
test('basic cache operation', t => {
const c = new LRUCache()
const max = 1000
for (let i = 0; i < max; i++) {
t.equal(c.set(i, i), c)
}
for (let i = 0; i < max; i++) {
t.equal(c.get(i), i)
}
c.set(1001, 1001)
// lru item should be gone
t.equal(c.get(0), undefined)
c.set(42, undefined)
t.end()
})
npm-node-semver-5993c2e/test/internal/parse-options.js 0000664 0000000 0000000 00000003075 15141150374 0023035 0 ustar 00root root 0000000 0000000 'use strict'
const t = require('tap')
const parseOptions = require('../../internal/parse-options.js')
t.test('falsey values always empty options object', t => {
t.strictSame(parseOptions(null), {})
t.strictSame(parseOptions(false), {})
t.strictSame(parseOptions(undefined), {})
t.strictSame(parseOptions(), {})
t.strictSame(parseOptions(0), {})
t.strictSame(parseOptions(''), {})
t.end()
})
t.test('truthy non-objects always loose mode, for backwards comp', t => {
t.strictSame(parseOptions('hello'), { loose: true })
t.strictSame(parseOptions(true), { loose: true })
t.strictSame(parseOptions(1), { loose: true })
t.end()
})
t.test('any object passed is returned', t => {
t.strictSame(parseOptions(/asdf/), /asdf/)
t.strictSame(parseOptions(new Error('hello')), new Error('hello'))
t.strictSame(parseOptions({ loose: true, a: 1, rtl: false }), { loose: true, a: 1, rtl: false })
t.strictSame(parseOptions({ loose: 1, rtl: 2, includePrerelease: 10 }), {
loose: 1,
rtl: 2,
includePrerelease: 10,
})
t.strictSame(parseOptions({ loose: true }), { loose: true })
t.strictSame(parseOptions({ rtl: true }), { rtl: true })
t.strictSame(parseOptions({ includePrerelease: true }), { includePrerelease: true })
t.strictSame(parseOptions({ loose: true, rtl: true }), { loose: true, rtl: true })
t.strictSame(parseOptions({ loose: true, includePrerelease: true }), {
loose: true,
includePrerelease: true,
})
t.strictSame(parseOptions({ rtl: true, includePrerelease: true }), {
rtl: true,
includePrerelease: true,
})
t.end()
})
npm-node-semver-5993c2e/test/internal/re.js 0000664 0000000 0000000 00000001636 15141150374 0020641 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const { src, re, safeRe, safeSrc } = require('../../internal/re')
const semver = require('../../')
test('Semver itself has a list of src, re, and tokens', (t) => {
t.match(Object.assign({}, semver), {
re: Array,
src: Array,
tokens: Object,
})
re.forEach(r => t.match(r, RegExp, 'regexps are regexps'))
safeRe.forEach(r => t.match(r, RegExp, 'safe regexps are regexps'))
src.forEach(s => t.match(s, String, 'src are strings'))
safeSrc.forEach(s => t.match(s, String, 'safe srcare strings'))
t.ok(Object.keys(semver.tokens).length, 'there are tokens')
for (const i in semver.tokens) {
t.match(semver.tokens[i], Number, 'tokens are numbers')
}
safeRe.forEach(r => {
t.notMatch(r.source, '\\s+', 'safe regex do not contain greedy whitespace')
t.notMatch(r.source, '\\s*', 'safe regex do not contain greedy whitespace')
})
t.end()
})
npm-node-semver-5993c2e/test/map.js 0000664 0000000 0000000 00000002410 15141150374 0017163 0 ustar 00root root 0000000 0000000 'use strict'
const t = require('tap')
const { resolve, join, relative, extname, dirname, basename } = require('path')
const { statSync, readdirSync } = require('fs')
const map = require('../map.js')
const pkg = require('../package.json')
const ROOT = resolve(__dirname, '..')
const TEST = join(ROOT, 'test')
const IGNORE_DIRS = ['fixtures', 'integration']
const getFile = (f) => {
try {
if (statSync(f).isFile()) {
return extname(f) === '.js' ? [f] : []
}
} catch {
return []
}
}
const walk = (item, res = []) => getFile(item) || readdirSync(item)
.map(f => join(item, f))
.reduce((acc, f) => acc.concat(statSync(f).isDirectory() ? walk(f, res) : getFile(f)), [])
.filter(Boolean)
const walkAll = (items, relativeTo) => items
.reduce((acc, f) => acc.concat(walk(join(ROOT, f))), [])
.map((f) => relative(relativeTo, f))
.sort()
t.test('tests match system', t => {
const sut = walkAll([pkg.tap['coverage-map'], ...pkg.files], ROOT)
const tests = walkAll([basename(TEST)], TEST)
.filter(f => !IGNORE_DIRS.includes(dirname(f)))
t.strictSame(sut, tests, 'test files should match system files')
for (const f of tests) {
t.test(f, t => {
t.plan(1)
t.ok(sut.includes(map(f)), 'test covers a file')
})
}
t.end()
})
npm-node-semver-5993c2e/test/preload.js 0000664 0000000 0000000 00000000250 15141150374 0020034 0 ustar 00root root 0000000 0000000 'use strict'
const t = require('tap')
const preload = require('../preload.js')
const index = require('../index.js')
t.equal(preload, index, 'preload and index match')
npm-node-semver-5993c2e/test/ranges/ 0000775 0000000 0000000 00000000000 15141150374 0017332 5 ustar 00root root 0000000 0000000 npm-node-semver-5993c2e/test/ranges/gtr.js 0000664 0000000 0000000 00000001635 15141150374 0020471 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const gtr = require('../../ranges/gtr')
const versionGtr = require('../fixtures/version-gt-range')
const versionNotGtr = require('../fixtures/version-not-gt-range')
test('gtr tests', (t) => {
// [range, version, options]
// Version should be greater than range
versionGtr.forEach((tuple) => {
const range = tuple[0]
const version = tuple[1]
const options = tuple[2] || false
const msg = `gtr(${version}, ${range}, ${options})`
t.ok(gtr(version, range, options), msg)
})
t.end()
})
test('negative gtr tests', (t) => {
// [range, version, options]
// Version should NOT be greater than range
versionNotGtr.forEach((tuple) => {
const range = tuple[0]
const version = tuple[1]
const options = tuple[2] || false
const msg = `!gtr(${version}, ${range}, ${options})`
t.notOk(gtr(version, range, options), msg)
})
t.end()
})
npm-node-semver-5993c2e/test/ranges/intersects.js 0000664 0000000 0000000 00000004650 15141150374 0022060 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const intersects = require('../../ranges/intersects')
const Range = require('../../classes/range')
const Comparator = require('../../classes/comparator')
const comparatorIntersection = require('../fixtures/comparator-intersection.js')
const rangeIntersection = require('../fixtures/range-intersection.js')
test('intersect comparators', t => {
t.plan(comparatorIntersection.length)
comparatorIntersection.forEach(([c0, c1, expect, includePrerelease]) =>
t.test(`${c0} ${c1} ${expect}`, t => {
const opts = { loose: false, includePrerelease }
const comp0 = new Comparator(c0)
const comp1 = new Comparator(c1)
t.equal(intersects(comp0, comp1, opts), expect, `${c0} intersects ${c1} objects`)
t.equal(intersects(comp1, comp0, opts), expect, `${c1} intersects ${c0} objects`)
t.equal(intersects(c0, c1, opts), expect, `${c0} intersects ${c1}`)
t.equal(intersects(c1, c0, opts), expect, `${c1} intersects ${c0}`)
opts.loose = true
t.equal(intersects(comp0, comp1, opts), expect, `${c0} intersects ${c1} loose, objects`)
t.equal(intersects(comp1, comp0, opts), expect, `${c1} intersects ${c0} loose, objects`)
t.equal(intersects(c0, c1, opts), expect, `${c0} intersects ${c1} loose`)
t.equal(intersects(c1, c0, opts), expect, `${c1} intersects ${c0} loose`)
t.end()
}))
})
test('ranges intersect', (t) => {
rangeIntersection.forEach(([r0, r1, expect]) => {
t.test(`${r0} <~> ${r1}`, t => {
const range0 = new Range(r0)
const range1 = new Range(r1)
t.equal(intersects(r1, r0), expect, `${r0} <~> ${r1}`)
t.equal(intersects(r0, r1), expect, `${r1} <~> ${r0}`)
t.equal(intersects(r1, r0, true), expect, `${r0} <~> ${r1} loose`)
t.equal(intersects(r0, r1, true), expect, `${r1} <~> ${r0} loose`)
t.equal(intersects(range0, range1), expect, `${r0} <~> ${r1} objects`)
t.equal(intersects(range1, range0), expect, `${r1} <~> ${r0} objects`)
t.equal(intersects(range0, range1, true), expect,
`${r0} <~> ${r1} objects loose`)
t.equal(intersects(range1, range0, true), expect,
`${r1} <~> ${r0} objects loose`)
t.end()
})
})
t.end()
})
test('missing comparator parameter in intersect comparators', (t) => {
t.throws(() => {
new Comparator('>1.0.0').intersects()
}, new TypeError('a Comparator is required'),
'throws type error')
t.end()
})
npm-node-semver-5993c2e/test/ranges/ltr.js 0000664 0000000 0000000 00000001423 15141150374 0020471 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const ltr = require('../../ranges/ltr')
const versionLtr = require('../fixtures/version-lt-range')
const versionNotLtr = require('../fixtures/version-not-lt-range')
test('ltr tests', (t) => {
// [range, version, options]
// Version should be less than range
versionLtr.forEach(([range, version, options = false]) => {
const msg = `ltr(${version}, ${range}, ${options})`
t.ok(ltr(version, range, options), msg)
})
t.end()
})
test('negative ltr tests', (t) => {
// [range, version, options]
// Version should NOT be less than range
versionNotLtr.forEach(([range, version, options = false]) => {
const msg = `!ltr(${version}, ${range}, ${options})`
t.notOk(ltr(version, range, options), msg)
})
t.end()
})
npm-node-semver-5993c2e/test/ranges/max-satisfying.js 0000664 0000000 0000000 00000001404 15141150374 0022632 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const maxSatisfying = require('../../ranges/max-satisfying')
test('max satisfying', (t) => {
[[['1.2.3', '1.2.4'], '1.2', '1.2.4'],
[['1.2.4', '1.2.3'], '1.2', '1.2.4'],
[['1.2.3', '1.2.4', '1.2.5', '1.2.6'], '~1.2.3', '1.2.6'],
[['1.1.0', '1.2.0', '1.2.1', '1.3.0', '2.0.0b1', '2.0.0b2', '2.0.0b3', '2.0.0', '2.1.0'],
'~2.0.0', '2.0.0', true],
].forEach((v) => {
const versions = v[0]
const range = v[1]
const expect = v[2]
const loose = v[3]
const actual = maxSatisfying(versions, range, loose)
t.equal(actual, expect)
})
t.end()
})
test('bad ranges in max satisfying', (t) => {
const r = 'some frogs and sneks-v2.5.6'
t.equal(maxSatisfying([], r), null)
t.end()
})
npm-node-semver-5993c2e/test/ranges/min-satisfying.js 0000664 0000000 0000000 00000001404 15141150374 0022630 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const minSatisfying = require('../../ranges/min-satisfying')
test('min satisfying', (t) => {
[[['1.2.3', '1.2.4'], '1.2', '1.2.3'],
[['1.2.4', '1.2.3'], '1.2', '1.2.3'],
[['1.2.3', '1.2.4', '1.2.5', '1.2.6'], '~1.2.3', '1.2.3'],
[['1.1.0', '1.2.0', '1.2.1', '1.3.0', '2.0.0b1', '2.0.0b2', '2.0.0b3', '2.0.0', '2.1.0'],
'~2.0.0', '2.0.0', true],
].forEach((v) => {
const versions = v[0]
const range = v[1]
const expect = v[2]
const loose = v[3]
const actual = minSatisfying(versions, range, loose)
t.equal(actual, expect)
})
t.end()
})
test('bad ranges in min satisfying', (t) => {
const r = 'some frogs and sneks-v2.5.6'
t.equal(minSatisfying([], r), null)
t.end()
})
npm-node-semver-5993c2e/test/ranges/min-version.js 0000664 0000000 0000000 00000003717 15141150374 0022146 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const minVersion = require('../../ranges/min-version')
test('minimum version in range tests', (t) => {
// [range, minimum, loose]
[
// Stars
['*', '0.0.0'],
['* || >=2', '0.0.0'],
['>=2 || *', '0.0.0'],
['>2 || *', '0.0.0'],
// equal
['1.0.0', '1.0.0'],
['1.0', '1.0.0'],
['1.0.x', '1.0.0'],
['1.0.*', '1.0.0'],
['1', '1.0.0'],
['1.x.x', '1.0.0'],
['1.x.x', '1.0.0'],
['1.*.x', '1.0.0'],
['1.x.*', '1.0.0'],
['1.x', '1.0.0'],
['1.*', '1.0.0'],
['=1.0.0', '1.0.0'],
// Tilde
['~1.1.1', '1.1.1'],
['~1.1.1-beta', '1.1.1-beta'],
['~1.1.1 || >=2', '1.1.1'],
// Caret
['^1.1.1', '1.1.1'],
['^1.1.1-beta', '1.1.1-beta'],
['^1.1.1 || >=2', '1.1.1'],
['^2.16.2 ^2.16', '2.16.2'],
// '-' operator
['1.1.1 - 1.8.0', '1.1.1'],
['1.1 - 1.8.0', '1.1.0'],
// Less / less or equal
['<2', '0.0.0'],
['<0.0.0-beta', '0.0.0-0'],
['<0.0.1-beta', '0.0.0'],
['<2 || >4', '0.0.0'],
['>4 || <2', '0.0.0'],
['<=2 || >=4', '0.0.0'],
['>=4 || <=2', '0.0.0'],
['<0.0.0-beta >0.0.0-alpha', '0.0.0-alpha.0'],
['>0.0.0-alpha <0.0.0-beta', '0.0.0-alpha.0'],
// Greater than or equal
['>=1.1.1 <2 || >=2.2.2 <2', '1.1.1'],
['>=2.2.2 <2 || >=1.1.1 <2', '1.1.1'],
// Greater than but not equal
['>1.0.0', '1.0.1'],
['>1.0.0-0', '1.0.0-0.0'],
['>1.0.0-beta', '1.0.0-beta.0'],
['>2 || >1.0.0', '1.0.1'],
['>2 || >1.0.0-0', '1.0.0-0.0'],
['>2 || >1.0.0-beta', '1.0.0-beta.0'],
// Impossible range
['>4 <3', null],
].forEach((tuple) => {
const range = tuple[0]
const version = tuple[1]
const loose = tuple[2] || false
const msg = `minVersion(${range}, ${loose}) = ${version}`
const min = minVersion(range, loose)
t.ok(min === version || (min && min.version === version), msg, {
found: min,
wanted: version,
})
})
t.end()
})
npm-node-semver-5993c2e/test/ranges/outside.js 0000664 0000000 0000000 00000003325 15141150374 0021347 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const outside = require('../../ranges/outside')
const versionGtr = require('../fixtures/version-gt-range')
const versionNotGtr = require('../fixtures/version-not-gt-range')
const versionLtr = require('../fixtures/version-lt-range')
const versionNotLtr = require('../fixtures/version-not-lt-range')
test('gtr tests', (t) => {
// [range, version, options]
// Version should be greater than range
versionGtr.forEach(([range, version, options = false]) => {
const msg = `outside(${version}, ${range}, > ${options})`
t.ok(outside(version, range, '>', options), msg)
})
t.end()
})
test('ltr tests', (t) => {
// [range, version, options]
// Version should be less than range
versionLtr.forEach(([range, version, options = false]) => {
const msg = `outside(${version}, ${range}, <, ${options})`
t.ok(outside(version, range, '<', options), msg)
})
t.end()
})
test('negative gtr tests', (t) => {
// [range, version, options]
// Version should NOT be greater than range
versionNotGtr.forEach(([range, version, options = false]) => {
const msg = `!outside(${version}, ${range}, > ${options})`
t.notOk(outside(version, range, '>', options), msg)
})
t.end()
})
test('negative ltr tests', (t) => {
// [range, version, options]
// Version should NOT be less than range
versionNotLtr.forEach(([range, version, options = false]) => {
const msg = `!outside(${version}, ${range}, < ${options})`
t.notOk(outside(version, range, '<', options), msg)
})
t.end()
})
test('outside with bad hilo throws', (t) => {
t.throws(() => {
outside('1.2.3', '>1.5.0', 'blerg', true)
}, new TypeError('Must provide a hilo val of "<" or ">"'))
t.end()
})
npm-node-semver-5993c2e/test/ranges/simplify.js 0000664 0000000 0000000 00000001654 15141150374 0021532 0 ustar 00root root 0000000 0000000 'use strict'
const simplify = require('../../ranges/simplify.js')
const Range = require('../../classes/range.js')
const t = require('tap')
const versions = [
'1.0.0',
'1.0.1',
'1.0.2',
'1.0.3',
'1.0.4',
'1.1.0',
'1.1.1',
'1.1.2',
'1.2.0',
'1.2.1',
'1.2.2',
'1.2.3',
'1.2.4',
'1.2.5',
'2.0.0',
'2.0.1',
'2.1.0',
'2.1.1',
'2.1.2',
'2.2.0',
'2.2.1',
'2.2.2',
'2.3.0',
'2.3.1',
'2.4.0',
'3.0.0',
'3.1.0',
'3.2.0',
'3.3.0',
]
t.equal(simplify(versions, '1.x'), '1.x')
t.equal(simplify(versions, '1.0.0 || 1.0.1 || 1.0.2 || 1.0.3 || 1.0.4'), '<=1.0.4')
t.equal(simplify(versions, new Range('1.0.0 || 1.0.1 || 1.0.2 || 1.0.3 || 1.0.4')), '<=1.0.4')
t.equal(simplify(versions, '>=3.0.0 <3.1.0'), '3.0.0')
t.equal(simplify(versions, '3.0.0 || 3.1 || 3.2 || 3.3'), '>=3.0.0')
t.equal(simplify(versions, '1 || 2 || 3'), '*')
t.equal(simplify(versions, '2.1 || 2.2 || 2.3'), '2.1.0 - 2.3.1')
npm-node-semver-5993c2e/test/ranges/subset.js 0000664 0000000 0000000 00000011254 15141150374 0021200 0 ustar 00root root 0000000 0000000 'use strict'
const t = require('tap')
const subset = require('../../ranges/subset.js')
const Range = require('../../classes/range')
// sub, dom, expect, [options]
const cases = [
['1.2.3', '1.2.3', true],
['1.2.3', '1.x', true],
['1.2.3 1.2.4', '1.2.3', true],
['1.2.3 1.2.4', '1.2.9', true], // null set is subset of everything
['1.2.3', '>1.2.0', true],
['1.2.3 2.3.4 || 2.3.4', '3', false],
['^1.2.3-pre.0', '1.x', false],
['^1.2.3-pre.0', '1.x', true, { includePrerelease: true }],
['>2 <1', '3', true],
['1 || 2 || 3', '>=1.0.0', true],
// everything is a subset of *
['1.2.3', '*', true],
['^1.2.3', '*', true],
['^1.2.3-pre.0', '*', false],
['^1.2.3-pre.0', '*', true, { includePrerelease: true }],
['1 || 2 || 3', '*', true],
// prerelease edge cases
['^1.2.3-pre.0', '>=1.0.0', false],
['^1.2.3-pre.0', '>=1.0.0', true, { includePrerelease: true }],
['^1.2.3-pre.0', '>=1.2.3-pre.0', true],
['^1.2.3-pre.0', '>=1.2.3-pre.0', true, { includePrerelease: true }],
['>1.2.3-pre.0', '>=1.2.3-pre.0', true],
['>1.2.3-pre.0', '>1.2.3-pre.0 || 2', true],
['1 >1.2.3-pre.0', '>1.2.3-pre.0', true],
['1 <=1.2.3-pre.0', '>=1.0.0-0', false],
['1 <=1.2.3-pre.0', '>=1.0.0-0', true, { includePrerelease: true }],
['1 <=1.2.3-pre.0', '<=1.2.3-pre.0', true],
['1 <=1.2.3-pre.0', '<=1.2.3-pre.0', true, { includePrerelease: true }],
['<1.2.3-pre.0', '<=1.2.3-pre.0', true],
['<1.2.3-pre.0', '<1.2.3-pre.0 || 2', true],
['1 <1.2.3-pre.0', '<1.2.3-pre.0', true],
['*', '*', true],
['', '*', true],
['*', '', true],
['', '', true],
// >=0.0.0 is like * in non-prerelease mode
// >=0.0.0-0 is like * in prerelease mode
['*', '>=0.0.0-0', true, { includePrerelease: true }],
// true because these are identical in non-PR mode
['*', '>=0.0.0', true],
// false because * includes 0.0.0-0 in PR mode
['*', '>=0.0.0', false, { includePrerelease: true }],
// true because * doesn't include 0.0.0-0 in non-PR mode
['*', '>=0.0.0-0', true],
['^2 || ^3 || ^4', '>=1', true],
['^2 || ^3 || ^4', '>1', true],
['^2 || ^3 || ^4', '>=2', true],
['^2 || ^3 || ^4', '>=3', false],
['>=1', '^2 || ^3 || ^4', false],
['>1', '^2 || ^3 || ^4', false],
['>=2', '^2 || ^3 || ^4', false],
['>=3', '^2 || ^3 || ^4', false],
['^1', '^2 || ^3 || ^4', false],
['^2', '^2 || ^3 || ^4', true],
['^3', '^2 || ^3 || ^4', true],
['^4', '^2 || ^3 || ^4', true],
['1.x', '^2 || ^3 || ^4', false],
['2.x', '^2 || ^3 || ^4', true],
['3.x', '^2 || ^3 || ^4', true],
['4.x', '^2 || ^3 || ^4', true],
['>=1.0.0 <=1.0.0 || 2.0.0', '1.0.0 || 2.0.0', true],
['<=1.0.0 >=1.0.0 || 2.0.0', '1.0.0 || 2.0.0', true],
['>=1.0.0', '1.0.0', false],
['>=1.0.0 <2.0.0', '<2.0.0', true],
['>=1.0.0 <2.0.0', '>0.0.0', true],
['>=1.0.0 <=1.0.0', '1.0.0', true],
['>=1.0.0 <=1.0.0', '2.0.0', false],
['<2.0.0', '>=1.0.0 <2.0.0', false],
['>=1.0.0', '>=1.0.0 <2.0.0', false],
['>=1.0.0 <2.0.0', '<2.0.0', true],
['>=1.0.0 <2.0.0', '>=1.0.0', true],
['>=1.0.0 <2.0.0', '>1.0.0', false],
['>=1.0.0 <=2.0.0', '<2.0.0', false],
['>=1.0.0', '<1.0.0', false],
['<=1.0.0', '>1.0.0', false],
['<=1.0.0 >1.0.0', '>1.0.0', true],
['1.0.0 >1.0.0', '>1.0.0', true],
['1.0.0 <1.0.0', '>1.0.0', true],
['<1 <2 <3', '<4', true],
['<3 <2 <1', '<4', true],
['>1 >2 >3', '>0', true],
['>3 >2 >1', '>0', true],
['<=1 <=2 <=3', '<4', true],
['<=3 <=2 <=1', '<4', true],
['>=1 >=2 >=3', '>0', true],
['>=3 >=2 >=1', '>0', true],
['>=3 >=2 >=1', '>=3 >=2 >=1', true],
['>2.0.0', '>=2.0.0', true],
]
t.plan(cases.length + 1)
cases.forEach(([sub, dom, expect, options]) => {
const msg = `${sub || "''"} ⊂ ${dom || "''"} = ${expect}` +
(options ? ' ' + Object.keys(options).join(',') : '')
t.equal(subset(sub, dom, options), expect, msg)
})
t.test('range should be subset of itself in obj or string mode', t => {
const range = '^1'
t.equal(subset(range, range), true)
t.equal(subset(range, new Range(range)), true)
t.equal(subset(new Range(range), range), true)
t.equal(subset(new Range(range), new Range(range)), true)
// test with using the same actual object
const r = new Range(range)
t.equal(subset(r, r), true)
// different range object with same set array
const r2 = new Range(range)
r2.set = r.set
t.equal(subset(r2, r), true)
t.equal(subset(r, r2), true)
// different range with set with same simple set arrays
const r3 = new Range(range)
r3.set = [...r.set]
t.equal(subset(r3, r), true)
t.equal(subset(r, r3), true)
// different range with set with simple sets with same comp objects
const r4 = new Range(range)
r4.set = r.set.map(s => [...s])
t.equal(subset(r4, r), true)
t.equal(subset(r, r4), true)
t.end()
})
npm-node-semver-5993c2e/test/ranges/to-comparators.js 0000664 0000000 0000000 00000006114 15141150374 0022644 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const toComparators = require('../../ranges/to-comparators')
test('comparators test', (t) => {
// [range, comparators]
// turn range into a set of individual comparators
[['1.0.0 - 2.0.0', [['>=1.0.0', '<=2.0.0']]],
['1.0.0', [['1.0.0']]],
['>=*', [['']]],
['', [['']]],
['*', [['']]],
['*', [['']]],
['>=1.0.0', [['>=1.0.0']]],
['>=1.0.0', [['>=1.0.0']]],
['>=1.0.0', [['>=1.0.0']]],
['>1.0.0', [['>1.0.0']]],
['>1.0.0', [['>1.0.0']]],
['<=2.0.0', [['<=2.0.0']]],
['1', [['>=1.0.0', '<2.0.0-0']]],
['<=2.0.0', [['<=2.0.0']]],
['<=2.0.0', [['<=2.0.0']]],
['<2.0.0', [['<2.0.0']]],
['<2.0.0', [['<2.0.0']]],
['>= 1.0.0', [['>=1.0.0']]],
['>= 1.0.0', [['>=1.0.0']]],
['>= 1.0.0', [['>=1.0.0']]],
['> 1.0.0', [['>1.0.0']]],
['> 1.0.0', [['>1.0.0']]],
['<= 2.0.0', [['<=2.0.0']]],
['<= 2.0.0', [['<=2.0.0']]],
['<= 2.0.0', [['<=2.0.0']]],
['< 2.0.0', [['<2.0.0']]],
['<\t2.0.0', [['<2.0.0']]],
['>=0.1.97', [['>=0.1.97']]],
['>=0.1.97', [['>=0.1.97']]],
['0.1.20 || 1.2.4', [['0.1.20'], ['1.2.4']]],
['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]],
['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]],
['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]],
['||', [['']]],
['2.x.x', [['>=2.0.0', '<3.0.0-0']]],
['1.2.x', [['>=1.2.0', '<1.3.0-0']]],
['1.2.x || 2.x', [['>=1.2.0', '<1.3.0-0'], ['>=2.0.0', '<3.0.0-0']]],
['1.2.x || 2.x', [['>=1.2.0', '<1.3.0-0'], ['>=2.0.0', '<3.0.0-0']]],
['x', [['']]],
['2.*.*', [['>=2.0.0', '<3.0.0-0']]],
['1.2.*', [['>=1.2.0', '<1.3.0-0']]],
['1.2.* || 2.*', [['>=1.2.0', '<1.3.0-0'], ['>=2.0.0', '<3.0.0-0']]],
['1.2.* || 2.*', [['>=1.2.0', '<1.3.0-0'], ['>=2.0.0', '<3.0.0-0']]],
['*', [['']]],
['2', [['>=2.0.0', '<3.0.0-0']]],
['2.3', [['>=2.3.0', '<2.4.0-0']]],
['~2.4', [['>=2.4.0', '<2.5.0-0']]],
['~2.4', [['>=2.4.0', '<2.5.0-0']]],
['~>3.2.1', [['>=3.2.1', '<3.3.0-0']]],
['~1', [['>=1.0.0', '<2.0.0-0']]],
['~>1', [['>=1.0.0', '<2.0.0-0']]],
['~> 1', [['>=1.0.0', '<2.0.0-0']]],
['~1.0', [['>=1.0.0', '<1.1.0-0']]],
['~ 1.0', [['>=1.0.0', '<1.1.0-0']]],
['~ 1.0.3', [['>=1.0.3', '<1.1.0-0']]],
['~> 1.0.3', [['>=1.0.3', '<1.1.0-0']]],
['<1', [['<1.0.0-0']]],
['< 1', [['<1.0.0-0']]],
['>=1', [['>=1.0.0']]],
['>= 1', [['>=1.0.0']]],
['<1.2', [['<1.2.0-0']]],
['< 1.2', [['<1.2.0-0']]],
['1', [['>=1.0.0', '<2.0.0-0']]],
['1 2', [['>=1.0.0', '<2.0.0-0', '>=2.0.0', '<3.0.0-0']]],
['1.2 - 3.4.5', [['>=1.2.0', '<=3.4.5']]],
['1.2.3 - 3.4', [['>=1.2.3', '<3.5.0-0']]],
['1.2.3 - 3', [['>=1.2.3', '<4.0.0-0']]],
['>*', [['<0.0.0-0']]],
['<*', [['<0.0.0-0']]],
['>X', [['<0.0.0-0']]],
['* 2.x', [['<0.0.0-0']]],
['>x 2.x || * || {
const found = toComparators(pre)
const jw = JSON.stringify(wanted)
t.same(found, wanted, `toComparators(${pre}) === ${jw}`)
})
t.end()
})
npm-node-semver-5993c2e/test/ranges/valid.js 0000664 0000000 0000000 00000000720 15141150374 0020766 0 ustar 00root root 0000000 0000000 'use strict'
const { test } = require('tap')
const validRange = require('../../ranges/valid')
const rangeParse = require('../fixtures/range-parse.js')
test('valid range test', (t) => {
// validRange(range) -> result
// translate ranges into their canonical form
t.plan(rangeParse.length)
rangeParse.forEach(([pre, wanted, options]) =>
t.equal(validRange(pre, options), wanted,
`validRange(${pre}) === ${wanted} ${JSON.stringify(options)}`))
})