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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « config.yaml ('k') | pubspec.lock » ('j') | pubspec.yaml » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: main.dart
diff --git a/main.dart b/main.dart
new file mode 100644
index 0000000000000000000000000000000000000000..27a9e4377a807c02c480852875e34742f142cd95
--- /dev/null
+++ b/main.dart
@@ -0,0 +1,58 @@
+import "dart:io";
+import "dart:async";
+
+import '../discovery_api_dart_client_generator/lib/generator.dart';
+import 'package:google_discovery_v1_api/discovery_v1_api_client.dart';
+import 'package:yaml/yaml.dart';
+
+main() {
+ // Read the configuration.
+ 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.
+ var pkgs = config['packages'];
+ var packages = {};
+ var supportedApis = [];
+ var knownApis = [];
+ pkgs.forEach((pkg) {
+ pkg.forEach((name, values) {
+ packages[name] = values != null ? values : [];
+ });
+ });
+ var skippedApis = config['skipped_apis'];
+ packages.forEach((_, values) => supportedApis.addAll(values));
+ knownApis.addAll(supportedApis);
+ knownApis.addAll(skippedApis);
+
+ // Check that all APIs are mentioned in the configuration.
+ var missingApis = [];
+ listAllApis().then((List<DirectoryListItems> items) {
+ items.forEach((item) {
+ if (!knownApis.contains(item.id)) missingApis.add(item.id);
+ });
+
+ if (missingApis.isNotEmpty) {
+ print('No configuration for the following APIs;');
+ missingApis.forEach((id) => print('- $id'));
+ return;
+ }
+
+ // Delete downloaded discovery documents.
+ packages.forEach((name, values) {
+ var dir = new Directory('discovery');
+ if (dir.existsSync()) dir.deleteSync(recursive: true);
+ });
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.
+
+ // Download the discovery documents for the packages to build.
+ var futures = [];
+ packages.forEach((name, values) {
+ futures.add(downloadDiscoveryDocuments('discovery/$name', ids: values));
+ });
+
+ Future.wait(futures).then((_) {
+ packages.forEach((name, values) {
+ print('Generating library $name');
+ generateAllLibraries('discovery/$name', 'generated/$name');
+ });
+ print('DONE');
+ });
+ });
+}
« no previous file with comments | « config.yaml ('k') | pubspec.lock » ('j') | pubspec.yaml » ('J')

Powered by Google App Engine
This is Rietveld 408576698