Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: tool/grind.dart

Issue 1505723004: Bump to 0.2.1. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:grinder/grinder.dart'; 5 import 'package:grinder/grinder.dart';
6 import 'package:pub_semver/pub_semver.dart';
6 import 'package:yaml/yaml.dart' as yaml; 7 import 'package:yaml/yaml.dart' as yaml;
7 8
9 /// Matches the version line in dart_style's pubspec.
10 final versionPattern = new RegExp(r"^version: .*$", multiLine: true);
jakemac 2015/12/07 22:25:17 I would typically make this private even in entry
Bob Nystrom 2015/12/07 22:50:35 Done. I don't usually bother for entry points, but
11
8 main(args) => grind(args); 12 main(args) => grind(args);
9 13
10 @DefaultTask() 14 @DefaultTask()
11 @Task() 15 @Task()
12 validate() async { 16 validate() async {
17 // Test it.
13 await new TestRunner().testAsync(); 18 await new TestRunner().testAsync();
19
20 // Make sure it's warning clean.
14 Analyzer.analyze("bin/format.dart", fatalWarnings: true); 21 Analyzer.analyze("bin/format.dart", fatalWarnings: true);
15 DartFmt.format("."); 22
23 // Format it.
24 Dart.run("bin/format.dart", arguments: ["-w", "."]);
16 } 25 }
17 26
18 /// Gets ready to publish a new version of the package. 27 /// Gets ready to publish a new version of the package.
19 /// 28 ///
20 /// To publish a version, you need to: 29 /// To publish a version, you need to:
21 /// 30 ///
22 /// 1. Bump the version in the pubspec to a non-dev number. 31 /// 1. Make sure the version in the pubspec is a "-dev" number. This should
32 /// already be the case since you've already landed patches that change
33 /// the formatter and bumped to that as a consequence.
23 /// 34 ///
24 /// 2. Run this task: 35 /// 2. Run this task:
25 /// 36 ///
26 /// pub run grinder bump 37 /// pub run grinder bump
27 /// 38 ///
28 /// 3. Commit the change to a branch. 39 /// 3. Commit the change to a branch.
29 /// 40 ///
30 /// 4. Send it out for review: 41 /// 4. Send it out for review:
31 /// 42 ///
32 /// git cl upload 43 /// git cl upload
33 /// 44 ///
34 /// 5. After the review is complete, land it: 45 /// 5. After the review is complete, land it:
35 /// 46 ///
36 /// git cl land 47 /// git cl land
37 /// 48 ///
38 /// 6. Tag the commit: 49 /// 6. Tag the commit:
39 /// 50 ///
40 /// git tag -a "<version>" -m "<version>" 51 /// git tag -a "<version>" -m "<version>"
41 /// git push origin <version> 52 /// git push origin <version>
42 /// 53 ///
43 /// 7. Publish the package: 54 /// 7. Publish the package:
44 /// 55 ///
45 /// pub lish 56 /// pub lish
46 @Task() 57 @Task()
47 @Depends(validate) 58 @Depends(validate)
48 bump() async { 59 bump() async {
49 // Read the version from the pubspec. 60 // Read the version from the pubspec.
50 var pubspec = yaml.loadYaml(getFile("pubspec.yaml").readAsStringSync()); 61 var pubspecFile = getFile("pubspec.yaml");
51 var version = pubspec["version"]; 62 var pubspec = pubspecFile.readAsStringSync();
52 print(version); 63 var version = new Version.parse(yaml.loadYaml(pubspec)["version"]);
53 64
54 if (version.contains("-dev")) throw "Cannot publish a dev version."; 65 // Require a "-dev" version since we don't otherwise know what to bump it to.
66 if (!version.isPreRelease) throw "Cannot publish non-dev version $version.";
67
68 // Don't allow versions like "1.2.3-dev+4" because it's not clear if the
69 // user intended the "+4" to be discarded or not.
70 if (version.build.isNotEmpty) throw "Cannot publish build version $version.";
71
72 var bumped = new Version(version.major, version.minor, version.patch);
73
74 // Update the version in the pubspec.
75 pubspec = pubspec.replaceAll(versionPattern, "version: $bumped");
jakemac 2015/12/07 22:25:17 If the Version class has an explicit getter for th
Bob Nystrom 2015/12/07 22:50:35 I want to not just match the version string in cas
jakemac 2015/12/07 23:02:53 Oh, I wasn't very clear here :). I was just talkin
76 pubspecFile.writeAsStringSync(pubspec);
55 77
56 // Update the version constant in bin/format.dart. 78 // Update the version constant in bin/format.dart.
57 var binFormatFile = getFile("bin/format.dart"); 79 var binFormatFile = getFile("bin/format.dart");
58 var binFormat = binFormatFile.readAsStringSync().replaceAll( 80 var binFormat = binFormatFile.readAsStringSync().replaceAll(
59 new RegExp(r'const version = "[^"]+";'), 'const version = "$version";'); 81 new RegExp(r'const version = "[^"]+";'), 'const version = "$bumped";');
60 binFormatFile.writeAsStringSync(binFormat); 82 binFormatFile.writeAsStringSync(binFormat);
61 print("Updated version constant to '$version'."); 83 log("Updated version to '$bumped'.");
62 } 84 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698