From d9ae89cf7deacb0ee82e6b363ca1e06c0a95ea4b Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Fri, 17 May 2019 11:06:55 +0100 Subject: [PATCH 1/9] Dart: fix pedantic lint for unawaited future --- containers/dart/test-project/server.dart | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/containers/dart/test-project/server.dart b/containers/dart/test-project/server.dart index 1b7512b58f..ef53c3e74d 100644 --- a/containers/dart/test-project/server.dart +++ b/containers/dart/test-project/server.dart @@ -4,14 +4,14 @@ *-------------------------------------------------------------------------------------------------------------*/ import 'dart:io'; +import 'package:pedantic/pedantic.dart'; Future main() async { - - - var server = await HttpServer.bind( + final server = await HttpServer.bind( InternetAddress.loopbackIPv4, 8080, ); + print('*************************************************************************'); print('* Press F1, select "Remote-Containers: Forward Port from Container...", *'); print('* and select the server port listed below to access server. *'); @@ -19,8 +19,7 @@ Future main() async { print('Listening on localhost:${server.port}'); await for (HttpRequest request in server) { - request.response - ..write('Hello remote world!') - ..close(); + request.response.write('Hello remote world!'); + unawaited(request.response.close()); } } \ No newline at end of file From 395b110be70adc56fa795bbc6fefd251a4564293 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Fri, 17 May 2019 11:07:29 +0100 Subject: [PATCH 2/9] Dart: Move server into bin/ folder and un-ignore --- containers/dart/.vscode/launch.json | 4 ++-- containers/dart/test-project/.gitignore | 3 +++ containers/dart/test-project/{ => bin}/server.dart | 0 3 files changed, 5 insertions(+), 2 deletions(-) rename containers/dart/test-project/{ => bin}/server.dart (100%) diff --git a/containers/dart/.vscode/launch.json b/containers/dart/.vscode/launch.json index eed8622f79..9a941e7b3f 100644 --- a/containers/dart/.vscode/launch.json +++ b/containers/dart/.vscode/launch.json @@ -8,8 +8,8 @@ "name": "Launch Server", "type": "dart", "request": "launch", - "program": "server.dart", - "cwd": "${workspaceFolder}/test-project", + "program": "bin/server.dart", + "cwd": "test-project", "preLaunchTask": "get" } ] diff --git a/containers/dart/test-project/.gitignore b/containers/dart/test-project/.gitignore index 50602ac67e..03d22407c8 100644 --- a/containers/dart/test-project/.gitignore +++ b/containers/dart/test-project/.gitignore @@ -9,3 +9,6 @@ build/ # Directory created by dartdoc doc/api/ + +# Don't exclude bin/ folders for Dart projects +![Bb]in/ \ No newline at end of file diff --git a/containers/dart/test-project/server.dart b/containers/dart/test-project/bin/server.dart similarity index 100% rename from containers/dart/test-project/server.dart rename to containers/dart/test-project/bin/server.dart From 2884e4f2a1f8ce7af46c4dde7cf2488c952505c2 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Fri, 17 May 2019 11:08:39 +0100 Subject: [PATCH 3/9] Dart: Remove unused dependencies --- containers/dart/.devcontainer/Dockerfile | 2 -- containers/dart/test-project/pubspec.yaml | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/containers/dart/.devcontainer/Dockerfile b/containers/dart/.devcontainer/Dockerfile index 527e428476..4119eb5bee 100644 --- a/containers/dart/.devcontainer/Dockerfile +++ b/containers/dart/.devcontainer/Dockerfile @@ -7,8 +7,6 @@ FROM google/dart:2 ENV PATH="$PATH":"/root/.pub-cache/bin" -RUN pub global activate webdev - # Install git, process tools RUN apt-get update && apt-get -y install git procps diff --git a/containers/dart/test-project/pubspec.yaml b/containers/dart/test-project/pubspec.yaml index 5f3b44b037..5a265153dd 100644 --- a/containers/dart/test-project/pubspec.yaml +++ b/containers/dart/test-project/pubspec.yaml @@ -10,6 +10,5 @@ environment: sdk: '>=2.1.0 <3.0.0' dev_dependencies: - build_runner: ^1.1.2 - build_web_compilers: ^1.0.0 pedantic: ^1.0.0 + \ No newline at end of file From b84beec7817ffdcc35f385940c1e45fb16e3ffb7 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Fri, 17 May 2019 11:09:20 +0100 Subject: [PATCH 4/9] Dart: Don't run pub-get on every launch --- containers/dart/.vscode/launch.json | 3 +-- containers/dart/.vscode/tasks.json | 13 ------------- containers/dart/README.md | 11 ++++++----- 3 files changed, 7 insertions(+), 20 deletions(-) delete mode 100644 containers/dart/.vscode/tasks.json diff --git a/containers/dart/.vscode/launch.json b/containers/dart/.vscode/launch.json index 9a941e7b3f..ae1c3bd367 100644 --- a/containers/dart/.vscode/launch.json +++ b/containers/dart/.vscode/launch.json @@ -9,8 +9,7 @@ "type": "dart", "request": "launch", "program": "bin/server.dart", - "cwd": "test-project", - "preLaunchTask": "get" + "cwd": "test-project" } ] } \ No newline at end of file diff --git a/containers/dart/.vscode/tasks.json b/containers/dart/.vscode/tasks.json deleted file mode 100644 index 458981e967..0000000000 --- a/containers/dart/.vscode/tasks.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "label": "get", - "type": "shell", - "command": "cd test-project && pub get" - } - - ] -} \ No newline at end of file diff --git a/containers/dart/README.md b/containers/dart/README.md index 7ac13d4707..04e895c4e3 100644 --- a/containers/dart/README.md +++ b/containers/dart/README.md @@ -38,11 +38,12 @@ This definition includes some test code that will help you verify it is working 2. Clone this repository. 3. Start VS Code, press F1, and select **Remote-Containers: Open Folder in Container...** 4. Select the `containers/dart` folder. -5. After the folder has opened in the container, press F5 to start the project. This will automatically run `pub get` and build the code before starting it. -6. Once the project is running, press F1 and select **Remote-Containers: Forward Port from Container...** -7. Select port 8080 and click the "Open Browser" button in the notification that appears. -8. You should see "Hello remote world!" after the page loads. -9. From here, you can add breakpoints or edit the contents of the `test-project` folder to do further testing. +5. After the folder has opened in the container, press F1, and select **Pub: Get Packages** to download packages +6. After packages have been downloaded, press F5 to start the project. +7. Once the project is running, press F1 and select **Remote-Containers: Forward Port from Container...** +8. Select port 8080 and click the "Open Browser" button in the notification that appears. +9. You should see "Hello remote world!" after the page loads. +10. From here, you can add breakpoints or edit the contents of the `test-project` folder to do further testing. ## License From 2f8627137e2c5489da315466193640a2e379bc2f Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Fri, 17 May 2019 11:13:31 +0100 Subject: [PATCH 5/9] Dart: Make browser open automatically --- containers/dart/.vscode/launch.json | 7 ++++++- containers/dart/README.md | 8 +++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/containers/dart/.vscode/launch.json b/containers/dart/.vscode/launch.json index ae1c3bd367..6079d56a07 100644 --- a/containers/dart/.vscode/launch.json +++ b/containers/dart/.vscode/launch.json @@ -9,7 +9,12 @@ "type": "dart", "request": "launch", "program": "bin/server.dart", - "cwd": "test-project" + "cwd": "test-project", + "serverReadyAction": { + "pattern": "Listening on localhost:([0-9]+)", + "uriFormat": "http://localhost:%s", + "action": "openExternally" + } } ] } \ No newline at end of file diff --git a/containers/dart/README.md b/containers/dart/README.md index 04e895c4e3..2726efa737 100644 --- a/containers/dart/README.md +++ b/containers/dart/README.md @@ -39,11 +39,9 @@ This definition includes some test code that will help you verify it is working 3. Start VS Code, press F1, and select **Remote-Containers: Open Folder in Container...** 4. Select the `containers/dart` folder. 5. After the folder has opened in the container, press F1, and select **Pub: Get Packages** to download packages -6. After packages have been downloaded, press F5 to start the project. -7. Once the project is running, press F1 and select **Remote-Containers: Forward Port from Container...** -8. Select port 8080 and click the "Open Browser" button in the notification that appears. -9. You should see "Hello remote world!" after the page loads. -10. From here, you can add breakpoints or edit the contents of the `test-project` folder to do further testing. +6. After packages have been downloaded, press F5 to start the project and launch the browser. +7. You should see "Hello remote world!" after the page loads. +8. From here, you can add breakpoints or edit the contents of the `test-project` folder to do further testing. ## License From bbaf4ec0ac7e3fd842d6e5e1ed7d3f7ee014fa45 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Fri, 17 May 2019 11:31:40 +0100 Subject: [PATCH 6/9] Dart: Remove unnecessary extension --- containers/dart/.devcontainer/devcontainer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/containers/dart/.devcontainer/devcontainer.json b/containers/dart/.devcontainer/devcontainer.json index a696913065..8ade05871a 100644 --- a/containers/dart/.devcontainer/devcontainer.json +++ b/containers/dart/.devcontainer/devcontainer.json @@ -2,8 +2,7 @@ "name": "Dart", "dockerFile": "Dockerfile", "extensions": [ - "dart-code.dart-code", - "msjsdiag.debugger-for-chrome" + "dart-code.dart-code" ], // Uncomment the next line if you want to publish any ports. From 4bf27bac7d5e2a9d55a3cebc2b5714f032d12cd1 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Fri, 17 May 2019 11:34:06 +0100 Subject: [PATCH 7/9] Dart: Remove pedantic to simplify startup --- containers/dart/.devcontainer/devcontainer.json | 2 +- containers/dart/test-project/analysis_options.yaml | 6 ------ containers/dart/test-project/bin/server.dart | 4 +--- containers/dart/test-project/pubspec.yaml | 4 ---- 4 files changed, 2 insertions(+), 14 deletions(-) delete mode 100644 containers/dart/test-project/analysis_options.yaml diff --git a/containers/dart/.devcontainer/devcontainer.json b/containers/dart/.devcontainer/devcontainer.json index 8ade05871a..4996dd9b02 100644 --- a/containers/dart/.devcontainer/devcontainer.json +++ b/containers/dart/.devcontainer/devcontainer.json @@ -9,5 +9,5 @@ // "appPort": [], // Uncomment the next line to run commands after the container is created. - // "postCreateCommand": "pub get" + // "postCreateCommand": "" } diff --git a/containers/dart/test-project/analysis_options.yaml b/containers/dart/test-project/analysis_options.yaml deleted file mode 100644 index d5105e6f22..0000000000 --- a/containers/dart/test-project/analysis_options.yaml +++ /dev/null @@ -1,6 +0,0 @@ -#------------------------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. -#------------------------------------------------------------------------------------------------------------- - -include: package:pedantic/analysis_options.yaml diff --git a/containers/dart/test-project/bin/server.dart b/containers/dart/test-project/bin/server.dart index ef53c3e74d..6c1c56f254 100644 --- a/containers/dart/test-project/bin/server.dart +++ b/containers/dart/test-project/bin/server.dart @@ -4,7 +4,6 @@ *-------------------------------------------------------------------------------------------------------------*/ import 'dart:io'; -import 'package:pedantic/pedantic.dart'; Future main() async { final server = await HttpServer.bind( @@ -19,7 +18,6 @@ Future main() async { print('Listening on localhost:${server.port}'); await for (HttpRequest request in server) { - request.response.write('Hello remote world!'); - unawaited(request.response.close()); + request.response..write('Hello remote world!')..close(); } } \ No newline at end of file diff --git a/containers/dart/test-project/pubspec.yaml b/containers/dart/test-project/pubspec.yaml index 5a265153dd..ba55c0b6d3 100644 --- a/containers/dart/test-project/pubspec.yaml +++ b/containers/dart/test-project/pubspec.yaml @@ -8,7 +8,3 @@ description: A test project environment: sdk: '>=2.1.0 <3.0.0' - -dev_dependencies: - pedantic: ^1.0.0 - \ No newline at end of file From bbf316667f8912bced2ed619dd0d2a860b1c46c1 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Fri, 17 May 2019 11:35:16 +0100 Subject: [PATCH 8/9] Dart: Remove unnecessary instructions + format --- containers/dart/test-project/bin/server.dart | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/containers/dart/test-project/bin/server.dart b/containers/dart/test-project/bin/server.dart index 6c1c56f254..a6550a399e 100644 --- a/containers/dart/test-project/bin/server.dart +++ b/containers/dart/test-project/bin/server.dart @@ -10,14 +10,12 @@ Future main() async { InternetAddress.loopbackIPv4, 8080, ); - - print('*************************************************************************'); - print('* Press F1, select "Remote-Containers: Forward Port from Container...", *'); - print('* and select the server port listed below to access server. *'); - print('*************************************************************************'); + print('Listening on localhost:${server.port}'); await for (HttpRequest request in server) { - request.response..write('Hello remote world!')..close(); + request.response + ..write('Hello remote world!') + ..close(); } -} \ No newline at end of file +} From a9fad745f1231b8cbbc95761546f0a976448b214 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Fri, 17 May 2019 11:56:25 +0100 Subject: [PATCH 9/9] Remove unnecessary "pub get" step from readme --- containers/dart/README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/containers/dart/README.md b/containers/dart/README.md index 2726efa737..fe6873c082 100644 --- a/containers/dart/README.md +++ b/containers/dart/README.md @@ -38,10 +38,9 @@ This definition includes some test code that will help you verify it is working 2. Clone this repository. 3. Start VS Code, press F1, and select **Remote-Containers: Open Folder in Container...** 4. Select the `containers/dart` folder. -5. After the folder has opened in the container, press F1, and select **Pub: Get Packages** to download packages -6. After packages have been downloaded, press F5 to start the project and launch the browser. -7. You should see "Hello remote world!" after the page loads. -8. From here, you can add breakpoints or edit the contents of the `test-project` folder to do further testing. +5. After the folder has opened in the container, press F5 to start the project and launch the browser. +6. You should see "Hello remote world!" after the page loads. +7. From here, you can add breakpoints or edit the contents of the `test-project` folder to do further testing. ## License