From 2ead5af7ba7e7a58b20b54b86973795bdba988aa Mon Sep 17 00:00:00 2001 From: Sungguk Lim Date: Wed, 17 Dec 2014 21:03:03 +0900 Subject: [PATCH 1/4] --version checks latest version --- AUTHORS | 1 + lib/src/cli_app.dart | 14 +++++++++++--- pubspec.yaml | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) 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..88fc3eda 100644 --- a/lib/src/cli_app.dart +++ b/lib/src/cli_app.dart @@ -10,10 +10,11 @@ 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'; @@ -84,8 +85,15 @@ class CliApp { } if (options['version']) { - _out('${APP_NAME} version ${APP_VERSION}'); - return new Future.value(); + _out('${APP_NAME} version: ${APP_VERSION}'); + return http.get('https://pub.dartlang.org/packages/stagehand.json') + .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..9f31f844 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: From 78d4af5c1c5059a10460125f71092f3840e5d2fc Mon Sep 17 00:00:00 2001 From: Sungguk Lim Date: Wed, 17 Dec 2014 21:19:03 +0900 Subject: [PATCH 2/4] double quotes from pubspec --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 9f31f844..d6dc5208 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,7 +20,7 @@ executables: dependencies: args: ">=0.12.0+1 <0.13.0" crypto: ">=0.9.0 <0.10.0" - http: '>=0.11.0 <0.12.0' + http: ">=0.11.0 <0.12.0" path: ">=1.3.0 <2.0.0" uuid: ">=0.4.0 <0.5.0" From 55bbc390a3222ae99318a555f2288cce335ac181 Mon Sep 17 00:00:00 2001 From: Sungguk Lim Date: Wed, 17 Dec 2014 18:38:46 -0500 Subject: [PATCH 3/4] indent --- lib/src/cli_app.dart | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/src/cli_app.dart b/lib/src/cli_app.dart index 88fc3eda..2ae4ffce 100644 --- a/lib/src/cli_app.dart +++ b/lib/src/cli_app.dart @@ -19,7 +19,9 @@ 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_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'; @@ -86,13 +88,12 @@ class CliApp { if (options['version']) { _out('${APP_NAME} version: ${APP_VERSION}'); - return http.get('https://pub.dartlang.org/packages/stagehand.json') - .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."); - } + 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); } From d424b7227017a6dfe039e9d829f6206ff48e5141 Mon Sep 17 00:00:00 2001 From: Sungguk Lim Date: Wed, 17 Dec 2014 18:41:37 -0500 Subject: [PATCH 4/4] nit --- lib/src/cli_app.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/cli_app.dart b/lib/src/cli_app.dart index 2ae4ffce..204e1d7d 100644 --- a/lib/src/cli_app.dart +++ b/lib/src/cli_app.dart @@ -19,7 +19,7 @@ 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_VERSION = '0.1.5+1'; const String APP_PUB_INFO = 'https://pub.dartlang.org/packages/stagehand.json';