diff --git a/CHANGELOG.md b/CHANGELOG.md index bf20d590..8816e2db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# 2.1.7 +* Fix a bug where `ArgResults.arguments` was used in `init` instead of the +intended `ArgResults.rest`. +* Stop including `package:angel_model` imports in `make model`. +* Update dependencies in `make` commands. +* Fix `make model` to generate ORM + migration by default. +* Fix `MakerDependency` logic to print missing dependencies. + # 2.1.6 * Fix a bug where models always defaulted to ORM. * Add GraphQL boilerplate. diff --git a/lib/src/commands/init.dart b/lib/src/commands/init.dart index 6e809774..2676c2cd 100644 --- a/lib/src/commands/init.dart +++ b/lib/src/commands/init.dart @@ -31,7 +31,7 @@ class InitCommand extends Command { @override run() async { Directory projectDir = new Directory( - argResults.arguments.isEmpty ? "." : argResults.arguments[0]); + argResults.rest.isEmpty ? "." : argResults.rest[0]); print("Creating new Angel project in ${projectDir.absolute.path}..."); await _cloneRepo(projectDir); // await preBuild(projectDir); diff --git a/lib/src/commands/make/controller.dart b/lib/src/commands/make/controller.dart index f5746d64..209aa401 100644 --- a/lib/src/commands/make/controller.dart +++ b/lib/src/commands/make/controller.dart @@ -40,7 +40,7 @@ class ControllerCommand extends Command { } List deps = [ - const MakerDependency('angel_framework', '^1.0.0') + const MakerDependency('angel_framework', '^2.0.0') ]; // ${pubspec.name}.src.models.${rc.snakeCase} @@ -48,7 +48,7 @@ class ControllerCommand extends Command { var rc = new ReCase(name); var controllerLib = new Library((controllerLib) { if (argResults['websocket'] as bool) { - deps.add(const MakerDependency('angel_websocket', '^1.0.0')); + deps.add(const MakerDependency('angel_websocket', '^2.0.0')); controllerLib.directives .add(new Directive.import('package:angel_websocket/server.dart')); } else { diff --git a/lib/src/commands/make/maker.dart b/lib/src/commands/make/maker.dart index 25b82795..38c57121 100644 --- a/lib/src/commands/make/maker.dart +++ b/lib/src/commands/make/maker.dart @@ -2,11 +2,14 @@ import 'dart:async'; import 'package:io/ansi.dart'; import '../../util.dart'; -class MakerDependency { +class MakerDependency implements Comparable { final String name, version; final bool dev; const MakerDependency(this.name, this.version, {this.dev: false}); + + @override + int compareTo(MakerDependency other) => name.compareTo(other.name); } Future depend(Iterable deps) async { @@ -21,6 +24,7 @@ Future depend(Iterable deps) async { isPresent = pubspec.dependencies.containsKey(dep.name); if (!isPresent) { + missing.add(dep); // TODO: https://github.com/dart-lang/pubspec_parse/issues/17: // print('Installing ${dep.name}@${dep.version}...'); // @@ -36,33 +40,28 @@ Future depend(Iterable deps) async { } } - missing.sort((a, b) { - if (!a.dev) { - if (b.dev) { - return -1; - } else { - return 0; - } - } else { - if (b.dev) { - return 0; - } else { - return 1; + var missingDeps = deps.where((d) => !d.dev).toList()..sort(); + var missingDevDeps = deps.where((d) => d.dev).toList()..sort(); + + if (missingDeps.isNotEmpty || missingDevDeps.isNotEmpty) { + var totalCount = missingDeps.length + missingDevDeps.length; + print(yellow.wrap(totalCount == 1 + ? 'You are missing one dependency.' + : 'You are missing ${missing.length} dependencies.')); + print(yellow.wrap( + 'Update your `pubspec.yaml` to add the following dependencies:\n')); + + void printMissing(String type, Iterable deps) { + if (deps.isNotEmpty) { + print(yellow.wrap(' $type:')); + for (var dep in deps) { + print(yellow.wrap(' ${dep.name}: ${dep.version}')); + } } } - }); - if (missing.isNotEmpty) { - print(yellow.wrap(missing.length == 1 - ? 'You are missing one dependency:' - : 'You are missing ${missing.length} dependencies:')); - print('\n'); - - for (var dep in missing) { - var m = ' * ${dep.name}@${dep.version}'; - if (dep.dev) m += ' (dev dependency)'; - print(yellow.wrap(m)); - } + printMissing('dependencies', missingDeps); + printMissing('dev_dependencies', missingDevDeps); } // if (isPresent) { diff --git a/lib/src/commands/make/migration.dart b/lib/src/commands/make/migration.dart index 58200996..a5792b0c 100644 --- a/lib/src/commands/make/migration.dart +++ b/lib/src/commands/make/migration.dart @@ -35,7 +35,7 @@ class MigrationCommand extends Command { name = prompts.get('Name of model class'); } - var deps = [const MakerDependency('angel_migration', '^1.0.0-alpha')]; + var deps = [const MakerDependency('angel_migration', '^2.0.0')]; var rc = new ReCase(name); var migrationLib = new Library((migrationLib) { diff --git a/lib/src/commands/make/model.dart b/lib/src/commands/make/model.dart index 16762581..04e964c8 100644 --- a/lib/src/commands/make/model.dart +++ b/lib/src/commands/make/model.dart @@ -20,7 +20,7 @@ class ModelCommand extends Command { ..addFlag('migration', abbr: 'm', help: 'Generate migrations when running `build_runner`.', - negatable: false) + defaultsTo: true) ..addFlag('orm', help: 'Generate angel_orm code.', negatable: false) ..addFlag('serializable', help: 'Generate angel_serialize annotations.', defaultsTo: true) @@ -47,33 +47,35 @@ class ModelCommand extends Command { var rc = new ReCase(name); var modelLib = new Library((modelLib) { - if (argResults['migration'] as bool) { + if (argResults['orm'] as bool && argResults['migration'] as bool) { modelLib.directives.addAll([ new Directive.import('package:angel_migration/angel_migration.dart'), ]); } - var needsSerialize = argResults['serializable'] as bool || - argResults['orm'] as bool || - argResults['migration'] as bool; + var needsSerialize = + argResults['serializable'] as bool || argResults['orm'] as bool; + // argResults['migration'] as bool; if (needsSerialize) { modelLib.directives.add(new Directive.import( 'package:angel_serialize/angel_serialize.dart')); deps.add(const MakerDependency('angel_serialize', '^2.0.0')); deps.add(const MakerDependency('angel_serialize_generator', '^2.0.0')); - deps.add(const MakerDependency('build_runner', '">=0.7.0 <0.10.0"')); - } else { - modelLib.directives - .add(new Directive.import('package:angel_model/angel_model.dart')); - deps.add(const MakerDependency('angel_model', '^1.0.0')); + deps.add(const MakerDependency('build_runner', '^1.0.0')); } - if (argResults['orm'] as bool || argResults['migration'] as bool) { + // else { + // modelLib.directives + // .add(new Directive.import('package:angel_model/angel_model.dart')); + // deps.add(const MakerDependency('angel_model', '^1.0.0')); + // } + + if (argResults['orm'] as bool) { modelLib.directives.addAll([ new Directive.import('package:angel_orm/angel_orm.dart'), ]); - deps.add(const MakerDependency('angel_orm', '^1.0.0-alpha')); + deps.add(const MakerDependency('angel_orm', '^2.0.0')); } modelLib.body.addAll([ @@ -91,7 +93,7 @@ class ModelCommand extends Command { modelClazz.annotations.add(refer('serializable')); } - if (argResults['orm'] as bool || argResults['migration'] as bool) { + if (argResults['orm'] as bool) { if (argResults['migration'] as bool) { modelClazz.annotations.add(refer('orm')); } else { diff --git a/lib/src/commands/make/plugin.dart b/lib/src/commands/make/plugin.dart index cfccbfe9..4f979777 100644 --- a/lib/src/commands/make/plugin.dart +++ b/lib/src/commands/make/plugin.dart @@ -35,7 +35,7 @@ class PluginCommand extends Command { } List deps = [ - const MakerDependency('angel_framework', '^1.0.0') + const MakerDependency('angel_framework', '^2.0.0') ]; var rc = new ReCase(name); diff --git a/lib/src/commands/make/service.dart b/lib/src/commands/make/service.dart index 2d99e6d9..a21d07f1 100644 --- a/lib/src/commands/make/service.dart +++ b/lib/src/commands/make/service.dart @@ -42,7 +42,7 @@ class ServiceCommand extends Command { } List deps = [ - const MakerDependency('angel_framework', '^1.0.0') + const MakerDependency('angel_framework', '^2.0.0') ]; // '${pubspec.name}.src.services.${rc.snakeCase}' diff --git a/lib/src/commands/make/test.dart b/lib/src/commands/make/test.dart index d95db4ff..32adcd7f 100644 --- a/lib/src/commands/make/test.dart +++ b/lib/src/commands/make/test.dart @@ -38,9 +38,9 @@ class TestCommand extends Command { } List deps = [ - const MakerDependency('angel_framework', '^1.0.0'), - const MakerDependency('angel_test', '^1.0.0', dev: true), - const MakerDependency('test', '^0.12.0', dev: true), + const MakerDependency('angel_framework', '^2.0.0'), + const MakerDependency('angel_test', '^2.0.0', dev: true), + const MakerDependency('test', '^1.0.0', dev: true), ]; var rc = new ReCase(name); diff --git a/lib/src/commands/service_generators/file_service.dart b/lib/src/commands/service_generators/file_service.dart index 673fe12d..39e1086e 100644 --- a/lib/src/commands/service_generators/file_service.dart +++ b/lib/src/commands/service_generators/file_service.dart @@ -8,7 +8,7 @@ class FileServiceGenerator extends ServiceGenerator { @override List get dependencies => - const [const MakerDependency('angel_file_service', '^1.0.0')]; + const [const MakerDependency('angel_file_service', '^2.0.0')]; @override bool get goesFirst => true; diff --git a/lib/src/commands/service_generators/mongo.dart b/lib/src/commands/service_generators/mongo.dart index bb6a45f4..d8d2f0d3 100644 --- a/lib/src/commands/service_generators/mongo.dart +++ b/lib/src/commands/service_generators/mongo.dart @@ -8,7 +8,7 @@ class MongoServiceGenerator extends ServiceGenerator { @override List get dependencies => - const [const MakerDependency('angel_mongo', '^1.0.0')]; + const [const MakerDependency('angel_mongo', '^2.0.0')]; @override bool get createsModel => false; diff --git a/lib/src/commands/service_generators/rethink.dart b/lib/src/commands/service_generators/rethink.dart index 313cbc2d..57059844 100644 --- a/lib/src/commands/service_generators/rethink.dart +++ b/lib/src/commands/service_generators/rethink.dart @@ -8,7 +8,7 @@ class RethinkServiceGenerator extends ServiceGenerator { @override List get dependencies => - const [const MakerDependency('angel_rethink', '^1.0.0')]; + const [const MakerDependency('angel_rethink', '^2.0.0')]; @override bool get createsModel => false; diff --git a/pubspec.yaml b/pubspec.yaml index 27a1bde6..d024c561 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ author: Tobe O description: Command-line tools for the Angel framework, including scaffolding. homepage: https://github.com/angel-dart/angel_cli name: angel_cli -version: 2.1.6 +version: 2.1.7 dependencies: analyzer: ">=0.32.0 <2.0.0" args: ^1.0.0