From cc57dc1aa256c6b00fbc8ddb55df2b55f5c9655f Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 25 Nov 2015 19:58:19 -0800 Subject: [PATCH] hello world for angular 2 --- CHANGELOG.md | 3 ++ README.md | 1 + lib/generators/web_angular.dart | 28 ++++++++++++ lib/generators/web_angular_data.dart | 46 ++++++++++++++++++++ lib/stagehand.dart | 2 + site/index.html | 1 + templates/web-angular/.gitignore | 24 ++++++++++ templates/web-angular/lib/app_component.dart | 9 ++++ templates/web-angular/lib/app_component.html | 1 + templates/web-angular/pubspec.yaml | 8 ++++ templates/web-angular/web/index.html | 12 +++++ templates/web-angular/web/main.dart | 12 +++++ 12 files changed, 147 insertions(+) create mode 100644 lib/generators/web_angular.dart create mode 100644 lib/generators/web_angular_data.dart create mode 100644 templates/web-angular/.gitignore create mode 100644 templates/web-angular/lib/app_component.dart create mode 100644 templates/web-angular/lib/app_component.html create mode 100644 templates/web-angular/pubspec.yaml create mode 100644 templates/web-angular/web/index.html create mode 100644 templates/web-angular/web/main.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index b2ce8c58..a373402b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## 0.2.5 +- Added `web-angular` template for an Angular2 (alpha) app. + ## 0.2.4 - Migrated `server-appengine` to use `shelf`. - Updated the template `.gitignore` files diff --git a/README.md b/README.md index 4c08fc28..f351b5d9 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Kit and Yeoman. * `package-simple` - A starting point for Dart libraries or applications. * `server-appengine` - A simple App Engine application. * `server-shelf` - A web server built using the shelf package. +* `web-angular` - A web app built using Angular 2. * `web-polymer` - A web app built using polymer.dart. * `web-simple` - An absolute bare-bones web app. diff --git a/lib/generators/web_angular.dart b/lib/generators/web_angular.dart new file mode 100644 index 00000000..65c4233d --- /dev/null +++ b/lib/generators/web_angular.dart @@ -0,0 +1,28 @@ +// Copyright (c) 2015, Google Inc. 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. + +library stagehand.web.angular; + +import '../stagehand.dart'; +import '../src/common.dart'; +import 'web_angular_data.dart'; + +/** + * A generator for an Angular 2 application. + */ +class WebAngularGenerator extends DefaultGenerator { + WebAngularGenerator() + : super('web-angular', 'Angular 2 Web Application', + 'A web app built using Angular 2.', + categories: const ['dart', 'web']) { + for (TemplateFile file in decodeConcatenatedData(data)) { + addTemplateFile(file); + } + + setEntrypoint(getFile('web/index.html')); + } + + String getInstallInstructions() => "${super.getInstallInstructions()}\n" + "to run your app, use 'pub serve'"; +} diff --git a/lib/generators/web_angular_data.dart b/lib/generators/web_angular_data.dart new file mode 100644 index 00000000..d6a52c20 --- /dev/null +++ b/lib/generators/web_angular_data.dart @@ -0,0 +1,46 @@ +// Copyright (c) 2014, Google Inc. 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. + +const List data = const [ + ".gitignore", + "text", + """IyBGaWxlcyBhbmQgZGlyZWN0b3JpZXMgY3JlYXRlZCBieSBwdWIKLmJ1aWxkbG9nCi5wYWNrYWdl +cwoucHJvamVjdAoucHViLwpidWlsZC8KcGFja2FnZXMKcHVic3BlYy5sb2NrICMgKFJlbW92ZSB0 +aGlzIHBhdHRlcm4gaWYgeW91IHdpc2ggdG8gY2hlY2sgaW4geW91ciBsb2NrIGZpbGUpCgojIEZp +bGVzIGNyZWF0ZWQgYnkgZGFydDJqcwoqLmRhcnQuanMKKi5wYXJ0LmpzCiouanMuZGVwcwoqLmpz +Lm1hcAoqLmluZm8uanNvbgoKIyBEaXJlY3RvcnkgY3JlYXRlZCBieSBkYXJ0ZG9jCmRvYy9hcGkv +CgojIEpldEJyYWlucyBJREVzIChXZWJTdG9ybSBhbmQgSURFQSBhcmUgdGhlIHJlY29tZW5kZWQg +RGFydCBJREVzKSAKLmlkZWEvCiouaW1sCiouaXByCiouaXdzCg==""", + "lib/app_component.dart", + "text", + """Ly8gQ29weXJpZ2h0IChjKSBfX3llYXJfXywgX19hdXRob3JfXy4gQWxsIHJpZ2h0cyByZXNlcnZl +ZC4gVXNlIG9mIHRoaXMgc291cmNlIGNvZGUKLy8gaXMgZ292ZXJuZWQgYnkgYSBCU0Qtc3R5bGUg +bGljZW5zZSB0aGF0IGNhbiBiZSBmb3VuZCBpbiB0aGUgTElDRU5TRSBmaWxlLgoKbGlicmFyeSBf +X3Byb2plY3ROYW1lX18uYXBwX2NvbXBvbmVudDsKCmltcG9ydCAncGFja2FnZTphbmd1bGFyMi9h +bmd1bGFyMi5kYXJ0JzsKCkBDb21wb25lbnQoc2VsZWN0b3I6ICdteS1hcHAnLCB0ZW1wbGF0ZVVy +bDogJ2FwcF9jb21wb25lbnQuaHRtbCcpCmNsYXNzIEFwcENvbXBvbmVudCB7fQo=""", + "lib/app_component.html", + "text", + "PGgxPk15IEZpcnN0IEFuZ3VsYXIgMiBBcHA8L2gxPgo=", + "pubspec.yaml", + "text", + """bmFtZTogX19wcm9qZWN0TmFtZV9fCnZlcnNpb246IDAuMC4xCmRlcGVuZGVuY2llczoKICBhbmd1 +bGFyMjogMi4wLjAtYWxwaGEuNDcKICBicm93c2VyOiBeMC4xMC4wCnRyYW5zZm9ybWVyczoKLSBh +bmd1bGFyMjoKICAgIGVudHJ5X3BvaW50czogd2ViL21haW4uZGFydAo=""", + "web/index.html", + "text", + """PCFET0NUWVBFIGh0bWw+CjxodG1sPgogIDxoZWFkPgogICAgPHRpdGxlPl9fcHJvamVjdE5hbWVf +XzwvdGl0bGU+CgogICAgPHNjcmlwdCBkZWZlciBzcmM9Im1haW4uZGFydCIgdHlwZT0iYXBwbGlj +YXRpb24vZGFydCI+PC9zY3JpcHQ+CiAgICA8c2NyaXB0IGRlZmVyIHNyYz0icGFja2FnZXMvYnJv +d3Nlci9kYXJ0LmpzIj48L3NjcmlwdD4KICA8L2hlYWQ+CiAgPGJvZHk+CiAgICA8bXktYXBwPkxv +YWRpbmcuLi48L215LWFwcD4KICA8L2JvZHk+CjwvaHRtbD4K""", + "web/main.dart", + "text", + """Ly8gQ29weXJpZ2h0IChjKSBfX3llYXJfXywgX19hdXRob3JfXy4gQWxsIHJpZ2h0cyByZXNlcnZl +ZC4gVXNlIG9mIHRoaXMgc291cmNlIGNvZGUKLy8gaXMgZ292ZXJuZWQgYnkgYSBCU0Qtc3R5bGUg +bGljZW5zZSB0aGF0IGNhbiBiZSBmb3VuZCBpbiB0aGUgTElDRU5TRSBmaWxlLgoKbGlicmFyeSBf +X3Byb2plY3ROYW1lX18ud2ViOwoKaW1wb3J0ICdwYWNrYWdlOmFuZ3VsYXIyL2Jvb3RzdHJhcC5k +YXJ0JzsKCmltcG9ydCAncGFja2FnZTpfX3Byb2plY3ROYW1lX18vYXBwX2NvbXBvbmVudC5kYXJ0 +JzsKCm1haW4oKSB7CiAgYm9vdHN0cmFwKEFwcENvbXBvbmVudCk7Cn0K""" +]; diff --git a/lib/stagehand.dart b/lib/stagehand.dart index 7debddfa..3d05a789 100644 --- a/lib/stagehand.dart +++ b/lib/stagehand.dart @@ -31,6 +31,7 @@ import 'generators/console_simple.dart'; import 'generators/package_simple.dart'; import 'generators/server_appengine.dart'; import 'generators/server_shelf.dart'; +import 'generators/web_angular.dart'; import 'generators/web_polymer.dart'; import 'generators/web_simple.dart'; import 'src/common.dart'; @@ -42,6 +43,7 @@ final List generators = [ new PackageSimpleGenerator(), new ServerAppEngineGenerator(), new ServerShelfGenerator(), + new WebAngularGenerator(), new WebPolymerGenerator(), new WebSimpleGenerator() ]..sort(); diff --git a/site/index.html b/site/index.html index 245351ac..135446bd 100644 --- a/site/index.html +++ b/site/index.html @@ -90,6 +90,7 @@

Usage

  • package-simple - A starting point for Dart libraries or applications.
  • server-appengine - A simple App Engine application.
  • server-shelf - A web server built using the shelf package.
  • +
  • web-angular - A web app built using Angular 2.
  • web-polymer - A web app built using polymer.dart.
  • web-simple - An absolute bare-bones web app.
  • diff --git a/templates/web-angular/.gitignore b/templates/web-angular/.gitignore new file mode 100644 index 00000000..ef1c6812 --- /dev/null +++ b/templates/web-angular/.gitignore @@ -0,0 +1,24 @@ +# Files and directories created by pub +.buildlog +.packages +.project +.pub/ +build/ +packages +pubspec.lock # (Remove this pattern if you wish to check in your lock file) + +# Files created by dart2js +*.dart.js +*.part.js +*.js.deps +*.js.map +*.info.json + +# Directory created by dartdoc +doc/api/ + +# JetBrains IDEs (WebStorm and IDEA are the recomended Dart IDEs) +.idea/ +*.iml +*.ipr +*.iws diff --git a/templates/web-angular/lib/app_component.dart b/templates/web-angular/lib/app_component.dart new file mode 100644 index 00000000..81b0de9b --- /dev/null +++ b/templates/web-angular/lib/app_component.dart @@ -0,0 +1,9 @@ +// Copyright (c) __year__, __author__. All rights reserved. Use of this source code +// is governed by a BSD-style license that can be found in the LICENSE file. + +library __projectName__.app_component; + +import 'package:angular2/angular2.dart'; + +@Component(selector: 'my-app', templateUrl: 'app_component.html') +class AppComponent {} diff --git a/templates/web-angular/lib/app_component.html b/templates/web-angular/lib/app_component.html new file mode 100644 index 00000000..4bcdd569 --- /dev/null +++ b/templates/web-angular/lib/app_component.html @@ -0,0 +1 @@ +

    My First Angular 2 App

    diff --git a/templates/web-angular/pubspec.yaml b/templates/web-angular/pubspec.yaml new file mode 100644 index 00000000..fcf4b750 --- /dev/null +++ b/templates/web-angular/pubspec.yaml @@ -0,0 +1,8 @@ +name: __projectName__ +version: 0.0.1 +dependencies: + angular2: 2.0.0-alpha.47 + browser: ^0.10.0 +transformers: +- angular2: + entry_points: web/main.dart diff --git a/templates/web-angular/web/index.html b/templates/web-angular/web/index.html new file mode 100644 index 00000000..2d1c4179 --- /dev/null +++ b/templates/web-angular/web/index.html @@ -0,0 +1,12 @@ + + + + __projectName__ + + + + + + Loading... + + diff --git a/templates/web-angular/web/main.dart b/templates/web-angular/web/main.dart new file mode 100644 index 00000000..a687cace --- /dev/null +++ b/templates/web-angular/web/main.dart @@ -0,0 +1,12 @@ +// Copyright (c) __year__, __author__. All rights reserved. Use of this source code +// is governed by a BSD-style license that can be found in the LICENSE file. + +library __projectName__.web; + +import 'package:angular2/bootstrap.dart'; + +import 'package:__projectName__/app_component.dart'; + +main() { + bootstrap(AppComponent); +}