mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-30 04:52:04 -04:00
fix: print better error on git-hosted pkg install failure (#4044)
ref #4038
This commit is contained in:
6
.changeset/eleven-clouds-scream.md
Normal file
6
.changeset/eleven-clouds-scream.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/git-fetcher": patch
|
||||
"@pnpm/tarball-fetcher": patch
|
||||
---
|
||||
|
||||
The temporary directory should be removed after preparing the git-hosted package.
|
||||
5
.changeset/nice-dolphins-kiss.md
Normal file
5
.changeset/nice-dolphins-kiss.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/tarball-fetcher": patch
|
||||
---
|
||||
|
||||
Fetch is not retried if preparation of git-hosted package fails.
|
||||
5
.changeset/spotty-bees-float.md
Normal file
5
.changeset/spotty-bees-float.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/prepare-package": patch
|
||||
---
|
||||
|
||||
If prepare fails, throw a pnpm error with a known error code.
|
||||
@@ -24,6 +24,7 @@ export default () => {
|
||||
// removing /.git to make directory integrity calculation faster
|
||||
await rimraf(path.join(tempLocation, '.git'))
|
||||
const filesIndex = await cafs.addFilesFromDir(tempLocation, opts.manifest)
|
||||
await rimraf(tempLocation)
|
||||
return { filesIndex }
|
||||
},
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/pnpm/pnpm/blob/master/packages/prepare-package#readme",
|
||||
"dependencies": {
|
||||
"@pnpm/error": "workspace:2.0.0",
|
||||
"@pnpm/read-package-json": "workspace:5.0.6",
|
||||
"@zkochan/rimraf": "^2.1.1",
|
||||
"execa": "npm:safe-execa@^0.1.1",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import path from 'path'
|
||||
import PnpmError from '@pnpm/error'
|
||||
import { safeReadPackageFromDir } from '@pnpm/read-package-json'
|
||||
import rimraf from '@zkochan/rimraf'
|
||||
import execa from 'execa'
|
||||
@@ -8,7 +9,11 @@ export default async function preparePackage (pkgDir: string) {
|
||||
const manifest = await safeReadPackageFromDir(pkgDir)
|
||||
if (manifest?.scripts?.prepare != null && manifest.scripts.prepare !== '') {
|
||||
const pm = (await preferredPM(pkgDir))?.name ?? 'npm'
|
||||
await execa(pm, ['install'], { cwd: pkgDir })
|
||||
try {
|
||||
await execa(pm, ['install'], { cwd: pkgDir })
|
||||
} catch (err: any) { // eslint-disable-line
|
||||
throw new PnpmError('PREPARE_PKG_FAILURE', `${err.shortMessage}`) // eslint-disable-line
|
||||
}
|
||||
await rimraf(path.join(pkgDir, 'node_modules'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
"../../typings/**/*.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../error"
|
||||
},
|
||||
{
|
||||
"path": "../read-package-json"
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
"@pnpm/graceful-fs": "workspace:1.0.0",
|
||||
"@pnpm/prepare-package": "workspace:1.0.6",
|
||||
"@zkochan/retry": "^0.2.0",
|
||||
"@zkochan/rimraf": "^2.1.1",
|
||||
"ramda": "^0.27.1",
|
||||
"ssri": "^8.0.1"
|
||||
},
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
import { FetchFromRegistry } from '@pnpm/fetching-types'
|
||||
import preparePackage from '@pnpm/prepare-package'
|
||||
import * as retry from '@zkochan/retry'
|
||||
import rimraf from '@zkochan/rimraf'
|
||||
import fromPairs from 'ramda/src/fromPairs'
|
||||
import omit from 'ramda/src/omit'
|
||||
import ssri from 'ssri'
|
||||
@@ -117,8 +118,13 @@ export default (
|
||||
try {
|
||||
resolve(await fetch(attempt))
|
||||
} catch (error: any) { // eslint-disable-line
|
||||
if (error.response?.status === 401 || error.response?.status === 403) {
|
||||
if (
|
||||
error.response?.status === 401 ||
|
||||
error.response?.status === 403 ||
|
||||
error.code === 'ERR_PNPM_PREPARE_PKG_FAILURE'
|
||||
) {
|
||||
reject(error)
|
||||
return
|
||||
}
|
||||
const timeout = op.retry(error)
|
||||
if (timeout === false) {
|
||||
@@ -242,6 +248,7 @@ async function prepareGitHostedPkg (filesIndex: FilesIndex, cafs: Cafs) {
|
||||
})
|
||||
await preparePackage(tempLocation)
|
||||
const newFilesIndex = await cafs.addFilesFromDir(tempLocation)
|
||||
await rimraf(tempLocation)
|
||||
return newFilesIndex
|
||||
}
|
||||
|
||||
|
||||
4
pnpm-lock.yaml
generated
4
pnpm-lock.yaml
generated
@@ -2894,12 +2894,14 @@ importers:
|
||||
|
||||
packages/prepare-package:
|
||||
specifiers:
|
||||
'@pnpm/error': workspace:2.0.0
|
||||
'@pnpm/prepare-package': 'link:'
|
||||
'@pnpm/read-package-json': workspace:5.0.6
|
||||
'@zkochan/rimraf': ^2.1.1
|
||||
execa: npm:safe-execa@^0.1.1
|
||||
preferred-pm: ^3.0.3
|
||||
dependencies:
|
||||
'@pnpm/error': link:../error
|
||||
'@pnpm/read-package-json': link:../read-package-json
|
||||
'@zkochan/rimraf': 2.1.1
|
||||
execa: /safe-execa/0.1.1
|
||||
@@ -3251,6 +3253,7 @@ importers:
|
||||
'@types/retry': ^0.12.0
|
||||
'@types/ssri': ^7.1.0
|
||||
'@zkochan/retry': ^0.2.0
|
||||
'@zkochan/rimraf': ^2.1.1
|
||||
cp-file: ^9.0.0
|
||||
nock: 12.0.3
|
||||
ramda: ^0.27.1
|
||||
@@ -3264,6 +3267,7 @@ importers:
|
||||
'@pnpm/graceful-fs': link:../graceful-fs
|
||||
'@pnpm/prepare-package': link:../prepare-package
|
||||
'@zkochan/retry': 0.2.0
|
||||
'@zkochan/rimraf': 2.1.1
|
||||
ramda: 0.27.1
|
||||
ssri: 8.0.1
|
||||
devDependencies:
|
||||
|
||||
Reference in New Issue
Block a user