Skip to content

Commit

Permalink
feat!: upgrade minimum Dart SDK version to 2.18.0 (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
blaugold authored Dec 7, 2022
1 parent 3d857c4 commit fa81cba
Show file tree
Hide file tree
Showing 29 changed files with 134 additions and 178 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1
with:
sdk: 2.12.0 # Update when min sdk supported version of `melos` package changes.
sdk: 2.18.0 # Update when min sdk supported version of `melos` package changes.
- name: "Run Melos"
run: ./.github/workflows/scripts/install-tools.sh

Expand Down
11 changes: 9 additions & 2 deletions all_lint_rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ linter:
- cascade_invocations
- cast_nullable_to_non_nullable
- close_sinks
- collection_methods_unrelated_type
- combinators_ordering
- comment_references
- conditional_uri_does_not_exist
- constant_identifier_names
- control_flow_in_finally
- curly_braces_in_flow_control_structures
- dangling_library_doc_comments
- depend_on_referenced_packages
- deprecated_consistency
- diagnostic_describe_all_properties
Expand All @@ -84,16 +87,18 @@ linter:
- empty_catches
- empty_constructor_bodies
- empty_statements
- enable_null_safety
- eol_at_end_of_file
- exhaustive_cases
- file_names
- flutter_style_todos
- hash_and_equals
- implementation_imports
- invariant_booleans
- implicit_call_tearoffs
- iterable_contains_unrelated_type
- join_return_with_assignment
- leading_newlines_in_multiline_strings
- library_annotations
- library_names
- library_prefixes
- library_private_types_in_public_api
Expand Down Expand Up @@ -132,7 +137,6 @@ linter:
- prefer_constructors_over_static_methods
- prefer_contains
- prefer_double_quotes
- prefer_equal_for_default_values
- prefer_expression_function_bodies
- prefer_final_fields
- prefer_final_in_for_each
Expand Down Expand Up @@ -186,6 +190,7 @@ linter:
- unnecessary_getters_setters
- unnecessary_lambdas
- unnecessary_late
- unnecessary_library_directive
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_aware_operator_on_extension_on_nullable
Expand All @@ -200,6 +205,7 @@ linter:
- unnecessary_string_interpolations
- unnecessary_this
- unnecessary_to_list_in_spreads
- unreachable_from_main
- unrelated_type_equality_checks
- unsafe_html
- use_build_context_synchronously
Expand All @@ -217,6 +223,7 @@ linter:
- use_rethrow_when_possible
- use_setters_to_change_properties
- use_string_buffers
- use_string_in_part_of_directives
- use_super_parameters
- use_test_throws_matchers
- use_to_and_as_if_applicable
Expand Down
2 changes: 0 additions & 2 deletions docs/configuration/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ Configuration for the `bootstrap` command.
Whether to use `pubspec_overrides.yaml` for overriding workspace dependencies
during development.

Enabling this option requires Dart **2.17.0** or greater.

When this option is enabled, Melos will generate a `pubspec_overrides.yaml` file
in the root of every package during bootstrapping. This file should not be
tracked in version control and should be added to `.gitignore`.
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ packages:
The `packages` list should contain paths to the individual packages within your project. Each path
can be defined using the [glob](https://docs.python.org/3/library/glob.html) pattern expansion format.

Consider setting `usePubspecOverrides` to `true`, if you are using Dart 2.17.0 or greater:
Consider setting `usePubspecOverrides` to `true`:

```yaml
command:
Expand Down
2 changes: 1 addition & 1 deletion packages/conventional_commit/lib/conventional_commit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ConventionalCommit {
final mergeCommitPrefixMatch = _mergeCommitPrefixRegex.firstMatch(header);
final isMergeCommit = mergeCommitPrefixMatch != null;
final headerMatch = _conventionalCommitHeaderRegex.firstMatch(
isMergeCommit ? header.substring(mergeCommitPrefixMatch!.end) : header,
isMergeCommit ? header.substring(mergeCommitPrefixMatch.end) : header,
);

if (headerMatch == null) {
Expand Down
2 changes: 1 addition & 1 deletion packages/conventional_commit/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository: /~https://github.com/invertase/melos/tree/main/packages/conventional_c
issue_tracker: /~https://github.com/invertase/melos/issues

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.18.0 <3.0.0'

dev_dependencies:
collection: ^1.15.0
Expand Down
3 changes: 1 addition & 2 deletions packages/melos/lib/src/command_runner/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
import 'dart:async';

import '../commands/runner.dart';
import '../workspace_configs.dart';
import 'base.dart';

class BootstrapCommand extends MelosCommand {
BootstrapCommand(MelosWorkspaceConfig config) : super(config) {
BootstrapCommand(super.config) {
setupPackageFilterParser();
}

Expand Down
3 changes: 1 addition & 2 deletions packages/melos/lib/src/command_runner/clean.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
*/

import '../commands/runner.dart';
import '../workspace_configs.dart';
import 'base.dart';

class CleanCommand extends MelosCommand {
CleanCommand(MelosWorkspaceConfig config) : super(config) {
CleanCommand(super.config) {
setupPackageFilterParser();
}

Expand Down
3 changes: 1 addition & 2 deletions packages/melos/lib/src/command_runner/exec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
import 'dart:io';

import '../commands/runner.dart';
import '../workspace_configs.dart';
import 'base.dart';

class ExecCommand extends MelosCommand {
ExecCommand(MelosWorkspaceConfig config) : super(config) {
ExecCommand(super.config) {
setupPackageFilterParser();
argParser.addOption('concurrency', defaultsTo: '5', abbr: 'c');
argParser.addFlag(
Expand Down
3 changes: 1 addition & 2 deletions packages/melos/lib/src/command_runner/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
*/

import '../commands/runner.dart';
import '../workspace_configs.dart';
import 'base.dart';

class ListCommand extends MelosCommand {
ListCommand(MelosWorkspaceConfig config) : super(config) {
ListCommand(super.config) {
setupPackageFilterParser();
argParser.addFlag(
'long',
Expand Down
3 changes: 1 addition & 2 deletions packages/melos/lib/src/command_runner/publish.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
*/

import '../commands/runner.dart';
import '../workspace_configs.dart';
import 'base.dart';

class PublishCommand extends MelosCommand {
PublishCommand(MelosWorkspaceConfig config) : super(config) {
PublishCommand(super.config) {
setupPackageFilterParser();
argParser.addFlag(
'dry-run',
Expand Down
3 changes: 1 addition & 2 deletions packages/melos/lib/src/command_runner/run.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
*/

import '../commands/runner.dart';
import '../workspace_configs.dart';
import 'base.dart';

class RunCommand extends MelosCommand {
RunCommand(MelosWorkspaceConfig config) : super(config) {
RunCommand(super.config) {
argParser.addFlag(
'no-select',
negatable: false,
Expand Down
5 changes: 2 additions & 3 deletions packages/melos/lib/src/command_runner/script.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ import 'base.dart';

class ScriptCommand extends MelosCommand {
ScriptCommand._(
MelosWorkspaceConfig config, {
super.config, {
required this.scripts,
}) : assert(scripts.isNotEmpty),
super(config) {
}) : assert(scripts.isNotEmpty) {
argParser.addFlag(
'no-select',
negatable: false,
Expand Down
3 changes: 1 addition & 2 deletions packages/melos/lib/src/command_runner/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import '../commands/runner.dart';
import '../common/utils.dart';
import '../common/versioning.dart';
import '../package.dart';
import '../workspace_configs.dart';
import 'base.dart';

/// Template variable that is replaced with versioned package info in commit
Expand All @@ -38,7 +37,7 @@ const defaultCommitMessage =
'chore(release): publish packages\n\n{$packageVersionsTemplateVar}';

class VersionCommand extends MelosCommand {
VersionCommand(MelosWorkspaceConfig config) : super(config) {
VersionCommand(super.config) {
setupPackageFilterParser();
argParser.addFlag(
'prerelease',
Expand Down
19 changes: 4 additions & 15 deletions packages/melos/lib/src/commands/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ mixin _BootstrapMixin on _CleanMixin {
Future<void> _linkPackagesWithPubspecOverrides(
MelosWorkspace workspace,
) async {
if (!workspace.isPubspecOverridesSupported) {
logger.warning(
'Dart 2.17.0 or greater is required to use Melos with '
'pubspec overrides.',
);
}

final filteredPackages = workspace.filteredPackages.values;

await Stream.fromIterable(filteredPackages).parallel(
Expand Down Expand Up @@ -101,10 +94,8 @@ mixin _BootstrapMixin on _CleanMixin {

bootstrappedPackages.forEach(_logBootstrapSuccess);
},
parallelism: workspace.config.commands.bootstrap.runPubGetInParallel &&
workspace.canRunPubGetConcurrently
? null
: 1,
parallelism:
workspace.config.commands.bootstrap.runPubGetInParallel ? null : 1,
).drain<void>();
}

Expand Down Expand Up @@ -185,10 +176,8 @@ mixin _BootstrapMixin on _CleanMixin {
);
return package;
},
parallelism: workspace.config.commands.bootstrap.runPubGetInParallel &&
workspace.canRunPubGetConcurrently
? null
: 1,
parallelism:
workspace.config.commands.bootstrap.runPubGetInParallel ? null : 1,
);

Future<void> _runPubGetForPackage(
Expand Down
10 changes: 5 additions & 5 deletions packages/melos/lib/src/common/git_commit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ GitCommit[

class RichGitCommit extends GitCommit {
RichGitCommit({
required String author,
required String id,
required DateTime date,
required String message,
required super.author,
required super.id,
required super.date,
required super.message,
required this.parsedMessage,
}) : super(author: author, id: id, date: date, message: message);
});

static RichGitCommit? tryParse(GitCommit commit) {
final parsedMessage = ConventionalCommit.tryParse(commit.message);
Expand Down
4 changes: 2 additions & 2 deletions packages/melos/lib/src/common/git_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ GitLabRepository(
}

final _hostsToUrlParser = {
'GitHub': (Uri url) => GitHubRepository.fromUrl(url),
'GitLab': (Uri url) => GitLabRepository.fromUrl(url),
'GitHub': GitHubRepository.fromUrl,
'GitLab': GitLabRepository.fromUrl,
};

final _hostsToSpecParser = {
Expand Down
4 changes: 2 additions & 2 deletions packages/melos/lib/src/common/pub_dependency_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import 'package:string_scanner/string_scanner.dart';

class PubDependencyList extends VersionedEntry {
PubDependencyList._(
VersionedEntry entry,
super.entry,
this.sdks,
this.sections,
) : super.copy(entry);
) : super.copy();

factory PubDependencyList.parse(String input) {
final scanner = StringScanner(input);
Expand Down
11 changes: 0 additions & 11 deletions packages/melos/lib/src/common/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,6 @@ Version currentDartVersion(String dartTool) {
return Version.parse(versionString);
}

String nextDartMajorVersion([String dartTool = 'dart']) {
return currentDartVersion(dartTool).nextMajor.toString();
}

bool isPubspecOverridesSupported([String dartTool = 'dart']) =>
currentDartVersion(dartTool).compareTo(Version.parse('2.17.0-266.0.dev')) >=
0;

bool canRunPubGetConcurrently([String dartTool = 'dart']) =>
currentDartVersion(dartTool).compareTo(Version.parse('2.16.0')) >= 0;

T _promptWithTerminal<T>(
T Function() runPrompt, {
required String message,
Expand Down
12 changes: 6 additions & 6 deletions packages/melos/lib/src/package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1267,20 +1267,20 @@ Map<String, Package> _transitivelyRelatedPackages({
}

extension on PubSpec {
Flutter? get flutter => (unParsedYaml?['flutter'] as Map<Object?, Object?>?)
.let((value) => Flutter(value));
Flutter? get flutter =>
(unParsedYaml?['flutter'] as Map<Object?, Object?>?).let(Flutter.new);
}

class Flutter {
Flutter(this._flutter);

final Map<Object?, Object?> _flutter;

Plugin? get plugin => (_flutter['plugin'] as Map<Object?, Object?>?)
.let((value) => Plugin(value));
Plugin? get plugin =>
(_flutter['plugin'] as Map<Object?, Object?>?).let(Plugin.new);

Module? get module => (_flutter['module'] as Map<Object?, Object?>?)
.let((value) => Module(value));
Module? get module =>
(_flutter['module'] as Map<Object?, Object?>?).let(Module.new);
}

class Module {
Expand Down
2 changes: 1 addition & 1 deletion packages/melos/lib/src/scripts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class LifecycleHook {
}

class Scripts extends MapView<String, Script> {
const Scripts(Map<String, Script> map) : super(map);
const Scripts(super.map);

factory Scripts.fromYaml(
Map<Object?, Object?> yaml, {
Expand Down
6 changes: 0 additions & 6 deletions packages/melos/lib/src/workspace.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ class MelosWorkspace {
return tool;
}

late final bool canRunPubGetConcurrently =
utils.canRunPubGetConcurrently(sdkTool('dart'));

late final bool isPubspecOverridesSupported =
utils.isPubspecOverridesSupported(sdkTool('dart'));

/// Returns a string path to the 'melos_tool' directory in this workspace.
///
/// This directory should be git ignored and is used by Melos for temporary
Expand Down
8 changes: 4 additions & 4 deletions packages/melos/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ repository: /~https://github.com/invertase/melos/tree/main/packages/melos
issue_tracker: /~https://github.com/invertase/melos/issues

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.18.0 <3.0.0'

executables:
melos:

dependencies:
ansi_styles: ^0.3.1
Expand Down Expand Up @@ -37,6 +40,3 @@ dependencies:
dev_dependencies:
mockito: ^5.1.0
test: ^1.17.5

executables:
melos:
Loading

0 comments on commit fa81cba

Please sign in to comment.