diff --git a/.idea/runConfigurations/Version.xml b/.idea/runConfigurations/Version.xml new file mode 100644 index 0000000..cd70052 --- /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 ee16c08..97f470f 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 43ab86e..4264689 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 6de7436..a7b3f6f 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 0000000..113c8b3 --- /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 4207fb7..0aa8ac8 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 1eee74a..c3544e7 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 b37a665..f1fac21 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 8f17b57..5eadffc 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 0000000..4d26599 --- /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 b767778..ab99f0a 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