Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/devtools_test/lib/src/mocks/generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:mockito/annotations.dart';
import 'package:vm_service/vm_service.dart';

// See https://github.com/dart-lang/mockito/blob/master/NULL_SAFETY_README.md
// Run `sh tool/generate_code.sh` to regenerate mocks.
// Run `devtools_tool generate-code` to regenerate mocks.
@GenerateNiceMocks([
MockSpec<ConnectedApp>(),
MockSpec<DebuggerController>(),
Expand Down
4 changes: 2 additions & 2 deletions tool/bots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export PATH="$PATH":"$DEVTOOLS_DIR/tool/bin"
devtools_tool pub-get --only-main

# Generate code.
bash tool/generate_code.sh
devtools_tool generate-code

# Change the CI to the packages/devtools_app directory.
pushd $DEVTOOLS_DIR/packages/devtools_app
Expand Down Expand Up @@ -176,7 +176,7 @@ elif [ "$BOT" = "integration_dart2js" ]; then
dart run integration_test/run_tests.dart --test-app-device=chrome --headless --shard="$SHARD"
elif [ "$DEVICE" = "dart-cli" ]; then
dart run integration_test/run_tests.dart --test-app-device=cli --headless --shard="$SHARD"
fi
fi
elif [ "$DEVTOOLS_PACKAGE" = "devtools_extensions" ]; then
pushd $DEVTOOLS_DIR/packages/devtools_extensions
dart run integration_test/run_tests.dart --headless
Expand Down
46 changes: 0 additions & 46 deletions tool/generate_code.sh

This file was deleted.

61 changes: 61 additions & 0 deletions tool/lib/commands/generate_code.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2023 The Chromium Authors. 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/command_runner.dart';
import 'package:devtools_tool/model.dart';
import 'package:io/io.dart';
import 'package:path/path.dart' as path;

import '../utils.dart';

class GenerateCodeCommand extends Command {
@override
String get name => 'generate-code';

@override
String get description => 'Runs build_runner build for required packages';

@override
Future run() async {
final repo = DevToolsRepo.getInstance();
final processManager = ProcessManager();

for (final packageName in ['devtools_app', 'devtools_test']) {
print('Running build_runner build for $packageName');
final directoryPath = path.join(repo.repoPath, 'packages', packageName);
await processManager.runProcess(
CliCommand.flutter(
'pub run build_runner build --delete-conflicting-outputs',
),
workingDirectory: directoryPath,
);
}

print('Adding lint ignores for mocks');
final mockFile = File(
path.join(
repo.repoPath,
'packages',
'devtools_test',
'lib',
'src',
'mocks',
'generated.mocks.dart',
),
);
var mockFileContents = mockFile.readAsStringSync();
if (!mockFileContents.contains('require_trailing_commas')) {
mockFileContents = mockFileContents.replaceFirst(
'// ignore_for_file:',
'// ignore_for_file: require_trailing_commas\n// ignore_for_file:',
);
mockFile.writeAsStringSync(mockFileContents);
}

// Closes stdin for the entire program.
await sharedStdIn.terminate();
}
}
2 changes: 2 additions & 0 deletions tool/lib/devtools_command_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'package:args/command_runner.dart';
import 'package:devtools_tool/commands/fix_goldens.dart';
import 'package:devtools_tool/commands/generate_code.dart';

import 'commands/analyze.dart';
import 'commands/list.dart';
Expand All @@ -26,5 +27,6 @@ class DevToolsCommandRunner extends CommandRunner {
addCommand(ReleaseHelperCommand());
addCommand(UpdateDevToolsVersionCommand());
addCommand(FixGoldensCommand());
addCommand(GenerateCodeCommand());
}
}
11 changes: 11 additions & 0 deletions tool/lib/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ class CliCommand {
);
}

factory CliCommand.flutter(
String args, {
bool throwOnException = true,
}) {
return CliCommand._(
exe: Platform.isWindows ? 'flutter.bat' : 'flutter',
args: args.split(' '),
throwOnException: throwOnException,
);
}

late final String exe;
late final List<String> args;
final bool throwOnException;
Expand Down
2 changes: 1 addition & 1 deletion tool/refresh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ echo "refresh.sh: refreshing local clone..."

bash tool/upgrade.sh

bash tool/generate_code.sh
bash tool/bin/devtools_tool generate-code

echo "refresh.sh: refreshed local clone."