Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const FIXTURES = path.join(__dirname, '../fixtures');
const iosProject = path.join(FIXTURES, 'ios-config-xml', '*');
const faultyplugin = path.join(FIXTURES, 'org.test.plugins.faultyplugin');
const dummyplugin = path.join(FIXTURES, 'org.test.plugins.dummyplugin');
const weblessplugin = path.join(FIXTURES, 'org.test.plugins.weblessplugin');
const dummyPluginInfo = new PluginInfo(dummyplugin);
const dummy_id = dummyPluginInfo.id;
const valid_source = dummyPluginInfo.getSourceFiles('ios');
const valid_headers = dummyPluginInfo.getHeaderFiles('ios');
const valid_resources = dummyPluginInfo.getResourceFiles('ios');
const valid_custom_frameworks = dummyPluginInfo.getFrameworks('ios').filter(f => f.custom);
const valid_embeddable_custom_frameworks = dummyPluginInfo.getFrameworks('ios').filter(f => f.custom && f.embed);
const valid_weak_frameworks = dummyPluginInfo.getFrameworks('ios').filter(f => !(f.custom) && f.weak);
const faultyPluginInfo = new PluginInfo(faultyplugin);
const invalid_source = faultyPluginInfo.getSourceFiles('ios');
const invalid_headers = faultyPluginInfo.getHeaderFiles('ios');
const invalid_resources = faultyPluginInfo.getResourceFiles('ios');
const invalid_custom_frameworks = faultyPluginInfo.getFrameworks('ios').filter(f => f.custom);
const weblessPluginInfo = new PluginInfo(weblessplugin);
function copyArray (arr) {
return Array.prototype.slice.call(arr, 0);
}
function slashJoin () {
// In some places we need to use forward slash instead of path.join().
// See CB-7311.
return Array.prototype.join.call(arguments, '/');
}
beforeEach(function () {
shell.mkdir('-p', cordovaProjectWindowsPlatformDir);
shell.cp('-rf', path.join(__dirname, '../fixtures/DummyProject/*'), cordovaProjectWindowsPlatformDir);
dummyProject = JsprojManager.getProject(cordovaProjectWindowsPlatformDir);
shell.mkdir('-p', cordovaProjectPluginsDir);
shell.cp('-rf', dummyplugin, cordovaProjectPluginsDir);
// CB-11558 Reinitialize plugin.dir to become project_root/plugins/plugin.id to avoid
// different drives issue resulting in absolute path in projectReferences.
dummyPluginInfo = new PluginInfo(path.join(cordovaProjectPluginsDir, dummyPluginInfo.id));
});
var shell = require('shelljs');
var rewire = require('rewire');
var PluginHandler = rewire('../../../template/cordova/lib/PluginHandler');
var JsprojManager = require('../../../template/cordova/lib/JsprojManager');
var cordovaProjectDir = path.join(os.tmpdir(), 'plugman');
var testProjectWindowsPlatformDir = path.join(__dirname, '../fixtures/testProj', 'platforms', 'windows');
var cordovaProjectWindowsPlatformDir = path.join(cordovaProjectDir, 'platforms', 'windows');
var cordovaProjectPluginsDir = path.join(cordovaProjectDir, 'plugins');
var PluginInfo = require('cordova-common').PluginInfo;
var pluginInfo = require('../../../template/cordova/lib/PluginInfo').PluginInfo;
var dummyplugin = path.join(__dirname, '../fixtures/testProj/plugins/org.test.plugins.dummyplugin');
var testPlugin = path.join(__dirname, '../fixtures/testProj/plugins/testPlugin');
var dummyPluginInfo = new PluginInfo(dummyplugin);
var testPluginInfo = new pluginInfo(testPlugin); /* eslint new-cap : 0 */
var valid_source = dummyPluginInfo.getSourceFiles('windows');
var valid_resourceFiles = dummyPluginInfo.getResourceFiles('windows');
var valid_libfiles = dummyPluginInfo.getLibFiles('windows');
var valid_frameworks = dummyPluginInfo.getFrameworks('windows');
var test_frameworks = testPluginInfo.getFrameworks('windows');
var faultyplugin = path.join(__dirname, '../fixtures/org.test.plugins.faultyplugin');
var faultyPluginInfo = new PluginInfo(faultyplugin);
var invalid_source = faultyPluginInfo.getSourceFiles('windows');
var invalid_resourceFiles = faultyPluginInfo.getResourceFiles('windows');
var invalid_libfiles = faultyPluginInfo.getLibFiles('windows');
var resourcereferenceplugin = path.join(__dirname, '../fixtures/org.test.plugins.resourcereferenceplugin');
var resourcePluginInfo = new PluginInfo(resourcereferenceplugin);
var valid_resourcereferenceFiles = resourcePluginInfo.getResourceFiles('windows');
beforeEach(function () {
shell.mkdir('-p', cordovaProjectWindowsPlatformDir);
shell.cp('-rf', path.join(__dirname, '../fixtures/DummyProject/*'), cordovaProjectWindowsPlatformDir);
dummyProject = JsprojManager.getProject(cordovaProjectWindowsPlatformDir);
shell.mkdir('-p', cordovaProjectPluginsDir);
shell.cp('-rf', dummyplugin, cordovaProjectPluginsDir);
// CB-11558 Reinitialize plugin.dir to become project_root/plugins/plugin.id to avoid
// different drives issue resulting in absolute path in projectReferences.
dummyPluginInfo = new PluginInfo(path.join(cordovaProjectPluginsDir, dummyPluginInfo.id));
});
specific language governing permissions and limitations
under the License.
*/
var blackberry10 = require('../../../src/plugman/platforms/blackberry10');
var common = require('../../../src/plugman/platforms/common');
var path = require('path');
var fs = require('fs');
var shell = require('shelljs');
var os = require('os');
var temp = path.join(os.tmpdir(), 'plugman');
var blackberry10_project = path.join(__dirname, '..', 'projects', 'blackberry10', '*');
var PluginInfo = require('cordova-common').PluginInfo;
var plugins = {
dummy: new PluginInfo(path.join(__dirname, '..', 'plugins', 'org.test.plugins.dummyplugin')),
faulty: new PluginInfo(path.join(__dirname, '..', 'plugins', 'org.test.plugins.faultyplugin')),
echo: new PluginInfo(path.join(__dirname, '..', 'plugins', 'com.cordova.echo'))
};
function copyArray (arr) {
return Array.prototype.slice.call(arr, 0);
}
describe('blackberry10 project handler', function () {
describe('www_dir method', function () {
it('Test 001 : should return cordova-blackberry10 project www location using www_dir', function () {
expect(blackberry10.www_dir(path.sep)).toEqual(path.sep + 'www');
});
});
describe('package_name method', function () {
it('Test 002 : should return a blackberry10 project\'s proper package name', function () {
function installDependency(dep, install, options) {
var opts;
dep.install_dir = path.join(install.plugins_dir, dep.id);
events.emit('verbose', 'Requesting plugin "' + (dep.version? dep.id+'@'+dep.version : dep.id) + '".' );
if (fs.existsSync(dep.install_dir) ) {
var pluginInfo = new PluginInfo(dep.install_dir);
var version_installed = pluginInfo.version;
var version_required = dep.version;
if(dep.version) {
if (Number(dep.version.replace('.',''))) {
version_required = '^' + dep.version;
}
}
//strip -dev from the installed plugin version so it properly passes
//semver.satisfies
var stripped_version;
if(version_installed.includes('-dev')) {
stripped_version = semver.inc(version_installed, 'patch');
}
if (options.force ||
semver.satisfies(version_installed, version_required, /*loose=*/true) ||
under the License.
*/
var blackberry10 = require('../../src/plugman/platforms/blackberry10'),
common = require('../../src/plugman/platforms/common'),
path = require('path'),
fs = require('fs'),
shell = require('shelljs'),
os = require('os'),
temp = path.join(os.tmpdir(), 'plugman'),
blackberry10_project = path.join(__dirname, '..', 'projects', 'blackberry10', '*');
var PluginInfo = require('cordova-common').PluginInfo;
var plugins = {
dummy: new PluginInfo(path.join(__dirname, '..', 'plugins', 'org.test.plugins.dummyplugin')),
faulty: new PluginInfo(path.join(__dirname, '..', 'plugins', 'org.test.plugins.faultyplugin')),
echo: new PluginInfo(path.join(__dirname, '..', 'plugins', 'com.cordova.echo'))
};
function copyArray(arr) {
return Array.prototype.slice.call(arr, 0);
}
describe('blackberry10 project handler', function() {
describe('www_dir method', function() {
it('Test 001 : should return cordova-blackberry10 project www location using www_dir', function() {
expect(blackberry10.www_dir(path.sep)).toEqual(path.sep + 'www');
});
});
describe('package_name method', function() {
project2 = path.join(spec, 'projects', 'android_uninstall.test2'),
project3 = path.join(spec, 'projects', 'android_uninstall.test3'),
plugins_dir = path.join(spec, 'plugins'),
plugins_install_dir = path.join(project, 'cordova', 'plugins'),
plugins_install_dir2 = path.join(project2, 'cordova', 'plugins'),
plugins_install_dir3 = path.join(project3, 'cordova', 'plugins'),
plugins = {
'org.test.plugins.dummyplugin' : path.join(plugins_dir, 'org.test.plugins.dummyplugin'),
'A' : path.join(plugins_dir, 'dependencies', 'A'),
'C' : path.join(plugins_dir, 'dependencies', 'C')
},
dummy_id = 'org.test.plugins.dummyplugin';
var dummyPluginInfo = new PluginInfo(plugins['org.test.plugins.dummyplugin']);
var TEST_XML = '\n' +
'\n' +
' Hello Cordova\n' +
' \n' +
' A sample Apache Cordova application that responds to the deviceready event.\n' +
' \n' +
' \n' +
' Apache Cordova Team\n' +
' \n' +
' <content src="index.html">\n' +
' \n' +
'</content>\n';
path = require('path'),
fs = require('fs'),
shell = require('shelljs'),
os = require('os'),
temp = path.join(os.tmpdir(), 'plugman'),
plugins_dir = path.join(temp, 'cordova', 'plugins'),
ios_config_xml_project = path.join(__dirname, '..', 'projects', 'ios-config-xml', '*'),
ios_project = path.join(ios_config_xml_project, '..'),
faultyplugin = path.join(__dirname, '..', 'plugins', 'org.test.plugins.faultyplugin'),
dummyplugin = path.join(__dirname, '..', 'plugins', 'org.test.plugins.dummyplugin'),
weblessplugin = path.join(__dirname, '..', 'plugins', 'org.test.plugins.weblessplugin'),
done = false;
var PluginInfo = require('cordova-common').PluginInfo;
var dummyPluginInfo = new PluginInfo(dummyplugin);
var dummy_id = dummyPluginInfo.id;
var valid_source = dummyPluginInfo.getSourceFiles('ios'),
valid_headers = dummyPluginInfo.getHeaderFiles('ios'),
valid_resources = dummyPluginInfo.getResourceFiles('ios'),
valid_custom_frameworks = dummyPluginInfo.getFrameworks('ios').filter(function(f) { return f.custom; });
var faultyPluginInfo = new PluginInfo(faultyplugin);
var faulty_id = faultyPluginInfo.id;
var invalid_source = faultyPluginInfo.getSourceFiles('ios');
var invalid_headers = faultyPluginInfo.getHeaderFiles('ios');
var invalid_resources = faultyPluginInfo.getResourceFiles('ios');
var invalid_custom_frameworks = faultyPluginInfo.getFrameworks('ios').filter(function(f) { return f.custom; });
shell.mkdir('-p', temp);
shell.cp('-rf', ios_config_xml_project, temp);
var os = require('os');
var temp = path.join(os.tmpdir(), 'plugman');
var plugins_dir = path.join(temp, 'cordova/plugins');
var dummyplugin = path.join(__dirname, '../../fixtures/org.test.plugins.dummyplugin');
var faultyplugin = path.join(__dirname, '../../fixtures/org.test.plugins.faultyplugin');
var android_project = path.join(__dirname, '../../fixtures/android_project/*');
var PluginInfo = require('cordova-common').PluginInfo;
var AndroidProject = require('../../../bin/templates/cordova/lib/AndroidProject');
var dummyPluginInfo = new PluginInfo(dummyplugin);
var valid_source = dummyPluginInfo.getSourceFiles('android');
var valid_resources = dummyPluginInfo.getResourceFiles('android');
var valid_libs = dummyPluginInfo.getLibFiles('android');
var faultyPluginInfo = new PluginInfo(faultyplugin);
var invalid_source = faultyPluginInfo.getSourceFiles('android');
describe('android project handler', function () {
describe('installation', function () {
var copyFileOrig = common.__get__('copyFile');
var copyFileSpy = jasmine.createSpy('copyFile');
var dummyProject;
beforeEach(function () {
shell.mkdir('-p', temp);
dummyProject = AndroidProject.getProjectFile(temp);
copyFileSpy.calls.reset();
common.__set__('copyFile', copyFileSpy);
});
afterEach(function () {