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]);
|
argResults.arguments.isEmpty ? "." : argResults.arguments[0]);
|
||||||
print("Creating new Angel project in ${projectDir.absolute.path}...");
|
print("Creating new Angel project in ${projectDir.absolute.path}...");
|
||||||
await _cloneRepo(projectDir);
|
await _cloneRepo(projectDir);
|
||||||
_pen.green();
|
|
||||||
_pen(
|
|
||||||
"${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);
|
var secret = rs.randomAlphaNumeric(32);
|
||||||
print('Generated new development JWT secret: $secret');
|
print('Generated new development JWT secret: $secret');
|
||||||
|
@ -45,7 +40,13 @@ class InitCommand extends Command {
|
||||||
|
|
||||||
var name = p.basenameWithoutExtension(projectDir.path);
|
var name = p.basenameWithoutExtension(projectDir.path);
|
||||||
print('Renaming project from "angel" to "$name"...');
|
print('Renaming project from "angel" to "$name"...');
|
||||||
|
await renamePubspec(projectDir, 'angel', name);
|
||||||
await renameDartFiles(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 {
|
_cloneRepo(Directory projectDir) async {
|
||||||
|
|
|
@ -39,9 +39,7 @@ class RenameCommand extends Command {
|
||||||
} else {
|
} else {
|
||||||
var pubspec = await PubSpec.load(Directory.current);
|
var pubspec = await PubSpec.load(Directory.current);
|
||||||
var oldName = pubspec.name;
|
var oldName = pubspec.name;
|
||||||
var newPubspec =
|
await renamePubspec(Directory.current, oldName, newName);
|
||||||
new PubSpec.fromJson(pubspec.toJson()..['name'] = newName);
|
|
||||||
await newPubspec.save(Directory.current);
|
|
||||||
await renameDartFiles(Directory.current, oldName, newName);
|
await renameDartFiles(Directory.current, oldName, newName);
|
||||||
print('Now running `pub get`...');
|
print('Now running `pub get`...');
|
||||||
var pub = await Process.start('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 {
|
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'));
|
var entry = new File.fromUri(dir.uri.resolve('lib/$oldName.dart'));
|
||||||
|
|
||||||
if (await entry.exists()) {
|
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}`...');
|
print('Renaming library file `${entry.absolute.path}`...');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ class ServiceGenerator {
|
||||||
bool get createsModel => true;
|
bool get createsModel => true;
|
||||||
bool get createsValidator => true;
|
bool get createsValidator => true;
|
||||||
bool get exportedInServiceLibrary => true;
|
bool get exportedInServiceLibrary => true;
|
||||||
bool get injectsSingleton => true;
|
bool get injectsSingleton => false;
|
||||||
bool get shouldRunBuild => false;
|
bool get shouldRunBuild => false;
|
||||||
|
|
||||||
void applyToLibrary(LibraryBuilder library, String name, String lower) {}
|
void applyToLibrary(LibraryBuilder library, String name, String lower) {}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:watcher/watcher.dart';
|
import 'package:watcher/watcher.dart';
|
||||||
|
@ -62,8 +63,8 @@ class StartCommand extends Command {
|
||||||
try {
|
try {
|
||||||
var scripts =
|
var scripts =
|
||||||
await Process.start('pub', ['global', 'run', 'scripts', 'start']);
|
await Process.start('pub', ['global', 'run', 'scripts', 'start']);
|
||||||
stdout.addStream(scripts.stdout);
|
listen(scripts.stdout, stdout);
|
||||||
stderr.addStream(scripts.stderr);
|
listen(scripts.stderr, stderr);
|
||||||
int code = await scripts.exitCode;
|
int code = await scripts.exitCode;
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
@ -94,10 +95,8 @@ class StartCommand extends Command {
|
||||||
environment: env);
|
environment: env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isNew) {
|
listen(server.stdout, stdout);
|
||||||
stdout.addStream(server.stdout);
|
listen(server.stderr, stderr);
|
||||||
stderr.addStream(server.stderr);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
}
|
}
|
||||||
|
@ -110,3 +109,7 @@ class StartCommand extends Command {
|
||||||
exitCode = await server.exitCode;
|
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."
|
description: "Command-line tools for the Angel framework."
|
||||||
homepage: "https://github.com/angel-dart/angel_cli"
|
homepage: "https://github.com/angel-dart/angel_cli"
|
||||||
name: "angel_cli"
|
name: "angel_cli"
|
||||||
version: "1.0.4"
|
version: "1.0.5"
|
||||||
dependencies:
|
dependencies:
|
||||||
analyzer: "^0.29.0"
|
analyzer: "^0.29.0"
|
||||||
args: "^0.13.7"
|
args: "^0.13.7"
|
||||||
|
|
Loading…
Reference in a new issue