You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by lo...@apache.org on 2013/10/23 19:56:54 UTC
webworks commit: CB-4780 update script for cli platform update command
Updated Branches:
refs/heads/master 19cfe94a5 -> 6b2ae1dec
CB-4780 update script for cli platform update command
Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/6b2ae1de
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/6b2ae1de
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/6b2ae1de
Branch: refs/heads/master
Commit: 6b2ae1decb9af5c1c41d997779d121eb90cfde86
Parents: 19cfe94
Author: lorinbeer <lo...@adobe.com>
Authored: Wed Oct 23 10:56:51 2013 -0700
Committer: lorinbeer <lo...@adobe.com>
Committed: Wed Oct 23 10:56:51 2013 -0700
----------------------------------------------------------------------
blackberry10/bin/update | 94 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/6b2ae1de/blackberry10/bin/update
----------------------------------------------------------------------
diff --git a/blackberry10/bin/update b/blackberry10/bin/update
new file mode 100755
index 0000000..586873a
--- /dev/null
+++ b/blackberry10/bin/update
@@ -0,0 +1,94 @@
+#!/usr/bin/env node
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+var shell = require('shelljs'),
+ path = require('path'),
+ fs = require('fs'),
+ ROOT = path.join(__dirname, '..');
+
+function setShellFatal(value, func) {
+ var oldVal = shell.config.fatal;
+ shell.config.fatal = value;
+ func();
+ shell.config.fatal = oldVal;
+}
+
+
+function updateNativeDir(projectpath) {
+ shell.cp('-rf', path.join(ROOT,'bin','templates','project','native'), path.join(projectpath,'native'));
+}
+
+function updateProjectJson(projectpath) {
+ var projectJson = require(path.resolve(path.join(projectpath, "project.json")));
+ projectJson.globalFetchDir = path.join(ROOT,'plugins');
+ fs.writeFileSync(path.join(projectpath, "project.json"), JSON.stringify(projectJson, null, 4) + "\n", "utf-8");
+}
+
+function updateCordovaJS(projectpath,version) {
+ var jspath = path.join(projectpath,'lib','cordova'+version,'javascript');
+ shell.rm('-rf', path.join(projectpath, 'lib')); //remove old lib tree
+ shell.mkdir('-p', jspath); // remake lib dir tree with updated version
+ shell.cp('-f', path.join(ROOT,'javascript','cordova.blackberry10.js'), path.join(jspath,'cordova.js')); // copy new js
+ shell.cp('-f', path.join(ROOT,'javascript','cordova.blackberry10.js'), path.join('www','cordova.js'));
+}
+
+function updateCordovaTools(projectpath) {
+ // update cordova scripts from template
+ shell.cp('-rf', path.join(ROOT,'bin','templates','project','cordova'), path.join(projectpath,'cordova'));
+ // update repo level scripts
+ updateTargetTool(projectpath);
+ updateInitTool(projectpath);
+}
+
+function updateTargetTool(projectpath) {
+ shell.cp('-f', path.join(ROOT,'bin','target'), path.join(projectpath,'cordova'));
+ shell.cp('-f', path.join(ROOT,'bin','target.bat'), path.join(projectpath,'cordova'));
+ shell.cp('-f', path.join(ROOT,'bin','lib','target.js'), path.join(projectpath,'cordova','lib'));
+ shell.cp('-f', path.join(ROOT,'bin','lib','utils.js'), path.join(projectpath,'cordova','lib'));
+}
+
+function updateInitTool(projectpath) {
+ shell.cp('-f', path.join(ROOT,'bin','init.bat'), path.join(projectpath, 'cordova'));
+ shell.cp('-f', path.join(ROOT,'bin','init'), path.join(projectpath, 'cordova'));
+}
+
+exports.updateProject = function(projectpath) {
+ var version = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8').trim();
+ setShellFatal(true, function() {
+ updateCordovaJS(projectpath,version);
+ updateCordovaTools(projectpath);
+ updateNativeDir(projectpath);
+ updateProjectJson(projectpath);
+ //console.log('BlackBerry10 project is now at version ' + version);
+ });
+};
+
+if (require.main === module) {
+ (function() {
+ var args = process.argv;
+ if (args.length < 3 || (args[2] == '--help' || args[2] == '-h')) {
+ console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'update')) + ' <path_to_project>');
+ process.exit(1);
+ } else {
+ exports.updateProject(args[2]);
+ }
+ })();
+}