Skip to content
Browse files

Added Metadata build scripts

  • Loading branch information...
1 parent 7a142c0 commit b8ebab364e99a26f676f70e600ff98b4d6380d12 @davglass davglass committed Sep 30, 2011
Showing with 74 additions and 0 deletions.
  1. +22 −0 BUILD.md
  2. +2 −0 README
  3. +23 −0 scripts/convert.php
  4. +27 −0 scripts/export_modules.js
View
22 BUILD.md
@@ -0,0 +1,22 @@
+Building YUI 3 Metadata
+-----------------------
+
+There are two scripts located in the `scripts` directory.
+
+ * `export_modules.js`
+ This script converts Loader metadata into a JSON text file that is to be parsed by `convert.php`
+ * `convert.php`
+ Converts the JSON loader structure into a php JSON structure
+
+
+Building
+========
+
+ * Download an official release from here: http://yuilibrary.com/download/yui3/
+ * Clone this repo: `git clone git://github.com/yui/phploader.git`
+ * Unzip the release as a sibling to the loader clone
+ * `cd phploader`
+ * `./scripts/export_modules.js`
+ * This will print the version
+ * `./scripts/convert.php <Version>`
+
View
2 README
@@ -56,3 +56,5 @@ examples
api_docs
Contains the standard YUI API style documentation
+scripts
+ Scripts to build meta-data
View
23 scripts/convert.php
@@ -0,0 +1,23 @@
+#!/usr/bin/env php
+<?php
+
+chdir(dirname(__FILE__));
+
+$version = $argv[1];
+
+$cwd = getcwd();
+
+if (!$version) {
+ echo('Please provide a version to convert');
+ exit;
+}
+
+
+
+$config = json_decode(file_get_contents($cwd.'/../lib/meta/json_'.$version.'.txt'), true);
+
+$out = '<?php $GLOBALS[\'yui_current\'] = ' . var_export($config, true) . '; ?>';
+
+file_put_contents($cwd.'/../lib/meta/config_'.$version.'.php', $out);
+echo('Finished converting JSON to PHP\n');
+?>
View
27 scripts/export_modules.js
@@ -0,0 +1,27 @@
+#!/usr/bin/env node
+
+var args = process.argv.slice(2);
+
+var fs = require('fs'),
+ path = require('path'),
+ yui3 = path.resolve(args[0]) || path.join(__dirname, '../../yui');
+
+if (!path.existsSync(yui3)) {
+ console.error('YUI 3 source tree was not found: ', yui3);
+ console.error(' FYI, you can pass the path as an argument..');
+ process.exit(1);
+}
+
+var YUI = require(path.join(yui3, 'build/yui/yui')).YUI;
+
+var Y = YUI();
+
+var loader = new Y.Loader({});
+
+var out = path.join(__dirname, '../lib/meta/json_' + Y.version + '.txt');
+
+fs.writeFileSync(out, JSON.stringify(loader.moduleInfo), 'utf8');
+
+console.log('JS Loader meta written: ', out);
+console.log('Version: ', Y.version);
+console.log('./convert.php', Y.version);

0 comments on commit b8ebab3

Please sign in to comment.
Something went wrong with that request. Please try again.