library polymer.builder


Common logic to make it easy to run the polymer linter and deploy tool.

The functions in this library are designed to make it easier to create build.dart files. A build.dart file is a Dart script that can be invoked from the command line, but that can also invoked automatically by the Dart Editor whenever a file in your project changes or when selecting some menu options, such as 'Reanalyze Sources'.

To work correctly, place the build.dart in the root of your project (where pubspec.yaml lives). The file must be named exactly build.dart.

It's quite likely that in the near future build.dart will be replaced with something else. For example, pub deploy will deal with deploying applications automatically, and the Dart Editor might provide other mechanisms to hook linters.

There are three important functions exposed by this library build, lint, and deploy. The following examples show common uses of these functions when writing a build.dart file.

Example 1: Uses build.dart to run the linter tool.

import 'dart:io';
import 'package:polymer/builder.dart';

main() {
   lint();
}

Example 2: Runs the linter and creates a deployable version of the app every time.

import 'dart:io';
import 'package:polymer/builder.dart';

main() {
   deploy(); // deploy also calls the linter internally.
}

Example 3: Always run the linter, but conditionally build a deployable version. See parseOptions for a description of options parsed automatically by this helper library.

import 'dart:io';
import 'package:polymer/builder.dart';

main(args) {
   var options = parseOptions(args);
   if (options.forceDeploy) {
     deploy();
   } else {
     lint();
   }
}

Example 4: Same as above, but uses build (which internally calls either lint or deploy).

import 'dart:io';
import 'package:polymer/builder.dart';

main(args) {
   build(options: parseOptions(args));
}

Example 5: Like the previous example, but indicates to the linter and deploy tool which files are actually used as entry point files. See the documentation of build below for more details.

import 'dart:io';
import 'package:polymer/builder.dart';

main(args) {
   build(entryPoints: ['web/index.html'], options: parseOptions(args));
}

Functions

build({List<String> entryPoints, CommandLineOptions options, String currentPackage, Map<String, String> packageDirs}) → Future

Runs the polymer linter on any relevant file in your package, such as any .html file under 'lib/', 'asset/', and 'web/'. And, if requested, creates a directory suitable for deploying a Polymer application to a server.

deploy({List<String> entryPoints, CommandLineOptions options, String currentPackage, Map<String, String> packageDirs}) → Future

Creates a directory suitable for deploying a Polymer application to a server.

lint({List<String> entryPoints, CommandLineOptions options, String currentPackage, Map<String, String> packageDirs}) → Future

Runs the polymer linter on any relevant file in your package, such as any .html file under 'lib/', 'asset/', and 'web/'.

parseOptions([List<String> args]) CommandLineOptions

Parse command-line arguments and return a CommandLineOptions object. The following flags are parsed by this method.

Classes

CommandLineOptions

Options that may be used either in build.dart or by the linter and deploy tools.