diff --git a/AUTHORS b/AUTHORS index 8326d6f4..84049e32 100644 --- a/AUTHORS +++ b/AUTHORS @@ -6,3 +6,4 @@ Google Inc. Seth Ladd Devon Carew +Sungguk Lim diff --git a/lib/src/cli_app.dart b/lib/src/cli_app.dart index a63a34be..204e1d7d 100644 --- a/lib/src/cli_app.dart +++ b/lib/src/cli_app.dart @@ -10,16 +10,19 @@ import 'dart:io' as io; import 'dart:math'; import 'package:args/args.dart'; +import 'package:http/http.dart' as http; import 'package:path/path.dart' as path; -import 'package:stagehand/stagehand.dart'; import 'package:stagehand/analytics/analytics_io.dart'; import 'package:stagehand/src/common.dart'; +import 'package:stagehand/stagehand.dart'; const String APP_NAME = 'stagehand'; // This version must be updated in tandem with the pubspec version. const String APP_VERSION = '0.1.5+1'; +const String APP_PUB_INFO = 'https://pub.dartlang.org/packages/stagehand.json'; + // The Google Analytics tracking ID for stagehand. const String _GA_TRACKING_ID = 'UA-55033590-1'; @@ -84,8 +87,14 @@ class CliApp { } if (options['version']) { - _out('${APP_NAME} version ${APP_VERSION}'); - return new Future.value(); + _out('${APP_NAME} version: ${APP_VERSION}'); + return http.get(APP_PUB_INFO).then((response) { + List versions = JSON.decode(response.body)['versions']; + if (APP_VERSION != versions.last) { + _out("Version ${versions.last} is available! Run `pub global activate" + " stagehand` to get the latest."); + } + }).catchError((e) => null); } if (options['help'] || args.isEmpty) { diff --git a/pubspec.yaml b/pubspec.yaml index 7f9fc60e..d6dc5208 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,8 +19,9 @@ executables: dependencies: args: ">=0.12.0+1 <0.13.0" - path: ">=1.3.0 <2.0.0" crypto: ">=0.9.0 <0.10.0" + http: ">=0.11.0 <0.12.0" + path: ">=1.3.0 <2.0.0" uuid: ">=0.4.0 <0.5.0" dev_dependencies: