diff --git a/packages/hot/.idea/hot.iml b/packages/hot/.idea/hot.iml deleted file mode 100644 index 954fa6c5..00000000 --- a/packages/hot/.idea/hot.iml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/hot/.idea/modules.xml b/packages/hot/.idea/modules.xml deleted file mode 100644 index 81b04c42..00000000 --- a/packages/hot/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/packages/hot/.idea/runConfigurations/main_dart.xml b/packages/hot/.idea/runConfigurations/main_dart.xml deleted file mode 100644 index 0d20fe85..00000000 --- a/packages/hot/.idea/runConfigurations/main_dart.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/packages/hot/.idea/runConfigurations/main_dart__No_VM_service_.xml b/packages/hot/.idea/runConfigurations/main_dart__No_VM_service_.xml deleted file mode 100644 index 08397143..00000000 --- a/packages/hot/.idea/runConfigurations/main_dart__No_VM_service_.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/packages/hot/.idea/vcs.xml b/packages/hot/.idea/vcs.xml deleted file mode 100644 index 94a25f7f..00000000 --- a/packages/hot/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/packages/hot/CHANGELOG.md b/packages/hot/CHANGELOG.md index bf9f0b96..b5a0fb97 100644 --- a/packages/hot/CHANGELOG.md +++ b/packages/hot/CHANGELOG.md @@ -1,41 +1,60 @@ -# 4.1.0 +# Change Log + +## 4.1.1 + +* Fixed NNBD issues +* Updated README + +## 4.1.0 + * Updated `vm_service` to 7.1.x -# 4.0.0 +## 4.0.0 + * Migrated to support Dart SDK 2.12.x NNBD -# 3.0.0 +## 3.0.0 + * Migrated to work with Dart SDK 2.12.x Non NNBD -# 2.0.6 +## 2.0.6 + * Support `--observe=*`, `--enable-vm-service=*` (`startsWith`, instead of `==`). -# 2.0.5 +## 2.0.5 + * Use `dart:developer` to find the Observatory URI. * Use the app's logger when necessary. * Apply `package:pedantic`. -# 2.0.4 +## 2.0.4 + * Forcibly close app loggers on shutdown. -# 2.0.3 +## 2.0.3 + * Fixed up manual restart. * Remove stutter on hotkey press. -# 2.0.2 +## 2.0.2 + * Fixed for compatibility with `package:angel_websocket@^2.0.0-alpha.5`. -# 2.0.1 -* Add import of `package:angel_framework/http.dart` - * https://github.com/angel-dart/hot/pull/7 +## 2.0.1 + +* Add import of `package:angel_framework/http.dart` + * + +## 2.0.0 -# 2.0.0 * Update for Dart 2 + Angel 2. -# 1.1.1+1 +## 1.1.1+1 + * Fix a bug that threw when `--observe` was not present. -# 1.1.1 +## 1.1.1 + * Disable the observatory from pausing the isolate on exceptions, because Angel already handles all exceptions by itself. diff --git a/packages/hot/README.md b/packages/hot/README.md index bd83f55b..2a32f79b 100644 --- a/packages/hot/README.md +++ b/packages/hot/README.md @@ -1,18 +1,20 @@ -# angel3_hot -[![version](https://img.shields.io/badge/pub-v4.1.0-brightgreen)](https://pub.dartlang.org/packages/angel3_hot) +# Angel3 Hot Reloader + +[![version](https://img.shields.io/badge/pub-v4.1.1-brightgreen)](https://pub.dartlang.org/packages/angel3_hot) [![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) [![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) [![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/hot/LICENSE) -![Screenshot of terminal](screenshots/screenshot.png) +![Screenshot of terminal](screenshots/angel3-screenshot.png) -Supports *hot reloading* of Angel servers on file changes. This is faster and -more reliable than merely reactively restarting a `Process`. +Supports *hot reloading* of Angel3 servers on file changes. This is faster and more reliable than merely reactively restarting a `Process`. +This package only works with the [Angel3 framework](https://github.com/dukefirehawk/angel). -This package only works with the [Angel framework](https://github.com/dukefirehawk/angel/tree/angel3). +**Not recommended to use in production, unless you are specifically intending for a "hot code push" in production..** + +## Installation -# Installation In your `pubspec.yaml`: ```yaml @@ -21,32 +23,28 @@ dependencies: angel3_hot: ^4.0.0 ``` -# Usage -This package is dependent on the Dart VM service, so you *must* run -Dart with the `--observe` (or `--enable-vm-service`) argument!!! +## Usage -Usage is fairly simple. Pass a function that creates an `Angel` server, along with a collection of paths -to watch, to the `HotReloader` constructor. The rest is history!!! +This package is dependent on the Dart VM service, so you *must* run Dart with the `--observe` (or `--enable-vm-service`) argument!!! -The recommended pattern is to only use hot-reloading in your application entry point. Create your `Angel` instance -within a separate function, conventionally named `createServer`. +Usage is fairly simple. Pass a function that creates an `Angel` server, along with a collection of paths to watch, to the `HotReloader` constructor. The rest is history!!! -**Using this in production mode is not recommended, unless you are -specifically intending for a "hot code push" in production..** +The recommended pattern is to only use hot-reloading in your application entry point. Create your `Angel` instance within a separate function, conventionally named `createServer`. You can watch: - * Files - * Directories - * Globs - * URI's - * `package:` URI's + +* Files +* Directories +* Globs +* URI's +* `package:` URI's ```dart import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_hot/angel_hot.dart'; +import 'package:angel3_framework/angel3_framework.dart'; +import 'package:angel3_hot/angel_hot.dart'; import 'package:logging/logging.dart'; import 'src/foo.dart'; @@ -55,26 +53,26 @@ main() async { new Directory('src'), new Directory('src'), 'main.dart', - Uri.parse('package:angel_hot/angel_hot.dart') + Uri.parse('package:angel3_hot/angel3_hot.dart') ]); await hot.startServer('127.0.0.1', 3000); } Future createServer() async { - var app = new Angel()..serializer = json.encode; + var app = Angel()..serializer = json.encode; // Edit this line, and then refresh the page in your browser! app.get('/', (req, res) => {'hello': 'hot world!'}); - app.get('/foo', (req, res) => new Foo(bar: 'baz')); + app.get('/foo', (req, res) => Foo(bar: 'baz')); - app.fallback((req, res) => throw new AngelHttpException.notFound()); + app.fallback((req, res) => throw AngelHttpException.notFound()); app.encoders.addAll({ 'gzip': gzip.encoder, 'deflate': zlib.encoder, }); - app.logger = new Logger('angel') + app.logger = Logger('angel') ..onRecord.listen((rec) { print(rec); if (rec.error != null) { diff --git a/packages/hot/lib/angel3_hot.dart b/packages/hot/lib/angel3_hot.dart index 6e3a50d2..18affc7d 100644 --- a/packages/hot/lib/angel3_hot.dart +++ b/packages/hot/lib/angel3_hot.dart @@ -140,7 +140,7 @@ class HotReloader { void _logWarning(String msg) { if (_server?.app.logger != null) { - _server!.app.logger!.warning(msg); + _server?.app.logger?.warning(msg); } else { print(yellow.wrap('WARNING: $msg')); } @@ -148,7 +148,7 @@ class HotReloader { void _logInfo(String msg) { if (_server?.app.logger != null) { - _server!.app.logger!.info(msg); + _server?.app.logger?.info(msg); } else { print(lightGray.wrap(msg)); } @@ -183,10 +183,14 @@ class HotReloader { } _client = await vm.vmServiceConnectUri(uri.toString()); _vmachine ??= await _client.getVM(); - _mainIsolate ??= _vmachine!.isolates!.first; + _mainIsolate ??= _vmachine?.isolates?.first; - for (var isolate in _vmachine!.isolates!) { - await _client.setExceptionPauseMode(isolate.id!, 'None'); + if (_vmachine != null) { + for (var isolate in _vmachine!.isolates ?? []) { + if (isolate.id != null) { + await _client.setExceptionPauseMode(isolate.id!, 'None'); + } + } } await _listenToFilesystem(); @@ -206,16 +210,25 @@ class HotReloader { if (enableHotkeys) { var serverUri = Uri(scheme: 'http', host: server.address.address, port: server.port); - var observatoryUri = - await dev.Service.getInfo().then((i) => i.serverUri!); + + var observatoryUri; + if (isHot) { + observatoryUri = await dev.Service.getInfo().then((i) => i.serverUri!); + } print(styleBold.wrap( '\n🔥 To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".')); - stdout.write('Your Angel server is listening at: '); + stdout.write('Your server is listening at: '); print(wrapWith('$serverUri', [cyan, styleUnderlined])); - stdout.write( - 'An Observatory debugger and profiler on ${Platform.operatingSystem} is available at: '); - print(wrapWith('$observatoryUri', [cyan, styleUnderlined])); + + if (isHot) { + stdout.write( + 'An Observatory debugger and profiler on ${Platform.operatingSystem} is available at: '); + print(wrapWith('$observatoryUri', [cyan, styleUnderlined])); + } else { + stdout.write( + 'The observatory debugger and profiler are not available.\n'); + } print( 'For a more detailed help message, press "h". To quit, press "q".\n'); diff --git a/packages/hot/pubspec.yaml b/packages/hot/pubspec.yaml index 9ff877f9..ade9c23e 100644 --- a/packages/hot/pubspec.yaml +++ b/packages/hot/pubspec.yaml @@ -1,6 +1,6 @@ name: angel3_hot description: Supports hot reloading/hot code push of Angel servers on file changes. -version: 4.1.0 +version: 4.1.1 homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/hot environment: sdk: '>=2.12.0 <3.0.0' diff --git a/packages/hot/screenshots/angel3-screenshot.png b/packages/hot/screenshots/angel3-screenshot.png new file mode 100644 index 00000000..5c29f347 Binary files /dev/null and b/packages/hot/screenshots/angel3-screenshot.png differ