Updated NNBD
This commit is contained in:
parent
6254a8a471
commit
7e4aa24ce0
19 changed files with 176 additions and 152 deletions
|
@ -1,19 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="WEB_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.pub" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/sample_project/.pub" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/sample_project/build" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
<orderEntry type="library" name="Dart SDK" level="project" />
|
|
||||||
<orderEntry type="library" name="Dart Packages" level="project" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/angel_cli.iml" filepath="$PROJECT_DIR$/.idea/angel_cli.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="Controller" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true">
|
|
||||||
<option name="arguments" value="controller" />
|
|
||||||
<option name="filePath" value="$PROJECT_DIR$/bin/angel.dart" />
|
|
||||||
<option name="workingDirectory" value="$PROJECT_DIR$/sample_project" />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
|
@ -1,7 +0,0 @@
|
||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="Doctor" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true">
|
|
||||||
<option name="arguments" value="doctor" />
|
|
||||||
<option name="filePath" value="$PROJECT_DIR$/bin/angel.dart" />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="Init" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true">
|
|
||||||
<option name="arguments" value="init sample_project" />
|
|
||||||
<option name="filePath" value="$PROJECT_DIR$/bin/angel.dart" />
|
|
||||||
<option name="workingDirectory" value="$PROJECT_DIR$" />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
|
@ -1,7 +0,0 @@
|
||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="Show Help" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true">
|
|
||||||
<option name="arguments" value="--help" />
|
|
||||||
<option name="filePath" value="$PROJECT_DIR$/bin/angel.dart" />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="Update" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true">
|
|
||||||
<option name="arguments" value="update" />
|
|
||||||
<option name="filePath" value="$PROJECT_DIR$/bin/angel.dart" />
|
|
||||||
<option name="workingDirectory" value="$PROJECT_DIR$" />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
|
@ -1,7 +0,0 @@
|
||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="Version" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true">
|
|
||||||
<option name="arguments" value="version" />
|
|
||||||
<option name="filePath" value="$PROJECT_DIR$/bin/angel.dart" />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
72
CHANGELOG.md
72
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
|
* Updated README
|
||||||
# 3.0.0-beta.1
|
|
||||||
|
## 3.0.0-beta.1
|
||||||
|
|
||||||
* Migrated to work with Dart SDK 2.12.x Non NNBD
|
* Migrated to work with Dart SDK 2.12.x Non NNBD
|
||||||
* Replaced `mustache4dart2` with `mustache_template`
|
* Replaced `mustache4dart2` with `mustache_template`
|
||||||
* Replaced `inflection2` with `inflection3`
|
* Replaced `inflection2` with `inflection3`
|
||||||
|
|
||||||
# 2.1.7+1
|
## 2.1.7+1
|
||||||
|
|
||||||
* Fix a bug where new directories were not being created in
|
* Fix a bug where new directories were not being created in
|
||||||
`init`.
|
`init`.
|
||||||
|
|
||||||
# 2.1.7
|
## 2.1.7
|
||||||
|
|
||||||
* Fix a bug where `ArgResults.arguments` was used in `init` instead of the
|
* Fix a bug where `ArgResults.arguments` was used in `init` instead of the
|
||||||
intended `ArgResults.rest`.
|
intended `ArgResults.rest`.
|
||||||
* Stop including `package:angel_model` imports in `make model`.
|
* 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 `make model` to generate ORM + migration by default.
|
||||||
* Fix `MakerDependency` logic to print missing dependencies.
|
* 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.
|
||||||
* Automatically restore terminal colors on shutdown.
|
* Automatically restore terminal colors on shutdown.
|
||||||
|
|
||||||
# 2.1.5+1
|
## 2.1.5+1
|
||||||
|
|
||||||
* Update to `inflection2`.
|
* Update to `inflection2`.
|
||||||
|
|
||||||
# 2.1.5
|
## 2.1.5
|
||||||
|
|
||||||
* Add `shared` boilerplates.
|
* Add `shared` boilerplates.
|
||||||
* Remove uncecessary `angel_model` imports.
|
* Remove uncecessary `angel_model` imports.
|
||||||
|
|
||||||
# 2.1.4+1
|
## 2.1.4+1
|
||||||
|
|
||||||
* Patch `part of 'path'` renames.
|
* Patch `part of 'path'` renames.
|
||||||
|
|
||||||
# 2.1.4
|
## 2.1.4
|
||||||
|
|
||||||
* The `migration` argument to `model` just emits an annotation now.
|
* The `migration` argument to `model` just emits an annotation now.
|
||||||
* Add the ORM boilerplate.
|
* Add the ORM boilerplate.
|
||||||
|
|
||||||
# 2.1.3
|
## 2.1.3
|
||||||
|
|
||||||
* Fix generation of ORM models.
|
* Fix generation of ORM models.
|
||||||
* A `--project-name` to `init` command.
|
* A `--project-name` to `init` command.
|
||||||
|
|
||||||
# 2.1.2
|
## 2.1.2
|
||||||
|
|
||||||
* No migrations-by-default.
|
* No migrations-by-default.
|
||||||
|
|
||||||
# 2.1.1
|
## 2.1.1
|
||||||
|
|
||||||
* Edit the way `rename` runs, leaving no corner unturned.
|
* Edit the way `rename` runs, leaving no corner unturned.
|
||||||
|
|
||||||
# 2.1.0
|
## 2.1.0
|
||||||
|
|
||||||
* Deprecate `angel install`.
|
* Deprecate `angel install`.
|
||||||
* Rename projects using `snake_case`.
|
* Rename projects using `snake_case`.
|
||||||
* `init` now fetches from `master`.
|
* `init` now fetches from `master`.
|
||||||
|
@ -55,34 +76,43 @@ intended `ArgResults.rest`.
|
||||||
* Replace `{{oldName}}` in the `rename` command.
|
* Replace `{{oldName}}` in the `rename` command.
|
||||||
* `pub get` now runs with `inheritStdio`.
|
* `pub get` now runs with `inheritStdio`.
|
||||||
|
|
||||||
# 2.0.1
|
## 2.0.1
|
||||||
|
|
||||||
* `deploy systemd` now has an `--install` option, where you can immediately
|
* `deploy systemd` now has an `--install` option, where you can immediately
|
||||||
spawn the service.
|
spawn the service.
|
||||||
|
|
||||||
# 2.0.0
|
## 2.0.0
|
||||||
|
|
||||||
* `init` can now produce either 1.x or 2.x projects.
|
* `init` can now produce either 1.x or 2.x projects.
|
||||||
* Fixed deps for compatibility with Dart2 stable.
|
* Fixed deps for compatibility with Dart2 stable.
|
||||||
|
|
||||||
# 1.3.4
|
## 1.3.4
|
||||||
|
|
||||||
* Fix another typo.
|
* Fix another typo.
|
||||||
|
|
||||||
# 1.3.3
|
## 1.3.3
|
||||||
|
|
||||||
* Fix a small typo in the model generator.
|
* Fix a small typo in the model generator.
|
||||||
|
|
||||||
# 1.3.2
|
## 1.3.2
|
||||||
|
|
||||||
* Restore `part` directives in generated models.
|
* Restore `part` directives in generated models.
|
||||||
|
|
||||||
# 1.3.1
|
## 1.3.1
|
||||||
|
|
||||||
* Add `deploy nginx` and `deploy systemd`.
|
* Add `deploy nginx` and `deploy systemd`.
|
||||||
|
|
||||||
# 1.3.0
|
## 1.3.0
|
||||||
|
|
||||||
* Focus on Dart2 from here on out.
|
* Focus on Dart2 from here on out.
|
||||||
* Update `code_builder`.
|
* Update `code_builder`.
|
||||||
* More changes...
|
* More changes...
|
||||||
|
|
||||||
# 1.1.5
|
## 1.1.5
|
||||||
|
|
||||||
Deprecated several commands, in favor of the `make`
|
Deprecated several commands, in favor of the `make`
|
||||||
command:
|
command:
|
||||||
|
|
||||||
* `controller`
|
* `controller`
|
||||||
* `plugin`
|
* `plugin`
|
||||||
* `service`
|
* `service`
|
||||||
|
|
4
LICENSE
4
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
24
README.md
24
README.md
|
@ -8,25 +8,31 @@
|
||||||
|
|
||||||
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel3-cli/blob/master/LICENSE)
|
[![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
|
* Project scaffolding
|
||||||
* Generating service models, plugins, tests and more
|
* Generating service models, plugins, tests and more
|
||||||
* Renaming projects
|
* Renaming projects
|
||||||
* Much more...
|
* Much more...
|
||||||
|
|
||||||
* To install:
|
## Installation
|
||||||
|
|
||||||
|
Release version:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ pub global activate angel3_cli
|
dart pub global activate angel3_cli
|
||||||
```
|
```
|
||||||
|
|
||||||
* Install development version
|
Development version:
|
||||||
`dart pub global activate --source git https://github.com/dukefirehawk/angel3-cli`
|
|
||||||
|
|
||||||
And then, for information on each command:
|
|
||||||
|
|
||||||
```bash
|
```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
|
||||||
```
|
```
|
||||||
|
|
3
TODO.md
3
TODO.md
|
@ -1,8 +1,7 @@
|
||||||
# Todo
|
# Todo
|
||||||
* Migrate inflection2, mustache4dart2 and prompts packages to NNBD
|
|
||||||
|
|
||||||
* `service`
|
* `service`
|
||||||
* Add tests
|
* Add tests
|
||||||
* `migration`
|
* `migration`
|
||||||
* `deploy`
|
* `deploy`
|
||||||
* Call these from Grinder script :)
|
* Call these from Grinder script
|
||||||
|
|
|
@ -12,11 +12,11 @@ final String DOCTOR = 'doctor';
|
||||||
void main(List<String> args) async {
|
void main(List<String> args) async {
|
||||||
var runner = CommandRunner(
|
var runner = CommandRunner(
|
||||||
'angel',
|
'angel',
|
||||||
asciiArt.trim() +
|
asciiArt +
|
||||||
'\n\n' +
|
'\n\n' +
|
||||||
'Command-line tools for the Angel framework.' +
|
'Command-line tools for the Angel3 framework.' +
|
||||||
'\n\n' +
|
'\n\n' +
|
||||||
'https://angel-dart.github.io');
|
'https://angel3-framework.web.app');
|
||||||
|
|
||||||
runner.argParser
|
runner.argParser
|
||||||
.addFlag('verbose', help: 'Print verbose output.', negatable: false);
|
.addFlag('verbose', help: 'Print verbose output.', negatable: false);
|
||||||
|
@ -46,7 +46,34 @@ void main(List<String> args) async {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const String asciiArt2 = '''
|
||||||
|
|
||||||
|
___ _ ________________ _____
|
||||||
|
/ | / | / / ____/ ____/ / |__ /
|
||||||
|
/ /| | / |/ / / __/ __/ / / /_ <
|
||||||
|
/ ___ |/ /| / /_/ / /___/ /______/ /
|
||||||
|
/_/ |_/_/ |_/\\____/_____/_____/____/
|
||||||
|
|
||||||
|
''';
|
||||||
|
|
||||||
const String asciiArt = '''
|
const String asciiArt = '''
|
||||||
|
|
||||||
|
_ _ _ ____ _____ _ _____
|
||||||
|
/ \\ | \\ | |/ ___| ____| | |___ /
|
||||||
|
/ _ \\ | \\| | | _| _| | | |_ \\
|
||||||
|
/ ___ \\| |\\ | |_| | |___| |___ ___) |
|
||||||
|
/_/ \\_\\_| \\_|\\____|_____|_____|____/
|
||||||
|
''';
|
||||||
|
|
||||||
|
const String asciiArt3 = '''
|
||||||
|
|
||||||
|
\ \ | ___| ____| | ___ /
|
||||||
|
_ \ \ | | __| | _ \
|
||||||
|
___ \ |\ | | | | | ) |
|
||||||
|
_/ _\ _| \_| \____| _____| _____| ____/
|
||||||
|
|
||||||
|
''';
|
||||||
|
const String asciiArtOld = '''
|
||||||
____________ ________________________
|
____________ ________________________
|
||||||
___ |__ | / /_ ____/__ ____/__ /
|
___ |__ | / /_ ____/__ ____/__ /
|
||||||
__ /| |_ |/ /_ / __ __ __/ __ /
|
__ /| |_ |/ /_ / __ __ __/ __ /
|
||||||
|
|
|
@ -34,6 +34,11 @@ class InitCommand extends Command {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void run() async {
|
void run() async {
|
||||||
|
if (argResults == null) {
|
||||||
|
print('Invalid arguements');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var projectDir =
|
var projectDir =
|
||||||
Directory(argResults!.rest.isEmpty ? '.' : argResults!.rest[0]);
|
Directory(argResults!.rest.isEmpty ? '.' : argResults!.rest[0]);
|
||||||
print('Creating new Angel3 project in ${projectDir.absolute.path}...');
|
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);
|
File.fromUri(projectDir.uri.resolve('config/production.yaml')), secret);
|
||||||
|
|
||||||
var name = argResults!.wasParsed('project-name')
|
var name = argResults!.wasParsed('project-name')
|
||||||
? (argResults!['project-name'] as String?)!
|
? (argResults!['project-name'] as String)
|
||||||
: p.basenameWithoutExtension(
|
: p.basenameWithoutExtension(
|
||||||
projectDir.absolute.uri.normalizePath().toFilePath());
|
projectDir.absolute.uri.normalizePath().toFilePath());
|
||||||
|
|
||||||
|
@ -58,6 +63,7 @@ class InitCommand extends Command {
|
||||||
print('Renaming project from "angel" to "$name"...');
|
print('Renaming project from "angel" to "$name"...');
|
||||||
await renamePubspec(projectDir, 'angel', name);
|
await renamePubspec(projectDir, 'angel', name);
|
||||||
await renameDartFiles(projectDir, 'angel', name);
|
await renameDartFiles(projectDir, 'angel', name);
|
||||||
|
// Renaming executable files
|
||||||
|
|
||||||
if (argResults!['pub-get'] != false && argResults!['offline'] == false) {
|
if (argResults!['pub-get'] != false && argResults!['offline'] == false) {
|
||||||
print('Now running pub get...');
|
print('Now running pub get...');
|
||||||
|
@ -77,8 +83,8 @@ class InitCommand extends Command {
|
||||||
..writeln(' in your terminal.')
|
..writeln(' in your terminal.')
|
||||||
..writeln()
|
..writeln()
|
||||||
..writeln('Find more documentation about Angel3:')
|
..writeln('Find more documentation about Angel3:')
|
||||||
|
..writeln(' * https://angel3-framework.web.app')
|
||||||
..writeln(' * https://angel3-docs.dukefirehaw.com')
|
..writeln(' * https://angel3-docs.dukefirehaw.com')
|
||||||
..writeln(' * https://github.com/dukefirehawk/angel/wiki')
|
|
||||||
..writeln(
|
..writeln(
|
||||||
' * https://www.youtube.com/playlist?list=PLl3P3tmiT-frEV50VdH_cIrA2YqIyHkkY')
|
' * https://www.youtube.com/playlist?list=PLl3P3tmiT-frEV50VdH_cIrA2YqIyHkkY')
|
||||||
..writeln(' * https://medium.com/the-angel-framework')
|
..writeln(' * https://medium.com/the-angel-framework')
|
||||||
|
@ -144,17 +150,23 @@ class InitCommand extends Command {
|
||||||
// var boilerplate = basicBoilerplate;
|
// var boilerplate = basicBoilerplate;
|
||||||
print('Choose a project type before continuing:');
|
print('Choose a project type before continuing:');
|
||||||
var boilerplate = prompts.choose(
|
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.
|
// Ultimately, we want a clone of every boilerplate locally on the system.
|
||||||
var boilerplateRootDir = Directory(p.join(angelDir.path, 'boilerplates'));
|
var boilerplateRootDir = Directory(p.join(angelDir.path, 'boilerplates'));
|
||||||
var boilerplateBasename = p.basenameWithoutExtension(boilerplate.url!);
|
var boilerplateBasename = p.basenameWithoutExtension(boilerplate.url);
|
||||||
if (boilerplate.ref != null) boilerplateBasename += '.${boilerplate.ref}';
|
if (boilerplate.ref != '') {
|
||||||
|
boilerplateBasename += '.${boilerplate.ref}';
|
||||||
|
}
|
||||||
boilerplateDir =
|
boilerplateDir =
|
||||||
Directory(p.join(boilerplateRootDir.path, boilerplateBasename));
|
Directory(p.join(boilerplateRootDir.path, boilerplateBasename));
|
||||||
await boilerplateRootDir.create(recursive: true);
|
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 there is no clone existing, clone it.
|
||||||
if (!await boilerplateDir.exists()) {
|
if (!await boilerplateDir.exists()) {
|
||||||
|
@ -167,7 +179,7 @@ class InitCommand extends Command {
|
||||||
'Cloning "${boilerplate.name}" boilerplate from "${boilerplate.url}"...');
|
'Cloning "${boilerplate.name}" boilerplate from "${boilerplate.url}"...');
|
||||||
Process git;
|
Process git;
|
||||||
|
|
||||||
if (boilerplate.ref == null) {
|
if (boilerplate.ref == '') {
|
||||||
print(darkGray.wrap(
|
print(darkGray.wrap(
|
||||||
'\$ git clone --depth 1 ${boilerplate.url} ${boilerplateDir.absolute.path}'));
|
'\$ git clone --depth 1 ${boilerplate.url} ${boilerplateDir.absolute.path}'));
|
||||||
git = await Process.start(
|
git = await Process.start(
|
||||||
|
@ -176,7 +188,7 @@ class InitCommand extends Command {
|
||||||
'clone',
|
'clone',
|
||||||
'--depth',
|
'--depth',
|
||||||
'1',
|
'1',
|
||||||
boilerplate.url!,
|
boilerplate.url,
|
||||||
boilerplateDir.absolute.path
|
boilerplateDir.absolute.path
|
||||||
],
|
],
|
||||||
mode: ProcessStartMode.inheritStdio,
|
mode: ProcessStartMode.inheritStdio,
|
||||||
|
@ -193,8 +205,8 @@ class InitCommand extends Command {
|
||||||
'1',
|
'1',
|
||||||
'--single-branch',
|
'--single-branch',
|
||||||
'-b',
|
'-b',
|
||||||
boilerplate.ref!,
|
boilerplate.ref,
|
||||||
boilerplate.url!,
|
boilerplate.url,
|
||||||
boilerplateDir.absolute.path
|
boilerplateDir.absolute.path
|
||||||
],
|
],
|
||||||
mode: ProcessStartMode.inheritStdio,
|
mode: ProcessStartMode.inheritStdio,
|
||||||
|
@ -231,7 +243,9 @@ class InitCommand extends Command {
|
||||||
var gitDir = Directory.fromUri(projectDir.uri.resolve('.git'));
|
var gitDir = Directory.fromUri(projectDir.uri.resolve('.git'));
|
||||||
if (await gitDir.exists()) await gitDir.delete(recursive: true);
|
if (await gitDir.exists()) await gitDir.delete(recursive: true);
|
||||||
} catch (e) {
|
} 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) {
|
if (e is! String) {
|
||||||
print(red.wrap('$ballot Could not initialize Angel3 project.'));
|
print(red.wrap('$ballot Could not initialize Angel3 project.'));
|
||||||
|
@ -271,21 +285,21 @@ const RepoLocation = 'https://github.com/dukefirehawk';
|
||||||
|
|
||||||
const BoilerplateInfo graphQLBoilerplate = BoilerplateInfo(
|
const BoilerplateInfo graphQLBoilerplate = BoilerplateInfo(
|
||||||
'GraphQL',
|
'GraphQL',
|
||||||
'A starting point for GraphQL API servers.',
|
'A starter application with GraphQL support.',
|
||||||
'$RepoLocation/boilerplates.git',
|
'$RepoLocation/boilerplates.git',
|
||||||
ref: 'angel3-graphql',
|
ref: 'angel3-graphql',
|
||||||
);
|
);
|
||||||
|
|
||||||
const BoilerplateInfo ormBoilerplate = BoilerplateInfo(
|
const BoilerplateInfo ormBoilerplate = BoilerplateInfo(
|
||||||
'ORM',
|
'ORM',
|
||||||
"A starting point for applications that use Angel3's ORM.",
|
'A starter application with ORM support.',
|
||||||
'$RepoLocation/boilerplates.git',
|
'$RepoLocation/boilerplates.git',
|
||||||
ref: 'angel3-orm',
|
ref: 'angel3-orm',
|
||||||
);
|
);
|
||||||
|
|
||||||
const BoilerplateInfo basicBoilerplate = BoilerplateInfo(
|
const BoilerplateInfo basicBoilerplate = BoilerplateInfo(
|
||||||
'Basic',
|
'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',
|
'$RepoLocation/boilerplates.git',
|
||||||
ref: 'angel3-basic');
|
ref: 'angel3-basic');
|
||||||
|
|
||||||
|
@ -310,11 +324,12 @@ const List<BoilerplateInfo> boilerplates = [
|
||||||
];
|
];
|
||||||
|
|
||||||
class BoilerplateInfo {
|
class BoilerplateInfo {
|
||||||
final String? name, description, url, ref;
|
final String name, description, url;
|
||||||
|
final String ref;
|
||||||
final bool needsPrebuild;
|
final bool needsPrebuild;
|
||||||
|
|
||||||
const BoilerplateInfo(this.name, this.description, this.url,
|
const BoilerplateInfo(this.name, this.description, this.url,
|
||||||
{this.ref, this.needsPrebuild = false});
|
{this.ref = '', this.needsPrebuild = false});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '$name ($description)';
|
String toString() => '$name ($description)';
|
||||||
|
|
|
@ -6,7 +6,7 @@ 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
|
@override
|
||||||
int compareTo(MakerDependency other) => name.compareTo(other.name);
|
int compareTo(MakerDependency other) => name.compareTo(other.name);
|
||||||
|
|
|
@ -36,13 +36,13 @@ class MigrationCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
var deps = [const MakerDependency('angel_migration', '^2.0.0')];
|
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
|
migrationLib
|
||||||
..directives.add(new Directive.import(
|
..directives.add(Directive.import(
|
||||||
'package:angel_migration.dart/angel_migration.dart'))
|
'package:angel_migration.dart/angel_migration.dart'))
|
||||||
..body.add(new Class((migrationClazz) {
|
..body.add(Class((migrationClazz) {
|
||||||
migrationClazz
|
migrationClazz
|
||||||
..name = '${rc.pascalCase}Migration'
|
..name = '${rc.pascalCase}Migration'
|
||||||
..extend = refer('Migration');
|
..extend = refer('Migration');
|
||||||
|
@ -50,21 +50,21 @@ class MigrationCommand extends Command {
|
||||||
var tableName = pluralize(rc.snakeCase);
|
var tableName = pluralize(rc.snakeCase);
|
||||||
|
|
||||||
// up()
|
// up()
|
||||||
migrationClazz.methods.add(new Method((up) {
|
migrationClazz.methods.add(Method((up) {
|
||||||
up
|
up
|
||||||
..name = 'up'
|
..name = 'up'
|
||||||
..returns = refer('void')
|
..returns = refer('void')
|
||||||
..annotations.add(refer('override'))
|
..annotations.add(refer('override'))
|
||||||
..requiredParameters.add(new Parameter((b) => b
|
..requiredParameters.add(Parameter((b) => b
|
||||||
..name = 'schema'
|
..name = 'schema'
|
||||||
..type = refer('Schema')))
|
..type = refer('Schema')))
|
||||||
..body = new Block((block) {
|
..body = Block((block) {
|
||||||
// (table) { ... }
|
// (table) { ... }
|
||||||
var callback = new Method((callback) {
|
var callback = Method((callback) {
|
||||||
callback
|
callback
|
||||||
..requiredParameters
|
..requiredParameters
|
||||||
.add(new Parameter((b) => b..name = 'table'))
|
.add(Parameter((b) => b..name = 'table'))
|
||||||
..body = new Block((block) {
|
..body = Block((block) {
|
||||||
var table = refer('table');
|
var table = refer('table');
|
||||||
|
|
||||||
block.addExpression(
|
block.addExpression(
|
||||||
|
@ -95,15 +95,15 @@ class MigrationCommand extends Command {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// down()
|
// down()
|
||||||
migrationClazz.methods.add(new Method((down) {
|
migrationClazz.methods.add(Method((down) {
|
||||||
down
|
down
|
||||||
..name = 'down'
|
..name = 'down'
|
||||||
..returns = refer('void')
|
..returns = refer('void')
|
||||||
..annotations.add(refer('override'))
|
..annotations.add(refer('override'))
|
||||||
..requiredParameters.add(new Parameter((b) => b
|
..requiredParameters.add(Parameter((b) => b
|
||||||
..name = 'schema'
|
..name = 'schema'
|
||||||
..type = refer('Schema')))
|
..type = refer('Schema')))
|
||||||
..body = new Block((block) {
|
..body = Block((block) {
|
||||||
block.addExpression(
|
block.addExpression(
|
||||||
refer('schema').property('drop').call([
|
refer('schema').property('drop').call([
|
||||||
literal(tableName),
|
literal(tableName),
|
||||||
|
@ -115,15 +115,16 @@ class MigrationCommand extends Command {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Save migration file
|
// Save migration file
|
||||||
var migrationDir = new Directory.fromUri(
|
var migrationDir = Directory.fromUri(
|
||||||
Directory.current.uri.resolve(argResults!['output-dir'] as String));
|
Directory.current.uri.resolve(argResults!['output-dir'] as String));
|
||||||
var migrationFile =
|
var migrationFile =
|
||||||
new File.fromUri(migrationDir.uri.resolve('${rc.snakeCase}.dart'));
|
File.fromUri(migrationDir.uri.resolve('${rc.snakeCase}.dart'));
|
||||||
if (!await migrationFile.exists())
|
if (!await migrationFile.exists()) {
|
||||||
await migrationFile.create(recursive: true);
|
await migrationFile.create(recursive: true);
|
||||||
|
}
|
||||||
|
|
||||||
await migrationFile.writeAsString(new DartFormatter()
|
await migrationFile.writeAsString(
|
||||||
.format(migrationLib.accept(new DartEmitter()).toString()));
|
DartFormatter().format(migrationLib.accept(DartEmitter()).toString()));
|
||||||
|
|
||||||
print(green.wrap(
|
print(green.wrap(
|
||||||
'$checkmark Created migration file "${migrationFile.absolute.path}".'));
|
'$checkmark Created migration file "${migrationFile.absolute.path}".'));
|
||||||
|
|
|
@ -31,8 +31,8 @@ class ServiceCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
run() async {
|
void run() async {
|
||||||
var pubspec = await loadPubspec();
|
await loadPubspec();
|
||||||
String? name;
|
String? name;
|
||||||
if (argResults!.wasParsed('name')) name = argResults!['name'] as String?;
|
if (argResults!.wasParsed('name')) name = argResults!['name'] as String?;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class ServiceCommand extends Command {
|
||||||
name = prompts.get('Name of service');
|
name = prompts.get('Name of service');
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MakerDependency> deps = [
|
var deps = <MakerDependency>[
|
||||||
const MakerDependency('angel_framework', '^2.0.0')
|
const MakerDependency('angel_framework', '^2.0.0')
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ class ServiceCommand extends Command {
|
||||||
final outputDir = Directory.fromUri(
|
final outputDir = Directory.fromUri(
|
||||||
Directory.current.uri.resolve(argResults!['output-dir'] as String));
|
Directory.current.uri.resolve(argResults!['output-dir'] as String));
|
||||||
final serviceFile =
|
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);
|
if (!await serviceFile.exists()) await serviceFile.create(recursive: true);
|
||||||
await serviceFile.writeAsString(
|
await serviceFile.writeAsString(
|
||||||
DartFormatter().format(serviceLib.accept(DartEmitter()).toString()));
|
DartFormatter().format(serviceLib.accept(DartEmitter()).toString()));
|
||||||
|
|
|
@ -88,6 +88,7 @@ Future renameDartFiles(Directory dir, String oldName, String newName) async {
|
||||||
if (!await dir.exists()) return;
|
if (!await dir.exists()) return;
|
||||||
|
|
||||||
// Try to replace MongoDB URL
|
// Try to replace MongoDB URL
|
||||||
|
// Replace name in config directory
|
||||||
var configGlob = Glob('config/**/*.yaml');
|
var configGlob = Glob('config/**/*.yaml');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -104,6 +105,23 @@ Future renameDartFiles(Directory dir, String oldName, String newName) async {
|
||||||
}
|
}
|
||||||
} catch (_) {}
|
} 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'));
|
var entry = File.fromUri(dir.uri.resolve('lib/$oldName.dart'));
|
||||||
|
|
||||||
if (await entry.exists()) {
|
if (await entry.exists()) {
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
name: angel3_cli
|
name: angel3_cli
|
||||||
version: 3.0.0-beta.2
|
version: 3.0.0-beta.2
|
||||||
description: Command-line tools for the Angel framework, including scaffolding.
|
description: Command line tools for the Angel3 framework, including scaffolding.
|
||||||
homepage: https://github.com/dukefirehawk/angel3-cli
|
homepage: https://angel3-framework.web.app/
|
||||||
|
repository: https://github.com/dukefirehawk/angel3-cli
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.12.0 <3.0.0'
|
sdk: '>=2.12.0 <3.0.0'
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -13,7 +14,6 @@ dependencies:
|
||||||
http: ^0.13.3
|
http: ^0.13.3
|
||||||
io: ^1.0.0
|
io: ^1.0.0
|
||||||
inflection3: ^0.5.3+2
|
inflection3: ^0.5.3+2
|
||||||
#mustache4dart2: ^0.1.0
|
|
||||||
mustache_template: ^2.0.0
|
mustache_template: ^2.0.0
|
||||||
path: ^1.8.0
|
path: ^1.8.0
|
||||||
prompts: ^2.0.0
|
prompts: ^2.0.0
|
||||||
|
|
Loading…
Reference in a new issue