Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 import "dart:io"; | |
| 2 import "dart:async"; | |
| 3 | |
| 4 import '../discovery_api_dart_client_generator/lib/generator.dart'; | |
| 5 import 'package:google_discovery_v1_api/discovery_v1_api_client.dart'; | |
| 6 import 'package:yaml/yaml.dart'; | |
| 7 | |
| 8 main() { | |
| 9 // Read the configuration. | |
| 10 var config = loadYaml(new File('config.yaml').readAsStringSync()); | |
|
kustermann
2014/08/18 09:32:03
You could use Platform.script, so we can call this
Søren Gjesse
2014/08/18 11:10:45
Done.
| |
| 11 var pkgs = config['packages']; | |
| 12 var packages = {}; | |
| 13 var supportedApis = []; | |
| 14 var knownApis = []; | |
| 15 pkgs.forEach((pkg) { | |
| 16 pkg.forEach((name, values) { | |
| 17 packages[name] = values != null ? values : []; | |
| 18 }); | |
| 19 }); | |
| 20 var skippedApis = config['skipped_apis']; | |
| 21 packages.forEach((_, values) => supportedApis.addAll(values)); | |
| 22 knownApis.addAll(supportedApis); | |
| 23 knownApis.addAll(skippedApis); | |
| 24 | |
| 25 // Check that all APIs are mentioned in the configuration. | |
| 26 var missingApis = []; | |
| 27 listAllApis().then((List<DirectoryListItems> items) { | |
| 28 items.forEach((item) { | |
| 29 if (!knownApis.contains(item.id)) missingApis.add(item.id); | |
| 30 }); | |
| 31 | |
| 32 if (missingApis.isNotEmpty) { | |
| 33 print('No configuration for the following APIs;'); | |
| 34 missingApis.forEach((id) => print('- $id')); | |
| 35 return; | |
| 36 } | |
| 37 | |
| 38 // Delete downloaded discovery documents. | |
| 39 packages.forEach((name, values) { | |
| 40 var dir = new Directory('discovery'); | |
| 41 if (dir.existsSync()) dir.deleteSync(recursive: true); | |
| 42 }); | |
|
kustermann
2014/08/18 09:32:03
There is no need for the forEach() loop here.
Søren Gjesse
2014/08/18 11:10:45
Of cause not.
| |
| 43 | |
| 44 // Download the discovery documents for the packages to build. | |
| 45 var futures = []; | |
| 46 packages.forEach((name, values) { | |
| 47 futures.add(downloadDiscoveryDocuments('discovery/$name', ids: values)); | |
| 48 }); | |
| 49 | |
| 50 Future.wait(futures).then((_) { | |
| 51 packages.forEach((name, values) { | |
| 52 print('Generating library $name'); | |
| 53 generateAllLibraries('discovery/$name', 'generated/$name'); | |
| 54 }); | |
| 55 print('DONE'); | |
| 56 }); | |
| 57 }); | |
| 58 } | |
| OLD | NEW |