You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ra...@apache.org on 2018/09/06 22:02:28 UTC
[cordova-lib] branch master updated: GH-676 Remove browserify (#682)
This is an automated email from the ASF dual-hosted git repository.
raphinesse pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-lib.git
The following commit(s) were added to refs/heads/master by this push:
new 2ada2ce GH-676 Remove browserify (#682)
2ada2ce is described below
commit 2ada2cebaa572ad363b16381bf64fe7d783c146d
Author: Raphael von der GrĂ¼n <ra...@gmail.com>
AuthorDate: Fri Sep 7 00:02:26 2018 +0200
GH-676 Remove browserify (#682)
Resolves #676
---
package.json | 3 -
spec/cordova/prepare.spec.js | 3 -
src/cordova/plugin/add.js | 1 -
src/cordova/prepare.js | 7 --
src/plugman/browserify.js | 179 -------------------------------------------
src/plugman/plugman.js | 8 --
6 files changed, 201 deletions(-)
diff --git a/package.json b/package.json
index d481674..277b0c7 100644
--- a/package.json
+++ b/package.json
@@ -17,11 +17,9 @@
"node": ">=6.0.0"
},
"dependencies": {
- "aliasify": "^2.1.0",
"cordova-common": "^2.2.0",
"cordova-create": "^1.1.0",
"cordova-fetch": "^1.3.0",
- "cordova-js": "^4.2.2",
"cordova-serve": "^2.0.0",
"dep-graph": "1.1.0",
"detect-indent": "^5.0.0",
@@ -31,7 +29,6 @@
"indent-string": "^3.2.0",
"init-package-json": "^1.2.0",
"nopt": "4.0.1",
- "opener": "^1.4.3",
"properties-parser": "0.3.1",
"q": "^1.5.1",
"read-chunk": "^3.0.0",
diff --git a/spec/cordova/prepare.spec.js b/spec/cordova/prepare.spec.js
index 8d1565b..e9d5246 100644
--- a/spec/cordova/prepare.spec.js
+++ b/spec/cordova/prepare.spec.js
@@ -170,9 +170,6 @@ describe('cordova/prepare', function () {
expect(platform_api_prepare_mock).toHaveBeenCalled();
});
});
- // TODO: xit'ed the one below as dynamic requires make it difficult to spy on
- // Can we refactor the relevant code to make it testable?
- xit('should invoke browserify if the browserify option is provided');
it('should handle config changes by invoking add_config_changes and save_all', function () {
return prepare.preparePlatforms(['android'], project_dir, {}).then(function () {
expect(platform_munger_mock.prototype.add_config_changes).toHaveBeenCalled();
diff --git a/src/cordova/plugin/add.js b/src/cordova/plugin/add.js
index e63b011..54de379 100644
--- a/src/cordova/plugin/add.js
+++ b/src/cordova/plugin/add.js
@@ -109,7 +109,6 @@ function add (projectRoot, hooksRunner, opts) {
var platformRoot = path.join(projectRoot, 'platforms', platform);
var options = {
cli_variables: opts.cli_variables || {},
- browserify: opts.browserify || false,
save: opts.save,
searchpath: searchPath,
noregistry: opts.noregistry,
diff --git a/src/cordova/prepare.js b/src/cordova/prepare.js
index eba0ac1..d36d692 100644
--- a/src/cordova/prepare.js
+++ b/src/cordova/prepare.js
@@ -104,13 +104,6 @@ function preparePlatforms (platformList, projectRoot, options) {
var platformApi = platforms.getPlatformApi(platform);
return platformApi.prepare(project, _.clone(options))
.then(function () {
- if (options.browserify) {
- // TODO: dynamic require here makes it difficult to test this code branch.
- var browserify = require('../plugman/browserify');
- return browserify(project, platformApi);
- }
- })
- .then(function () {
// Handle edit-config in config.xml
var platformRoot = path.join(projectRoot, 'platforms', platform);
var platformJson = PlatformJson.load(platformRoot, platform);
diff --git a/src/plugman/browserify.js b/src/plugman/browserify.js
deleted file mode 100644
index 6421bfb..0000000
--- a/src/plugman/browserify.js
+++ /dev/null
@@ -1,179 +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 aliasify = require('aliasify');
-var common = require('./platforms/common');
-var fs = require('fs-extra');
-var childProcess = require('child_process');
-var events = require('cordova-common').events;
-var bundle = require('cordova-js/tasks/lib/bundle-browserify');
-var writeLicenseHeader = require('cordova-js/tasks/lib/write-license-header');
-var Q = require('q');
-var computeCommitId = require('cordova-js/tasks/lib/compute-commit-id');
-var Readable = require('stream').Readable;
-
-var PlatformJson = require('cordova-common').PlatformJson;
-var PluginInfoProvider = require('cordova-common').PluginInfoProvider;
-
-function generateFinalBundle (platform, libraryRelease, outReleaseFile, commitId, platformVersion) {
- var deferred = Q.defer();
- var outReleaseFileStream = fs.createWriteStream(outReleaseFile);
- var time = new Date().valueOf();
-
- writeLicenseHeader(outReleaseFileStream, platform, commitId, platformVersion);
-
- var releaseBundle = libraryRelease.bundle();
-
- releaseBundle.pipe(outReleaseFileStream);
-
- outReleaseFileStream.on('finish', function () {
- var newtime = new Date().valueOf() - time;
- events.emit('verbose', 'generated cordova.' + platform + '.js @ ' + commitId + ' in ' + newtime + 'ms');
- deferred.resolve();
- // TODO clean up all the *.browserify files
- });
-
- outReleaseFileStream.on('error', function (err) {
- events.emit('warn', 'Error while generating cordova.js');
- deferred.reject(err);
- });
- return deferred.promise;
-}
-
-function computeCommitIdSync () {
- var deferred = Q.defer();
- computeCommitId(function (cId) {
- deferred.resolve(cId);
- });
- return deferred.promise;
-}
-
-function getPlatformVersion (cId, project_dir) {
- var deferred = Q.defer();
- // run version script for each platform to get platformVersion
- var versionPath = path.join(project_dir, '/cordova/version');
- childProcess.exec('"' + versionPath + '"', function (err, stdout, stderr) {
- if (err) {
- err.message = 'Failed to get platform version (will use \'N/A\' instead).\n' + err.message;
- events.emit('warn', err);
- deferred.resolve('N/A');
- } else {
- deferred.resolve(stdout.trim());
- }
- });
- return deferred.promise;
-}
-
-module.exports = function doBrowserify (project, platformApi, pluginInfoProvider) {
- // Process:
- // - Do config munging by calling into config-changes module
- // - List all plugins in plugins_dir
- // - Load and parse their plugin.xml files.
- // - Skip those without support for this platform. (No <platform> tags means JS-only!)
- // - Build a list of all their js-modules, including platform-specific js-modules.
- // - For each js-module (general first, then platform) build up an object storing the path and any clobbers, merges and runs for it.
- // Write this object into www/cordova_plugins.json.
- // This file is not really used. Maybe cordova app harness
- var platform = platformApi.platform;
- events.emit('verbose', 'Preparing ' + platform + ' browserify project');
- pluginInfoProvider = pluginInfoProvider || new PluginInfoProvider(); // Allow null for backwards-compat.
- var platformJson = PlatformJson.load(project.locations.plugins, platform);
- var wwwDir = platformApi.getPlatformInfo().locations.www;
-
- var commitId;
- return computeCommitIdSync()
- .then(function (cId) {
- commitId = cId;
- return getPlatformVersion(commitId, platformApi.root);
- }).then(function (platformVersion) {
- var libraryRelease = bundle(platform, false, commitId, platformVersion, platformApi.getPlatformInfo().locations.platformWww);
-
- var pluginMetadata = {};
- var modulesMetadata = [];
-
- var plugins = Object.keys(platformJson.root.installed_plugins).concat(Object.keys(platformJson.root.dependent_plugins));
- events.emit('verbose', 'Iterating over plugins in project:', plugins);
- plugins.forEach(function (plugin) {
- var pluginDir = path.join(project.locations.plugins, plugin);
- var pluginInfo = pluginInfoProvider.get(pluginDir);
- // pluginMetadata is a mapping from plugin IDs to versions.
- pluginMetadata[pluginInfo.id] = pluginInfo.version;
-
- // Copy www assets described in <asset> tags.
- pluginInfo.getAssets(platform)
- .forEach(function (asset) {
- common.asset.install(asset, pluginDir, wwwDir);
- });
-
- pluginInfo.getJsModules(platform)
- .forEach(function (jsModule) {
- var moduleName = jsModule.name ? jsModule.name : path.basename(jsModule.src, '.js');
- var moduleId = pluginInfo.id + '.' + moduleName;
- var moduleMetadata = {
- file: jsModule.src,
- id: moduleId,
- name: moduleName,
- pluginId: pluginInfo.id
- };
-
- if (jsModule.clobbers.length > 0) {
- moduleMetadata.clobbers = jsModule.clobbers.map(function (o) { return o.target; });
- }
- if (jsModule.merges.length > 0) {
- moduleMetadata.merges = jsModule.merges.map(function (o) { return o.target; });
- }
- if (jsModule.runs) {
- moduleMetadata.runs = true;
- }
-
- modulesMetadata.push(moduleMetadata);
- libraryRelease.require(path.join(pluginDir, jsModule.src), { expose: moduleId });
- });
- });
-
- events.emit('verbose', 'Writing out cordova_plugins.js...');
-
- // Create a stream and write plugin metadata into it
- // instead of generating intermediate file on FS
- var cordova_plugins = new Readable();
- cordova_plugins.push(
- 'module.exports = ' + JSON.stringify(modulesMetadata, null, 2) + ';\n' +
- 'module.exports.metadata = ' + JSON.stringify(pluginMetadata, null, 2) + ';\n', 'utf8');
- cordova_plugins.push(null);
-
- var bootstrap = new Readable();
- bootstrap.push('require(\'cordova/init\');\n', 'utf8');
- bootstrap.push(null);
-
- var moduleAliases = modulesMetadata
- .reduce(function (accum, meta) {
- accum['./' + meta.name] = meta.id;
- return accum;
- }, {});
-
- libraryRelease
- .add(cordova_plugins, {file: path.join(wwwDir, 'cordova_plugins.js'), expose: 'cordova/plugin_list'})
- .add(bootstrap)
- .transform(aliasify, {aliases: moduleAliases});
-
- var outReleaseFile = path.join(wwwDir, 'cordova.js');
- return generateFinalBundle(platform, libraryRelease, outReleaseFile, commitId, platformVersion);
- });
-};
diff --git a/src/plugman/plugman.js b/src/plugman/plugman.js
index 9e155c6..4497b40 100644
--- a/src/plugman/plugman.js
+++ b/src/plugman/plugman.js
@@ -30,7 +30,6 @@ var plugman = {
install: require('./install'),
uninstall: require('./uninstall'),
fetch: require('./fetch'),
- browserify: require('./browserify'),
help: require('./help'),
create: require('./create'),
platform: require('./platform_operation'),
@@ -51,9 +50,6 @@ plugman.commands = {
if (!cli_opts.platform || !cli_opts.project || !cli_opts.plugin) {
return console.log(plugman.help());
}
- if (cli_opts.browserify === true) {
- plugman.prepare = require('./prepare-browserify');
- }
var cli_variables = {};
if (cli_opts.variable) {
@@ -88,10 +84,6 @@ plugman.commands = {
return console.log(plugman.help());
}
- if (cli_opts.browserify === true) {
- plugman.prepare = require('./prepare-browserify');
- }
-
var p = Q();
cli_opts.plugin.forEach(function (pluginSrc) {
var opts = {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org