From 589c40415cbc15a043941e612d497930f231c00a Mon Sep 17 00:00:00 2001 From: Tobe O Date: Fri, 25 Jan 2019 11:02:38 -0500 Subject: [PATCH] 2.1.5 --- CHANGELOG.md | 4 ++++ lib/src/commands/init.dart | 14 ++++++++++++++ lib/src/commands/make/model.dart | 7 ++++--- lib/src/commands/rename.dart | 20 ++++++++++++-------- pubspec.yaml | 2 +- 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7aa4d8..f2972a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.1.5 +* Add `shared` boilerplates. +* Remove uncecessary `angel_model` imports. + # 2.1.4+1 * Patch `part of 'path'` renames. diff --git a/lib/src/commands/init.dart b/lib/src/commands/init.dart index a7f4e85..099b421 100644 --- a/lib/src/commands/init.dart +++ b/lib/src/commands/init.dart @@ -240,10 +240,24 @@ const BoilerplateInfo legacyBoilerplate = const BoilerplateInfo( ref: '1.1.x', ); +const BoilerplateInfo sharedBoilerplate = const BoilerplateInfo( + 'Shared', + 'Holds common models and files shared across multiple Dart projects.', + 'https://github.com/angel-dart/boilerplate_shared.git'); + +const BoilerplateInfo sharedOrmBoilerplate = const BoilerplateInfo( + 'Shared (ORM)', + 'Holds common models and files shared across multiple Dart projects.', + 'https://github.com/angel-dart/boilerplate_shared.git', + ref: 'orm', +); + const List boilerplates = const [ basicBoilerplate, //legacyBoilerplate, ormBoilerplate, + sharedBoilerplate, + sharedOrmBoilerplate, ]; class BoilerplateInfo { diff --git a/lib/src/commands/make/model.dart b/lib/src/commands/make/model.dart index 45ebc1b..68f4bef 100644 --- a/lib/src/commands/make/model.dart +++ b/lib/src/commands/make/model.dart @@ -54,9 +54,6 @@ class ModelCommand extends Command { ]); } - modelLib.directives - .add(new Directive.import('package:angel_model/angel_model.dart')); - var needsSerialize = argResults['serializable'] as bool || argResults['orm'] as bool || argResults['migration'] as bool; @@ -67,6 +64,10 @@ class ModelCommand extends Command { 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')); } if (argResults['orm'] as bool || argResults['migration'] as bool) { diff --git a/lib/src/commands/rename.dart b/lib/src/commands/rename.dart index e95586f..ae11b5e 100644 --- a/lib/src/commands/rename.dart +++ b/lib/src/commands/rename.dart @@ -81,18 +81,22 @@ renamePubspec(Directory dir, String oldName, String newName) async { } renameDartFiles(Directory dir, String oldName, String newName) async { + if (!await dir.exists()) return; + // Try to replace MongoDB URL var configGlob = new Glob('config/**/*.yaml'); - await for (var yamlFile in configGlob.list(root: dir.absolute.path)) { - if (yamlFile is File) { - print( - 'Replacing occurrences of "$oldName" with "$newName" in file "${yamlFile.absolute.path}"...'); - var contents = await yamlFile.readAsString(); - contents = contents.replaceAll(oldName, newName); - await yamlFile.writeAsString(contents); + try { + await for (var yamlFile in configGlob.list(root: dir.absolute.path)) { + if (yamlFile is File) { + print( + 'Replacing occurrences of "$oldName" with "$newName" in file "${yamlFile.absolute.path}"...'); + var contents = await yamlFile.readAsString(); + contents = contents.replaceAll(oldName, newName); + await yamlFile.writeAsString(contents); + } } - } + } catch (_) {} var entry = new File.fromUri(dir.uri.resolve('lib/$oldName.dart')); diff --git a/pubspec.yaml b/pubspec.yaml index e79ae8e..45fc484 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: 2.1.4+1 +version: 2.1.5 dependencies: analyzer: ">=0.32.0" args: ^1.0.0