diff --git a/pkgs/firehose/CHANGELOG.md b/pkgs/firehose/CHANGELOG.md index 6890c0d0..632fb5e9 100644 --- a/pkgs/firehose/CHANGELOG.md +++ b/pkgs/firehose/CHANGELOG.md @@ -2,6 +2,7 @@ - Remove the `version` pubspec checks (these largely duplicate the feedback provided by publishing automation). +- Set minimum SDK version to `3.5.0` because of the `dart_apitool` dependency. ## 0.9.3 diff --git a/pkgs/repo_manage/lib/issue_transfer.dart b/pkgs/repo_manage/lib/issue_transfer.dart index f5b5bf2b..fa624a7f 100644 --- a/pkgs/repo_manage/lib/issue_transfer.dart +++ b/pkgs/repo_manage/lib/issue_transfer.dart @@ -14,51 +14,46 @@ class TransferIssuesCommand extends ReportCommand { TransferIssuesCommand() : super('transfer-issues', 'Bulk transfer issues from one repo to another.') { - argParser.addFlag( - 'apply-changes', - negatable: false, - help: 'WARNING: This will transfer the issues. Please preview the changes' - "first by running without '--apply-changes'.", - defaultsTo: false, - ); - argParser.addMultiOption( - 'issues', - valueHelp: '1,2,3', - help: 'Specifiy the numbers of specific issues to transfer, otherwise' - ' transfers all.', - ); - argParser.addOption( - 'source-repo', - valueHelp: 'repo-org/repo-name', - help: 'The source repository for the issues to be moved from.', - mandatory: true, - ); - argParser.addOption( - 'target-repo', - valueHelp: 'repo-org/repo-name', - help: 'The target repository name where the issues will be moved to.', - mandatory: true, - ); - argParser.addOption( - 'add-label', - help: 'Add a label to all transferred issues.', - valueHelp: 'package:foo', - ); + argParser + ..addFlag( + 'apply-changes', + negatable: false, + help: + 'WARNING: This will transfer the issues. Please preview the changes' + "first by running without '--apply-changes'.", + defaultsTo: false, + ) + ..addOption( + 'source-repo', + valueHelp: 'repo-org/repo-name', + help: 'The source repository for the issues to be moved from.', + mandatory: true, + ) + ..addOption( + 'target-repo', + valueHelp: 'repo-org/repo-name', + help: 'The target repository name where the issues will be moved to.', + mandatory: true, + ) + ..addOption( + 'add-label', + help: 'Add a label to all transferred issues.', + valueHelp: 'package:foo', + ); } @override String get invocation => - '${super.invocation} --source-repo repo-org/old-repo-name --target-repo repo-org/new-repo-name --add-label pkg:old-repo-name'; + '${super.invocation} --source-repo repo-org/old-repo-name --target-repo repo-org/new-repo-name --add-label package:old-repo-name'; @override Future run() async { - var applyChanges = argResults!['apply-changes'] as bool; + var parsedArgs = argResults!; + var applyChanges = parsedArgs.flag('apply-changes'); - var sourceRepo = argResults!['source-repo'] as String; - var targetRepo = argResults!['target-repo'] as String; + var sourceRepo = parsedArgs.option('source-repo')!; + var targetRepo = parsedArgs.option('target-repo')!; - var issueNumberString = argResults!['issues'] as List?; - var issueNumbers = issueNumberString?.map(int.parse).toList(); var labelName = argResults!['add-label'] as String?; if (!applyChanges) { @@ -68,7 +63,6 @@ class TransferIssuesCommand extends ReportCommand { return await transferAndLabelIssues( RepositorySlug.full(sourceRepo), RepositorySlug.full(targetRepo), - issueNumbers, labelName, applyChanges, ); @@ -77,7 +71,6 @@ class TransferIssuesCommand extends ReportCommand { Future transferAndLabelIssues( RepositorySlug sourceRepo, RepositorySlug targetRepo, [ - List? issueNumbers, String? labelName, bool applyChanges = false, ]) async { @@ -118,10 +111,7 @@ class TransferIssuesCommand extends ReportCommand { return 0; } - Future> getIssueIds( - RepositorySlug slug, [ - List? issueNumbers, - ]) async { + Future> getIssueIds(RepositorySlug slug) async { final queryString = '''query { repository(owner:"${slug.owner}", name:"${slug.name}") { issues(last:100) { @@ -144,9 +134,6 @@ class TransferIssuesCommand extends ReportCommand { var nodes = issues['nodes'] as List; return nodes .map((node) => node as Map) - .where((node) => issueNumbers != null - ? issueNumbers.contains(node['number'] as int) - : true) .map((node) => node['id'] as String) .toList(); }, diff --git a/pkgs/trebuchet/README.md b/pkgs/trebuchet/README.md index e3df998b..724c1d90 100644 --- a/pkgs/trebuchet/README.md +++ b/pkgs/trebuchet/README.md @@ -7,7 +7,8 @@ This is a tool to move existing packages into monorepos. ```bash dart run bin/trebuchet.dart \ --input-name coverage \ - --branch-name main \ + --input-branch-name main \ + --target-branch-name main \ --input-path ~/projects/coverage/ \ --target tools \ --target-path ~/projects/tools/ \ diff --git a/pkgs/trebuchet/bin/trebuchet.dart b/pkgs/trebuchet/bin/trebuchet.dart index 60340417..7cd0a771 100644 --- a/pkgs/trebuchet/bin/trebuchet.dart +++ b/pkgs/trebuchet/bin/trebuchet.dart @@ -8,6 +8,7 @@ import 'dart:io'; import 'package:args/args.dart'; import 'package:path/path.dart' as p; +import 'package:pubspec_parse/pubspec_parse.dart'; Future main(List arguments) async { final argParser = ArgParser() @@ -28,7 +29,12 @@ Future main(List arguments) async { help: 'Path to the mono-repo', ) ..addOption( - 'branch-name', + 'input-branch-name', + help: 'The name of the main branch on the input repo', + defaultsTo: 'main', + ) + ..addOption( + 'target-branch-name', help: 'The name of the main branch on the input repo', defaultsTo: 'main', ) @@ -52,7 +58,8 @@ Future main(List arguments) async { String inputPath; String target; String targetPath; - String branchName; + String inputBranchName; + String targetBranchName; String gitFilterRepo; bool dryRun; try { @@ -66,7 +73,8 @@ Future main(List arguments) async { inputPath = parsed.option('input-path')!; target = parsed.option('target')!; targetPath = parsed.option('target-path')!; - branchName = parsed.option('branch-name')!; + inputBranchName = parsed.option('input-branch-name')!; + targetBranchName = parsed.option('target-branch-name')!; gitFilterRepo = parsed.option('git-filter-repo')!; dryRun = parsed.flag('dry-run'); } catch (e) { @@ -81,7 +89,8 @@ Future main(List arguments) async { inputPath: inputPath, target: target, targetPath: targetPath, - branchName: branchName, + inputBranchName: inputBranchName, + targetBranchName: targetBranchName, gitFilterRepo: gitFilterRepo, dryRun: dryRun, ); @@ -94,7 +103,8 @@ class Trebuchet { final String inputPath; final String target; final String targetPath; - final String branchName; + final String inputBranchName; + final String targetBranchName; final String gitFilterRepo; final bool dryRun; @@ -103,7 +113,8 @@ class Trebuchet { required this.inputPath, required this.target, required this.targetPath, - required this.branchName, + required this.inputBranchName, + required this.targetBranchName, required this.gitFilterRepo, required this.dryRun, }); @@ -148,12 +159,52 @@ class Trebuchet { [ 'merge', '--allow-unrelated-histories', - '${input}_package/$branchName', + '${input}_package/$inputBranchName', '-m', - 'Merge package:$input into shared $target repository' + 'Merge package:$input into the $target monorepo', ], ); + print('Replace URI in pubspec'); + Pubspec? pubspec; + if (!dryRun) { + final pubspecFile = + File(p.join(targetPath, 'pkgs', input, 'pubspec.yaml')); + final pubspecContents = await pubspecFile.readAsString(); + pubspec = Pubspec.parse(pubspecContents); + final newPubspecContents = pubspecContents.replaceFirst( + 'repository: https://github.com/dart-lang/$input', + 'repository: https://github.com/dart-lang/$target/tree/$targetBranchName/pkgs/$input', + ); + await pubspecFile.writeAsString(newPubspecContents); + } + + print('Add issue template'); + final issueTemplateFile = + File(p.join(targetPath, '.github', 'ISSUE_TEMPLATE', '$input.md')); + final issueTemplateContents = ''' +--- +name: "package:$input" +about: "Create a bug or file a feature request against package:$input." +labels: "package:$input" +---'''; + if (!dryRun) { + await issueTemplateFile.create(recursive: true); + await issueTemplateFile.writeAsString(issueTemplateContents); + } + + print('Remove CONTRIBUTING.md'); + if (!dryRun) { + final contributingFile = + File(p.join(targetPath, 'pkgs', input, 'CONTRIBUTING.md')); + if (await contributingFile.exists()) await contributingFile.delete(); + } + + print('Committing changes'); + await runProcess('git', ['add', '.']); + await runProcess( + 'git', ['commit', '-m', 'Add issue template and other fixes']); + final shouldPush = getInput('Push to remote? (y/N)'); if (shouldPush) { @@ -165,16 +216,47 @@ class Trebuchet { } final remainingSteps = [ - 'move and fix workflow files', if (!shouldPush) 'run `git push --set-upstream origin merge-$input-package` in the monorepo directory', - "enable 'Allow merge commits' in GitHub settings; merge the PR with 'Create a merge commit'; disable 'Allow merge commits'", - "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', - '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`', - 'update the auto-publishing settings on pub.dev/packages/$input', - "add a commit to https://github.com/dart-lang/$input/ with it's readme pointing to the monorepo", - 'archive https://github.com/dart-lang/$input/', + 'Move and fix workflow files, labeler.yaml, and badges in the README.md', + 'Rev the version of the package, so that pub.dev points to the correct site', + ''' +Add a line to the changelog: +``` +* Move to `dart-lang/$target` monorepo. +``` +''', + ''' +Add the package to the top-level readme of the monorepo: +``` +| [$input](pkgs/$input/) | ${pubspec?.description ?? ''} | [![pub package](https://img.shields.io/pub/v/$input.svg)](https://pub.dev/packages/$input) | +``` +''', + "**Important!** Merge the PR with 'Create a merge commit' (enabling then disabling the `Allow merge commits` admin setting)", + 'Update the auto-publishing settings on https://pub.dev/packages/$input/admin', + ''' +Add the following text to https://github.com/dart-lang/$input/:' + +``` +> [!IMPORTANT] +> This repo has moved to https://github.com/dart-lang/$target/tree/$targetBranchName/pkgs/$input +``` +''', + 'Publish using the autopublish workflow', + """Push tags to GitHub using +```git tag --list '$input*' | xargs git push origin``` +""", + ''' +Close open PRs in dart-lang/$input with the following message: + +``` +Closing as the [dart-lang/$input](https://github.com/dart-lang/$input) repository is merged into the [dart-lang/$target](https://github.com/dart-lang/$target) monorepo. Please re-open this PR there! +``` + ''', + '''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``` +''', + 'Archive https://github.com/dart-lang/$input/', ]; print('DONE!'); diff --git a/pkgs/trebuchet/pubspec.yaml b/pkgs/trebuchet/pubspec.yaml index b245a201..417a2d02 100644 --- a/pkgs/trebuchet/pubspec.yaml +++ b/pkgs/trebuchet/pubspec.yaml @@ -9,6 +9,7 @@ environment: dependencies: args: ^2.5.0 path: ^1.9.0 + pubspec_parse: ^1.3.0 dev_dependencies: dart_flutter_team_lints: ^3.2.0