@pnpm/error 0.0.0-20230605-20230605142810
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +32 -0
- package/lib/index.d.ts +31 -0
- package/lib/index.js +51 -0
- package/lib/index.js.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
|
|
4
|
+
Copyright (c) 2016-2023 Zoltan Kochan and other contributors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @pnpm/error
|
|
2
|
+
|
|
3
|
+
> An error class for pnpm errors
|
|
4
|
+
|
|
5
|
+
<!--@shields('npm')-->
|
|
6
|
+
[](https://www.npmjs.com/package/@pnpm/error)
|
|
7
|
+
<!--/@-->
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm add @pnpm/error
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Usage
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { PnpmError } from '@pnpm/error'
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
throw new PnpmError('THE_ERROR_CODE', 'The error message')
|
|
22
|
+
} catch (err: any) { // eslint-disable-line
|
|
23
|
+
console.log(err.code)
|
|
24
|
+
//> ERR_PNPM_THE_ERROR_CODE
|
|
25
|
+
console.log(err.message)
|
|
26
|
+
//> The error message
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## License
|
|
31
|
+
|
|
32
|
+
MIT
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare class PnpmError extends Error {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
readonly hint?: string;
|
|
4
|
+
attempts?: number;
|
|
5
|
+
prefix?: string;
|
|
6
|
+
pkgsStack?: Array<{
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
}>;
|
|
11
|
+
constructor(code: string, message: string, opts?: {
|
|
12
|
+
attempts?: number;
|
|
13
|
+
hint?: string;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export interface FetchErrorResponse {
|
|
17
|
+
status: number;
|
|
18
|
+
statusText: string;
|
|
19
|
+
}
|
|
20
|
+
export interface FetchErrorRequest {
|
|
21
|
+
url: string;
|
|
22
|
+
authHeaderValue?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare class FetchError extends PnpmError {
|
|
25
|
+
readonly response: FetchErrorResponse;
|
|
26
|
+
readonly request: FetchErrorRequest;
|
|
27
|
+
constructor(request: FetchErrorRequest, response: FetchErrorResponse, hint?: string);
|
|
28
|
+
}
|
|
29
|
+
export declare class LockfileMissingDependencyError extends PnpmError {
|
|
30
|
+
constructor(depPath: string);
|
|
31
|
+
}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LockfileMissingDependencyError = exports.FetchError = exports.PnpmError = void 0;
|
|
4
|
+
const constants_1 = require("@pnpm/constants");
|
|
5
|
+
class PnpmError extends Error {
|
|
6
|
+
constructor(code, message, opts) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.code = `ERR_PNPM_${code}`;
|
|
9
|
+
this.hint = opts?.hint;
|
|
10
|
+
this.attempts = opts?.attempts;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.PnpmError = PnpmError;
|
|
14
|
+
class FetchError extends PnpmError {
|
|
15
|
+
constructor(request, response, hint) {
|
|
16
|
+
const message = `GET ${request.url}: ${response.statusText} - ${response.status}`;
|
|
17
|
+
const authHeaderValue = request.authHeaderValue
|
|
18
|
+
? hideAuthInformation(request.authHeaderValue)
|
|
19
|
+
: undefined;
|
|
20
|
+
// NOTE: For security reasons, some registries respond with 404 on authentication errors as well.
|
|
21
|
+
// So we print authorization info on 404 errors as well.
|
|
22
|
+
if (response.status === 401 || response.status === 403 || response.status === 404) {
|
|
23
|
+
hint = hint ? `${hint}\n\n` : '';
|
|
24
|
+
if (authHeaderValue) {
|
|
25
|
+
hint += `An authorization header was used: ${authHeaderValue}`;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
hint += 'No authorization header was set for the request.';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
super(`FETCH_${response.status}`, message, { hint });
|
|
32
|
+
this.request = request;
|
|
33
|
+
this.response = response;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.FetchError = FetchError;
|
|
37
|
+
function hideAuthInformation(authHeaderValue) {
|
|
38
|
+
const [authType, token] = authHeaderValue.split(' ');
|
|
39
|
+
return `${authType} ${token.substring(0, 4)}[hidden]`;
|
|
40
|
+
}
|
|
41
|
+
class LockfileMissingDependencyError extends PnpmError {
|
|
42
|
+
constructor(depPath) {
|
|
43
|
+
const message = `Broken lockfile: no entry for '${depPath}' in ${constants_1.WANTED_LOCKFILE}`;
|
|
44
|
+
super('LOCKFILE_MISSING_DEPENDENCY', message, {
|
|
45
|
+
hint: 'This issue is probably caused by a badly resolved merge conflict.\n' +
|
|
46
|
+
'To fix the lockfile, run \'pnpm install --no-frozen-lockfile\'.',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.LockfileMissingDependencyError = LockfileMissingDependencyError;
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+CAAiD;AAEjD,MAAa,SAAU,SAAQ,KAAK;IAMlC,YACE,IAAY,EACZ,OAAe,EACf,IAGC;QAED,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,YAAY,IAAI,EAAE,CAAA;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,EAAE,IAAI,CAAA;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,EAAE,QAAQ,CAAA;IAChC,CAAC;CACF;AAnBD,8BAmBC;AAMD,MAAa,UAAW,SAAQ,SAAS;IAIvC,YACE,OAA0B,EAC1B,QAA4B,EAC5B,IAAa;QAEb,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,CAAC,UAAU,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAA;QACjF,MAAM,eA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
|
+
{
|
|
2
|
+
"name": "@pnpm/error",
|
|
3
|
+
"version": "0.0.0-20230605-20230605142810",
|
|
4
|
+
"description": "An error class for pnpm errors",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"!*.map"
|
|
10
|
+
],
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=16.14"
|
|
13
|
+
},
|
|
14
|
+
"repository": "https://github.com/pnpm/pnpm/blob/main/packages/error",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"pnpm8",
|
|
17
|
+
"pnpm",
|
|
18
|
+
"error"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/pnpm/pnpm/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/pnpm/pnpm/blob/main/packages/error#readme",
|
|
25
|
+
"funding": "https://opencollective.com/pnpm",
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@pnpm/error": "0.0.0-20230605-20230605142810"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@pnpm/constants": "0.0.0-20230605-20230605142810"
|
|
31
|
+
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./lib/index.js"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"lint": "eslint \"src/**/*.ts\"",
|
|
37
|
+
"test": "pnpm run compile",
|
|
38
|
+
"compile": "tsc --build && pnpm run lint --fix"
|
|
39
|
+
}
|
|
40
|
+
}
|