Skip to content

Commit 23c8203

Browse files
committed
Migrate to new commands for Dart 2.10+
1 parent 598ad1f commit 23c8203

19 files changed

+239
-240
lines changed

.github/workflows/dart.yml

Lines changed: 63 additions & 63 deletions
Large diffs are not rendered by default.

.travis.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ language: dart
44
jobs:
55
include:
66
- stage: smoke_test
7-
name: "Dart dev; PKGS: mono_repo, test_pkg; `dartfmt -n --set-exit-if-changed .`, `dartanalyzer --fatal-infos .`"
7+
name: "Dart dev; PKGS: mono_repo, test_pkg; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`"
88
dart: dev
99
os: linux
1010
env: PKGS="mono_repo test_pkg"
@@ -16,85 +16,85 @@ jobs:
1616
env: PKGS="mono_repo"
1717
script: tool/ci.sh command
1818
- stage: smoke_test
19-
name: "Dart 2.12.0; PKG: mono_repo; `dartanalyzer .`"
19+
name: "Dart 2.12.0; PKG: mono_repo; `dart analyze`"
2020
dart: "2.12.0"
2121
os: linux
2222
env: PKGS="mono_repo"
2323
script: tool/ci.sh dartanalyzer_1
2424
- stage: smoke_test
25-
name: "Dart 2.10.4; PKG: test_pkg; `dartfmt -n --set-exit-if-changed .`, `dartanalyzer --fatal-infos .`"
25+
name: "Dart 2.10.4; PKG: test_pkg; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`"
2626
dart: "2.10.4"
2727
os: linux
2828
env: PKGS="test_pkg"
2929
script: tool/ci.sh dartfmt dartanalyzer_0
3030
- stage: smoke_test
31-
name: "Dart 2.12.0-259.0.dev; PKG: test_pkg; `dartfmt -n --set-exit-if-changed .`, `dartanalyzer --fatal-infos .`"
31+
name: "Dart 2.12.0-259.0.dev; PKG: test_pkg; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`"
3232
dart: "2.12.0-259.0.dev"
3333
os: linux
3434
env: PKGS="test_pkg"
3535
script: tool/ci.sh dartfmt dartanalyzer_0
3636
- stage: smoke_test
37-
name: "Dart 2.12.0-29.10.beta; PKG: test_pkg; `dartfmt -n --set-exit-if-changed .`, `dartanalyzer --fatal-infos .`"
37+
name: "Dart 2.12.0-29.10.beta; PKG: test_pkg; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`"
3838
dart: "2.12.0-29.10.beta"
3939
os: linux
4040
env: PKGS="test_pkg"
4141
script: tool/ci.sh dartfmt dartanalyzer_0
4242
- stage: smoke_test
43-
name: "Dart main; PKG: test_pkg; `dartfmt -n --set-exit-if-changed .`, `dartanalyzer --fatal-infos .`"
43+
name: "Dart main; PKG: test_pkg; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`"
4444
dart: be/raw/latest
4545
os: linux
4646
env: PKGS="test_pkg"
4747
script: tool/ci.sh dartfmt dartanalyzer_0
4848
- stage: smoke_test
49-
name: "Dart beta; PKG: test_pkg; `dartfmt -n --set-exit-if-changed .`, `dartanalyzer --fatal-infos .`"
49+
name: "Dart beta; PKG: test_pkg; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`"
5050
dart: beta
5151
os: linux
5252
env: PKGS="test_pkg"
5353
script: tool/ci.sh dartfmt dartanalyzer_0
5454
- stage: smoke_test
55-
name: "Dart stable; PKG: test_pkg; `dartfmt -n --set-exit-if-changed .`, `dartanalyzer --fatal-infos .`"
55+
name: "Dart stable; PKG: test_pkg; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`"
5656
dart: stable
5757
os: linux
5858
env: PKGS="test_pkg"
5959
script: tool/ci.sh dartfmt dartanalyzer_0
6060
- stage: unit_test
61-
name: "Dart 2.12.0; PKG: mono_repo; `pub run test -x yaml -P presubmit --test-randomize-ordering-seed=random`"
61+
name: "Dart 2.12.0; PKG: mono_repo; `dart test -x yaml -P presubmit --test-randomize-ordering-seed=random`"
6262
dart: "2.12.0"
6363
os: linux
6464
env: PKGS="mono_repo"
6565
script: tool/ci.sh test_0
6666
- stage: unit_test
67-
name: "Dart 2.12.0; PKG: mono_repo; `pub run test -x yaml -P presubmit --test-randomize-ordering-seed=random`"
67+
name: "Dart 2.12.0; PKG: mono_repo; `dart test -x yaml -P presubmit --test-randomize-ordering-seed=random`"
6868
dart: "2.12.0"
6969
os: windows
7070
env: PKGS="mono_repo"
7171
script: tool/ci.sh test_0
7272
- stage: unit_test
73-
name: "Dart dev; PKG: mono_repo; `pub run test -x yaml -P presubmit --test-randomize-ordering-seed=random`"
73+
name: "Dart dev; PKG: mono_repo; `dart test -x yaml -P presubmit --test-randomize-ordering-seed=random`"
7474
dart: dev
7575
os: linux
7676
env: PKGS="mono_repo"
7777
script: tool/ci.sh test_0
7878
- stage: unit_test
79-
name: "Dart dev; PKG: mono_repo; `pub run test -x yaml -P presubmit --test-randomize-ordering-seed=random`"
79+
name: "Dart dev; PKG: mono_repo; `dart test -x yaml -P presubmit --test-randomize-ordering-seed=random`"
8080
dart: dev
8181
os: windows
8282
env: PKGS="mono_repo"
8383
script: tool/ci.sh test_0
8484
- stage: unit_test
85-
name: "Dart 2.12.0; PKG: mono_repo; `pub run test -t yaml --test-randomize-ordering-seed=random`"
85+
name: "Dart 2.12.0; PKG: mono_repo; `dart test -t yaml --test-randomize-ordering-seed=random`"
8686
dart: "2.12.0"
8787
os: linux
8888
env: PKGS="mono_repo"
8989
script: tool/ci.sh test_1
9090
- stage: unit_test
91-
name: "Dart dev; PKG: mono_repo; `pub run test -t yaml --test-randomize-ordering-seed=random`"
91+
name: "Dart dev; PKG: mono_repo; `dart test -t yaml --test-randomize-ordering-seed=random`"
9292
dart: dev
9393
os: linux
9494
env: PKGS="mono_repo"
9595
script: tool/ci.sh test_1
9696
- stage: unit_test
97-
name: "Dart dev; PKG: test_pkg; `pub run test --test-randomize-ordering-seed=random`"
97+
name: "Dart dev; PKG: test_pkg; `dart test --test-randomize-ordering-seed=random`"
9898
dart: dev
9999
os: linux
100100
env: PKGS="test_pkg"

mono_repo/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Drop `--no-precompile` as the default for `pub` `get` and `upgrade` commands.
55
It's now the default across Dart tools.
66
- Use latest `actions/cache@v2.1.6`.
7+
- Migrate to new command pattern supported in Dart 2.10+
78

89
## 4.0.0
910

mono_repo/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Available commands:
3535
check Check the state of the repository.
3636
generate Generates the CI configuration for child packages.
3737
presubmit Run the CI presubmits locally.
38-
pub Run `pub get` or `pub upgrade` against all packages.
38+
pub Run `dart pub get` or `dart pub upgrade` against all packages.
3939
travis (Deprecated, use `generate`) Configure Travis-CI for child packages.
4040
4141
Run "mono_repo help <command>" for more information about a command.

mono_repo/lib/src/ci_shared.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ String get _pkgVersion => _isTesting ? '1.2.3' : packageVersion;
3535
const selfValidateJobName = 'mono_repo self validate';
3636

3737
final selfValidateCommands = [
38-
'pub global activate mono_repo $_pkgVersion',
39-
'pub global run mono_repo generate --validate',
38+
'dart pub global activate mono_repo $_pkgVersion',
39+
'dart pub global run mono_repo generate --validate',
4040
];
4141

4242
class CIJobEntry {

mono_repo/lib/src/ci_test_script.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function $commandName() {
3131
if [[ \$TRAVIS_OS_NAME == "windows" ]]; then
3232
command pub.bat "\$@"
3333
else
34-
command pub "\$@"
34+
command dart pub "\$@"
3535
fi
3636
fi
3737
}''';
@@ -76,11 +76,11 @@ for PKG in \${PKGS}; do
7676
exit 64
7777
fi
7878
79-
pub $pubDependencyCommand || EXIT_CODE=\$?
79+
dart pub $pubDependencyCommand || EXIT_CODE=\$?
8080
8181
if [[ \${EXIT_CODE} -ne 0 ]]; then
82-
${echoWithEvaluation(prettyAnsi, red, "PKG: \${PKG}; 'pub $pubDependencyCommand' - FAILED (\${EXIT_CODE})")}
83-
FAILURES+=("\${PKG}; 'pub $pubDependencyCommand'")
82+
${echoWithEvaluation(prettyAnsi, red, "PKG: \${PKG}; 'dart pub $pubDependencyCommand' - FAILED (\${EXIT_CODE})")}
83+
FAILURES+=("\${PKG}; 'dart pub $pubDependencyCommand'")
8484
else
8585
for TASK in "\$@"; do
8686
EXIT_CODE=0

mono_repo/lib/src/commands/pub.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class PubCommand extends Command<void> {
2323

2424
@override
2525
String get description =>
26-
'Run `pub get` or `pub upgrade` against all packages.';
26+
'Run `dart pub get` or `dart pub upgrade` against all packages.';
2727
}
2828

2929
const _offline = 'offline';
@@ -53,7 +53,7 @@ class _PubSubCommand extends MonoRepoCommand {
5353
}
5454

5555
@override
56-
String get description => 'Run `pub $name` against all packages.';
56+
String get description => 'Run `dart pub $name` against all packages.';
5757

5858
@override
5959
Future<void> run() => pub(
@@ -89,8 +89,12 @@ Future<void> pub(
8989
args.add('--$_precompile');
9090
}
9191

92-
print(lightBlue.wrap(
93-
'Running `pub ${args.join(' ')}` across ${pkgDirs.length} package(s).'));
92+
print(
93+
lightBlue.wrap(
94+
'Running `dart pub ${args.join(' ')}` across ${pkgDirs.length} '
95+
'package(s).',
96+
),
97+
);
9498

9599
for (var config in rootConfig) {
96100
final dir = config.relativePath;

mono_repo/lib/src/package_config.dart

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ class Task {
285285

286286
final String command;
287287

288-
Task(this.name, {this.args}) : command = _commandValue(name, args);
288+
Task(this.name, {this.args}) : command = _commandValue(name, args).join(' ');
289289

290290
/// Parses an individual item under `stages`, which might be a `group` or an
291291
/// individual task.
@@ -393,27 +393,24 @@ class Task {
393393

394394
Map<String, dynamic> toJson() => _$TaskToJson(this);
395395

396-
static String _commandValue(String name, String? args) {
396+
static List<String> _commandValue(String name, String? args) {
397397
switch (name) {
398398
case 'dartfmt':
399-
if (args == null || args == 'sdk') {
400-
return 'dartfmt -n --set-exit-if-changed .';
401-
}
402-
return 'dartfmt $args';
399+
return [
400+
'dart format',
401+
(args == null || args == 'sdk')
402+
? '--output=none --set-exit-if-changed .'
403+
: args,
404+
];
403405
case 'dartanalyzer':
404-
if (args == null) {
405-
return 'dartanalyzer .';
406-
}
407-
return 'dartanalyzer $args';
408-
406+
return ['dart analyze', if (args != null) args];
409407
case 'test':
410-
var value = 'pub run test';
411-
if (args != null) {
412-
value = '$value $args';
413-
}
414-
return value;
408+
return [
409+
'dart test',
410+
if (args != null) args,
411+
];
415412
case 'command':
416-
return args!;
413+
return [args!];
417414
default:
418415
throw UnsupportedError('Cannot generate the command for `$name`.');
419416
}

0 commit comments

Comments
 (0)