From 01166b39a6e207d9578c9e4c547b76176657a7a1 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Fri, 10 Jan 2025 17:03:26 -0800 Subject: [PATCH] Fix deprecation ID displays in JS mode In the pure JS release, these weren't working because the Dart-to-JS logger didn't know to pass along the deprecation metadata when falling back to the wrapped StderrLogger. In the embedded release, these weren't working because we didn't give it an update to match the stderr logger. --- CHANGELOG.md | 6 ++++++ lib/src/embedded/logger.dart | 4 ++++ lib/src/logger/js_to_dart.dart | 10 ++++++++-- lib/src/logger/stderr.dart | 8 ++++---- pkg/sass-parser/CHANGELOG.md | 4 ++++ pkg/sass-parser/package.json | 2 +- pkg/sass_api/CHANGELOG.md | 4 ++++ pkg/sass_api/pubspec.yaml | 4 ++-- pubspec.yaml | 2 +- 9 files changed, 34 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c2186b25..883c00bab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.83.2 + +* Properly display deprecation IDs for the JS Sass API. + +* Don't display deprecation IDs for user-defined deprecations. + ## 1.83.1 * Fix a bug where `--quiet-deps` would get deactivated for `@content` blocks, diff --git a/lib/src/embedded/logger.dart b/lib/src/embedded/logger.dart index dd1f2a223..32a04ed45 100644 --- a/lib/src/embedded/logger.dart +++ b/lib/src/embedded/logger.dart @@ -44,13 +44,17 @@ final class EmbeddedLogger extends LoggerWithDeprecationType { {FileSpan? span, Trace? trace, Deprecation? deprecation}) { var formatted = withGlyphs(() { var buffer = StringBuffer(); + var showDeprecation = + deprecation != null && deprecation != Deprecation.userAuthored; if (_color) { buffer.write('\u001b[33m\u001b[1m'); if (deprecation != null) buffer.write('Deprecation '); buffer.write('Warning\u001b[0m'); + if (showDeprecation) result.write(' [\u001b[34m$deprecation\u001b[0m]'); } else { if (deprecation != null) buffer.write('DEPRECATION '); buffer.write('WARNING'); + if (showDeprecation) result.write(' [$deprecation]'); } if (span == null) { buffer.writeln(': $message'); diff --git a/lib/src/logger/js_to_dart.dart b/lib/src/logger/js_to_dart.dart index 4a11bf546..8ee2b205c 100644 --- a/lib/src/logger/js_to_dart.dart +++ b/lib/src/logger/js_to_dart.dart @@ -41,8 +41,14 @@ final class JSToDartLogger extends LoggerWithDeprecationType { deprecationType: deprecations[deprecation?.id])); } else { _withAscii(() { - _fallback.warn(message, - span: span, trace: trace, deprecation: deprecation != null); + switch (_fallback) { + case LoggerWithDeprecationType(): + _fallback.internalWarn(message, + span: span, trace: trace, deprecation: deprecation); + case _: + _fallback.warn(message, + span: span, trace: trace, deprecation: deprecation != null); + } }); } } diff --git a/lib/src/logger/stderr.dart b/lib/src/logger/stderr.dart index 4682d8bb0..07dcd70b9 100644 --- a/lib/src/logger/stderr.dart +++ b/lib/src/logger/stderr.dart @@ -21,18 +21,18 @@ final class StderrLogger extends LoggerWithDeprecationType { void internalWarn(String message, {FileSpan? span, Trace? trace, Deprecation? deprecation}) { var result = StringBuffer(); + var showDeprecation = + deprecation != null && deprecation != Deprecation.userAuthored; if (color) { // Bold yellow. result.write('\u001b[33m\u001b[1m'); if (deprecation != null) result.write('Deprecation '); result.write('Warning\u001b[0m'); - if (deprecation != null) { - result.write(' [\u001b[34m$deprecation\u001b[0m]'); - } + if (showDeprecation) result.write(' [\u001b[34m$deprecation\u001b[0m]'); } else { if (deprecation != null) result.write('DEPRECATION '); result.write('WARNING'); - if (deprecation != null) result.write(' [$deprecation]'); + if (showDeprecation) result.write(' [$deprecation]'); } if (span == null) { diff --git a/pkg/sass-parser/CHANGELOG.md b/pkg/sass-parser/CHANGELOG.md index af044c012..107d2751c 100644 --- a/pkg/sass-parser/CHANGELOG.md +++ b/pkg/sass-parser/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.10 + +* No user-visible changes. + ## 0.4.9 * No user-visible changes. diff --git a/pkg/sass-parser/package.json b/pkg/sass-parser/package.json index d23090d84..53cfbb154 100644 --- a/pkg/sass-parser/package.json +++ b/pkg/sass-parser/package.json @@ -1,6 +1,6 @@ { "name": "sass-parser", - "version": "0.4.9", + "version": "0.4.10", "description": "A PostCSS-compatible wrapper of the official Sass parser", "repository": "sass/sass", "author": "Google Inc.", diff --git a/pkg/sass_api/CHANGELOG.md b/pkg/sass_api/CHANGELOG.md index a981bb724..127cc7525 100644 --- a/pkg/sass_api/CHANGELOG.md +++ b/pkg/sass_api/CHANGELOG.md @@ -1,3 +1,7 @@ +## 15.0.2 + +* No user-visible changes. + ## 15.0.1 * No user-visible changes. diff --git a/pkg/sass_api/pubspec.yaml b/pkg/sass_api/pubspec.yaml index dd0c08570..ec8ba668e 100644 --- a/pkg/sass_api/pubspec.yaml +++ b/pkg/sass_api/pubspec.yaml @@ -2,7 +2,7 @@ name: sass_api # Note: Every time we add a new Sass AST node, we need to bump the *major* # version because it's a breaking change for anyone who's implementing the # visitor interface(s). -version: 15.0.1 +version: 15.0.2 description: Additional APIs for Dart Sass. homepage: https://github.com/sass/dart-sass @@ -10,7 +10,7 @@ environment: sdk: ">=3.3.0 <4.0.0" dependencies: - sass: 1.83.1 + sass: 1.83.2 dev_dependencies: dartdoc: ^8.0.14 diff --git a/pubspec.yaml b/pubspec.yaml index 9af9300f6..54412ba34 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.83.1 +version: 1.83.2 description: A Sass implementation in Dart. homepage: https://github.com/sass/dart-sass