From 38d327c7f47b3af360c2829bae8b785c9be055b5 Mon Sep 17 00:00:00 2001 From: Romain Marcadier Date: Tue, 13 Jun 2023 16:16:56 +0200 Subject: [PATCH] feat(jsii): allow specifying a deprecation message regardless of stability (#4145) Previously, `jsii` required the package's stability to be `deprecated` if there cas a `deprecated` message configured. This is however problematic when a `stable` package reaches End-of-Support and the maintainer wants to signal this in npmjs.com. Instead of failing, only log a warning to possibly raise awareness on an unintended configuration. Additionally - emit the `Development Status :: 7 - Inactive` trove classifier on packages with a `deprecated` message, even if their stability is not `deprecated`. --- packages/jsii-pacmak/lib/targets/python.ts | 9 ++++++++- packages/jsii/lib/project-info.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index e5915a99a1..f06fd7a458 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -2125,7 +2125,14 @@ class Package { scripts, }; - switch (this.metadata.docs?.stability) { + // Packages w/ a deprecated message may have a non-deprecated stability (e.g: when EoL happens + // for a stable package). We pretend it's deprecated for the purpose of trove classifiers when + // this happens. + switch ( + this.metadata.docs?.deprecated + ? spec.Stability.Deprecated + : this.metadata.docs?.stability + ) { case spec.Stability.Experimental: setupKwargs.classifiers.push('Development Status :: 4 - Beta'); break; diff --git a/packages/jsii/lib/project-info.ts b/packages/jsii/lib/project-info.ts index 2de0ae3f13..ce69463553 100644 --- a/packages/jsii/lib/project-info.ts +++ b/packages/jsii/lib/project-info.ts @@ -484,7 +484,7 @@ function _validateStability( if (!stability && deprecated) { stability = spec.Stability.Deprecated; } else if (deprecated && stability !== spec.Stability.Deprecated) { - throw new Error( + console.warn( `Package is deprecated (${deprecated}), but it's stability is ${stability} and not ${spec.Stability.Deprecated}`, ); }