Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: main.dart

Issue 475413002: Initial generator for google API packages (Closed) Base URL: git@github.com:dart-lang/googleapis.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « config.yaml ('k') | pubspec.lock » ('j') | pubspec.yaml » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « config.yaml ('k') | pubspec.lock » ('j') | pubspec.yaml » ('J')

Powered by Google App Engine
This is Rietveld 408576698