-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reorganized package, put example it it's own directory, etc #9
Changes from 6 commits
ca37bc7
2a64f7a
26dc660
1ec74ac
73f2d59
36548d1
52d2aa6
e328fe9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
packages | ||
/*/build/ | ||
.pub/ | ||
pubspec.lock | ||
|
||
# Files generated by dart tools | ||
.dart_tool | ||
doc/ | ||
.packages | ||
pubspec.lock |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// 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( | ||
selector: 'hello-world', | ||
styleUrls: const ['hello_world.css'], | ||
templateUrl: 'hello_world.html', | ||
) | ||
class HelloWorldComponent { | ||
// Nothing here. | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div>Hello World</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// 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 | ||
import 'package:webdev_example_app/app_component.template.dart' as ng; | ||
|
||
main() { | ||
// ignore: argument_type_not_assignable | ||
bootstrapFactory(ng.AppComponentNgFactory); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
// 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 'package:webdev/webdev.dart'; | ||
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<String> 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; | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
// 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'; | ||
|
||
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. | ||
|
@@ -19,13 +25,97 @@ abstract class BuildRunnerCommandBase extends Command { | |
help: 'Enables verbose logging.'); | ||
} | ||
|
||
Future<Uri> 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); | ||
|
||
// Heavily inspired by dart-lang/build @ 0c77443dd7 | ||
// /build_runner/bin/build_runner.dart#L58-L85 | ||
var exitPort = new ReceivePort(); | ||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As an FYI this isn't guaranteed to fire. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There oughta be a helper... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be a todo? File an issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes there should :) I still haven't made up my mind whether I want a specific helper in |
||
await errorListener.cancel(); | ||
await exitCodeListener?.cancel(); | ||
} | ||
} | ||
|
||
Future<Uri> _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<String> args, [SendPort sendPort]) async { | ||
var buildScript = await generateBuildScript(); | ||
var scriptFile = new File(scriptLocation)..createSync(recursive: true); | ||
scriptFile.writeAsStringSync(buildScript); | ||
sendPort.send(p.absolute(scriptLocation)); | ||
} | ||
'''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we bump to alpha+8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh...sure