From 6f5b4624b434149d9f071bd314506bc5c5585c9b Mon Sep 17 00:00:00 2001 From: thosakwe Date: Thu, 15 Jun 2017 22:57:35 -0400 Subject: [PATCH] 1.1.4 --- .idea/runConfigurations/Version.xml | 7 +++++++ bin/angel.dart | 3 ++- lib/src/commands/commands.dart | 3 ++- lib/src/commands/init.dart | 12 +----------- lib/src/commands/pub.dart | 13 +++++++++++++ lib/src/commands/pubspec.update.g.dart | 2 +- lib/src/commands/rename.dart | 3 ++- lib/src/commands/start.dart | 4 ++-- lib/src/commands/update.dart | 4 ++-- lib/src/commands/version.dart | 13 +++++++++++++ pubspec.yaml | 2 +- 11 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 .idea/runConfigurations/Version.xml create mode 100644 lib/src/commands/pub.dart create mode 100644 lib/src/commands/version.dart diff --git a/.idea/runConfigurations/Version.xml b/.idea/runConfigurations/Version.xml new file mode 100644 index 00000000..cd70052b --- /dev/null +++ b/.idea/runConfigurations/Version.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/bin/angel.dart b/bin/angel.dart index ee16c084..97f470fb 100644 --- a/bin/angel.dart +++ b/bin/angel.dart @@ -21,7 +21,8 @@ main(List args) async { ..addCommand(new PluginCommand()) ..addCommand(new StartCommand()) ..addCommand(new RenameCommand()) - ..addCommand(new UpdateCommand()); + ..addCommand(new UpdateCommand()) + ..addCommand(new VersionCommand()); return await runner.run(args).then((_) {}).catchError((exc) { stderr.writeln("Oops, something went wrong: $exc"); diff --git a/lib/src/commands/commands.dart b/lib/src/commands/commands.dart index 43ab86ed..4264689c 100644 --- a/lib/src/commands/commands.dart +++ b/lib/src/commands/commands.dart @@ -9,4 +9,5 @@ export "rename.dart"; export "service.dart"; export "start.dart"; export "test.dart"; -export 'update.dart'; \ No newline at end of file +export 'update.dart'; +export 'version.dart'; \ No newline at end of file diff --git a/lib/src/commands/init.dart b/lib/src/commands/init.dart index 6de7436c..a7b3f6f5 100644 --- a/lib/src/commands/init.dart +++ b/lib/src/commands/init.dart @@ -4,10 +4,9 @@ import "package:console/console.dart"; import 'package:random_string/random_string.dart' as rs; import 'package:path/path.dart' as p; import 'key.dart'; +import 'pub.dart'; import 'rename.dart'; -final RegExp _leadingSlashes = new RegExp(r'^/+'); - class InitCommand extends Command { final KeyCommand _key = new KeyCommand(); final TextPen _pen = new TextPen(); @@ -149,15 +148,6 @@ class InitCommand extends Command { } } - static String resolvePub() { - var exec = new File(Platform.resolvedExecutable); - var pubPath = exec.parent.uri.resolve('pub').path; - if (Platform.isWindows) - pubPath = pubPath.replaceAll(_leadingSlashes, '') + '.bat'; - pubPath = Uri.decodeFull(pubPath); - return pubPath; - } - _pubGet(Directory projectDir) async { var pubPath = resolvePub(); print('Running pub at "$pubPath"...'); diff --git a/lib/src/commands/pub.dart b/lib/src/commands/pub.dart new file mode 100644 index 00000000..113c8b33 --- /dev/null +++ b/lib/src/commands/pub.dart @@ -0,0 +1,13 @@ +import 'dart:io'; + +final RegExp _leadingSlashes = new RegExp(r'^/+'); + + + String resolvePub() { +var exec = new File(Platform.resolvedExecutable); +var pubPath = exec.parent.uri.resolve('pub').path; +if (Platform.isWindows) +pubPath = pubPath.replaceAll(_leadingSlashes, '') + '.bat'; +pubPath = Uri.decodeFull(pubPath); +return pubPath; +} \ No newline at end of file diff --git a/lib/src/commands/pubspec.update.g.dart b/lib/src/commands/pubspec.update.g.dart index 4207fb77..0aa8ac8f 100644 --- a/lib/src/commands/pubspec.update.g.dart +++ b/lib/src/commands/pubspec.update.g.dart @@ -3,7 +3,7 @@ import 'dart:convert'; import 'package:http/src/base_client.dart' as http; import 'package:pub_semver/pub_semver.dart'; -final Version PACKAGE_VERSION = new Version(1, 1, 3); +final Version PACKAGE_VERSION = new Version(1, 1, 4); Future fetchCurrentVersion(http.BaseClient client) async { var response = await client.get('https://pub.dartlang.org/api/packages/angel_cli'); diff --git a/lib/src/commands/rename.dart b/lib/src/commands/rename.dart index 1eee74aa..c3544e76 100644 --- a/lib/src/commands/rename.dart +++ b/lib/src/commands/rename.dart @@ -3,6 +3,7 @@ import 'package:analyzer/analyzer.dart'; import 'package:args/command_runner.dart'; import 'package:console/console.dart'; import 'package:pubspec/pubspec.dart'; +import 'pub.dart'; class RenameCommand extends Command { @override @@ -42,7 +43,7 @@ class RenameCommand extends Command { await renamePubspec(Directory.current, oldName, newName); await renameDartFiles(Directory.current, oldName, newName); print('Now running `pub get`...'); - var pub = await Process.start('pub', ['get']); + var pub = await Process.start(resolvePub(), ['get']); stdout.addStream(pub.stdout); stderr.addStream(pub.stderr); await pub.exitCode; diff --git a/lib/src/commands/start.dart b/lib/src/commands/start.dart index b37a665b..f1fac21a 100644 --- a/lib/src/commands/start.dart +++ b/lib/src/commands/start.dart @@ -3,7 +3,7 @@ import 'dart:io'; import 'package:args/command_runner.dart'; import 'package:watcher/watcher.dart'; import 'package:yaml/yaml.dart'; -import 'init.dart'; +import 'pub.dart'; Process server; bool watching = false; @@ -85,7 +85,7 @@ class StartCommand extends Command { if (scriptsNode != null && scriptsNode.containsKey('start')) { try { var scripts = await Process.start( - InitCommand.resolvePub(), ['global', 'run', 'scripts', 'start']); + resolvePub(), ['global', 'run', 'scripts', 'start']); listen(scripts.stdout, stdout); listen(scripts.stderr, stderr); int code = await scripts.exitCode; diff --git a/lib/src/commands/update.dart b/lib/src/commands/update.dart index 8f17b579..5eadffc4 100644 --- a/lib/src/commands/update.dart +++ b/lib/src/commands/update.dart @@ -2,8 +2,8 @@ import 'dart:io'; import 'package:args/command_runner.dart'; import 'package:console/console.dart'; import 'package:http/http.dart' as http; -import 'init.dart'; import 'pubspec.update.g.dart'; +import 'pub.dart'; class UpdateCommand extends Command { @override @@ -40,7 +40,7 @@ class UpdateCommand extends Command { pen(); stdout.writeln(); } else { - var pubPath = InitCommand.resolvePub(); + var pubPath = resolvePub(); print('Running `pub global activate` using $pubPath...'); var p = await Process.start(pubPath, ['global', 'activate', 'angel_cli']); diff --git a/lib/src/commands/version.dart b/lib/src/commands/version.dart new file mode 100644 index 00000000..4d265991 --- /dev/null +++ b/lib/src/commands/version.dart @@ -0,0 +1,13 @@ +import 'package:args/command_runner.dart'; +import 'pubspec.update.g.dart'; + +class VersionCommand extends Command { + @override + String get name => 'version'; + + @override + String get description => 'Prints the currently-installed version of the Angel CLI.'; + + @override + run() => print('Angel CLI version $PACKAGE_VERSION'); +} \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index b7677786..ab99f0a4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ author: "Tobe O " description: "Command-line tools for the Angel framework." homepage: "https://github.com/angel-dart/angel_cli" name: "angel_cli" -version: 1.1.3 +version: 1.1.4 dependencies: # analyzer: "^0.29.0" args: ^0.13.4