diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index ee7b280..f522452 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -84,21 +84,18 @@ jobs: os: macos-13 shell: bash node-version: - - 16.14.0 - - 16.x - - 18.0.0 + - 18.17.0 - 18.x + - 20.5.0 - 20.x - 22.x exclude: - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 16.14.0 - - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 16.x - - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 18.0.0 + node-version: 18.17.0 - platform: { name: macOS, os: macos-13, shell: bash } node-version: 18.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 20.5.0 - platform: { name: macOS, os: macos-13, shell: bash } node-version: 20.x - platform: { name: macOS, os: macos-13, shell: bash } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e922815..dfc6778 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,21 +61,18 @@ jobs: os: macos-13 shell: bash node-version: - - 16.14.0 - - 16.x - - 18.0.0 + - 18.17.0 - 18.x + - 20.5.0 - 20.x - 22.x exclude: - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 16.14.0 - - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 16.x - - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 18.0.0 + node-version: 18.17.0 - platform: { name: macOS, os: macos-13, shell: bash } node-version: 18.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 20.5.0 - platform: { name: macOS, os: macos-13, shell: bash } node-version: 20.x - platform: { name: macOS, os: macos-13, shell: bash } diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 4654535..07706ea 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "18.0.6" + ".": "19.0.1" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f32e7a..bc3db8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ # Changelog +## [19.0.1](https://github.com/npm/pacote/compare/v19.0.0...v19.0.1) (2024-10-15) +### Bug Fixes +* [`cbf94e8`](https://github.com/npm/pacote/commit/cbf94e8b0486e80f8f2e4c9ed7c7d18c3282096b) [#389](https://github.com/npm/pacote/pull/389) prepare script respects scriptshell config (#389) (@milaninfy) +* [`2b2948f`](https://github.com/npm/pacote/commit/2b2948faaebff35dd469c653e76517887f6e119d) [#403](https://github.com/npm/pacote/pull/403) log tarball retrieval from cache (#403) (@mbtools, @wraithgar) +### Dependencies +* [`a9fc4d1`](https://github.com/npm/pacote/commit/a9fc4d13ad4b28bb64ae92077ce6d35d2c130125) [#405](https://github.com/npm/pacote/pull/405) bump sigstore from 2.2.0 to 3.0.0 (#405) (@bdehamer) + +## [19.0.0](https://github.com/npm/pacote/compare/v18.0.6...v19.0.0) (2024-09-27) +### ⚠️ BREAKING CHANGES +* `pacote` now supports node `^18.17.0 || >=20.5.0` +### Bug Fixes +* [`03b31ca`](https://github.com/npm/pacote/commit/03b31cacfe3833a2e435ed50237dfee8014538ae) [#392](https://github.com/npm/pacote/pull/392) align to npm 10 node engine range (@reggi) +### Dependencies +* [`f055f71`](https://github.com/npm/pacote/commit/f055f71f3477f5ce234a42f559e53239cd1dd949) [#395](https://github.com/npm/pacote/pull/395) bump npm-pick-manifest from 9.1.0 to 10.0.0 (#395) (@dependabot[bot]) +* [`932b9ab`](https://github.com/npm/pacote/commit/932b9ab4d133b39b96a03e73d97e08c2f43494f7) [#396](https://github.com/npm/pacote/pull/396) bump @npmcli/package-json from 5.2.1 to 6.0.0 (#396) (@dependabot[bot]) +* [`a1621f9`](https://github.com/npm/pacote/commit/a1621f94537af0e71e66d293d35ff482e4eef0b5) [#397](https://github.com/npm/pacote/pull/397) bump npm-registry-fetch from 17.1.0 to 18.0.0 (#397) (@dependabot[bot]) +* [`c776199`](https://github.com/npm/pacote/commit/c7761995fb79bd6c5b987127f331c7df199833dd) [#398](https://github.com/npm/pacote/pull/398) bump cacache from 18.0.4 to 19.0.0 (#398) (@dependabot[bot]) +* [`6d59022`](https://github.com/npm/pacote/commit/6d590229d709005ec0ed841fa1f4cdf110cffb86) [#399](https://github.com/npm/pacote/pull/399) bump @npmcli/git from 5.0.8 to 6.0.0 (#399) +* [`21ea2d4`](https://github.com/npm/pacote/commit/21ea2d49ce6dd76ffc08540a1670da79126199fb) [#400](https://github.com/npm/pacote/pull/400) bump @npmcli/run-script from 8.1.0 to 9.0.0 (#400) +* [`eddbc01`](https://github.com/npm/pacote/commit/eddbc01e5cbd164437effbe7886385e875517cbf) [#392](https://github.com/npm/pacote/pull/392) `ssri@12.0.0` +* [`6c672e9`](https://github.com/npm/pacote/commit/6c672e99cb33224bfa4d7388d772083364bba293) [#392](https://github.com/npm/pacote/pull/392) `proc-log@5.0.0` +* [`03ba2a2`](https://github.com/npm/pacote/commit/03ba2a21f1d2b6a67813f6dad2459d184a8d6566) [#392](https://github.com/npm/pacote/pull/392) `npm-packlist@9.0.0` +* [`2710286`](https://github.com/npm/pacote/commit/2710286f44625474af23a529c12ea3c8b0cbf4aa) [#392](https://github.com/npm/pacote/pull/392) `npm-package-arg@12.0.0` +* [`aa0bd4a`](https://github.com/npm/pacote/commit/aa0bd4aaf59d2d3c34da33352293ad2774e3d915) [#392](https://github.com/npm/pacote/pull/392) `@npmcli/promise-spawn@8.0.0` +* [`df23343`](https://github.com/npm/pacote/commit/df233432a6ac4c25b8744d429f5e7e358b24abea) [#392](https://github.com/npm/pacote/pull/392) `@npmcli/installed-package-contents@3.0.0` +### Chores +* [`e4ed5cd`](https://github.com/npm/pacote/commit/e4ed5cd66c4bb4c4faef4a511b6d48c72d49470b) [#392](https://github.com/npm/pacote/pull/392) bump hosted-git-info ^7.0.0 to ^8.0.0 (@reggi) +* [`2871f56`](https://github.com/npm/pacote/commit/2871f569064ebaf4a1ae73a42d502e3876d0a18b) [#392](https://github.com/npm/pacote/pull/392) run template-oss-apply (@reggi) +* [`39643f1`](https://github.com/npm/pacote/commit/39643f1e956f83dd84f7f0ab6278f7051a69b32d) [#382](https://github.com/npm/pacote/pull/382) bump @npmcli/eslint-config from 4.0.5 to 5.0.0 (@dependabot[bot]) +* [`7e33c82`](https://github.com/npm/pacote/commit/7e33c829b0143c9a22f1418d6f29f9a7aac03d00) [#383](https://github.com/npm/pacote/pull/383) postinstall for dependabot template-oss PR (@hashtagchris) +* [`e4e07bf`](https://github.com/npm/pacote/commit/e4e07bfb37190ef8c129ca6a643b91a4099560d8) [#383](https://github.com/npm/pacote/pull/383) bump @npmcli/template-oss from 4.23.1 to 4.23.3 (@dependabot[bot]) + ## [18.0.6](https://github.com/npm/pacote/compare/v18.0.5...v18.0.6) (2024-05-07) ### Bug Fixes diff --git a/lib/dir.js b/lib/dir.js index f3229b3..4ae97c2 100644 --- a/lib/dir.js +++ b/lib/dir.js @@ -39,6 +39,8 @@ class DirFetcher extends Fetcher { const stdio = this.opts.foregroundScripts ? 'inherit' : 'pipe' return runScript({ + // this || undefined is because runScript will be unhappy with the default null value + scriptShell: this.opts.scriptShell || undefined, pkg: mani, event: 'prepare', path: this.resolved, diff --git a/lib/fetcher.js b/lib/fetcher.js index cc2c2db..f2ac976 100644 --- a/lib/fetcher.js +++ b/lib/fetcher.js @@ -188,7 +188,15 @@ class FetcherBase { // private // Note: cacache will raise a EINTEGRITY error if the integrity doesn't match #tarballFromCache () { - return cacache.get.stream.byDigest(this.cache, this.integrity, this.opts) + const startTime = Date.now() + const stream = cacache.get.stream.byDigest(this.cache, this.integrity, this.opts) + const elapsedTime = Date.now() - startTime + // cache is good, so log it as a hit in particular since there was no fetch logged + log.http( + 'cache', + `${this.spec} ${elapsedTime}ms (cache hit)` + ) + return stream } get [_.cacheFetches] () { diff --git a/package.json b/package.json index c73fb64..71c9aa1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pacote", - "version": "18.0.6", + "version": "19.0.1", "description": "JavaScript package downloader", "author": "GitHub Inc.", "bin": { @@ -29,7 +29,7 @@ "@npmcli/arborist": "^7.1.0", "@npmcli/eslint-config": "^5.0.0", "@npmcli/template-oss": "4.23.3", - "hosted-git-info": "^7.0.0", + "hosted-git-info": "^8.0.0", "mutate-fs": "^2.1.1", "nock": "^13.2.4", "npm-registry-mock": "^1.3.2", @@ -45,26 +45,26 @@ "git" ], "dependencies": { - "@npmcli/git": "^5.0.0", - "@npmcli/installed-package-contents": "^2.0.1", - "@npmcli/package-json": "^5.1.0", - "@npmcli/promise-spawn": "^7.0.0", - "@npmcli/run-script": "^8.0.0", - "cacache": "^18.0.0", + "@npmcli/git": "^6.0.0", + "@npmcli/installed-package-contents": "^3.0.0", + "@npmcli/package-json": "^6.0.0", + "@npmcli/promise-spawn": "^8.0.0", + "@npmcli/run-script": "^9.0.0", + "cacache": "^19.0.0", "fs-minipass": "^3.0.0", "minipass": "^7.0.2", - "npm-package-arg": "^11.0.0", - "npm-packlist": "^8.0.0", - "npm-pick-manifest": "^9.0.0", - "npm-registry-fetch": "^17.0.0", - "proc-log": "^4.0.0", + "npm-package-arg": "^12.0.0", + "npm-packlist": "^9.0.0", + "npm-pick-manifest": "^10.0.0", + "npm-registry-fetch": "^18.0.0", + "proc-log": "^5.0.0", "promise-retry": "^2.0.1", - "sigstore": "^2.2.0", - "ssri": "^10.0.0", + "sigstore": "^3.0.0", + "ssri": "^12.0.0", "tar": "^6.1.11" }, "engines": { - "node": "^16.14.0 || >=18.0.0" + "node": "^18.17.0 || >=20.5.0" }, "repository": { "type": "git", diff --git a/tap-snapshots/test/dir.js.test.cjs b/tap-snapshots/test/dir.js.test.cjs index 631fc2f..097f9ea 100644 --- a/tap-snapshots/test/dir.js.test.cjs +++ b/tap-snapshots/test/dir.js.test.cjs @@ -312,3 +312,69 @@ Object { }, } ` + +exports[`test/dir.js TAP with prepare script with scriptshell configuration > extract 1`] = ` +Object { + "from": "file:test/fixtures/prepare-script", + "integrity": "{integrity}", + "resolved": "\${CWD}/test/fixtures/prepare-script", +} +` + +exports[`test/dir.js TAP with prepare script with scriptshell configuration > file list 1`] = ` +Array [ + "index.js", + "package.json", + "prepare.js", +] +` + +exports[`test/dir.js TAP with prepare script with scriptshell configuration > manifest 1`] = ` +Object { + "_from": "file:test/fixtures/prepare-script", + "_id": "git-prepare-script@1.0.0", + "_integrity": null, + "_resolved": "\${CWD}/test/fixtures/prepare-script", + "devDependencies": Object { + "abbrev": "^1.1.1", + }, + "license": "ISC", + "main": "index.js", + "name": "git-prepare-script", + "scripts": Object { + "prepare": "node prepare.js", + }, + "version": "1.0.0", +} +` + +exports[`test/dir.js TAP with prepare script with scriptshell configuration > packument 1`] = ` +Object { + "dist-tags": Object { + "latest": "1.0.0", + }, + "name": "git-prepare-script", + "versions": Object { + "1.0.0": Object { + "_from": "file:test/fixtures/prepare-script", + "_id": "git-prepare-script@1.0.0", + "_integrity": null, + "_resolved": "\${CWD}/test/fixtures/prepare-script", + "devDependencies": Object { + "abbrev": "^1.1.1", + }, + "dist": Object { + "integrity": null, + "tarball": "file:\${CWD}/test/fixtures/prepare-script", + }, + "license": "ISC", + "main": "index.js", + "name": "git-prepare-script", + "scripts": Object { + "prepare": "node prepare.js", + }, + "version": "1.0.0", + }, + }, +} +` diff --git a/test/dir.js b/test/dir.js index de17921..a02f85c 100644 --- a/test/dir.js +++ b/test/dir.js @@ -67,6 +67,22 @@ t.test('with prepare script', async t => { }, 'should run in background')) }) +t.test('with prepare script with scriptshell configuration', async t => { + RUNS.length = 0 + const f = new DirFetcher(preparespec, { tree: await loadActual(prepare), scriptShell: 'sh' }) + t.resolveMatchSnapshot(f.packument(), 'packument') + t.resolveMatchSnapshot(f.manifest(), 'manifest') + const index = me + '/prepare/index.js' + return t.resolveMatchSnapshot(f.extract(me + '/prepare'), 'extract') + .then(() => t.spawn(process.execPath, [index], 'test prepared result')) + .then(() => t.matchSnapshot(fs.readdirSync(me + '/prepare').sort(), 'file list')) + .then(() => t.match(RUNS, + [{ + stdio: 'pipe', + scriptShell: 'sh', + }], 'should run in background and use scriptshell configuration')) +}) + t.test('responds to foregroundScripts: true', async t => { RUNS.length = 0 const opt = { foregroundScripts: true, tree: await loadActual(prepare) } diff --git a/test/fetcher.js b/test/fetcher.js index ee6e6a8..8003444 100644 --- a/test/fetcher.js +++ b/test/fetcher.js @@ -210,6 +210,10 @@ t.test('extract', t => { .then(({ resolved, integrity }) => { if (process.platform !== 'win32') { t.match(logs, [ + ['http', + 'cache', + /file:test\/fixtures\/abbrev-1.1.1.tgz.*(cache hit)/, + ], ['warn', 'tar', 'zlib: incorrect header check'], [ 'silly', @@ -239,6 +243,10 @@ t.test('extract', t => { ], 'got expected logs') } else { t.match(logs, [ + ['http', + 'cache', + /file:test\\\\fixtures\\\\abbrev-1.1.1.tgz.*(cache hit)/, + ], ['warn', 'tar', 'zlib: incorrect header check'], [ 'silly', @@ -334,6 +342,10 @@ t.test('extract', t => { }, 'got expected error') if (process.platform !== 'win32') { t.same(logs, [ + ['http', + 'cache', + /file:test\/fixtures\/abbrev-1.1.1.tgz.*(cache hit)/, + ], [ 'silly', 'tarball',