From 6bbe2232da23f90d4e8d88aa929305bed485a93c Mon Sep 17 00:00:00 2001 From: Matthew Nitschke Date: Fri, 7 Aug 2026 08:23:24 -0600 Subject: [PATCH 1/3] migrated to dart 3 --- .github/workflows/ci.yml | 6 +- .tool-versions | 1 + analysis_options.yaml | 4 - doc/tools/analyze-tool.md | 13 +- doc/tools/format-tool.md | 11 +- doc/tools/tuneup-check-tool.md | 2 +- lib/src/core_config.dart | 2 - lib/src/tools/analyze_tool.dart | 58 ++--- lib/src/tools/format_tool.dart | 37 +-- lib/src/tools/webdev_serve_tool.dart | 3 +- lib/src/utils/dart_semver_version.dart | 5 - lib/src/utils/executables.dart | 6 - lib/src/utils/format_tool_builder.dart | 2 - pubspec.yaml | 2 +- .../fixtures/analyze/failure/pubspec.yaml | 2 +- .../fixtures/analyze/success/pubspec.yaml | 2 +- .../dart_format_configured/pubspec.yaml | 2 +- .../organize_directives_off/pubspec.yaml | 2 +- .../organize_directives_on/pubspec.yaml | 2 +- .../opted_in_custom_config/pubspec.yaml | 2 +- .../lib/lib.dart | 0 .../pubspec.yaml | 10 - .../tool/dart_dev/config.dart | 6 - .../opted_in_no_config/pubspec.yaml | 2 +- .../format_tool_functional_test.dart | 4 +- .../null_safety_functional_test.dart | 8 - test/tools/analyze_tool_test.dart | 89 ++------ .../format/has_dart_style/pubspec.yaml | 2 +- .../format/missing_dart_style/pubspec.yaml | 2 +- .../tuneup_check/has_tuneup/pubspec.yaml | 2 +- .../tuneup_check/missing_tuneup/pubspec.yaml | 2 +- test/tools/format_tool_test.dart | 210 +++--------------- test/tools/webdev_serve_tool_test.dart | 5 +- test/utils/format_tool_builder_test.dart | 6 +- test/utils/get_dart_version_comment_test.dart | 1 - 35 files changed, 122 insertions(+), 391 deletions(-) create mode 100644 .tool-versions delete mode 100644 test/functional/fixtures/null_safety/opted_in_custom_config_version_comment/lib/lib.dart delete mode 100644 test/functional/fixtures/null_safety/opted_in_custom_config_version_comment/pubspec.yaml delete mode 100644 test/functional/fixtures/null_safety/opted_in_custom_config_version_comment/tool/dart_dev/config.dart diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75d069ab..48f86476 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu, windows ] - sdk: [ 2.19.6, stable ] + sdk: [ stable ] name: Dart ${{ matrix.sdk }} on ${{ matrix.os }} runs-on: ${{ matrix.os }}-latest steps: @@ -36,7 +36,7 @@ jobs: - name: Analysis run: dart run dart_dev analyze - name: Formatting - if: ${{ matrix.sdk == 'stable' && matrix.os == 'ubuntu' }} + if: ${{ matrix.os == 'ubuntu' }} run: dart run dart_dev format --check - name: Tests - run: dart run dart_dev test ${{ matrix.sdk != '2.19.6' && '--test-args="--exclude-tags dart2"' || '' }} \ No newline at end of file + run: dart run dart_dev test diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..95bfbd43 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +dart 3.12.2 diff --git a/analysis_options.yaml b/analysis_options.yaml index 2051c706..bf83817e 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -6,10 +6,6 @@ analyzer: language: strict-inference: true strict-raw-types: true - strong-mode: - implicit-casts: true - implicit-dynamic: true - linter: rules: - avoid_types_on_closure_parameters diff --git a/doc/tools/analyze-tool.md b/doc/tools/analyze-tool.md index d82be601..4b5c2d1c 100644 --- a/doc/tools/analyze-tool.md +++ b/doc/tools/analyze-tool.md @@ -1,6 +1,6 @@ # `AnalyzeTool` -Statically analyzes the current project by running the `dartanalyzer`. +Statically analyzes the current project by running `dart analyze`. ## Usage @@ -18,13 +18,13 @@ final config = { ## Default behavior -By default this tool will run `dartanalyzer .` which will analyze all dart files +By default this tool will run `dart analyze .` which will analyze all dart files in the current project. ## Configuration `AnalyzeTool` supports one configuration option which is the list of args to -pass to the `dartanalyzer` process: +pass to `dart analyze`: ```dart // tool/dart_dev/config.dart @@ -44,13 +44,12 @@ final config = { The `analysis_options.yaml` configuration file [supports excluding files][analysis-exclude]. However, there is an -[open issue with the `dartanalyzer` CLI][analyzer-exclude-issue] because it does +[open issue with the `dart analyze` CLI][analyzer-exclude-issue] because it does not respect this list. If your project has files that need to be excluded from analysis (e.g. generated -files), use the [`TuneupCheckTool`][tuneup-check-tool]. It uses the -`tuneup` package to run analysis instead of `dartanalyzer` and it properly -respects the exclude rules defined in `analysis_options.yaml`. +files), use the [`TuneupCheckTool`][tuneup-check-tool] which properly respects +the exclude rules defined in `analysis_options.yaml`. ## Command-line options diff --git a/doc/tools/format-tool.md b/doc/tools/format-tool.md index 9802ded0..a62552db 100644 --- a/doc/tools/format-tool.md +++ b/doc/tools/format-tool.md @@ -1,6 +1,6 @@ # `FormatTool` -Formats dart files in the current project by running `dartfmt`. +Formats dart files in the current project by running `dart format`. ## Usage @@ -18,7 +18,7 @@ final config = { ## Default behavior -By default this tool will run `dartfmt -w .` which will format all dart files in +By default this tool will run `dart format .` which will format all dart files in the current project. ## Configuration @@ -44,11 +44,10 @@ final config = { }; ``` -### Using the `dart_style` package instead of `dartfmt` +### Using the `dart_style` package instead of `dart format` Some projects like to depend on a specific version of the `dart_style` package -and use its `format` executable rather than the `dartfmt` provided by the Dart -SDK. +and use its `format` executable rather than `dart format` from the SDK. ```dart // tool/dart_dev/config.dart @@ -75,7 +74,7 @@ final config = { ```bash $ ddev format [INFO] Running subprocess... -dartfmt -w --fix . +dart format --fix . ---------------------------- ``` diff --git a/doc/tools/tuneup-check-tool.md b/doc/tools/tuneup-check-tool.md index ba453716..ed357062 100644 --- a/doc/tools/tuneup-check-tool.md +++ b/doc/tools/tuneup-check-tool.md @@ -6,7 +6,7 @@ Statically analyzes the current project via the `tuneup` package. This is intended to be used as a drop-in replacement to the [`AnalyzeTool`][analyze-tool] to workaround an -[open issue with `dartanalyzer` and excluding files][analyzer-exclude-issue] via +[open issue with `dart analyze` and excluding files][analyzer-exclude-issue] via `analysis_options.yaml`. Add `tuneup` as a dev dependency to your project: diff --git a/lib/src/core_config.dart b/lib/src/core_config.dart index ceef7655..e3147a46 100644 --- a/lib/src/core_config.dart +++ b/lib/src/core_config.dart @@ -1,8 +1,6 @@ /// A `tool/dart_dev/config.dart` base configuration with the core Dart /// developer tasks. Intended to help standardize dart_dev configuration and /// command-line usage across Dart projects. -library dart_dev.src.core_config; - import 'package:dart_dev/dart_dev.dart'; Map get coreConfig => { diff --git a/lib/src/tools/analyze_tool.dart b/lib/src/tools/analyze_tool.dart index 37987d92..bba99c8c 100644 --- a/lib/src/tools/analyze_tool.dart +++ b/lib/src/tools/analyze_tool.dart @@ -9,7 +9,6 @@ import 'package:logging/logging.dart'; import '../dart_dev_tool.dart'; import '../utils/arg_results_utils.dart'; import '../utils/assert_no_positional_args_nor_args_after_separator.dart'; -import '../utils/dart_semver_version.dart'; import '../utils/executables.dart' as exe; import '../utils/logging.dart'; import '../utils/process_declaration.dart'; @@ -17,15 +16,14 @@ import '../utils/run_process_and_ensure_exit.dart'; final _log = Logger('Analyze'); -/// A dart_dev tool that runs the `dartanalyzer` or `dart analyze` on the current project. -/// If the `useDartAnalyze` flag is not specified it will default to `dartanalyzer`. +/// A dart_dev tool that runs `dart analyze` on the current project. /// /// To use this tool in your project, include it in the dart_dev config in /// `tool/dart_dev/config.dart`: /// import 'package:dart_dev/dart_dev.dart'; /// /// final config = { -/// 'analyze': AnalyzeTool() ..useDartAnalyze = true, +/// 'analyze': AnalyzeTool(), /// }; /// /// This will make it available via the `dart_dev` command-line app like so: @@ -39,25 +37,23 @@ final _log = Logger('Analyze'); /// 'analyze': AnalyzeTool() /// ..analyzerArgs = ['--fatal-infos'] /// ..include = [Glob('.'), Glob('other/**.dart')], -/// ..useDartAnalyze = true /// }; /// /// It is also possible to run this tool directly in a dart script: /// AnalyzeTool().run(); class AnalyzeTool extends DevTool { - /// The args to pass to the `dartanalyzer` or `dart analyze` process run by this tool. + /// The args to pass to the `dart analyze` process run by this tool. /// - /// Run `dartanalyzer -h -v` or `dart analyze -h -v` to see all available args. + /// Run `dart analyze -h -v` to see all available args. List? analyzerArgs; /// The globs to include as entry points to run static analysis on. /// - /// The default is `.` (e.g. `dartanalyzer .`) which runs analysis on all Dart + /// The default is `.` (e.g. `dart analyze .`) which runs analysis on all Dart /// files in the current working directory. List? include; - /// The default tool for analysis will be `dartanalyzer` unless opted in here - /// to utilize `dart analyze`. + @Deprecated('dart analyze is always used in Dart 3+. This field is ignored.') bool? useDartAnalyze; // --------------------------------------------------------------------------- @@ -69,8 +65,8 @@ class AnalyzeTool extends DevTool { ..addOption( 'analyzer-args', help: - 'Args to pass to the "dartanalyzer" or "dart analyze" process.\n' - 'Run "dartanalyzer -h -v" or `dart analyze -h -v" to see all available options.', + 'Args to pass to the "dart analyze" process.\n' + 'Run "dart analyze -h -v" to see all available options.', ); @override @@ -83,17 +79,13 @@ class AnalyzeTool extends DevTool { context ?? DevToolExecutionContext(), configuredAnalyzerArgs: analyzerArgs, include: include, - useDartAnalyze: !dartVersionHasDartanalyzer - ? true - : useDartAnalyze ?? false, ), log: _log, ); } } -/// Returns a combined list of args for the `dartanalyzer` -/// or `dart analyze` process. +/// Returns a combined list of args for the `dart analyze` process. /// /// If [configuredAnalyzerArgs] is non-null, they will be included first. /// @@ -105,17 +97,11 @@ class AnalyzeTool extends DevTool { Iterable buildArgs({ ArgResults? argResults, List? configuredAnalyzerArgs, - bool useDartAnalyze = false, bool verbose = false, }) { final args = [ - // Combine all args that should be passed through to the analyzer in - // this order: - // 1. The analyze command if using dart analyze - if (useDartAnalyze) 'analyze', - // 2. Statically configured args from [AnalyzeTool.analyzerArgs] + 'analyze', ...?configuredAnalyzerArgs, - // 3. Args passed to --analyzer-args ...?splitSingleOptionValue(argResults, 'analyzer-args'), ]; if (verbose && !args.contains('-v') && !args.contains('--verbose')) { @@ -161,9 +147,6 @@ Iterable buildEntrypoints({List? include, String? root}) { /// If non-null, [path] will override the current working directory for any /// operations that require it. This is intended for use by tests. /// -/// If true, [useDartAnalyze] will utilize `dart analyze` for analysis. -/// If null, it will default to utilze `dartanalyzer`. -/// /// The [AnalyzeTool] can be tested almost completely via this function by /// enumerating all of the possible parameter variations and making assertions /// on the declarative output. @@ -172,41 +155,32 @@ ProcessDeclaration buildProcess( List? configuredAnalyzerArgs, List? include, String? path, - bool useDartAnalyze = false, }) { final argResults = context.argResults; if (argResults != null) { - final analyzerUsed = useDartAnalyze ? 'dart analyze' : 'dartanalyzer'; assertNoPositionalArgsNorArgsAfterSeparator( argResults, context.usageException, commandName: context.commandName, usageFooter: - 'Arguments can be passed to the "$analyzerUsed" process via ' + 'Arguments can be passed to the "dart analyze" process via ' 'the --analyzer-args option.', ); } - var executable = useDartAnalyze ? exe.dart : exe.dartanalyzer; final args = buildArgs( argResults: context.argResults, configuredAnalyzerArgs: configuredAnalyzerArgs, verbose: context.verbose, - useDartAnalyze: useDartAnalyze, ); final entrypoints = buildEntrypoints(include: include, root: path); - logCommand( - args, - entrypoints, - verbose: context.verbose, - useDartAnalyzer: useDartAnalyze, - ); - return ProcessDeclaration(executable, [ + logCommand(args, entrypoints, verbose: context.verbose); + return ProcessDeclaration(exe.dart, [ ...args, ...entrypoints, ], mode: ProcessStartMode.inheritStdio); } -/// Logs the `dartanalyzer` or `dart analyze` command that will be run by [AnalyzeTool] so that +/// Logs the `dart analyze` command that will be run by [AnalyzeTool] so that /// consumers can run it directly for debugging purposes. /// /// Unless [verbose] is true, the list of entrypoints will be abbreviated to @@ -214,11 +188,9 @@ ProcessDeclaration buildProcess( void logCommand( Iterable args, Iterable entrypoints, { - bool useDartAnalyzer = false, bool verbose = false, }) { - final exeAndArgs = - '${useDartAnalyzer ? "dart" : "dartanalyzer"} ${args.join(' ')}'.trim(); + final exeAndArgs = 'dart ${args.join(' ')}'.trim(); if (entrypoints.length <= 5 || verbose) { logSubprocessHeader(_log, '$exeAndArgs ${entrypoints.join(' ')}'); diff --git a/lib/src/tools/format_tool.dart b/lib/src/tools/format_tool.dart index 5202e41b..9a2a9560 100644 --- a/lib/src/tools/format_tool.dart +++ b/lib/src/tools/format_tool.dart @@ -13,7 +13,6 @@ import 'package:yaml/yaml.dart'; import '../dart_dev_tool.dart'; import '../utils/arg_results_utils.dart'; import '../utils/assert_no_positional_args_nor_args_after_separator.dart'; -import '../utils/dart_semver_version.dart'; import '../utils/executables.dart' as exe; import '../utils/logging.dart'; import '../utils/organize_directives/organize_directives_in_paths.dart'; @@ -64,14 +63,13 @@ class FormatTool extends DevTool { List? exclude; /// The formatter to run, one of: - /// - `dartfmt` (provided by the SDK) + /// - `dart format` (provided by the SDK) /// - `dart run dart_style:format` (provided by the `dart_style` package) - /// - `dart format` (added in Dart SDK 2.10.0) - Formatter formatter = Formatter.dartfmt; + Formatter formatter = Formatter.dartFormat; /// The args to pass to the formatter process run by this command. /// - /// Run `dartfmt -h -v` or `dart format -h -v` to see all available args. + /// Run `dart format -h -v` to see all available args. List? formatterArgs; /// The language version to pass to formatters that support @@ -116,8 +114,8 @@ class FormatTool extends DevTool { ..addOption( 'formatter-args', help: - 'Args to pass to the "dartfmt" or "dart format" process.\n' - 'Run "dartfmt -h -v" or "dart format -h -v" to see all available options.', + 'Args to pass to the "dart format" process.\n' + 'Run "dart format -h -v" to see all available options.', ); @override @@ -126,7 +124,8 @@ class FormatTool extends DevTool { @override FutureOr run([DevToolExecutionContext? context]) async { context ??= DevToolExecutionContext(); - if (formatter == Formatter.dartfmt && !dartVersionHasDartfmt) { + // ignore: deprecated_member_use_from_same_package + if (formatter == Formatter.dartfmt) { formatter = Formatter.dartFormat; } final formatExecution = buildExecution( @@ -325,11 +324,11 @@ enum FormatMode { /// Available dart formatters. enum Formatter { - // The formatter provided via the Dart SDK. + @Deprecated('Use Formatter.dartFormat instead. dartfmt was removed in Dart 2.15.') dartfmt, // The formatter provided via the `dart_style` package. dartStyle, - // The formatter provided via the Dart 2.10 SDK + // The formatter provided via `dart format`. dartFormat, } @@ -455,6 +454,7 @@ FormatExecution buildExecution( bool organizeDirectives = false, String? path, }) { + formatter ??= Formatter.dartFormat; FormatMode? mode; final useRestForInputs = @@ -469,7 +469,7 @@ FormatExecution buildExecution( allowRest: useRestForInputs, commandName: context.commandName, usageFooter: - 'Arguments can be passed to the "dartfmt" or "dart format" process via the ' + 'Arguments can be passed to the "dart format" process via the ' '--formatter-args option.', ); mode = validateAndParseMode(argResults, context.usageException); @@ -482,10 +482,10 @@ FormatExecution buildExecution( red.wrap('Cannot run "dart_style:format".\n')! + yellow.wrap( 'You must either have a dependency on "dart_style" in ' - 'pubspec.yaml or configure the format tool to use "dartfmt" ' + 'pubspec.yaml or configure the format tool to use "dartFormat" ' 'instead.\n' 'Either add "dart_style" to your pubspec.yaml or configure the ' - 'format tool to use "dartfmt" instead.', + 'format tool to use "dartFormat" instead.', )!, ); return FormatExecution.exitEarly(ExitCode.config.code); @@ -523,7 +523,8 @@ FormatExecution buildExecution( dartStyleSupportsWriteArg, configuredLanguageVersion: languageVersion, ); - if (formatter == Formatter.dartFormat) { + // ignore: deprecated_member_use_from_same_package + if (formatter == Formatter.dartFormat || formatter == Formatter.dartfmt) { args = buildArgsForDartFormat( dartFormatter.args, mode, @@ -565,7 +566,6 @@ FormatExecution buildExecution( /// Returns a representation of the process that will be run by [FormatTool] /// based on the given [formatter]. /// -/// - [Formatter.dartfmt] -> `dartfmt` /// - [Formatter.dartFormat] -> `dart format` /// - [Formatter.dartStyle] -> `dart run dart_style:format` ProcessDeclaration buildFormatProcess([Formatter? formatter]) { @@ -573,10 +573,10 @@ ProcessDeclaration buildFormatProcess([Formatter? formatter]) { case Formatter.dartStyle: return ProcessDeclaration(exe.dart, ['run', 'dart_style:format']); case Formatter.dartFormat: - return ProcessDeclaration(exe.dart, ['format']); + // ignore: deprecated_member_use_from_same_package case Formatter.dartfmt: default: - return ProcessDeclaration(exe.dartfmt, []); + return ProcessDeclaration(exe.dart, ['format']); } } @@ -613,7 +613,8 @@ String? _formatterLanguageVersion( if (formatter == Formatter.dartStyle && !dartStyleSupportsWriteArg) { return configuredLanguageVersion ?? 'latest'; } - if (formatter == Formatter.dartFormat && dartSemverVersion.major >= 3) { + // ignore: deprecated_member_use_from_same_package + if (formatter == Formatter.dartFormat || formatter == Formatter.dartfmt) { return configuredLanguageVersion ?? 'latest'; } return null; diff --git a/lib/src/tools/webdev_serve_tool.dart b/lib/src/tools/webdev_serve_tool.dart index d8a2326c..1c256719 100644 --- a/lib/src/tools/webdev_serve_tool.dart +++ b/lib/src/tools/webdev_serve_tool.dart @@ -10,7 +10,6 @@ import 'package:pub_semver/pub_semver.dart'; import '../dart_dev_tool.dart'; import '../utils/arg_results_utils.dart'; import '../utils/assert_no_positional_args_nor_args_after_separator.dart'; -import '../utils/dart_semver_version.dart'; import '../utils/executables.dart' as exe; import '../utils/global_package_is_active_and_compatible.dart'; import '../utils/logging.dart'; @@ -232,7 +231,7 @@ WebdevServeExecution buildExecution( ); } - final webdevVersion = dartSemverVersion.major == 2 ? '^2.0.0' : '^3.0.0'; + const webdevVersion = '^3.0.0'; if (!globalPackageIsActiveAndCompatible( 'webdev', diff --git a/lib/src/utils/dart_semver_version.dart b/lib/src/utils/dart_semver_version.dart index ca45f635..1a7028c3 100644 --- a/lib/src/utils/dart_semver_version.dart +++ b/lib/src/utils/dart_semver_version.dart @@ -6,8 +6,3 @@ final versionPattern = RegExp(r'(\d+.\d+.\d+)'); Version get dartSemverVersion => Version.parse(versionPattern.firstMatch(Platform.version)!.group(1)!); - -bool get dartVersionHasDartanalyzer => - dartSemverVersion < Version.parse('2.18.0'); - -bool get dartVersionHasDartfmt => dartSemverVersion < Version.parse('2.15.0'); diff --git a/lib/src/utils/executables.dart b/lib/src/utils/executables.dart index 7c3d2a26..ce28e6bc 100644 --- a/lib/src/utils/executables.dart +++ b/lib/src/utils/executables.dart @@ -1,7 +1 @@ -import 'dart:io'; - final dart = 'dart'; - -final dartanalyzer = Platform.isWindows ? 'dartanalyzer.bat' : 'dartanalyzer'; - -final dartfmt = Platform.isWindows ? 'dartfmt.bat' : 'dartfmt'; diff --git a/lib/src/utils/format_tool_builder.dart b/lib/src/utils/format_tool_builder.dart index c52cffdf..28c15ee7 100644 --- a/lib/src/utils/format_tool_builder.dart +++ b/lib/src/utils/format_tool_builder.dart @@ -204,8 +204,6 @@ Formatter? detectFormatterForFormatTool(SimpleIdentifier formatterIdentifier) { switch (formatterIdentifier.name) { case 'dartfmt': - formatter = Formatter.dartfmt; - break; case 'dartFormat': formatter = Formatter.dartFormat; break; diff --git a/pubspec.yaml b/pubspec.yaml index 1c7fc9b9..68c67c93 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ description: > repository: https://github.com/Workiva/dart_dev environment: - sdk: '>=2.19.0 <4.0.0' + sdk: '>=3.0.0 <4.0.0' dependencies: analyzer: ">=5.0.0 <11.0.0" diff --git a/test/functional/fixtures/analyze/failure/pubspec.yaml b/test/functional/fixtures/analyze/failure/pubspec.yaml index 4fd27a07..cf0e0d38 100644 --- a/test/functional/fixtures/analyze/failure/pubspec.yaml +++ b/test/functional/fixtures/analyze/failure/pubspec.yaml @@ -1,7 +1,7 @@ name: dart_dev_test_functional_analyze_failure version: 0.0.0 environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dev_dependencies: dart_dev: path: ../../../../.. diff --git a/test/functional/fixtures/analyze/success/pubspec.yaml b/test/functional/fixtures/analyze/success/pubspec.yaml index ad708292..8a6f1076 100644 --- a/test/functional/fixtures/analyze/success/pubspec.yaml +++ b/test/functional/fixtures/analyze/success/pubspec.yaml @@ -1,7 +1,7 @@ name: dart_dev_test_functional_analyze_success version: 0.0.0 environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dev_dependencies: dart_dev: path: ../../../../.. diff --git a/test/functional/fixtures/format/language_version/dart_format_configured/pubspec.yaml b/test/functional/fixtures/format/language_version/dart_format_configured/pubspec.yaml index f1d8dcfc..1986c502 100644 --- a/test/functional/fixtures/format/language_version/dart_format_configured/pubspec.yaml +++ b/test/functional/fixtures/format/language_version/dart_format_configured/pubspec.yaml @@ -1,7 +1,7 @@ name: dart_dev_test_functional_format_language_version_dart_format version: 0.0.0 environment: - sdk: ">=2.19.0 <4.0.0" + sdk: ">=3.0.0 <4.0.0" dev_dependencies: dart_dev: path: ../../../../../../ diff --git a/test/functional/fixtures/format/unsorted_imports/organize_directives_off/pubspec.yaml b/test/functional/fixtures/format/unsorted_imports/organize_directives_off/pubspec.yaml index 65ebbfd8..7b456eaf 100644 --- a/test/functional/fixtures/format/unsorted_imports/organize_directives_off/pubspec.yaml +++ b/test/functional/fixtures/format/unsorted_imports/organize_directives_off/pubspec.yaml @@ -1,7 +1,7 @@ name: dart_dev_test_functional_format_organize_directives_off version: 0.0.0 environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dev_dependencies: dart_dev: path: ../../../../../../ diff --git a/test/functional/fixtures/format/unsorted_imports/organize_directives_on/pubspec.yaml b/test/functional/fixtures/format/unsorted_imports/organize_directives_on/pubspec.yaml index c2013a5b..f7c3a106 100644 --- a/test/functional/fixtures/format/unsorted_imports/organize_directives_on/pubspec.yaml +++ b/test/functional/fixtures/format/unsorted_imports/organize_directives_on/pubspec.yaml @@ -1,7 +1,7 @@ name: dart_dev_test_functional_format_organize_directives_on version: 0.0.0 environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dev_dependencies: dart_dev: path: ../../../../../../ diff --git a/test/functional/fixtures/null_safety/opted_in_custom_config/pubspec.yaml b/test/functional/fixtures/null_safety/opted_in_custom_config/pubspec.yaml index 574a9dac..9ef9b0fc 100644 --- a/test/functional/fixtures/null_safety/opted_in_custom_config/pubspec.yaml +++ b/test/functional/fixtures/null_safety/opted_in_custom_config/pubspec.yaml @@ -1,7 +1,7 @@ name: dart_dev_test_functional_null_safety_opted_in_custom_config_version_comment version: 0.0.0 environment: - sdk: ">=2.12.0" + sdk: ">=3.0.0 <4.0.0" dev_dependencies: dart_dev: path: ../../../../.. diff --git a/test/functional/fixtures/null_safety/opted_in_custom_config_version_comment/lib/lib.dart b/test/functional/fixtures/null_safety/opted_in_custom_config_version_comment/lib/lib.dart deleted file mode 100644 index e69de29b..00000000 diff --git a/test/functional/fixtures/null_safety/opted_in_custom_config_version_comment/pubspec.yaml b/test/functional/fixtures/null_safety/opted_in_custom_config_version_comment/pubspec.yaml deleted file mode 100644 index 19cfc427..00000000 --- a/test/functional/fixtures/null_safety/opted_in_custom_config_version_comment/pubspec.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: dart_dev_test_functional_null_safety_opted_in_custom_config -version: 0.0.0 -environment: - sdk: ">=2.12.0" -dev_dependencies: - dart_dev: - path: ../../../../.. - -workiva: - disable_core_checks: true diff --git a/test/functional/fixtures/null_safety/opted_in_custom_config_version_comment/tool/dart_dev/config.dart b/test/functional/fixtures/null_safety/opted_in_custom_config_version_comment/tool/dart_dev/config.dart deleted file mode 100644 index 2b4b33c1..00000000 --- a/test/functional/fixtures/null_safety/opted_in_custom_config_version_comment/tool/dart_dev/config.dart +++ /dev/null @@ -1,6 +0,0 @@ -// @dart=2.9 -import 'package:dart_dev/dart_dev.dart'; - -final config = { - ...coreConfig, -}; diff --git a/test/functional/fixtures/null_safety/opted_in_no_config/pubspec.yaml b/test/functional/fixtures/null_safety/opted_in_no_config/pubspec.yaml index 6aa0be75..915e65ff 100644 --- a/test/functional/fixtures/null_safety/opted_in_no_config/pubspec.yaml +++ b/test/functional/fixtures/null_safety/opted_in_no_config/pubspec.yaml @@ -1,7 +1,7 @@ name: dart_dev_test_functional_null_safety_opted_in_no_config version: 0.0.0 environment: - sdk: ">=2.12.0" + sdk: ">=3.0.0 <4.0.0" dev_dependencies: dart_dev: path: ../../../../.. diff --git a/test/functional/format_tool_functional_test.dart b/test/functional/format_tool_functional_test.dart index f6c21826..0990690b 100644 --- a/test/functional/format_tool_functional_test.dart +++ b/test/functional/format_tool_functional_test.dart @@ -2,7 +2,6 @@ @Timeout(Duration(seconds: 20)) import 'dart:io'; -import 'package:dart_dev/src/utils/dart_semver_version.dart'; import 'package:test/test.dart'; import 'package:test_descriptor/test_descriptor.dart' as d; @@ -53,8 +52,7 @@ void main() { final expectedCommandPattern = RegExp( [ RegExp.escape('dart format'), - if (dartSemverVersion.major >= 3) - RegExp.escape('--language-version=3.0'), + RegExp.escape('--language-version=3.0'), r'lib[\\/]main\.dart', ].join(r'\s+'), ); diff --git a/test/functional/null_safety_functional_test.dart b/test/functional/null_safety_functional_test.dart index 497ff444..0e6bb6b0 100644 --- a/test/functional/null_safety_functional_test.dart +++ b/test/functional/null_safety_functional_test.dart @@ -21,13 +21,5 @@ void main() { ); await process.shouldExit(0); }); - - test('with a custom config that has a language version comment', () async { - final process = await runDevToolFunctionalTest( - 'analyze', - 'test/functional/fixtures/null_safety/opted_in_custom_config_version_comment', - ); - await process.shouldExit(0); - }, tags: 'dart2'); }); } diff --git a/test/tools/analyze_tool_test.dart b/test/tools/analyze_tool_test.dart index 1c7adbd6..911001c6 100644 --- a/test/tools/analyze_tool_test.dart +++ b/test/tools/analyze_tool_test.dart @@ -25,8 +25,8 @@ void main() { }); group('buildArgs', () { - test('defaults to an empty list', () { - expect(buildArgs(), isEmpty); + test('defaults to analyze command', () { + expect(buildArgs(), orderedEquals(['analyze'])); }); test('combines configured args and cli args (in that order)', () { @@ -34,26 +34,10 @@ void main() { final argResults = argParser.parse(['--analyzer-args', 'c d']); expect( buildArgs(argResults: argResults, configuredAnalyzerArgs: ['a', 'b']), - orderedEquals(['a', 'b', 'c', 'd']), + orderedEquals(['analyze', 'a', 'b', 'c', 'd']), ); }); - test( - 'combines configured args and cli args (in that order) with useDartAnalyze', - () { - final argParser = AnalyzeTool().toCommand('t').argParser; - final argResults = argParser.parse(['--analyzer-args', 'c d']); - expect( - buildArgs( - argResults: argResults, - configuredAnalyzerArgs: ['a', 'b'], - useDartAnalyze: true, - ), - orderedEquals(['analyze', 'a', 'b', 'c', 'd']), - ); - }, - ); - test('inserts a verbose flag if not already present', () { final argParser = AnalyzeTool().toCommand('t').argParser; final argResults = argParser.parse(['--analyzer-args', 'c d']); @@ -63,21 +47,21 @@ void main() { configuredAnalyzerArgs: ['a', 'b'], verbose: true, ), - orderedEquals(['a', 'b', 'c', 'd', '-v']), + orderedEquals(['analyze', 'a', 'b', 'c', 'd', '-v']), ); }); test('does not insert a duplicate verbose flag (-v)', () { expect( buildArgs(configuredAnalyzerArgs: ['-v'], verbose: true), - orderedEquals(['-v']), + orderedEquals(['analyze', '-v']), ); }); test('does not insert a duplicate verbose flag (--verbose)', () { expect( buildArgs(configuredAnalyzerArgs: ['--verbose'], verbose: true), - orderedEquals(['--verbose']), + orderedEquals(['analyze', '--verbose']), ); }); }); @@ -157,13 +141,6 @@ void main() { test('returns a ProcessDeclaration (default)', () { final context = DevToolExecutionContext(); final process = buildProcess(context); - expect(process.executable, exe.dartanalyzer); - expect(process.args, orderedEquals(['.'])); - }); - - test('returns a ProcessDeclaration with useDartAnalyze (default)', () { - final context = DevToolExecutionContext(); - final process = buildProcess(context, useDartAnalyze: true); expect(process.executable, exe.dart); expect(process.args, orderedEquals(['analyze', '.'])); }); @@ -181,34 +158,6 @@ void main() { include: [Glob('*.dart'), Glob('*.txt')], path: globRoot, ); - expect(process.executable, exe.dartanalyzer); - expect( - process.args, - orderedEquals([ - '--fatal-infos', - '--fatal-warnings', - '--dart-sdk', - '/sdk', - '${globRoot}file.dart', - '${globRoot}file.txt', - ]), - ); - }); - - test('returns a ProcessDeclaration with useDartAnalyzer (with args)', () { - final argParser = AnalyzeTool().toCommand('t').argParser; - final argResults = argParser.parse([ - '--analyzer-args', - '--dart-sdk /sdk', - ]); - final context = DevToolExecutionContext(argResults: argResults); - final process = buildProcess( - context, - configuredAnalyzerArgs: ['--fatal-infos', '--fatal-warnings'], - include: [Glob('*.dart')], - path: globRoot, - useDartAnalyze: true, - ); expect(process.executable, exe.dart); expect( process.args, @@ -219,6 +168,7 @@ void main() { '--dart-sdk', '/sdk', '${globRoot}file.dart', + '${globRoot}file.txt', ]), ); }); @@ -239,10 +189,11 @@ void main() { include: [Glob('*.dart'), Glob('*.txt')], path: globRoot, ); - expect(process.executable, exe.dartanalyzer); + expect(process.executable, exe.dart); expect( process.args, orderedEquals([ + 'analyze', '--fatal-infos', '--fatal-warnings', '--dart-sdk', @@ -259,33 +210,29 @@ void main() { test('with <=5 entrypoints', () { expect( Logger.root.onRecord, - emitsThrough(infoLogOf(contains('dartanalyzer -t a b c d e'))), + emitsThrough(infoLogOf(contains('dart analyze -t a b c d e'))), ); - logCommand(['-t'], ['a', 'b', 'c', 'd', 'e'], useDartAnalyzer: false); + logCommand(['analyze', '-t'], ['a', 'b', 'c', 'd', 'e']); }); test('with >5 entrypoints', () { expect( Logger.root.onRecord, - emitsThrough(infoLogOf(contains('dartanalyzer -t <6 paths>'))), + emitsThrough(infoLogOf(contains('dart analyze -t <6 paths>'))), ); - logCommand(['-t'], ['a', 'b', 'c', 'd', 'e', 'f']); + logCommand(['analyze', '-t'], ['a', 'b', 'c', 'd', 'e', 'f']); }); test('with >5 entrypoints in verbose mode', () { expect( Logger.root.onRecord, - emitsThrough(infoLogOf(contains('dartanalyzer -t a b c d e f'))), + emitsThrough(infoLogOf(contains('dart analyze -t a b c d e f'))), ); - logCommand(['-t'], ['a', 'b', 'c', 'd', 'e', 'f'], verbose: true); - }); - - test('in useDartAnalyze mode', () { - expect( - Logger.root.onRecord, - emitsThrough(infoLogOf(contains('dart analyze -t a'))), + logCommand( + ['analyze', '-t'], + ['a', 'b', 'c', 'd', 'e', 'f'], + verbose: true, ); - logCommand(['analyze', '-t'], ['a'], useDartAnalyzer: true); }); }); } diff --git a/test/tools/fixtures/format/has_dart_style/pubspec.yaml b/test/tools/fixtures/format/has_dart_style/pubspec.yaml index 9ee2462d..f007049b 100644 --- a/test/tools/fixtures/format/has_dart_style/pubspec.yaml +++ b/test/tools/fixtures/format/has_dart_style/pubspec.yaml @@ -1,6 +1,6 @@ name: has_dart_style environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dev_dependencies: dart_style: ^2.0.0 diff --git a/test/tools/fixtures/format/missing_dart_style/pubspec.yaml b/test/tools/fixtures/format/missing_dart_style/pubspec.yaml index 0bda9ee3..912e153b 100644 --- a/test/tools/fixtures/format/missing_dart_style/pubspec.yaml +++ b/test/tools/fixtures/format/missing_dart_style/pubspec.yaml @@ -1,6 +1,6 @@ name: missing_dart_style environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dev_dependencies: test: any diff --git a/test/tools/fixtures/tuneup_check/has_tuneup/pubspec.yaml b/test/tools/fixtures/tuneup_check/has_tuneup/pubspec.yaml index 6c788e74..97c986b7 100644 --- a/test/tools/fixtures/tuneup_check/has_tuneup/pubspec.yaml +++ b/test/tools/fixtures/tuneup_check/has_tuneup/pubspec.yaml @@ -1,6 +1,6 @@ name: has_tuneup environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dev_dependencies: tuneup: any diff --git a/test/tools/fixtures/tuneup_check/missing_tuneup/pubspec.yaml b/test/tools/fixtures/tuneup_check/missing_tuneup/pubspec.yaml index f8d543fd..1fe600a6 100644 --- a/test/tools/fixtures/tuneup_check/missing_tuneup/pubspec.yaml +++ b/test/tools/fixtures/tuneup_check/missing_tuneup/pubspec.yaml @@ -1,6 +1,6 @@ name: missing_tuneup environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" workiva: disable_core_checks: true diff --git a/test/tools/format_tool_test.dart b/test/tools/format_tool_test.dart index 97b73f67..6806e19d 100644 --- a/test/tools/format_tool_test.dart +++ b/test/tools/format_tool_test.dart @@ -5,7 +5,6 @@ import 'package:args/args.dart'; import 'package:args/command_runner.dart'; import 'package:dart_dev/src/dart_dev_tool.dart'; import 'package:dart_dev/src/tools/format_tool.dart'; -import 'package:dart_dev/src/utils/dart_semver_version.dart'; import 'package:dart_dev/src/utils/executables.dart' as exe; import 'package:glob/glob.dart'; import 'package:io/io.dart'; @@ -111,90 +110,6 @@ void main() { }); }); - group('buildArgs', () { - test('no mode', () { - expect(buildArgs(['a', 'b'], null), orderedEquals(['a', 'b'])); - }); - - test('mode=overwrite', () { - expect( - buildArgs(['a', 'b'], FormatMode.overwrite), - orderedEquals(['a', 'b', '-w']), - ); - }); - - test('mode=overwrite without write arg', () { - expect( - buildArgs( - ['a', 'b'], - FormatMode.overwrite, - passWriteArgForOverwrite: false, - ), - orderedEquals(['a', 'b']), - ); - }); - - test('adds latest language version flag when configured', () { - expect( - buildArgs( - ['a', 'b'], - FormatMode.overwrite, - passWriteArgForOverwrite: false, - languageVersion: 'latest', - ), - orderedEquals(['a', 'b', '--language-version=latest']), - ); - }); - - test('adds configured language version flag', () { - expect( - buildArgs( - ['a', 'b'], - FormatMode.overwrite, - passWriteArgForOverwrite: false, - languageVersion: '3.0', - ), - orderedEquals(['a', 'b', '--language-version=3.0']), - ); - }); - - test('mode=dry-run', () { - expect( - buildArgs(['a', 'b'], FormatMode.dryRun), - orderedEquals(['a', 'b', '-n']), - ); - }); - - test('mode=check', () { - expect( - buildArgs(['a', 'b'], FormatMode.check), - orderedEquals(['a', 'b', '-n', '--set-exit-if-changed']), - ); - }); - - test('combines configured args with cli args (in that order)', () { - final argParser = FormatTool().toCommand('t').argParser; - final argResults = argParser.parse(['--formatter-args', '--indent 2']); - expect( - buildArgs( - ['a', 'b'], - FormatMode.overwrite, - argResults: argResults, - configuredFormatterArgs: ['--fix', '--follow-links'], - ), - orderedEquals([ - 'a', - 'b', - '-w', - '--fix', - '--follow-links', - '--indent', - '2', - ]), - ); - }); - }); - group('buildArgsForDartFormat', () { test('no mode', () { expect( @@ -280,8 +195,11 @@ void main() { ); final execution = buildExecution(context); expect(execution.exitCode, isNull); - expect(execution.formatProcess!.executable, exe.dartfmt); - expect(execution.formatProcess!.args, orderedEquals(['a/random/path'])); + expect(execution.formatProcess!.executable, exe.dart); + expect( + execution.formatProcess!.args, + orderedEquals(['format', '--language-version=latest', 'a/random/path']), + ); expect(execution.formatProcess!.mode, ProcessStartMode.inheritStdio); expect(execution.directiveOrganization, isNull); }); @@ -339,7 +257,7 @@ void main() { allOf( contains('Cannot run "dart_style:format"'), contains('add "dart_style" to your pubspec.yaml'), - contains('use "dartfmt" instead'), + contains('use "dartFormat" instead'), ), ), ), @@ -381,8 +299,11 @@ void main() { final context = DevToolExecutionContext(); final execution = buildExecution(context); expect(execution.exitCode, isNull); - expect(execution.formatProcess!.executable, exe.dartfmt); - expect(execution.formatProcess!.args, orderedEquals(['.'])); + expect(execution.formatProcess!.executable, exe.dart); + expect( + execution.formatProcess!.args, + orderedEquals(['format', '--language-version=latest', '.']), + ); expect(execution.formatProcess!.mode, ProcessStartMode.inheritStdio); expect(execution.directiveOrganization, isNull); }); @@ -394,18 +315,17 @@ void main() { defaultMode: FormatMode.dryRun, ); expect(execution.exitCode, isNull); - expect(execution.formatProcess!.executable, exe.dartfmt); - expect(execution.formatProcess!.args, orderedEquals(['-n', '.'])); - expect(execution.formatProcess!.mode, ProcessStartMode.inheritStdio); - expect(execution.directiveOrganization, isNull); - }); - - test('with dartfmt', () { - final context = DevToolExecutionContext(); - final execution = buildExecution(context, formatter: Formatter.dartfmt); - expect(execution.exitCode, isNull); - expect(execution.formatProcess!.executable, exe.dartfmt); - expect(execution.formatProcess!.args, orderedEquals(['.'])); + expect(execution.formatProcess!.executable, exe.dart); + expect( + execution.formatProcess!.args, + orderedEquals([ + 'format', + '-o', + 'none', + '--language-version=latest', + '.', + ]), + ); expect(execution.formatProcess!.mode, ProcessStartMode.inheritStdio); expect(execution.directiveOrganization, isNull); }); @@ -420,11 +340,7 @@ void main() { expect(execution.formatProcess!.executable, exe.dart); expect( execution.formatProcess!.args, - orderedEquals([ - 'format', - if (dartSemverVersion.major >= 3) '--language-version=latest', - '.', - ]), + orderedEquals(['format', '--language-version=latest', '.']), ); expect(execution.formatProcess!.mode, ProcessStartMode.inheritStdio); }); @@ -446,36 +362,6 @@ void main() { expect(execution.directiveOrganization, isNull); }); - test('dartfmt with args', () { - final argParser = FormatTool().toCommand('t').argParser; - final argResults = argParser.parse([ - '-w', - '--formatter-args', - '--indent 2', - ]); - final context = DevToolExecutionContext(argResults: argResults); - final execution = buildExecution( - context, - configuredFormatterArgs: ['--fix', '--follow-links'], - formatter: Formatter.dartfmt, - ); - expect(execution.exitCode, isNull); - expect(execution.formatProcess!.executable, exe.dartfmt); - expect( - execution.formatProcess!.args, - orderedEquals([ - '-w', - '--fix', - '--follow-links', - '--indent', - '2', - '.', - ]), - ); - expect(execution.formatProcess!.mode, ProcessStartMode.inheritStdio); - expect(execution.directiveOrganization, isNull); - }); - test( 'dart_style:format in overwrite mode passes -w for dart_style <3.0.0', () { @@ -562,7 +448,7 @@ void main() { execution.formatProcess!.args, orderedEquals([ 'format', - if (dartSemverVersion.major >= 3) '--language-version=latest', + '--language-version=latest', '--fix', '--follow-links', '--indent', @@ -584,37 +470,17 @@ void main() { expect(execution.formatProcess!.executable, exe.dart); expect( execution.formatProcess!.args, - orderedEquals([ - 'format', - if (dartSemverVersion.major >= 3) '--language-version=3.0', - '.', - ]), + orderedEquals(['format', '--language-version=3.0', '.']), ); expect(execution.formatProcess!.mode, ProcessStartMode.inheritStdio); }); - test('and logs the test subprocess by default', () { - expect( - Logger.root.onRecord, - emitsThrough(infoLogOf(contains('${exe.dartfmt} .'))), - ); - - buildExecution(DevToolExecutionContext()); - }); - test('and logs the test subprocess for dart format', () { expect( Logger.root.onRecord, emitsThrough( infoLogOf( - contains( - [ - exe.dart, - 'format', - if (dartSemverVersion.major >= 3) '--language-version=latest', - '.', - ].join(' '), - ), + contains('dart format --language-version=latest .'), ), ), ); @@ -652,12 +518,6 @@ void main() { }); group('buildFormatProcess', () { - test('dartfmt', () { - final process = buildFormatProcess(Formatter.dartfmt); - expect(process.executable, exe.dartfmt); - expect(process.args, isEmpty); - }); - test('dart format', () { final process = buildFormatProcess(Formatter.dartFormat); expect(process.executable, exe.dart); @@ -671,9 +531,9 @@ void main() { }); test('default', () { - final process = buildFormatProcess(Formatter.dartfmt); - expect(process.executable, exe.dartfmt); - expect(process.args, isEmpty); + final process = buildFormatProcess(); + expect(process.executable, exe.dart); + expect(process.args, orderedEquals(['format'])); }); }); @@ -681,26 +541,26 @@ void main() { test('<=5 inputs and verbose=false', () async { expect( Logger.root.onRecord, - emitsThrough(infoLogOf(contains('dartfmt -x -y a b'))), + emitsThrough(infoLogOf(contains('dart -x -y a b'))), ); - logCommand('dartfmt', ['a', 'b'], ['-x', '-y']); + logCommand('dart', ['a', 'b'], ['-x', '-y']); }); test('>5 inputs and verbose=true', () async { expect( Logger.root.onRecord, - emitsThrough(infoLogOf(contains('dartfmt -x -y <6 paths>'))), + emitsThrough(infoLogOf(contains('dart -x -y <6 paths>'))), ); - logCommand('dartfmt', ['a', 'b', 'c', 'd', 'e', 'f'], ['-x', '-y']); + logCommand('dart', ['a', 'b', 'c', 'd', 'e', 'f'], ['-x', '-y']); }); test('>5 inputs and verbose=false', () async { expect( Logger.root.onRecord, - emitsThrough(infoLogOf(contains('dartfmt -x -y a b c d e f'))), + emitsThrough(infoLogOf(contains('dart -x -y a b c d e f'))), ); logCommand( - 'dartfmt', + 'dart', ['a', 'b', 'c', 'd', 'e', 'f'], ['-x', '-y'], verbose: true, diff --git a/test/tools/webdev_serve_tool_test.dart b/test/tools/webdev_serve_tool_test.dart index 1f8c00d1..e9db476c 100644 --- a/test/tools/webdev_serve_tool_test.dart +++ b/test/tools/webdev_serve_tool_test.dart @@ -3,7 +3,6 @@ import 'package:args/args.dart'; import 'package:args/command_runner.dart'; import 'package:dart_dev/src/dart_dev_tool.dart'; import 'package:dart_dev/src/tools/webdev_serve_tool.dart'; -import 'package:dart_dev/src/utils/dart_semver_version.dart'; import 'package:dart_dev/src/utils/executables.dart' as exe; import 'package:io/ansi.dart'; import 'package:io/io.dart'; @@ -169,7 +168,7 @@ void main() { pubCacheWithWebdev = TempPubCache(); globalActivate( 'webdev', - '^${dartSemverVersion.major}.0.0', + '^3.0.0', environment: pubCacheWithWebdev.envOverride, ); @@ -226,7 +225,7 @@ void main() { allOf( contains('webdev serve could not run'), contains( - 'dart pub global activate webdev ^${dartSemverVersion.major}.0.0', + 'dart pub global activate webdev ^3.0.0', ), ), ), diff --git a/test/utils/format_tool_builder_test.dart b/test/utils/format_tool_builder_test.dart index 598f9c83..4859bb2f 100644 --- a/test/utils/format_tool_builder_test.dart +++ b/test/utils/format_tool_builder_test.dart @@ -45,7 +45,7 @@ void main() { group('when the tool is a CascadeExpression', () { group('detects formatter correctly for:', () { - test('darfmt', () { + test('dartfmt maps to dartFormat', () { final visitor = FormatToolBuilder(); parseString(content: formatToolCascadeSrc()).unit.accept(visitor); @@ -54,7 +54,7 @@ void main() { expect(visitor.formatDevTool, isA()); expect( (visitor.formatDevTool as FormatTool).formatter, - Formatter.dartfmt, + Formatter.dartFormat, ); }); @@ -180,7 +180,7 @@ import 'package:glob/glob.dart'; final config = { ...coreConfig, 'format': UnknownTool() - ..formatter = Formatter.dartfmt + ..formatter = Formatter.dartFormat ..formatterArgs = ['-l', '120'], }; '''; diff --git a/test/utils/get_dart_version_comment_test.dart b/test/utils/get_dart_version_comment_test.dart index b3d8acb5..65c71678 100644 --- a/test/utils/get_dart_version_comment_test.dart +++ b/test/utils/get_dart_version_comment_test.dart @@ -1,5 +1,4 @@ @TestOn('vm') -@Tags(['dart2']) import 'package:dart_dev/src/utils/get_dart_version_comment.dart'; import 'package:test/test.dart'; From 2e39e493c20b743fc338af217a977e83596bf2be Mon Sep 17 00:00:00 2001 From: Matthew Nitschke Date: Fri, 7 Aug 2026 08:27:42 -0600 Subject: [PATCH 2/3] removed direct dep on dep validator --- .github/workflows/ci.yml | 4 +++- pubspec.yaml | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48f86476..5be52fcd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,9 @@ jobs: - name: Install dependencies run: dart pub get - name: Validate dependencies - run: dart run dependency_validator + run: | + dart pub global activate dependency_validator + dart pub global run dependency_validator - name: Analysis run: dart run dart_dev analyze - name: Formatting diff --git a/pubspec.yaml b/pubspec.yaml index 68c67c93..fc523149 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,7 +10,7 @@ environment: sdk: '>=3.0.0 <4.0.0' dependencies: - analyzer: ">=5.0.0 <11.0.0" + analyzer: ">=10.0.0 <15.0.0" args: ^2.0.0 async: ^2.5.0 crypto: ^3.0.1 @@ -26,7 +26,6 @@ dependencies: dev_dependencies: build_runner: ^2.0.0 - dependency_validator: ">=4.0.0 <6.0.0" lints: ">=2.0.0 <7.0.0" matcher: ^0.12.5 test: ^1.15.7 From ef1b1e00326d34ed7fce4516ce6ba500f8adcafb Mon Sep 17 00:00:00 2001 From: Matthew Nitschke Date: Fri, 7 Aug 2026 08:30:00 -0600 Subject: [PATCH 3/3] fmt + sdk for sbom --- .github/workflows/ci.yml | 4 +++- lib/src/tools/format_tool.dart | 4 +++- test/tools/format_tool_test.dart | 4 +--- test/tools/webdev_serve_tool_test.dart | 4 +--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5be52fcd..be194cc0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,8 @@ permissions: jobs: build: uses: Workiva/gha-dart-oss/.github/workflows/build.yaml@v0.1.14 + with: + sdk: 3.12.2 dart: strategy: @@ -25,7 +27,7 @@ jobs: name: Dart ${{ matrix.sdk }} on ${{ matrix.os }} runs-on: ${{ matrix.os }}-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - uses: dart-lang/setup-dart@v1 with: sdk: ${{ matrix.sdk }} diff --git a/lib/src/tools/format_tool.dart b/lib/src/tools/format_tool.dart index 9a2a9560..4d614480 100644 --- a/lib/src/tools/format_tool.dart +++ b/lib/src/tools/format_tool.dart @@ -324,7 +324,9 @@ enum FormatMode { /// Available dart formatters. enum Formatter { - @Deprecated('Use Formatter.dartFormat instead. dartfmt was removed in Dart 2.15.') + @Deprecated( + 'Use Formatter.dartFormat instead. dartfmt was removed in Dart 2.15.', + ) dartfmt, // The formatter provided via the `dart_style` package. dartStyle, diff --git a/test/tools/format_tool_test.dart b/test/tools/format_tool_test.dart index 6806e19d..9fa71209 100644 --- a/test/tools/format_tool_test.dart +++ b/test/tools/format_tool_test.dart @@ -479,9 +479,7 @@ void main() { expect( Logger.root.onRecord, emitsThrough( - infoLogOf( - contains('dart format --language-version=latest .'), - ), + infoLogOf(contains('dart format --language-version=latest .')), ), ); diff --git a/test/tools/webdev_serve_tool_test.dart b/test/tools/webdev_serve_tool_test.dart index e9db476c..ef6a8f7f 100644 --- a/test/tools/webdev_serve_tool_test.dart +++ b/test/tools/webdev_serve_tool_test.dart @@ -224,9 +224,7 @@ void main() { severeLogOf( allOf( contains('webdev serve could not run'), - contains( - 'dart pub global activate webdev ^3.0.0', - ), + contains('dart pub global activate webdev ^3.0.0'), ), ), ),