How to use cordova-lib - 10 common examples

To help you get started, we’ve selected a few cordova-lib 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 combine / universal-react-redux / scripts / cordova / build.js View on Github external
};

  // Check if config file exists, if not warn the user.
  if (config) {
    try {
      fs.accessSync(configFile, fs.F_OK);
    } catch (e) {
      console.log('Warning: build file not found, using defaults...');
    }
  }

  // switch to cordova directory
  process.chdir('./cordova');

  // build with options and distribute to Fabric if specified
  return cordova.raw.build(buildOpts).then(
    function() {
      if (distribute) {
        fabric.distribute(platforms, target);
      }
    },
    function(error) {
      console.log('Build failed:', error);
    }
  );
};
github phonegap / phonegap-cli / lib / phonegap / run.js View on Github external
if (!platform) {
        var platarg = options.platforms[0];
        self.phonegap.emit('error', {message:PG_STR.platerr[0]+platarg+PG_STR.platerr[1]+ platarg + PG_STR.platerr[2]});
        return; 
    }

    // change to project directory and delegate errors
    if (!project.cd({ emitter: self.phonegap, callback: callback })) return;

    // detect the platform support
    self.phonegap.emit('log', 'detecting', platform.human, 'SDK environment...');

    try {
        // will throw if element in options.platforms isn't recognized
        cordova.platform('', options.platforms, null)
        // invoke local build
        var env = 'local';
        self.phonegap.emit('log', PG_STR.useenv[0], env, PG_STR.useenv[1]);
        self.phonegap[env].run(options, callback);
    } catch (e) {
        // invoke remote build
        var env = 'remote';
        self.phonegap.emit('log', PG_STR.useenv[0], env, PG_STR.useenv[1]);
        self.phonegap[env].run(options, callback);
    };
};
github phonegap / phonegap-cli / lib / phonegap / install.js View on Github external
callback(new Error(msg));
        return;
    }

    
    // change to project directory and delegate errors
    if (!project.cd({ emitter: self.phonegap, callback: callback })) return;

    self.phonegap.emit('log', PG_STR.msgdet[0], platform.human, PG_STR.msgdet[1]);

    try {
        // will throw if element in options.platform isn't recognized
        installed = project.listPlatforms('.');
        if (!(options.platforms[0] in installed)) {
            cordova.platform('add', options.platforms, null, function(e){
                // invoke local build
                install.apply(self, ['local', options, callback]);
            });
        }
   } catch (e) {
        // invoke remote build
        install.apply(self, ['remote', options, callback]);
    }
};
github phonegap / phonegap-cli / lib / phonegap / build.js View on Github external
env = '';

    if (!platform) {
        var platarg = options.platforms[0];
        self.phonegap.emit('error', {message:PG_STR.platerr[0]+platarg+PG_STR.platerr[1]+ platarg + PG_STR.platerr[2]});
        return;
    }

    // change to project directory and delegate errors
    if (!project.cd({ emitter: self.phonegap, callback: callback })) return;

    self.phonegap.emit('log', PG_STR.msgdet[0], platform.human, PG_STR.msgdet[1]);

    // detect the platform support
    try {
        cordova.platform('.', platform.local, null);
        // invoke local or remote build
        var env = 'local';
        self.phonegap.emit('log', PG_STR.useenv[0], env, PG_STR.useenv[1]);
        self.phonegap[env].build(options, callback);
    } catch (e) {
        var env = 'remote';
        // emit a non-exiting message to stderr, incase user wants to react to local build failure
        self.phonegap.emit('error', e);
        self.phonegap.emit('log', PG_STR.useenv[0], env, PG_STR.useenv[1]);
        self.phonegap[env].build(options, callback);
    };
};
github phonegap / phonegap-cli / lib / phonegap / platform.update.js View on Github external
// validate parameters
    if (options.platforms.length < 1) {
        var e = new Error('missing a platform to update');
        self.phonegap.emit('error', e);
        callback(e);
        return;
    }

    // change to project directory and delegate errors
    if (!project.cd({ emitter: self.phonegap, callback: callback })) return;
for (each in self.phonegap.version())
{ self.phonegap.emit('log', each);}
    self.phonegap.emit('log', 'updating ' + platform.human + ' platform using PhoneGap CLI version ' + project.readPackage().version );

    // update the platform
    cordova.platform('update', [ platform.local ], function(e) {
        if (e) {
            self.phonegap.emit('error', e);
            callback(e);
            return;
        }

        self.phonegap.emit('log', 'successfully update', platform.human, 'platform');
        callback(null);
    });
};
github axemclion / react-native-cordova-plugin / cli / android-cli.js View on Github external
var path = require('path');
var fs = require('fs');

var Q = require('q');
var mkdirp = require('mkdirp');
var rimraf = require('rimraf')
var cordova = require('cordova-lib');
var glob = require('glob');

var CONFIG_XML = "";
var STRING_XML = '';
var ANDROID_MANIFEST = "";
var PLUGIN_GRADLE = "dependencies {compile fileTree(dir: 'libs', include: '*.jar')\n// SUB-PROJECT DEPENDENCIES START\n\n// SUB-PROJECT DEPENDENCIES END\n}\n// PLUGIN GRADLE EXTENSIONS START\n// PLUGIN GRADLE EXTENSIONS END";
var PLATFORM_DIR = path.resolve(__dirname, '../platforms/android');

cordova.events.on('verbose', console.log.bind(console));
cordova.events.on('log', console.log.bind(console));

function Android(projectRoot) {
    this.projectRoot = projectRoot;
}

Android.prototype.init = function () {
    if (this.isInitialized) {
        return;
    }
    createDirectories(['src', 'libs', 'res/xml', 'res/values', 'assets/www']);
    writeIfNotExists('res/xml/config.xml', CONFIG_XML);
    writeIfNotExists('res/values/strings.xml', STRING_XML);
    writeIfNotExists('project.properties', '');
    writeIfNotExists('plugin-build.gradle', PLUGIN_GRADLE);
    writeIfNotExists('AndroidManifest.xml', ANDROID_MANIFEST);
github axemclion / react-native-cordova-plugin / cli / android-cli.js View on Github external
var fs = require('fs');

var Q = require('q');
var mkdirp = require('mkdirp');
var rimraf = require('rimraf')
var cordova = require('cordova-lib');
var glob = require('glob');

var CONFIG_XML = "";
var STRING_XML = '';
var ANDROID_MANIFEST = "";
var PLUGIN_GRADLE = "dependencies {compile fileTree(dir: 'libs', include: '*.jar')\n// SUB-PROJECT DEPENDENCIES START\n\n// SUB-PROJECT DEPENDENCIES END\n}\n// PLUGIN GRADLE EXTENSIONS START\n// PLUGIN GRADLE EXTENSIONS END";
var PLATFORM_DIR = path.resolve(__dirname, '../platforms/android');

cordova.events.on('verbose', console.log.bind(console));
cordova.events.on('log', console.log.bind(console));

function Android(projectRoot) {
    this.projectRoot = projectRoot;
}

Android.prototype.init = function () {
    if (this.isInitialized) {
        return;
    }
    createDirectories(['src', 'libs', 'res/xml', 'res/values', 'assets/www']);
    writeIfNotExists('res/xml/config.xml', CONFIG_XML);
    writeIfNotExists('res/values/strings.xml', STRING_XML);
    writeIfNotExists('project.properties', '');
    writeIfNotExists('plugin-build.gradle', PLUGIN_GRADLE);
    writeIfNotExists('AndroidManifest.xml', ANDROID_MANIFEST);
    console.log('Initialized Android resources');
github apache / cordova-cli / src / help.js View on Github external
command = ((args)[0] || 'cordova');
    docdir = path.join(__dirname, '..', 'doc');
    file = [
        command + '.md',
        command + '.txt',
        'cordova.md',
        'cordova.txt'
    ].map(function (file) {
        var f = path.join(docdir, file);
        if (fs.existsSync(f)) {
            return f;
        }
    }).filter(function (f) {
        return !!f;
    });
    raw = fs.readFileSync(file[0]).toString('utf8').replace(/cordova-cli/g, cordova_lib.binname);
    // cordova.emit('results', raw);

    return raw;
};
github sony / generator-cordova-plugin-devbed / app / index.js View on Github external
'use strict';
var assert = require('assert');
var Q = require('q');
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var cordova_lib = require('cordova-lib');
var plugman = cordova_lib.plugman;
var cordova = cordova_lib.cordova;

//============================================================================
// CONFIGURE
//
var TEST_FRAMEWORK = 'http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework.git';

//============================================================================
// Yeoman generator implementation
//
module.exports = yeoman.generators.Base.extend({

  constructor: function (args, options, config) {
    yeoman.generators.Base.apply(this, arguments);
    this.props = options;
  },
github sony / generator-cordova-plugin-devbed / _plugin / index.js View on Github external
var assert = require('assert');
var yeoman = require('yeoman-generator');
var fs = require('fs');
var xml2js = require('xml2js');
var cordova_lib = require('cordova-lib');
var plugman = cordova_lib.plugman;

//============================================================================
// Yeoman generator implementation
//
module.exports = yeoman.generators.Base.extend({

  constructor: function (args, options, config) {
    yeoman.generators.Base.apply(this, arguments);
    this.props = options;
  },

  //==========================================================================
  // Create plugin
  //--------------------------------------------------------------------------
  // Run plugman: create plugin
  //