[
https://issues.apache.org/jira/browse/CB-13055?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16534346#comment-16534346
]
ASF GitHub Bot commented on CB-13055:
-------------------------------------
raphinesse closed pull request #624: CB-13055 Fold all fetch options to `true`
URL: https://github.com/apache/cordova-lib/pull/624
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/integration-tests/pkgJson-restore.spec.js
b/integration-tests/pkgJson-restore.spec.js
index e045e6080..558c908a8 100644
--- a/integration-tests/pkgJson-restore.spec.js
+++ b/integration-tests/pkgJson-restore.spec.js
@@ -561,9 +561,10 @@ describe('update empty package.json to match config.xml',
function () {
// Expect that config.xml contains only android at this point.
expect(configEngArray.indexOf('android')).toBeGreaterThan(-1);
expect(configEngArray.length === 1);
- // Run cordova prepare.
- prepare();
+
return emptyPlatformList().then(function () {
+ return prepare();
+ }).then(function () {
var cfg2 = new ConfigParser(configXmlPath);
engines = cfg2.getEngines();
engNames = engines.map(function (elem) {
diff --git a/integration-tests/plugman_uninstall.spec.js
b/integration-tests/plugman_uninstall.spec.js
index 5faa8a792..6f4465160 100644
--- a/integration-tests/plugman_uninstall.spec.js
+++ b/integration-tests/plugman_uninstall.spec.js
@@ -17,7 +17,6 @@
under the License.
*/
-var uninstall = require('../src/plugman/uninstall');
var install = require('../src/plugman/install');
var actions = require('cordova-common').ActionStack;
var PluginInfo = require('cordova-common').PluginInfo;
@@ -30,6 +29,7 @@ var fs = require('fs');
var path = require('path');
var shell = require('shelljs');
var Q = require('q');
+var rewire = require('rewire');
var spec = path.join(__dirname, '..', 'spec', 'plugman');
var srcProject = path.join(spec, 'projects', 'android');
var project = path.join(spec, 'projects', 'android_uninstall.test');
@@ -66,6 +66,13 @@ var TEST_XML = '<?xml version="1.0" encoding="UTF-8"?>\n' +
' <access origin="*" />\n' +
'</widget>\n';
+var uninstall;
+
+beforeEach(() => {
+ uninstall = rewire('../src/plugman/uninstall');
+ uninstall.__set__('npmUninstall', jasmine.createSpy());
+});
+
describe('plugman uninstall start', function () {
beforeEach(function () {
var origParseElementtreeSync =
xmlHelpers.parseElementtreeSync.bind(xmlHelpers);
@@ -159,11 +166,8 @@ describe('uninstallPlatform', function () {
});
});
- describe('with dependencies', function () {
- var emit;
- beforeEach(function () {
- emit = spyOn(events, 'emit');
- });
+ it('Test 014 : should uninstall dependent plugins', function () {
+ var emit = spyOn(events, 'emit');
return uninstall.uninstallPlatform('android', project, 'A')
.then(function (result) {
expect(emit).toHaveBeenCalledWith('log', 'Uninstalling 2
dependent plugins.');
diff --git a/spec/cordova/platform/addHelper.spec.js
b/spec/cordova/platform/addHelper.spec.js
index 2fc88cc0f..4eaa90a48 100644
--- a/spec/cordova/platform/addHelper.spec.js
+++ b/spec/cordova/platform/addHelper.spec.js
@@ -138,8 +138,9 @@ describe('cordova/platform/addHelper', function () {
describe('platform spec inference', function () {
it('should retrieve platform details from
directories-specified-as-platforms using getPlatformDetailsFromDir', function
() {
- cordova_util.isDirectory.and.returnValue(true);
var directory_to_platform = '/path/to/cordova-atari';
+ cordova_util.isDirectory.and.returnValue(true);
+
fetch_mock.and.returnValue(Promise.resolve(directory_to_platform));
return platform_addHelper('add', hooks_mock, projectRoot,
[directory_to_platform], {restoring: true}).then(function () {
expect(platform_module.getPlatformDetailsFromDir).toHaveBeenCalledWith(directory_to_platform,
null);
expect(platform_addHelper.downloadPlatform).not.toHaveBeenCalled();
diff --git a/spec/cordova/platform/remove.spec.js
b/spec/cordova/platform/remove.spec.js
index d55508576..058ca2a7e 100644
--- a/spec/cordova/platform/remove.spec.js
+++ b/spec/cordova/platform/remove.spec.js
@@ -20,7 +20,6 @@ var fs = require('fs');
var Q = require('q');
var events = require('cordova-common').events;
var rewire = require('rewire');
-var platform_remove = rewire('../../../src/cordova/platform/remove');
var cordova_util = require('../../../src/cordova/util');
var promiseutil = require('../../../src/util/promise-util');
var fail;
@@ -28,31 +27,33 @@ var fail;
describe('cordova/platform/remove', function () {
var projectRoot = '/some/path';
var cfg_parser_mock = function () {};
- var cfg_parser_revert_mock;
var hooks_mock;
var package_json_mock;
package_json_mock = jasmine.createSpyObj('package json mock', ['cordova',
'dependencies']);
package_json_mock.dependencies = {};
package_json_mock.cordova = {};
- var hooksRunnerRevert;
+ var platform_remove;
beforeEach(function () {
hooks_mock = jasmine.createSpyObj('hooksRunner mock', ['fire']);
hooks_mock.fire.and.returnValue(Q());
- hooksRunnerRevert = platform_remove.__set__('HooksRunner', function ()
{});
cfg_parser_mock.prototype = jasmine.createSpyObj('config parser mock',
['write', 'removeEngine']);
- cfg_parser_revert_mock = platform_remove.__set__('ConfigParser',
cfg_parser_mock);
+
+ platform_remove = rewire('../../../src/cordova/platform/remove');
+ platform_remove.__set__({
+ HooksRunner: _ => _,
+ npmUninstall: _ => Promise.resolve(''),
+ ConfigParser: cfg_parser_mock
+ });
+
spyOn(fs, 'existsSync').and.returnValue(false);
spyOn(fs, 'writeFileSync');
spyOn(cordova_util, 'removePlatformPluginsJson');
spyOn(events, 'emit');
spyOn(cordova_util, 'requireNoCache').and.returnValue({});
});
- afterEach(function () {
- cfg_parser_revert_mock();
- hooksRunnerRevert();
- });
+
describe('error/warning conditions', function () {
it('should require specifying at least one platform', function () {
return platform_remove('remove', hooks_mock).then(function () {
diff --git a/src/cordova/platform/addHelper.js
b/src/cordova/platform/addHelper.js
index 87ff75282..aaf457af2 100644
--- a/src/cordova/platform/addHelper.js
+++ b/src/cordova/platform/addHelper.js
@@ -127,14 +127,10 @@ function addHelper (cmd, hooksRunner, projectRoot,
targets, opts) {
if (spec) {
var maybeDir = cordova_util.fixRelativePath(spec);
if (cordova_util.isDirectory(maybeDir)) {
- if (opts.fetch) {
- return fetch(path.resolve(maybeDir),
projectRoot, opts)
- .then(function (directory) {
- return
require('./index').getPlatformDetailsFromDir(directory, platform);
- });
- } else {
- return
require('./index').getPlatformDetailsFromDir(maybeDir, platform);
- }
+ return fetch(path.resolve(maybeDir), projectRoot,
opts)
+ .then(function (directory) {
+ return
require('./index').getPlatformDetailsFromDir(directory, platform);
+ });
}
}
return module.exports.downloadPlatform(projectRoot,
platform, spec, opts);
@@ -207,7 +203,6 @@ function addHelper (cmd, hooksRunner, projectRoot, targets,
opts) {
var prepOpts = {
platforms: [platform],
searchpath: opts.searchpath,
- fetch: opts.fetch || false,
save: opts.save || false
};
// delete
require.cache[require.resolve('../cordova')]
@@ -291,19 +286,17 @@ function getVersionFromConfigFile (platform, cfg) {
function downloadPlatform (projectRoot, platform, version, opts) {
var target = version ? (platform + '@' + version) : platform;
return Q().then(function () {
- if (opts.fetch) {
- // append cordova to platform
- if (platform in platforms) {
- target = 'cordova-' + target;
- }
+ // append cordova to platform
+ if (platform in platforms) {
+ target = 'cordova-' + target;
+ }
- // gitURLs don't supply a platform, it equals null
- if (!platform) {
- target = version;
- }
- events.emit('log', 'Using cordova-fetch for ' + target);
- return fetch(target, projectRoot, opts);
+ // gitURLs don't supply a platform, it equals null
+ if (!platform) {
+ target = version;
}
+ events.emit('log', 'Using cordova-fetch for ' + target);
+ return fetch(target, projectRoot, opts);
}).fail(function (error) {
var message = 'Failed to fetch platform ' + target +
'\nProbably this is either a connection problem, or platform spec
is incorrect.' +
@@ -355,7 +348,6 @@ function installPluginsForNewPlatform (platform,
projectRoot, opts) {
usePlatformWww: true,
is_top_level: pluginMetadata.is_top_level,
force: opts.force,
- fetch: opts.fetch || false,
save: opts.save || false
};
diff --git a/src/cordova/platform/remove.js b/src/cordova/platform/remove.js
index 1fa5cb400..e094a39fc 100644
--- a/src/cordova/platform/remove.js
+++ b/src/cordova/platform/remove.js
@@ -83,16 +83,14 @@ function remove (hooksRunner, projectRoot, targets, opts) {
events.emit('verbose', 'Removing platform ' + target + ' from
platforms.json file...');
});
}).then(function () {
- // Remove from node_modules if it exists and --fetch was used.
- if (opts.fetch) {
- return promiseutil.Q_chainmap(targets, function (target) {
- if (target in platforms) {
- target = 'cordova-' + target;
- }
- // Edits package.json.
- return npmUninstall(target, projectRoot, opts);
- });
- }
+ // Remove from node_modules if it exists
+ return promiseutil.Q_chainmap(targets, function (target) {
+ if (target in platforms) {
+ target = 'cordova-' + target;
+ }
+ // Edits package.json.
+ return npmUninstall(target, projectRoot, opts);
+ });
}).then(function () {
return hooksRunner.fire('after_platform_rm', opts);
});
diff --git a/src/cordova/plugin/add.js b/src/cordova/plugin/add.js
index 8aea7f0a7..8850e3659 100644
--- a/src/cordova/plugin/add.js
+++ b/src/cordova/plugin/add.js
@@ -81,7 +81,6 @@ function add (projectRoot, hooksRunner, opts) {
var fetchOptions = {
searchpath: searchPath,
noregistry: opts.noregistry,
- fetch: opts.fetch || false,
save: opts.save,
nohooks: opts.nohooks,
link: opts.link,
@@ -111,7 +110,6 @@ function add (projectRoot, hooksRunner, opts) {
var options = {
cli_variables: opts.cli_variables || {},
browserify: opts.browserify || false,
- fetch: opts.fetch || false,
save: opts.save,
searchpath: searchPath,
noregistry: opts.noregistry,
diff --git a/src/cordova/prepare.js b/src/cordova/prepare.js
index 7353a03fd..ba154268d 100644
--- a/src/cordova/prepare.js
+++ b/src/cordova/prepare.js
@@ -41,11 +41,10 @@ function prepare (options) {
var config_json = config.read(projectRoot);
options = options || { verbose: false, platforms: [], options: {} };
options.save = options.save || false;
- options.fetch = options.fetch || false;
var hooksRunner = new HooksRunner(projectRoot);
return hooksRunner.fire('before_prepare', options)
.then(function () {
- return
restore.installPlatformsFromConfigXML(options.platforms, { searchpath:
options.searchpath, fetch: options.fetch, restoring: true });
+ return
restore.installPlatformsFromConfigXML(options.platforms, { searchpath:
options.searchpath, restoring: true });
})
.then(function () {
options = cordova_util.preProcessOptions(options);
diff --git a/src/cordova/restore-util.js b/src/cordova/restore-util.js
index 2c3f8c998..2a79dd706 100644
--- a/src/cordova/restore-util.js
+++ b/src/cordova/restore-util.js
@@ -408,7 +408,6 @@ function installPluginsFromConfigXML (args) {
var options = {
cli_variables: pluginEntry.variables,
searchpath: args.searchpath,
- fetch: args.fetch || false,
save: args.save || false
};
var plugin = require('./plugin');
diff --git a/src/plugman/fetch.js b/src/plugman/fetch.js
index 4d83f69c1..221e21ccb 100644
--- a/src/plugman/fetch.js
+++ b/src/plugman/fetch.js
@@ -63,22 +63,10 @@ function fetchPlugin (plugin_src, plugins_dir, options) {
if (result) {
if (result[1]) { options.git_ref = result[1]; }
if (result[2]) { options.subdir = result[2]; }
- // if --fetch was used, throw error for subdirectories
+ // throw error for subdirectories
if (options.subdir && options.subdir !== '.') {
- events.emit('warn', 'support for subdirectories is deprecated
and will be removed in Cordova@7');
- if (options.fetch) {
- return Q.reject(new CordovaError('--fetch does not support
subdirectories'));
- }
- }
-
- // Recurse and exit with the new options and truncated URL.
- var new_dir = plugin_src.substring(0, plugin_src.indexOf('#'));
-
- // skip the return if user asked for --fetch
- // cordova-fetch doesn't need to strip out git-ref
- if (!options.fetch) {
- return fetchPlugin(new_dir, plugins_dir, options);
+ return Q.reject(new CordovaError('Cordova does not support
subdirectories'));
}
}
}
@@ -87,31 +75,29 @@ function fetchPlugin (plugin_src, plugins_dir, options) {
return Q.when().then(function () {
// check if it is a local path
if (fs.existsSync(plugin_dir)) {
- if (options.fetch) {
- if (!fs.existsSync(path.join(plugin_dir, 'package.json')))
{
- return Q.reject(new CordovaError('Invalid Plugin! ' +
plugin_dir + ' needs a valid package.json'));
- }
+ if (!fs.existsSync(path.join(plugin_dir, 'package.json'))) {
+ return Q.reject(new CordovaError('Invalid Plugin! ' +
plugin_dir + ' needs a valid package.json'));
+ }
- projectRoot = path.join(plugins_dir, '..');
- // Plugman projects need to go up two directories to reach
project root.
- // Plugman projects have an options.projectRoot variable
- if (options.projectRoot) {
- projectRoot = options.projectRoot;
- }
- return fetch(path.resolve(plugin_dir), projectRoot,
options)
- .then(function (directory) {
- return {
- pinfo: pluginInfoProvider.get(directory),
- fetchJsonSource: {
- type: 'local',
- path: directory
- }
- };
- }).fail(function (error) {
- // something went wrong with cordova-fetch
- return Q.reject(new CordovaError(error.message));
- });
+ projectRoot = path.join(plugins_dir, '..');
+ // Plugman projects need to go up two directories to reach
project root.
+ // Plugman projects have an options.projectRoot variable
+ if (options.projectRoot) {
+ projectRoot = options.projectRoot;
}
+ return fetch(path.resolve(plugin_dir), projectRoot, options)
+ .then(function (directory) {
+ return {
+ pinfo: pluginInfoProvider.get(directory),
+ fetchJsonSource: {
+ type: 'local',
+ path: directory
+ }
+ };
+ }).fail(function (error) {
+ // something went wrong with cordova-fetch
+ return Q.reject(new CordovaError(error.message));
+ });
}
// If there is no such local path or it's a git URL, it's a plugin
id or id@versionspec.
// First look for it in the local search path (if provided).
@@ -142,26 +128,24 @@ function fetchPlugin (plugin_src, plugins_dir, options) {
P = Q(plugin_dir);
skipCopyingPlugin = true;
} else {
- // use cordova-fetch if --fetch was passed in
- if (options.fetch) {
- projectRoot = path.join(plugins_dir, '..');
- // Plugman projects need to go up two directories to reach
project root.
- // Plugman projects have an options.projectRoot variable
- if (options.projectRoot) {
- projectRoot = options.projectRoot;
- }
-
- if (process.platform === 'win32' && parsedSpec.version) {
- var windowsShellSpecialCharacters = ['&', '\\', '<',
'>', '^', '|'];
- specContainsSpecialCharacters =
windowsShellSpecialCharacters.some(function (character) {
- return parsedSpec.version.indexOf(character);
- });
- }
+ // use cordova-fetch
+ projectRoot = path.join(plugins_dir, '..');
+ // Plugman projects need to go up two directories to reach
project root.
+ // Plugman projects have an options.projectRoot variable
+ if (options.projectRoot) {
+ projectRoot = options.projectRoot;
+ }
- var fetchPluginSrc = specContainsSpecialCharacters ?
- parsedSpec.package + '@"' + parsedSpec.version + '"' :
plugin_src;
- P = fetch(fetchPluginSrc, projectRoot, options);
+ if (process.platform === 'win32' && parsedSpec.version) {
+ var windowsShellSpecialCharacters = ['&', '\\', '<', '>',
'^', '|'];
+ specContainsSpecialCharacters =
windowsShellSpecialCharacters.some(function (character) {
+ return parsedSpec.version.indexOf(character);
+ });
}
+
+ var fetchPluginSrc = specContainsSpecialCharacters ?
+ parsedSpec.package + '@"' + parsedSpec.version + '"' :
plugin_src;
+ P = fetch(fetchPluginSrc, projectRoot, options);
skipCopyingPlugin = false;
}
return P
diff --git a/src/plugman/plugman.js b/src/plugman/plugman.js
index 9b249bfd8..60a866b97 100644
--- a/src/plugman/plugman.js
+++ b/src/plugman/plugman.js
@@ -79,7 +79,6 @@ plugman.commands = {
var opts = {
subdir: '.',
cli_variables: cli_variables,
- fetch: cli_opts.fetch || false,
save: cli_opts.save || false,
www_dir: cli_opts.www,
searchpath: cli_opts.searchpath,
@@ -111,7 +110,6 @@ plugman.commands = {
var opts = {
www_dir: cli_opts.www,
save: cli_opts.save || false,
- fetch: cli_opts.fetch || false,
projectRoot: cli_opts.project
};
p = p.then(function () {
diff --git a/src/plugman/uninstall.js b/src/plugman/uninstall.js
index c15b1afa1..0a0099c0f 100644
--- a/src/plugman/uninstall.js
+++ b/src/plugman/uninstall.js
@@ -114,8 +114,7 @@ module.exports.uninstallPlugin = function (id, plugins_dir,
options) {
}
/*
- * Deletes plugin from plugins directory and
- * node_modules directory if --fetch was supplied.
+ * Deletes plugin from plugins directory and node_modules directory.
*
* @param {String} id the id of the plugin being removed
*
@@ -131,13 +130,8 @@ module.exports.uninstallPlugin = function (id,
plugins_dir, options) {
shell.rm('-rf', plugin_dir);
events.emit('verbose', 'Deleted "' + id + '"');
- if (options.fetch) {
- // remove plugin from node_modules directory
- return npmUninstall(id, options.projectRoot, options);
- }
-
- return Q();
-
+ // remove plugin from node_modules directory
+ return npmUninstall(id, options.projectRoot, options);
};
// We've now lost the metadata for the plugins that have been uninstalled,
so we can't use that info.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> remove --nofetch option and all old fetching code
> -------------------------------------------------
>
> Key: CB-13055
> URL: https://issues.apache.org/jira/browse/CB-13055
> Project: Apache Cordova
> Issue Type: Bug
> Components: cordova-lib
> Reporter: Steve Gill
> Assignee: Raphael
> Priority: Major
> Labels: backlog, tools-next
> Fix For: cordova@8
>
>
> Cordova uses cordova-fetch for fetching modules by default now. In the next
> major version, lets drop the older methods. This is great for reducing
> maintenance in cordova. Original fetch proposal is at
> https://github.com/cordova/cordova-discuss/pull/33
> remove --nofetch option
> remove lazy_load
> remove gitclone.js
> remove npm dependency
> remove remoteload.js
> update anywhere that these files are used
> Proposal: https://github.com/apache/cordova-discuss/pull/76
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]