Upgraded package cli
This commit is contained in:
parent
c5e7de1b97
commit
326d2d0c59
6 changed files with 50 additions and 41 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -14,6 +14,7 @@
|
||||||
.metals/
|
.metals/
|
||||||
build/
|
build/
|
||||||
#**/packages/
|
#**/packages/
|
||||||
|
packages/hubbub/
|
||||||
|
|
||||||
# Files created by dart2js
|
# Files created by dart2js
|
||||||
# (Most Dart developers will use pub build to compile Dart, use/modify these
|
# (Most Dart developers will use pub build to compile Dart, use/modify these
|
||||||
|
|
|
@ -12,7 +12,7 @@ import 'pub.dart';
|
||||||
import 'rename.dart';
|
import 'rename.dart';
|
||||||
|
|
||||||
class InitCommand extends Command {
|
class InitCommand extends Command {
|
||||||
final KeyCommand _key = new KeyCommand();
|
final KeyCommand _key = KeyCommand();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get name => "init";
|
String get name => "init";
|
||||||
|
@ -35,21 +35,19 @@ class InitCommand extends Command {
|
||||||
@override
|
@override
|
||||||
run() async {
|
run() async {
|
||||||
Directory projectDir =
|
Directory projectDir =
|
||||||
new Directory(argResults.rest.isEmpty ? "." : argResults.rest[0]);
|
Directory(argResults.rest.isEmpty ? "." : argResults.rest[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);
|
||||||
// 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');
|
||||||
await _key.changeSecret(
|
await _key.changeSecret(
|
||||||
new File.fromUri(projectDir.uri.resolve('config/default.yaml')),
|
File.fromUri(projectDir.uri.resolve('config/default.yaml')), secret);
|
||||||
secret);
|
|
||||||
|
|
||||||
secret = rs.randomAlphaNumeric(32);
|
secret = rs.randomAlphaNumeric(32);
|
||||||
print('Generated new production JWT secret: $secret');
|
print('Generated new production JWT secret: $secret');
|
||||||
await _key.changeSecret(
|
await _key.changeSecret(
|
||||||
new File.fromUri(projectDir.uri.resolve('config/production.yaml')),
|
File.fromUri(projectDir.uri.resolve('config/production.yaml')), secret);
|
||||||
secret);
|
|
||||||
|
|
||||||
var name = argResults.wasParsed('project-name')
|
var name = argResults.wasParsed('project-name')
|
||||||
? argResults['project-name'] as String
|
? argResults['project-name'] as String
|
||||||
|
@ -110,9 +108,9 @@ class InitCommand extends Command {
|
||||||
|
|
||||||
switch (stat.type) {
|
switch (stat.type) {
|
||||||
case FileSystemEntityType.directory:
|
case FileSystemEntityType.directory:
|
||||||
return await _deleteRecursive(new Directory(path));
|
return await _deleteRecursive(Directory(path));
|
||||||
case FileSystemEntityType.file:
|
case FileSystemEntityType.file:
|
||||||
return await _deleteRecursive(new File(path));
|
return await _deleteRecursive(File(path));
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -198,7 +196,7 @@ class InitCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await git.exitCode != 0) {
|
if (await git.exitCode != 0) {
|
||||||
throw new Exception("Could not clone repo.");
|
throw Exception("Could not clone repo.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +222,7 @@ class InitCommand extends Command {
|
||||||
await preBuild(projectDir).catchError((_) => null);
|
await preBuild(projectDir).catchError((_) => null);
|
||||||
}
|
}
|
||||||
|
|
||||||
var gitDir = new 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((_) => null);
|
||||||
|
@ -260,7 +258,7 @@ Future preBuild(Directory projectDir) async {
|
||||||
|
|
||||||
var buildCode = await build.exitCode;
|
var buildCode = await build.exitCode;
|
||||||
|
|
||||||
if (buildCode != 0) throw new Exception('Failed to pre-build resources.');
|
if (buildCode != 0) throw Exception('Failed to pre-build resources.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const RepoArchiveLocation = "https://github.com/angel-dart";
|
const RepoArchiveLocation = "https://github.com/angel-dart";
|
||||||
|
|
|
@ -3,7 +3,7 @@ import 'dart:io';
|
||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:glob/glob.dart';
|
import 'package:glob/glob.dart';
|
||||||
import 'package:io/ansi.dart';
|
import 'package:io/ansi.dart';
|
||||||
import 'package:mustache4dart/mustache4dart.dart' as mustache;
|
import 'package:mustache4dart2/mustache4dart2.dart' as mustache;
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:prompts/prompts.dart' as prompts;
|
import 'package:prompts/prompts.dart' as prompts;
|
||||||
import 'package:pubspec_parse/pubspec_parse.dart';
|
import 'package:pubspec_parse/pubspec_parse.dart';
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:analyzer/analyzer.dart';
|
import 'package:analyzer/dart/ast/ast.dart';
|
||||||
|
import 'package:analyzer/dart/ast/visitor.dart';
|
||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:dart_style/dart_style.dart';
|
import 'package:dart_style/dart_style.dart';
|
||||||
import 'package:glob/glob.dart';
|
import 'package:glob/glob.dart';
|
||||||
|
import 'package:glob/list_local_fs.dart';
|
||||||
import 'package:io/ansi.dart';
|
import 'package:io/ansi.dart';
|
||||||
import 'package:prompts/prompts.dart' as prompts;
|
import 'package:prompts/prompts.dart' as prompts;
|
||||||
import 'package:recase/recase.dart';
|
import 'package:recase/recase.dart';
|
||||||
|
@ -14,7 +16,7 @@ class RenameCommand extends Command {
|
||||||
String get name => 'rename';
|
String get name => 'rename';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get description => 'Renames the current project.';
|
String get description => 'Renames the current project (To be available).';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get invocation => '$name <new name>';
|
String get invocation => '$name <new name>';
|
||||||
|
@ -33,7 +35,10 @@ class RenameCommand extends Command {
|
||||||
|
|
||||||
var choice = prompts.getBool('Rename the project to `$newName`?');
|
var choice = prompts.getBool('Rename the project to `$newName`?');
|
||||||
|
|
||||||
|
// TODO: To be available once the issue is fixed
|
||||||
if (choice) {
|
if (choice) {
|
||||||
|
print('Rename the project is currently not available');
|
||||||
|
/*
|
||||||
print('Renaming project to `$newName`...');
|
print('Renaming project to `$newName`...');
|
||||||
var pubspecFile =
|
var pubspecFile =
|
||||||
File.fromUri(Directory.current.uri.resolve('pubspec.yaml'));
|
File.fromUri(Directory.current.uri.resolve('pubspec.yaml'));
|
||||||
|
@ -53,6 +58,7 @@ class RenameCommand extends Command {
|
||||||
stderr.addStream(pub.stderr);
|
stderr.addStream(pub.stderr);
|
||||||
await pub.exitCode;
|
await pub.exitCode;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +67,7 @@ renamePubspec(Directory dir, String oldName, String newName) async {
|
||||||
// var pubspec = await loadPubspec(dir);
|
// var pubspec = await loadPubspec(dir);
|
||||||
print(cyan.wrap('Renaming your project to `$newName.`'));
|
print(cyan.wrap('Renaming your project to `$newName.`'));
|
||||||
|
|
||||||
var pubspecFile = new File.fromUri(dir.uri.resolve('pubspec.yaml'));
|
var pubspecFile = File.fromUri(dir.uri.resolve('pubspec.yaml'));
|
||||||
|
|
||||||
if (await pubspecFile.exists()) {
|
if (await pubspecFile.exists()) {
|
||||||
var contents = await pubspecFile.readAsString(), oldContents = contents;
|
var contents = await pubspecFile.readAsString(), oldContents = contents;
|
||||||
|
@ -91,9 +97,11 @@ renameDartFiles(Directory dir, String oldName, String newName) async {
|
||||||
if (yamlFile is File) {
|
if (yamlFile is File) {
|
||||||
print(
|
print(
|
||||||
'Replacing occurrences of "$oldName" with "$newName" in file "${yamlFile.absolute.path}"...');
|
'Replacing occurrences of "$oldName" with "$newName" in file "${yamlFile.absolute.path}"...');
|
||||||
var contents = await yamlFile.readAsString();
|
if (yamlFile is File) {
|
||||||
|
var contents = (yamlFile as File).readAsStringSync();
|
||||||
contents = contents.replaceAll(oldName, newName);
|
contents = contents.replaceAll(oldName, newName);
|
||||||
await yamlFile.writeAsString(contents);
|
(yamlFile as File).writeAsStringSync(contents);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
@ -109,9 +117,12 @@ renameDartFiles(Directory dir, String oldName, String newName) async {
|
||||||
await for (FileSystemEntity file in dir.list(recursive: true)) {
|
await for (FileSystemEntity file in dir.list(recursive: true)) {
|
||||||
if (file is File && file.path.endsWith('.dart')) {
|
if (file is File && file.path.endsWith('.dart')) {
|
||||||
var contents = await file.readAsString();
|
var contents = await file.readAsString();
|
||||||
var ast = parseCompilationUnit(contents);
|
|
||||||
var visitor = RenamingVisitor(oldName, newName)
|
// TODO: Issue to be fixed: parseCompilationUnit uses Hubbub library which uses discontinued Google front_end library
|
||||||
..visitCompilationUnit(ast);
|
// front_end package. Temporarily commeted out
|
||||||
|
//var ast = parseCompilationUnit(contents);
|
||||||
|
var visitor = RenamingVisitor(oldName, newName);
|
||||||
|
// ..visitCompilationUnit(ast);
|
||||||
|
|
||||||
if (visitor.replace.isNotEmpty) {
|
if (visitor.replace.isNotEmpty) {
|
||||||
visitor.replace.forEach((range, replacement) {
|
visitor.replace.forEach((range, replacement) {
|
||||||
|
|
|
@ -1,28 +1,27 @@
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
#author: Tobe O <thosakwe@gmail.com>
|
||||||
description: Command-line tools for the Angel framework, including scaffolding.
|
description: Command-line tools for the Angel framework, including scaffolding.
|
||||||
homepage: https://github.com/angel-dart/angel_cli
|
homepage: https://github.com/dukefirehawk/angel/packages/angel_cli
|
||||||
name: angel_cli
|
name: angel_cli
|
||||||
version: 2.2.0
|
version: 2.3.0
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.10.0 <2.12.0"
|
sdk: ">=2.10.0 <3.0.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
analyzer: ^0.39.17
|
analyzer: ^1.1.0
|
||||||
args: ^1.0.0
|
args: ^2.0.0
|
||||||
code_builder: ^3.0.0
|
code_builder: ^3.0.0
|
||||||
dart_style: ^1.0.0
|
dart_style: ^1.0.0
|
||||||
glob: ^1.1.0
|
glob: ^2.0.0
|
||||||
http: ^0.12.0
|
http: ^0.13.0
|
||||||
io: ^0.3.2
|
io: ^0.3.5
|
||||||
inflection2: ^0.4.2
|
inflection2: ^0.4.2
|
||||||
mustache4dart: ^3.0.0-dev.1.0
|
mustache4dart2: ^0.1.0
|
||||||
path: ^1.0.0
|
path: ^1.0.0
|
||||||
prompts: ^1.0.0
|
prompts: ^1.3.1
|
||||||
pubspec_parse: ^0.1.2
|
pubspec_parse: ^1.0.0
|
||||||
quiver: ^2.0.0
|
quiver: ^3.0.0
|
||||||
recase: ^2.0.0
|
recase: ^3.0.1
|
||||||
shutdown: ^0.4.0
|
shutdown: ^0.4.0
|
||||||
watcher: ^0.9.7
|
watcher: ^1.0.0
|
||||||
yaml: ^2.0.0
|
yaml: ^3.0.0
|
||||||
#yamlicious: ^0.0.5
|
|
||||||
executables:
|
executables:
|
||||||
angel: angel
|
angel: angel
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
name: angel_http_exception
|
name: angel_http_exception
|
||||||
version: 1.1.0
|
version: 2.3.0
|
||||||
description: Exception class that can be serialized to JSON and serialized to clients.
|
description: Exception class that can be serialized to JSON and serialized to clients.
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
#author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/http_exception
|
homepage: https://github.com/dukefirehawk/angel/packages/http_exception
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.10.0 <3.0.0"
|
sdk: ">=2.10.0 <3.0.0"
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|
Loading…
Reference in a new issue