Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bump the sass_api dependency along with package versions #2408

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions tool/grind/bump_version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down Expand Up @@ -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();
Expand Down