From 2414886c2a28688d4c1decf688fc97fc24997aea Mon Sep 17 00:00:00 2001 From: thosakwe Date: Thu, 15 Jun 2017 16:43:16 -0400 Subject: [PATCH] Multiple boilerplates --- lib/src/commands/init.dart | 40 ++++++++++++++++++++------ lib/src/commands/pubspec.update.g.dart | 2 +- pubspec.yaml | 2 +- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/lib/src/commands/init.dart b/lib/src/commands/init.dart index 69917ac..6de7436 100644 --- a/lib/src/commands/init.dart +++ b/lib/src/commands/init.dart @@ -122,13 +122,14 @@ class InitCommand extends Command { } } - var git = await Process.start("git", [ - "clone", - "--depth", - "1", - "https://github.com/angel-dart/angel", - projectDir.absolute.path - ]); + print('Choose a project type before continuing:'); + var boilerplateChooser = new Chooser(ALL_BOILERPLATES); + var boilerplate = await boilerplateChooser.choose(); + + print( + 'Cloning "${boilerplate.name}" boilerplate from "${boilerplate.url}"...'); + var git = await Process.start("git", + ["clone", "--depth", "1", boilerplate.url, projectDir.absolute.path]); stdout.addStream(git.stdout); stderr.addStream(git.stderr); @@ -138,7 +139,6 @@ class InitCommand extends Command { } var gitDir = new Directory.fromUri(projectDir.uri.resolve(".git")); - if (await gitDir.exists()) await gitDir.delete(recursive: true); } catch (e) { print(e); @@ -184,3 +184,27 @@ preBuild(Directory projectDir) async { if (buildCode != 0) throw new Exception('Failed to pre-build resources.'); } + +const BoilerplateInfo FULL_APPLICATION_BOILERPLATE = const BoilerplateInfo( + 'Full Application', + 'A complete project including authentication, multi-threading, and more.', + 'https://github.com/angel-dart/angel.git'); + +const BoilerplateInfo LIGHT_BOILERPLATE = const BoilerplateInfo( + 'Light', + 'Minimal starting point for new users', + 'https://github.com/angel-dart/boilerplate_light.git'); + +const List ALL_BOILERPLATES = const [ + FULL_APPLICATION_BOILERPLATE, + LIGHT_BOILERPLATE +]; + +class BoilerplateInfo { + final String name, description, url; + + const BoilerplateInfo(this.name, this.description, this.url); + + @override + String toString() => '$name ($description)'; +} diff --git a/lib/src/commands/pubspec.update.g.dart b/lib/src/commands/pubspec.update.g.dart index fd4e05e..4207fb7 100644 --- a/lib/src/commands/pubspec.update.g.dart +++ b/lib/src/commands/pubspec.update.g.dart @@ -3,7 +3,7 @@ import 'dart:convert'; import 'package:http/src/base_client.dart' as http; import 'package:pub_semver/pub_semver.dart'; -final Version PACKAGE_VERSION = new Version(1, 1, 2); +final Version PACKAGE_VERSION = new Version(1, 1, 3); Future fetchCurrentVersion(http.BaseClient client) async { var response = await client.get('https://pub.dartlang.org/api/packages/angel_cli'); diff --git a/pubspec.yaml b/pubspec.yaml index fc2c35c..b767778 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ author: "Tobe O " description: "Command-line tools for the Angel framework." homepage: "https://github.com/angel-dart/angel_cli" name: "angel_cli" -version: 1.1.2 +version: 1.1.3 dependencies: # analyzer: "^0.29.0" args: ^0.13.4