@pnpm/error 1.3.1 → 2.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2016 Rico Sta. Cruz <rico@ricostacruz.com>
4
- Copyright (c) 2016-2020 Zoltan Kochan <z@kochan.io>
3
+ Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
4
+ Copyright (c) 2016-2022 Zoltan Kochan and other contributors
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -19,7 +19,7 @@ import PnpmError from '@pnpm/error'
19
19
 
20
20
  try {
21
21
  throw new PnpmError('THE_ERROR_CODE', 'The error message')
22
- } catch (err) {
22
+ } catch (err: any) { // eslint-disable-line
23
23
  console.log(err.code)
24
24
  //> ERR_PNPM_THE_ERROR_CODE
25
25
  console.log(err.message)
@@ -29,4 +29,4 @@ try {
29
29
 
30
30
  ## License
31
31
 
32
- MIT © [Zoltan Kochan](https://www.kochan.io/)
32
+ MIT
package/lib/index.d.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  export default class PnpmError extends Error {
2
2
  readonly code: string;
3
3
  readonly hint?: string;
4
+ attempts?: number;
4
5
  pkgsStack?: Array<{
5
6
  id: string;
6
7
  name: string;
7
8
  version: string;
8
9
  }>;
9
10
  constructor(code: string, message: string, opts?: {
11
+ attempts?: number;
10
12
  hint?: string;
11
13
  });
12
14
  }
@@ -23,3 +25,6 @@ export declare class FetchError extends PnpmError {
23
25
  readonly request: FetchErrorRequest;
24
26
  constructor(request: FetchErrorRequest, response: FetchErrorResponse, hint?: string);
25
27
  }
28
+ export declare class LockfileMissingDependencyError extends PnpmError {
29
+ constructor(depPath: string);
30
+ }
package/lib/index.js CHANGED
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FetchError = void 0;
3
+ exports.LockfileMissingDependencyError = exports.FetchError = void 0;
4
+ const constants_1 = require("@pnpm/constants");
4
5
  class PnpmError extends Error {
5
6
  constructor(code, message, opts) {
6
7
  super(message);
7
8
  this.code = `ERR_PNPM_${code}`;
8
9
  this.hint = opts === null || opts === void 0 ? void 0 : opts.hint;
10
+ this.attempts = opts === null || opts === void 0 ? void 0 : opts.attempts;
9
11
  }
10
12
  }
11
13
  exports.default = PnpmError;
@@ -13,7 +15,8 @@ class FetchError extends PnpmError {
13
15
  constructor(request, response, hint) {
14
16
  const message = `GET ${request.url}: ${response.statusText} - ${response.status}`;
15
17
  const authHeaderValue = request.authHeaderValue
16
- ? hideAuthInformation(request.authHeaderValue) : undefined;
18
+ ? hideAuthInformation(request.authHeaderValue)
19
+ : undefined;
17
20
  // NOTE: For security reasons, some registries respond with 404 on authentication errors as well.
18
21
  // So we print authorization info on 404 errors as well.
19
22
  if (response.status === 401 || response.status === 403 || response.status === 404) {
@@ -35,4 +38,14 @@ function hideAuthInformation(authHeaderValue) {
35
38
  const [authType, token] = authHeaderValue.split(' ');
36
39
  return `${authType} ${token.substring(0, 4)}[hidden]`;
37
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;
38
51
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+CAAiD;AAEjD,MAAqB,SAAU,SAAQ,KAAK;IAK1C,YACE,IAAY,E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mB,CAAE,eAAuB;IACnD,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACpD,OAAO,GAAG,QAAQ,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,CAAA;AACvD,CAAC;AAED,MAAa,8BAA+B,SAAQ,SAAS;IAC3D,YAAa,OAAe;QAC1B,MAAM,OAAO,GAAG,kCAAkC,OAAO,QAAQ,2BAAe,EAAE,CAAA;QAClF,KAAK,CAAC,6BAA6B,EAAE,OAAO,EAAE;YAC5C,IAAI,EAAE,qEAAqE;gBACzE,iEAAiE;SACpE,CAAC,CAAA;IACJ,CAAC;CACF;AARD,wEAQC"}
package/package.json CHANGED
@@ -1,32 +1,37 @@
1
1
  {
2
2
  "name": "@pnpm/error",
3
- "version": "1.3.1",
3
+ "version": "2.1.0",
4
4
  "description": "An error class for pnpm errors",
5
5
  "main": "lib/index.js",
6
- "typings": "lib/index.d.ts",
6
+ "types": "lib/index.d.ts",
7
7
  "files": [
8
8
  "lib",
9
9
  "!*.map"
10
10
  ],
11
11
  "engines": {
12
- "node": ">=10.13"
12
+ "node": ">=12.17"
13
13
  },
14
- "scripts": {
15
- "lint": "eslint -c ../../eslint.json src/**/*.ts",
16
- "test": "pnpm run compile",
17
- "prepublishOnly": "pnpm run compile",
18
- "compile": "rimraf lib tsconfig.tsbuildinfo && tsc --build"
19
- },
20
- "repository": "https://github.com/pnpm/pnpm/blob/master/packages/error",
14
+ "repository": "https://github.com/pnpm/pnpm/blob/main/packages/error",
21
15
  "keywords": [
16
+ "pnpm6",
22
17
  "pnpm",
23
18
  "error"
24
19
  ],
25
- "author": "Zoltan Kochan <z@kochan.io> (https://www.kochan.io/)",
26
20
  "license": "MIT",
27
21
  "bugs": {
28
22
  "url": "https://github.com/pnpm/pnpm/issues"
29
23
  },
30
- "homepage": "https://github.com/pnpm/pnpm/blob/master/packages/error#readme",
31
- "funding": "https://opencollective.com/pnpm"
32
- }
24
+ "homepage": "https://github.com/pnpm/pnpm/blob/main/packages/error#readme",
25
+ "funding": "https://opencollective.com/pnpm",
26
+ "devDependencies": {
27
+ "@pnpm/error": "2.1.0"
28
+ },
29
+ "dependencies": {
30
+ "@pnpm/constants": "5.0.0"
31
+ },
32
+ "scripts": {
33
+ "lint": "eslint src/**/*.ts",
34
+ "test": "pnpm run compile",
35
+ "compile": "tsc --build && pnpm run lint --fix"
36
+ }
37
+ }
package/CHANGELOG.md DELETED
@@ -1,15 +0,0 @@
1
- # @pnpm/error
2
-
3
- ## 1.3.1
4
-
5
- ### Patch Changes
6
-
7
- - 75a36deba: Report auth info on 404 errors as well.
8
-
9
- ## 1.3.0
10
-
11
- ### Minor Changes
12
-
13
- - 6d480dd7a: A new error class added for throwing fetch errors: FetchError.
14
-
15
- ## 1.2.1