This commit is contained in:
thosakwe 2017-06-15 22:57:35 -04:00
parent 2414886c2a
commit 6f5b4624b4
11 changed files with 46 additions and 20 deletions

View file

@ -0,0 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Version" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true">
<option name="arguments" value="version" />
<option name="filePath" value="$PROJECT_DIR$/bin/angel.dart" />
<method />
</configuration>
</component>

View file

@ -21,7 +21,8 @@ main(List<String> args) async {
..addCommand(new PluginCommand()) ..addCommand(new PluginCommand())
..addCommand(new StartCommand()) ..addCommand(new StartCommand())
..addCommand(new RenameCommand()) ..addCommand(new RenameCommand())
..addCommand(new UpdateCommand()); ..addCommand(new UpdateCommand())
..addCommand(new VersionCommand());
return await runner.run(args).then((_) {}).catchError((exc) { return await runner.run(args).then((_) {}).catchError((exc) {
stderr.writeln("Oops, something went wrong: $exc"); stderr.writeln("Oops, something went wrong: $exc");

View file

@ -10,3 +10,4 @@ export "service.dart";
export "start.dart"; export "start.dart";
export "test.dart"; export "test.dart";
export 'update.dart'; export 'update.dart';
export 'version.dart';

View file

@ -4,10 +4,9 @@ import "package:console/console.dart";
import 'package:random_string/random_string.dart' as rs; import 'package:random_string/random_string.dart' as rs;
import 'package:path/path.dart' as p; import 'package:path/path.dart' as p;
import 'key.dart'; import 'key.dart';
import 'pub.dart';
import 'rename.dart'; import 'rename.dart';
final RegExp _leadingSlashes = new RegExp(r'^/+');
class InitCommand extends Command { class InitCommand extends Command {
final KeyCommand _key = new KeyCommand(); final KeyCommand _key = new KeyCommand();
final TextPen _pen = new TextPen(); 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 { _pubGet(Directory projectDir) async {
var pubPath = resolvePub(); var pubPath = resolvePub();
print('Running pub at "$pubPath"...'); print('Running pub at "$pubPath"...');

13
lib/src/commands/pub.dart Normal file
View file

@ -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;
}

View file

@ -3,7 +3,7 @@ import 'dart:convert';
import 'package:http/src/base_client.dart' as http; import 'package:http/src/base_client.dart' as http;
import 'package:pub_semver/pub_semver.dart'; 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<Version> fetchCurrentVersion(http.BaseClient client) async { Future<Version> fetchCurrentVersion(http.BaseClient client) async {
var response = var response =
await client.get('https://pub.dartlang.org/api/packages/angel_cli'); await client.get('https://pub.dartlang.org/api/packages/angel_cli');

View file

@ -3,6 +3,7 @@ import 'package:analyzer/analyzer.dart';
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:console/console.dart'; import 'package:console/console.dart';
import 'package:pubspec/pubspec.dart'; import 'package:pubspec/pubspec.dart';
import 'pub.dart';
class RenameCommand extends Command { class RenameCommand extends Command {
@override @override
@ -42,7 +43,7 @@ class RenameCommand extends Command {
await renamePubspec(Directory.current, oldName, newName); await renamePubspec(Directory.current, oldName, newName);
await renameDartFiles(Directory.current, oldName, newName); await renameDartFiles(Directory.current, oldName, newName);
print('Now running `pub get`...'); print('Now running `pub get`...');
var pub = await Process.start('pub', ['get']); var pub = await Process.start(resolvePub(), ['get']);
stdout.addStream(pub.stdout); stdout.addStream(pub.stdout);
stderr.addStream(pub.stderr); stderr.addStream(pub.stderr);
await pub.exitCode; await pub.exitCode;

View file

@ -3,7 +3,7 @@ import 'dart:io';
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:watcher/watcher.dart'; import 'package:watcher/watcher.dart';
import 'package:yaml/yaml.dart'; import 'package:yaml/yaml.dart';
import 'init.dart'; import 'pub.dart';
Process server; Process server;
bool watching = false; bool watching = false;
@ -85,7 +85,7 @@ class StartCommand extends Command {
if (scriptsNode != null && scriptsNode.containsKey('start')) { if (scriptsNode != null && scriptsNode.containsKey('start')) {
try { try {
var scripts = await Process.start( var scripts = await Process.start(
InitCommand.resolvePub(), ['global', 'run', 'scripts', 'start']); resolvePub(), ['global', 'run', 'scripts', 'start']);
listen(scripts.stdout, stdout); listen(scripts.stdout, stdout);
listen(scripts.stderr, stderr); listen(scripts.stderr, stderr);
int code = await scripts.exitCode; int code = await scripts.exitCode;

View file

@ -2,8 +2,8 @@ import 'dart:io';
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:console/console.dart'; import 'package:console/console.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'init.dart';
import 'pubspec.update.g.dart'; import 'pubspec.update.g.dart';
import 'pub.dart';
class UpdateCommand extends Command { class UpdateCommand extends Command {
@override @override
@ -40,7 +40,7 @@ class UpdateCommand extends Command {
pen(); pen();
stdout.writeln(); stdout.writeln();
} else { } else {
var pubPath = InitCommand.resolvePub(); var pubPath = resolvePub();
print('Running `pub global activate` using $pubPath...'); print('Running `pub global activate` using $pubPath...');
var p = var p =
await Process.start(pubPath, ['global', 'activate', 'angel_cli']); await Process.start(pubPath, ['global', 'activate', 'angel_cli']);

View file

@ -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');
}

View file

@ -2,7 +2,7 @@ author: "Tobe O <thosakwe@gmail.com>"
description: "Command-line tools for the Angel framework." description: "Command-line tools for the Angel framework."
homepage: "https://github.com/angel-dart/angel_cli" homepage: "https://github.com/angel-dart/angel_cli"
name: "angel_cli" name: "angel_cli"
version: 1.1.3 version: 1.1.4
dependencies: dependencies:
# analyzer: "^0.29.0" # analyzer: "^0.29.0"
args: ^0.13.4 args: ^0.13.4