Merge pull request dart-lang/io#77 from dart-lang/darttool
Update example to use unified `dart` tool
diff --git a/pkgs/io/CHANGELOG.md b/pkgs/io/CHANGELOG.md
index 1e86f5a..38c0314 100644
--- a/pkgs/io/CHANGELOG.md
+++ b/pkgs/io/CHANGELOG.md
@@ -1,4 +1,6 @@
-## 1.0.1-dev
+## 1.0.1
+
+* Update code examples to call the unified `dart` developer tool.
## 1.0.0
diff --git a/pkgs/io/README.md b/pkgs/io/README.md
index 4ed2e2d..a73e4aa 100644
--- a/pkgs/io/README.md
+++ b/pkgs/io/README.md
@@ -25,25 +25,25 @@
##### Use `spawn` to create a process with std[in|out|err] forwarded by default
```dart
-/// Runs `dartfmt` commands and `pub publish`.
Future<void> main() async {
final manager = ProcessManager();
- // Runs dartfmt --version and outputs the result via stdout.
- print('Running dartfmt --version');
- var spawn = await manager.spawn('dartfmt', ['--version']);
+ // Print `dart` tool version to stdout.
+ print('** Running `dart --version`');
+ var spawn = await manager.spawn('dart', ['--version']);
await spawn.exitCode;
- // Runs dartfmt -n . and outputs the result via stdout.
- print('Running dartfmt -n .');
- spawn = await manager.spawn('dartfmt', ['-n', '.']);
+ // Check formatting and print the result to stdout.
+ print('** Running `dart format --output=none .`');
+ spawn = await manager.spawn('dart', ['format', '--output=none', '.']);
await spawn.exitCode;
- // Runs pub publish. Upon hitting a blocking stdin state, you may directly
+ // Check if a package is ready for publishing.
+ // Upon hitting a blocking stdin state, you may directly
// output to the processes's stdin via your own, similar to how a bash or
// shell script would spawn a process.
- print('Running pub publish');
- spawn = await manager.spawn('pub', ['publish']);
+ print('** Running pub publish');
+ spawn = await manager.spawn('dart', ['pub', 'publish', '--dry-run']);
await spawn.exitCode;
// Closes stdin for the entire program.
diff --git a/pkgs/io/analysis_options.yaml b/pkgs/io/analysis_options.yaml
index 963fe81..9b21854 100644
--- a/pkgs/io/analysis_options.yaml
+++ b/pkgs/io/analysis_options.yaml
@@ -1,4 +1,4 @@
-include: package:pedantic/analysis_options.yaml
+include: package:lints/recommended.yaml
analyzer:
strong-mode:
@@ -9,94 +9,7 @@
linter:
rules:
- - always_put_required_named_parameters_first
- - avoid_annotating_with_dynamic
- - avoid_bool_literals_in_conditional_expressions
- - avoid_catches_without_on_clauses
- - avoid_catching_errors
- - avoid_classes_with_only_static_members
- - avoid_double_and_int_checks
- - avoid_dynamic_calls
- - avoid_field_initializers_in_const_classes
- - avoid_function_literals_in_foreach_calls
- - avoid_implementing_value_types
- - avoid_js_rounded_ints
- - avoid_private_typedef_functions
- - avoid_redundant_argument_values
- - avoid_renaming_method_parameters
- - avoid_returning_null_for_future
- - avoid_returning_null_for_void
- - avoid_returning_this
- - avoid_setters_without_getters
- - avoid_single_cascade_in_expression_statements
- - avoid_slow_async_io
- - avoid_types_on_closure_parameters
- - avoid_unused_constructor_parameters
- - avoid_void_async
- - await_only_futures
- - camel_case_types
- - cancel_subscriptions
- - cascade_invocations
- - close_sinks
- - comment_references
- - constant_identifier_names
- - control_flow_in_finally
- - directives_ordering
- - empty_statements
- - file_names
- - hash_and_equals
- - implementation_imports
- - invariant_booleans
- - iterable_contains_unrelated_type
- - join_return_with_assignment
- - lines_longer_than_80_chars
- - list_remove_unrelated_type
- - literal_only_boolean_expressions
- - missing_whitespace_between_adjacent_strings
- - no_adjacent_strings_in_list
- - no_runtimeType_toString
- - non_constant_identifier_names
- - one_member_abstracts
- - only_throw_errors
- - overridden_fields
- - package_api_docs
- - package_names
- - package_prefixed_library_names
- - prefer_asserts_in_initializer_lists
- - prefer_const_constructors
- - prefer_const_constructors_in_immutables
- - prefer_const_declarations
- - prefer_const_literals_to_create_immutables
- - prefer_expression_function_bodies
- - prefer_final_locals
- - prefer_foreach
- - prefer_function_declarations_over_variables
- - prefer_initializing_formals
- - prefer_inlined_adds
- - prefer_int_literals
- - prefer_interpolation_to_compose_strings
- - prefer_is_not_operator
- - prefer_mixin
- - prefer_null_aware_operators
- - prefer_relative_imports
- - prefer_typing_uninitialized_variables
- - prefer_void_to_null
- - provide_deprecation_message
- - sort_pub_dependencies
- - test_types_in_equals
- - throw_in_finally
- - type_annotate_public_apis
- - unnecessary_await_in_return
- - unnecessary_brace_in_string_interps
- - unnecessary_getters_setters
- - unnecessary_lambdas
- - unnecessary_null_aware_assignments
- - unnecessary_overrides
- - unnecessary_parenthesis
- - unnecessary_statements
- - unnecessary_string_interpolations
- - use_is_even_rather_than_modulo
- - use_setters_to_change_properties
- - use_string_buffers
- - use_to_and_as_if_applicable
- - void_checks
+ - always_declare_return_types
+ - omit_local_variable_types
+ - prefer_single_quotes
+ - unawaited_futures
diff --git a/pkgs/io/example/spawn_process_example.dart b/pkgs/io/example/spawn_process_example.dart
index 5918057..50f6de9 100644
--- a/pkgs/io/example/spawn_process_example.dart
+++ b/pkgs/io/example/spawn_process_example.dart
@@ -6,25 +6,26 @@
import 'package:io/io.dart';
-/// Runs `dartfmt` commands and `pub publish`.
+/// Runs a few subcommands in the `dart` command.
Future<void> main() async {
final manager = ProcessManager();
- // Runs dartfmt --version and outputs the result via stdout.
- print('Running dartfmt --version');
- var spawn = await manager.spawn('dartfmt', ['--version']);
+ // Print `dart` tool version to stdout.
+ print('** Running `dart --version`');
+ var spawn = await manager.spawn('dart', ['--version']);
await spawn.exitCode;
- // Runs dartfmt -n . and outputs the result via stdout.
- print('Running dartfmt -n .');
- spawn = await manager.spawn('dartfmt', ['-n', '.']);
+ // Check formatting and print the result to stdout.
+ print('** Running `dart format --output=none .`');
+ spawn = await manager.spawn('dart', ['format', '--output=none', '.']);
await spawn.exitCode;
- // Runs pub publish. Upon hitting a blocking stdin state, you may directly
+ // Check if a package is ready for publishing.
+ // Upon hitting a blocking stdin state, you may directly
// output to the processes's stdin via your own, similar to how a bash or
// shell script would spawn a process.
- print('Running pub publish');
- spawn = await manager.spawn('pub', ['publish']);
+ print('** Running pub publish');
+ spawn = await manager.spawn('dart', ['pub', 'publish', '--dry-run']);
await spawn.exitCode;
// Closes stdin for the entire program.
diff --git a/pkgs/io/lib/src/ansi_code.dart b/pkgs/io/lib/src/ansi_code.dart
index ff7583a..86a77a3 100644
--- a/pkgs/io/lib/src/ansi_code.dart
+++ b/pkgs/io/lib/src/ansi_code.dart
@@ -147,6 +147,9 @@
case AnsiCodeType.reset:
throw ArgumentError.value(
codes, 'codes', 'Cannot contain reset codes.');
+ case AnsiCodeType.style:
+ // Ignore.
+ break;
}
}
diff --git a/pkgs/io/pubspec.yaml b/pkgs/io/pubspec.yaml
index b2963b8..57e077b 100644
--- a/pkgs/io/pubspec.yaml
+++ b/pkgs/io/pubspec.yaml
@@ -2,7 +2,7 @@
description: >-
Utilities for the Dart VM Runtime including support for ANSI colors,
file copying, and standard exit code values.
-version: 1.0.1-dev
+version: 1.0.1
repository: https://github.com/dart-lang/io
environment:
@@ -14,6 +14,6 @@
string_scanner: ^1.1.0
dev_dependencies:
- pedantic: ^1.10.0
+ lints: ^1.0.0
test: ^1.16.0
test_descriptor: ^2.0.0