From 1db250ca1640ea4fcb203529bb1fec6b3f3e0a17 Mon Sep 17 00:00:00 2001 From: thosakwe Date: Wed, 1 Mar 2017 22:31:00 -0500 Subject: [PATCH] 1.0.3 --- lib/src/commands/service.dart | 20 +++++++++++++------ .../commands/service_generators/mongo.dart | 5 +---- pubspec.yaml | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/src/commands/service.dart b/lib/src/commands/service.dart index 73090211..aa1bf75a 100644 --- a/lib/src/commands/service.dart +++ b/lib/src/commands/service.dart @@ -3,6 +3,7 @@ import 'package:args/command_runner.dart'; import 'package:code_builder/code_builder.dart'; import 'package:console/console.dart'; import 'package:inflection/inflection.dart'; +import 'package:pubspec/pubspec.dart'; import 'package:recase/recase.dart'; import 'service_generators/service_generators.dart'; import 'init.dart' show preBuild; @@ -25,6 +26,7 @@ class ServiceCommand extends Command { @override run() async { + var pubspec = await PubSpec.load(Directory.current); var name = await readInput('Name of Service (not plural): '); var chooser = new Chooser( GENERATORS.map((g) => g.name).toList(), @@ -102,7 +104,7 @@ class ServiceCommand extends Command { export '../models/$lower.dart'; */ lib.addMember( - new ImportBuilder('package:angel_framework/angel_framework.dart')); + new ImportBuilder('package:angel_common/angel_common.dart')); generator.applyToLibrary(lib, name, lower); if (generator.createsModel == true) { @@ -180,8 +182,14 @@ class $name extends Model { await file.writeAsString(''' import 'package:angel_validate/angel_validate.dart'; -final Validator CREATE_$constantCase = - new Validator({'name*': isString, 'desc*': isString}); +final Validator $constantCase = new Validator({ + 'name': [isString, isNotEmpty], + 'desc': [isString, isNotEmpty] +}); + +final Validator CREATE_$constantCase = $constantCase.extend({}) + ..requiredFields.addAll(['name', 'desc']); + ''' .trim()); } @@ -198,11 +206,11 @@ final Validator CREATE_$constantCase = .trim(); } - _generateTests(String lower, String type) { + _generateTests(PubSpec pubspec, String lower, String type) { return ''' import 'dart:io'; -import 'package:angel/angel.dart'; -import 'package:angel_framework/angel_framework.dart'; +import 'package:${pubspec.name}/${pubspec.name}.dart'; +import 'package:angel_common/angel_common.dart'; import 'package:angel_test/angel_test.dart'; import 'package:test/test.dart'; diff --git a/lib/src/commands/service_generators/mongo.dart b/lib/src/commands/service_generators/mongo.dart index 1e9d1fd5..af15f740 100644 --- a/lib/src/commands/service_generators/mongo.dart +++ b/lib/src/commands/service_generators/mongo.dart @@ -13,10 +13,7 @@ class MongoServiceGenerator extends ServiceGenerator { @override void applyToLibrary(LibraryBuilder library, String name, String lower) { - library.addMembers([ - 'package:angel_mongo/angel_mongo.dart', - 'package:mongo_dart/mongo_dart.dart' - ].map((str) => new ImportBuilder(str))); + library.addMember(new ImportBuilder('package:mongo_dart/mongo_dart.dart')); } @override diff --git a/pubspec.yaml b/pubspec.yaml index 3baa982b..bbe944d2 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.2" +version: "1.0.3" dependencies: analyzer: "^0.29.0" args: "^0.13.7"