From ca37bc7ae07c62c441a4224418038d1bcc4eb6ac Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 16 Mar 2018 13:09:36 -0700 Subject: [PATCH 1/8] Reorganized package, put example it it's own directory, etc --- .gitignore | 9 +-- .../example => example}/lib/app_component.css | 0 .../lib/app_component.dart | 0 .../lib/app_component.html | 0 .../lib/src/hello_world/hello_world.css | 0 .../lib/src/hello_world/hello_world.dart | 0 example/lib/src/hello_world/hello_world.html | 1 + example/pubspec.yaml | 12 ++++ {webdev/example => example}/web/index.html | 3 +- example/web/main.dart | 9 +++ {webdev/example => example}/web/styles.css | 0 webdev/bin/webdev.dart | 2 +- .../lib/src/hello_world/hello_world.html | 1 - webdev/example/pubspec.yaml | 25 ------- webdev/example/web/main.dart | 7 -- webdev/lib/src/command/build_command.dart | 11 +-- .../command/build_runner_command_base.dart | 70 ++++++++++++++++--- webdev/lib/src/command/serve_command.dart | 16 ++--- webdev/lib/webdev.dart | 1 - webdev/pubspec.yaml | 12 ++-- 20 files changed, 99 insertions(+), 80 deletions(-) rename {webdev/example => example}/lib/app_component.css (100%) rename {webdev/example => example}/lib/app_component.dart (100%) rename {webdev/example => example}/lib/app_component.html (100%) rename {webdev/example => example}/lib/src/hello_world/hello_world.css (100%) rename {webdev/example => example}/lib/src/hello_world/hello_world.dart (100%) create mode 100644 example/lib/src/hello_world/hello_world.html create mode 100644 example/pubspec.yaml rename {webdev/example => example}/web/index.html (68%) create mode 100644 example/web/main.dart rename {webdev/example => example}/web/styles.css (100%) delete mode 100644 webdev/example/lib/src/hello_world/hello_world.html delete mode 100644 webdev/example/pubspec.yaml delete mode 100644 webdev/example/web/main.dart delete mode 100644 webdev/lib/webdev.dart diff --git a/.gitignore b/.gitignore index 26e9525be..79f51c3d5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,3 @@ -packages -/*/build/ -.pub/ -pubspec.lock - -# Files generated by dart tools .dart_tool -doc/ +.packages +pubspec.lock diff --git a/webdev/example/lib/app_component.css b/example/lib/app_component.css similarity index 100% rename from webdev/example/lib/app_component.css rename to example/lib/app_component.css diff --git a/webdev/example/lib/app_component.dart b/example/lib/app_component.dart similarity index 100% rename from webdev/example/lib/app_component.dart rename to example/lib/app_component.dart diff --git a/webdev/example/lib/app_component.html b/example/lib/app_component.html similarity index 100% rename from webdev/example/lib/app_component.html rename to example/lib/app_component.html diff --git a/webdev/example/lib/src/hello_world/hello_world.css b/example/lib/src/hello_world/hello_world.css similarity index 100% rename from webdev/example/lib/src/hello_world/hello_world.css rename to example/lib/src/hello_world/hello_world.css diff --git a/webdev/example/lib/src/hello_world/hello_world.dart b/example/lib/src/hello_world/hello_world.dart similarity index 100% rename from webdev/example/lib/src/hello_world/hello_world.dart rename to example/lib/src/hello_world/hello_world.dart diff --git a/example/lib/src/hello_world/hello_world.html b/example/lib/src/hello_world/hello_world.html new file mode 100644 index 000000000..88990aa19 --- /dev/null +++ b/example/lib/src/hello_world/hello_world.html @@ -0,0 +1 @@ +
Hello World
diff --git a/example/pubspec.yaml b/example/pubspec.yaml new file mode 100644 index 000000000..4532d19b6 --- /dev/null +++ b/example/pubspec.yaml @@ -0,0 +1,12 @@ +name: webdev_example_app +description: A web app example for webdev CLI. + +environment: + sdk: ">=2.0.0-dev.32.0 <2.0.0" + +dependencies: + angular: ^5.0.0-alpha+3 + +dev_dependencies: + build_runner: ^0.8.0 + build_web_compilers: ^0.3.4 diff --git a/webdev/example/web/index.html b/example/web/index.html similarity index 68% rename from webdev/example/web/index.html rename to example/web/index.html index c7fe29810..0799eec25 100644 --- a/webdev/example/web/index.html +++ b/example/web/index.html @@ -4,8 +4,7 @@ webdev example - - + diff --git a/example/web/main.dart b/example/web/main.dart new file mode 100644 index 000000000..7dda58045 --- /dev/null +++ b/example/web/main.dart @@ -0,0 +1,9 @@ +import 'package:angular/experimental.dart'; + +// ignore: uri_has_not_been_generated +import 'package:webdev_example_app/app_component.template.dart' as ng; + +main() { + // ignore: argument_type_not_assignable + bootstrapFactory(ng.AppComponentNgFactory); +} diff --git a/webdev/example/web/styles.css b/example/web/styles.css similarity index 100% rename from webdev/example/web/styles.css rename to example/web/styles.css diff --git a/webdev/bin/webdev.dart b/webdev/bin/webdev.dart index 6c28c16fa..dc2e03664 100644 --- a/webdev/bin/webdev.dart +++ b/webdev/bin/webdev.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:webdev/webdev.dart'; +import 'package:webdev/src/webdev_command_runner.dart'; Future main(List args) async { await webdevCommandRunner().run(args); diff --git a/webdev/example/lib/src/hello_world/hello_world.html b/webdev/example/lib/src/hello_world/hello_world.html deleted file mode 100644 index e5b22f94a..000000000 --- a/webdev/example/lib/src/hello_world/hello_world.html +++ /dev/null @@ -1 +0,0 @@ -
Hello World
diff --git a/webdev/example/pubspec.yaml b/webdev/example/pubspec.yaml deleted file mode 100644 index 5e4f3719d..000000000 --- a/webdev/example/pubspec.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: webdev_example_app -description: A web app example for webdev CLI. -version: 0.0.1 - -environment: - sdk: ">=2.0.0-dev.3.0 <2.0.0" - -dependencies: - angular: ^5.0.0-alpha+3 - browser: ^0.10.0 - -dev_dependencies: - webdev: - path: ../ - ############################################################################## - # Temporary until build_runner exposes a function to generate it's script. - build_runner: - git: - url: https://github.com/dart-lang/build.git - path: build_runner - ############################################################################## - -dependency_overrides: - # Necessary with angular: ^5.0.0-alpha+1 dependency. - analyzer: ^0.31.0-alpha.1 diff --git a/webdev/example/web/main.dart b/webdev/example/web/main.dart deleted file mode 100644 index 78477ff34..000000000 --- a/webdev/example/web/main.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'package:angular/angular.dart'; -import 'package:webdev_example_app/app_component.dart'; -import 'main.template.dart' as ng; - -main() { - bootstrapStatic(AppComponent, [/*providers*/], ng.initReflector); -} diff --git a/webdev/lib/src/command/build_command.dart b/webdev/lib/src/command/build_command.dart index ac1b646ca..dd2496768 100644 --- a/webdev/lib/src/command/build_command.dart +++ b/webdev/lib/src/command/build_command.dart @@ -1,6 +1,4 @@ import 'dart:async'; -import 'dart:isolate'; - import 'build_runner_command_base.dart'; /// Command to execute pub run build_runner build. @@ -12,12 +10,5 @@ class BuildCommand extends BuildRunnerCommandBase { final description = 'Run builders to build a package.'; @override - Future run() async { - final arguments = ['build']; - arguments.addAll(argResults.arguments); - var exitPort = new ReceivePort(); - await Isolate.spawnUri(await buildRunnerScript, arguments, null, - onExit: exitPort.sendPort, automaticPackageResolution: true); - await exitPort.first; - } + Future run() => runCore('build'); } diff --git a/webdev/lib/src/command/build_runner_command_base.dart b/webdev/lib/src/command/build_runner_command_base.dart index 88f2fc0eb..91ea52893 100644 --- a/webdev/lib/src/command/build_runner_command_base.dart +++ b/webdev/lib/src/command/build_runner_command_base.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'dart:io'; +import 'dart:isolate'; import 'package:args/command_runner.dart'; @@ -19,13 +20,66 @@ abstract class BuildRunnerCommandBase extends Command { help: 'Enables verbose logging.'); } - Future get buildRunnerScript async { - // TODO(nshahan) build_runner will expose this as a function call that will - // be imported to avoid running a binary in a transitive dependency with - // pub run. - final executable = 'pub'; - final arguments = ['run', 'build_runner', 'generate-build-script']; - final results = await Process.run(executable, arguments); - return new Uri.file(results.stdout.toString().trim()); + Future runCore(String command) async { + final arguments = [command]..addAll(argResults.arguments); + var exitPort = new ReceivePort(); + await Isolate.spawnUri(await _buildRunnerScript(), arguments, null, + onExit: exitPort.sendPort, automaticPackageResolution: true); + await exitPort.first; } } + +Future _buildRunnerScript() async { + var dataUri = new Uri.dataFromString(_bootstrapScript); + + var messagePort = new ReceivePort(); + var exitPort = new ReceivePort(); + var errorPort = new ReceivePort(); + + await Isolate.spawnUri(dataUri, [], messagePort.sendPort, + onExit: exitPort.sendPort, + onError: errorPort.sendPort, + errorsAreFatal: true, + packageConfig: new Uri.file('.packages')); + + var allErrorsFuture = errorPort.forEach((error) { + var errorList = error as List; + var message = errorList[0] as String; + var stack = new StackTrace.fromString(errorList[1] as String); + + stderr.writeln(message); + stderr.writeln(stack); + }); + + var items = await Future.wait([ + messagePort.toList(), + allErrorsFuture, + exitPort.first.whenComplete(() { + messagePort.close(); + errorPort.close(); + }) + ]); + + var messages = items[0] as List; + if (messages.isEmpty) { + throw new StateError('An error occurred while running booting.'); + } + + assert(messages.length == 1); + return new Uri.file(messages.single as String); +} + +const _bootstrapScript = r''' +import 'dart:io'; +import 'dart:isolate'; + +import 'package:build_runner/build_script_generate.dart'; +import 'package:path/path.dart' as p; + +void main(List args, [SendPort sendPort]) async { + var buildScript = await generateBuildScript(); + var scriptFile = new File(scriptLocation)..createSync(recursive: true); + scriptFile.writeAsStringSync(buildScript); + sendPort.send(p.absolute(scriptLocation)); +} +'''; diff --git a/webdev/lib/src/command/serve_command.dart b/webdev/lib/src/command/serve_command.dart index a8ba022b7..c2b4e5f96 100644 --- a/webdev/lib/src/command/serve_command.dart +++ b/webdev/lib/src/command/serve_command.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:isolate'; import 'build_runner_command_base.dart'; @@ -17,16 +16,13 @@ class ServeCommand extends BuildRunnerCommandBase { // build_runner might expose args for use in wrapping scripts like this one. argParser ..addOption('hostname', - defaultsTo: 'localhost', help: 'Specify the hostname to serve on.'); + help: 'Specify the hostname to serve on', defaultsTo: 'localhost') + ..addFlag('log-requests', + defaultsTo: false, + negatable: false, + help: 'Enables logging for each request to the server.'); } @override - Future run() async { - final arguments = ['serve']; - arguments.addAll(argResults.arguments); - var exitPort = new ReceivePort(); - await Isolate.spawnUri(await buildRunnerScript, arguments, null, - onExit: exitPort.sendPort, automaticPackageResolution: true); - await exitPort.first; - } + Future run() => runCore('serve'); } diff --git a/webdev/lib/webdev.dart b/webdev/lib/webdev.dart deleted file mode 100644 index 97ed18291..000000000 --- a/webdev/lib/webdev.dart +++ /dev/null @@ -1 +0,0 @@ -export 'src/webdev_command_runner.dart'; diff --git a/webdev/pubspec.yaml b/webdev/pubspec.yaml index 5796813f4..443ef325f 100644 --- a/webdev/pubspec.yaml +++ b/webdev/pubspec.yaml @@ -2,17 +2,13 @@ name: webdev description: A CLI for Dart web development. author: Dart Team homepage: https://github.com/dart-lang/webdev +version: 0.1.0-dev environment: - sdk: ">=2.0.0-dev.3.0 <2.0.0" + sdk: ">=2.0.0-dev.32.0 <2.0.0" dependencies: args: ^1.2.0 - build_runner: - git: - url: https://github.com/dart-lang/build.git - path: build_runner - build_web_compilers: ^0.1.1 -dev_dependencies: - test: "^0.12.0" +executables: + webdev: From 2a64f7a51d073e2581271b84a1dc69656bbae2f9 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sun, 18 Mar 2018 14:44:04 -0700 Subject: [PATCH 2/8] Add missing copyright headers --- example/lib/app_component.dart | 4 ++++ example/lib/src/hello_world/hello_world.dart | 4 ++++ example/web/main.dart | 4 ++++ webdev/bin/webdev.dart | 4 ++++ webdev/lib/src/command/build_command.dart | 4 ++++ webdev/lib/src/command/build_runner_command_base.dart | 4 ++++ webdev/lib/src/command/serve_command.dart | 4 ++++ webdev/lib/src/webdev_command_runner.dart | 4 ++++ 8 files changed, 32 insertions(+) diff --git a/example/lib/app_component.dart b/example/lib/app_component.dart index faf444f0c..feac3bfdb 100644 --- a/example/lib/app_component.dart +++ b/example/lib/app_component.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + import 'package:angular/angular.dart'; import 'src/hello_world/hello_world.dart'; diff --git a/example/lib/src/hello_world/hello_world.dart b/example/lib/src/hello_world/hello_world.dart index f67367f4a..a17e4f738 100644 --- a/example/lib/src/hello_world/hello_world.dart +++ b/example/lib/src/hello_world/hello_world.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + import 'package:angular/angular.dart'; @Component( diff --git a/example/web/main.dart b/example/web/main.dart index 7dda58045..51e09c9bd 100644 --- a/example/web/main.dart +++ b/example/web/main.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + import 'package:angular/experimental.dart'; // ignore: uri_has_not_been_generated diff --git a/webdev/bin/webdev.dart b/webdev/bin/webdev.dart index dc2e03664..70e0dbfcd 100644 --- a/webdev/bin/webdev.dart +++ b/webdev/bin/webdev.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file +// for details. 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:async'; import 'package:webdev/src/webdev_command_runner.dart'; diff --git a/webdev/lib/src/command/build_command.dart b/webdev/lib/src/command/build_command.dart index dd2496768..d98c5fbe3 100644 --- a/webdev/lib/src/command/build_command.dart +++ b/webdev/lib/src/command/build_command.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file +// for details. 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:async'; import 'build_runner_command_base.dart'; diff --git a/webdev/lib/src/command/build_runner_command_base.dart b/webdev/lib/src/command/build_runner_command_base.dart index 91ea52893..67cec1a9f 100644 --- a/webdev/lib/src/command/build_runner_command_base.dart +++ b/webdev/lib/src/command/build_runner_command_base.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file +// for details. 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:async'; import 'dart:io'; import 'dart:isolate'; diff --git a/webdev/lib/src/command/serve_command.dart b/webdev/lib/src/command/serve_command.dart index c2b4e5f96..567cd3d0e 100644 --- a/webdev/lib/src/command/serve_command.dart +++ b/webdev/lib/src/command/serve_command.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file +// for details. 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:async'; import 'build_runner_command_base.dart'; diff --git a/webdev/lib/src/webdev_command_runner.dart b/webdev/lib/src/webdev_command_runner.dart index 1dbdd4133..c2a7c02b5 100644 --- a/webdev/lib/src/webdev_command_runner.dart +++ b/webdev/lib/src/webdev_command_runner.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + import 'package:args/command_runner.dart'; import 'command/build_command.dart'; From 26dc6609b998a383a1ee90f207e218ba6d8ad675 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 19 Mar 2018 13:17:04 -0700 Subject: [PATCH 3/8] Pipe through documentation on serve [director:port] --- webdev/lib/src/command/serve_command.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webdev/lib/src/command/serve_command.dart b/webdev/lib/src/command/serve_command.dart index 567cd3d0e..790d52b97 100644 --- a/webdev/lib/src/command/serve_command.dart +++ b/webdev/lib/src/command/serve_command.dart @@ -15,6 +15,9 @@ class ServeCommand extends BuildRunnerCommandBase { final description = 'Run a local web development server and a file system' ' watcher that re-builds on changes.'; + @override + String get invocation => '${super.invocation} [[:]]...'; + ServeCommand() { // TODO(nshahan) Expose more args passed to build_runner serve. // build_runner might expose args for use in wrapping scripts like this one. From 1ec74ac10128f5554ebcb6cbfd23d6f9ee27cc00 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 19 Mar 2018 13:17:25 -0700 Subject: [PATCH 4/8] Print helpful error with bad command usage --- webdev/bin/webdev.dart | 13 ++++++++++++- webdev/pubspec.yaml | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/webdev/bin/webdev.dart b/webdev/bin/webdev.dart index 70e0dbfcd..d88116ca4 100644 --- a/webdev/bin/webdev.dart +++ b/webdev/bin/webdev.dart @@ -3,9 +3,20 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:async'; +import 'dart:io'; +import 'package:args/command_runner.dart'; +import 'package:io/ansi.dart'; +import 'package:io/io.dart'; import 'package:webdev/src/webdev_command_runner.dart'; Future main(List args) async { - await webdevCommandRunner().run(args); + try { + await webdevCommandRunner().run(args); + } on UsageException catch (e) { + print(yellow.wrap(e.message)); + print(' '); + print(e.usage); + exitCode = ExitCode.usage.code; + } } diff --git a/webdev/pubspec.yaml b/webdev/pubspec.yaml index 443ef325f..1c74a7f49 100644 --- a/webdev/pubspec.yaml +++ b/webdev/pubspec.yaml @@ -9,6 +9,7 @@ environment: dependencies: args: ^1.2.0 + io: ^0.3.2+1 executables: webdev: From 73f2d5921e0eb6e97380d580097eae6f1fc5dbf0 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 19 Mar 2018 14:26:23 -0700 Subject: [PATCH 5/8] Enable travis --- .travis.yml | 41 ++++++++++++++++++++++++++++++++++++++ example/.mono_repo.yml | 10 ++++++++++ tool/travis.sh | 45 ++++++++++++++++++++++++++++++++++++++++++ webdev/.mono_repo.yml | 10 ++++++++++ 4 files changed, 106 insertions(+) create mode 100644 .travis.yml create mode 100644 example/.mono_repo.yml create mode 100755 tool/travis.sh create mode 100644 webdev/.mono_repo.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..cbd34a33e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,41 @@ +# Created with https://github.com/dart-lang/mono_repo +language: dart + +jobs: + include: + - stage: analyzer_and_format + script: ./tool/travis.sh dartfmt + env: PKG="example" + dart: dev + - stage: analyzer_and_format + script: ./tool/travis.sh dartanalyzer + env: PKG="example" + dart: dev + - stage: unit_test + script: ./tool/travis.sh test + env: PKG="example" + dart: dev + - stage: analyzer_and_format + script: ./tool/travis.sh dartfmt + env: PKG="webdev" + dart: dev + - stage: analyzer_and_format + script: ./tool/travis.sh dartanalyzer + env: PKG="webdev" + dart: dev + - stage: unit_test + script: ./tool/travis.sh test + env: PKG="webdev" + dart: dev + +stages: + - analyzer_and_format + - unit_test + +# Only building master means that we don't run two builds for each pull request. +branches: + only: [master] + +cache: + directories: + - $HOME/.pub-cache diff --git a/example/.mono_repo.yml b/example/.mono_repo.yml new file mode 100644 index 000000000..c44173cf8 --- /dev/null +++ b/example/.mono_repo.yml @@ -0,0 +1,10 @@ +# See https://github.com/dart-lang/mono_repo for details +dart: + - dev + +stages: + - analyzer_and_format: + - dartfmt + - dartanalyzer: --fatal-infos --fatal-warnings . + - unit_test: + - test diff --git a/tool/travis.sh b/tool/travis.sh new file mode 100755 index 000000000..a28953b9f --- /dev/null +++ b/tool/travis.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# Created with https://github.com/dart-lang/mono_repo + +if [ -z "$PKG" ]; then + echo -e '\033[31mPKG environment variable must be set!\033[0m' + exit 1 +fi + +if [ "$#" == "0" ]; then + echo -e '\033[31mAt least one task argument must be provided!\033[0m' + exit 1 +fi + +pushd $PKG +pub upgrade || exit $? + +EXIT_CODE=0 + +while (( "$#" )); do + TASK=$1 + case $TASK in + dartanalyzer) echo + echo -e '\033[1mTASK: dartanalyzer\033[22m' + echo -e 'dartanalyzer --fatal-infos --fatal-warnings .' + dartanalyzer --fatal-infos --fatal-warnings . || EXIT_CODE=$? + ;; + dartfmt) echo + echo -e '\033[1mTASK: dartfmt\033[22m' + echo -e 'dartfmt -n --set-exit-if-changed .' + dartfmt -n --set-exit-if-changed . || EXIT_CODE=$? + ;; + test) echo + echo -e '\033[1mTASK: test\033[22m' + echo -e 'pub run test' + pub run test || EXIT_CODE=$? + ;; + *) echo -e "\033[31mNot expecting TASK '${TASK}'. Error!\033[0m" + EXIT_CODE=1 + ;; + esac + + shift +done + +exit $EXIT_CODE diff --git a/webdev/.mono_repo.yml b/webdev/.mono_repo.yml new file mode 100644 index 000000000..c44173cf8 --- /dev/null +++ b/webdev/.mono_repo.yml @@ -0,0 +1,10 @@ +# See https://github.com/dart-lang/mono_repo for details +dart: + - dev + +stages: + - analyzer_and_format: + - dartfmt + - dartanalyzer: --fatal-infos --fatal-warnings . + - unit_test: + - test From 36548d1e58a87296d4c4954e72b42a7d42b87d03 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 19 Mar 2018 15:26:33 -0700 Subject: [PATCH 6/8] Be very careful when invoking the build script via isolate Closes https://github.com/dart-lang/webdev/issues/10 --- .../command/build_runner_command_base.dart | 36 +++++++++++++++++-- webdev/pubspec.yaml | 1 + 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/webdev/lib/src/command/build_runner_command_base.dart b/webdev/lib/src/command/build_runner_command_base.dart index 67cec1a9f..a03bace6a 100644 --- a/webdev/lib/src/command/build_runner_command_base.dart +++ b/webdev/lib/src/command/build_runner_command_base.dart @@ -7,6 +7,7 @@ import 'dart:io'; import 'dart:isolate'; import 'package:args/command_runner.dart'; +import 'package:stack_trace/stack_trace.dart'; /// Extend to get a command with the arguments common to all build_runner /// commands. @@ -26,10 +27,41 @@ abstract class BuildRunnerCommandBase extends Command { Future runCore(String command) async { final arguments = [command]..addAll(argResults.arguments); + + // Heavily inspired by dart-lang/build @ 0c77443dd7 + // /build_runner/bin/build_runner.dart#L58-L85 var exitPort = new ReceivePort(); - await Isolate.spawnUri(await _buildRunnerScript(), arguments, null, - onExit: exitPort.sendPort, automaticPackageResolution: true); + var errorPort = new ReceivePort(); + var messagePort = new ReceivePort(); + var errorListener = errorPort.listen((e) { + stderr.writeln('\n\nYou have hit a bug in build_runner'); + stderr.writeln('Please file an issue with reproduction steps at ' + 'https://github.com/dart-lang/build/issues\n\n'); + final error = e[0]; + final trace = e[1] as String; + stderr.writeln(error); + stderr.writeln(new Trace.parse(trace).terse); + if (exitCode == 0) exitCode = 1; + }); + await Isolate.spawnUri( + await _buildRunnerScript(), arguments, messagePort.sendPort, + onExit: exitPort.sendPort, + onError: errorPort.sendPort, + automaticPackageResolution: true); + StreamSubscription exitCodeListener; + exitCodeListener = messagePort.listen((isolateExitCode) { + if (isolateExitCode is! int) { + throw new StateError( + 'Bad response from isolate, expected an exit code but got ' + '$isolateExitCode'); + } + exitCode = isolateExitCode as int; + exitCodeListener.cancel(); + exitCodeListener = null; + }); await exitPort.first; + await errorListener.cancel(); + await exitCodeListener?.cancel(); } } diff --git a/webdev/pubspec.yaml b/webdev/pubspec.yaml index 1c74a7f49..eadcaa2df 100644 --- a/webdev/pubspec.yaml +++ b/webdev/pubspec.yaml @@ -10,6 +10,7 @@ environment: dependencies: args: ^1.2.0 io: ^0.3.2+1 + stack_trace: ^1.9.2 executables: webdev: From 52d2aa6abb1925259ed433464276355a1023fa10 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 19 Mar 2018 20:26:04 -0700 Subject: [PATCH 7/8] latest angular --- example/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 4532d19b6..b45240ced 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -5,7 +5,7 @@ environment: sdk: ">=2.0.0-dev.32.0 <2.0.0" dependencies: - angular: ^5.0.0-alpha+3 + angular: ^5.0.0-alpha+8 dev_dependencies: build_runner: ^0.8.0 From e328fe9c8e2e17c8ee182b126411b7d25e520d76 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 19 Mar 2018 20:26:41 -0700 Subject: [PATCH 8/8] no tests yet --- .travis.yml | 9 --------- example/.mono_repo.yml | 4 ++-- tool/travis.sh | 5 ----- webdev/.mono_repo.yml | 4 ++-- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index cbd34a33e..009f41650 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,10 +11,6 @@ jobs: script: ./tool/travis.sh dartanalyzer env: PKG="example" dart: dev - - stage: unit_test - script: ./tool/travis.sh test - env: PKG="example" - dart: dev - stage: analyzer_and_format script: ./tool/travis.sh dartfmt env: PKG="webdev" @@ -23,14 +19,9 @@ jobs: script: ./tool/travis.sh dartanalyzer env: PKG="webdev" dart: dev - - stage: unit_test - script: ./tool/travis.sh test - env: PKG="webdev" - dart: dev stages: - analyzer_and_format - - unit_test # Only building master means that we don't run two builds for each pull request. branches: diff --git a/example/.mono_repo.yml b/example/.mono_repo.yml index c44173cf8..77bede62c 100644 --- a/example/.mono_repo.yml +++ b/example/.mono_repo.yml @@ -6,5 +6,5 @@ stages: - analyzer_and_format: - dartfmt - dartanalyzer: --fatal-infos --fatal-warnings . - - unit_test: - - test +# - unit_test: +# - test diff --git a/tool/travis.sh b/tool/travis.sh index a28953b9f..2e8091aa2 100755 --- a/tool/travis.sh +++ b/tool/travis.sh @@ -29,11 +29,6 @@ while (( "$#" )); do echo -e 'dartfmt -n --set-exit-if-changed .' dartfmt -n --set-exit-if-changed . || EXIT_CODE=$? ;; - test) echo - echo -e '\033[1mTASK: test\033[22m' - echo -e 'pub run test' - pub run test || EXIT_CODE=$? - ;; *) echo -e "\033[31mNot expecting TASK '${TASK}'. Error!\033[0m" EXIT_CODE=1 ;; diff --git a/webdev/.mono_repo.yml b/webdev/.mono_repo.yml index c44173cf8..77bede62c 100644 --- a/webdev/.mono_repo.yml +++ b/webdev/.mono_repo.yml @@ -6,5 +6,5 @@ stages: - analyzer_and_format: - dartfmt - dartanalyzer: --fatal-infos --fatal-warnings . - - unit_test: - - test +# - unit_test: +# - test