2018-06-19 23:00:06 +02:00
|
|
|
// Copyright 2018 Google Inc. Use of this source code is governed by an
|
|
|
|
// MIT-style license that can be found in the LICENSE file or at
|
|
|
|
// https://opensource.org/licenses/MIT.
|
|
|
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
2020-01-24 22:05:04 +01:00
|
|
|
import 'package:cli_pkg/cli_pkg.dart' as pkg;
|
2018-06-19 23:00:06 +02:00
|
|
|
import 'package:grinder/grinder.dart';
|
|
|
|
import 'package:path/path.dart' as p;
|
|
|
|
|
|
|
|
import 'utils.dart';
|
|
|
|
|
|
|
|
@Task('Update the Bazel rules for the current version.')
|
2019-11-06 01:28:26 +01:00
|
|
|
Future<void> updateBazel() async {
|
2018-06-19 23:00:06 +02:00
|
|
|
ensureBuild();
|
|
|
|
|
2018-07-11 22:12:59 +02:00
|
|
|
run("npm", arguments: ["install", "-g", "yarn"]);
|
|
|
|
|
2018-06-19 23:00:06 +02:00
|
|
|
var repo = await cloneOrPull("https://github.com/bazelbuild/rules_sass.git");
|
|
|
|
|
2018-11-16 00:16:24 +01:00
|
|
|
var packageFile = File(p.join(repo, "sass", "package.json"));
|
2018-06-19 23:00:06 +02:00
|
|
|
log("updating ${packageFile.path}");
|
|
|
|
packageFile.writeAsStringSync(packageFile
|
|
|
|
.readAsStringSync()
|
2020-01-24 22:05:04 +01:00
|
|
|
.replaceFirst(RegExp(r'"sass": "[^"]+"'), '"sass": "${pkg.version}"'));
|
2018-06-19 23:00:06 +02:00
|
|
|
|
2021-01-12 01:44:51 +01:00
|
|
|
try {
|
|
|
|
run("yarn", workingDirectory: p.join(repo, "sass"));
|
|
|
|
} on ProcessException catch (error) {
|
|
|
|
if (error.stderr.contains("Couldn't find any versions for \"sass\"")) {
|
2021-01-12 22:59:59 +01:00
|
|
|
log("The new sass version doesn't seem to be available yet, waiting 30s...");
|
|
|
|
await Future<void>.delayed(Duration(seconds: 30));
|
2021-01-12 01:44:51 +01:00
|
|
|
run("yarn", workingDirectory: p.join(repo, "sass"));
|
|
|
|
}
|
|
|
|
}
|
2018-07-11 22:12:59 +02:00
|
|
|
|
2018-06-19 23:00:06 +02:00
|
|
|
run("git",
|
|
|
|
arguments: [
|
|
|
|
"commit",
|
|
|
|
"--all",
|
|
|
|
"--message",
|
2020-01-24 22:05:04 +01:00
|
|
|
"Update Dart Sass to ${pkg.version}"
|
2018-06-19 23:00:06 +02:00
|
|
|
],
|
|
|
|
workingDirectory: repo,
|
|
|
|
runOptions: sassBotEnvironment);
|
|
|
|
|
|
|
|
run("git",
|
2020-01-24 22:05:04 +01:00
|
|
|
arguments: ["tag", pkg.version.toString()],
|
2018-06-19 23:00:06 +02:00
|
|
|
workingDirectory: repo,
|
|
|
|
runOptions: sassBotEnvironment);
|
|
|
|
|
2021-01-12 01:37:46 +01:00
|
|
|
var username = environment('GH_USER');
|
|
|
|
var password = environment('GH_TOKEN');
|
2018-06-19 23:00:06 +02:00
|
|
|
await runAsync("git",
|
|
|
|
arguments: [
|
|
|
|
"push",
|
|
|
|
"--tags",
|
|
|
|
"https://$username:$password@github.com/bazelbuild/rules_sass.git",
|
2018-11-01 22:32:01 +01:00
|
|
|
],
|
|
|
|
workingDirectory: repo);
|
|
|
|
await runAsync("git",
|
|
|
|
arguments: [
|
|
|
|
"push",
|
|
|
|
"https://$username:$password@github.com/bazelbuild/rules_sass.git",
|
2018-11-20 01:38:15 +01:00
|
|
|
"HEAD:master"
|
2018-06-19 23:00:06 +02:00
|
|
|
],
|
|
|
|
workingDirectory: repo);
|
|
|
|
}
|