pax_global_header 0000666 0000000 0000000 00000000064 14452077232 0014520 g ustar 00root root 0000000 0000000 52 comment=36cd334708ec1f85a71445622fb1864bceee0f4e
node-semver-7.5.4/ 0000775 0000000 0000000 00000000000 14452077232 0013761 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/.commitlintrc.js 0000664 0000000 0000000 00000000553 14452077232 0017104 0 ustar 00root root 0000000 0000000 /* This file is automatically added by @npmcli/template-oss. Do not edit. */
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'deps', 'chore']],
'header-max-length': [2, 'always', 80],
'subject-case': [0, 'always', ['lower-case', 'sentence-case', 'start-case']],
},
}
node-semver-7.5.4/.eslintrc.js 0000664 0000000 0000000 00000000545 14452077232 0016224 0 ustar 00root root 0000000 0000000 /* This file is automatically added by @npmcli/template-oss. Do not edit. */
'use strict'
const { readdirSync: readdir } = require('fs')
const localConfigs = readdir(__dirname)
.filter((file) => file.startsWith('.eslintrc.local.'))
.map((file) => `./${file}`)
module.exports = {
root: true,
extends: [
'@npmcli',
...localConfigs,
],
}
node-semver-7.5.4/.eslintrc.local.js 0000664 0000000 0000000 00000000550 14452077232 0017311 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'],
},
},
],
}
node-semver-7.5.4/.github/ 0000775 0000000 0000000 00000000000 14452077232 0015321 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/.github/CODEOWNERS 0000664 0000000 0000000 00000000132 14452077232 0016710 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
* @npm/cli-team
node-semver-7.5.4/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 14452077232 0017504 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/.github/ISSUE_TEMPLATE/bug.yml 0000664 0000000 0000000 00000002655 14452077232 0021014 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
node-semver-7.5.4/.github/ISSUE_TEMPLATE/config.yml 0000664 0000000 0000000 00000000145 14452077232 0021474 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
blank_issues_enabled: true
node-semver-7.5.4/.github/dependabot.yml 0000664 0000000 0000000 00000000563 14452077232 0020155 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: daily
allow:
- dependency-type: direct
versioning-strategy: increase-if-necessary
commit-message:
prefix: deps
prefix-development: chore
labels:
- "Dependencies"
node-semver-7.5.4/.github/matchers/ 0000775 0000000 0000000 00000000000 14452077232 0017127 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/.github/matchers/tap.json 0000664 0000000 0000000 00000001204 14452077232 0020603 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
}
]
}
]
}
node-semver-7.5.4/.github/settings.yml 0000664 0000000 0000000 00000002733 14452077232 0017711 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
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: latest
protection:
required_status_checks: null
enforce_admins: 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/v*
protection:
required_status_checks: null
enforce_admins: 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" ]
node-semver-7.5.4/.github/workflows/ 0000775 0000000 0000000 00000000000 14452077232 0017356 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/.github/workflows/audit.yml 0000664 0000000 0000000 00000002120 14452077232 0021202 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Audit
on:
workflow_dispatch:
schedule:
# "At 08:00 UTC (01:00 PT) on Monday" https://crontab.guru/#0_8_*_*_1
- cron: "0 8 * * 1"
jobs:
audit:
name: Audit Dependencies
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@8
run: npm i --prefer-online --no-fund --no-audit -g npm@8
- name: npm Version
run: npm -v
- 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
node-semver-7.5.4/.github/workflows/ci-release.yml 0000664 0000000 0000000 00000015464 14452077232 0022124 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: CI - Release
on:
workflow_dispatch:
inputs:
ref:
required: true
type: string
default: main
workflow_call:
inputs:
ref:
required: true
type: string
check-sha:
required: true
type: string
jobs:
lint-all:
name: Lint All
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Get Workflow Job
uses: actions/github-script@v6
if: inputs.check-sha
id: check-output
env:
JOB_NAME: "Lint All"
MATRIX_NAME: ""
with:
script: |
const { owner, repo } = context.repo
const { data } = await github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id: context.runId,
per_page: 100
})
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
const job = data.jobs.find(j => j.name.endsWith(jobName))
const jobUrl = job?.html_url
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}`
let summary = `This check is assosciated with ${shaUrl}\n\n`
if (jobUrl) {
summary += `For run logs, click here: ${jobUrl}`
} else {
summary += `Run logs could not be found for a job with name: "${jobName}"`
}
return { summary }
- name: Create Check
uses: LouisBrunner/checks-action@v1.6.0
id: check
if: inputs.check-sha
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: in_progress
name: Lint All
sha: ${{ inputs.check-sha }}
output: ${{ steps.check-output.outputs.result }}
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@8
run: npm i --prefer-online --no-fund --no-audit -g npm@8
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Lint
run: npm run lint --ignore-scripts
- name: Post Lint
run: npm run postlint --ignore-scripts
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.6.0
if: steps.check.outputs.check_id && always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ job.status }}
check_id: ${{ steps.check.outputs.check_id }}
test-all:
name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
platform:
- name: Linux
os: ubuntu-latest
shell: bash
- name: macOS
os: macos-latest
shell: bash
- name: Windows
os: windows-latest
shell: cmd
node-version:
- 10.0.0
- 10.x
- 12.x
- 14.x
- 16.x
- 18.x
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- name: Get Workflow Job
uses: actions/github-script@v6
if: inputs.check-sha
id: check-output
env:
JOB_NAME: "Test All"
MATRIX_NAME: " - ${{ matrix.platform.name }} - ${{ matrix.node-version }}"
with:
script: |
const { owner, repo } = context.repo
const { data } = await github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id: context.runId,
per_page: 100
})
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
const job = data.jobs.find(j => j.name.endsWith(jobName))
const jobUrl = job?.html_url
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}`
let summary = `This check is assosciated with ${shaUrl}\n\n`
if (jobUrl) {
summary += `For run logs, click here: ${jobUrl}`
} else {
summary += `Run logs could not be found for a job with name: "${jobName}"`
}
return { summary }
- name: Create Check
uses: LouisBrunner/checks-action@v1.6.0
id: check
if: inputs.check-sha
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: in_progress
name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
sha: ${{ inputs.check-sha }}
output: ${{ steps.check-output.outputs.result }}
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Update Windows npm
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.'))
run: |
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
tar xf npm-7.5.4.tgz
cd package
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
cd ..
rmdir /s /q package
- name: Install npm@7
if: startsWith(matrix.node-version, '10.')
run: npm i --prefer-online --no-fund --no-audit -g npm@7
- name: Install npm@8
if: ${{ !startsWith(matrix.node-version, '10.') }}
run: npm i --prefer-online --no-fund --no-audit -g npm@8
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Add Problem Matcher
run: echo "::add-matcher::.github/matchers/tap.json"
- name: Test
run: npm test --ignore-scripts
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.6.0
if: steps.check.outputs.check_id && always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ job.status }}
check_id: ${{ steps.check.outputs.check_id }}
node-semver-7.5.4/.github/workflows/ci.yml 0000664 0000000 0000000 00000006317 14452077232 0020503 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- latest
- release/v*
schedule:
# "At 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1
- cron: "0 9 * * 1"
jobs:
lint:
name: Lint
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@8
run: npm i --prefer-online --no-fund --no-audit -g npm@8
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Lint
run: npm run lint --ignore-scripts
- name: Post Lint
run: npm run postlint --ignore-scripts
test:
name: Test - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
platform:
- name: Linux
os: ubuntu-latest
shell: bash
- name: macOS
os: macos-latest
shell: bash
- name: Windows
os: windows-latest
shell: cmd
node-version:
- 10.0.0
- 10.x
- 12.x
- 14.x
- 16.x
- 18.x
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Update Windows npm
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.'))
run: |
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
tar xf npm-7.5.4.tgz
cd package
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
cd ..
rmdir /s /q package
- name: Install npm@7
if: startsWith(matrix.node-version, '10.')
run: npm i --prefer-online --no-fund --no-audit -g npm@7
- name: Install npm@8
if: ${{ !startsWith(matrix.node-version, '10.') }}
run: npm i --prefer-online --no-fund --no-audit -g npm@8
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Add Problem Matcher
run: echo "::add-matcher::.github/matchers/tap.json"
- name: Test
run: npm test --ignore-scripts
node-semver-7.5.4/.github/workflows/codeql-analysis.yml 0000664 0000000 0000000 00000001653 14452077232 0023176 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: CodeQL
on:
push:
branches:
- main
- latest
- release/v*
pull_request:
branches:
- main
- latest
- release/v*
schedule:
# "At 10:00 UTC (03:00 PT) on Monday" https://crontab.guru/#0_10_*_*_1
- cron: "0 10 * * 1"
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
node-semver-7.5.4/.github/workflows/post-dependabot.yml 0000664 0000000 0000000 00000011615 14452077232 0023175 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Post Dependabot
on: pull_request
permissions:
contents: write
jobs:
template-oss:
name: template-oss
if: github.repository_owner == 'npm' && github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@8
run: npm i --prefer-online --no-fund --no-audit -g npm@8
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Fetch Dependabot Metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# Dependabot can update multiple directories so we output which directory
# it is acting on so we can run the command for the correct root or workspace
- name: Get Dependabot Directory
if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss')
id: flags
run: |
dependabot_dir="${{ steps.metadata.outputs.directory }}"
if [[ "$dependabot_dir" == "/" ]]; then
echo "workspace=-iwr" >> $GITHUB_OUTPUT
else
# strip leading slash from directory so it works as a
# a path to the workspace flag
echo "workspace=-w ${dependabot_dir#/}" >> $GITHUB_OUTPUT
fi
- name: Apply Changes
if: steps.flags.outputs.workspace
id: apply
run: |
npm run template-oss-apply ${{ steps.flags.outputs.workspace }}
if [[ `git status --porcelain` ]]; then
echo "changes=true" >> $GITHUB_OUTPUT
fi
# This only sets the conventional commit prefix. This workflow can't reliably determine
# what the breaking change is though. If a BREAKING CHANGE message is required then
# this PR check will fail and the commit will be amended with stafftools
if [[ "${{ steps.metadata.outputs.update-type }}" == "version-update:semver-major" ]]; then
prefix='feat!'
else
prefix='chore'
fi
echo "message=$prefix: postinstall for dependabot template-oss PR" >> $GITHUB_OUTPUT
# This step will fail if template-oss has made any workflow updates. It is impossible
# for a workflow to update other workflows. In the case it does fail, we continue
# and then try to apply only a portion of the changes in the next step
- name: Push All Changes
if: steps.apply.outputs.changes
id: push
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git commit -am "${{ steps.apply.outputs.message }}"
git push
# If the previous step failed, then reset the commit and remove any workflow changes
# and attempt to commit and push again. This is helpful because we will have a commit
# with the correct prefix that we can then --amend with @npmcli/stafftools later.
- name: Push All Changes Except Workflows
if: steps.apply.outputs.changes && steps.push.outcome == 'failure'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git reset HEAD~
git checkout HEAD -- .github/workflows/
git clean -fd .github/workflows/
git commit -am "${{ steps.apply.outputs.message }}"
git push
# Check if all the necessary template-oss changes were applied. Since we continued
# on errors in one of the previous steps, this check will fail if our follow up
# only applied a portion of the changes and we need to followup manually.
#
# Note that this used to run `lint` and `postlint` but that will fail this action
# if we've also shipped any linting changes separate from template-oss. We do
# linting in another action, so we want to fail this one only if there are
# template-oss changes that could not be applied.
- name: Check Changes
if: steps.apply.outputs.changes
run: |
npm exec --offline ${{ steps.flags.outputs.workspace }} -- template-oss-check
- name: Fail on Breaking Change
if: steps.apply.outputs.changes && startsWith(steps.apply.outputs.message, 'feat!')
run: |
echo "This PR has a breaking change. Run 'npx -p @npmcli/stafftools gh template-oss-fix'"
echo "for more information on how to fix this with a BREAKING CHANGE footer."
exit 1
node-semver-7.5.4/.github/workflows/pull-request.yml 0000664 0000000 0000000 00000002612 14452077232 0022544 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Pull Request
on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize
jobs:
commitlint:
name: Lint Commits
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@8
run: npm i --prefer-online --no-fund --no-audit -g npm@8
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Run Commitlint on Commits
id: commit
continue-on-error: true
run: |
npx --offline commitlint -V --from 'origin/${{ github.base_ref }}' --to ${{ github.event.pull_request.head.sha }}
- name: Run Commitlint on PR Title
if: steps.commit.outcome == 'failure'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
echo '$PR_TITLE' | npx --offline commitlint -V
node-semver-7.5.4/.github/workflows/release.yml 0000664 0000000 0000000 00000034046 14452077232 0021530 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Release
on:
workflow_dispatch:
inputs:
release-pr:
description: a release PR number to rerun release jobs on
type: string
push:
branches:
- main
- latest
- release/v*
permissions:
contents: write
pull-requests: write
checks: write
jobs:
release:
outputs:
pr: ${{ steps.release.outputs.pr }}
release: ${{ steps.release.outputs.release }}
releases: ${{ steps.release.outputs.releases }}
branch: ${{ steps.release.outputs.pr-branch }}
pr-number: ${{ steps.release.outputs.pr-number }}
comment-id: ${{ steps.pr-comment.outputs.result }}
check-id: ${{ steps.check.outputs.check_id }}
name: Release
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@8
run: npm i --prefer-online --no-fund --no-audit -g npm@8
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Release Please
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx --offline template-oss-release-please "${{ github.ref_name }}" "${{ inputs.release-pr }}"
- name: Post Pull Request Comment
if: steps.release.outputs.pr-number
uses: actions/github-script@v6
id: pr-comment
env:
PR_NUMBER: ${{ steps.release.outputs.pr-number }}
REF_NAME: ${{ github.ref_name }}
with:
script: |
const { REF_NAME, PR_NUMBER: issue_number } = process.env
const { runId, repo: { owner, repo } } = context
const { data: workflow } = await github.rest.actions.getWorkflowRun({ owner, repo, run_id: runId })
let body = '## Release Manager\n\n'
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number })
let commentId = comments.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id
body += `Release workflow run: ${workflow.html_url}\n\n#### Force CI to Update This Release\n\n`
body += `This PR will be updated and CI will run for every non-\`chore:\` commit that is pushed to \`${REF_NAME}\`. `
body += `To force CI to update this PR, run this command:\n\n`
body += `\`\`\`\ngh workflow run release.yml -r ${REF_NAME} -R ${owner}/${repo} -f release-pr=${issue_number}\n\`\`\``
if (commentId) {
await github.rest.issues.updateComment({ owner, repo, comment_id: commentId, body })
} else {
const { data: comment } = await github.rest.issues.createComment({ owner, repo, issue_number, body })
commentId = comment?.id
}
return commentId
- name: Get Workflow Job
uses: actions/github-script@v6
if: steps.release.outputs.pr-sha
id: check-output
env:
JOB_NAME: "Release"
MATRIX_NAME: ""
with:
script: |
const { owner, repo } = context.repo
const { data } = await github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id: context.runId,
per_page: 100
})
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
const job = data.jobs.find(j => j.name.endsWith(jobName))
const jobUrl = job?.html_url
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ steps.release.outputs.pr-sha }}`
let summary = `This check is assosciated with ${shaUrl}\n\n`
if (jobUrl) {
summary += `For run logs, click here: ${jobUrl}`
} else {
summary += `Run logs could not be found for a job with name: "${jobName}"`
}
return { summary }
- name: Create Check
uses: LouisBrunner/checks-action@v1.6.0
id: check
if: steps.release.outputs.pr-sha
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: in_progress
name: Release
sha: ${{ steps.release.outputs.pr-sha }}
output: ${{ steps.check-output.outputs.result }}
update:
needs: release
outputs:
sha: ${{ steps.commit.outputs.sha }}
check-id: ${{ steps.check.outputs.check_id }}
name: Update - Release
if: github.repository_owner == 'npm' && needs.release.outputs.pr
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ needs.release.outputs.branch }}
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@8
run: npm i --prefer-online --no-fund --no-audit -g npm@8
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Run Post Pull Request Actions
env:
RELEASE_PR_NUMBER: ${{ needs.release.outputs.pr-number }}
RELEASE_COMMENT_ID: ${{ needs.release.outputs.comment-id }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm exec --offline -- template-oss-release-manager --lockfile=false --publish=true
npm run rp-pull-request --ignore-scripts --if-present
- name: Commit
id: commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git commit --all --amend --no-edit || true
git push --force-with-lease
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Get Workflow Job
uses: actions/github-script@v6
if: steps.commit.outputs.sha
id: check-output
env:
JOB_NAME: "Update - Release"
MATRIX_NAME: ""
with:
script: |
const { owner, repo } = context.repo
const { data } = await github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id: context.runId,
per_page: 100
})
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
const job = data.jobs.find(j => j.name.endsWith(jobName))
const jobUrl = job?.html_url
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ steps.commit.outputs.sha }}`
let summary = `This check is assosciated with ${shaUrl}\n\n`
if (jobUrl) {
summary += `For run logs, click here: ${jobUrl}`
} else {
summary += `Run logs could not be found for a job with name: "${jobName}"`
}
return { summary }
- name: Create Check
uses: LouisBrunner/checks-action@v1.6.0
id: check
if: steps.commit.outputs.sha
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: in_progress
name: Release
sha: ${{ steps.commit.outputs.sha }}
output: ${{ steps.check-output.outputs.result }}
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.6.0
if: needs.release.outputs.check-id && always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ job.status }}
check_id: ${{ needs.release.outputs.check-id }}
ci:
name: CI - Release
needs: [ release, update ]
if: needs.release.outputs.pr
uses: ./.github/workflows/ci-release.yml
with:
ref: ${{ needs.release.outputs.branch }}
check-sha: ${{ needs.update.outputs.sha }}
post-ci:
needs: [ release, update, ci ]
name: Post CI - Release
if: github.repository_owner == 'npm' && needs.release.outputs.pr && always()
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Get Needs Result
id: needs-result
run: |
result=""
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
result="failure"
elif [[ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
result="cancelled"
else
result="success"
fi
echo "result=$result" >> $GITHUB_OUTPUT
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.6.0
if: needs.update.outputs.check-id && always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ steps.needs-result.outputs.result }}
check_id: ${{ needs.update.outputs.check-id }}
post-release:
needs: release
name: Post Release - Release
if: github.repository_owner == 'npm' && needs.release.outputs.releases
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Create Release PR Comment
uses: actions/github-script@v6
env:
RELEASES: ${{ needs.release.outputs.releases }}
with:
script: |
const releases = JSON.parse(process.env.RELEASES)
const { runId, repo: { owner, repo } } = context
const issue_number = releases[0].prNumber
let body = '## Release Workflow\n\n'
for (const { pkgName, version, url } of releases) {
body += `- \`${pkgName}@${version}\` ${url}\n`
}
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number })
.then(cs => cs.map(c => ({ id: c.id, login: c.user.login, body: c.body })))
console.log(`Found comments: ${JSON.stringify(comments, null, 2)}`)
const releaseComments = comments.filter(c => c.login === 'github-actions[bot]' && c.body.includes('Release is at'))
for (const comment of releaseComments) {
console.log(`Release comment: ${JSON.stringify(comment, null, 2)}`)
await github.rest.issues.deleteComment({ owner, repo, comment_id: comment.id })
}
const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${runId}`
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: `${body}- Workflow run: :arrows_counterclockwise: ${runUrl}`,
})
release-integration:
needs: release
name: Release Integration
if: needs.release.outputs.release
runs-on: ubuntu-latest
defaults:
run:
shell: bash
permissions:
deployments: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ fromJSON(needs.release.outputs.release).tagName }}
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: |
npm i --prefer-online --no-fund --no-audit -g npm@latest
npm config set '//registry.npmjs.org/:_authToken'=\${PUBLISH_TOKEN}
- name: Publish
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
run: npm publish --provenance
post-release-integration:
needs: [ release, release-integration ]
name: Post Release Integration - Release
if: github.repository_owner == 'npm' && needs.release.outputs.release && always()
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Get Needs Result
id: needs-result
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: Update Release PR Comment
uses: actions/github-script@v6
env:
PR_NUMBER: ${{ fromJSON(needs.release.outputs.release).prNumber }}
RESULT: ${{ steps.needs-result.outputs.result }}
with:
script: |
const { PR_NUMBER: issue_number, RESULT } = process.env
const { runId, repo: { owner, repo } } = context
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number })
const updateComment = comments.find(c =>
c.user.login === 'github-actions[bot]' &&
c.body.startsWith('## Release Workflow\n\n') &&
c.body.includes(runId)
)
if (updateComment) {
console.log('Found comment to update:', JSON.stringify(updateComment, null, 2))
let body = updateComment.body.replace(/Workflow run: :[a-z_]+:/, `Workflow run: :${RESULT}:`)
const tagCodeowner = RESULT !== 'white_check_mark'
if (tagCodeowner) {
body += `\n\n:rotating_light:`
body += ` @npm/cli-team: The post-release workflow failed for this release.`
body += ` Manual steps may need to be taken after examining the workflow output`
body += ` from the above workflow run. :rotating_light:`
}
await github.rest.issues.updateComment({
owner,
repo,
body,
comment_id: updateComment.id,
})
} else {
console.log('No matching comments found:', JSON.stringify(comments, null, 2))
}
node-semver-7.5.4/.gitignore 0000664 0000000 0000000 00000001031 14452077232 0015744 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
# ignore everything in the root
/*
# keep these
!**/.gitignore
!/.commitlintrc.js
!/.eslintrc.js
!/.eslintrc.local.*
!/.github/
!/.gitignore
!/.npmrc
!/.release-please-manifest.json
!/bin/
!/CHANGELOG*
!/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/
node-semver-7.5.4/.npmrc 0000664 0000000 0000000 00000000135 14452077232 0015100 0 ustar 00root root 0000000 0000000 ; This file is automatically added by @npmcli/template-oss. Do not edit.
package-lock=false
node-semver-7.5.4/.release-please-manifest.json 0000664 0000000 0000000 00000000023 14452077232 0021420 0 ustar 00root root 0000000 0000000 {
".": "7.5.4"
}
node-semver-7.5.4/CHANGELOG.md 0000664 0000000 0000000 00000024203 14452077232 0015573 0 ustar 00root root 0000000 0000000 # Changelog
## [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
node-semver-7.5.4/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000000507 14452077232 0016562 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.
node-semver-7.5.4/CONTRIBUTING.md 0000664 0000000 0000000 00000005133 14452077232 0016214 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.
node-semver-7.5.4/LICENSE 0000664 0000000 0000000 00000001375 14452077232 0014774 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.
node-semver-7.5.4/README.md 0000664 0000000 0000000 00000056174 14452077232 0015255 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 simplifyRange = require('semver/ranges/simplify')
const rangeSubset = 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, or prerelease. 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>
This is the base to be used for the prerelease identifier.
-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.
## Ranges
A `version range` is a set of `comparators` which 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. The
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 for 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
clearly 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 the purpose of 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
```
#### 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, release)`: Return the version incremented by the release
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
`prepatch`, or `prerelease`), 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, the `prerelease` will work the
same as `prepatch`. It increments the patch version, then makes a
prerelease. If the input version is already a prerelease it simply
increments it.
* `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 exact 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()`.
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
* `diff(v1, v2)`: Returns difference between two versions by the release type
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
or null if the versions are the same.
### 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 possibly match
the given range.
* `gtr(version, range)`: Return `true` if version is greater than all the
versions possible in the range.
* `ltr(version, range)`: Return `true` if 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 ranges comparators intersect
* `simplifyRange(versions, range)`: Return a "simplified" range that
matches the same items in `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 the 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.
### 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/to-comparators')`
* `require('semver/ranges/valid')`
node-semver-7.5.4/SECURITY.md 0000664 0000000 0000000 00000002321 14452077232 0015550 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.
node-semver-7.5.4/bin/ 0000775 0000000 0000000 00000000000 14452077232 0014531 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/bin/semver.js 0000775 0000000 0000000 00000011327 14452077232 0016377 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.
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':
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)
})
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()
}
}
return success(versions)
}
const failInc = () => {
console.error('--inc can only be used on a single version with no range')
fail()
}
const fail = () => process.exit(1)
const success = () => {
const compare = reverse ? 'rcompare' : 'compare'
versions.sort((a, b) => {
return semver[compare](a, b, options)
}).map((v) => {
return semver.clean(v, options)
}).map((v) => {
return inc ? semver.inc(v, inc, options, identifier, identifierBase) : v
}).forEach((v, i, _) => {
console.log(v)
})
}
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, or prerelease. 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()
node-semver-7.5.4/classes/ 0000775 0000000 0000000 00000000000 14452077232 0015416 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/classes/comparator.js 0000664 0000000 0000000 00000007041 14452077232 0020125 0 ustar 00root root 0000000 0000000 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')
node-semver-7.5.4/classes/index.js 0000664 0000000 0000000 00000000201 14452077232 0017054 0 ustar 00root root 0000000 0000000 module.exports = {
SemVer: require('./semver.js'),
Range: require('./range.js'),
Comparator: require('./comparator.js'),
}
node-semver-7.5.4/classes/range.js 0000664 0000000 0000000 00000034262 14452077232 0017057 0 ustar 00root root 0000000 0000000 // 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.format()
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()
.split(/\s+/)
.join(' ')
// 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.format()
}
format () {
this.range = this.set
.map((comps) => comps.join(' ').trim())
.join('||')
.trim()
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('lru-cache')
const cache = new LRU({ max: 1000 })
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) => {
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
const hyphenReplace = incPr => ($0,
from, fM, fm, fp, fpr, fb,
to, tM, tm, tp, tpr, tb) => {
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
}
node-semver-7.5.4/classes/semver.js 0000664 0000000 0000000 00000021064 14452077232 0017260 0 ustar 00root root 0000000 0000000 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)
}
return (
compareIdentifiers(this.major, other.major) ||
compareIdentifiers(this.minor, other.minor) ||
compareIdentifiers(this.patch, other.patch)
)
}
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('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)
}
// 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) {
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 '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 (!identifier && identifierBase === false) {
throw new Error('invalid increment argument: identifier is empty')
}
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
node-semver-7.5.4/functions/ 0000775 0000000 0000000 00000000000 14452077232 0015771 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/functions/clean.js 0000664 0000000 0000000 00000000277 14452077232 0017417 0 ustar 00root root 0000000 0000000 const parse = require('./parse')
const clean = (version, options) => {
const s = parse(version.trim().replace(/^[=v]+/, ''), options)
return s ? s.version : null
}
module.exports = clean
node-semver-7.5.4/functions/cmp.js 0000664 0000000 0000000 00000001663 14452077232 0017114 0 ustar 00root root 0000000 0000000 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
node-semver-7.5.4/functions/coerce.js 0000664 0000000 0000000 00000002751 14452077232 0017574 0 ustar 00root root 0000000 0000000 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(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'
//
// 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.
let next
while ((next = re[t.COERCERTL].exec(version)) &&
(!match || match.index + match[0].length !== version.length)
) {
if (!match ||
next.index + next[0].length !== match.index + match[0].length) {
match = next
}
re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length
}
// leave it in a clean state
re[t.COERCERTL].lastIndex = -1
}
if (match === null) {
return null
}
return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options)
}
module.exports = coerce
node-semver-7.5.4/functions/compare-build.js 0000664 0000000 0000000 00000000413 14452077232 0021050 0 ustar 00root root 0000000 0000000 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
node-semver-7.5.4/functions/compare-loose.js 0000664 0000000 0000000 00000000166 14452077232 0021077 0 ustar 00root root 0000000 0000000 const compare = require('./compare')
const compareLoose = (a, b) => compare(a, b, true)
module.exports = compareLoose
node-semver-7.5.4/functions/compare.js 0000664 0000000 0000000 00000000234 14452077232 0017754 0 ustar 00root root 0000000 0000000 const SemVer = require('../classes/semver')
const compare = (a, b, loose) =>
new SemVer(a, loose).compare(new SemVer(b, loose))
module.exports = compare
node-semver-7.5.4/functions/diff.js 0000664 0000000 0000000 00000003114 14452077232 0017236 0 ustar 00root root 0000000 0000000 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'
}
// Otherwise it can be determined by checking the high version
if (highVersion.patch) {
// anything higher than a patch bump would result in the wrong version
return 'patch'
}
if (highVersion.minor) {
// anything higher than a minor bump would result in the wrong version
return 'minor'
}
// bumping major/minor/patch all have same result
return 'major'
}
// 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 preleases
return 'prerelease'
}
module.exports = diff
node-semver-7.5.4/functions/eq.js 0000664 0000000 0000000 00000000160 14452077232 0016731 0 ustar 00root root 0000000 0000000 const compare = require('./compare')
const eq = (a, b, loose) => compare(a, b, loose) === 0
module.exports = eq
node-semver-7.5.4/functions/gt.js 0000664 0000000 0000000 00000000156 14452077232 0016743 0 ustar 00root root 0000000 0000000 const compare = require('./compare')
const gt = (a, b, loose) => compare(a, b, loose) > 0
module.exports = gt
node-semver-7.5.4/functions/gte.js 0000664 0000000 0000000 00000000161 14452077232 0017104 0 ustar 00root root 0000000 0000000 const compare = require('./compare')
const gte = (a, b, loose) => compare(a, b, loose) >= 0
module.exports = gte
node-semver-7.5.4/functions/inc.js 0000664 0000000 0000000 00000000720 14452077232 0017077 0 ustar 00root root 0000000 0000000 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
node-semver-7.5.4/functions/lt.js 0000664 0000000 0000000 00000000156 14452077232 0016750 0 ustar 00root root 0000000 0000000 const compare = require('./compare')
const lt = (a, b, loose) => compare(a, b, loose) < 0
module.exports = lt
node-semver-7.5.4/functions/lte.js 0000664 0000000 0000000 00000000161 14452077232 0017111 0 ustar 00root root 0000000 0000000 const compare = require('./compare')
const lte = (a, b, loose) => compare(a, b, loose) <= 0
module.exports = lte
node-semver-7.5.4/functions/major.js 0000664 0000000 0000000 00000000172 14452077232 0017437 0 ustar 00root root 0000000 0000000 const SemVer = require('../classes/semver')
const major = (a, loose) => new SemVer(a, loose).major
module.exports = major
node-semver-7.5.4/functions/minor.js 0000664 0000000 0000000 00000000172 14452077232 0017453 0 ustar 00root root 0000000 0000000 const SemVer = require('../classes/semver')
const minor = (a, loose) => new SemVer(a, loose).minor
module.exports = minor
node-semver-7.5.4/functions/neq.js 0000664 0000000 0000000 00000000162 14452077232 0017111 0 ustar 00root root 0000000 0000000 const compare = require('./compare')
const neq = (a, b, loose) => compare(a, b, loose) !== 0
module.exports = neq
node-semver-7.5.4/functions/parse.js 0000664 0000000 0000000 00000000475 14452077232 0017447 0 ustar 00root root 0000000 0000000 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
node-semver-7.5.4/functions/patch.js 0000664 0000000 0000000 00000000172 14452077232 0017426 0 ustar 00root root 0000000 0000000 const SemVer = require('../classes/semver')
const patch = (a, loose) => new SemVer(a, loose).patch
module.exports = patch
node-semver-7.5.4/functions/prerelease.js 0000664 0000000 0000000 00000000334 14452077232 0020456 0 ustar 00root root 0000000 0000000 const parse = require('./parse')
const prerelease = (version, options) => {
const parsed = parse(version, options)
return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
}
module.exports = prerelease
node-semver-7.5.4/functions/rcompare.js 0000664 0000000 0000000 00000000166 14452077232 0020142 0 ustar 00root root 0000000 0000000 const compare = require('./compare')
const rcompare = (a, b, loose) => compare(b, a, loose)
module.exports = rcompare
node-semver-7.5.4/functions/rsort.js 0000664 0000000 0000000 00000000225 14452077232 0017477 0 ustar 00root root 0000000 0000000 const compareBuild = require('./compare-build')
const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose))
module.exports = rsort
node-semver-7.5.4/functions/satisfies.js 0000664 0000000 0000000 00000000351 14452077232 0020320 0 ustar 00root root 0000000 0000000 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
node-semver-7.5.4/functions/sort.js 0000664 0000000 0000000 00000000223 14452077232 0017313 0 ustar 00root root 0000000 0000000 const compareBuild = require('./compare-build')
const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose))
module.exports = sort
node-semver-7.5.4/functions/valid.js 0000664 0000000 0000000 00000000242 14452077232 0017424 0 ustar 00root root 0000000 0000000 const parse = require('./parse')
const valid = (version, options) => {
const v = parse(version, options)
return v ? v.version : null
}
module.exports = valid
node-semver-7.5.4/index.js 0000664 0000000 0000000 00000005070 14452077232 0015430 0 ustar 00root root 0000000 0000000 // 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,
}
node-semver-7.5.4/internal/ 0000775 0000000 0000000 00000000000 14452077232 0015575 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/internal/constants.js 0000664 0000000 0000000 00000001533 14452077232 0020151 0 ustar 00root root 0000000 0000000 // 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,
}
node-semver-7.5.4/internal/debug.js 0000664 0000000 0000000 00000000342 14452077232 0017220 0 ustar 00root root 0000000 0000000 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
node-semver-7.5.4/internal/identifiers.js 0000664 0000000 0000000 00000000632 14452077232 0020441 0 ustar 00root root 0000000 0000000 const numeric = /^[0-9]+$/
const compareIdentifiers = (a, b) => {
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,
}
node-semver-7.5.4/internal/parse-options.js 0000664 0000000 0000000 00000000504 14452077232 0020735 0 ustar 00root root 0000000 0000000 // 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
node-semver-7.5.4/internal/re.js 0000664 0000000 0000000 00000017012 14452077232 0016542 0 ustar 00root root 0000000 0000000 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 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
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.
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
}|${src[t.NONNUMERICIDENTIFIER]})`)
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
}|${src[t.NONNUMERICIDENTIFIER]})`)
// ## 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('COERCE', `${'(^|[^\\d])' +
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
`(?:$|[^\\d])`)
createToken('COERCERTL', src[t.COERCE], 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*$')
node-semver-7.5.4/map.js 0000664 0000000 0000000 00000000074 14452077232 0015075 0 ustar 00root root 0000000 0000000 module.exports = testFile => testFile.replace(/test\//, '')
node-semver-7.5.4/package.json 0000664 0000000 0000000 00000003313 14452077232 0016247 0 ustar 00root root 0000000 0000000 {
"name": "semver",
"version": "7.5.4",
"description": "The semantic version parser used by npm.",
"main": "index.js",
"scripts": {
"test": "tap",
"snap": "tap",
"lint": "eslint \"**/*.js\"",
"postlint": "template-oss-check",
"lintfix": "npm run lint -- --fix",
"posttest": "npm run lint",
"template-oss-apply": "template-oss-apply --force"
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.17.0",
"tap": "^16.0.0"
},
"license": "ISC",
"repository": {
"type": "git",
"url": "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"
},
"dependencies": {
"lru-cache": "^6.0.0"
},
"author": "GitHub Inc.",
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.17.0",
"engines": ">=10",
"ciVersions": [
"10.0.0",
"10.x",
"12.x",
"14.x",
"16.x",
"18.x"
],
"npmSpec": "8",
"distPaths": [
"classes/",
"functions/",
"internal/",
"ranges/",
"index.js",
"preload.js",
"range.bnf"
],
"allowPaths": [
"/classes/",
"/functions/",
"/internal/",
"/ranges/",
"/index.js",
"/preload.js",
"/range.bnf"
],
"publish": "true"
}
}
node-semver-7.5.4/preload.js 0000664 0000000 0000000 00000000105 14452077232 0015741 0 ustar 00root root 0000000 0000000 // XXX remove in v8 or beyond
module.exports = require('./index.js')
node-semver-7.5.4/range.bnf 0000664 0000000 0000000 00000001153 14452077232 0015544 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]+
node-semver-7.5.4/ranges/ 0000775 0000000 0000000 00000000000 14452077232 0015240 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/ranges/gtr.js 0000664 0000000 0000000 00000000331 14452077232 0016367 0 ustar 00root root 0000000 0000000 // 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
node-semver-7.5.4/ranges/intersects.js 0000664 0000000 0000000 00000000322 14452077232 0017756 0 ustar 00root root 0000000 0000000 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
node-semver-7.5.4/ranges/ltr.js 0000664 0000000 0000000 00000000325 14452077232 0016377 0 ustar 00root root 0000000 0000000 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
node-semver-7.5.4/ranges/max-satisfying.js 0000664 0000000 0000000 00000001103 14452077232 0020534 0 ustar 00root root 0000000 0000000 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
node-semver-7.5.4/ranges/min-satisfying.js 0000664 0000000 0000000 00000001101 14452077232 0020530 0 ustar 00root root 0000000 0000000 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
node-semver-7.5.4/ranges/min-version.js 0000664 0000000 0000000 00000002734 14452077232 0020052 0 ustar 00root root 0000000 0000000 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
node-semver-7.5.4/ranges/outside.js 0000664 0000000 0000000 00000004216 14452077232 0017255 0 ustar 00root root 0000000 0000000 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
node-semver-7.5.4/ranges/simplify.js 0000664 0000000 0000000 00000002475 14452077232 0017442 0 ustar 00root root 0000000 0000000 // 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
}
node-semver-7.5.4/ranges/subset.js 0000664 0000000 0000000 00000016526 14452077232 0017115 0 ustar 00root root 0000000 0000000 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 GT.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
node-semver-7.5.4/ranges/to-comparators.js 0000664 0000000 0000000 00000000414 14452077232 0020547 0 ustar 00root root 0000000 0000000 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
node-semver-7.5.4/ranges/valid.js 0000664 0000000 0000000 00000000470 14452077232 0016676 0 ustar 00root root 0000000 0000000 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
node-semver-7.5.4/release-please-config.json 0000664 0000000 0000000 00000001254 14452077232 0021010 0 ustar 00root root 0000000 0000000 {
"exclude-packages-from-root": true,
"group-pull-request-title-pattern": "chore: release ${version}",
"pull-request-title-pattern": "chore: release${component} ${version}",
"changelog-sections": [
{
"type": "feat",
"section": "Features",
"hidden": false
},
{
"type": "fix",
"section": "Bug Fixes",
"hidden": false
},
{
"type": "docs",
"section": "Documentation",
"hidden": false
},
{
"type": "deps",
"section": "Dependencies",
"hidden": false
},
{
"type": "chore",
"hidden": true
}
],
"packages": {
".": {
"package-name": ""
}
}
}
node-semver-7.5.4/tap-snapshots/ 0000775 0000000 0000000 00000000000 14452077232 0016565 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/tap-snapshots/test/ 0000775 0000000 0000000 00000000000 14452077232 0017544 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/tap-snapshots/test/bin/ 0000775 0000000 0000000 00000000000 14452077232 0020314 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/tap-snapshots/test/bin/semver.js.test.cjs 0000664 0000000 0000000 00000026375 14452077232 0023724 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, or prerelease. 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, or prerelease. 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, or prerelease. 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, or prerelease. 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 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.3foo 1.2.3-bar -l 1`] = `
Object {
"code": 0,
"err": "",
"out": "1.2.3-bar\\n",
"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.3.4-beta
2.3.4
),
"signal": null,
}
`
node-semver-7.5.4/test/ 0000775 0000000 0000000 00000000000 14452077232 0014740 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/test/bin/ 0000775 0000000 0000000 00000000000 14452077232 0015510 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/test/bin/semver.js 0000664 0000000 0000000 00000005433 14452077232 0017354 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'],
].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.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(' '))
})))
node-semver-7.5.4/test/classes/ 0000775 0000000 0000000 00000000000 14452077232 0016375 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/test/classes/comparator.js 0000664 0000000 0000000 00000003431 14452077232 0021103 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/classes/index.js 0000664 0000000 0000000 00000000356 14452077232 0020046 0 ustar 00root root 0000000 0000000 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')
node-semver-7.5.4/test/classes/range.js 0000664 0000000 0000000 00000006341 14452077232 0020033 0 ustar 00root root 0000000 0000000 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('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()
})
node-semver-7.5.4/test/classes/semver.js 0000664 0000000 0000000 00000010024 14452077232 0020231 0 ustar 00root root 0000000 0000000 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')
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('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()
})
node-semver-7.5.4/test/fixtures/ 0000775 0000000 0000000 00000000000 14452077232 0016611 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/test/fixtures/comparator-intersection.js 0000664 0000000 0000000 00000002430 14452077232 0024021 0 ustar 00root root 0000000 0000000 // 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],
]
node-semver-7.5.4/test/fixtures/comparisons.js 0000664 0000000 0000000 00000002047 14452077232 0021507 0 ustar 00root root 0000000 0000000 // [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'],
]
node-semver-7.5.4/test/fixtures/equality.js 0000664 0000000 0000000 00000002626 14452077232 0021012 0 ustar 00root root 0000000 0000000 // [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'],
]
node-semver-7.5.4/test/fixtures/increments.js 0000664 0000000 0000000 00000015445 14452077232 0021327 0 ustar 00root root 0000000 0000000 // [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.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.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]
['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],
]
node-semver-7.5.4/test/fixtures/invalid-versions.js 0000664 0000000 0000000 00000001215 14452077232 0022442 0 ustar 00root root 0000000 0000000 // 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', true, 'even loose, its still junk'],
['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'],
]
node-semver-7.5.4/test/fixtures/range-exclude.js 0000664 0000000 0000000 00000006023 14452077232 0021673 0 ustar 00root root 0000000 0000000 // [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 }],
]
node-semver-7.5.4/test/fixtures/range-include.js 0000664 0000000 0000000 00000007706 14452077232 0021676 0 ustar 00root root 0000000 0000000 // [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 }],
]
node-semver-7.5.4/test/fixtures/range-intersection.js 0000664 0000000 0000000 00000003627 14452077232 0022757 0 ustar 00root root 0000000 0000000 // 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],
]
node-semver-7.5.4/test/fixtures/range-parse.js 0000664 0000000 0000000 00000005750 14452077232 0021362 0 ustar 00root root 0000000 0000000 // [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`],
]
node-semver-7.5.4/test/fixtures/version-gt-range.js 0000664 0000000 0000000 00000003015 14452077232 0022335 0 ustar 00root root 0000000 0000000 // [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'],
]
node-semver-7.5.4/test/fixtures/version-lt-range.js 0000664 0000000 0000000 00000003126 14452077232 0022345 0 ustar 00root root 0000000 0000000 // [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'],
]
node-semver-7.5.4/test/fixtures/version-not-gt-range.js 0000664 0000000 0000000 00000004431 14452077232 0023136 0 ustar 00root root 0000000 0000000 // [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 }],
]
node-semver-7.5.4/test/fixtures/version-not-lt-range.js 0000664 0000000 0000000 00000004642 14452077232 0023147 0 ustar 00root root 0000000 0000000 // [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 }],
]
node-semver-7.5.4/test/functions/ 0000775 0000000 0000000 00000000000 14452077232 0016750 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/test/functions/clean.js 0000664 0000000 0000000 00000001206 14452077232 0020367 0 ustar 00root root 0000000 0000000 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],
].forEach(([range, version]) => {
const msg = `clean(${range}) = ${version}`
t.equal(clean(range), version, msg)
})
t.end()
})
node-semver-7.5.4/test/functions/cmp.js 0000664 0000000 0000000 00000003473 14452077232 0020074 0 ustar 00root root 0000000 0000000 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`)
}))
})
node-semver-7.5.4/test/functions/coerce.js 0000664 0000000 0000000 00000007512 14452077232 0020553 0 ustar 00root root 0000000 0000000 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 }],
]
coerceToValid.forEach(([input, expected, options]) => {
const msg = `coerce(${input}) should become ${expected}`
t.same((coerce(input, options) || {}).version, expected, msg)
})
t.same(valid(coerce('42.6.7.9.3-alpha')), '42.6.7')
t.same(valid(coerce('v2')), '2.0.0')
t.end()
})
node-semver-7.5.4/test/functions/compare-build.js 0000664 0000000 0000000 00000001062 14452077232 0022030 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/functions/compare-loose.js 0000664 0000000 0000000 00000001453 14452077232 0022056 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/functions/compare.js 0000664 0000000 0000000 00000002511 14452077232 0020733 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/functions/diff.js 0000664 0000000 0000000 00000003213 14452077232 0020215 0 ustar 00root root 0000000 0000000 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'],
].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()
})
node-semver-7.5.4/test/functions/eq.js 0000664 0000000 0000000 00000001613 14452077232 0017714 0 ustar 00root root 0000000 0000000 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})`)
}))
})
node-semver-7.5.4/test/functions/gt.js 0000664 0000000 0000000 00000001465 14452077232 0017726 0 ustar 00root root 0000000 0000000 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})`)
}))
})
node-semver-7.5.4/test/functions/gte.js 0000664 0000000 0000000 00000001473 14452077232 0020072 0 ustar 00root root 0000000 0000000 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})`)
}))
})
node-semver-7.5.4/test/functions/inc.js 0000664 0000000 0000000 00000002526 14452077232 0020064 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/functions/lt.js 0000664 0000000 0000000 00000001465 14452077232 0017733 0 ustar 00root root 0000000 0000000 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})`)
}))
})
node-semver-7.5.4/test/functions/lte.js 0000664 0000000 0000000 00000001473 14452077232 0020077 0 ustar 00root root 0000000 0000000 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})`)
}))
})
node-semver-7.5.4/test/functions/major.js 0000664 0000000 0000000 00000001160 14452077232 0020414 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/functions/minor.js 0000664 0000000 0000000 00000001160 14452077232 0020430 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/functions/neq.js 0000664 0000000 0000000 00000001655 14452077232 0020100 0 ustar 00root root 0000000 0000000 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})`)
}))
})
node-semver-7.5.4/test/functions/parse.js 0000664 0000000 0000000 00000002130 14452077232 0020414 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/functions/patch.js 0000664 0000000 0000000 00000001160 14452077232 0020403 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/functions/prerelease.js 0000664 0000000 0000000 00000001252 14452077232 0021435 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/functions/rcompare.js 0000664 0000000 0000000 00000000445 14452077232 0021121 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/functions/rsort.js 0000664 0000000 0000000 00000000514 14452077232 0020457 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/functions/satisfies.js 0000664 0000000 0000000 00000001736 14452077232 0021307 0 ustar 00root root 0000000 0000000 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`))
})
node-semver-7.5.4/test/functions/sort.js 0000664 0000000 0000000 00000000510 14452077232 0020271 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/functions/valid.js 0000664 0000000 0000000 00000002245 14452077232 0020410 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/index.js 0000664 0000000 0000000 00000000522 14452077232 0016404 0 ustar 00root root 0000000 0000000 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')
node-semver-7.5.4/test/integration/ 0000775 0000000 0000000 00000000000 14452077232 0017263 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/test/integration/whitespace.js 0000664 0000000 0000000 00000003266 14452077232 0021764 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/internal/ 0000775 0000000 0000000 00000000000 14452077232 0016554 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/test/internal/constants.js 0000664 0000000 0000000 00000000435 14452077232 0021130 0 ustar 00root root 0000000 0000000 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')
node-semver-7.5.4/test/internal/debug.js 0000664 0000000 0000000 00000002201 14452077232 0020173 0 ustar 00root root 0000000 0000000 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()
}
node-semver-7.5.4/test/internal/identifiers.js 0000664 0000000 0000000 00000001002 14452077232 0021410 0 ustar 00root root 0000000 0000000 const { test } = require('tap')
const { compareIdentifiers, rcompareIdentifiers } = require('../../internal/identifiers')
test('rcompareIdentifiers and compareIdentifiers', (t) => {
const set = [
['1', '2'],
['alpha', 'beta'],
['0', 'beta'],
]
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.end()
})
node-semver-7.5.4/test/internal/parse-options.js 0000664 0000000 0000000 00000003057 14452077232 0021722 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/internal/re.js 0000664 0000000 0000000 00000001262 14452077232 0017521 0 ustar 00root root 0000000 0000000 const { test } = require('tap')
const { src, re, safeRe } = require('../../internal/re')
const semver = require('../../')
test('has a list of src, re, and tokens', (t) => {
t.match(Object.assign({}, semver), {
src: Array,
re: Array,
tokens: Object,
})
re.forEach(r => t.match(r, RegExp, 'regexps are regexps'))
src.forEach(s => t.match(s, String, 'src is strings'))
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()
})
node-semver-7.5.4/test/map.js 0000664 0000000 0000000 00000002372 14452077232 0016057 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/preload.js 0000664 0000000 0000000 00000000232 14452077232 0016721 0 ustar 00root root 0000000 0000000 const t = require('tap')
const preload = require('../preload.js')
const index = require('../index.js')
t.equal(preload, index, 'preload and index match')
node-semver-7.5.4/test/ranges/ 0000775 0000000 0000000 00000000000 14452077232 0016217 5 ustar 00root root 0000000 0000000 node-semver-7.5.4/test/ranges/gtr.js 0000664 0000000 0000000 00000001617 14452077232 0017356 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/ranges/intersects.js 0000664 0000000 0000000 00000004632 14452077232 0020745 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/ranges/ltr.js 0000664 0000000 0000000 00000001405 14452077232 0017356 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/ranges/max-satisfying.js 0000664 0000000 0000000 00000001366 14452077232 0021526 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/ranges/min-satisfying.js 0000664 0000000 0000000 00000001366 14452077232 0021524 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/ranges/min-version.js 0000664 0000000 0000000 00000003701 14452077232 0021024 0 ustar 00root root 0000000 0000000 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'],
// Carot
['^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()
})
node-semver-7.5.4/test/ranges/outside.js 0000664 0000000 0000000 00000003307 14452077232 0020234 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/ranges/simplify.js 0000664 0000000 0000000 00000001636 14452077232 0020417 0 ustar 00root root 0000000 0000000 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')
node-semver-7.5.4/test/ranges/subset.js 0000664 0000000 0000000 00000011236 14452077232 0020065 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/ranges/to-comparators.js 0000664 0000000 0000000 00000006076 14452077232 0021540 0 ustar 00root root 0000000 0000000 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()
})
node-semver-7.5.4/test/ranges/valid.js 0000664 0000000 0000000 00000000702 14452077232 0017653 0 ustar 00root root 0000000 0000000 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)}`))
})