diff --git a/lib/generators/appengineapp.dart b/lib/generators/appengineapp.dart index c86449bec35e1cfd9af22ee03ed5739b5a0cbf8f..150938858dbf68d5e6fee5d1adb57ef2f685b057 100644 --- a/lib/generators/appengineapp.dart +++ b/lib/generators/appengineapp.dart @@ -12,12 +12,9 @@ import '../src/common.dart'; * A generator for a hello world AppEngine application. */ class AppEngineAppGenerator extends DefaultGenerator { - AppEngineAppGenerator() : super( - 'appengineapp', - 'AppEngine Application', - 'A simple AppEngine application.', - categories: const ['dart', 'appengine', 'server']) { - + AppEngineAppGenerator() : super('appengineapp', 'AppEngine Application', + 'A simple AppEngine application.', + categories: const ['dart', 'appengine', 'server']) { for (TemplateFile file in decodeConcatenatedData(data)) { addTemplateFile(file); } @@ -25,7 +22,6 @@ class AppEngineAppGenerator extends DefaultGenerator { setEntrypoint(getFile('bin/server.dart')); } - String getInstallInstructions() => - "${super.getInstallInstructions()}\n" + String getInstallInstructions() => "${super.getInstallInstructions()}\n" "run your app using 'gcloud preview app run app.yaml'"; } diff --git a/lib/generators/consoleapp.dart b/lib/generators/consoleapp.dart index df7d6ef02bc00f27fa4a838ab29f123ac8cbbacd..3b1ae2f9d780221da19f3be5bdc842f9eeb3e769 100644 --- a/lib/generators/consoleapp.dart +++ b/lib/generators/consoleapp.dart @@ -12,12 +12,9 @@ import 'consoleapp_data.dart'; * A generator for a hello world command-line application. */ class ConsoleAppGenerator extends DefaultGenerator { - ConsoleAppGenerator() : super( - 'consoleapp', - 'Console Application', - 'A simple command-line application.', - categories: const ['dart', 'console', 'minimal']) { - + ConsoleAppGenerator() : super('consoleapp', 'Console Application', + 'A simple command-line application.', + categories: const ['dart', 'console', 'minimal']) { for (TemplateFile file in decodeConcatenatedData(data)) { addTemplateFile(file); } @@ -25,7 +22,6 @@ class ConsoleAppGenerator extends DefaultGenerator { setEntrypoint(getFile('bin/main.dart')); } - String getInstallInstructions() => - "${super.getInstallInstructions()}\n" + String getInstallInstructions() => "${super.getInstallInstructions()}\n" "run your app using 'dart ${entrypoint.path}'"; } diff --git a/lib/generators/package.dart b/lib/generators/package.dart index 85bf438daf4eb413ffb6f0f0fdae6efa859900da..2b7db1b7dbd57f6beb0aaf9b88c63479c3f85419 100644 --- a/lib/generators/package.dart +++ b/lib/generators/package.dart @@ -12,12 +12,9 @@ import 'package_data.dart'; * A generator for a pub library. */ class PackageGenerator extends DefaultGenerator { - PackageGenerator() : super( - 'package', - 'Dart Package', - 'A starting point for Dart libraries or applications.', - categories: const ['dart']) { - + PackageGenerator() : super('package', 'Dart Package', + 'A starting point for Dart libraries or applications.', + categories: const ['dart']) { for (TemplateFile file in decodeConcatenatedData(data)) { addTemplateFile(file); } diff --git a/lib/generators/polymerapp.dart b/lib/generators/polymerapp.dart index 74adcd182445657d737197352c85173dfd1cebaa..2213c1f2baafbd47a3219321d750d6458fa691c3 100644 --- a/lib/generators/polymerapp.dart +++ b/lib/generators/polymerapp.dart @@ -12,12 +12,9 @@ import 'polymerapp_data.dart'; * A generator for a polymer.dart application. */ class PolymerAppGenerator extends DefaultGenerator { - PolymerAppGenerator() : super( - 'polymerapp', - 'Polymer Web Application', - 'A web app built using polymer.dart.', - categories: const ['dart', 'web']) { - + PolymerAppGenerator() : super('polymerapp', 'Polymer Web Application', + 'A web app built using polymer.dart.', + categories: const ['dart', 'web']) { for (TemplateFile file in decodeConcatenatedData(data)) { addTemplateFile(file); } @@ -25,7 +22,6 @@ class PolymerAppGenerator extends DefaultGenerator { setEntrypoint(getFile('web/index.html')); } - String getInstallInstructions() => - "${super.getInstallInstructions()}\n" + String getInstallInstructions() => "${super.getInstallInstructions()}\n" "to run your app, use 'pub serve'"; } diff --git a/lib/generators/shelfserver.dart b/lib/generators/shelfserver.dart index b6385c7a008fc99c5b89da04f036a5f932387b59..86c679797c873c29fc5f1d2e64be49f07f4ae195 100644 --- a/lib/generators/shelfserver.dart +++ b/lib/generators/shelfserver.dart @@ -12,12 +12,9 @@ import 'shelfserver_data.dart'; * A generator for a hello world command-line application. */ class ShelfServerGenerator extends DefaultGenerator { - ShelfServerGenerator() : super( - 'shelfserver', - 'Shelf Web Server', - 'A web server built using the shelf package.', - categories: const ['dart', 'shelf', 'server']) { - + ShelfServerGenerator() : super('shelfserver', 'Shelf Web Server', + 'A web server built using the shelf package.', + categories: const ['dart', 'shelf', 'server']) { for (TemplateFile file in decodeConcatenatedData(data)) { addTemplateFile(file); } @@ -25,7 +22,6 @@ class ShelfServerGenerator extends DefaultGenerator { setEntrypoint(getFile('bin/server.dart')); } - String getInstallInstructions() => - "${super.getInstallInstructions()}\n" + String getInstallInstructions() => "${super.getInstallInstructions()}\n" "run your app via 'dart ${entrypoint.path}'"; } diff --git a/lib/generators/ubersimplewebapp.dart b/lib/generators/ubersimplewebapp.dart index 0d79633ce65ef2a693d0d43310e6bcb17e657899..d5a882fedc9e556d77fd18180e7d32076bbf94d5 100644 --- a/lib/generators/ubersimplewebapp.dart +++ b/lib/generators/ubersimplewebapp.dart @@ -12,12 +12,9 @@ import 'ubersimplewebapp_data.dart'; * A generator for a uber-simple web application. */ class UberSimpleWebAppGenerator extends DefaultGenerator { - UberSimpleWebAppGenerator() : super( - 'ubersimplewebapp', - 'Uber Simple Web Application', - "An absolute bare-bones web app.", - categories: const ['dart', 'web']) { - + UberSimpleWebAppGenerator() : super('ubersimplewebapp', + 'Uber Simple Web Application', "An absolute bare-bones web app.", + categories: const ['dart', 'web']) { for (TemplateFile file in decodeConcatenatedData(data)) { addTemplateFile(file); } diff --git a/lib/generators/webapp.dart b/lib/generators/webapp.dart index 193bb1d5c8961cdfd16a970c180a033138e78f31..95a07490725ac10e1e081e6087aaa4982028aa8c 100644 --- a/lib/generators/webapp.dart +++ b/lib/generators/webapp.dart @@ -12,13 +12,9 @@ import 'webapp_data.dart'; * A generator for a minimal web application. */ class WebAppGenerator extends DefaultGenerator { - WebAppGenerator() : super( - 'webapp', - 'Web Application', - "A mobile-friendly web app with routing, responsive CSS, and " - "(optional) Sass support.", - categories: const ['dart', 'web']) { - + WebAppGenerator() : super('webapp', 'Web Application', + "A mobile-friendly web app with routing, responsive CSS, and " + "(optional) Sass support.", categories: const ['dart', 'web']) { for (TemplateFile file in decodeConcatenatedData(data)) { addTemplateFile(file); } @@ -26,8 +22,7 @@ class WebAppGenerator extends DefaultGenerator { setEntrypoint(getFile('web/index.html')); } - String getInstallInstructions() => - "${super.getInstallInstructions()}\n" + String getInstallInstructions() => "${super.getInstallInstructions()}\n" "sass is required if you want to modify the sass styles (sass-lang.com/install)\n" "to run your app, use 'pub serve'\n"; } diff --git a/lib/src/cli_app.dart b/lib/src/cli_app.dart index 55e05c8bc56ea263e2148a07c1882315b6faa357..01453f3726c89088f1f43e4822692051a6dfbe2d 100644 --- a/lib/src/cli_app.dart +++ b/lib/src/cli_app.dart @@ -21,7 +21,8 @@ const String APP_NAME = 'stagehand'; // This version must be updated in tandem with the pubspec version. const String APP_VERSION = '0.1.5+5'; -const String APP_PUB_INFO = 'https://pub.dartlang.org/packages/${APP_NAME}.json'; +const String APP_PUB_INFO = + 'https://pub.dartlang.org/packages/${APP_NAME}.json'; // The Google Analytics tracking ID for stagehand. const String _GA_TRACKING_ID = 'UA-55033590-1'; @@ -89,7 +90,7 @@ class CliApp { List versions = JSON.decode(response.body)['versions']; if (APP_VERSION != versions.last) { _out("Version ${versions.last} is available! Run `pub global activate" - " ${APP_NAME}` to get the latest."); + " ${APP_NAME}` to get the latest."); } }).catchError((e) => null); } @@ -97,8 +98,10 @@ class CliApp { if (options['help'] || args.isEmpty) { // Prompt to opt into advanced analytics. if (!analytics.hasSetOptIn) { - _out("Welcome to Stagehand! We collect anonymous usage statistics and crash reports in"); - _out("order to improve the tool (http://goo.gl/6wsncI). Would you like to opt-in to"); + _out( + "Welcome to Stagehand! We collect anonymous usage statistics and crash reports in"); + _out( + "order to improve the tool (http://goo.gl/6wsncI). Would you like to opt-in to"); _out("additional analytics to help us improve Stagehand [y/yes/no]? "); io.stdout.flush(); String response = io.stdin.readLineSync(); @@ -153,8 +156,8 @@ class CliApp { if (!options['override'] && !_isDirEmpty(dir)) { logger.stderr( -'The current directory is not empty. Please create a new project directory, or ' -'use --override to force generation into the current directory.'); + 'The current directory is not empty. Please create a new project directory, or ' + 'use --override to force generation into the current directory.'); return new Future.error(new ArgError('project directory not empty')); } @@ -193,12 +196,14 @@ class CliApp { ArgParser _createArgParser() { var argParser = new ArgParser(); - argParser.addFlag('analytics', negatable: true, + argParser.addFlag('analytics', + negatable: true, help: 'Opt-out of anonymous usage and crash reporting.'); argParser.addFlag('help', abbr: 'h', negatable: false, help: 'Help!'); - argParser.addFlag('version', negatable: false, - help: 'Display the version for ${APP_NAME}.'); - argParser.addOption('author', defaultsTo: '<your name>', + argParser.addFlag('version', + negatable: false, help: 'Display the version for ${APP_NAME}.'); + argParser.addOption('author', + defaultsTo: '<your name>', help: 'The author name to use for file headers.'); // This option is deprecated and will go away. @@ -234,18 +239,17 @@ class CliApp { } void _usage(ArgParser argParser) { - _out('Stagehand will generate the given application type into the current directory.'); + _out( + 'Stagehand will generate the given application type into the current directory.'); _out(''); _out('usage: ${APP_NAME} <generator-name>'); _out(argParser.usage); _out(''); _out('Available generators:'); - int len = generators - .map((g) => g.id.length) - .fold(0, (a, b) => max(a, b)); + int len = generators.map((g) => g.id.length).fold(0, (a, b) => max(a, b)); generators - .map((g) => " ${_pad(g.id, len)} - ${g.description}") - .forEach(logger.stdout); + .map((g) => " ${_pad(g.id, len)} - ${g.description}") + .forEach(logger.stdout); } Generator _getGenerator(String id) { @@ -267,10 +271,10 @@ class CliApp { bool _isDirEmpty(io.Directory dir) { var isHiddenDir = (dir) => path.basename(dir.path).startsWith('.'); - return dir.listSync(followLinks: false) + return dir + .listSync(followLinks: false) .where((entity) => entity is io.Directory) - .where((entity) => !isHiddenDir(entity)) - .isEmpty; + .where((entity) => !isHiddenDir(entity)).isEmpty; } } @@ -299,8 +303,8 @@ class _DirectoryGeneratorTarget extends GeneratorTarget { logger.stdout(' ${file.path}'); return file - .create(recursive: true) - .then((_) => file.writeAsBytes(contents)); + .create(recursive: true) + .then((_) => file.writeAsBytes(contents)); } } diff --git a/lib/src/common.dart b/lib/src/common.dart index 951f3cb9b618ccfb3de67b81bbea0d525dc15850..e7bf503d3a99d44163b02e1194d43f0b594081fa 100644 --- a/lib/src/common.dart +++ b/lib/src/common.dart @@ -17,7 +17,7 @@ const int _RUNE_SPACE = 32; @Deprecated('see decodeConcatenatedData') List<TemplateFile> decodeConcanenatedData(List<String> data) => - decodeConcatenatedData(data); + decodeConcatenatedData(data); List<TemplateFile> decodeConcatenatedData(List<String> data) { List<TemplateFile> results = []; diff --git a/test/cli_test.dart b/test/cli_test.dart index 8bd02dc4fcd1e5b5d42f0c227ac4681c6236ac50..9773d63fe921d7c1c31a37184449904c71a32230 100644 --- a/test/cli_test.dart +++ b/test/cli_test.dart @@ -33,16 +33,14 @@ void defineTests() { } Future _expectError(Future f, [bool hasStdout = true]) { - return f - .then((_) => fail('error expected')) - .catchError((e) { - expect(logger.getStderr(), isNot(isEmpty)); - if (hasStdout) { - expect(logger.getStdout(), isNot(isEmpty)); - } else { - expect(logger.getStdout(), isEmpty); - } - }); + return f.then((_) => fail('error expected')).catchError((e) { + expect(logger.getStderr(), isNot(isEmpty)); + if (hasStdout) { + expect(logger.getStdout(), isNot(isEmpty)); + } else { + expect(logger.getStdout(), isEmpty); + } + }); } test('no args', () { diff --git a/test/common_test.dart b/test/common_test.dart index 27e7abea5eabb555b7a44560c1c9eca992d8e61e..3fe762d56ddd3f13777ce2f27705940e3269f9c4 100644 --- a/test/common_test.dart +++ b/test/common_test.dart @@ -28,8 +28,7 @@ void defineTests() { }); test('convertToYamlMultiLine', () { - expect( - convertToYamlMultiLine( + expect(convertToYamlMultiLine( 'one two three four five size seven eight nine ' 'ten eleven twelve thirteen fourteen fifteen'), ' one two three four five size seven eight nine ten eleven twelve ' diff --git a/tool/grind.dart b/tool/grind.dart index d86ac4ed0caf3179d5b92c86c59ad60fa76f0759..6fe70aee3f395b1d5bc7f566a7b843a7c16ac993 100644 --- a/tool/grind.dart +++ b/tool/grind.dart @@ -41,9 +41,7 @@ void init(GrinderContext context) { */ void buildTemplates(GrinderContext context) { stagehand.generators.forEach((generator) { - _concatenateFiles( - context, - getDir('templates/${generator.id}'), + _concatenateFiles(context, getDir('templates/${generator.id}'), getFile('lib/generators/${generator.id}_data.dart')); }); } @@ -54,8 +52,8 @@ void buildTemplates(GrinderContext context) { void updateGhPages(GrinderContext context) { context.log('Updating gh-pages branch of the project'); new ghpages.Generator(rootDir: getDir('.').absolute.path) - ..templateDir = getDir('site').absolute.path - ..generate(); + ..templateDir = getDir('site').absolute.path + ..generate(); } /** @@ -81,8 +79,8 @@ void testGenerators(GrinderContext context) { File file = joinFile(fooDir, [generator.entrypoint.path]); if (joinFile(fooDir, ['pubspec.yaml']).existsSync()) { - runProcess(context, 'pub', arguments: ['get'], - workingDirectory: fooDir.path); + runProcess(context, 'pub', + arguments: ['get'], workingDirectory: fooDir.path); } // TODO: This does not locate the polymer template Dart entrypoint. @@ -95,15 +93,16 @@ void testGenerators(GrinderContext context) { filePath = filePath.replaceAll('projectName', 'foo'); // TODO: We should be able to pass a cwd into `analyzePath`. - Analyzer.analyzePath(context, filePath, fatalWarnings: true, - packageRoot: new Directory('foo/packages')); + Analyzer.analyzePath(context, filePath, + fatalWarnings: true, packageRoot: new Directory('foo/packages')); } fooDir.deleteSync(recursive: true); } } catch (e) { - try { fooDir.deleteSync(recursive: true); } - catch (_) { } + try { + fooDir.deleteSync(recursive: true); + } catch (_) {} rethrow; } @@ -160,8 +159,8 @@ void _traverse(Directory dir, String root, List<String> results) { } else { File file = entity; String fileType = _isBinaryFile(name) ? 'binary' : 'text'; - String data = CryptoUtils.bytesToBase64( - file.readAsBytesSync(), addLineSeparator: true); + String data = CryptoUtils.bytesToBase64(file.readAsBytesSync(), + addLineSeparator: true); results.add('${root}${name}'); results.add(fileType); @@ -178,8 +177,8 @@ bool _isBinaryFile(String filename) => _binaryFileTypes.hasMatch(filename); File _locateDartFile(File file) { if (file.path.endsWith('.dart')) return file; - return _listSync(file.parent).firstWhere( - (f) => f.path.endsWith('.dart'), orElse: () => null); + return _listSync(file.parent).firstWhere((f) => f.path.endsWith('.dart'), + orElse: () => null); } /** @@ -189,8 +188,8 @@ File _locateDartFile(File file) { */ List<FileSystemEntity> _listSync(Directory dir, {bool recursive: false, bool followLinks: true}) { - List<FileSystemEntity> results = dir.listSync( - recursive: recursive, followLinks: followLinks); + List<FileSystemEntity> results = + dir.listSync(recursive: recursive, followLinks: followLinks); results.sort((entity1, entity2) => entity1.path.compareTo(entity2.path)); return results; }