Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys authored and wraithgar committed May 8, 2024
1 parent 268303c commit 8d161a4
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 434 deletions.
2 changes: 0 additions & 2 deletions DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ graph LR;
libnpmversion-->require-inject;
libnpmversion-->semver;
libnpmversion-->tap;
lru-cache-->yallist;
make-fetch-happen-->cacache;
make-fetch-happen-->http-cache-semantics;
make-fetch-happen-->is-lambda;
Expand Down Expand Up @@ -729,7 +728,6 @@ graph LR;
read-->mute-stream;
read-package-json-fast-->json-parse-even-better-errors;
read-package-json-fast-->npm-normalize-package-bin;
semver-->lru-cache;
shebang-command-->shebang-regex;
sigstore-->sigstore-bundle["@sigstore/bundle"];
sigstore-->sigstore-core["@sigstore/core"];
Expand Down
3 changes: 0 additions & 3 deletions node_modules/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@
!/retry
!/safer-buffer
!/semver
!/semver/node_modules/
/semver/node_modules/*
!/semver/node_modules/lru-cache
!/shebang-command
!/shebang-regex
!/signal-exit
Expand Down
19 changes: 5 additions & 14 deletions node_modules/semver/bin/semver.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ const main = () => {
return fail()
}
}
return success(versions)
versions
.sort((a, b) => semver[reverse ? 'rcompare' : 'compare'](a, b, options))
.map(v => semver.clean(v, options))
.map(v => inc ? semver.inc(v, inc, options, identifier, identifierBase) : v)
.forEach(v => console.log(v))
}

const failInc = () => {
Expand All @@ -129,19 +133,6 @@ const failInc = () => {

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}
Expand Down
7 changes: 4 additions & 3 deletions node_modules/semver/classes/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ class Range {

module.exports = Range

const LRU = require('lru-cache')
const cache = new LRU({ max: 1000 })
const LRU = require('../internal/lrucache')
const cache = new LRU()

const parseOptions = require('../internal/parse-options')
const Comparator = require('./comparator')
Expand Down Expand Up @@ -470,9 +470,10 @@ const replaceGTE0 = (comp, options) => {
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
// 1.2 - 3.4 => >=1.2.0 <3.5.0-0
// TODO build?
const hyphenReplace = incPr => ($0,
from, fM, fm, fp, fpr, fb,
to, tM, tm, tp, tpr, tb) => {
to, tM, tm, tp, tpr) => {
if (isX(fM)) {
from = ''
} else if (isX(fm)) {
Expand Down
2 changes: 1 addition & 1 deletion node_modules/semver/classes/semver.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class SemVer {
do {
const a = this.build[i]
const b = other.build[i]
debug('prerelease compare', i, a, b)
debug('build compare', i, a, b)
if (a === undefined && b === undefined) {
return 0
} else if (b === undefined) {
Expand Down
45 changes: 45 additions & 0 deletions node_modules/semver/internal/lrucache.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class LRUCache {
constructor () {
this.max = 1000
this.map = new Map()
}

get (key) {
const value = this.map.get(key)
if (value === undefined) {
return undefined
} else {
// Remove the key from the map and add it to the end
this.map.delete(key)
this.map.set(key, value)
return value
}
}

delete (key) {
if (this.map.has(key)) {
this.map.delete(key)
return true
} else {
return false
}
}

set (key, value) {
const deleted = this.delete(key)

if (!deleted && value !== undefined) {
// If cache is full, delete the least recently used item
if (this.map.size >= this.max) {
const firstKey = this.map.keys().next().value
this.delete(firstKey)
}

this.map.set(key, value)
}

return this
}
}

module.exports = LRUCache
15 changes: 0 additions & 15 deletions node_modules/semver/node_modules/lru-cache/LICENSE

This file was deleted.

Loading

0 comments on commit 8d161a4

Please sign in to comment.