| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Common logic to make it easy to run the polymer linter and deploy tool. | 6 * Common logic to make it easy to run the polymer linter and deploy tool. |
| 7 * | 7 * |
| 8 * The functions in this library are designed to make it easier to create | 8 * The functions in this library are designed to make it easier to create |
| 9 * `build.dart` files. A `build.dart` file is a Dart script that can be invoked | 9 * `build.dart` files. A `build.dart` file is a Dart script that can be invoked |
| 10 * from the command line, but that can also invoked automatically by the Dart | 10 * from the command line, but that can also invoked automatically by the Dart |
| 11 * Editor whenever a file in your project changes or when selecting some menu | 11 * Editor whenever a file in your project changes or when selecting some menu |
| 12 * options, such as 'Reanalyze Sources'. | 12 * options, such as 'Reanalyze Sources'. |
| 13 * | 13 * |
| 14 * To work correctly, place the `build.dart` in the root of your project (where | 14 * To work correctly, place the `build.dart` in the root of your project (where |
| 15 * pubspec.yaml lives). The file must be named exactly `build.dart`. | 15 * pubspec.yaml lives). The file must be named exactly `build.dart`. |
| 16 * | 16 * |
| 17 * It's quite likely that in the near future `build.dart` will be replaced with | 17 * It's quite likely that in the near future `build.dart` will be replaced with |
| (...skipping 14 matching lines...) Expand all Loading... |
| 32 * lint(); | 32 * lint(); |
| 33 * } | 33 * } |
| 34 * | 34 * |
| 35 * **Example 2**: Runs the linter and creates a deployable version of the app | 35 * **Example 2**: Runs the linter and creates a deployable version of the app |
| 36 * every time. | 36 * every time. |
| 37 * | 37 * |
| 38 * import 'dart:io'; | 38 * import 'dart:io'; |
| 39 * import 'package:polymer/builder.dart'; | 39 * import 'package:polymer/builder.dart'; |
| 40 * | 40 * |
| 41 * main() { | 41 * main() { |
| 42 * lint().then(() => deploy()); | 42 * lint().then((_) => deploy()); |
| 43 * } | 43 * } |
| 44 * | 44 * |
| 45 * **Example 3**: Runs the linter, but conditionally does the deploy step. See | 45 * **Example 3**: Runs the linter, but conditionally does the deploy step. See |
| 46 * [parseOptions] for a description of options parsed automatically by this | 46 * [parseOptions] for a description of options parsed automatically by this |
| 47 * helper library. | 47 * helper library. |
| 48 * | 48 * |
| 49 * import 'dart:io'; | 49 * import 'dart:io'; |
| 50 * import 'package:polymer/builder.dart'; | 50 * import 'package:polymer/builder.dart'; |
| 51 * | 51 * |
| 52 * main() { | 52 * main() { |
| 53 * var options = parseOptions(); | 53 * var options = parseOptions(); |
| 54 * lint().then(() { | 54 * lint().then((_) { |
| 55 * if (options.forceDeploy) deploy(); | 55 * if (options.forceDeploy) deploy(); |
| 56 * }); | 56 * }); |
| 57 * } | 57 * } |
| 58 * | 58 * |
| 59 * **Example 4**: Same as above, but uses [build] (which internally calls [lint] | 59 * **Example 4**: Same as above, but uses [build] (which internally calls [lint] |
| 60 * and [deploy]). | 60 * and [deploy]). |
| 61 * | 61 * |
| 62 * import 'dart:io'; | 62 * import 'dart:io'; |
| 63 * import 'package:polymer/builder.dart'; | 63 * import 'package:polymer/builder.dart'; |
| 64 * | 64 * |
| (...skipping 25 matching lines...) Expand all Loading... |
| 90 | 90 |
| 91 | 91 |
| 92 /** | 92 /** |
| 93 * Runs the polymer linter on any relevant file in your package, such as any | 93 * Runs the polymer linter on any relevant file in your package, such as any |
| 94 * .html file under 'lib/', 'asset/', and 'web/'. And, if requested, creates a | 94 * .html file under 'lib/', 'asset/', and 'web/'. And, if requested, creates a |
| 95 * directory suitable for deploying a Polymer application to a server. | 95 * directory suitable for deploying a Polymer application to a server. |
| 96 * | 96 * |
| 97 * The [entryPoints] list contains files under web/ that should be treated as | 97 * The [entryPoints] list contains files under web/ that should be treated as |
| 98 * entry points. Each entry on this list is a relative path from the package | 98 * entry points. Each entry on this list is a relative path from the package |
| 99 * root (for example 'web/index.html'). If null, all files under 'web/' are | 99 * root (for example 'web/index.html'). If null, all files under 'web/' are |
| 100 * treated as possible entry points. | 100 * treated as possible entry points. |
| 101 * | 101 * |
| 102 * Options are read from the command line arguments, but you can override them | 102 * Options are read from the command line arguments, but you can override them |
| 103 * passing the [options] argument. The deploy operation is run only when the | 103 * passing the [options] argument. The deploy operation is run only when the |
| 104 * command-line argument `--deploy` is present, or equivalently when | 104 * command-line argument `--deploy` is present, or equivalently when |
| 105 * `options.forceDeploy` is true. | 105 * `options.forceDeploy` is true. |
| 106 * | 106 * |
| 107 * The linter and deploy steps needs to know the name of the [currentPackage] | 107 * The linter and deploy steps needs to know the name of the [currentPackage] |
| 108 * and the location where to find the code for any package it depends on | 108 * and the location where to find the code for any package it depends on |
| 109 * ([packageDirs]). This is inferred automatically, but can be overriden if | 109 * ([packageDirs]). This is inferred automatically, but can be overriden if |
| 110 * those arguments are provided. | 110 * those arguments are provided. |
| 111 */ | 111 */ |
| 112 Future build({List<String> entryPoints, CommandLineOptions options, | 112 Future build({List<String> entryPoints, CommandLineOptions options, |
| 113 String currentPackage, Map<String, String> packageDirs}) { | 113 String currentPackage, Map<String, String> packageDirs}) { |
| 114 if (options == null) options = _options; | 114 if (options == null) options = _options; |
| 115 return lint(entryPoints: entryPoints, options: options, | 115 return lint(entryPoints: entryPoints, options: options, |
| 116 currentPackage: currentPackage, packageDirs: packageDirs).then((res) { | 116 currentPackage: currentPackage, packageDirs: packageDirs).then((res) { |
| 117 if (options.forceDeploy) { | 117 if (options.forceDeploy) { |
| 118 return deploy(entryPoints: entryPoints, options: options, | 118 return deploy(entryPoints: entryPoints, options: options, |
| 119 currentPackage: currentPackage, packageDirs: packageDirs); | 119 currentPackage: currentPackage, packageDirs: packageDirs); |
| 120 } | 120 } |
| 121 }); | 121 }); |
| 122 } | 122 } |
| 123 | 123 |
| 124 | 124 |
| 125 /** | 125 /** |
| 126 * Runs the polymer linter on any relevant file in your package, | 126 * Runs the polymer linter on any relevant file in your package, |
| 127 * such as any .html file under 'lib/', 'asset/', and 'web/'. | 127 * such as any .html file under 'lib/', 'asset/', and 'web/'. |
| 128 * | 128 * |
| 129 * The [entryPoints] list contains files under web/ that should be treated as | 129 * The [entryPoints] list contains files under web/ that should be treated as |
| 130 * entry points. Each entry on this list is a relative path from the package | 130 * entry points. Each entry on this list is a relative path from the package |
| 131 * root (for example 'web/index.html'). If null, all files under 'web/' are | 131 * root (for example 'web/index.html'). If null, all files under 'web/' are |
| 132 * treated as possible entry points. | 132 * treated as possible entry points. |
| 133 * | 133 * |
| 134 * Options are read from the command line arguments, but you can override them | 134 * Options are read from the command line arguments, but you can override them |
| 135 * passing the [options] argument. | 135 * passing the [options] argument. |
| 136 * | 136 * |
| 137 * The linter needs to know the name of the [currentPackage] and the location | 137 * The linter needs to know the name of the [currentPackage] and the location |
| 138 * where to find the code for any package it depends on ([packageDirs]). This is | 138 * where to find the code for any package it depends on ([packageDirs]). This is |
| 139 * inferred automatically, but can be overriden if those arguments are provided. | 139 * inferred automatically, but can be overriden if those arguments are provided. |
| 140 */ | 140 */ |
| 141 Future lint({List<String> entryPoints, CommandLineOptions options, | 141 Future lint({List<String> entryPoints, CommandLineOptions options, |
| 142 String currentPackage, Map<String, String> packageDirs}) { | 142 String currentPackage, Map<String, String> packageDirs}) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 177 |
| 178 /** | 178 /** |
| 179 * Creates a directory suitable for deploying a Polymer application to a server. | 179 * Creates a directory suitable for deploying a Polymer application to a server. |
| 180 * | 180 * |
| 181 * **Note**: this function will be replaced in the future by the `pub deploy` | 181 * **Note**: this function will be replaced in the future by the `pub deploy` |
| 182 * command. | 182 * command. |
| 183 * | 183 * |
| 184 * The [entryPoints] list contains files under web/ that should be treated as | 184 * The [entryPoints] list contains files under web/ that should be treated as |
| 185 * entry points. Each entry on this list is a relative path from the package | 185 * entry points. Each entry on this list is a relative path from the package |
| 186 * root (for example 'web/index.html'). If null, all files under 'web/' are | 186 * root (for example 'web/index.html'). If null, all files under 'web/' are |
| 187 * treated as possible entry points. | 187 * treated as possible entry points. |
| 188 * | 188 * |
| 189 * Options are read from the command line arguments, but you can override them | 189 * Options are read from the command line arguments, but you can override them |
| 190 * passing the [options] list. | 190 * passing the [options] list. |
| 191 * | 191 * |
| 192 * The deploy step needs to know the name of the [currentPackage] and the | 192 * The deploy step needs to know the name of the [currentPackage] and the |
| 193 * location where to find the code for any package it depends on | 193 * location where to find the code for any package it depends on |
| 194 * ([packageDirs]). This is inferred automatically, but can be overriden if | 194 * ([packageDirs]). This is inferred automatically, but can be overriden if |
| 195 * those arguments are provided. | 195 * those arguments are provided. |
| 196 */ | 196 */ |
| 197 Future deploy({List<String> entryPoints, CommandLineOptions options, | 197 Future deploy({List<String> entryPoints, CommandLineOptions options, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 if (res['help']) { | 283 if (res['help']) { |
| 284 print('A build script that invokes the polymer linter and deploy tools.'); | 284 print('A build script that invokes the polymer linter and deploy tools.'); |
| 285 print('Usage: dart build.dart [options]'); | 285 print('Usage: dart build.dart [options]'); |
| 286 print('\nThese are valid options expected by build.dart:'); | 286 print('\nThese are valid options expected by build.dart:'); |
| 287 print(parser.getUsage()); | 287 print(parser.getUsage()); |
| 288 exit(0); | 288 exit(0); |
| 289 } | 289 } |
| 290 return new CommandLineOptions(res['changed'], res['removed'], res['clean'], | 290 return new CommandLineOptions(res['changed'], res['removed'], res['clean'], |
| 291 res['full'], res['machine'], res['deploy'], res['out']); | 291 res['full'], res['machine'], res['deploy'], res['out']); |
| 292 } | 292 } |
| OLD | NEW |