Modernized build format to use the current check_reqs/create/update format for Cordova platforms
diff --git a/bin/check_reqs b/bin/check_reqs
new file mode 100755
index 0000000..a5fc642
--- /dev/null
+++ b/bin/check_reqs
@@ -0,0 +1,31 @@
+#!/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 check_reqs = require('./lib/check_reqs');
+
+check_reqs.run().done(
+ function success() {
+ console.log('Looks like your environment fully supports cordova-webos development!');
+ }, function fail(err) {
+ console.log(err);
+ process.exit(2);
+ }
+);
diff --git a/bin/check_reqs.bat b/bin/check_reqs.bat
new file mode 100755
index 0000000..d060302
--- /dev/null
+++ b/bin/check_reqs.bat
@@ -0,0 +1,26 @@
+:: 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.
+
+@ECHO OFF
+SET script_path="%~dp0check_reqs"
+IF EXIST %script_path% (
+ node "%script_path%" %*
+) ELSE (
+ ECHO.
+ ECHO ERROR: Could not find 'check_reqs' script in 'bin' folder, aborting...>&2
+ EXIT /B 1
+)
diff --git a/bin/create b/bin/create
new file mode 100755
index 0000000..18a9430
--- /dev/null
+++ b/bin/create
@@ -0,0 +1,36 @@
+#!/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 path = require('path');
+var create = require('./lib/create');
+var args = process.argv;
+
+// Support basic help commands
+if(args.length < 3 || (args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
+ args[2] == 'help' || args[2] == '-help' || args[2] == '/help')) {
+ console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'create')) + ' <path_to_new_project> <project_id> <project_name>');
+ console.log(' <path_to_new_project>: Path to your new Cordova webOS project');
+ console.log(' <project_id>: Package name, following reverse-domain style convention');
+ console.log(' <project_name>: Project name');
+ process.exit(1);
+} else {
+ create.createProject(args[2], args[3], args[4], args[5]);
+}
+
diff --git a/bin/create.bat b/bin/create.bat
new file mode 100755
index 0000000..c15cbcb
--- /dev/null
+++ b/bin/create.bat
@@ -0,0 +1,26 @@
+:: 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.
+
+@ECHO OFF
+SET script_path="%~dp0create"
+IF EXIST %script_path% (
+ node %script_path% %*
+) ELSE (
+ ECHO.
+ ECHO ERROR: Could not find 'create' script in 'bin' folder, aborting...>&2
+ EXIT /B 1
+)
\ No newline at end of file
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
new file mode 100755
index 0000000..d9f745b
--- /dev/null
+++ b/bin/lib/check_reqs.js
@@ -0,0 +1,59 @@
+#!/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 child_process = require("child_process"),
+ Q = require("q"),
+ ext = ((process.platform.indexOf("win")==0) ? "": ".sh");
+
+// Returns a promise.
+module.exports.check_ares_package = function() {
+ var d = Q.defer();
+ child_process.exec("ares-package" + ext + " -V", function(err, stdout, stderr) {
+ if (err) d.reject(new Error("ERROR : executing command \"ares-package" + ext + "\", make sure you have ares-webos-sdk installed and added to your path."));
+ else d.resolve();
+ });
+ return d.promise;
+}
+
+// Returns a promise.
+module.exports.check_ares_install = function() {
+ var d = Q.defer();
+ child_process.exec("ares-install" + ext + " -V", function(err, stdout, stderr) {
+ if (err) d.reject(new Error("ERROR : executing command \"ares-install" + ext + "\", make sure you have ares-webos-sdk installed and added to your path."));
+ else d.resolve();
+ });
+ return d.promise;
+}
+
+// Returns a promise.
+module.exports.check_ares_launch = function() {
+ var d = Q.defer();
+ child_process.exec("ares-launch" + ext + " -V", function(err, stdout, stderr) {
+ if (err) d.reject(new Error("ERROR : executing command \"ares-launch" + ext + "\", make sure you have ares-webos-sdk installed and added to your path."));
+ else d.resolve();
+ });
+ return d.promise;
+}
+
+// Returns a promise.
+module.exports.run = function() {
+ return Q.all([this.check_ares_package(), this.check_ares_install(), this.check_ares_launch()]);
+}
\ No newline at end of file
diff --git a/bin/lib/create.js b/bin/lib/create.js
new file mode 100755
index 0000000..c547883
--- /dev/null
+++ b/bin/lib/create.js
@@ -0,0 +1,87 @@
+#!/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 fs = require('fs'),
+ shjs = require('shelljs'),
+ args = process.argv,
+ path = require('path'),
+ ROOT = path.join(__dirname, '..', '..'),
+ check_reqs = require('./check_reqs');
+
+exports.createProject = function(project_path,project_id,project_name){
+ var VERSION = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8');
+
+ // Set default values for path, package and name
+ project_path = typeof project_path !== 'undefined' ? project_path : "CordovaExample";
+ project_id = typeof project_id !== 'undefined' ? project_id : 'org.apache.cordova.example';
+ project_name = typeof project_name !== 'undefined' ? project_name : 'CordovaExample';
+
+ // Check if project already exists
+ if(fs.existsSync(project_path)) {
+ console.error('Project already exists! Delete and recreate');
+ process.exit(2);
+ }
+
+ // Check that requirements are met and proper targets are installed
+ check_reqs.run().done(
+ function success() {
+ console.log('Creating webOS project');
+ console.log('Project Path: '+ path.relative(process.cwd(),project_path));
+ console.log('Project ID: '+ project_id);
+ console.log('Project Name: '+ project_name);
+
+ //copy template folder
+ shjs.cp('-r', path.join(ROOT, 'bin', 'templates', 'project', 'www'), project_path);
+
+ // update appinfo.json
+ try {
+ var appInfoPath = path.join(project_path, 'www', 'appinfo.json');
+ var appInfo = JSON.parse(fs.readFileSync(appInfoPath, {encoding:"utf8"}));
+ appInfo.id = project_id;
+ appInfo.title = project_name;
+ fs.writeFileSync(appInfoPath, JSON.stringify(appInfo, null, "\t"));
+ } catch(e) {
+ console.warn('AppInfo initialization failed: ' + e);
+ }
+
+ //copy cordova js file
+ shjs.cp(path.join(ROOT, 'cordova.js'), path.join(project_path,'www'));
+
+ //copy cordova folder
+ shjs.cp('-r', path.join(ROOT, 'bin', 'templates', 'project', 'cordova'), project_path);
+ shjs.cp('-r', path.join(ROOT, 'bin', 'node_modules'), path.join(project_path,'cordova'));
+
+ // copy check_reqs
+ shjs.cp(path.join(ROOT, 'bin', 'check_reqs.bat'), path.join(project_path, 'cordova', 'check_reqs.bat'));
+ shjs.cp(path.join(ROOT, 'bin', 'check_reqs'), path.join(project_path, 'cordova', 'check_reqs'));
+ shjs.cp(path.join(ROOT, 'bin', 'lib', 'check_reqs.js'), path.join(project_path, 'cordova', 'lib', 'check_reqs.js'));
+
+ // update permissions
+ shjs.find(path.join(project_path, 'cordova')).forEach(function(entry) {
+ shjs.chmod(755, entry);
+ });
+ console.log('Project successfully created.');
+ }, function fail(err) {
+ console.error('Please make sure you meet the software requirements in order to build a webOS Cordova project');
+ process.exit(2);
+ }
+ );
+}
diff --git a/bin/lib/update.js b/bin/lib/update.js
new file mode 100755
index 0000000..0e5a098
--- /dev/null
+++ b/bin/lib/update.js
@@ -0,0 +1,75 @@
+#!/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 copyJs(projectPath) {
+ shell.cp('-f', path.join(ROOT, 'cordova.js'), path.join(projectPath, 'www'));
+}
+
+function copyScripts(projectPath) {
+ var srcScriptsDir = path.join(ROOT, 'bin', 'templates', 'project', 'cordova');
+ var destScriptsDir = path.join(projectPath, 'cordova');
+ // Delete old scripts directory.
+ shell.rm('-rf', destScriptsDir);
+ // Copy in the new ones.
+ shell.cp('-r', srcScriptsDir, projectPath);
+ shell.cp('-r', path.join(ROOT, 'bin', 'node_modules'), destScriptsDir);
+ shell.cp(path.join(ROOT, 'bin', 'check_reqs.bat'), path.join(destScriptsDir, 'check_reqs.bat'));
+ shell.cp(path.join(ROOT, 'bin', 'check_reqs'), path.join(destScriptsDir, 'check_reqs'));
+ shell.cp(path.join(ROOT, 'bin', 'lib', 'check_reqs.js'), path.join(destScriptsDir, 'lib', 'check_reqs.js'));
+ // Make sure they are executable.
+ shell.find(destScriptsDir).forEach(function(entry) {
+ shell.chmod(755, entry);
+ });
+}
+
+exports.updateProject = function(projectPath) {
+ var version = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8').trim();
+ setShellFatal(true, function() {
+ copyJs(projectPath);
+ copyScripts(projectPath);
+ console.log('webOS 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]);
+ }
+ })();
+}
+
diff --git a/bin/update b/bin/update
new file mode 100755
index 0000000..9ba3d71
--- /dev/null
+++ b/bin/update
@@ -0,0 +1,31 @@
+#! /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 path = require('path')
+var args = process.argv;
+var update = require('./lib/update');
+
+// Support basic help commands
+if(args.length < 3 || (args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
+ args[2] == 'help' || args[2] == '-help' || args[2] == '/help')) {
+ console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'update')) + ' <path_to_project>');
+ process.exit(1);
+} else {
+ update.updateProject(args[2]);
+}
diff --git a/bin/update.bat b/bin/update.bat
new file mode 100755
index 0000000..b49ecf3
--- /dev/null
+++ b/bin/update.bat
@@ -0,0 +1,26 @@
+:: 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.
+
+@ECHO OFF
+SET script_path="%~dp0update"
+IF EXIST %script_path% (
+ node %script_path% %*
+) ELSE (
+ ECHO.
+ ECHO ERROR: Could not find 'update' script in 'bin' folder, aborting...>&2
+ EXIT /B 1
+)