How to use the cordova-common.PluginInfo function in cordova-common

To help you get started, we’ve selected a few cordova-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / cordova-ios / tests / spec / unit / Plugman / pluginHandler.spec.js View on Github external
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, '/');
}
github apache / cordova-windows / spec / unit / pluginHandler / windows.spec.js View on Github external
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));
    });
github apache / cordova-windows / spec / unit / pluginHandler / windows.spec.js View on Github external
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');
github katzer / cordova-plugin-badge / node_modules / cordova-windows / spec / unit / pluginHandler / windows.spec.js View on Github external
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));
    });
github apache / cordova-lib / spec / plugman / platforms / blackberry10.spec.js View on Github external
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 () {
github apache / cordova-lib / cordova-lib / src / plugman / install.js View on Github external
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) ||
github apache / cordova-lib / cordova-lib / spec-plugman / platforms / blackberry10.spec.js View on Github external
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() {
github apache / cordova-lib / cordova-lib / spec-plugman / uninstall.spec.js View on Github external
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';
github apache / cordova-lib / cordova-lib / spec-plugman / platforms / ios.spec.js View on Github external
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);
github myFace-KYC / Identity_Verification / node_modules / cordova-android / spec / unit / pluginHandlers / handlers.spec.js View on Github external
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 () {