Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

plugman

Package Overview
Dependencies
Maintainers
6
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

plugman - npm Package Compare versions

Comparing version 0.7.7 to 0.7.8

spec/plugins/EnginePlugin/plugin.xml

11

main.js

@@ -66,3 +66,3 @@ #!/usr/bin/env node

else if (cli_opts.uninstall) {
plugman.uninstall(cli_opts.platform, cli_opts.project, cli_opts.plugin, plugins_dir, {}, cli_opts.www);
plugman.uninstall(cli_opts.platform, cli_opts.project, cli_opts.plugin, plugins_dir, { www_dir: cli_opts.www });
}

@@ -78,3 +78,8 @@ else {

}
plugman.install(cli_opts.platform, cli_opts.project, cli_opts.plugin, plugins_dir, '.', cli_variables, cli_opts.www);
var opts = {
subdir: '.',
cli_variables: cli_variables,
www_dir: cli_opts.www
};
plugman.install(cli_opts.platform, cli_opts.project, cli_opts.plugin, plugins_dir, opts);
}

@@ -86,5 +91,5 @@

console.log('Install a plugin (will fetch if cannot be found):\n\t' + package.name + ' --platform <'+ platforms +'> --project <directory> --plugin <name|path|url> [--www <directory>] [--plugins_dir <directory>] [--variable <name>=<value>]\n');
console.log('Uninstall a plugin:\n\t' + package.name + ' --uninstall --platform <'+ platforms +'> --project <directory> --plugin <name> [--www <directory>] [--plugins_dir <directory>]\n');
console.log('Uninstall a plugin:\n\t' + package.name + ' --uninstall --platform <'+ platforms +'> --project <directory> --plugin <id> [--www <directory>] [--plugins_dir <directory>]\n');
console.log('\n\t--plugins_dir defaults to <project>/cordova/plugins, but can be any directory containing a subdirectory for each plugin');
console.log('\n\t--www defaults to the project\'s www folder, but can be any directory where web assets should be installed into');
}

@@ -5,3 +5,3 @@ {

"description": "install/uninstall Cordova plugins",
"version": "0.7.7",
"version": "0.7.8",
"repository": {

@@ -26,3 +26,4 @@ "type": "git",

"underscore":"1.4.4",
"dep-graph":"1.1.0"
"dep-graph":"1.1.0",
"semver": "1.x.x"
},

@@ -34,3 +35,3 @@ "devDependencies": {

"scripts": {
"test": "node node_modules/jasmine-node/bin/jasmine-node --color spec"
"test": "jasmine-node --color spec"
},

@@ -37,0 +38,0 @@ "contributors":[

@@ -30,10 +30,10 @@ # plugman

plugman --install --platform <ios|android|blackberry10|wp7|wp8> --project <directory> --plugin <name|url|path> [--plugins_dir <directory>] [--www <directory>] [--variable <name>=<value> [--variable <name>=<value> ...]]
plugman --uninstall --platform <ios|android|blackberr10|wp7|wp8> --project <directory> --plugin <name> [--www <directory>] [--plugins_dir <directory>]
plugman --platform <ios|android|blackberry10|wp7|wp8> --project <directory> --plugin <name|url|path> [--plugins_dir <directory>] [--www <directory>] [--variable <name>=<value> [--variable <name>=<value> ...]]
plugman --uninstall --platform <ios|android|blackberr10|wp7|wp8> --project <directory> --plugin <id> [--www <directory>] [--plugins_dir <directory>]
* `--install`: Installs a plugin into a cordova project. You must specify a platform and cordova project location for that platform. You also must specify a plugin, with the different `--plugin` parameter forms being:
* Using minimum parameters, installs a plugin into a cordova project. You must specify a platform and cordova project location for that platform. You also must specify a plugin, with the different `--plugin` parameter forms being:
* `name`: The directory name where the plugin contents exist. This must be an existing directory under the `--plugins_dir` path (see below for more info).
* `url`: A URL starting with https:// or git://, pointing to a valid git repository that is clonable and contains a `plugin.xml` file. The contents of this repository would be copied into the `--plugins_dir`.
* `path`: A path to a directory containing a valid plugin which includes a `plugin.xml` file. This path's contents will be copied into the `--plugins_dir`.
* `--uninstall`: Uninstalls an already-`--install`'ed plugin from a cordova project
* `--uninstall`: Uninstalls an already-`--install`'ed plugin from a cordova project. Specify the plugin ID.

@@ -40,0 +40,0 @@ Other parameters:

@@ -22,3 +22,3 @@ var fetch = require('../src/fetch'),

it('should copy locally-available plugin to plugins directory', function() {
fetch(test_plugin, temp, false);
fetch(test_plugin, temp);
expect(fs.existsSync(copied_plugin_path)).toBe(true);

@@ -31,3 +31,3 @@ });

it('should create a symlink if used with `link` param', function() {
fetch(test_plugin, temp, true);
fetch(test_plugin, temp, { link: true });
expect(fs.lstatSync(copied_plugin_path).isSymbolicLink()).toBe(true);

@@ -39,3 +39,3 @@ });

var s = spyOn(plugins, 'clonePluginGitRepo');
fetch("https://github.com/bobeast/GAPlugin.git", temp, false);
fetch("https://github.com/bobeast/GAPlugin.git", temp);
expect(s).toHaveBeenCalled();

@@ -47,3 +47,3 @@ });

var dir = 'fakeSubDir';
fetch(url, temp, false, dir);
fetch(url, temp, { subdir: dir });
expect(s).toHaveBeenCalledWith(url, temp, dir, undefined, undefined);

@@ -56,3 +56,3 @@ });

var ref = 'fakeGitRef';
fetch(url, temp, false, dir, ref);
fetch(url, temp, { subdir: dir, git_ref: ref });
expect(s).toHaveBeenCalledWith(url, temp, dir, ref, undefined);

@@ -59,0 +59,0 @@ });

var install = require('../src/install'),
android = require('../src/platforms/android'),
blackberry = require('../src/platforms/blackberry10'),
common = require('../src/platforms/common'),

@@ -12,2 +15,3 @@ actions = require('../src/util/action-stack'),

shell = require('shelljs'),
semver = require('semver'),
temp = path.join(os.tmpdir(), 'plugman'),

@@ -24,5 +28,6 @@ childbrowser = path.join(__dirname, 'plugins', 'ChildBrowser'),

faultyplugin = path.join(__dirname, 'plugins', 'FaultyPlugin'),
android_one_project = path.join(__dirname, 'projects', 'android_one', '*');
//blackberry10_project = path.join(__dirname, 'projects', 'blackberry10', '*');
//ios_project = path.join(__dirname, 'projects', 'ios-config-xml', '*');
engineplugin = path.join(__dirname, 'plugins','EnginePlugin'),
android_one_project = path.join(__dirname, 'projects', 'android_one', '*'),
//blackberry_project = path.join(__dirname, 'projects', 'blackberry', '*'),
//ios_project = path.join(__dirname, 'projects', 'ios-config-xml', '*'),
plugins_dir = path.join(temp, 'cordova', 'plugins');

@@ -44,3 +49,3 @@

var s = spyOn(common, 'copyFile').andCallThrough();
install('android', temp, dummyplugin, plugins_dir, '.', {});
install('android', temp, dummyplugin, plugins_dir, {});
// making sure the right methods were called

@@ -67,3 +72,3 @@ expect(s).toHaveBeenCalled();

expect(function() {
install('android', temp, 'DummyPlugin', plugins_dir, '.', {});
install('android', temp, 'DummyPlugin', plugins_dir, {});
}).toThrow();

@@ -85,3 +90,3 @@ // making sure the right methods were called

var s = spyOn(common, 'copyFile').andCallThrough();
install('android', temp, dummyplugin, plugins_dir, '.', {}, path.join(temp, 'staging'));
install('android', temp, dummyplugin, plugins_dir, { www_dir: path.join(temp, 'staging') });
// making sure the right methods were called

@@ -109,3 +114,3 @@ expect(s).toHaveBeenCalled();

expect(function() {
install('android', temp, 'DummyPlugin', plugins_dir, '.', {}, path.join(temp, 'staging'));
install('android', temp, 'DummyPlugin', plugins_dir, { www_dir: path.join(temp, 'staging') });
}).toThrow();

@@ -127,3 +132,3 @@ // making sure the right methods were called

var s = spyOn(plugman, 'prepare');
install('android', temp, dummyplugin, plugins_dir, '.', {});
install('android', temp, dummyplugin, plugins_dir, {});
expect(s).toHaveBeenCalled();

@@ -134,3 +139,3 @@ });

var s = spyOn(plugman, 'fetch');
install('android', temp, 'CLEANYOURSHORTS', plugins_dir, '.', {});
install('android', temp, 'CLEANYOURSHORTS', plugins_dir, {});
expect(s).toHaveBeenCalled();

@@ -140,3 +145,3 @@ });

var spy = spyOn(config_changes, 'add_installed_plugin_to_prepare_queue');
install('android', temp, dummyplugin, plugins_dir, '.', {});
install('android', temp, dummyplugin, plugins_dir, {});
expect(spy).toHaveBeenCalledWith(plugins_dir, dummy_id, 'android', {}, true);

@@ -146,6 +151,6 @@ });

expect(function() {
install('android', temp, dummyplugin, plugins_dir,'.', {});
install('android', temp, dummyplugin, plugins_dir, {});
}).not.toThrow();
var spy = spyOn(console, 'log');
install('android', temp, dummyplugin, plugins_dir, '.', {});
install('android', temp, dummyplugin, plugins_dir, {});
expect(spy).toHaveBeenCalledWith('Plugin "com.phonegap.plugins.dummyplugin" already installed, \'sall good.');

@@ -161,3 +166,3 @@ });

shell.cp('-rf', dep_c, plugins_dir);
install('android', temp, 'A', plugins_dir, '.', {});
install('android', temp, 'A', plugins_dir, {});
expect(spy.calls.length).toEqual(3);

@@ -170,8 +175,14 @@ });

shell.cp('-rf', dep_c, plugins_dir);
install('android', temp, 'A', plugins_dir, '.', {});
install('android', temp, 'A', plugins_dir, {});
expect(spy).toHaveBeenCalled();
});
});
it('should check version if plugin has engine tag', function(){
shell.cp('-rf', engineplugin, plugins_dir);
var spy = spyOn(semver, 'satisfies').andCallThrough();
install('android', temp, 'engineplugin', plugins_dir, {});
expect(spy).toHaveBeenCalledWith('2.7.0rc1', '>=2.3.0');
});
});
describe('failure', function() {

@@ -182,3 +193,3 @@ it('should throw if asset target already exists', function() {

expect(function() {
install('android', temp, dummyplugin, plugins_dir, '.', {});
install('android', temp, dummyplugin, plugins_dir, {});
}).toThrow();

@@ -193,3 +204,3 @@ });

expect(function() {
install('android', temp, variableplugin, plugins_dir, '.', {});
install('android', temp, variableplugin, plugins_dir, {});
}).toThrow('Variable(s) missing: API_KEY');

@@ -203,3 +214,3 @@ });

expect(function() {
install('android', temp, 'DummyPlugin', plugins_dir, '.', {});
install('android', temp, 'DummyPlugin', plugins_dir, {});
}).toThrow();

@@ -212,3 +223,3 @@ });

install('android', temp, 'DummyPlugin', plugins_dir, '.', {}, null, function(err) {
install('android', temp, 'DummyPlugin', plugins_dir, {}, function(err) {
expect(err).toBeDefined();

@@ -215,0 +226,0 @@ done();

@@ -112,3 +112,3 @@ var android = require('../../src/platforms/android'),

var s = spyOn(common, 'deleteJava');
install('android', temp, dummyplugin, plugins_dir, '.', {}, undefined, function() {
install('android', temp, dummyplugin, plugins_dir, {}, function() {
var source = copyArray(valid_source);

@@ -115,0 +115,0 @@ android['source-file'].uninstall(source[0], temp);

@@ -44,3 +44,3 @@ var uninstall = require('../src/uninstall'),

beforeEach(function() {
install('android', temp, dummyplugin, plugins_dir, '.', {});
install('android', temp, dummyplugin, plugins_dir, {});
});

@@ -91,3 +91,3 @@ it('should properly uninstall assets', function() {

shell.cp('-rf', dep_c, plugins_dir);
install('android', temp, 'A', plugins_dir, '.', {});
install('android', temp, 'A', plugins_dir, {});
var spy = spyOn(actions.prototype, 'process').andCallThrough();

@@ -104,4 +104,4 @@ uninstall('android', temp, 'A', plugins_dir, {});

shell.cp('-rf', dep_e, plugins_dir);
install('android', temp, 'A', plugins_dir, '.', {});
install('android', temp, 'B', plugins_dir, '.', {});
install('android', temp, 'A', plugins_dir, {});
install('android', temp, 'B', plugins_dir, {});
var spy = spyOn(actions.prototype, 'process').andCallThrough();

@@ -108,0 +108,0 @@ uninstall('android', temp, 'A', plugins_dir, {});

@@ -32,13 +32,31 @@ #!/usr/bin/env node

it('should shell out to git clone with correct arguments', function(){
var mySpy = spyOn(shell, 'exec');
var execSpy = spyOn(shell, 'exec').andReturn({
code: 0,
output: 'git output'
});
var fake_id = 'fake.plugin.id';
var xml = {
getroot: function() {
return { attrib: { id: fake_id } };
}
};
spyOn(xml_helpers, 'parseElementtreeSync').andReturn(xml);
spyOn(shell, 'cp');
var plugin_git_url = 'https://github.com/imhotep/ChildBrowser'
plugins.clonePluginGitRepo(plugin_git_url, temp, '.');
expect(mySpy).toHaveBeenCalled();
var callback = jasmine.createSpy();
plugins.clonePluginGitRepo(plugin_git_url, temp, '.', undefined, callback);
expect(execSpy).toHaveBeenCalled();
var git_clone_regex = new RegExp('^git clone "' + plugin_git_url + '" ".*"$', 'gi');
expect(mySpy.mostRecentCall.args[0]).toMatch(git_clone_regex);
expect(execSpy.mostRecentCall.args[0]).toMatch(git_clone_regex);
expect(callback).toHaveBeenCalled();
expect(callback.mostRecentCall.args[0]).toBe(null);
expect(callback.mostRecentCall.args[1]).toMatch(new RegExp('/' + fake_id + '$'));
});
it('should take into account subdirectory argument when copying over final repository into plugins+plugin_id directory', function() {
var exec_spy = spyOn(shell, 'exec');
var exec_spy = spyOn(shell, 'exec').andReturn({ code: 0, output: 'git clone output' });
var cp_spy = spyOn(shell, 'cp');

@@ -57,3 +75,2 @@ var fake_id = 'VillageDrunkard';

plugins.clonePluginGitRepo(plugin_git_url, temp, fake_subdir);
exec_spy.mostRecentCall.args[2](0); // fake out shell.exec finishing appropriately (so we dont ACTUALLY shell out to git-clone, assume it worked fine)
var expected_subdir_cp_path = new RegExp(fake_subdir + '[\\\\\\/]\\*$', 'gi');

@@ -60,0 +77,0 @@ expect(cp_spy.mostRecentCall.args[1]).toMatch(expected_subdir_cp_path);

@@ -7,11 +7,13 @@ var shell = require('shelljs'),

module.exports = function fetchPlugin(plugin_dir, plugins_dir, link, subdir, git_ref, callback) {
// possible options: link, subdir, git_ref
module.exports = function fetchPlugin(plugin_dir, plugins_dir, options, callback) {
// Ensure the containing directory exists.
shell.mkdir('-p', plugins_dir);
subdir = subdir || '.';
options = options || {};
options.subdir = options.subdir || '.';
// clone from git repository
if(plugin_dir.indexOf('https://') == 0 || plugin_dir.indexOf('git://') == 0) {
if (link) {
if (options.link) {
var err = new Error('--link is not supported for git URLs');

@@ -21,8 +23,12 @@ if (callback) callback(err);

} else {
plugins.clonePluginGitRepo(plugin_dir, plugins_dir, subdir, git_ref, callback);
plugins.clonePluginGitRepo(plugin_dir, plugins_dir, options.subdir, options.git_ref, callback);
}
} else {
if (plugin_dir.lastIndexOf('file://', 0) === 0) {
plugin_dir = plugin_dir.substring('file://'.length);
}
// Copy from the local filesystem.
// First, read the plugin.xml and grab the ID.
plugin_dir = path.join(plugin_dir, subdir);
plugin_dir = path.join(plugin_dir, options.subdir);
var xml = xml_helpers.parseElementtreeSync(path.join(plugin_dir, 'plugin.xml'));

@@ -34,3 +40,3 @@ var plugin_id = xml.getroot().attrib.id;

shell.rm('-rf', dest);
if (link) {
if (options.link) {
fs.symlinkSync(plugin_dir, dest, 'dir');

@@ -37,0 +43,0 @@ } else {

@@ -7,5 +7,9 @@ var path = require('path'),

action_stack = require('./util/action-stack'),
shell = require('shelljs'),
semver = require('semver'),
config_changes = require('./util/config-changes'),
platform_modules = require('./platforms');
module.exports = function installPlugin(platform, project_dir, id, plugins_dir, subdir, cli_variables, www_dir, callback) {
// possible options: subdir, cli_variables, www_dir
module.exports = function installPlugin(platform, project_dir, id, plugins_dir, options, callback) {
if (!platform_modules[platform]) {

@@ -20,6 +24,8 @@ var err = new Error(platform + " not supported.");

possiblyFetch(current_stack, platform, project_dir, id, plugins_dir, subdir, cli_variables, www_dir, true, callback);
options.is_top_level = true;
possiblyFetch(current_stack, platform, project_dir, id, plugins_dir, options, callback);
};
function possiblyFetch(actions, platform, project_dir, id, plugins_dir, subdir, cli_variables, www_dir, is_top_level, callback) {
// possible options: subdir, cli_variables, www_dir, git_ref, is_top_level
function possiblyFetch(actions, platform, project_dir, id, plugins_dir, options, callback) {
var plugin_dir = path.join(plugins_dir, id);

@@ -31,3 +37,3 @@

// TODO: Actual value for git_ref.
require('../plugman').fetch(id, plugins_dir, false, '.', undefined /* git_ref */, function(err, plugin_dir) {
require('../plugman').fetch(id, plugins_dir, { link: false, subdir: '.', git_ref: options.git_ref }, function(err, plugin_dir) {
if (err) {

@@ -37,11 +43,12 @@ callback(err);

// update ref to plugin_dir after successful fetch, via fetch callback
runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, cli_variables, www_dir, is_top_level, callback);
runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, options, callback);
}
});
} else {
runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, cli_variables, www_dir, is_top_level, callback);
runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, options, callback);
}
}
function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, cli_variables, www_dir, is_top_level, callback) {
// possible options: cli_variables, www_dir, is_top_level
function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, options, callback) {
var xml_path = path.join(plugin_dir, 'plugin.xml')

@@ -74,2 +81,35 @@ , xml_text = fs.readFileSync(xml_path, 'utf-8')

// checking engine
// will there be a case for multiple engine support?
var engines = plugin_et.findall('engines/engine');
engines.forEach(function(engine){
if(engine.attrib["name"].toLowerCase() === "cordova"){
var engineVersion = engine.attrib["version"];
var versionPath = path.join(project_dir, 'cordova', 'version');
// need to rethink this so I don't have to chmod anything
fs.chmodSync(versionPath, '755');
var versionScript = shell.exec(versionPath, {silent: true});
if(versionScript.code>0){
var err = new Error('File missing: ' + versionPath);
if (callback) callback(err);
else throw err;
}else{
// clean only versionScript.output since semver.clean strips out
// the gt and lt operators
if(semver.satisfies(semver.clean(versionScript.output), engineVersion)){
// engine ok!
}else{
var err = new Error('Plugin doesn\'t support Cordova version. Check plugin.xml');
if (callback) callback(err);
else throw err;
}
}
}else{
// check for other engines?
}
});
// checking preferences, if certain variables are not provided, we should throw.

@@ -81,6 +121,7 @@ prefs = plugin_et.findall('./preference') || [];

var key = pref.attrib["name"].toUpperCase();
if (cli_variables[key] == undefined)
options.cli_variables = options.cli_variables || {};
if (options.cli_variables[key] == undefined)
missing_vars.push(key)
else
filtered_variables[key] = cli_variables[key]
filtered_variables[key] = options.cli_variables[key]
});

@@ -98,3 +139,3 @@ if (missing_vars.length > 0) {

var end = n(dependencies.length, function() {
handleInstall(actions, plugin_id, plugin_et, platform, project_dir, plugins_dir, plugin_basename, plugin_dir, filtered_variables, www_dir, is_top_level, callback);
handleInstall(actions, plugin_id, plugin_et, platform, project_dir, plugins_dir, plugin_basename, plugin_dir, filtered_variables, options.www_dir, options.is_top_level, callback);
});

@@ -105,2 +146,3 @@ dependencies.forEach(function(dep) {

var dep_url = dep.attrib.url;
var dep_git_ref = dep.attrib.commit;
if (dep_subdir) {

@@ -112,10 +154,27 @@ dep_subdir = path.join.apply(null, dep_subdir.split('/'));

console.log('Dependent plugin ' + dep_plugin_id + ' already fetched, using that version.');
runInstall(actions, platform, project_dir, dep_plugin_dir, plugins_dir, filtered_variables, www_dir, false, end);
var opts = {
cli_variables: filtered_variables,
www_dir: options.www_dir,
is_top_level: false
};
runInstall(actions, platform, project_dir, dep_plugin_dir, plugins_dir, opts, end);
} else {
console.log('Dependent plugin ' + dep_plugin_id + ' not fetched, retrieving then installing.');
possiblyFetch(actions, platform, project_dir, dep_url, plugins_dir, dep_subdir, filtered_variables, www_dir, false, end);
var opts = {
cli_variables: filtered_variables,
www_dir: options.www_dir,
is_top_level: false,
git_ref: dep_git_ref
};
possiblyFetch(actions, platform, project_dir, dep_url, plugins_dir, opts, function(err) {
if (err) {
if (callback) callback(err);
else throw err;
} else end();
});
}
});
} else {
handleInstall(actions, plugin_id, plugin_et, platform, project_dir, plugins_dir, plugin_basename, plugin_dir, filtered_variables, www_dir, is_top_level, callback);
handleInstall(actions, plugin_id, plugin_et, platform, project_dir, plugins_dir, plugin_basename, plugin_dir, filtered_variables, options.www_dir, options.is_top_level, callback);
}

@@ -125,2 +184,3 @@ }

function handleInstall(actions, plugin_id, plugin_et, platform, project_dir, plugins_dir, plugin_basename, plugin_dir, filtered_variables, www_dir, is_top_level, callback) {
console.log('Installing plugin ' + plugin_id + '...');
var handler = platform_modules[platform];

@@ -127,0 +187,0 @@ www_dir = www_dir || handler.www_dir(project_dir);

@@ -64,6 +64,19 @@ var shell = require('shelljs'),

var target = asset_el.attrib.target;
if (!src) {
throw new Error('<asset> tag without required "src" attribute');
}
if (!target) {
throw new Error('<asset> tag without required "target" attribute');
}
module.exports.copyFile(plugin_dir, src, www_dir, target);
},
uninstall:function(asset_el, www_dir, plugin_id) {
var target = asset_el.attrib.target;
var target = asset_el.attrib.target || asset_el.attrib.src;
if (!target) {
throw new Error('<asset> tag without required "target" attribute');
}
module.exports.removeFile(www_dir, target);

@@ -70,0 +83,0 @@ module.exports.removeFileF(path.resolve(www_dir, 'plugins', plugin_id));

@@ -12,3 +12,4 @@ var path = require('path'),

module.exports = function uninstallPlugin(platform, project_dir, id, plugins_dir, cli_variables, www_dir, callback) {
// possible options: cli_variables, www_dir
module.exports = function uninstallPlugin(platform, project_dir, id, plugins_dir, options, callback) {
if (!platform_modules[platform]) {

@@ -32,6 +33,8 @@ var err = new Error(platform + " not supported.");

runUninstall(current_stack, platform, project_dir, plugin_dir, plugins_dir, cli_variables, www_dir, true, callback);
options.is_top_level = true;
runUninstall(current_stack, platform, project_dir, plugin_dir, plugins_dir, options, callback);
};
function runUninstall(actions, platform, project_dir, plugin_dir, plugins_dir, cli_variables, www_dir, is_top_level, callback) {
// possible options: cli_variables, www_dir, is_top_level
function runUninstall(actions, platform, project_dir, plugin_dir, plugins_dir, options, callback) {
var xml_path = path.join(plugin_dir, 'plugin.xml')

@@ -42,2 +45,3 @@ , xml_text = fs.readFileSync(xml_path, 'utf-8')

var plugin_id = plugin_et._root.attrib['id'];
options = options || {};

@@ -53,3 +57,3 @@ var dependency_info = dependencies.generate_dependency_info(plugins_dir, platform);

var ds = graph.getChain(tlp);
if (is_top_level && ds.indexOf(plugin_id) > -1) {
if (options.is_top_level && ds.indexOf(plugin_id) > -1) {
var err = new Error('Another top-level plugin (' + tlp + ') relies on plugin ' + plugin_id + ', therefore aborting uninstallation.');

@@ -69,11 +73,16 @@ if (callback) callback(err);

var end = n(danglers.length, function() {
handleUninstall(actions, platform, plugin_id, plugin_et, project_dir, www_dir, plugins_dir, plugin_dir, is_top_level, callback);
handleUninstall(actions, platform, plugin_id, plugin_et, project_dir, options.www_dir, plugins_dir, plugin_dir, options.is_top_level, callback);
});
danglers.forEach(function(dangler) {
var dependent_path = path.join(plugins_dir, dangler);
runUninstall(actions, platform, project_dir, dependent_path, plugins_dir, cli_variables, www_dir, false /* TODO: should this "is_top_level" param be false for dependents? */, end);
var opts = {
www_dir: options.www_dir,
cli_variables: options.cli_variables,
is_top_level: false /* TODO: should this "is_top_level" param be false for dependents? */
};
runUninstall(actions, platform, project_dir, dependent_path, plugins_dir, opts, end);
});
} else {
// this plugin can get axed by itself, gogo!
handleUninstall(actions, platform, plugin_id, plugin_et, project_dir, www_dir, plugins_dir, plugin_dir, is_top_level, callback);
handleUninstall(actions, platform, plugin_id, plugin_et, project_dir, options.www_dir, plugins_dir, plugin_dir, options.is_top_level, callback);
}

@@ -80,0 +89,0 @@ }

@@ -57,2 +57,3 @@ var ios = require('../platforms/ios'),

}
console.log(e.stack);
e.message = issue + e.message;

@@ -59,0 +60,0 @@ if (callback) callback(e);

@@ -42,36 +42,39 @@ #!/usr/bin/env node

var cmd = util.format('git clone "%s" "%s"', plugin_git_url, tmp_dir);
shell.exec(cmd, {silent: true, async:true}, function(code, output) {
if (code > 0) {
var err = new Error('failed to get the plugin via git from URL '+ plugin_git_url + ', output: ' + output);
if (callback) callback(err)
else throw err;
} else {
// Check out the specified revision, if provided.
if (git_ref) {
var result = shell.exec(util.format('git checkout "%s"', git_ref), { silent: true });
if (result.code > 0) {
var err = new Error('failed to checkout git ref "' + git_ref + '"');
if (callback) callback(err);
else throw err;
}
shell.cd(path.dirname(tmp_dir));
var cmd = util.format('git clone "%s" "%s"', plugin_git_url, path.basename(tmp_dir));
var result = shell.exec(cmd, {silent: true, async:false});
if (result.code > 0) {
var err = new Error('failed to get the plugin via git from URL '+ plugin_git_url + ', output: ' + result.output);
if (callback) callback(err)
else throw err;
} else {
console.log('Plugin "' + plugin_git_url + '" fetched.');
// Check out the specified revision, if provided.
if (git_ref) {
var cmd = util.format('cd "%s" && git checkout "%s"', tmp_dir, git_ref);
var result = shell.exec(cmd, { silent: true, async:false });
if (result.code > 0) {
var err = new Error('failed to checkout git ref "' + git_ref + '" for plugin at git url "' + plugin_git_url + '", output: ' + result.output);
if (callback) callback(err);
else throw err;
}
console.log('Checked out ' + git_ref);
}
// Read the plugin.xml file and extract the plugin's ID.
tmp_dir = path.join(tmp_dir, subdir);
// TODO: what if plugin.xml does not exist?
var xml_file = path.join(tmp_dir, 'plugin.xml');
var xml = xml_helpers.parseElementtreeSync(xml_file);
var plugin_id = xml.getroot().attrib.id;
// Read the plugin.xml file and extract the plugin's ID.
tmp_dir = path.join(tmp_dir, subdir);
// TODO: what if plugin.xml does not exist?
var xml_file = path.join(tmp_dir, 'plugin.xml');
var xml = xml_helpers.parseElementtreeSync(xml_file);
var plugin_id = xml.getroot().attrib.id;
// TODO: what if a plugin dependended on different subdirectories of the same plugin? this would fail.
// should probably copy over entire plugin git repo contents into plugins_dir and handle subdir seperately during install.
var plugin_dir = path.join(plugins_dir, plugin_id);
shell.cp('-R', path.join(tmp_dir, '*'), plugin_dir);
// TODO: what if a plugin dependended on different subdirectories of the same plugin? this would fail.
// should probably copy over entire plugin git repo contents into plugins_dir and handle subdir seperately during install.
var plugin_dir = path.join(plugins_dir, plugin_id);
shell.cp('-R', path.join(tmp_dir, '*'), plugin_dir);
if (callback) callback(null, plugin_dir);
}
});
if (callback) callback(null, plugin_dir);
}
}
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc