Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
Merge pull request #181 from sunglim/version_check
Browse files Browse the repository at this point in the history
--version checks latest version
  • Loading branch information
devoncarew committed Dec 17, 2014
2 parents 01015b0 + d424b72 commit 5e8a2b3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
Google Inc.
Seth Ladd <[email protected]>
Devon Carew <[email protected]>
Sungguk Lim <[email protected]>
15 changes: 12 additions & 3 deletions lib/src/cli_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5e8a2b3

Please sign in to comment.