diff --git a/.idea/angel_cli.iml b/.idea/angel_cli.iml
deleted file mode 100644
index 6118a7a..0000000
--- a/.idea/angel_cli.iml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 5f91449..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/Controller.xml b/.idea/runConfigurations/Controller.xml
deleted file mode 100644
index 3831510..0000000
--- a/.idea/runConfigurations/Controller.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/Doctor.xml b/.idea/runConfigurations/Doctor.xml
deleted file mode 100644
index bd640dd..0000000
--- a/.idea/runConfigurations/Doctor.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/Init.xml b/.idea/runConfigurations/Init.xml
deleted file mode 100644
index c074007..0000000
--- a/.idea/runConfigurations/Init.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/Show_Help.xml b/.idea/runConfigurations/Show_Help.xml
deleted file mode 100644
index 009fef3..0000000
--- a/.idea/runConfigurations/Show_Help.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/Update.xml b/.idea/runConfigurations/Update.xml
deleted file mode 100644
index 75cab2d..0000000
--- a/.idea/runConfigurations/Update.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/Version.xml b/.idea/runConfigurations/Version.xml
deleted file mode 100644
index cd70052..0000000
--- a/.idea/runConfigurations/Version.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f41ea03..206c158 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,15 +1,27 @@
-# 3.0.0-beta.2
+# Change Log
+
+## 3.0.0
+
+* Fixed NNBD issues
+* Updated to use `angel3` packages
+
+## 3.0.0-beta.2
+
* Updated README
-# 3.0.0-beta.1
+
+## 3.0.0-beta.1
+
* Migrated to work with Dart SDK 2.12.x Non NNBD
* Replaced `mustache4dart2` with `mustache_template`
* Replaced `inflection2` with `inflection3`
-# 2.1.7+1
+## 2.1.7+1
+
* Fix a bug where new directories were not being created in
`init`.
-# 2.1.7
+## 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`.
@@ -17,36 +29,45 @@ intended `ArgResults.rest`.
* 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.
* Add GraphQL boilerplate.
* Automatically restore terminal colors on shutdown.
-# 2.1.5+1
+## 2.1.5+1
+
* Update to `inflection2`.
-# 2.1.5
+## 2.1.5
+
* Add `shared` boilerplates.
* Remove uncecessary `angel_model` imports.
-# 2.1.4+1
+## 2.1.4+1
+
* Patch `part of 'path'` renames.
-# 2.1.4
+## 2.1.4
+
* The `migration` argument to `model` just emits an annotation now.
* Add the ORM boilerplate.
-# 2.1.3
+## 2.1.3
+
* Fix generation of ORM models.
* A `--project-name` to `init` command.
-# 2.1.2
+## 2.1.2
+
* No migrations-by-default.
-# 2.1.1
+## 2.1.1
+
* Edit the way `rename` runs, leaving no corner unturned.
-# 2.1.0
+## 2.1.0
+
* Deprecate `angel install`.
* Rename projects using `snake_case`.
* `init` now fetches from `master`.
@@ -55,34 +76,43 @@ intended `ArgResults.rest`.
* Replace `{{oldName}}` in the `rename` command.
* `pub get` now runs with `inheritStdio`.
-# 2.0.1
+## 2.0.1
+
* `deploy systemd` now has an `--install` option, where you can immediately
spawn the service.
-# 2.0.0
+## 2.0.0
+
* `init` can now produce either 1.x or 2.x projects.
* Fixed deps for compatibility with Dart2 stable.
-# 1.3.4
+## 1.3.4
+
* Fix another typo.
-# 1.3.3
+## 1.3.3
+
* Fix a small typo in the model generator.
-# 1.3.2
+## 1.3.2
+
* Restore `part` directives in generated models.
-# 1.3.1
+## 1.3.1
+
* Add `deploy nginx` and `deploy systemd`.
-# 1.3.0
+## 1.3.0
+
* Focus on Dart2 from here on out.
* Update `code_builder`.
* More changes...
-# 1.1.5
+## 1.1.5
+
Deprecated several commands, in favor of the `make`
command:
+
* `controller`
* `plugin`
* `service`
diff --git a/LICENSE b/LICENSE
index 63b4b68..8f65b57 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
-MIT License
+MIT License (MIT)
-Copyright (c) [year] [fullname]
+Copyright (c) 2021 dukefirehawk.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 73313f3..34fcd2b 100644
--- a/README.md
+++ b/README.md
@@ -8,25 +8,31 @@
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel3-cli/blob/master/LICENSE)
+Command-line tools for the Angel3 framework that provides the following functionalities:
-Command-line tools for the Angel3 framework.
-Includes functionality such as:
* Project scaffolding
* Generating service models, plugins, tests and more
* Renaming projects
* Much more...
-* To install:
+## Installation
+
+Release version:
```bash
-$ pub global activate angel3_cli
+dart pub global activate angel3_cli
```
-* Install development version
-`dart pub global activate --source git https://github.com/dukefirehawk/angel3-cli`
-
-And then, for information on each command:
+Development version:
```bash
-$ angel3 help
+dart pub global activate --source git https://github.com/dukefirehawk/angel3-cli
+```
+
+## Help
+
+For information on the available options:
+
+```bash
+angel3 help
```
diff --git a/TODO.md b/TODO.md
index 868ba85..e0d92cb 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,8 +1,7 @@
# Todo
-* Migrate inflection2, mustache4dart2 and prompts packages to NNBD
* `service`
- * Add tests
+ * Add tests
* `migration`
* `deploy`
-* Call these from Grinder script :)
\ No newline at end of file
+* Call these from Grinder script
diff --git a/bin/angel3.dart b/bin/angel3.dart
index 4967ac2..b1ce6c6 100644
--- a/bin/angel3.dart
+++ b/bin/angel3.dart
@@ -12,11 +12,11 @@ final String DOCTOR = 'doctor';
void main(List args) async {
var runner = CommandRunner(
'angel',
- asciiArt.trim() +
+ asciiArt +
'\n\n' +
- 'Command-line tools for the Angel framework.' +
+ 'Command-line tools for the Angel3 framework.' +
'\n\n' +
- 'https://angel-dart.github.io');
+ 'https://angel3-framework.web.app');
runner.argParser
.addFlag('verbose', help: 'Print verbose output.', negatable: false);
@@ -46,7 +46,34 @@ void main(List args) async {
});
}
+const String asciiArt2 = '''
+
+ ___ _ ________________ _____
+ / | / | / / ____/ ____/ / |__ /
+ / /| | / |/ / / __/ __/ / / /_ <
+ / ___ |/ /| / /_/ / /___/ /______/ /
+/_/ |_/_/ |_/\\____/_____/_____/____/
+
+''';
+
const String asciiArt = '''
+
+ _ _ _ ____ _____ _ _____
+ / \\ | \\ | |/ ___| ____| | |___ /
+ / _ \\ | \\| | | _| _| | | |_ \\
+ / ___ \\| |\\ | |_| | |___| |___ ___) |
+ /_/ \\_\\_| \\_|\\____|_____|_____|____/
+''';
+
+const String asciiArt3 = '''
+
+ \ \ | ___| ____| | ___ /
+ _ \ \ | | __| | _ \
+ ___ \ |\ | | | | | ) |
+ _/ _\ _| \_| \____| _____| _____| ____/
+
+''';
+const String asciiArtOld = '''
____________ ________________________
___ |__ | / /_ ____/__ ____/__ /
__ /| |_ |/ /_ / __ __ __/ __ /
diff --git a/lib/src/commands/init.dart b/lib/src/commands/init.dart
index 1cbae47..d79c611 100644
--- a/lib/src/commands/init.dart
+++ b/lib/src/commands/init.dart
@@ -34,6 +34,11 @@ class InitCommand extends Command {
@override
void run() async {
+ if (argResults == null) {
+ print('Invalid arguements');
+ return;
+ }
+
var projectDir =
Directory(argResults!.rest.isEmpty ? '.' : argResults!.rest[0]);
print('Creating new Angel3 project in ${projectDir.absolute.path}...');
@@ -50,7 +55,7 @@ class InitCommand extends Command {
File.fromUri(projectDir.uri.resolve('config/production.yaml')), secret);
var name = argResults!.wasParsed('project-name')
- ? (argResults!['project-name'] as String?)!
+ ? (argResults!['project-name'] as String)
: p.basenameWithoutExtension(
projectDir.absolute.uri.normalizePath().toFilePath());
@@ -58,6 +63,7 @@ class InitCommand extends Command {
print('Renaming project from "angel" to "$name"...');
await renamePubspec(projectDir, 'angel', name);
await renameDartFiles(projectDir, 'angel', name);
+ // Renaming executable files
if (argResults!['pub-get'] != false && argResults!['offline'] == false) {
print('Now running pub get...');
@@ -77,8 +83,8 @@ class InitCommand extends Command {
..writeln(' in your terminal.')
..writeln()
..writeln('Find more documentation about Angel3:')
+ ..writeln(' * https://angel3-framework.web.app')
..writeln(' * https://angel3-docs.dukefirehaw.com')
- ..writeln(' * https://github.com/dukefirehawk/angel/wiki')
..writeln(
' * https://www.youtube.com/playlist?list=PLl3P3tmiT-frEV50VdH_cIrA2YqIyHkkY')
..writeln(' * https://medium.com/the-angel-framework')
@@ -144,17 +150,23 @@ class InitCommand extends Command {
// var boilerplate = basicBoilerplate;
print('Choose a project type before continuing:');
var boilerplate = prompts.choose(
- 'Choose a project type before continuing', boilerplates)!;
+ 'Choose a project type before continuing', boilerplates) ??
+ basicBoilerplate;
// Ultimately, we want a clone of every boilerplate locally on the system.
var boilerplateRootDir = Directory(p.join(angelDir.path, 'boilerplates'));
- var boilerplateBasename = p.basenameWithoutExtension(boilerplate.url!);
- if (boilerplate.ref != null) boilerplateBasename += '.${boilerplate.ref}';
+ var boilerplateBasename = p.basenameWithoutExtension(boilerplate.url);
+ if (boilerplate.ref != '') {
+ boilerplateBasename += '.${boilerplate.ref}';
+ }
boilerplateDir =
Directory(p.join(boilerplateRootDir.path, boilerplateBasename));
await boilerplateRootDir.create(recursive: true);
- var branch = boilerplate.ref ?? 'master';
+ var branch = boilerplate.ref;
+ if (branch == '') {
+ branch = 'master';
+ }
// If there is no clone existing, clone it.
if (!await boilerplateDir.exists()) {
@@ -167,7 +179,7 @@ class InitCommand extends Command {
'Cloning "${boilerplate.name}" boilerplate from "${boilerplate.url}"...');
Process git;
- if (boilerplate.ref == null) {
+ if (boilerplate.ref == '') {
print(darkGray.wrap(
'\$ git clone --depth 1 ${boilerplate.url} ${boilerplateDir.absolute.path}'));
git = await Process.start(
@@ -176,7 +188,7 @@ class InitCommand extends Command {
'clone',
'--depth',
'1',
- boilerplate.url!,
+ boilerplate.url,
boilerplateDir.absolute.path
],
mode: ProcessStartMode.inheritStdio,
@@ -193,8 +205,8 @@ class InitCommand extends Command {
'1',
'--single-branch',
'-b',
- boilerplate.ref!,
- boilerplate.url!,
+ boilerplate.ref,
+ boilerplate.url,
boilerplateDir.absolute.path
],
mode: ProcessStartMode.inheritStdio,
@@ -231,7 +243,9 @@ class InitCommand extends Command {
var gitDir = Directory.fromUri(projectDir.uri.resolve('.git'));
if (await gitDir.exists()) await gitDir.delete(recursive: true);
} catch (e) {
- await boilerplateDir.delete(recursive: true).catchError((_) => null);
+ await boilerplateDir.delete(recursive: true).catchError((e) {
+ print('Got error: ${e.error}');
+ });
if (e is! String) {
print(red.wrap('$ballot Could not initialize Angel3 project.'));
@@ -271,21 +285,21 @@ const RepoLocation = 'https://github.com/dukefirehawk';
const BoilerplateInfo graphQLBoilerplate = BoilerplateInfo(
'GraphQL',
- 'A starting point for GraphQL API servers.',
+ 'A starter application with GraphQL support.',
'$RepoLocation/boilerplates.git',
ref: 'angel3-graphql',
);
const BoilerplateInfo ormBoilerplate = BoilerplateInfo(
'ORM',
- "A starting point for applications that use Angel3's ORM.",
+ 'A starter application with ORM support.',
'$RepoLocation/boilerplates.git',
ref: 'angel3-orm',
);
const BoilerplateInfo basicBoilerplate = BoilerplateInfo(
'Basic',
- 'Minimal starting point for Angel3 - A simple server with only a few additional packages.',
+ 'A basic starter application with minimal packages.',
'$RepoLocation/boilerplates.git',
ref: 'angel3-basic');
@@ -310,11 +324,12 @@ const List boilerplates = [
];
class BoilerplateInfo {
- final String? name, description, url, ref;
+ final String name, description, url;
+ final String ref;
final bool needsPrebuild;
const BoilerplateInfo(this.name, this.description, this.url,
- {this.ref, this.needsPrebuild = false});
+ {this.ref = '', this.needsPrebuild = false});
@override
String toString() => '$name ($description)';
diff --git a/lib/src/commands/make/maker.dart b/lib/src/commands/make/maker.dart
index 2ba937c..1cd20bf 100644
--- a/lib/src/commands/make/maker.dart
+++ b/lib/src/commands/make/maker.dart
@@ -6,7 +6,7 @@ class MakerDependency implements Comparable {
final String name, version;
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);
diff --git a/lib/src/commands/make/migration.dart b/lib/src/commands/make/migration.dart
index c276760..2d20c59 100644
--- a/lib/src/commands/make/migration.dart
+++ b/lib/src/commands/make/migration.dart
@@ -36,13 +36,13 @@ class MigrationCommand extends Command {
}
var deps = [const MakerDependency('angel_migration', '^2.0.0')];
- var rc = new ReCase(name!);
+ var rc = ReCase(name!);
- var migrationLib = new Library((migrationLib) {
+ var migrationLib = Library((migrationLib) {
migrationLib
- ..directives.add(new Directive.import(
+ ..directives.add(Directive.import(
'package:angel_migration.dart/angel_migration.dart'))
- ..body.add(new Class((migrationClazz) {
+ ..body.add(Class((migrationClazz) {
migrationClazz
..name = '${rc.pascalCase}Migration'
..extend = refer('Migration');
@@ -50,21 +50,21 @@ class MigrationCommand extends Command {
var tableName = pluralize(rc.snakeCase);
// up()
- migrationClazz.methods.add(new Method((up) {
+ migrationClazz.methods.add(Method((up) {
up
..name = 'up'
..returns = refer('void')
..annotations.add(refer('override'))
- ..requiredParameters.add(new Parameter((b) => b
+ ..requiredParameters.add(Parameter((b) => b
..name = 'schema'
..type = refer('Schema')))
- ..body = new Block((block) {
+ ..body = Block((block) {
// (table) { ... }
- var callback = new Method((callback) {
+ var callback = Method((callback) {
callback
..requiredParameters
- .add(new Parameter((b) => b..name = 'table'))
- ..body = new Block((block) {
+ .add(Parameter((b) => b..name = 'table'))
+ ..body = Block((block) {
var table = refer('table');
block.addExpression(
@@ -95,15 +95,15 @@ class MigrationCommand extends Command {
}));
// down()
- migrationClazz.methods.add(new Method((down) {
+ migrationClazz.methods.add(Method((down) {
down
..name = 'down'
..returns = refer('void')
..annotations.add(refer('override'))
- ..requiredParameters.add(new Parameter((b) => b
+ ..requiredParameters.add(Parameter((b) => b
..name = 'schema'
..type = refer('Schema')))
- ..body = new Block((block) {
+ ..body = Block((block) {
block.addExpression(
refer('schema').property('drop').call([
literal(tableName),
@@ -115,15 +115,16 @@ class MigrationCommand extends Command {
});
// Save migration file
- var migrationDir = new Directory.fromUri(
+ var migrationDir = Directory.fromUri(
Directory.current.uri.resolve(argResults!['output-dir'] as String));
var migrationFile =
- new File.fromUri(migrationDir.uri.resolve('${rc.snakeCase}.dart'));
- if (!await migrationFile.exists())
+ File.fromUri(migrationDir.uri.resolve('${rc.snakeCase}.dart'));
+ if (!await migrationFile.exists()) {
await migrationFile.create(recursive: true);
+ }
- await migrationFile.writeAsString(new DartFormatter()
- .format(migrationLib.accept(new DartEmitter()).toString()));
+ await migrationFile.writeAsString(
+ DartFormatter().format(migrationLib.accept(DartEmitter()).toString()));
print(green.wrap(
'$checkmark Created migration file "${migrationFile.absolute.path}".'));
diff --git a/lib/src/commands/make/service.dart b/lib/src/commands/make/service.dart
index 9066b67..1168f08 100644
--- a/lib/src/commands/make/service.dart
+++ b/lib/src/commands/make/service.dart
@@ -31,8 +31,8 @@ class ServiceCommand extends Command {
}
@override
- run() async {
- var pubspec = await loadPubspec();
+ void run() async {
+ await loadPubspec();
String? name;
if (argResults!.wasParsed('name')) name = argResults!['name'] as String?;
@@ -40,7 +40,7 @@ class ServiceCommand extends Command {
name = prompts.get('Name of service');
}
- List deps = [
+ var deps = [
const MakerDependency('angel_framework', '^2.0.0')
];
@@ -122,7 +122,7 @@ class ServiceCommand extends Command {
final outputDir = Directory.fromUri(
Directory.current.uri.resolve(argResults!['output-dir'] as String));
final serviceFile =
- File.fromUri(outputDir.uri.resolve("${rc.snakeCase}.dart"));
+ File.fromUri(outputDir.uri.resolve('${rc.snakeCase}.dart'));
if (!await serviceFile.exists()) await serviceFile.create(recursive: true);
await serviceFile.writeAsString(
DartFormatter().format(serviceLib.accept(DartEmitter()).toString()));
diff --git a/lib/src/commands/rename.dart b/lib/src/commands/rename.dart
index b9d8f1b..a2a61fb 100644
--- a/lib/src/commands/rename.dart
+++ b/lib/src/commands/rename.dart
@@ -88,6 +88,7 @@ Future renameDartFiles(Directory dir, String oldName, String newName) async {
if (!await dir.exists()) return;
// Try to replace MongoDB URL
+ // Replace name in config directory
var configGlob = Glob('config/**/*.yaml');
try {
@@ -104,6 +105,23 @@ Future renameDartFiles(Directory dir, String oldName, String newName) async {
}
} catch (_) {}
+ // Replace name in bin directory
+ var binGlob = Glob('bin/**/*.dart');
+
+ try {
+ await for (var dartFile in binGlob.list(root: dir.absolute.path)) {
+ if (dartFile is File) {
+ print(
+ 'Replacing occurrences of "$oldName" with "$newName" in file "${dartFile.absolute.path}"...');
+ if (dartFile is File) {
+ var contents = (dartFile as File).readAsStringSync();
+ contents = contents.replaceAll(oldName, newName);
+ (dartFile as File).writeAsStringSync(contents);
+ }
+ }
+ }
+ } catch (_) {}
+
var entry = File.fromUri(dir.uri.resolve('lib/$oldName.dart'));
if (await entry.exists()) {
diff --git a/pubspec.yaml b/pubspec.yaml
index af70b96..0a55e64 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,7 +1,8 @@
name: angel3_cli
version: 3.0.0-beta.2
-description: Command-line tools for the Angel framework, including scaffolding.
-homepage: https://github.com/dukefirehawk/angel3-cli
+description: Command line tools for the Angel3 framework, including scaffolding.
+homepage: https://angel3-framework.web.app/
+repository: https://github.com/dukefirehawk/angel3-cli
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
@@ -13,7 +14,6 @@ dependencies:
http: ^0.13.3
io: ^1.0.0
inflection3: ^0.5.3+2
- #mustache4dart2: ^0.1.0
mustache_template: ^2.0.0
path: ^1.8.0
prompts: ^2.0.0