This commit is contained in:
thosakwe 2016-12-31 11:50:35 -05:00
parent 994a4cf97b
commit 07d48ca35e
3 changed files with 27 additions and 16 deletions

View file

@ -1,4 +1,3 @@
import "dart:convert";
import "dart:io";
import "package:args/command_runner.dart";
import "package:console/console.dart";
@ -29,7 +28,7 @@ class InitCommand extends Command {
"${Icon.CHECKMARK} Successfully initialized Angel project. Now running pub get...");
_pen();
await _pubGet(projectDir);
await _preBuild(projectDir);
await preBuild(projectDir);
var secret = rs.randomAlphaNumeric(32);
print('Generated new JWT secret: $secret');
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
print('Pre-building resources...');
var build = await Process.start(Platform.executable, ['tool/build.dart'],
workingDirectory: projectDir.absolute.path);
@ -91,13 +102,3 @@ class InitCommand extends Command {
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");
}
}

View file

@ -1,4 +1,3 @@
import 'dart:convert';
import 'dart:io';
import 'package:args/command_runner.dart';
import 'package:random_string/random_string.dart' as rs;

View file

@ -2,6 +2,7 @@ import 'dart:io';
import 'package:args/command_runner.dart';
import 'package:console/console.dart';
import 'package:id/id.dart';
import 'init.dart' show preBuild;
class ServiceCommand extends Command {
final String CUSTOM = 'Custom';
@ -73,6 +74,7 @@ class ServiceCommand extends Command {
var serviceLibrary = new File('lib/src/models/models.dart');
await serviceLibrary.writeAsString("\nexport '$lower.dart';",
mode: FileMode.APPEND);
await preBuild(Directory.current);
}
await testFile.writeAsString(_generateTests(name, type));
@ -119,6 +121,10 @@ part '$lower.g.dart';
@JsonSerializable()
class $name extends MemoryModel with _\$${name}SerializerMixin {
@JsonKey('id')
@override
String id;
@JsonKey('name')
String name;
@ -170,6 +176,10 @@ part '$lower.g.dart';
@JsonSerializable()
class $name extends Model with _\$${name}SerializerMixin {
@JsonKey('id')
@override
String id;
@JsonKey('name')
String name;
@ -193,6 +203,7 @@ class $name extends Model with _\$${name}SerializerMixin {
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_mongo/angel_mongo.dart';
import 'package:angel_validate/angel_validate.dart';
import 'package:angel_validate/server.dart';
import 'package:mongo_dart/mongo_dart.dart';
final Validator ${lower}Schema = new Validator({