16
This commit is contained in:
parent
994a4cf97b
commit
07d48ca35e
3 changed files with 27 additions and 16 deletions
|
@ -1,4 +1,3 @@
|
||||||
import "dart:convert";
|
|
||||||
import "dart:io";
|
import "dart:io";
|
||||||
import "package:args/command_runner.dart";
|
import "package:args/command_runner.dart";
|
||||||
import "package:console/console.dart";
|
import "package:console/console.dart";
|
||||||
|
@ -29,7 +28,7 @@ class InitCommand extends Command {
|
||||||
"${Icon.CHECKMARK} Successfully initialized Angel project. Now running pub get...");
|
"${Icon.CHECKMARK} Successfully initialized Angel project. Now running pub get...");
|
||||||
_pen();
|
_pen();
|
||||||
await _pubGet(projectDir);
|
await _pubGet(projectDir);
|
||||||
await _preBuild(projectDir);
|
await preBuild(projectDir);
|
||||||
var secret = rs.randomAlphaNumeric(32);
|
var secret = rs.randomAlphaNumeric(32);
|
||||||
print('Generated new JWT secret: $secret');
|
print('Generated new JWT secret: $secret');
|
||||||
await _key.changeSecret(
|
await _key.changeSecret(
|
||||||
|
@ -79,8 +78,20 @@ class InitCommand extends Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_preBuild(Directory projectDir) async {
|
_pubGet(Directory projectDir) async {
|
||||||
|
var pub = await Process.start("pub", ["get"],
|
||||||
|
workingDirectory: projectDir.absolute.path);
|
||||||
|
stdout.addStream(pub.stdout);
|
||||||
|
stderr.addStream(pub.stderr);
|
||||||
|
var code = await pub.exitCode;
|
||||||
|
print("Pub process exited with code $code");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
preBuild(Directory projectDir) async {
|
||||||
// Run build
|
// Run build
|
||||||
|
print('Pre-building resources...');
|
||||||
|
|
||||||
var build = await Process.start(Platform.executable, ['tool/build.dart'],
|
var build = await Process.start(Platform.executable, ['tool/build.dart'],
|
||||||
workingDirectory: projectDir.absolute.path);
|
workingDirectory: projectDir.absolute.path);
|
||||||
|
|
||||||
|
@ -91,13 +102,3 @@ class InitCommand extends Command {
|
||||||
|
|
||||||
if (buildCode != 0) throw new Exception('Failed to pre-build resources.');
|
if (buildCode != 0) throw new Exception('Failed to pre-build resources.');
|
||||||
}
|
}
|
||||||
|
|
||||||
_pubGet(Directory projectDir) async {
|
|
||||||
var pub = await Process.start("pub", ["get"],
|
|
||||||
workingDirectory: projectDir.absolute.path);
|
|
||||||
stdout.addStream(pub.stdout);
|
|
||||||
stderr.addStream(pub.stderr);
|
|
||||||
var code = await pub.exitCode;
|
|
||||||
print("Pub process exited with code $code");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:random_string/random_string.dart' as rs;
|
import 'package:random_string/random_string.dart' as rs;
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:io';
|
||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:console/console.dart';
|
import 'package:console/console.dart';
|
||||||
import 'package:id/id.dart';
|
import 'package:id/id.dart';
|
||||||
|
import 'init.dart' show preBuild;
|
||||||
|
|
||||||
class ServiceCommand extends Command {
|
class ServiceCommand extends Command {
|
||||||
final String CUSTOM = 'Custom';
|
final String CUSTOM = 'Custom';
|
||||||
|
@ -73,6 +74,7 @@ class ServiceCommand extends Command {
|
||||||
var serviceLibrary = new File('lib/src/models/models.dart');
|
var serviceLibrary = new File('lib/src/models/models.dart');
|
||||||
await serviceLibrary.writeAsString("\nexport '$lower.dart';",
|
await serviceLibrary.writeAsString("\nexport '$lower.dart';",
|
||||||
mode: FileMode.APPEND);
|
mode: FileMode.APPEND);
|
||||||
|
await preBuild(Directory.current);
|
||||||
}
|
}
|
||||||
|
|
||||||
await testFile.writeAsString(_generateTests(name, type));
|
await testFile.writeAsString(_generateTests(name, type));
|
||||||
|
@ -119,6 +121,10 @@ part '$lower.g.dart';
|
||||||
|
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class $name extends MemoryModel with _\$${name}SerializerMixin {
|
class $name extends MemoryModel with _\$${name}SerializerMixin {
|
||||||
|
@JsonKey('id')
|
||||||
|
@override
|
||||||
|
String id;
|
||||||
|
|
||||||
@JsonKey('name')
|
@JsonKey('name')
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
|
@ -170,6 +176,10 @@ part '$lower.g.dart';
|
||||||
|
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class $name extends Model with _\$${name}SerializerMixin {
|
class $name extends Model with _\$${name}SerializerMixin {
|
||||||
|
@JsonKey('id')
|
||||||
|
@override
|
||||||
|
String id;
|
||||||
|
|
||||||
@JsonKey('name')
|
@JsonKey('name')
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
|
@ -193,6 +203,7 @@ class $name extends Model with _\$${name}SerializerMixin {
|
||||||
import 'package:angel_framework/angel_framework.dart';
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
import 'package:angel_mongo/angel_mongo.dart';
|
import 'package:angel_mongo/angel_mongo.dart';
|
||||||
import 'package:angel_validate/angel_validate.dart';
|
import 'package:angel_validate/angel_validate.dart';
|
||||||
|
import 'package:angel_validate/server.dart';
|
||||||
import 'package:mongo_dart/mongo_dart.dart';
|
import 'package:mongo_dart/mongo_dart.dart';
|
||||||
|
|
||||||
final Validator ${lower}Schema = new Validator({
|
final Validator ${lower}Schema = new Validator({
|
||||||
|
|
Loading…
Reference in a new issue