diff --git a/CHANGELOG.md b/CHANGELOG.md index 4064305..cf3051e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,31 @@ +## [1.3.2-beta.3](https://github.com/ghusse/semantic-release-npm-deprecate-old-versions/compare/v1.3.2-beta.2...v1.3.2-beta.3) (2022-01-07) + + +### Bug Fixes + +* :bug: don't quotes versions, only ignore 400 errors ([#40](https://github.com/ghusse/semantic-release-npm-deprecate-old-versions/issues/40)) ([1c14322](https://github.com/ghusse/semantic-release-npm-deprecate-old-versions/commit/1c143220c4b7fb9899b40debb0d01caf10c2c868)) + +## [1.3.2-beta.2](https://github.com/ghusse/semantic-release-npm-deprecate-old-versions/compare/v1.3.2-beta.1...v1.3.2-beta.2) (2022-01-07) + + +### Bug Fixes + +* :bug: don't quotes versions, only ignore 400 errors ([#39](https://github.com/ghusse/semantic-release-npm-deprecate-old-versions/issues/39)) ([638dbba](https://github.com/ghusse/semantic-release-npm-deprecate-old-versions/commit/638dbba62e7eb7a47c0b2417c31a790f23503c00)) + +## [1.3.2-beta.1](https://github.com/ghusse/semantic-release-npm-deprecate-old-versions/compare/v1.3.1...v1.3.2-beta.1) (2022-01-07) + + +### Bug Fixes + +* :bug: quote the version number to deprecate to avoid errors 400 returned by npm ([#36](https://github.com/ghusse/semantic-release-npm-deprecate-old-versions/issues/36)) ([85a3fd7](https://github.com/ghusse/semantic-release-npm-deprecate-old-versions/commit/85a3fd73225f771cf10f7e8f9a2b6c03a015b58b)) + +## [1.3.2-alpha.1](https://github.com/ghusse/semantic-release-npm-deprecate-old-versions/compare/v1.3.1...v1.3.2-alpha.1) (2022-01-07) + + +### Bug Fixes + +* :bug: quote the version number to deprecate to avoid errors 400 returned by npm ([#36](https://github.com/ghusse/semantic-release-npm-deprecate-old-versions/issues/36)) ([85a3fd7](https://github.com/ghusse/semantic-release-npm-deprecate-old-versions/commit/85a3fd73225f771cf10f7e8f9a2b6c03a015b58b)) + ## [1.3.1](https://github.com/ghusse/semantic-release-npm-deprecate-old-versions/compare/v1.3.0...v1.3.1) (2022-01-03) diff --git a/package-lock.json b/package-lock.json index ce0869b..7e3704b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "semantic-release-npm-deprecate-old-versions", - "version": "1.3.1", + "version": "1.3.2-beta.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e8701bf..4022199 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semantic-release-npm-deprecate-old-versions", - "version": "1.3.1", + "version": "1.3.2-beta.3", "description": "A plugin for semantic-release, to automatically deprecate old versions on npm, based on a custom configuration", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/deprecier.test.ts b/src/deprecier.test.ts index 266dd49..3fae1be 100644 --- a/src/deprecier.test.ts +++ b/src/deprecier.test.ts @@ -184,6 +184,48 @@ describe("Deprecier", () => { verifyAll(); }); + it("should log a message when a 400 is thrown", async () => { + const { deprecier, npm } = setup(); + + const packageInfo: PackageInfo = { + name: "name", + versions: { + "1.0.0": { + version: "1.0.0", + name: "name", + }, + }, + }; + + const context = mock(); + + const logger = mock(); + when( + logger.log( + "Version 1.0.0 could not be deprecated, it has not been found. It could be a bug of the registry." + ) + ).thenReturn(undefined); + + when(context.logger).thenReturn(instance(logger)); + + const reason = "reason"; + + when( + npm.deprecate( + { name: "name", version: "1.0.0", reason }, + instance(context) + ) + ).thenReject(new NpmError("E400", "", new Error())); + + await deprecier.deprecate( + packageInfo, + { version: new SemVer("1.0.0"), reason }, + instance(context) + ); + + verifyAll(); + }); + it("should log and rethrow unexpected errors", async () => { const { deprecier, npm } = setup(); diff --git a/src/deprecier.ts b/src/deprecier.ts index 0c443af..e684c63 100644 --- a/src/deprecier.ts +++ b/src/deprecier.ts @@ -32,7 +32,7 @@ export class Deprecier { context.logger.log( `Version ${version.format()} could not be deprecated, is it already deprecated?` ); - } else if (npmError.code === "E404") { + } else if (["E404", "E400"].includes(npmError.code)) { context.logger.log( `Version ${version.format()} could not be deprecated, it has not been found. It could be a bug of the registry.` );