1.0.5
This commit is contained in:
parent
058e2fee39
commit
886dd32167
5 changed files with 36 additions and 17 deletions
|
@ -25,11 +25,6 @@ class InitCommand extends Command {
|
|||
argResults.arguments.isEmpty ? "." : argResults.arguments[0]);
|
||||
print("Creating new Angel project in ${projectDir.absolute.path}...");
|
||||
await _cloneRepo(projectDir);
|
||||
_pen.green();
|
||||
_pen(
|
||||
"${Icon.CHECKMARK} Successfully initialized Angel project. Now running pub get...");
|
||||
_pen();
|
||||
await _pubGet(projectDir);
|
||||
// await preBuild(projectDir);
|
||||
var secret = rs.randomAlphaNumeric(32);
|
||||
print('Generated new development JWT secret: $secret');
|
||||
|
@ -45,7 +40,13 @@ class InitCommand extends Command {
|
|||
|
||||
var name = p.basenameWithoutExtension(projectDir.path);
|
||||
print('Renaming project from "angel" to "$name"...');
|
||||
await renamePubspec(projectDir, 'angel', name);
|
||||
await renameDartFiles(projectDir, 'angel', name);
|
||||
_pen.green();
|
||||
_pen(
|
||||
"${Icon.CHECKMARK} Successfully initialized Angel project. Now running pub get...");
|
||||
_pen();
|
||||
await _pubGet(projectDir);
|
||||
}
|
||||
|
||||
_cloneRepo(Directory projectDir) async {
|
||||
|
|
|
@ -39,9 +39,7 @@ class RenameCommand extends Command {
|
|||
} else {
|
||||
var pubspec = await PubSpec.load(Directory.current);
|
||||
var oldName = pubspec.name;
|
||||
var newPubspec =
|
||||
new PubSpec.fromJson(pubspec.toJson()..['name'] = newName);
|
||||
await newPubspec.save(Directory.current);
|
||||
await renamePubspec(Directory.current, oldName, newName);
|
||||
await renameDartFiles(Directory.current, oldName, newName);
|
||||
print('Now running `pub get`...');
|
||||
var pub = await Process.start('pub', ['get']);
|
||||
|
@ -53,11 +51,28 @@ class RenameCommand extends Command {
|
|||
}
|
||||
}
|
||||
|
||||
renamePubspec(Directory dir, String oldName, String newName) async {
|
||||
var pubspec = await PubSpec.load(dir);
|
||||
var newPubspec = new PubSpec.fromJson(pubspec.toJson()..['name'] = newName);
|
||||
await newPubspec.save(dir);
|
||||
}
|
||||
|
||||
renameDartFiles(Directory dir, String oldName, String newName) async {
|
||||
// Try to replace MongoDB URL
|
||||
var defaultYaml = new File.fromUri(dir.uri.resolve('config/default.yaml'));
|
||||
|
||||
if (await defaultYaml.exists()) {
|
||||
print('Changing MongoDB URL in file "${defaultYaml.absolute.path}"...');
|
||||
var contents = await defaultYaml.readAsString();
|
||||
contents = contents.replaceAll('mongodb://localhost:27017/$oldName',
|
||||
'mongodb://localhost:27017/$newName');
|
||||
await defaultYaml.writeAsString(contents);
|
||||
}
|
||||
|
||||
var entry = new File.fromUri(dir.uri.resolve('lib/$oldName.dart'));
|
||||
|
||||
if (await entry.exists()) {
|
||||
await entry.rename('lib/$newName.dart');
|
||||
await entry.rename(dir.uri.resolve('lib/$newName.dart').toFilePath());
|
||||
print('Renaming library file `${entry.absolute.path}`...');
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ class ServiceGenerator {
|
|||
bool get createsModel => true;
|
||||
bool get createsValidator => true;
|
||||
bool get exportedInServiceLibrary => true;
|
||||
bool get injectsSingleton => true;
|
||||
bool get injectsSingleton => false;
|
||||
bool get shouldRunBuild => false;
|
||||
|
||||
void applyToLibrary(LibraryBuilder library, String name, String lower) {}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:watcher/watcher.dart';
|
||||
|
@ -62,8 +63,8 @@ class StartCommand extends Command {
|
|||
try {
|
||||
var scripts =
|
||||
await Process.start('pub', ['global', 'run', 'scripts', 'start']);
|
||||
stdout.addStream(scripts.stdout);
|
||||
stderr.addStream(scripts.stderr);
|
||||
listen(scripts.stdout, stdout);
|
||||
listen(scripts.stderr, stderr);
|
||||
int code = await scripts.exitCode;
|
||||
|
||||
if (code != 0) {
|
||||
|
@ -94,10 +95,8 @@ class StartCommand extends Command {
|
|||
environment: env);
|
||||
|
||||
try {
|
||||
if (isNew) {
|
||||
stdout.addStream(server.stdout);
|
||||
stderr.addStream(server.stderr);
|
||||
}
|
||||
listen(server.stdout, stdout);
|
||||
listen(server.stderr, stderr);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
|
@ -110,3 +109,7 @@ class StartCommand extends Command {
|
|||
exitCode = await server.exitCode;
|
||||
}
|
||||
}
|
||||
|
||||
void listen(Stream<List<int>> stream, IOSink sink) {
|
||||
stream.listen(sink.add);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ author: "Tobe O <thosakwe@gmail.com>"
|
|||
description: "Command-line tools for the Angel framework."
|
||||
homepage: "https://github.com/angel-dart/angel_cli"
|
||||
name: "angel_cli"
|
||||
version: "1.0.4"
|
||||
version: "1.0.5"
|
||||
dependencies:
|
||||
analyzer: "^0.29.0"
|
||||
args: "^0.13.7"
|
||||
|
|
Loading…
Reference in a new issue