From 5be80a4fe0f5909f37c31667b7eeaf7bc4754eee Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 21 Aug 2024 13:20:09 +0200 Subject: [PATCH 01/15] Add `package:trebuchet` to repo. --- README.md | 1 + pkgs/trebuchet/README.md | 7 + pkgs/trebuchet/analysis_options.yaml | 1 + pkgs/trebuchet/bin/trebuchet.dart | 197 +++++++++++++++++++++++++++ pkgs/trebuchet/pubspec.yaml | 16 +++ 5 files changed, 222 insertions(+) create mode 100644 pkgs/trebuchet/README.md create mode 100644 pkgs/trebuchet/analysis_options.yaml create mode 100644 pkgs/trebuchet/bin/trebuchet.dart create mode 100644 pkgs/trebuchet/pubspec.yaml diff --git a/README.md b/README.md index 1adf3184..652c8040 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ This repository is home to general Dart Ecosystem tools and packages. | [firehose](pkgs/firehose/) | A tool to automate publishing of Pub packages from GitHub actions. | [![pub package](https://img.shields.io/pub/v/firehose.svg)](https://pub.dev/packages/firehose) | | [repo_manage](pkgs/repo_manage/) | Miscellaneous issue, repo, and PR query tools. | | | [sdk_triage_bot](pkgs/sdk_triage_bot/) | A triage automation tool for dart-lang/sdk issues. | | +| [trebuchet](pkgs/trebuchet/) | A tool for hurling packages into monorepos. | | ## Publishing automation diff --git a/pkgs/trebuchet/README.md b/pkgs/trebuchet/README.md new file mode 100644 index 00000000..d4e325b3 --- /dev/null +++ b/pkgs/trebuchet/README.md @@ -0,0 +1,7 @@ +Run + +```bash +dart run bin/trebuchet.dart --input-name coverage --branch-name master --input-path ~/projects/coverage/ --target-path ~/projects/tools/ --git-filter-repo ~/tools/git-filter-repo +``` + +This basically executes the instructions at https://github.com/dart-lang/ecosystem/wiki/Merging-existing-repos-into-a-monorepo \ No newline at end of file diff --git a/pkgs/trebuchet/analysis_options.yaml b/pkgs/trebuchet/analysis_options.yaml new file mode 100644 index 00000000..d978f811 --- /dev/null +++ b/pkgs/trebuchet/analysis_options.yaml @@ -0,0 +1 @@ +include: package:dart_flutter_team_lints/analysis_options.yaml diff --git a/pkgs/trebuchet/bin/trebuchet.dart b/pkgs/trebuchet/bin/trebuchet.dart new file mode 100644 index 00000000..cb702f24 --- /dev/null +++ b/pkgs/trebuchet/bin/trebuchet.dart @@ -0,0 +1,197 @@ +import 'dart:io'; + +import 'package:args/args.dart'; +import 'package:path/path.dart' as p; + +Future main(List arguments) async { + var argParser = ArgParser() + ..addOption( + 'input-name', + help: 'Name of the package which should be transferred to a mono-repo', + ) + ..addOption( + 'input-path', + help: 'Path to the package which should be transferred to a mono-repo', + ) + ..addOption( + 'target-path', + help: 'Path to the mono-repo', + ) + ..addOption( + 'branch-name', + help: 'The name of the main branch on the input repo', + defaultsTo: 'main', + ) + ..addOption( + 'git-filter-repo', + help: 'Path to the git-filter-repo tool', + ) + ..addFlag( + 'push', + help: 'Whether to push the branch to remote', + defaultsTo: true, + ) + ..addFlag( + 'help', + abbr: 'h', + help: 'Prints usage info', + negatable: false, + ) + ..addFlag( + 'dry-run', + help: 'Do not actually execute any of the steps', + defaultsTo: false, + ); + + String input; + String inputPath; + String targetPath; + String branchName; + String gitFilterRepo; + bool push; + bool dryRun; + try { + var parsed = argParser.parse(arguments); + if (parsed.flag('help')) { + print(argParser.usage); + exit(0); + } + + input = parsed['input-name'] as String; + inputPath = parsed['input-path'] as String; + targetPath = parsed['target-path'] as String; + branchName = parsed['branch-name'] as String; + gitFilterRepo = parsed['git-filter-repo'] as String; + push = parsed.flag('push'); + dryRun = parsed.flag('dry-run'); + } catch (e) { + print(e); + print(''); + print(argParser.usage); + exit(1); + } + + var trebuchet = Trebuchet( + input: input, + inputPath: inputPath, + targetPath: targetPath, + branchName: branchName, + gitFilterRepo: gitFilterRepo, + push: push, + dryRun: dryRun, + ); + + await trebuchet.hurl(); +} + +class Trebuchet { + final String input; + final String inputPath; + final String targetPath; + final String branchName; + final String gitFilterRepo; + final bool push; + final bool dryRun; + + Trebuchet({ + required this.input, + required this.inputPath, + required this.targetPath, + required this.branchName, + required this.gitFilterRepo, + required this.push, + required this.dryRun, + }); + + Future hurl() async { + print('Rename to `pkgs/`'); + await filterRepo(['--path-rename', ':pkgs/$input/']); + + print('Prefix tags'); + await filterRepo(['--tag-rename', ':$input-']); + + print('Replace issue references in commit messages'); + final tempDirectory = await Directory.systemTemp.createTemp(); + final regexFile = File(p.join(tempDirectory.path, 'expressions.txt')); + await regexFile.create(); + await regexFile.writeAsString('regex:#(\\d)==>dart-lang/$input#\\1'); + await filterRepo(['--replace-message', regexFile.path]); + + print('Create branch at target'); + await runProcess('git', ['checkout', '-b', 'merge-$input-package']); + + print('Add a remote for the local clone of the moving package'); + await runProcess( + 'git', + ['remote', 'add', '${input}_package', inputPath], + ); + await runProcess('git', ['fetch', '${input}_package']); + + print('Merge branch into monorepo'); + await runProcess( + 'git', + [ + 'merge', + '--allow-unrelated-histories', + '${input}_package/$branchName', + '-m', + 'Merge package:$input into shared tool repository' + ], + ); + + if (push) { + print('Push to remote'); + await runProcess( + 'git', + ['push', '--set-upstream', 'origin', 'merge-$input-package'], + ); + } + + print('DONE!'); + print(''' +Steps left to do: + +- Move and fix workflow files +${push ? '' : '- Run `git push --set-upstream origin merge-$input-package` in the monorepo directory'} +- Disable squash-only in GitHub settings, and merge with a fast forward merge to the main branch, enable squash-only in GitHub settings. +- Push tags to github +- Follow up with a PR adding links to the top-level readme table. +- Add a commit to https://github.com/dart-lang/$input/ with it's readme pointing to the monorepo. +- Update the auto-publishing settings on pub.dev/packages/$input. +- Archive https://github.com/dart-lang/$input/. +'''); + } + + Future runProcess( + String executable, + List arguments, { + bool inTarget = true, + }) async { + final workingDirectory = inTarget ? targetPath : inputPath; + print('----------'); + print('Running `$executable $arguments` in $workingDirectory'); + if (!dryRun) { + var processResult = await Process.run( + executable, + arguments, + workingDirectory: workingDirectory, + ); + print('stdout:'); + print(processResult.stdout); + if ((processResult.stderr as String).isNotEmpty) { + print('stderr:'); + print(processResult.stderr); + } + } else { + print('Not running, as --dry-run is set.'); + } + print('=========='); + } + + Future filterRepo(List args) async { + await runProcess( + 'python3', + [p.relative(gitFilterRepo, from: inputPath), ...args], + ); + } +} diff --git a/pkgs/trebuchet/pubspec.yaml b/pkgs/trebuchet/pubspec.yaml new file mode 100644 index 00000000..73a9620f --- /dev/null +++ b/pkgs/trebuchet/pubspec.yaml @@ -0,0 +1,16 @@ +name: trebuchet +description: A tool for hurling packages into monorepos. + +publish_to: none + +environment: + sdk: ^3.3.0 + +dependencies: + args: ^2.5.0 + path: ^1.9.0 + +dev_dependencies: + dart_flutter_team_lints: ^3.2.0 + lints: ^4.0.0 + test: ^1.24.0 From d9de1ab692dd86ec19686b03e68114f2a5ec704c Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 21 Aug 2024 13:57:03 +0200 Subject: [PATCH 02/15] Add license --- pkgs/trebuchet/bin/trebuchet.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/trebuchet/bin/trebuchet.dart b/pkgs/trebuchet/bin/trebuchet.dart index cb702f24..c221e6ef 100644 --- a/pkgs/trebuchet/bin/trebuchet.dart +++ b/pkgs/trebuchet/bin/trebuchet.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + import 'dart:io'; import 'package:args/args.dart'; From f2c0827cb22e9fc702930620c76bc1638078025e Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 21 Aug 2024 14:03:09 +0200 Subject: [PATCH 03/15] Delete temp dir --- pkgs/trebuchet/analysis_options.yaml | 4 ++++ pkgs/trebuchet/bin/trebuchet.dart | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pkgs/trebuchet/analysis_options.yaml b/pkgs/trebuchet/analysis_options.yaml index d978f811..73a5a734 100644 --- a/pkgs/trebuchet/analysis_options.yaml +++ b/pkgs/trebuchet/analysis_options.yaml @@ -1 +1,5 @@ include: package:dart_flutter_team_lints/analysis_options.yaml + +linter: + rules: + - prefer_final_locals \ No newline at end of file diff --git a/pkgs/trebuchet/bin/trebuchet.dart b/pkgs/trebuchet/bin/trebuchet.dart index c221e6ef..acc7db17 100644 --- a/pkgs/trebuchet/bin/trebuchet.dart +++ b/pkgs/trebuchet/bin/trebuchet.dart @@ -8,7 +8,7 @@ import 'package:args/args.dart'; import 'package:path/path.dart' as p; Future main(List arguments) async { - var argParser = ArgParser() + final argParser = ArgParser() ..addOption( 'input-name', help: 'Name of the package which should be transferred to a mono-repo', @@ -55,7 +55,7 @@ Future main(List arguments) async { bool push; bool dryRun; try { - var parsed = argParser.parse(arguments); + final parsed = argParser.parse(arguments); if (parsed.flag('help')) { print(argParser.usage); exit(0); @@ -75,7 +75,7 @@ Future main(List arguments) async { exit(1); } - var trebuchet = Trebuchet( + final trebuchet = Trebuchet( input: input, inputPath: inputPath, targetPath: targetPath, @@ -120,6 +120,7 @@ class Trebuchet { await regexFile.create(); await regexFile.writeAsString('regex:#(\\d)==>dart-lang/$input#\\1'); await filterRepo(['--replace-message', regexFile.path]); + await tempDirectory.delete(); print('Create branch at target'); await runProcess('git', ['checkout', '-b', 'merge-$input-package']); @@ -175,7 +176,7 @@ ${push ? '' : '- Run `git push --set-upstream origin merge-$input-package` in th print('----------'); print('Running `$executable $arguments` in $workingDirectory'); if (!dryRun) { - var processResult = await Process.run( + final processResult = await Process.run( executable, arguments, workingDirectory: workingDirectory, From 721d9272447f7f906e1edca501e81604f8e23830 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 21 Aug 2024 14:06:47 +0200 Subject: [PATCH 04/15] Refactor --- pkgs/trebuchet/bin/trebuchet.dart | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pkgs/trebuchet/bin/trebuchet.dart b/pkgs/trebuchet/bin/trebuchet.dart index acc7db17..0cb1ab6d 100644 --- a/pkgs/trebuchet/bin/trebuchet.dart +++ b/pkgs/trebuchet/bin/trebuchet.dart @@ -115,12 +115,12 @@ class Trebuchet { await filterRepo(['--tag-rename', ':$input-']); print('Replace issue references in commit messages'); - final tempDirectory = await Directory.systemTemp.createTemp(); - final regexFile = File(p.join(tempDirectory.path, 'expressions.txt')); - await regexFile.create(); - await regexFile.writeAsString('regex:#(\\d)==>dart-lang/$input#\\1'); - await filterRepo(['--replace-message', regexFile.path]); - await tempDirectory.delete(); + await inTempDir((tempDirectory) async { + final regexFile = File(p.join(tempDirectory.path, 'expressions.txt')); + await regexFile.create(); + await regexFile.writeAsString('regex:#(\\d)==>dart-lang/$input#\\1'); + await filterRepo(['--replace-message', regexFile.path]); + }); print('Create branch at target'); await runProcess('git', ['checkout', '-b', 'merge-$input-package']); @@ -200,3 +200,9 @@ ${push ? '' : '- Run `git push --set-upstream origin merge-$input-package` in th ); } } + +Future inTempDir(Future Function(Directory temp) f) async { + final tempDirectory = await Directory.systemTemp.createTemp(); + await f(tempDirectory); + await tempDirectory.delete(); +} From e95aa33d9dfd70543d771843d3b2a82c327b5e80 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 21 Aug 2024 14:07:51 +0200 Subject: [PATCH 05/15] Also delete subdirs --- pkgs/trebuchet/bin/trebuchet.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/trebuchet/bin/trebuchet.dart b/pkgs/trebuchet/bin/trebuchet.dart index 0cb1ab6d..d2a33309 100644 --- a/pkgs/trebuchet/bin/trebuchet.dart +++ b/pkgs/trebuchet/bin/trebuchet.dart @@ -204,5 +204,5 @@ ${push ? '' : '- Run `git push --set-upstream origin merge-$input-package` in th Future inTempDir(Future Function(Directory temp) f) async { final tempDirectory = await Directory.systemTemp.createTemp(); await f(tempDirectory); - await tempDirectory.delete(); + await tempDirectory.delete(recursive: true); } From 620ff49294a417e50e9f4f999ea195dac170e136 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 21 Aug 2024 14:16:10 +0200 Subject: [PATCH 06/15] Abort on non-zero exit code --- pkgs/trebuchet/bin/trebuchet.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/trebuchet/bin/trebuchet.dart b/pkgs/trebuchet/bin/trebuchet.dart index d2a33309..f0244d3b 100644 --- a/pkgs/trebuchet/bin/trebuchet.dart +++ b/pkgs/trebuchet/bin/trebuchet.dart @@ -187,6 +187,9 @@ ${push ? '' : '- Run `git push --set-upstream origin merge-$input-package` in th print('stderr:'); print(processResult.stderr); } + if (processResult.exitCode != 0) { + throw ProcessException(executable, arguments); + } } else { print('Not running, as --dry-run is set.'); } From a52e3d3823d20b00e905420f042ea1cb4e6fa55f Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 21 Aug 2024 14:21:14 +0200 Subject: [PATCH 07/15] Fix working dir --- pkgs/trebuchet/bin/trebuchet.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/trebuchet/bin/trebuchet.dart b/pkgs/trebuchet/bin/trebuchet.dart index f0244d3b..f6726cec 100644 --- a/pkgs/trebuchet/bin/trebuchet.dart +++ b/pkgs/trebuchet/bin/trebuchet.dart @@ -200,6 +200,7 @@ ${push ? '' : '- Run `git push --set-upstream origin merge-$input-package` in th await runProcess( 'python3', [p.relative(gitFilterRepo, from: inputPath), ...args], + inTarget: false, ); } } From a4d84c1dd3cb13588644820316674c1d8b3b79fd Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 21 Aug 2024 14:40:50 +0200 Subject: [PATCH 08/15] Add tag push command --- pkgs/trebuchet/bin/trebuchet.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/trebuchet/bin/trebuchet.dart b/pkgs/trebuchet/bin/trebuchet.dart index f6726cec..4b6ef616 100644 --- a/pkgs/trebuchet/bin/trebuchet.dart +++ b/pkgs/trebuchet/bin/trebuchet.dart @@ -159,7 +159,7 @@ Steps left to do: - Move and fix workflow files ${push ? '' : '- Run `git push --set-upstream origin merge-$input-package` in the monorepo directory'} - Disable squash-only in GitHub settings, and merge with a fast forward merge to the main branch, enable squash-only in GitHub settings. -- Push tags to github +- Push tags to github using `git tag --list '$input*' | xargs git push origin` - Follow up with a PR adding links to the top-level readme table. - Add a commit to https://github.com/dart-lang/$input/ with it's readme pointing to the monorepo. - Update the auto-publishing settings on pub.dev/packages/$input. From 0b5573bfc6ec6ba0d581179f23358149459be244 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 22 Aug 2024 09:36:30 +0200 Subject: [PATCH 09/15] Update README.md Co-authored-by: Devon Carew --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 652c8040..5c6102b1 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This repository is home to general Dart Ecosystem tools and packages. | [firehose](pkgs/firehose/) | A tool to automate publishing of Pub packages from GitHub actions. | [![pub package](https://img.shields.io/pub/v/firehose.svg)](https://pub.dev/packages/firehose) | | [repo_manage](pkgs/repo_manage/) | Miscellaneous issue, repo, and PR query tools. | | | [sdk_triage_bot](pkgs/sdk_triage_bot/) | A triage automation tool for dart-lang/sdk issues. | | -| [trebuchet](pkgs/trebuchet/) | A tool for hurling packages into monorepos. | | +| [trebuchet](pkgs/trebuchet/) | A tool for moving existing packages into monorepos. | | ## Publishing automation From e9ef9c7b8f3bb272c3b51d692702dbb67f04c1ed Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 22 Aug 2024 09:36:40 +0200 Subject: [PATCH 10/15] Update pkgs/trebuchet/README.md Co-authored-by: Devon Carew --- pkgs/trebuchet/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/trebuchet/README.md b/pkgs/trebuchet/README.md index d4e325b3..9dc1b595 100644 --- a/pkgs/trebuchet/README.md +++ b/pkgs/trebuchet/README.md @@ -1,4 +1,8 @@ -Run +## What's this? + +This is a tool to move existing packages into monorepos. + +## Running this tool ```bash dart run bin/trebuchet.dart --input-name coverage --branch-name master --input-path ~/projects/coverage/ --target-path ~/projects/tools/ --git-filter-repo ~/tools/git-filter-repo From 2f0bc3f96ebd3bd9a747f4496e128fe3c3f39f75 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 26 Aug 2024 13:27:14 +0200 Subject: [PATCH 11/15] Add python check --- pkgs/trebuchet/bin/trebuchet.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/trebuchet/bin/trebuchet.dart b/pkgs/trebuchet/bin/trebuchet.dart index 4b6ef616..a9968a19 100644 --- a/pkgs/trebuchet/bin/trebuchet.dart +++ b/pkgs/trebuchet/bin/trebuchet.dart @@ -108,6 +108,15 @@ class Trebuchet { }); Future hurl() async { + print('Check existence of python3 on path'); + await runProcess( + 'python3', + ['--version'], + inTarget: false, + ); + + print('Start moving package'); + print('Rename to `pkgs/`'); await filterRepo(['--path-rename', ':pkgs/$input/']); From 90c85e4016ecb2b6445abc1517e64f0c7a256f93 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 26 Aug 2024 13:30:35 +0200 Subject: [PATCH 12/15] Use .option --- pkgs/trebuchet/bin/trebuchet.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/trebuchet/bin/trebuchet.dart b/pkgs/trebuchet/bin/trebuchet.dart index a9968a19..ee7c4928 100644 --- a/pkgs/trebuchet/bin/trebuchet.dart +++ b/pkgs/trebuchet/bin/trebuchet.dart @@ -61,11 +61,11 @@ Future main(List arguments) async { exit(0); } - input = parsed['input-name'] as String; - inputPath = parsed['input-path'] as String; - targetPath = parsed['target-path'] as String; - branchName = parsed['branch-name'] as String; - gitFilterRepo = parsed['git-filter-repo'] as String; + input = parsed.option('input-name')!; + inputPath = parsed.option('input-path')!; + targetPath = parsed.option('target-path')!; + branchName = parsed.option('branch-name')!; + gitFilterRepo = parsed.option('git-filter-repo')!; push = parsed.flag('push'); dryRun = parsed.flag('dry-run'); } catch (e) { From dffa98320680dbeaefa95df623a1724cfa6eead5 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 26 Aug 2024 13:31:37 +0200 Subject: [PATCH 13/15] Add continuation symbols --- pkgs/trebuchet/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/trebuchet/README.md b/pkgs/trebuchet/README.md index 9dc1b595..21f94013 100644 --- a/pkgs/trebuchet/README.md +++ b/pkgs/trebuchet/README.md @@ -5,7 +5,12 @@ This is a tool to move existing packages into monorepos. ## Running this tool ```bash -dart run bin/trebuchet.dart --input-name coverage --branch-name master --input-path ~/projects/coverage/ --target-path ~/projects/tools/ --git-filter-repo ~/tools/git-filter-repo +dart run bin/trebuchet.dart \ +--input-name coverage \ +--branch-name master \ +--input-path ~/projects/coverage/ \ +--target-path ~/projects/tools/ \ +--git-filter-repo ~/tools/git-filter-repo ``` This basically executes the instructions at https://github.com/dart-lang/ecosystem/wiki/Merging-existing-repos-into-a-monorepo \ No newline at end of file From 5dfe4e54f4817fc74932f856405b7d1c75c3571e Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 26 Aug 2024 13:58:47 +0200 Subject: [PATCH 14/15] Ask to push --- pkgs/trebuchet/bin/trebuchet.dart | 38 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/pkgs/trebuchet/bin/trebuchet.dart b/pkgs/trebuchet/bin/trebuchet.dart index ee7c4928..9286cc23 100644 --- a/pkgs/trebuchet/bin/trebuchet.dart +++ b/pkgs/trebuchet/bin/trebuchet.dart @@ -31,28 +31,22 @@ Future main(List arguments) async { help: 'Path to the git-filter-repo tool', ) ..addFlag( - 'push', - help: 'Whether to push the branch to remote', - defaultsTo: true, + 'dry-run', + help: 'Do not actually execute any of the steps', + defaultsTo: false, ) ..addFlag( 'help', abbr: 'h', help: 'Prints usage info', negatable: false, - ) - ..addFlag( - 'dry-run', - help: 'Do not actually execute any of the steps', - defaultsTo: false, ); - String input; - String inputPath; - String targetPath; - String branchName; - String gitFilterRepo; - bool push; + String? input; + String? inputPath; + String? targetPath; + String? branchName; + String? gitFilterRepo; bool dryRun; try { final parsed = argParser.parse(arguments); @@ -66,7 +60,6 @@ Future main(List arguments) async { targetPath = parsed.option('target-path')!; branchName = parsed.option('branch-name')!; gitFilterRepo = parsed.option('git-filter-repo')!; - push = parsed.flag('push'); dryRun = parsed.flag('dry-run'); } catch (e) { print(e); @@ -81,7 +74,6 @@ Future main(List arguments) async { targetPath: targetPath, branchName: branchName, gitFilterRepo: gitFilterRepo, - push: push, dryRun: dryRun, ); @@ -94,7 +86,6 @@ class Trebuchet { final String targetPath; final String branchName; final String gitFilterRepo; - final bool push; final bool dryRun; Trebuchet({ @@ -103,7 +94,6 @@ class Trebuchet { required this.targetPath, required this.branchName, required this.gitFilterRepo, - required this.push, required this.dryRun, }); @@ -153,7 +143,9 @@ class Trebuchet { ], ); - if (push) { + final shouldPush = getInput('Push to remote? (y/N)'); + + if (shouldPush) { print('Push to remote'); await runProcess( 'git', @@ -166,7 +158,7 @@ class Trebuchet { Steps left to do: - Move and fix workflow files -${push ? '' : '- Run `git push --set-upstream origin merge-$input-package` in the monorepo directory'} +${shouldPush ? '' : '- Run `git push --set-upstream origin merge-$input-package` in the monorepo directory'} - Disable squash-only in GitHub settings, and merge with a fast forward merge to the main branch, enable squash-only in GitHub settings. - Push tags to github using `git tag --list '$input*' | xargs git push origin` - Follow up with a PR adding links to the top-level readme table. @@ -176,6 +168,12 @@ ${push ? '' : '- Run `git push --set-upstream origin merge-$input-package` in th '''); } + bool getInput(String question) { + print(question); + final line = stdin.readLineSync()?.toLowerCase(); + return line == 'y' || line == 'yes'; + } + Future runProcess( String executable, List arguments, { From 1a686958bcc6f4841c8572b45b5388440c979f1f Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 26 Aug 2024 13:59:31 +0200 Subject: [PATCH 15/15] Add newlien --- pkgs/trebuchet/analysis_options.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/trebuchet/analysis_options.yaml b/pkgs/trebuchet/analysis_options.yaml index 73a5a734..df4c571b 100644 --- a/pkgs/trebuchet/analysis_options.yaml +++ b/pkgs/trebuchet/analysis_options.yaml @@ -2,4 +2,4 @@ include: package:dart_flutter_team_lints/analysis_options.yaml linter: rules: - - prefer_final_locals \ No newline at end of file + - prefer_final_locals