OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 * Definitions used to run the polymer linter and deploy tools without using | 6 * Definitions used to run the polymer linter and deploy tools without using |
7 * pub serve or pub deploy. | 7 * pub serve or pub deploy. |
8 */ | 8 */ |
9 library polymer.src.build.runner; | 9 library polymer.src.build.runner; |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 map[currentPackage] = '.'; | 98 map[currentPackage] = '.'; |
99 return map; | 99 return map; |
100 } | 100 } |
101 | 101 |
102 /** Internal packages used by polymer. */ | 102 /** Internal packages used by polymer. */ |
103 // TODO(sigmund): consider computing this list by recursively parsing | 103 // TODO(sigmund): consider computing this list by recursively parsing |
104 // pubspec.yaml files in the `Options.packageDirs`. | 104 // pubspec.yaml files in the `Options.packageDirs`. |
105 final Set<String> _polymerPackageDependencies = [ | 105 final Set<String> _polymerPackageDependencies = [ |
106 'analyzer_experimental', 'args', 'barback', 'browser', 'csslib', | 106 'analyzer_experimental', 'args', 'barback', 'browser', 'csslib', |
107 'custom_element', 'fancy_syntax', 'html5lib', 'html_import', 'js', | 107 'custom_element', 'fancy_syntax', 'html5lib', 'html_import', 'js', |
108 'logging', 'mdv', 'meta', 'mutation_observer', 'observe', 'path', 'polymer', | 108 'logging', 'mdv', 'meta', 'mutation_observer', 'observe', 'path' |
109 'polymer_expressions', 'serialization', 'shadow_dom', 'source_maps', | 109 'polymer_expressions', 'serialization', 'shadow_dom', 'source_maps', |
110 'stack_trace', 'unittest', 'unmodifiable_collection', 'yaml'].toSet(); | 110 'stack_trace', 'unittest', 'unmodifiable_collection', 'yaml'].toSet(); |
111 | 111 |
112 /** Return the relative path of each file under [subDir] in [package]. */ | 112 /** Return the relative path of each file under [subDir] in [package]. */ |
113 Iterable<String> _listPackageDir(String package, String subDir, | 113 Iterable<String> _listPackageDir(String package, String subDir, |
114 BarbackOptions options) { | 114 BarbackOptions options) { |
115 var packageDir = options.packageDirs[package]; | 115 var packageDir = options.packageDirs[package]; |
116 if (packageDir == null) return const []; | 116 if (packageDir == null) return const []; |
117 var dir = new Directory(path.join(packageDir, subDir)); | 117 var dir = new Directory(path.join(packageDir, subDir)); |
118 if (!dir.existsSync()) return const []; | 118 if (!dir.existsSync()) return const []; |
(...skipping 23 matching lines...) Expand all Loading... |
142 /** Tell barback which transformers to use and which assets to process. */ | 142 /** Tell barback which transformers to use and which assets to process. */ |
143 void _initBarback(Barback barback, BarbackOptions options) { | 143 void _initBarback(Barback barback, BarbackOptions options) { |
144 var assets = []; | 144 var assets = []; |
145 void addAssets(String package, String subDir) { | 145 void addAssets(String package, String subDir) { |
146 for (var filepath in _listPackageDir(package, subDir, options)) { | 146 for (var filepath in _listPackageDir(package, subDir, options)) { |
147 assets.add(new AssetId(package, filepath)); | 147 assets.add(new AssetId(package, filepath)); |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 for (var package in options.packageDirs.keys) { | 151 for (var package in options.packageDirs.keys) { |
152 // There is nothing to do in the 'polymer' package and its dependencies. | 152 // There is nothing to do in the polymer package dependencies. |
| 153 // However: in Polymer package *itself*, we need to replace ObservableMixin |
| 154 // with ChangeNotifierMixin. |
153 if (!options.transformPolymerDependencies && | 155 if (!options.transformPolymerDependencies && |
154 _polymerPackageDependencies.contains(package)) continue; | 156 _polymerPackageDependencies.contains(package)) continue; |
155 barback.updateTransformers(package, options.phases); | 157 barback.updateTransformers(package, options.phases); |
156 | 158 |
157 // Notify barback to process anything under 'lib' and 'asset'. | 159 // Notify barback to process anything under 'lib' and 'asset'. |
158 addAssets(package, 'lib'); | 160 addAssets(package, 'lib'); |
159 addAssets(package, 'asset'); | 161 addAssets(package, 'asset'); |
160 } | 162 } |
161 | 163 |
162 // In case of the current package, include also 'web'. | 164 // In case of the current package, include also 'web'. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 return writer.addStream(new File(inpath).openRead()) | 305 return writer.addStream(new File(inpath).openRead()) |
304 .then((_) => writer.close()); | 306 .then((_) => writer.close()); |
305 } | 307 } |
306 | 308 |
307 /** Write contents of an [asset] into a file at [filepath]. */ | 309 /** Write contents of an [asset] into a file at [filepath]. */ |
308 Future _writeAsset(String filepath, Asset asset) { | 310 Future _writeAsset(String filepath, Asset asset) { |
309 _ensureDir(path.dirname(filepath)); | 311 _ensureDir(path.dirname(filepath)); |
310 var writer = new File(filepath).openWrite(); | 312 var writer = new File(filepath).openWrite(); |
311 return writer.addStream(asset.read()).then((_) => writer.close()); | 313 return writer.addStream(asset.read()).then((_) => writer.close()); |
312 } | 314 } |
OLD | NEW |