Merge pull request #162 from brodybits/cb-remove-browserify
[CB-14156] Remove browserify
diff --git a/Gruntfile.js b/Gruntfile.js
index ebf9a19..eee5161 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -34,20 +34,6 @@
"ubuntu": {},
"browser": {}
},
- "compile-browserify": {
- "amazon-fireos": {},
- "android": {},
- "blackberry10": {},
- "ios": {},
- "osx": {},
- "test": {},
- "windows": { useWindowsLineEndings: true },
- "wp8": { useWindowsLineEndings: true },
- "firefoxos": {},
- "webos": {},
- "ubuntu": {},
- "browser": {}
- },
clean: ['pkg'],
});
@@ -63,6 +49,4 @@
grunt.registerTask('test', ['compile:test', '_test']);
grunt.registerTask('btest', ['compile:test', '_btest']);
grunt.registerTask('cover', ['compile', '_cover']);
- grunt.registerTask('test-browserify', ['compile-browserify:test', '_test']);
- grunt.registerTask('btest-browserify', ['compile-browserify:test', '_btest']);
};
diff --git a/README.md b/README.md
index 71ef136..d46fbbc 100644
--- a/README.md
+++ b/README.md
@@ -78,16 +78,6 @@
grunt compile --android='../custompath/cordova-android' --ios='../custompath/cordova-ios'
-To create the browserify version of the js, run:
-
- grunt compile-browserify --platformVersion=4.0.0
-
-To compile the browserify version of the js for just one platform, run:
-
- grunt compile-browserify:android --platformVersion=4.0.0
-
-NOTE: browserify method does not support custom paths for platform repos.
-
For integration, see the 'Integration' section below.
## Known Issues
diff --git a/package.json b/package.json
index b1faaae..f7843ff 100644
--- a/package.json
+++ b/package.json
@@ -18,8 +18,7 @@
"eslint": "eslint src test pkg",
"test": "grunt test && npm run eslint",
"btest": "grunt btest && npm run eslint",
- "build": "grunt compile",
- "build-browserify": "grunt compile-browserify"
+ "build": "grunt compile"
},
"license": "Apache-2.0",
"contributors": [
@@ -68,6 +67,7 @@
"email": "stevengill97@gmail.com"
}
],
+ "dependencies": {},
"devDependencies": {
"eslint": "^4.7.2",
"eslint-config-semistandard": "^11.0.0",
@@ -84,9 +84,6 @@
"jsdom-no-contextify": "^3.1.0",
"mkdirp": "^0.5.0"
},
- "dependencies": {
- "browserify": "14.4.0"
- },
"cordova-platforms": {
"cordova-android": "../cordova-android",
"cordova-ios": "../cordova-ios",
diff --git a/src/common/init_b.js b/src/common/init_b.js
deleted file mode 100644
index 336f098..0000000
--- a/src/common/init_b.js
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- *
- * 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 channel = require('cordova/channel');
-var cordova = require('cordova');
-var modulemapper = require('cordova/modulemapper');
-var platform = require('cordova/platform');
-var pluginloader = require('cordova/pluginloader');
-var utils = require('cordova/utils');
-
-var platformInitChannelsArray = [channel.onDOMContentLoaded, channel.onNativeReady, channel.onPluginsReady];
-
-// setting exec
-cordova.exec = require('cordova/exec');
-
-function logUnfiredChannels (arr) {
- for (var i = 0; i < arr.length; ++i) {
- if (arr[i].state !== 2) {
- console.log('Channel not fired: ' + arr[i].type);
- }
- }
-}
-
-window.setTimeout(function () {
- if (channel.onDeviceReady.state !== 2) {
- console.log('deviceready has not fired after 5 seconds.');
- logUnfiredChannels(platformInitChannelsArray);
- logUnfiredChannels(channel.deviceReadyChannelsArray);
- }
-}, 5000);
-
-// Replace navigator before any modules are required(), to ensure it happens as soon as possible.
-// We replace it so that properties that can't be clobbered can instead be overridden.
-function replaceNavigator (origNavigator) {
- var CordovaNavigator = function () {};
- CordovaNavigator.prototype = origNavigator;
- var newNavigator = new CordovaNavigator();
- // This work-around really only applies to new APIs that are newer than Function.bind.
- // Without it, APIs such as getGamepads() break.
- if (CordovaNavigator.bind) {
- for (var key in origNavigator) {
- if (typeof origNavigator[key] === 'function') {
- newNavigator[key] = origNavigator[key].bind(origNavigator);
- } else {
- (function (k) {
- utils.defineGetterSetter(newNavigator, key, function () {
- return origNavigator[k];
- });
- })(key);
- }
- }
- }
- return newNavigator;
-}
-if (window.navigator) {
- window.navigator = replaceNavigator(window.navigator);
-}
-
-if (!window.console) {
- window.console = {
- log: function () {}
- };
-}
-if (!window.console.warn) {
- window.console.warn = function (msg) {
- this.log('warn: ' + msg);
- };
-}
-
-// Register pause, resume and deviceready channels as events on document.
-channel.onPause = cordova.addDocumentEventHandler('pause');
-channel.onResume = cordova.addDocumentEventHandler('resume');
-channel.onActivated = cordova.addDocumentEventHandler('activated');
-channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
-
-// Listen for DOMContentLoaded and notify our channel subscribers.
-if (document.readyState === 'complete' || document.readyState === 'interactive') {
- channel.onDOMContentLoaded.fire();
-} else {
- document.addEventListener('DOMContentLoaded', function () {
- channel.onDOMContentLoaded.fire();
- }, false);
-}
-
-// _nativeReady is global variable that the native side can set
-// to signify that the native code is ready. It is a global since
-// it may be called before any cordova JS is ready.
-if (window._nativeReady) {
- channel.onNativeReady.fire();
-}
-
-// Call the platform-specific initialization.
-platform.bootstrap && platform.bootstrap();
-
-// Wrap in a setTimeout to support the use-case of having plugin JS appended to cordova.js.
-// The delay allows the attached modules to be defined before the plugin loader looks for them.
-setTimeout(function () {
- pluginloader.load(function () {
- channel.onPluginsReady.fire();
- });
-}, 0);
-
-/**
- * Create all cordova objects once native side is ready.
- */
-channel.join(function () {
- modulemapper.mapModules(window);
-
- platform.initialize && platform.initialize();
-
- // Fire event to notify that all objects are created
- channel.onCordovaReady.fire();
-
- // Fire onDeviceReady event once page has fully loaded, all
- // constructors have run and cordova info has been received from native
- // side.
- channel.join(function () {
- require('cordova').fireDocumentEvent('deviceready');
- }, channel.deviceReadyChannelsArray);
-
-}, platformInitChannelsArray);
diff --git a/src/common/modulemapper_b.js b/src/common/modulemapper_b.js
deleted file mode 100644
index 46dd1d3..0000000
--- a/src/common/modulemapper_b.js
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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 builder = require('cordova/builder');
-var symbolList = [];
-var deprecationMap;
-
-exports.reset = function () {
- symbolList = [];
- deprecationMap = {};
-};
-
-function addEntry (strategy, moduleName, symbolPath, opt_deprecationMessage) {
- symbolList.push(strategy, moduleName, symbolPath);
- if (opt_deprecationMessage) {
- deprecationMap[symbolPath] = opt_deprecationMessage;
- }
-}
-
-// Note: Android 2.3 does have Function.bind().
-exports.clobbers = function (moduleName, symbolPath, opt_deprecationMessage) {
- addEntry('c', moduleName, symbolPath, opt_deprecationMessage);
-};
-
-exports.merges = function (moduleName, symbolPath, opt_deprecationMessage) {
- addEntry('m', moduleName, symbolPath, opt_deprecationMessage);
-};
-
-exports.defaults = function (moduleName, symbolPath, opt_deprecationMessage) {
- addEntry('d', moduleName, symbolPath, opt_deprecationMessage);
-};
-
-exports.runs = function (moduleName) {
- addEntry('r', moduleName, null);
-};
-
-function prepareNamespace (symbolPath, context) {
- if (!symbolPath) {
- return context;
- }
- var parts = symbolPath.split('.');
- var cur = context;
- for (var i = 0, part; part = parts[i]; ++i) { // eslint-disable-line no-cond-assign
- cur = cur[part] = cur[part] || {};
- }
- return cur;
-}
-
-exports.mapModules = function (context) {
- var origSymbols = {};
- context.CDV_origSymbols = origSymbols;
- for (var i = 0, len = symbolList.length; i < len; i += 3) {
- var strategy = symbolList[i];
- var moduleName = symbolList[i + 1];
- var module = require(moduleName);
- // <runs/>
- if (strategy === 'r') {
- continue;
- }
- var symbolPath = symbolList[i + 2];
- var lastDot = symbolPath.lastIndexOf('.');
- var namespace = symbolPath.substr(0, lastDot);
- var lastName = symbolPath.substr(lastDot + 1);
-
- var deprecationMsg = symbolPath in deprecationMap ? 'Access made to deprecated symbol: ' + symbolPath + '. ' + deprecationMsg : null;
- var parentObj = prepareNamespace(namespace, context);
- var target = parentObj[lastName];
-
- if (strategy === 'm' && target) {
- builder.recursiveMerge(target, module);
- } else if ((strategy === 'd' && !target) || (strategy !== 'd')) {
- if (!(symbolPath in origSymbols)) {
- origSymbols[symbolPath] = target;
- }
- builder.assignOrWrapInDeprecateGetter(parentObj, lastName, module, deprecationMsg);
- }
- }
-};
-
-exports.getOriginalSymbol = function (context, symbolPath) {
- var origSymbols = context.CDV_origSymbols;
- if (origSymbols && (symbolPath in origSymbols)) {
- return origSymbols[symbolPath];
- }
- var parts = symbolPath.split('.');
- var obj = context;
- for (var i = 0; i < parts.length; ++i) {
- obj = obj && obj[parts[i]];
- }
- return obj;
-};
-
-exports.reset();
diff --git a/src/common/pluginloader_b.js b/src/common/pluginloader_b.js
deleted file mode 100644
index 418dc54..0000000
--- a/src/common/pluginloader_b.js
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- *
- * 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 modulemapper = require('cordova/modulemapper');
-
-// Handler for the cordova_plugins.js content.
-// See plugman's plugin_loader.js for the details of this object.
-function handlePluginsObject (moduleList) {
- // if moduleList is not defined or empty, we've nothing to do
- if (!moduleList || !moduleList.length) {
- return;
- }
-
- // Loop through all the modules and then through their clobbers and merges.
- for (var i = 0, module; module = moduleList[i]; i++) { // eslint-disable-line no-cond-assign
- if (module.clobbers && module.clobbers.length) {
- for (var j = 0; j < module.clobbers.length; j++) {
- modulemapper.clobbers(module.id, module.clobbers[j]);
- }
- }
-
- if (module.merges && module.merges.length) {
- for (var k = 0; k < module.merges.length; k++) {
- modulemapper.merges(module.id, module.merges[k]);
- }
- }
-
- // Finally, if runs is truthy we want to simply require() the module.
- if (module.runs) {
- modulemapper.runs(module.id);
- }
- }
-}
-
-// Loads all plugins' js-modules. Plugin loading is syncronous in browserified bundle
-// but the method accepts callback to be compatible with non-browserify flow.
-// onDeviceReady is blocked on onPluginsReady. onPluginsReady is fired when there are
-// no plugins to load, or they are all done.
-exports.load = function (callback) {
- var moduleList = require('cordova/plugin_list');
- handlePluginsObject(moduleList);
-
- callback();
-};
diff --git a/src/cordova_b.js b/src/cordova_b.js
deleted file mode 100644
index 4e918f5..0000000
--- a/src/cordova_b.js
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- *
- * 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.
- *
-*/
-
-// Workaround for Windows 10 in hosted environment case
-// http://www.w3.org/html/wg/drafts/html/master/browsers.html#named-access-on-the-window-object
-if (window.cordova && !(window.cordova instanceof HTMLElement)) { // eslint-disable-line no-undef
- throw new Error('cordova already defined');
-}
-
-var channel = require('cordova/channel');
-var platform = require('cordova/platform');
-
-/**
- * Intercept calls to addEventListener + removeEventListener and handle deviceready,
- * resume, and pause events.
- */
-var m_document_addEventListener = document.addEventListener;
-var m_document_removeEventListener = document.removeEventListener;
-var m_window_addEventListener = window.addEventListener;
-var m_window_removeEventListener = window.removeEventListener;
-
-/**
- * Houses custom event handlers to intercept on document + window event listeners.
- */
-var documentEventHandlers = {};
-var windowEventHandlers = {};
-
-document.addEventListener = function (evt, handler, capture) {
- var e = evt.toLowerCase();
- if (typeof documentEventHandlers[e] !== 'undefined') {
- documentEventHandlers[e].subscribe(handler);
- } else {
- m_document_addEventListener.call(document, evt, handler, capture);
- }
-};
-
-window.addEventListener = function (evt, handler, capture) {
- var e = evt.toLowerCase();
- if (typeof windowEventHandlers[e] !== 'undefined') {
- windowEventHandlers[e].subscribe(handler);
- } else {
- m_window_addEventListener.call(window, evt, handler, capture);
- }
-};
-
-document.removeEventListener = function (evt, handler, capture) {
- var e = evt.toLowerCase();
- // If unsubscribing from an event that is handled by a plugin
- if (typeof documentEventHandlers[e] !== 'undefined') {
- documentEventHandlers[e].unsubscribe(handler);
- } else {
- m_document_removeEventListener.call(document, evt, handler, capture);
- }
-};
-
-window.removeEventListener = function (evt, handler, capture) {
- var e = evt.toLowerCase();
- // If unsubscribing from an event that is handled by a plugin
- if (typeof windowEventHandlers[e] !== 'undefined') {
- windowEventHandlers[e].unsubscribe(handler);
- } else {
- m_window_removeEventListener.call(window, evt, handler, capture);
- }
-};
-
-function createEvent (type, data) {
- var event = document.createEvent('Events');
- event.initEvent(type, false, false);
- if (data) {
- for (var i in data) {
- if (data.hasOwnProperty(i)) {
- event[i] = data[i];
- }
- }
- }
- return event;
-}
-
-/* eslint-disable no-undef */
-var cordova = {
- platformVersion: PLATFORM_VERSION_BUILD_LABEL,
- version: PLATFORM_VERSION_BUILD_LABEL,
- require: require,
- platformId: platform.id,
-
- /* eslint-enable no-undef */
-
- /**
- * Methods to add/remove your own addEventListener hijacking on document + window.
- */
- addWindowEventHandler: function (event) {
- return (windowEventHandlers[event] = channel.create(event));
- },
- addStickyDocumentEventHandler: function (event) {
- return (documentEventHandlers[event] = channel.createSticky(event));
- },
- addDocumentEventHandler: function (event) {
- return (documentEventHandlers[event] = channel.create(event));
- },
- removeWindowEventHandler: function (event) {
- delete windowEventHandlers[event];
- },
- removeDocumentEventHandler: function (event) {
- delete documentEventHandlers[event];
- },
- /**
- * Retrieve original event handlers that were replaced by Cordova
- *
- * @return object
- */
- getOriginalHandlers: function () {
- return {'document': {'addEventListener': m_document_addEventListener, 'removeEventListener': m_document_removeEventListener},
- 'window': {'addEventListener': m_window_addEventListener, 'removeEventListener': m_window_removeEventListener}};
- },
- /**
- * Method to fire event from native code
- * bNoDetach is required for events which cause an exception which needs to be caught in native code
- */
- fireDocumentEvent: function (type, data, bNoDetach) {
- var evt = createEvent(type, data);
- if (typeof documentEventHandlers[type] !== 'undefined') {
- if (bNoDetach) {
- documentEventHandlers[type].fire(evt);
- } else {
- setTimeout(function () {
- // Fire deviceready on listeners that were registered before cordova.js was loaded.
- if (type === 'deviceready') {
- document.dispatchEvent(evt);
- }
- documentEventHandlers[type].fire(evt);
- }, 0);
- }
- } else {
- document.dispatchEvent(evt);
- }
- },
- fireWindowEvent: function (type, data) {
- var evt = createEvent(type, data);
- if (typeof windowEventHandlers[type] !== 'undefined') {
- setTimeout(function () {
- windowEventHandlers[type].fire(evt);
- }, 0);
- } else {
- window.dispatchEvent(evt);
- }
- },
-
- /**
- * Plugin callback mechanism.
- */
- // Randomize the starting callbackId to avoid collisions after refreshing or navigating.
- // This way, it's very unlikely that any new callback would get the same callbackId as an old callback.
- callbackId: Math.floor(Math.random() * 2000000000),
- callbacks: {},
- callbackStatus: {
- NO_RESULT: 0,
- OK: 1,
- CLASS_NOT_FOUND_EXCEPTION: 2,
- ILLEGAL_ACCESS_EXCEPTION: 3,
- INSTANTIATION_EXCEPTION: 4,
- MALFORMED_URL_EXCEPTION: 5,
- IO_EXCEPTION: 6,
- INVALID_ACTION: 7,
- JSON_EXCEPTION: 8,
- ERROR: 9
- },
- /**
- * Called by native code when returning successful result from an action.
- */
- callbackSuccess: function (callbackId, args) {
- this.callbackFromNative(callbackId, true, args.status, [args.message], args.keepCallback);
- },
- /**
- * Called by native code when returning error result from an action.
- */
- callbackError: function (callbackId, args) {
- // TODO: Deprecate callbackSuccess and callbackError in favour of callbackFromNative.
- // Derive success from status.
- this.callbackFromNative(callbackId, false, args.status, [args.message], args.keepCallback);
- },
- /**
- * Called by native code when returning the result from an action.
- */
- callbackFromNative: function (callbackId, isSuccess, status, args, keepCallback) {
- try {
- var callback = cordova.callbacks[callbackId];
- if (callback) {
- if (isSuccess && status === cordova.callbackStatus.OK) {
- callback.success && callback.success.apply(null, args);
- } else if (!isSuccess) {
- callback.fail && callback.fail.apply(null, args);
- }
- /*
- else
- Note, this case is intentionally not caught.
- this can happen if isSuccess is true, but callbackStatus is NO_RESULT
- which is used to remove a callback from the list without calling the callbacks
- typically keepCallback is false in this case
- */
-
- // Clear callback if not expecting any more results
- if (!keepCallback) {
- delete cordova.callbacks[callbackId];
- }
- }
- } catch (err) {
- var msg = 'Error in ' + (isSuccess ? 'Success' : 'Error') + ' callbackId: ' + callbackId + ' : ' + err;
- console && console.log && console.log(msg);
- this.fireWindowEvent('cordovacallbackerror', { 'message': msg });
- throw err;
- }
- },
- addConstructor: function (func) {
- channel.onCordovaReady.subscribe(function () {
- try {
- func();
- } catch (e) {
- console.log('Failed to run constructor: ' + e);
- }
- });
- }
-};
-
-window.cordova = module.exports = cordova;
diff --git a/tasks/compile-browserify.js b/tasks/compile-browserify.js
deleted file mode 100644
index cfafff2..0000000
--- a/tasks/compile-browserify.js
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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');
-var path = require('path');
-var pkgJson = require(process.cwd() + '/package.json');
-
-try {
- require('browserify');
-} catch (e) {
- console.error("\nbrowserify is not installed, you need to:\n\trun `npm install` from " + require('path').dirname(__dirname)+"\n");
- process.exit(1);
-}
-
-var generate = require('./lib/packager-browserify');
-
-module.exports = function(grunt) {
- grunt.registerMultiTask('compile-browserify', 'Packages cordova.js browserify style', function() {
- var done = this.async();
- var platformName = this.target;
- var useWindowsLineEndings = this.data.useWindowsLineEndings;
-
- //grabs --platformVersion flag
- var flags = grunt.option.flags();
- var platformVersion;
- flags.forEach(function(flag) {
- if (flag.indexOf('platformVersion') > -1) {
- var equalIndex = flag.indexOf('=');
- platformVersion = flag.slice(equalIndex + 1);
- }
- });
- if(!platformVersion){
- var platformPath = pkgJson['cordova-platforms']['cordova-'+platformName];
- if(platformPath && fs.existsSync(platformPath)) {
- var platformPkgJson = require('../' + platformPath +'/package.json');
- platformVersion = platformPkgJson.version;
- } else {
- console.log('platformVersion not supplied. Setting platformVersion to N/A');
- console.log('ex: grunt compile-browserify --platformVersion=3.6.0');
- platformVersion = 'N/A';
- }
- }
- generate(platformName, useWindowsLineEndings, platformVersion, platformPath, done);
- });
-}
diff --git a/tasks/lib/bundle-browserify.js b/tasks/lib/bundle-browserify.js
deleted file mode 100644
index 8eaecb8..0000000
--- a/tasks/lib/bundle-browserify.js
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF
- * or more contributor license agreements. See th
- * distributed with this work for additional infor
- * regarding copyright ownership. The ASF license
- * to you under the Apache License, Version 2.0 (t
- * "License"); you may not use this file except in
- * with the License. You may obtain a copy of the
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to
- * software distributed under the License is distr
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
- * KIND, either express or implied. See the Licen
- * specific language governing permissions and lim
- * under the License.
- */
-var fs = require('fs');
-var path = require('path');
-var browserify = require('browserify');
-var root = path.join(__dirname, '..', '..');
-var pkgJson = require('../../package.json');
-var collectFiles = require('./collect-files');
-var copyProps = require('./copy-props');
-
-module.exports = function bundle(platform, debug, commitId, platformVersion, platformPath) {
-
- if (fs.existsSync(platformPath) && fs.existsSync(path.join(platformPath, 'cordova-js-src'))) {
- platformPath = path.join(platformPath, 'cordova-js-src');
- } else {
- if(platform === 'test') {
- platformPath = path.resolve(root, 'src', 'legacy-exec', platform);
- } else {
- console.log('Your version of ' + platform + ' does not contain cordova-js-src. Update to a newer version of ' + platform + '.');
- }
- }
-
- var platformDirname = platform === 'amazon-fireos' ? 'android' : platform;
-
- var modules = {'cordova': path.resolve(root, 'src', 'cordova_b.js')};
- copyProps(modules, collectFiles(path.resolve(root, 'src', 'common'), 'cordova'));
- copyProps(modules, collectFiles(platformPath, 'cordova'));
-
- // Replace standart initialization script with browserify's one
- delete modules['cordova/init_b'];
- delete modules['cordova/modulemapper_b'];
- delete modules['cordova/pluginloader_b'];
- modules['cordova/init'] = path.resolve(root, 'src', 'common', 'init_b.js');
- modules['cordova/modulemapper'] = path.resolve(root, 'src', 'common', 'modulemapper_b.js');
- modules['cordova/pluginloader'] = path.resolve(root, 'src', 'common', 'pluginloader_b.js');
-
- // test doesn't support custom paths
- if (platform === 'test') {
- var androidPath = path.resolve(pkgJson['cordova-platforms']['cordova-android']);
- var iosPath = path.resolve(pkgJson['cordova-platforms']['cordova-ios']);
- var testFilesPath = path.resolve(androidPath, 'cordova-js-src', 'android');
- // Add android platform-specific modules that have tests to the test bundle.
- if(fs.existsSync(androidPath)) {
-
- modules['cordova/android/exec'] = path.resolve(androidPath, 'cordova-js-src', 'exec.js');
- } else {
- //testFilesPath = path.resolve('src', 'legacy-exec', 'android', 'android');
- //modules['cordova/android/exec'] = path.resolve(root, 'src', 'legacy-exec', 'android', 'exec.js');
- console.log('Couldn\'t add android test files.');
- throw 'Stopped process';
- }
- copyProps(modules, collectFiles(testFilesPath, 'cordova/android'));
-
- //Add iOS platform-specific modules that have tests for the test bundle.
- if(fs.existsSync(iosPath)) {
- modules['cordova/ios/exec'] = path.join(iosPath, 'cordova-js-src', 'exec.js');
- } else {
- //modules['cordova/ios/exec'] = path.resolve(root, 'src', 'legacy-exec', 'ios', 'exec.js');
- console.log('Couldn\'t add iOS test files.');
- throw 'Stopped process';
- }
- copyProps(modules, collectFiles(testFilesPath, 'cordova/ios'));
- }
-
- modules = Object.keys(modules)
- .map(function (moduleId) {
- return {
- file: modules[moduleId],
- expose: moduleId
- };
- });
-
- return browserify({debug: !!debug, detectGlobals: false})
- .require(modules)
- .exclude('cordova/plugin_list');
-};
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
deleted file mode 100644
index e5c8d41..0000000
--- a/tasks/lib/packager-browserify.js
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF
- * or more contributor license agreements. See th
- * distributed with this work for additional infor
- * regarding copyright ownership. The ASF license
- * to you under the Apache License, Version 2.0 (t
- * "License"); you may not use this file except in
- * with the License. You may obtain a copy of the
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to
- * software distributed under the License is distr
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
- * KIND, either express or implied. See the Licen
- * specific language governing permissions and lim
- * under the License.
- */
-var fs = require('fs');
-var path = require('path');
-var util = require('util');
-var bundle = require('./bundle-browserify');
-var computeCommitId = require('./compute-commit-id');
-var writeLicenseHeader = require('./write-license-header');
-
-module.exports = function generate(platform, useWindowsLineEndings, platformVersion, platformPath, done) {
- computeCommitId(function(commitId) {
- var outReleaseFile, outReleaseFileStream,
- outDebugFile, outDebugFileStream,
- releaseBundle, debugBundle;
- var time = new Date().valueOf();
-
- if (!fs.existsSync('pkg')) {
- fs.mkdirSync('pkg');
- }
-
- outReleaseFile = path.join('pkg', 'cordova.' + platform + '.js');
- outReleaseFileStream = fs.createWriteStream(outReleaseFile);
-
- // write license header
- writeLicenseHeader(outReleaseFileStream, platform, commitId, platformVersion);
-
- bundle(platform, false, commitId, platformVersion, platformPath)
- .add(path.resolve(__dirname, '..', '..', 'src/scripts/bootstrap.js'))
- .bundle()
- .pipe(outReleaseFileStream);
-
- outReleaseFileStream.on('finish', function() {
- var newtime = new Date().valueOf() - time;
- console.log('generated cordova.' + platform + '.js @ ' + commitId + ' in ' + newtime + 'ms');
- done();
- });
- });
-};
diff --git a/tasks/lib/test-browser.js b/tasks/lib/test-browser.js
deleted file mode 100644
index 5933b9b..0000000
--- a/tasks/lib/test-browser.js
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- *
- * 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');
-var path = require('path');
-
-var express = require('express');
-
-var collect = require('./collect');
-
-var testLibName = path.join(__dirname, '..', '..', 'pkg', 'cordova.test.js');
-var testLib = fs.readFileSync(testLibName, 'utf8');
-
-var pathToTemplate = path.join(__dirname, '..', 'templates', 'suite.html');
-var pathToVendor = path.join(__dirname, '..', 'vendor');
-var pathToJasmine = path.join(__dirname, '..', '..', 'node_modules', 'jasmine-node', 'lib', 'jasmine-node');
-var pathToTests = path.join(__dirname, '..', '..', 'test');
-
-var template = fs.readFileSync(pathToTemplate, "utf-8");
-
-// middlewar for GET '/cordova.test.js'
-function cordovajs(req, res) {
- res.writeHead(200, {
- "Cache-Control": "no-cache",
- "Content-Type": "text/javascript"
- });
- res.end(testLib);
-}
-
-// middleware for GET '/'
-function root(req, res) {
- res.writeHead(200, {
- "Cache-Control": "no-cache",
- "Content-Type": "text/html"
- });
-
- //FIXME in place collect thing is atrocious
- //create the script tags to include
- var tests = [];
- collect(path.join(__dirname, '..', '..', 'test'), tests);
- var specs = tests.map(function (file, path) {
- return '<script src="' + file.replace(/\\/g, '/').replace(/^.*\/test\//, "/") +
- '" type="text/javascript" charset="utf-8"></script>';
- }).join('\n');
-
- template = template.replace(/<!-- ##TESTS## -->/g, specs);
-
- // write the document
- res.end(template);
-}
-
-// connect router defn
-function routes(app) {
- app.get('/cordova.test.js', cordovajs);
- app.get('/', root);
-}
-
-module.exports = function() {
- console.log('starting browser-based tests');
-
- var app = express();
-
- app.set('port', 3000);
-
- app.use(express.static(pathToVendor));
- app.use(express.static(pathToJasmine));
- app.use(express.static(pathToTests));
-
- routes(app);
-
- app.listen(3000, () => console.log('Test Server running on: http://localhost:3000'));
-};
-
diff --git a/tasks/lib/write-license-header.js b/tasks/lib/write-license-header.js
deleted file mode 100644
index f9a394b..0000000
--- a/tasks/lib/write-license-header.js
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *
- * 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 util = require('util');
-var fs = require('fs');
-var licensePath = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
-
-module.exports = function(outStream, platform, commitId, platformVersion, symbolList) {
- // some poppycock
- var licenseText = util.format("/*\n *%s\n */\n", fs.readFileSync(licensePath, 'utf8').replace(/\n/g, "\n *"));
-
- outStream.write("// Platform: " + platform + "\n", 'utf8');
- outStream.write("// " + commitId + "\n", 'utf8');
- outStream.write("// browserify" + "\n", 'utf8');
- outStream.write(licenseText, 'utf8');
- outStream.write("var PLATFORM_VERSION_BUILD_LABEL = '" + platformVersion + "';\n", 'utf8');
- outStream.write("var define = {moduleMap: []};\n", 'utf8');
- //outStream.write(util.format("var symbolList = %s", JSON.stringify(symbolList)), 'utf8');
-
-}