From 5c63839328b19782bc9a434a77f6028561906b96 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Fri, 25 Oct 2024 21:48:31 +0000 Subject: [PATCH] Bump the sass_api dependency along with package versions (#2408) --- tool/grind/bump_version.dart | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/tool/grind/bump_version.dart b/tool/grind/bump_version.dart index a7adc5ea0..bf28fc66b 100644 --- a/tool/grind/bump_version.dart +++ b/tool/grind/bump_version.dart @@ -14,6 +14,9 @@ import 'package:yaml/yaml.dart'; /// A regular expression that matches a version in a pubspec. final _pubspecVersionRegExp = RegExp(r'^version: (.*)$', multiLine: true); +/// A regular expression that matches a Sass dependency version in a pubspec. +final _sassVersionRegExp = RegExp(r'^( +)sass: (\d.*)$', multiLine: true); + /// Adds grinder tasks for bumping package versions. void addBumpVersionTasks() { for (var patch in [false, true]) { @@ -72,18 +75,33 @@ void _bumpVersion(bool patch, bool dev) { // Bumps the current version of [pubspec] to the next [patch] version, with // `-dev` if [dev] is true. - void bumpDartVersion(String path) { + // + // If [sassVersion] is passed, this bumps the `sass` dependency to that version. + // + // Returns the new version of this package. + Version bumpDartVersion(String path, [Version? sassVersion]) { var text = File(path).readAsStringSync(); var pubspec = loadYaml(text, sourceUrl: p.toUri(path)) as YamlMap; var version = chooseNextVersion(Version.parse(pubspec["version"] as String), pubspec.nodes["version"]!.span); - File(path).writeAsStringSync( - text.replaceFirst(_pubspecVersionRegExp, 'version: $version')); + + text = text.replaceFirst(_pubspecVersionRegExp, 'version: $version'); + if (sassVersion != null) { + // Don't depend on a prerelease version, depend on its released + // equivalent. + var sassDependencyVersion = + Version(sassVersion.major, sassVersion.minor, sassVersion.patch); + text = text.replaceFirstMapped(_sassVersionRegExp, + (match) => '${match[1]}sass: $sassDependencyVersion'); + } + + File(path).writeAsStringSync(text); addChangelogEntry(p.dirname(path), version); + return version; } - bumpDartVersion('pubspec.yaml'); - bumpDartVersion('pkg/sass_api/pubspec.yaml'); + var sassVersion = bumpDartVersion('pubspec.yaml'); + bumpDartVersion('pkg/sass_api/pubspec.yaml', sassVersion); var packageJsonPath = 'pkg/sass-parser/package.json'; var packageJsonText = File(packageJsonPath).readAsStringSync();