Added start
This commit is contained in:
parent
b92ebdeb21
commit
b3fe0c5146
8 changed files with 114 additions and 3 deletions
BIN
.DS_Store
vendored
Normal file
BIN
.DS_Store
vendored
Normal file
Binary file not shown.
26
.idea/angel_cli.iml
Normal file
26
.idea/angel_cli.iml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/bin/packages" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/example/packages" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/packages" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/sample_project/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/sample_project/bin/packages" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/sample_project/packages" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/sample_project/test/packages" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/sample_project/test/services/packages" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/sample_project/tool/packages" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/sample_project/web/packages" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="Dart SDK" level="application" />
|
||||||
|
<orderEntry type="library" name="Dart Packages" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/angel_cli.iml" filepath="$PROJECT_DIR$/.idea/angel_cli.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
14
README.md
14
README.md
|
@ -1,2 +1,14 @@
|
||||||
# angel_cli
|
# angel_cli
|
||||||
Command-line tools for the Angel framework.
|
Command-line tools for the Angel framework.
|
||||||
|
|
||||||
|
To install:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ pub global activate angel_cli
|
||||||
|
```
|
||||||
|
|
||||||
|
And then, for information on each command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ angel --help
|
||||||
|
```
|
|
@ -16,7 +16,8 @@ main(List<String> args) {
|
||||||
..addCommand(new ServiceCommand())
|
..addCommand(new ServiceCommand())
|
||||||
..addCommand(new InitCommand())
|
..addCommand(new InitCommand())
|
||||||
..addCommand(new TestCommand())
|
..addCommand(new TestCommand())
|
||||||
..addCommand(new PluginCommand());
|
..addCommand(new PluginCommand())
|
||||||
|
..addCommand(new StartCommand());
|
||||||
|
|
||||||
return runner.run(args).then((_) {}).catchError((exc) {
|
return runner.run(args).then((_) {}).catchError((exc) {
|
||||||
stderr.writeln("Oops, something went wrong: $exc");
|
stderr.writeln("Oops, something went wrong: $exc");
|
||||||
|
|
|
@ -4,4 +4,5 @@ export "doctor.dart";
|
||||||
export "init.dart";
|
export "init.dart";
|
||||||
export "plugin.dart";
|
export "plugin.dart";
|
||||||
export "service.dart";
|
export "service.dart";
|
||||||
|
export "start.dart";
|
||||||
export "test.dart";
|
export "test.dart";
|
63
lib/src/commands/start.dart
Normal file
63
lib/src/commands/start.dart
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:args/command_runner.dart';
|
||||||
|
import 'package:yaml/yaml.dart';
|
||||||
|
|
||||||
|
class StartCommand extends Command {
|
||||||
|
@override
|
||||||
|
String get name => 'start';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get description =>
|
||||||
|
'Runs any `start` scripts, and then runs the server.';
|
||||||
|
|
||||||
|
StartCommand() : super() {
|
||||||
|
argParser.addFlag('production',
|
||||||
|
help: 'Starts the server in production mode.',
|
||||||
|
negatable: false,
|
||||||
|
defaultsTo: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
run() async {
|
||||||
|
final pubspec = new File('pubspec.yaml');
|
||||||
|
|
||||||
|
if (await pubspec.exists()) {
|
||||||
|
// Run start scripts
|
||||||
|
final doc = loadYamlDocument(await pubspec.readAsString());
|
||||||
|
final scriptsNode = doc.contents['scripts'];
|
||||||
|
|
||||||
|
if (scriptsNode != null && scriptsNode.containsKey('start')) {
|
||||||
|
final scripts = scriptsNode['start'] is List
|
||||||
|
? scriptsNode['start']
|
||||||
|
: [scriptsNode['start']];
|
||||||
|
|
||||||
|
for (String script in scripts) {
|
||||||
|
final split = script.split(' ');
|
||||||
|
final result = await Process.run(split.first, split.skip(1).toList(),
|
||||||
|
stdoutEncoding: null, stderrEncoding: null);
|
||||||
|
final code = result.exitCode;
|
||||||
|
|
||||||
|
stdout.add(result.stdout);
|
||||||
|
stderr.add(result.stderr);
|
||||||
|
|
||||||
|
if (code != 0) {
|
||||||
|
throw new Exception("Command '$script' exited with code $code.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print('Starting server...');
|
||||||
|
|
||||||
|
final env = {};
|
||||||
|
|
||||||
|
if (argResults['production']) env['ANGEL_ENV'] = 'production';
|
||||||
|
|
||||||
|
final server = await Process.start(Platform.executable, ['bin/server.dart'],
|
||||||
|
environment: env);
|
||||||
|
server.stdout.pipe(stdout);
|
||||||
|
server.stderr.pipe(stderr);
|
||||||
|
|
||||||
|
exitCode = await server.exitCode;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
name: angel_cli
|
name: angel_cli
|
||||||
version: 1.0.0-dev+5
|
version: 1.0.0-dev+6
|
||||||
description: Command-line tools for the Angel framework.
|
description: Command-line tools for the Angel framework.
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/angel_cli
|
homepage: https://github.com/angel-dart/angel_cli
|
||||||
|
|
Loading…
Reference in a new issue