Update to 2.1.7

This commit is contained in:
thosakwe 2019-07-17 11:18:49 -04:00
parent cf1b813578
commit 427f81ee49
13 changed files with 60 additions and 51 deletions

View file

@ -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 # 2.1.6
* Fix a bug where models always defaulted to ORM. * Fix a bug where models always defaulted to ORM.
* Add GraphQL boilerplate. * Add GraphQL boilerplate.

View file

@ -31,7 +31,7 @@ class InitCommand extends Command {
@override @override
run() async { run() async {
Directory projectDir = new Directory( 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}..."); print("Creating new Angel project in ${projectDir.absolute.path}...");
await _cloneRepo(projectDir); await _cloneRepo(projectDir);
// await preBuild(projectDir); // await preBuild(projectDir);

View file

@ -40,7 +40,7 @@ class ControllerCommand extends Command {
} }
List<MakerDependency> deps = [ List<MakerDependency> deps = [
const MakerDependency('angel_framework', '^1.0.0') const MakerDependency('angel_framework', '^2.0.0')
]; ];
// ${pubspec.name}.src.models.${rc.snakeCase} // ${pubspec.name}.src.models.${rc.snakeCase}
@ -48,7 +48,7 @@ class ControllerCommand extends Command {
var rc = new ReCase(name); var rc = new ReCase(name);
var controllerLib = new Library((controllerLib) { var controllerLib = new Library((controllerLib) {
if (argResults['websocket'] as bool) { 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 controllerLib.directives
.add(new Directive.import('package:angel_websocket/server.dart')); .add(new Directive.import('package:angel_websocket/server.dart'));
} else { } else {

View file

@ -2,11 +2,14 @@ import 'dart:async';
import 'package:io/ansi.dart'; import 'package:io/ansi.dart';
import '../../util.dart'; import '../../util.dart';
class MakerDependency { class MakerDependency implements Comparable<MakerDependency> {
final String name, version; final String name, version;
final bool dev; final bool dev;
const MakerDependency(this.name, this.version, {this.dev: false}); const MakerDependency(this.name, this.version, {this.dev: false});
@override
int compareTo(MakerDependency other) => name.compareTo(other.name);
} }
Future depend(Iterable<MakerDependency> deps) async { Future depend(Iterable<MakerDependency> deps) async {
@ -21,6 +24,7 @@ Future depend(Iterable<MakerDependency> deps) async {
isPresent = pubspec.dependencies.containsKey(dep.name); isPresent = pubspec.dependencies.containsKey(dep.name);
if (!isPresent) { if (!isPresent) {
missing.add(dep);
// TODO: https://github.com/dart-lang/pubspec_parse/issues/17: // TODO: https://github.com/dart-lang/pubspec_parse/issues/17:
// print('Installing ${dep.name}@${dep.version}...'); // print('Installing ${dep.name}@${dep.version}...');
// //
@ -36,33 +40,28 @@ Future depend(Iterable<MakerDependency> deps) async {
} }
} }
missing.sort((a, b) { var missingDeps = deps.where((d) => !d.dev).toList()..sort();
if (!a.dev) { var missingDevDeps = deps.where((d) => d.dev).toList()..sort();
if (b.dev) {
return -1; if (missingDeps.isNotEmpty || missingDevDeps.isNotEmpty) {
} else { var totalCount = missingDeps.length + missingDevDeps.length;
return 0; print(yellow.wrap(totalCount == 1
} ? 'You are missing one dependency.'
} else { : 'You are missing ${missing.length} dependencies.'));
if (b.dev) { print(yellow.wrap(
return 0; 'Update your `pubspec.yaml` to add the following dependencies:\n'));
} else {
return 1; void printMissing(String type, Iterable<MakerDependency> deps) {
if (deps.isNotEmpty) {
print(yellow.wrap(' $type:'));
for (var dep in deps) {
print(yellow.wrap(' ${dep.name}: ${dep.version}'));
}
} }
} }
});
if (missing.isNotEmpty) { printMissing('dependencies', missingDeps);
print(yellow.wrap(missing.length == 1 printMissing('dev_dependencies', missingDevDeps);
? '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));
}
} }
// if (isPresent) { // if (isPresent) {

View file

@ -35,7 +35,7 @@ class MigrationCommand extends Command {
name = prompts.get('Name of model class'); 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 rc = new ReCase(name);
var migrationLib = new Library((migrationLib) { var migrationLib = new Library((migrationLib) {

View file

@ -20,7 +20,7 @@ class ModelCommand extends Command {
..addFlag('migration', ..addFlag('migration',
abbr: 'm', abbr: 'm',
help: 'Generate migrations when running `build_runner`.', help: 'Generate migrations when running `build_runner`.',
negatable: false) defaultsTo: true)
..addFlag('orm', help: 'Generate angel_orm code.', negatable: false) ..addFlag('orm', help: 'Generate angel_orm code.', negatable: false)
..addFlag('serializable', ..addFlag('serializable',
help: 'Generate angel_serialize annotations.', defaultsTo: true) help: 'Generate angel_serialize annotations.', defaultsTo: true)
@ -47,33 +47,35 @@ class ModelCommand extends Command {
var rc = new ReCase(name); var rc = new ReCase(name);
var modelLib = new Library((modelLib) { var modelLib = new Library((modelLib) {
if (argResults['migration'] as bool) { if (argResults['orm'] as bool && argResults['migration'] as bool) {
modelLib.directives.addAll([ modelLib.directives.addAll([
new Directive.import('package:angel_migration/angel_migration.dart'), new Directive.import('package:angel_migration/angel_migration.dart'),
]); ]);
} }
var needsSerialize = argResults['serializable'] as bool || var needsSerialize =
argResults['orm'] as bool || argResults['serializable'] as bool || argResults['orm'] as bool;
argResults['migration'] as bool; // argResults['migration'] as bool;
if (needsSerialize) { if (needsSerialize) {
modelLib.directives.add(new Directive.import( modelLib.directives.add(new Directive.import(
'package:angel_serialize/angel_serialize.dart')); 'package:angel_serialize/angel_serialize.dart'));
deps.add(const MakerDependency('angel_serialize', '^2.0.0')); deps.add(const MakerDependency('angel_serialize', '^2.0.0'));
deps.add(const MakerDependency('angel_serialize_generator', '^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"')); deps.add(const MakerDependency('build_runner', '^1.0.0'));
} 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 || 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([ modelLib.directives.addAll([
new Directive.import('package:angel_orm/angel_orm.dart'), 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([ modelLib.body.addAll([
@ -91,7 +93,7 @@ class ModelCommand extends Command {
modelClazz.annotations.add(refer('serializable')); modelClazz.annotations.add(refer('serializable'));
} }
if (argResults['orm'] as bool || argResults['migration'] as bool) { if (argResults['orm'] as bool) {
if (argResults['migration'] as bool) { if (argResults['migration'] as bool) {
modelClazz.annotations.add(refer('orm')); modelClazz.annotations.add(refer('orm'));
} else { } else {

View file

@ -35,7 +35,7 @@ class PluginCommand extends Command {
} }
List<MakerDependency> deps = [ List<MakerDependency> deps = [
const MakerDependency('angel_framework', '^1.0.0') const MakerDependency('angel_framework', '^2.0.0')
]; ];
var rc = new ReCase(name); var rc = new ReCase(name);

View file

@ -42,7 +42,7 @@ class ServiceCommand extends Command {
} }
List<MakerDependency> deps = [ List<MakerDependency> deps = [
const MakerDependency('angel_framework', '^1.0.0') const MakerDependency('angel_framework', '^2.0.0')
]; ];
// '${pubspec.name}.src.services.${rc.snakeCase}' // '${pubspec.name}.src.services.${rc.snakeCase}'

View file

@ -38,9 +38,9 @@ class TestCommand extends Command {
} }
List<MakerDependency> deps = [ List<MakerDependency> deps = [
const MakerDependency('angel_framework', '^1.0.0'), const MakerDependency('angel_framework', '^2.0.0'),
const MakerDependency('angel_test', '^1.0.0', dev: true), const MakerDependency('angel_test', '^2.0.0', dev: true),
const MakerDependency('test', '^0.12.0', dev: true), const MakerDependency('test', '^1.0.0', dev: true),
]; ];
var rc = new ReCase(name); var rc = new ReCase(name);

View file

@ -8,7 +8,7 @@ class FileServiceGenerator extends ServiceGenerator {
@override @override
List<MakerDependency> get dependencies => List<MakerDependency> get dependencies =>
const [const MakerDependency('angel_file_service', '^1.0.0')]; const [const MakerDependency('angel_file_service', '^2.0.0')];
@override @override
bool get goesFirst => true; bool get goesFirst => true;

View file

@ -8,7 +8,7 @@ class MongoServiceGenerator extends ServiceGenerator {
@override @override
List<MakerDependency> get dependencies => List<MakerDependency> get dependencies =>
const [const MakerDependency('angel_mongo', '^1.0.0')]; const [const MakerDependency('angel_mongo', '^2.0.0')];
@override @override
bool get createsModel => false; bool get createsModel => false;

View file

@ -8,7 +8,7 @@ class RethinkServiceGenerator extends ServiceGenerator {
@override @override
List<MakerDependency> get dependencies => List<MakerDependency> get dependencies =>
const [const MakerDependency('angel_rethink', '^1.0.0')]; const [const MakerDependency('angel_rethink', '^2.0.0')];
@override @override
bool get createsModel => false; bool get createsModel => false;

View file

@ -2,7 +2,7 @@ author: Tobe O <thosakwe@gmail.com>
description: Command-line tools for the Angel framework, including scaffolding. description: Command-line tools for the Angel framework, including scaffolding.
homepage: https://github.com/angel-dart/angel_cli homepage: https://github.com/angel-dart/angel_cli
name: angel_cli name: angel_cli
version: 2.1.6 version: 2.1.7
dependencies: dependencies:
analyzer: ">=0.32.0 <2.0.0" analyzer: ">=0.32.0 <2.0.0"
args: ^1.0.0 args: ^1.0.0