From 1675cbd701cd4bb3a8985451473ab94bf6752878 Mon Sep 17 00:00:00 2001 From: thosakwe Date: Wed, 26 Apr 2017 09:21:25 -0400 Subject: [PATCH] Bugfixes --- .idea/angel_cli.iml | 2 +- lib/src/commands/init.dart | 3 +++ lib/src/commands/service.dart | 4 ++-- lib/src/commands/service_generators/map.dart | 4 ++-- .../commands/service_generators/mongo.dart | 3 +++ .../commands/service_generators/rethink.dart | 3 +++ lib/src/commands/start.dart | 20 ++++++++++++++++--- pubspec.yaml | 2 +- 8 files changed, 32 insertions(+), 9 deletions(-) diff --git a/.idea/angel_cli.iml b/.idea/angel_cli.iml index e673c03..0a2188d 100644 --- a/.idea/angel_cli.iml +++ b/.idea/angel_cli.iml @@ -6,7 +6,6 @@ - @@ -17,6 +16,7 @@ + diff --git a/lib/src/commands/init.dart b/lib/src/commands/init.dart index 744ca6d..59f435b 100644 --- a/lib/src/commands/init.dart +++ b/lib/src/commands/init.dart @@ -6,6 +6,8 @@ import 'package:path/path.dart' as p; import 'key.dart'; import 'rename.dart'; +final RegExp _leadingSlashes = new RegExp(r'^/+'); + class InitCommand extends Command { final KeyCommand _key = new KeyCommand(); final TextPen _pen = new TextPen(); @@ -143,6 +145,7 @@ class InitCommand extends Command { _pubGet(Directory projectDir) async { var exec = new File(Platform.resolvedExecutable); var pubPath = exec.parent.uri.resolve('pub').path; + if (Platform.isWindows) pubPath = pubPath.replaceAll(_leadingSlashes, ''); print('Running pub at "$pubPath"...'); var pub = await Process.start(pubPath, ["get"], workingDirectory: projectDir.absolute.path); diff --git a/lib/src/commands/service.dart b/lib/src/commands/service.dart index f65e293..c5c682f 100644 --- a/lib/src/commands/service.dart +++ b/lib/src/commands/service.dart @@ -107,7 +107,7 @@ class ServiceCommand extends Command { new ImportBuilder('package:angel_common/angel_common.dart')); generator.applyToLibrary(lib, name, lower); - if (generator.createsModel == true) { + if (generator.createsModel == true || typed) { lib ..addMember(new ImportBuilder('../models/$lower.dart')) ..addMember(new ExportBuilder('../models/$lower.dart')); @@ -180,7 +180,7 @@ class $name extends Model { if (!await file.exists()) await file.createSync(recursive: true); await file.writeAsString(''' -library ${pubspec.name}.models.$lower; +library ${pubspec.name}.validtors.$lower; import 'package:angel_validate/angel_validate.dart'; final Validator $constantCase = new Validator({ diff --git a/lib/src/commands/service_generators/map.dart b/lib/src/commands/service_generators/map.dart index d0f7eb4..ec7b149 100644 --- a/lib/src/commands/service_generators/map.dart +++ b/lib/src/commands/service_generators/map.dart @@ -2,11 +2,11 @@ import 'generator.dart'; import 'package:code_builder/code_builder.dart'; class MapServiceGenerator extends ServiceGenerator { + const MapServiceGenerator() : super('In-Memory'); + @override bool get createsModel => false; - const MapServiceGenerator() : super('In-Memory'); - @override ExpressionBuilder createInstance( MethodBuilder methodBuilder, String name, String lower) { diff --git a/lib/src/commands/service_generators/mongo.dart b/lib/src/commands/service_generators/mongo.dart index af15f74..16e7c36 100644 --- a/lib/src/commands/service_generators/mongo.dart +++ b/lib/src/commands/service_generators/mongo.dart @@ -5,6 +5,9 @@ import 'package:inflection/inflection.dart'; class MongoServiceGenerator extends ServiceGenerator { const MongoServiceGenerator() : super('MongoDB'); + @override + bool get createsModel => false; + @override void applyToConfigureServer( MethodBuilder configureServer, String name, String lower) { diff --git a/lib/src/commands/service_generators/rethink.dart b/lib/src/commands/service_generators/rethink.dart index 71d6acc..22d0bd6 100644 --- a/lib/src/commands/service_generators/rethink.dart +++ b/lib/src/commands/service_generators/rethink.dart @@ -5,6 +5,9 @@ import 'package:inflection/inflection.dart'; class RethinkServiceGenerator extends ServiceGenerator { const RethinkServiceGenerator() : super('RethinkDB'); + @override + bool get createsModel => false; + @override void applyToConfigureServer( MethodBuilder configureServer, String name, String lower) { diff --git a/lib/src/commands/start.dart b/lib/src/commands/start.dart index 02ac0c0..f9af79b 100644 --- a/lib/src/commands/start.dart +++ b/lib/src/commands/start.dart @@ -34,9 +34,23 @@ class StartCommand extends Command { @override run() async { if (argResults['watch']) { - new DirectoryWatcher('bin').events.listen((_) async => start()); - new DirectoryWatcher('config').events.listen((_) async => start()); - new DirectoryWatcher('lib').events.listen((_) async => start()); + try { + new DirectoryWatcher('bin').events.listen((_) async => start()); + } catch (e) { + // Fail silently... + } + + try { + new DirectoryWatcher('config').events.listen((_) async => start()); + } catch (e) { + // Fail silently... + } + + try { + new DirectoryWatcher('lib').events.listen((_) async => start()); + } catch (e) { + // Fail silently... + } } return await start(); diff --git a/pubspec.yaml b/pubspec.yaml index 8706e71..bbb0ff9 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.0.10 +version: 1.0.11 dependencies: # analyzer: "^0.29.0" args: "^0.13.7"