A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/npm/cli/commit/846118686849f821b084775f7891038013f7ba97 below:

update npx cache if possible when spec is a range · npm/cli@8461186 · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+56

-2

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+56

-2

lines changed Original file line number Diff line number Diff line change

@@ -8,8 +8,8 @@ const jsonParse = require('json-parse-even-better-errors')

8 8

const localeCompare = require('@isaacs/string-locale-compare')('en')

9 9

const { log, output } = require('proc-log')

10 10

const PkgJson = require('@npmcli/package-json')

11 -

const BaseCommand = require('../base-cmd.js')

12 11

const abbrev = require('abbrev')

12 +

const BaseCommand = require('../base-cmd.js')

13 13 14 14

const searchCachePackage = async (path, parsed, cacheKeys) => {

15 15

const searchMFH = new RegExp(`^make-fetch-happen:request-cache:.*(?<!/[@a-zA-Z]+)/${parsed.name}/-/(${parsed.name}[^/]+.tgz)$`)

Original file line number Diff line number Diff line change

@@ -38,6 +38,7 @@ const missingFromTree = async ({ spec, tree, flatOptions, isNpxTree, shallow })

38 38

// - In local or global mode go with anything in the tree that matches

39 39

// - If looking in the npx cache check if a newer version is available

40 40

const npxByNameOnly = isNpxTree && spec.name === spec.raw

41 +

// If they gave a range and not a tag we still need to check if it's outdated.

41 42

if (spec.registry && spec.type !== 'tag' && !npxByNameOnly) {

42 43

// registry spec that is not a specific tag.

43 44

const nodesBySpec = tree.inventory.query('packageName', spec.name)

@@ -54,7 +55,8 @@ const missingFromTree = async ({ spec, tree, flatOptions, isNpxTree, shallow })

54 55

return { node }

55 56

}

56 57

// package requested by version range, only remaining registry type

57 -

if (semver.satisfies(node.package.version, spec.rawSpec)) {

58 +

// the npx tree shouldn't be ok w/ an outdated version

59 +

if (!isNpxTree && semver.satisfies(node.package.version, spec.rawSpec)) {

58 60

return { node }

59 61

}

60 62

}

Original file line number Diff line number Diff line change

@@ -1,6 +1,7 @@

1 1

const { resolve } = require('node:path')

2 2

const t = require('tap')

3 3

const { setup, createPkg, merge } = require('./fixtures/setup.js')

4 +

const crypto = require('node:crypto')

4 5 5 6

t.test('run from registry - no local packages', async t => {

6 7

const { fixtures, package } = createPkg({ versions: ['2.0.0'] })

@@ -245,3 +246,54 @@ t.test('run from registry - non existant global path', async t => {

245 246

value: 'packages-2.0.0',

246 247

})

247 248

})

249 + 250 +

t.test('npx tree triggers manifest fetch when local version does satisfy range using real npx cache inventory', async t => {

251 +

// The local installation is version 1.0.0, which does NOT satisfy the spec ^2.0.0.

252 +

const pkgData = createPkg({

253 +

localVersion: '1.0.0',

254 +

versions: ['1.0.0', '2.0.0', '2.0.1'],

255 +

name: '@npmcli/create-index',

256 +

})

257 +

const { fixtures, package: pkg } = pkgData

258 + 259 +

const hash = crypto.createHash('sha512')

260 +

.update('@npmcli/create-index@^2.0.0')

261 +

.digest('hex')

262 +

.slice(0, 16)

263 + 264 +

const npxCacheFixture = {

265 +

[hash]: {

266 +

'package.json': {

267 +

name: '@npmcli/create-index',

268 +

version: '2.0.0',

269 +

},

270 +

},

271 +

}

272 + 273 +

const { exec: execFn, path, registry, readOutput, binLinks } = setup(t, {

274 +

pkg: [pkg],

275 +

testdir: {

276 +

...fixtures,

277 +

npxCache: npxCacheFixture,

278 +

},

279 +

})

280 + 281 +

// Set up the registry package so that a manifest fetch returns version 2.0.1.

282 +

await pkg({

283 +

registry,

284 +

path,

285 +

tarballs: ['2.0.1'],

286 +

})

287 +

await binLinks()

288 + 289 +

// Execute in NPX mode with the spec ^2.0.0.

290 +

// The local tree (version 1.0.0) does not satisfy ^2.0.0, so the system will find the cached package (version 2.0.0) in npxCache and then update from the registry to 2.0.1.

291 +

await execFn({

292 +

args: ['create-index'],

293 +

packages: ['@npmcli/create-index@^2.0.0'],

294 +

})

295 + 296 +

t.match(await readOutput('@npmcli-create-index'), {

297 +

value: 'packages-2.0.1',

298 +

})

299 +

})

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4