From 9ebafa157bed5cdde9b6ad9dcd96b51c27ca3d45 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 7 Jan 2016 10:42:08 -0800 Subject: [PATCH] [API] Add temporary bundle-rewriting script --- header.txt | 25 +++++++++++++++++++++++++ rebundle.js | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 header.txt create mode 100644 rebundle.js diff --git a/header.txt b/header.txt new file mode 100644 index 0000000000..fb2ba2b096 --- /dev/null +++ b/header.txt @@ -0,0 +1,25 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global define*/ + +define(['legacyRegistry'], function (legacyRegistry) { + "use strict"; diff --git a/rebundle.js b/rebundle.js new file mode 100644 index 0000000000..23a3ce2ef0 --- /dev/null +++ b/rebundle.js @@ -0,0 +1,38 @@ +// Temporary utility script to rewrite bundle.json +// files as bundle.js files. + +var glob = require('glob'), + fs = require('fs'), + header = fs.readFileSync('header.txt', 'utf8'); + +function indent(str) { + return str.split('\n').map(function (line, index) { + return index === 0 ? line : (' ' + line); + }).join('\n'); +} + +function rebundle(file) { + var plainJson = fs.readFileSync(file, 'utf8'), + bundleName = file.replace("/bundle.json", ""), + outputFile = file.replace(".json", ".js"), + contents = [ + header, + "legacyRegistry.register(\"", + bundleName, + "\", ", + indent(plainJson), + ");\n", + "});\n" + ].join(''); + fs.writeFileSync(outputFile, contents, 'utf8'); +} + +glob('**/bundle.json', {}, function (err, files) { + if (err) { + console.log(err); + return; + } + + files.forEach(rebundle); +}); +