Skip to content

Commit 0ea4f59

Browse files
authored
Update the output for the trebuchet tool (#299)
Update the output for the trebuchet tool: - use bold for commands in the stdout output; indent subprocess putput by two spaces - interpolate the target repo name into the post-PR steps --- - [x] I’ve reviewed the contributor guide and applied the relevant portions to this PR. <details> <summary>Contribution guidelines:</summary><br> - See our [contributor guide](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md) for general expectations for PRs. - Larger or significant changes should be discussed in an issue before creating a PR. - Contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`. - Most changes should add an entry to the changelog and may need to [rev the pubspec package version](https://github.com/dart-lang/sdk/blob/main/docs/External-Package-Maintenance.md#making-a-change). - Changes to packages require [corresponding tests](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md#Testing). Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback. </details>
1 parent 70521d7 commit 0ea4f59

File tree

2 files changed

+45
-28
lines changed

2 files changed

+45
-28
lines changed

pkgs/trebuchet/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
This is a tool to move existing packages into monorepos.
44

5-
## Running this tool
5+
## Running the tool
66

77
```bash
88
dart run bin/trebuchet.dart \
9-
--input-name coverage \
10-
--branch-name master \
11-
--input-path ~/projects/coverage/ \
12-
--target tools \
13-
--target-path ~/projects/tools/ \
14-
--git-filter-repo ~/tools/git-filter-repo \
15-
--dry-run
9+
--input-name coverage \
10+
--branch-name main \
11+
--input-path ~/projects/coverage/ \
12+
--target labs \
13+
--target-path ~/projects/tools/ \
14+
--git-filter-repo ~/tools/git-filter-repo \
15+
--dry-run
1616
```
1717

18-
This basically executes the instructions at https://github.com/dart-lang/ecosystem/wiki/Merging-existing-repos-into-a-monorepo
18+
This basically executes the instructions at https://github.com/dart-lang/ecosystem/wiki/Merging-existing-repos-into-a-monorepo

pkgs/trebuchet/bin/trebuchet.dart

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
// ignore_for_file: lines_longer_than_80_chars
6+
57
import 'dart:io';
68

79
import 'package:args/args.dart';
@@ -148,7 +150,7 @@ class Trebuchet {
148150
'--allow-unrelated-histories',
149151
'${input}_package/$branchName',
150152
'-m',
151-
'Merge package:$input into shared tool repository'
153+
'Merge package:$input into shared $target repository'
152154
],
153155
);
154156

@@ -162,19 +164,24 @@ class Trebuchet {
162164
);
163165
}
164166

167+
final remainingSteps = [
168+
'Move and fix workflow files',
169+
if (!shouldPush)
170+
'Run `git push --set-upstream origin merge-$input-package` in the monorepo directory',
171+
'Disable squash-only in GitHub settings, and merge with a fast forward merge to the main branch, enable squash-only in GitHub settings.',
172+
"Push tags to github using `git tag --list '$input*' | xargs git push origin`",
173+
'Follow up with a PR adding links to the top-level readme table.',
174+
'Transfer issues by running `dart run pkgs/repo_manage/bin/report.dart transfer-issues --source-repo dart-lang/$input --target-repo dart-lang/$target --add-label package:$input --apply-changes`',
175+
"Add a commit to https://github.com/dart-lang/$input/ with it's readme pointing to the monorepo.",
176+
'Update the auto-publishing settings on pub.dev/packages/$input.',
177+
'Archive https://github.com/dart-lang/$input/.',
178+
];
179+
165180
print('DONE!');
166181
print('''
167182
Steps left to do:
168183
169-
- Move and fix workflow files
170-
${shouldPush ? '' : '- Run `git push --set-upstream origin merge-$input-package` in the monorepo directory'}
171-
- Disable squash-only in GitHub settings, and merge with a fast forward merge to the main branch, enable squash-only in GitHub settings.
172-
- Push tags to github using `git tag --list '$input*' | xargs git push origin`
173-
- Follow up with a PR adding links to the top-level readme table.
174-
- Transfer issues by running `dart run pkgs/repo_manage/bin/report.dart transfer-issues --source-repo dart-lang/$input --target-repo dart-lang/$target --add-label package:$input --apply-changes`
175-
- Add a commit to https://github.com/dart-lang/$input/ with it's readme pointing to the monorepo.
176-
- Update the auto-publishing settings on pub.dev/packages/$input.
177-
- Archive https://github.com/dart-lang/$input/.
184+
${remainingSteps.map((step) => ' - $step').join('\n')}
178185
''');
179186
}
180187

@@ -191,27 +198,30 @@ ${shouldPush ? '' : '- Run `git push --set-upstream origin merge-$input-package`
191198
bool overrideDryRun = false,
192199
}) async {
193200
final workingDirectory = inTarget ? targetPath : inputPath;
194-
print('----------');
195-
print('Running `$executable $arguments` in $workingDirectory');
201+
print('');
202+
print('${bold('$executable ${arguments.join(' ')}')} '
203+
'${subtle('[$workingDirectory]')}');
196204
if (!dryRun || overrideDryRun) {
197205
final processResult = await Process.run(
198206
executable,
199207
arguments,
200208
workingDirectory: workingDirectory,
201209
);
202-
print('stdout:');
203-
print(processResult.stdout);
204-
if ((processResult.stderr as String).isNotEmpty) {
205-
print('stderr:');
206-
print(processResult.stderr);
210+
final out = processResult.stdout as String;
211+
if (out.isNotEmpty) {
212+
print(indent(out).trimRight());
213+
}
214+
final err = processResult.stderr as String;
215+
if (err.isNotEmpty) {
216+
print(indent(err).trimRight());
207217
}
208218
if (processResult.exitCode != 0) {
209219
throw ProcessException(executable, arguments);
210220
}
211221
} else {
212-
print('Not running, as --dry-run is set.');
222+
print(' (not running; --dry-run is set)');
213223
}
214-
print('==========');
224+
print('');
215225
}
216226

217227
Future<void> filterRepo(List<String> args) async {
@@ -228,3 +238,10 @@ Future<void> inTempDir(Future<void> Function(Directory temp) f) async {
228238
await f(tempDirectory);
229239
await tempDirectory.delete(recursive: true);
230240
}
241+
242+
String bold(String str) => '\u001b[1m$str\u001b[22m';
243+
244+
String subtle(String str) => '\u001b[2m$str\u001b[22m';
245+
246+
String indent(String str) =>
247+
str.split('\n').map((line) => ' $line').join('\n');

0 commit comments

Comments
 (0)