diff --git a/integration-tests/fetch.spec.js b/integration-tests/fetch.spec.js index 28278ae92..78e3b9b44 100644 --- a/integration-tests/fetch.spec.js +++ b/integration-tests/fetch.spec.js @@ -49,15 +49,15 @@ describe('end-to-end plugin dependency tests', function() { }); it('Test 029 : should fail if dependency already installed is wrong version', function(done) { - cordova.raw.create('hello3') + cordova.create('hello3') .then(function() { process.chdir(project); - return cordova.raw.platform('add', 'android', {'fetch': true}); + return cordova.platform('add', 'android', {'fetch': true}); }).then(function() { - return cordova.raw.plugin('add', 'cordova-plugin-file', {'fetch': true}); + return cordova.plugin('add', 'cordova-plugin-file', {'fetch': true}); }).then(function() { expect(path.join(pluginsDir, 'cordova-plugin-file')).toExist(); - return cordova.raw.plugin('add', plugins['Test1'], {'fetch': true}); + return cordova.plugin('add', plugins['Test1'], {'fetch': true}); }).fail(function(err) { expect(err.message).toContain('does not satisfy dependency plugin requirement'); }) @@ -65,17 +65,17 @@ describe('end-to-end plugin dependency tests', function() { }, TIMEOUT); it('Test 030 : should pass if dependency already installed is wrong version with --force', function(done) { - cordova.raw.create('hello3') + cordova.create('hello3') .then(function() { process.chdir(project); - return cordova.raw.platform('add', 'android', {'fetch': true}); + return cordova.platform('add', 'android', {'fetch': true}); }) .then(function() { - return cordova.raw.plugin('add', 'cordova-plugin-file', {'fetch': true}); + return cordova.plugin('add', 'cordova-plugin-file', {'fetch': true}); }) .then(function() { expect(path.join(pluginsDir, 'cordova-plugin-file')).toExist(); - return cordova.raw.plugin('add', plugins['Test1'], {'fetch': true, 'force':true}); + return cordova.plugin('add', plugins['Test1'], {'fetch': true, 'force':true}); }) .then(function() { expect(path.join(pluginsDir, 'Test1')).toExist(); @@ -89,17 +89,17 @@ describe('end-to-end plugin dependency tests', function() { it('Test 031 : should pass if dependency already installed is same major version (if specific version is specified)', function(done) { //Test1 requires cordova-plugin-file version 2.0.0 (which should automatically turn into ^2.0.0); we'll install version 2.1.0 - cordova.raw.create('hello3') + cordova.create('hello3') .then(function() { process.chdir(project); - return cordova.raw.platform('add', 'android', {'fetch': true}); + return cordova.platform('add', 'android', {'fetch': true}); }) .then(function() { - return cordova.raw.plugin('add', 'cordova-plugin-file@2.1.0', {'fetch': true}); + return cordova.plugin('add', 'cordova-plugin-file@2.1.0', {'fetch': true}); }) .then(function() { expect(path.join(pluginsDir, 'cordova-plugin-file')).toExist(); - return cordova.raw.plugin('add', plugins['Test1'], {'fetch': true}); + return cordova.plugin('add', plugins['Test1'], {'fetch': true}); }) .then(function() { expect(path.join(pluginsDir, 'Test1')).toExist(); @@ -114,21 +114,21 @@ describe('end-to-end plugin dependency tests', function() { it('Test 032 : should handle two plugins with same dependent plugin', function(done) { //Test1 and Test2 have compatible dependencies on cordova-plugin-file //Test1 and Test3 have incompatible dependencies on cordova-plugin-file - cordova.raw.create('hello3') + cordova.create('hello3') .then(function() { process.chdir(project); - return cordova.raw.platform('add', 'android', {'fetch': true}); + return cordova.platform('add', 'android', {'fetch': true}); }) .then(function() { - return cordova.raw.plugin('add', plugins['Test1'], {'fetch': true}); + return cordova.plugin('add', plugins['Test1'], {'fetch': true}); }) .then(function() { expect(path.join(pluginsDir, 'cordova-plugin-file')).toExist(); expect(path.join(pluginsDir, 'Test1')).toExist(); - return cordova.raw.plugin('add', plugins['Test2'], {'fetch': true}); + return cordova.plugin('add', plugins['Test2'], {'fetch': true}); }) .then(function() { - return cordova.raw.plugin('add', plugins['Test3'], {'fetch': true}); + return cordova.plugin('add', plugins['Test3'], {'fetch': true}); }) .fail(function(err) { expect(path.join(pluginsDir, 'Test2')).toExist(); @@ -141,16 +141,16 @@ describe('end-to-end plugin dependency tests', function() { it('Test 033 : should use a dev version of a dependent plugin if it is already installed', function(done) { //Test4 has this dependency in its plugin.xml: // - cordova.raw.create('hello3') + cordova.create('hello3') .then(function() { process.chdir(project); - return cordova.raw.platform('add', 'android', {'fetch': true}); + return cordova.platform('add', 'android', {'fetch': true}); }) .then(function() { - return cordova.raw.plugin('add', 'https://github.com/apache/cordova-plugin-file'); + return cordova.plugin('add', 'https://github.com/apache/cordova-plugin-file'); }) .then(function() { - return cordova.raw.plugin('add', plugins['Test4'], {'fetch': true}); + return cordova.plugin('add', plugins['Test4'], {'fetch': true}); }) .then(function() { expect(path.join(pluginsDir, 'cordova-plugin-file')).toExist(); diff --git a/integration-tests/pkgJson-restore.spec.js b/integration-tests/pkgJson-restore.spec.js index 4fb2f61f4..01402e90e 100644 --- a/integration-tests/pkgJson-restore.spec.js +++ b/integration-tests/pkgJson-restore.spec.js @@ -55,7 +55,7 @@ describe('tests platform/spec restore with --save', function () { // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -79,7 +79,7 @@ describe('tests platform/spec restore with --save', function () { emptyPlatformList().then(function() { // Add platform with save, fetch - return cordova.raw.platform('add', androidPlatform, {'save':true , 'fetch':true}); + return cordova.platform('add', androidPlatform, {'save':true , 'fetch':true}); }).then(function() { pkgJson = cordova_util.requireNoCache(pkgJsonPath); // Added platform properly to pkg.json @@ -104,7 +104,7 @@ describe('tests platform/spec restore with --save', function () { expect(firstCharConfig === '~'); }).then(function() { // Run cordova prepare - return cordova.raw.prepare(); + return cordova.prepare(); }).then(function() { pkgJson = cordova_util.requireNoCache(pkgJsonPath); // No changes to pkg.json spec for android. @@ -149,7 +149,7 @@ describe('tests platform/spec restore with --save', function () { emptyPlatformList().then(function() { // Add platform with save and fetch - return cordova.raw.platform('add', 'https://github.com/apache/cordova-browser', {'save':true, 'fetch':true}); + return cordova.platform('add', 'https://github.com/apache/cordova-browser', {'save':true, 'fetch':true}); }).then(function() { // Check that platform was added to config.xml successfully. var cfg = new ConfigParser(configXmlPath); @@ -171,7 +171,7 @@ describe('tests platform/spec restore with --save', function () { expect(platformsJson[bPlatform]).toBeDefined(); }).then(function() { // Remove platform without --save. - return cordova.raw.platform('rm', bPlatform, {'fetch':true}); + return cordova.platform('rm', bPlatform, {'fetch':true}); }).then(function() { // Platform in pkg.json should still be there. pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -182,7 +182,7 @@ describe('tests platform/spec restore with --save', function () { expect(platformsJson[bPlatform]).toBeUndefined(); }).then(function() { // Run cordova prepare - return cordova.raw.prepare({'fetch':true}); + return cordova.prepare({'fetch':true}); }).then(function() { // Check config.xml for spec modification. var cfg3 = new ConfigParser(configXmlPath); @@ -224,7 +224,7 @@ describe('tests platform/spec restore with --save', function () { emptyPlatformList().then(function() { // Add plugin with save and fetch. - return cordova.raw.plugin('add', ['https://github.com/apache/cordova-plugin-splashscreen'], {'save':true, 'fetch':true}); + return cordova.plugin('add', ['https://github.com/apache/cordova-plugin-splashscreen'], {'save':true, 'fetch':true}); }).then(function() { // Plugin id and spec were added to config.xml successfully. var cfg = new ConfigParser(configXmlPath); @@ -240,7 +240,7 @@ describe('tests platform/spec restore with --save', function () { expect(path.join(pluginsFolderPath, 'cordova-plugin-splashscreen')).toExist(); }).then(function() { // Remove plugin without --save. - return cordova.raw.plugin('rm', 'cordova-plugin-splashscreen', {'fetch':true}); + return cordova.plugin('rm', 'cordova-plugin-splashscreen', {'fetch':true}); }).then(function() { // Plugin id and spec are still in config.xml. var cfg2 = new ConfigParser(configXmlPath); @@ -256,10 +256,10 @@ describe('tests platform/spec restore with --save', function () { expect(path.join(pluginsFolderPath, 'cordova-plugin-splashscreen')).not.toExist(); }).then(function() { // Add platform (so that prepare can run). - return cordova.raw.platform('add', 'browser', {'save':true}); + return cordova.platform('add', 'browser', {'save':true}); }).then(function() { // Run cordova prepare with fetch. - return cordova.raw.prepare({'fetch':true}); + return cordova.prepare({'fetch':true}); }).then(function() { // Config.xml spec is modified. var cfg3 = new ConfigParser(configXmlPath); @@ -304,7 +304,7 @@ describe('tests platform/spec restore with --save', function () { // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -312,7 +312,7 @@ describe('tests platform/spec restore with --save', function () { } function fullPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBeGreaterThan(-1); @@ -333,10 +333,10 @@ describe('tests platform/spec restore with --save', function () { emptyPlatformList().then(function() { // Add 'browser' platform to project without --save - return cordova.raw.platform('add', secondPlatformAdded); + return cordova.platform('add', secondPlatformAdded); }).then(function() { // Add helpers.testPlatform to project with --save - return cordova.raw.platform('add', [helpers.testPlatform], {'save':true}); + return cordova.platform('add', [helpers.testPlatform], {'save':true}); }).then(function() { // Delete any previous caches of require(package.json) and (platformsJson) pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -351,10 +351,10 @@ describe('tests platform/spec restore with --save', function () { }).then(fullPlatformList) // Platforms should still be in platform ls. .then(function() { // Remove helpers.testPlatform without --save. - return cordova.raw.platform('rm', [helpers.testPlatform]); + return cordova.platform('rm', [helpers.testPlatform]); }).then(function() { // Remove secondPlatformAdded without --save. - return cordova.raw.platform('rm', secondPlatformAdded); + return cordova.platform('rm', secondPlatformAdded); }).then(function() { // Delete any previous caches of require(pkgJson) and (platformsJson) platformsJson = cordova_util.requireNoCache(platformsFolderPath); @@ -366,7 +366,7 @@ describe('tests platform/spec restore with --save', function () { expect(platformsJson[helpers.testPlatform]).toBeUndefined(); }).then(function() { // Run cordova prepare - return cordova.raw.prepare(); + return cordova.prepare(); }).then(function() { // Delete any previous caches of platformsJson platformsJson = cordova_util.requireNoCache(platformsFolderPath); @@ -406,7 +406,7 @@ describe('files should not be modified if their platforms are identical', functi // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -430,7 +430,7 @@ describe('files should not be modified if their platforms are identical', functi // Pkg.json and config.xml contain only android at this point (basePkgJson6). emptyPlatformList().then(function() { // Run cordova prepare. - return cordova.raw.prepare(); + return cordova.prepare(); }).then(function() { var cfg2 = new ConfigParser(configXmlPath); engines = cfg2.getEngines(); @@ -476,7 +476,7 @@ describe('update pkg.json to include platforms in config.xml', function () { // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -513,7 +513,7 @@ describe('update pkg.json to include platforms in config.xml', function () { expect(pkgJson.dependencies[browserPlatform]).toBeUndefined(); expect(pkgJson.dependencies[androidPlatform]).toBeUndefined(); emptyPlatformList().then(function() { - return cordova.raw.prepare(); + return cordova.prepare(); }).then(function() { pkgJson = cordova_util.requireNoCache(pkgJsonPath); // Expect 'browser' to be added to pkg.json. @@ -560,7 +560,7 @@ describe('update empty package.json to match config.xml', function () { // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -590,7 +590,7 @@ describe('update empty package.json to match config.xml', function () { expect(configEngArray.indexOf('android')).toBeGreaterThan(-1); expect(configEngArray.length === 1); // Run cordova prepare. - cordova.raw.prepare(); + cordova.prepare(); emptyPlatformList().then(function() { var cfg2 = new ConfigParser(configXmlPath); engines = cfg2.getEngines(); @@ -638,7 +638,7 @@ describe('update config.xml to include platforms in pkg.json', function () { // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -670,7 +670,7 @@ describe('update config.xml to include platforms in pkg.json', function () { expect(pkgJson.dependencies).toEqual({ 'cordova-android' : '^3.1.0', 'cordova-browser' : '^4.1.0' }); emptyPlatformList().then(function() { // Run cordova prepare. - return cordova.raw.prepare(); + return cordova.prepare(); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -725,7 +725,7 @@ describe('update config.xml to use the variable found in pkg.json', function () }); // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -759,7 +759,7 @@ describe('update config.xml to use the variable found in pkg.json', function () emptyPlatformList().then(function() { // Run cordova prepare. - return cordova.raw.prepare(); + return cordova.prepare(); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -808,7 +808,7 @@ describe('update pkg.json to include plugin and variable found in config.xml', f // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -844,7 +844,7 @@ describe('update pkg.json to include plugin and variable found in config.xml', f emptyPlatformList().then(function() { // Run cordova prepare. - return cordova.raw.prepare(); + return cordova.prepare(); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -894,7 +894,7 @@ describe('update pkg.json AND config.xml to include all plugins and merge unique // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -946,7 +946,7 @@ describe('update pkg.json AND config.xml to include all plugins and merge unique emptyPlatformList().then(function() { // Run cordova prepare. - return cordova.raw.prepare(); + return cordova.prepare(); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -1016,7 +1016,7 @@ describe('update pkg.json AND config.xml to include all plugins/merge variables // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -1075,7 +1075,7 @@ describe('update pkg.json AND config.xml to include all plugins/merge variables emptyPlatformList().then(function() { // Run cordova prepare - return cordova.raw.prepare(); + return cordova.prepare(); }).then(function() { // Delete any previous caches of require(package.json) pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -1157,7 +1157,7 @@ describe('update config.xml to include the plugin that is in pkg.json', function // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -1193,7 +1193,7 @@ describe('update config.xml to include the plugin that is in pkg.json', function emptyPlatformList().then(function() { // Run cordova prepare. - return cordova.raw.prepare(); + return cordova.prepare(); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -1256,7 +1256,7 @@ describe('platforms and plugins should be restored with config.xml even without // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -1290,7 +1290,7 @@ describe('platforms and plugins should be restored with config.xml even without emptyPlatformList().then(function() { // Run platform add. - return cordova.raw.platform('add', browserPlatform, {'save':true}); + return cordova.platform('add', browserPlatform, {'save':true}); }).then(function () { // Android and browser are in config.xml. var cfg3 = new ConfigParser(configXmlPath); @@ -1317,7 +1317,7 @@ describe('platforms and plugins should be restored with config.xml even without expect(pkgJson.version).toEqual(cfg3.version()); expect(pkgJson.displayName).toEqual(cfg3.name()); // Remove android without --save. - return cordova.raw.platform('rm', [browserPlatform]); + return cordova.platform('rm', [browserPlatform]); }).then(function () { // Android should not be in the installed list (only browser). platformsJson = cordova_util.requireNoCache(platformsFolderPath1); @@ -1326,7 +1326,7 @@ describe('platforms and plugins should be restored with config.xml even without expect(platformsJson[androidPlatform]).not.toBeDefined(); }).then(function () { // Run cordova prepare. - return cordova.raw.prepare(); + return cordova.prepare(); }).then(function() { var cfg2 = new ConfigParser(configXmlPath); engines = cfg2.getEngines(); @@ -1357,7 +1357,7 @@ describe('platforms and plugins should be restored with config.xml even without expect(path.join(pluginsFolderPath16, 'cordova-plugin-device')).toExist(); }).then(function () { // Remove plugin without save. - return cordova.raw.plugin('rm', 'cordova-plugin-device'); + return cordova.plugin('rm', 'cordova-plugin-device'); }).then(function () { var cfg4 = new ConfigParser(configXmlPath); engines = cfg4.getEngines(); @@ -1372,7 +1372,7 @@ describe('platforms and plugins should be restored with config.xml even without expect(path.join(pluginsFolderPath16, 'cordova-plugin-device')).not.toExist(); }).then(function () { // Run cordova prepare. - return cordova.raw.prepare(); + return cordova.prepare(); }).then(function () { // Plugin should be restored and returned to the installed list. expect(path.join(pluginsFolderPath16, 'cordova-plugin-device')).toExist(); @@ -1407,7 +1407,7 @@ describe('tests platform/spec restore with --save', function () { // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -1415,7 +1415,7 @@ describe('tests platform/spec restore with --save', function () { } function fullPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBeGreaterThan(-1); @@ -1437,7 +1437,7 @@ describe('tests platform/spec restore with --save', function () { emptyPlatformList().then(function() { // Add the testing platform with --save. - return cordova.raw.platform('add', 'android', {'save':true}); + return cordova.platform('add', 'android', {'save':true}); }).then(function() { pkgJson = cordova_util.requireNoCache(pkgJsonPath); // Require platformsFolderPath @@ -1451,7 +1451,7 @@ describe('tests platform/spec restore with --save', function () { }).then(fullPlatformList) // Platform should still be in platform ls. .then(function() { // And now remove helpers.testPlatform without --save. - return cordova.raw.platform('rm', [helpers.testPlatform]); + return cordova.platform('rm', [helpers.testPlatform]); }).then(function() { // Delete any previous caches of require(package.json) and (platforms.json) platformsJson = cordova_util.requireNoCache(platformsFolderPath); @@ -1462,7 +1462,7 @@ describe('tests platform/spec restore with --save', function () { expect(platformsJson[helpers.testPlatform]).toBeUndefined(); }).then(function() { // Run cordova prepare. - return cordova.raw.prepare(); + return cordova.prepare(); }).then(function() { // Delete any previous caches of platforms.json. platformsJson = cordova_util.requireNoCache(platformsFolderPath); @@ -1489,10 +1489,10 @@ describe('tests platform/spec restore with --save', function () { emptyPlatformList().then(function() { // Add the testing platform with --save. - return cordova.raw.platform('add', [helpers.testPlatform], {'save':true}); + return cordova.platform('add', [helpers.testPlatform], {'save':true}); }).then(function() { // Add the 'browser' platform with --save - return cordova.raw.platform('add',secondPlatformAdded, {'save':true}); + return cordova.platform('add',secondPlatformAdded, {'save':true}); }).then(function() { // Delete any previous caches of require(package.json) and (platforms.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -1508,10 +1508,10 @@ describe('tests platform/spec restore with --save', function () { }).then(fullPlatformList) // Platform should still be in platform ls. .then(function() { // Remove helpers.testPlatform with --save. - return cordova.raw.platform('rm', [helpers.testPlatform], {'save':true}); + return cordova.platform('rm', [helpers.testPlatform], {'save':true}); }).then(function() { // Remove secondPlatformAdded without --save. - return cordova.raw.platform('rm', secondPlatformAdded); + return cordova.platform('rm', secondPlatformAdded); }).then(function() { // Delete any previous caches of require(package.json) and (platformsJson). platformsJson = cordova_util.requireNoCache(platformsFolderPath); @@ -1524,7 +1524,7 @@ describe('tests platform/spec restore with --save', function () { expect(platformsJson[secondPlatformAdded]).toBeUndefined(); }).then(function() { // Run cordova prepare. - return cordova.raw.prepare(); + return cordova.prepare(); }).then(function() { // Delete any previous caches of platformsJson. platformsJson = cordova_util.requireNoCache(platformsFolderPath); diff --git a/integration-tests/pkgJson.spec.js b/integration-tests/pkgJson.spec.js index 9e85d08a1..d5cdf1569 100644 --- a/integration-tests/pkgJson.spec.js +++ b/integration-tests/pkgJson.spec.js @@ -77,7 +77,7 @@ describe('plugin end-to-end', function() { expect(pkgJsonPath).toExist(); // Add the plugin with --save. - return cordova.raw.plugin('add', pluginId+'@1.1.2', {'save':true, 'fetch':true}) + return cordova.plugin('add', pluginId+'@1.1.2', {'save':true, 'fetch':true}) .then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -94,7 +94,7 @@ describe('plugin end-to-end', function() { expect(configPlugin).toEqual({ name: 'cordova-plugin-device', spec: '^1.1.2', variables: {} }); }).then(function() { // And now remove it with --save. - return cordova.raw.plugin('rm', pluginId, {'save':true, 'fetch':true}); + return cordova.plugin('rm', pluginId, {'save':true, 'fetch':true}); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -113,10 +113,10 @@ describe('plugin end-to-end', function() { expect(pkgJsonPath).toExist(); // Add the geolocation plugin with --save. - return cordova.raw.plugin('add', 'cordova-plugin-geolocation', {'save':true, 'fetch':true}) + return cordova.plugin('add', 'cordova-plugin-geolocation', {'save':true, 'fetch':true}) .then(function() { // Add a second plugin without save. - return cordova.raw.plugin('add', pluginId); + return cordova.plugin('add', pluginId); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -137,7 +137,7 @@ describe('plugin end-to-end', function() { expect(pkgJsonPath).toExist(); // Add the plugin with --save. - return cordova.raw.plugin('add', pluginId, {'save':true}) + return cordova.plugin('add', pluginId, {'save':true}) .then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -147,7 +147,7 @@ describe('plugin end-to-end', function() { expect(pkgJson.cordova.plugins[pluginId]).toBeDefined(); }).then(function() { // And now remove it, but without --save. - return cordova.raw.plugin('rm', 'cordova-plugin-device'); + return cordova.plugin('rm', 'cordova-plugin-device'); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -166,7 +166,7 @@ describe('plugin end-to-end', function() { expect(pkgJsonPath).toExist(); // Add the plugin with --save. - return cordova.raw.plugin('add', pluginId, {'save':true, 'cli_variables': {'someKey':'someValue'}}) + return cordova.plugin('add', pluginId, {'save':true, 'cli_variables': {'someKey':'someValue'}}) .then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -177,7 +177,7 @@ describe('plugin end-to-end', function() { expect(pkgJson.cordova.plugins[pluginId][someKey]).toEqual('someValue'); }).then(function() { // And now remove it with --save. - return cordova.raw.plugin('rm', pluginId, {'save':true}); + return cordova.plugin('rm', pluginId, {'save':true}); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -197,7 +197,7 @@ describe('plugin end-to-end', function() { expect(pkgJsonPath).toExist(); // Add the plugin with --save. - return cordova.raw.plugin('add', [pluginId,'cordova-plugin-device-motion'], {'save':true, 'fetch':true}) + return cordova.plugin('add', [pluginId,'cordova-plugin-device-motion'], {'save':true, 'fetch':true}) .then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -210,7 +210,7 @@ describe('plugin end-to-end', function() { expect(pkgJson.dependencies['cordova-plugin-device-motion']).toBeDefined(); }).then(function() { // And now remove it with --save. - return cordova.raw.plugin('rm', [pluginId,'cordova-plugin-device-motion'], {'save':true, 'fetch':true}); + return cordova.plugin('rm', [pluginId,'cordova-plugin-device-motion'], {'save':true, 'fetch':true}); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -249,7 +249,7 @@ describe('plugin end-to-end', function() { // Config.xml has no platform or plugin or specs. expect(engines.length).toEqual(0); // Add ios without version. - return cordova.raw.platform('add', ['ios'], {'save':true, 'fetch':true}) + return cordova.platform('add', ['ios'], {'save':true, 'fetch':true}) .then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -273,7 +273,7 @@ describe('plugin end-to-end', function() { }); }).then(function() { // Add geolocation plugin with --save --fetch. - return cordova.raw.plugin('add', 'cordova-plugin-geolocation', {'save':true, 'fetch':true}); + return cordova.plugin('add', 'cordova-plugin-geolocation', {'save':true, 'fetch':true}); }).then(function() { var iosJson = cordova_util.requireNoCache(iosJsonPath); expect(iosJson.installed_plugins['cordova-plugin-geolocation']).toBeDefined(); @@ -311,7 +311,7 @@ describe('plugin end-to-end', function() { cordova_util.requireNoCache(pkgJsonPath); // Run cordova platform add local path --save --fetch. - return cordova.raw.platform('add', platformPath, {'save':true, 'fetch':true}) + return cordova.platform('add', platformPath, {'save':true, 'fetch':true}) .then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -335,7 +335,7 @@ describe('plugin end-to-end', function() { }); }).then(function() { // Run cordova plugin add local path --save --fetch. - return cordova.raw.plugin('add', pluginPath, {'save':true, 'fetch':true}); + return cordova.plugin('add', pluginPath, {'save':true, 'fetch':true}); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -389,14 +389,14 @@ describe('platform end-to-end with --save', function () { // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); }); } function fullPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBeGreaterThan(-1); @@ -411,7 +411,7 @@ describe('platform end-to-end with --save', function () { // Check there are no platforms yet. emptyPlatformList().then(function() { // Add the testing platform with --save. - return cordova.raw.platform('add', [helpers.testPlatform], {'save':true}); + return cordova.platform('add', [helpers.testPlatform], {'save':true}); }).then(function() { // Check the platform add was successful. pkgJson = require(pkgJsonPath); @@ -420,7 +420,7 @@ describe('platform end-to-end with --save', function () { }).then(fullPlatformList) // Platform should still be in platform ls. .then(function() { // And now remove it with --save. - return cordova.raw.platform('rm', [helpers.testPlatform], {'save':true}); + return cordova.platform('rm', [helpers.testPlatform], {'save':true}); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -438,7 +438,7 @@ describe('platform end-to-end with --save', function () { emptyPlatformList().then(function() { // Add the testing platform with --save. - return cordova.raw.platform('add', [helpers.testPlatform], {'save':true}); + return cordova.platform('add', [helpers.testPlatform], {'save':true}); }).then(function() { // Check the platform add was successful. pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -447,7 +447,7 @@ describe('platform end-to-end with --save', function () { }).then(fullPlatformList) // Platform should still be in platform ls. .then(function() { // And now remove it without --save. - return cordova.raw.platform('rm', [helpers.testPlatform]); + return cordova.platform('rm', [helpers.testPlatform]); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -467,7 +467,7 @@ describe('platform end-to-end with --save', function () { // Pkg.json "platforms" should be empty and helpers.testPlatform should not exist in pkg.json. expect(pkgJson.cordova).toBeUndefined(); // Add platform without --save. - cordova.raw.platform('add',[helpers.testPlatform]) + cordova.platform('add',[helpers.testPlatform]) .then(function() { // Check the platform add was successful, reload, skipping cache. pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -487,10 +487,10 @@ describe('platform end-to-end with --save', function () { expect(pkgJsonPath).toExist(); // Add a platform without --save. - cordova.raw.platform('add',platformNotToAdd) + cordova.platform('add',platformNotToAdd) .then(function() { // And now add another platform with --save. - return cordova.raw.platform('add', [helpers.testPlatform], {'save':true}); + return cordova.platform('add', [helpers.testPlatform], {'save':true}); }).then(function() { // Check the platform add was successful, reload, skipping cache. pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -527,7 +527,7 @@ describe('platform end-to-end with --save', function () { // Check there are no platforms yet. emptyPlatformList().then(function() { // Add the testing platform with --save and add specific version to android platform. - return cordova.raw.platform('add', ['android@6.1.0', 'browser@4.1.0'], {'save':true, 'fetch':true}); + return cordova.platform('add', ['android@6.1.0', 'browser@4.1.0'], {'save':true, 'fetch':true}); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -554,7 +554,7 @@ describe('platform end-to-end with --save', function () { }).then(fullPlatformList) // Platform should still be in platform ls. .then(function() { // And now remove it with --save. - return cordova.raw.platform('rm', ['android', 'browser'], {'save':true, 'fetch':true}); + return cordova.platform('rm', ['android', 'browser'], {'save':true, 'fetch':true}); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -606,7 +606,7 @@ describe('During add, if pkg.json has a platform/plugin spec, use that one.', fu // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -643,7 +643,7 @@ describe('During add, if pkg.json has a platform/plugin spec, use that one.', fu emptyPlatformList().then(function() { // Add ios with --save and --fetch. - return cordova.raw.platform('add', [iosPlatform], {'save':true , 'fetch':true}); + return cordova.platform('add', [iosPlatform], {'save':true , 'fetch':true}); }).then(function() { // Require platformsFolderPath, ios and spec should be in there. platformsJson = cordova_util.requireNoCache(platformsFolderPath); @@ -677,7 +677,7 @@ describe('During add, if pkg.json has a platform/plugin spec, use that one.', fu expect(semver.satisfies(platformsJson[iosPlatform], pkgJson.dependencies['cordova-ios'])).toEqual(true); }).then(function() { // Add splashscreen plugin with --save --fetch. - return cordova.raw.plugin('add', 'cordova-plugin-splashscreen', {'save':true, 'fetch':true}); + return cordova.plugin('add', 'cordova-plugin-splashscreen', {'save':true, 'fetch':true}); }).then(function() { pluginPkgJsonVersion = cordova_util.requireNoCache(pluginPkgJsonDir); // Check that pkg.json version and plugin pkg.json version "satisfy" each other. @@ -715,7 +715,7 @@ describe('During add, if config.xml has a platform/plugin spec and pkg.json does // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -744,10 +744,10 @@ describe('During add, if config.xml has a platform/plugin spec and pkg.json does // Pkg.json does not have platform or spec yet. Config.xml has ios and spec '~4.2.1'. // Remove for testing purposes so platform is not pre-installed. - cordova.raw.platform('rm', [iosPlatform], {'save':true}); + cordova.platform('rm', [iosPlatform], {'save':true}); emptyPlatformList().then(function() { // Add ios with --save and --fetch. - return cordova.raw.platform('add', [iosPlatform], {'save':true , 'fetch':true}); + return cordova.platform('add', [iosPlatform], {'save':true , 'fetch':true}); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -770,7 +770,7 @@ describe('During add, if config.xml has a platform/plugin spec and pkg.json does }); }).then(function() { // Add splashscreen with --save --fetch. - return cordova.raw.plugin('add', 'cordova-plugin-splashscreen', {'save':true, 'fetch':true}); + return cordova.plugin('add', 'cordova-plugin-splashscreen', {'save':true, 'fetch':true}); }).then(function() { var cfg3 = new ConfigParser(configXmlPath); // Check config.xml for plugins and spec. @@ -814,7 +814,7 @@ describe('During add, if add specifies a platform spec, use that one regardless // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); @@ -848,7 +848,7 @@ describe('During add, if add specifies a platform spec, use that one regardless expect(engines).toEqual([ { name: 'ios', spec: '~4.2.1' } ]); emptyPlatformList().then(function() { // Add ios with --save and --fetch. - return cordova.raw.platform('add', ['ios@4.3.0'], {'save':true , 'fetch':true}); + return cordova.platform('add', ['ios@4.3.0'], {'save':true , 'fetch':true}); }).then(function() { // Delete any previous caches of require(package.json). pkgJson = cordova_util.requireNoCache(pkgJsonPath); @@ -870,7 +870,7 @@ describe('During add, if add specifies a platform spec, use that one regardless expect(semver.satisfies(iosVersion.version, pkgJson.dependencies['cordova-ios'])).toEqual(true); }).then(function() { // Add splashscreen with --save --fetch. - return cordova.raw.plugin('add', 'cordova-plugin-splashscreen@4.0.0', {'save':true, 'fetch':true}); + return cordova.plugin('add', 'cordova-plugin-splashscreen@4.0.0', {'save':true, 'fetch':true}); }).then(function() { var cfg3 = new ConfigParser(configXmlPath); // Check config.xml for plugins and spec. @@ -927,7 +927,7 @@ describe('local path is added to config.xml without pkg.json', function () { var platformPath = path.join(testRunRoot,'spec-cordova/fixtures/platforms/cordova-browser'); // Run cordova platform add local path --save --fetch. - return cordova.raw.platform('add', platformPath, {'save':true, 'fetch':true}) + return cordova.platform('add', platformPath, {'save':true, 'fetch':true}) .then(function() { var cfg2 = new ConfigParser(configXmlPath); engines = cfg2.getEngines(); @@ -955,7 +955,7 @@ describe('local path is added to config.xml without pkg.json', function () { var configPlugins = cfg.getPluginIdList(); var configPlugin = cfg.getPlugin(configPlugins); // Run platform add with local path. - return cordova.raw.plugin('add', pluginPath, {'save':true, 'fetch':true}) + return cordova.plugin('add', pluginPath, {'save':true, 'fetch':true}) .then(function() { var cfg2 = new ConfigParser(configXmlPath); // Check config.xml for plugins and spec. diff --git a/spec-cordova/HooksRunner.spec.js b/spec-cordova/HooksRunner.spec.js index ef28fa811..86d389674 100644 --- a/spec-cordova/HooksRunner.spec.js +++ b/spec-cordova/HooksRunner.spec.js @@ -125,7 +125,7 @@ describe('HooksRunner', function() { // Add the testing platform. - cordova.raw.platform('add', [helpers.testPlatform]).fail(function (err) { + cordova.platform('add', [helpers.testPlatform]).fail(function (err) { expect(err).toBeUndefined(); done(); }).then(function () { @@ -142,7 +142,7 @@ describe('HooksRunner', function() { hookOptions = { projectRoot: project, cordova: options }; - cordova.raw.plugin('add', testPluginFixturePath).fail(function (err) { + cordova.plugin('add', testPluginFixturePath).fail(function (err) { expect(err && err.stack).toBeUndefined(); done(); }).then(function () { @@ -423,10 +423,10 @@ describe('HooksRunner', function() { var projectRoot = cordovaUtil.isCordova(); // remove plugin - cordova.raw.plugin('rm', 'com.plugin.withhooks').fail(function (err) { + cordova.plugin('rm', 'com.plugin.withhooks').fail(function (err) { expect(err.stack).toBeUndefined(); }).then(function () { - cordova.raw.plugin('add', testPluginFixturePath).fail(function (err) { + cordova.plugin('add', testPluginFixturePath).fail(function (err) { expect(err).toBeUndefined(); }).then(function () { testPluginInstalledPath = path.join(projectRoot, 'plugins', 'com.plugin.withhooks'); diff --git a/spec-cordova/build.spec.js b/spec-cordova/build.spec.js index d1fe02efc..b6e3ad193 100644 --- a/spec-cordova/build.spec.js +++ b/spec-cordova/build.spec.js @@ -34,13 +34,13 @@ describe('build command', function() { cd_project_root = spyOn(util, 'cdProjectRoot').and.returnValue(project_dir); list_platforms = spyOn(util, 'listPlatforms').and.returnValue(supported_platforms); fire = spyOn(HooksRunner.prototype, 'fire').and.returnValue(Q()); - prepare_spy = spyOn(cordova.raw, 'prepare').and.returnValue(Q()); - compile_spy = spyOn(cordova.raw, 'compile').and.returnValue(Q()); + prepare_spy = spyOn(cordova, 'prepare').and.returnValue(Q()); + compile_spy = spyOn(cordova, 'compile').and.returnValue(Q()); }); describe('failure', function() { it('Test 001 : should not run inside a project with no platforms', function(done) { list_platforms.and.returnValue([]); - cordova.raw.build() + cordova.build() .then(function() { expect('this call').toBe('fail'); }, function(err) { @@ -53,7 +53,7 @@ describe('build command', function() { it('Test 002 : should not run outside of a Cordova-based project', function(done) { is_cordova.and.returnValue(false); - cordova.raw.build() + cordova.build() .then(function() { expect('this call').toBe('fail'); }, function(err) { @@ -66,7 +66,7 @@ describe('build command', function() { describe('success', function() { it('Test 003 : should run inside a Cordova-based project with at least one added platform and call both prepare and compile', function(done) { - cordova.raw.build(['android','ios']).then(function() { + cordova.build(['android','ios']).then(function() { var opts = Object({ platforms: [ 'android', 'ios' ], verbose: false, options: Object({ }) }); expect(prepare_spy).toHaveBeenCalledWith(opts); expect(compile_spy).toHaveBeenCalledWith(opts); @@ -74,7 +74,7 @@ describe('build command', function() { }); }); it('Test 004 : should pass down options', function(done) { - cordova.raw.build({platforms: ['android'], options: {release: true}}).then(function() { + cordova.build({platforms: ['android'], options: {release: true}}).then(function() { var opts = {platforms: ['android'], options: {release: true}, verbose: false}; expect(prepare_spy).toHaveBeenCalledWith(opts); expect(compile_spy).toHaveBeenCalledWith(opts); @@ -84,11 +84,11 @@ describe('build command', function() { it('Test 005 : should convert options from old format and warn user about this', function (done) { function warnSpy(message) { - expect(message).toMatch('The format of cordova.raw.* methods "options" argument was changed'); + expect(message).toMatch('The format of cordova.* methods "options" argument was changed'); } cordova.on('warn', warnSpy); - cordova.raw.build({platforms:['android'], options:['--release', '--cdvBuildOpt=opt']}).then(function () { + cordova.build({platforms:['android'], options:['--release', '--cdvBuildOpt=opt']}).then(function () { var opts = {platforms: ['android'], options: jasmine.objectContaining({release: true, argv: ['--cdvBuildOpt=opt']}), verbose: false}; expect(prepare_spy).toHaveBeenCalledWith(opts); expect(compile_spy).toHaveBeenCalledWith(opts); @@ -101,13 +101,13 @@ describe('build command', function() { describe('hooks', function() { describe('when platforms are added', function() { it('Test 006 : should fire before hooks through the hooker module', function(done) { - cordova.raw.build(['android', 'ios']).then(function() { + cordova.build(['android', 'ios']).then(function() { expect(fire.calls.argsFor(0)).toEqual(['before_build', {verbose: false, platforms:['android', 'ios'] , options: {}}]); done(); }); }); it('Test 007 : should fire after hooks through the hooker module', function(done) { - cordova.raw.build('android').then(function() { + cordova.build('android').then(function() { expect(fire.calls.argsFor(1)).toEqual([ 'after_build', { platforms: [ 'android' ], verbose: false, options: {} } ]); done(); }); @@ -117,7 +117,7 @@ describe('build command', function() { describe('with no platforms added', function() { it('Test 008 : should not fire the hooker', function(done) { list_platforms.and.returnValue([]); - Q().then(cordova.raw.build).then(function() { + Q().then(cordova.build).then(function() { expect('this call').toBe('fail'); }, function(err) { expect(err.message).toEqual( diff --git a/spec-cordova/compile.spec.js b/spec-cordova/compile.spec.js index 4cd1c1d9a..4c9450892 100644 --- a/spec-cordova/compile.spec.js +++ b/spec-cordova/compile.spec.js @@ -42,7 +42,7 @@ describe('compile command', function() { it('Test 001 : should not run inside a Cordova-based project with no added platforms by calling util.listPlatforms', function(done) { list_platforms.and.returnValue([]); var success = jasmine.createSpy('success'); - cordova.raw.compile() + cordova.compile() .then(success, function(result) { expect(result instanceof Error).toBe(true); expect('' + result).toContain('No platforms added to this project. Please use `cordova platform add `.'); @@ -55,7 +55,7 @@ describe('compile command', function() { it('Test 002 : should not run outside of a Cordova-based project', function(done) { is_cordova.and.returnValue(false); var success = jasmine.createSpy('success'); - cordova.raw.compile() + cordova.compile() .then(success, function(result) { expect(result instanceof Error).toBe(true); }) @@ -68,7 +68,7 @@ describe('compile command', function() { describe('success', function() { it('Test 003 : should run inside a Cordova-based project with at least one added platform and shell out to build', function(done) { - cordova.raw.compile(['android','ios']).then(function() { + cordova.compile(['android','ios']).then(function() { expect(getPlatformApi).toHaveBeenCalledWith('android'); expect(getPlatformApi).toHaveBeenCalledWith('ios'); expect(platformApi.build).toHaveBeenCalled(); @@ -78,7 +78,7 @@ describe('compile command', function() { }); it('Test 004 : should pass down optional parameters', function (done) { - cordova.raw.compile({platforms:['blackberry10'], options:{release: true}}).then(function () { + cordova.compile({platforms:['blackberry10'], options:{release: true}}).then(function () { expect(getPlatformApi).toHaveBeenCalledWith('blackberry10'); expect(platformApi.build).toHaveBeenCalledWith({release: true}); }) @@ -88,11 +88,11 @@ describe('compile command', function() { it('Test 005 : should convert options from old format and warn user about this', function (done) { function warnSpy(message) { - expect(message).toMatch('The format of cordova.raw.* methods "options" argument was changed'); + expect(message).toMatch('The format of cordova.* methods "options" argument was changed'); } cordova.on('warn', warnSpy); - cordova.raw.compile({platforms:['blackberry10'], options:['--release']}).then(function () { + cordova.compile({platforms:['blackberry10'], options:['--release']}).then(function () { expect(getPlatformApi).toHaveBeenCalledWith('blackberry10'); expect(platformApi.build).toHaveBeenCalledWith({release: true, argv: []}); }) @@ -107,7 +107,7 @@ describe('compile command', function() { describe('hooks', function() { describe('when platforms are added', function() { it('Test 006 : should fire before hooks through the hooker module', function(done) { - cordova.raw.compile(['android', 'ios']).then(function() { + cordova.compile(['android', 'ios']).then(function() { expect(fire.calls.argsFor(0)).toEqual(['before_compile', {verbose: false, platforms:['android', 'ios'] , options: {}}]); done(); }) @@ -115,7 +115,7 @@ describe('compile command', function() { .fin(done); }); it('Test 007 : should fire after hooks through the hooker module', function(done) { - cordova.raw.compile('android').then(function() { + cordova.compile('android').then(function() { expect(fire.calls.argsFor(1)).toEqual(['after_compile', {verbose: false, platforms:['android'] , options: {}}]); done(); }) @@ -127,7 +127,7 @@ describe('compile command', function() { describe('with no platforms added', function() { it('Test 008 : should not fire the hooker', function(done) { list_platforms.and.returnValue([]); - Q().then(cordova.raw.compile).then(function() { + Q().then(cordova.compile).then(function() { expect('this call').toBe('fail'); }, function(err) { expect(fire).not.toHaveBeenCalled(); diff --git a/spec-cordova/create.spec.js b/spec-cordova/create.spec.js index d731ccb55..d9bc572e1 100644 --- a/spec-cordova/create.spec.js +++ b/spec-cordova/create.spec.js @@ -40,7 +40,7 @@ var configBasic = { describe('cordova create checks for valid-identifier', function() { it('Test 001 : should reject reserved words from start of id', function(done) { - cordova.raw.create('projectPath', 'int.bob', 'appName', {}, events) + cordova.create('projectPath', 'int.bob', 'appName', {}, events) .fail(function(err) { expect(err.message).toBe('App id contains a reserved word, or is not a valid identifier.'); }) @@ -48,7 +48,7 @@ describe('cordova create checks for valid-identifier', function() { }); it('Test 002 : should reject reserved words from end of id', function(done) { - cordova.raw.create('projectPath', 'bob.class', 'appName', {}, events) + cordova.create('projectPath', 'bob.class', 'appName', {}, events) .fail(function(err) { expect(err.message).toBe('App id contains a reserved word, or is not a valid identifier.'); }) @@ -99,7 +99,7 @@ describe('create basic test (see more in cordova-create)', function() { Q() .then(function() { // Create a real project - return cordova.raw.create(project, appId, appName, configBasic, events); + return cordova.create(project, appId, appName, configBasic, events); }) .then(checkProject) .fail(function(err) { @@ -109,4 +109,4 @@ describe('create basic test (see more in cordova-create)', function() { .fin(done); }, 60000); -}); \ No newline at end of file +}); diff --git a/spec-cordova/emulate.spec.js b/spec-cordova/emulate.spec.js index ecb6440ca..24a72bf6a 100644 --- a/spec-cordova/emulate.spec.js +++ b/spec-cordova/emulate.spec.js @@ -34,7 +34,7 @@ describe('emulate command', function() { cd_project_root = spyOn(util, 'cdProjectRoot').and.returnValue(project_dir); list_platforms = spyOn(util, 'listPlatforms').and.returnValue(supported_platforms); fire = spyOn(HooksRunner.prototype, 'fire').and.returnValue(Q()); - prepare_spy = spyOn(cordova.raw, 'prepare').and.returnValue(Q()); + prepare_spy = spyOn(cordova, 'prepare').and.returnValue(Q()); fail = function (err) { expect(err.stack).not.toBeDefined(); }; platformApi = { run: jasmine.createSpy('run').and.returnValue(Q()), @@ -47,7 +47,7 @@ describe('emulate command', function() { it('Test 001 : should not run inside a Cordova-based project with no added platforms by calling util.listPlatforms', function(done) { list_platforms.and.returnValue([]); var success = jasmine.createSpy('success'); - cordova.raw.compile() + cordova.compile() .then(success, function(result) { expect(result instanceof Error).toBe(true); expect('' + result).toContain('No platforms added to this project. Please use `cordova platform add `.'); @@ -60,7 +60,7 @@ describe('emulate command', function() { it('Test 002 : should not run outside of a Cordova-based project', function(done) { is_cordova.and.returnValue(false); var success = jasmine.createSpy('success'); - cordova.raw.compile() + cordova.compile() .then(success, function(result) { expect(result instanceof Error).toBe(true); }) @@ -73,7 +73,7 @@ describe('emulate command', function() { describe('success', function() { it('Test 003 : should run inside a Cordova-based project with at least one added platform and call prepare and shell out to the emulate script', function(done) { - cordova.raw.emulate(['android','ios']).then(function(err) { + cordova.emulate(['android','ios']).then(function(err) { expect(prepare_spy).toHaveBeenCalledWith(jasmine.objectContaining({platforms: ['android', 'ios']})); expect(getPlatformApi).toHaveBeenCalledWith('android'); expect(getPlatformApi).toHaveBeenCalledWith('ios'); @@ -84,7 +84,7 @@ describe('emulate command', function() { .fin(done); }); it('Test 004 : should pass down options', function(done) { - cordova.raw.emulate({platforms: ['ios'], options: {optionTastic: true }}).then(function(err) { + cordova.emulate({platforms: ['ios'], options: {optionTastic: true }}).then(function(err) { expect(prepare_spy).toHaveBeenCalledWith(jasmine.objectContaining({platforms: ['ios']})); expect(getPlatformApi).toHaveBeenCalledWith('ios'); expect(platformApi.build).toHaveBeenCalledWith({ device: false, emulator: true, optionTastic: true }); @@ -95,11 +95,11 @@ describe('emulate command', function() { }); it('Test 005 : should convert options from old format and warn user about this', function (done) { function warnSpy(message) { - expect(message).toMatch('The format of cordova.raw.* methods "options" argument was changed'); + expect(message).toMatch('The format of cordova.* methods "options" argument was changed'); } cordova.on('warn', warnSpy); - cordova.raw.emulate({platforms:['ios'], options:['--optionTastic']}).then(function () { + cordova.emulate({platforms:['ios'], options:['--optionTastic']}).then(function () { expect(prepare_spy).toHaveBeenCalledWith(jasmine.objectContaining({platforms: ['ios']})); expect(getPlatformApi).toHaveBeenCalledWith('ios'); expect(platformApi.run).toHaveBeenCalledWith(jasmine.objectContaining({emulator: true, argv: ['--optionTastic']})); @@ -123,7 +123,7 @@ describe('emulate command', function() { platformApi.build = originalBuildSpy; }); it('Test 006 : should leave parameters unchanged', function(done) { - cordova.raw.run({platforms: ['blackberry10'], options:{password: '1q1q'}}).then(function() { + cordova.run({platforms: ['blackberry10'], options:{password: '1q1q'}}).then(function() { expect(prepare_spy).toHaveBeenCalledWith({ platforms: [ 'blackberry10' ], options: { password: '1q1q', 'couldBeModified': 'insideBuild' }, verbose: false }); expect(platformApi.build).toHaveBeenCalledWith({password: '1q1q', 'couldBeModified': 'insideBuild'}); expect(platformApi.run).toHaveBeenCalledWith({password: '1q1q', nobuild: true}); @@ -134,7 +134,7 @@ describe('emulate command', function() { }); it('Test 007 : should call platform\'s build method', function (done) { - cordova.raw.emulate({platforms: ['blackberry10']}) + cordova.emulate({platforms: ['blackberry10']}) .then(function() { expect(prepare_spy).toHaveBeenCalled(); expect(platformApi.build).toHaveBeenCalledWith({device: false, emulator: true}); @@ -146,7 +146,7 @@ describe('emulate command', function() { }); it('Test 008 : should not call build if --nobuild option is passed', function (done) { - cordova.raw.emulate({platforms: ['blackberry10'], options: { nobuild: true }}) + cordova.emulate({platforms: ['blackberry10'], options: { nobuild: true }}) .then(function() { expect(prepare_spy).toHaveBeenCalled(); expect(platformApi.build).not.toHaveBeenCalled(); @@ -161,7 +161,7 @@ describe('emulate command', function() { describe('hooks', function() { describe('when platforms are added', function() { it('Test 009 : should fire before hooks through the hooker module', function(done) { - cordova.raw.emulate(['android', 'ios']).then(function() { + cordova.emulate(['android', 'ios']).then(function() { expect(fire).toHaveBeenCalledWith('before_emulate', jasmine.objectContaining({verbose: false, platforms:['android', 'ios'], options: jasmine.any(Object)})); }) @@ -169,7 +169,7 @@ describe('emulate command', function() { .fin(done); }); it('Test 010 : should fire after hooks through the hooker module', function(done) { - cordova.raw.emulate('android').then(function() { + cordova.emulate('android').then(function() { expect(fire).toHaveBeenCalledWith('after_emulate', jasmine.objectContaining({verbose: false, platforms:['android'], options: jasmine.any(Object)})); }) @@ -181,7 +181,7 @@ describe('emulate command', function() { describe('with no platforms added', function() { it('Test 011 : should not fire the hooker', function(done) { list_platforms.and.returnValue([]); - Q().then(cordova.raw.emulate).then(function() { + Q().then(cordova.emulate).then(function() { expect('this call').toBe('fail'); }, function(err) { expect(fire).not.toHaveBeenCalled(); @@ -190,4 +190,4 @@ describe('emulate command', function() { }); }); }); -}); \ No newline at end of file +}); diff --git a/spec-cordova/platform.spec.ios.js b/spec-cordova/platform.spec.ios.js index 6934a8fed..5a183bc27 100644 --- a/spec-cordova/platform.spec.ios.js +++ b/spec-cordova/platform.spec.ios.js @@ -47,13 +47,13 @@ describe('cocoapod plugin add and rm end-to-end', function () { it('Test 001 : installs and uninstalls plugin depending on new pod and existing pod', function(done) { - cordova.raw.create('hello4') + cordova.create('hello4') .then(function() { process.chdir(project); - return cordova.raw.platform('add', 'https://git-wip-us.apache.org/repos/asf/cordova-ios.git'); + return cordova.platform('add', 'https://git-wip-us.apache.org/repos/asf/cordova-ios.git'); }) .then(function() { - return cordova.raw.plugin('add', samplePlugin); + return cordova.plugin('add', samplePlugin); }) .then(function() { podfile = path.resolve('./platforms/ios/Podfile'); @@ -81,7 +81,7 @@ describe('cocoapod plugin add and rm end-to-end', function () { var podsJSONContent = require(podsJSON); expect(podsJSONContent[AFNetworking] !== null); - return cordova.raw.plugin('add', overlappingDependencyPlugin); + return cordova.plugin('add', overlappingDependencyPlugin); }) .then(function() { var podfileContent = fs.readFileSync(podfile, {'encoding' : 'utf8'}); @@ -99,7 +99,7 @@ describe('cocoapod plugin add and rm end-to-end', function () { //spec property should not be changed because of overlapping dependency expect(specPropertyOfAFNetworkingInPodsJSON).toEqual('~> 3.0'); - return cordova.raw.plugin('rm','sample-cocoapod-plugin-overlapping-dependency'); + return cordova.plugin('rm','sample-cocoapod-plugin-overlapping-dependency'); }) .then(function() { //expect only AFNetworking @@ -113,7 +113,7 @@ describe('cocoapod plugin add and rm end-to-end', function () { expect(podsJSONContent[AFNetworking]); expect(podsJSONContent[CWStatusBarNotification] === undefined); - return cordova.raw.plugin('rm', 'sample-cordova-plugin-cocoapod-dependent'); + return cordova.plugin('rm', 'sample-cordova-plugin-cocoapod-dependent'); }) .then(function() { //expect no pods @@ -134,4 +134,4 @@ describe('cocoapod plugin add and rm end-to-end', function () { }) .fin(done); }, 60000); -}); \ No newline at end of file +}); diff --git a/spec-cordova/platform.spec.js b/spec-cordova/platform.spec.js index c15b0f2ef..ae23178f6 100644 --- a/spec-cordova/platform.spec.js +++ b/spec-cordova/platform.spec.js @@ -77,14 +77,14 @@ describe('platform end-to-end', function () { // Factoring out some repeated checks. function emptyPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1); }); } function fullPlatformList() { - return cordova.raw.platform('list').then(function() { + return cordova.platform('list').then(function() { var installed = results.match(/Installed platforms:\n (.*)/); expect(installed).toBeDefined(); expect(installed[1].indexOf(helpers.testPlatform)).toBeGreaterThan(-1); @@ -103,7 +103,7 @@ describe('platform end-to-end', function () { // Check there are no platforms yet. emptyPlatformList().then(function() { // Add the testing platform. - return cordova.raw.platform('add', [helpers.testPlatform]); + return cordova.platform('add', [helpers.testPlatform]); }).then(function() { // Check the platform add was successful. expect(path.join(project, 'platforms', helpers.testPlatform)).toExist(); @@ -111,14 +111,14 @@ describe('platform end-to-end', function () { }).then(fullPlatformList) // Check for it in platform ls. .then(function() { // Try to update the platform. - return cordova.raw.platform('update', [helpers.testPlatform]); + return cordova.platform('update', [helpers.testPlatform]); }).then(function() { // Our fake update script in the exec mock above creates this dummy file. expect(path.join(project, 'platforms', helpers.testPlatform, 'updated')).toExist(); }).then(fullPlatformList) // Platform should still be in platform ls. .then(function() { // And now remove it. - return cordova.raw.platform('rm', [helpers.testPlatform]); + return cordova.platform('rm', [helpers.testPlatform]); }).then(function() { // It should be gone. expect(path.join(project, 'platforms', helpers.testPlatform)).not.toExist(); @@ -130,9 +130,9 @@ describe('platform end-to-end', function () { it('Test 002 : should install plugins correctly while adding platform', function(done) { - cordova.raw.plugin('add', path.join(pluginsDir, 'test')) + cordova.plugin('add', path.join(pluginsDir, 'test')) .then(function() { - return cordova.raw.platform('add', [helpers.testPlatform]); + return cordova.platform('add', [helpers.testPlatform]); }) .then(function() { // Check the platform add was successful. @@ -149,12 +149,12 @@ describe('platform end-to-end', function () { it('Test 003 : should call prepare after plugins were installed into platform', function(done) { var order = ''; var fail = jasmine.createSpy(fail); - spyOn(plugman.raw, 'install').and.callFake(function() { order += 'I'; }); - spyOn(cordova.raw, 'prepare').and.callFake(function() { order += 'P'; }); + spyOn(plugman, 'install').and.callFake(function() { order += 'I'; }); + spyOn(cordova, 'prepare').and.callFake(function() { order += 'P'; }); - cordova.raw.plugin('add', path.join(pluginsDir, 'test')) + cordova.plugin('add', path.join(pluginsDir, 'test')) .then(function() { - return cordova.raw.platform('add', [helpers.testPlatform]); + return cordova.platform('add', [helpers.testPlatform]); }) .fail(fail) .fin(function() { @@ -220,23 +220,23 @@ describe('platform add plugin rm end-to-end', function () { it('Test 006 : should remove dependency when removing parent plugin', function(done) { - cordova.raw.create('hello') + cordova.create('hello') .then(function() { process.chdir(project); - return cordova.raw.platform('add', 'browser@latest'); + return cordova.platform('add', 'browser@latest'); }) .then(function() { - return cordova.raw.plugin('add', 'cordova-plugin-media'); + return cordova.plugin('add', 'cordova-plugin-media'); }) .then(function() { expect(path.join(pluginsDir, 'cordova-plugin-media')).toExist(); expect(path.join(pluginsDir, 'cordova-plugin-file')).toExist(); - return cordova.raw.platform('add', 'android'); + return cordova.platform('add', 'android'); }) .then(function() { expect(path.join(pluginsDir, 'cordova-plugin-media')).toExist(); expect(path.join(pluginsDir, 'cordova-plugin-file')).toExist(); - return cordova.raw.plugin('rm', 'cordova-plugin-media'); + return cordova.plugin('rm', 'cordova-plugin-media'); }) .then(function() { expect(path.join(pluginsDir, 'cordova-plugin-media')).not.toExist(); @@ -268,27 +268,27 @@ describe('platform add and remove --fetch', function () { it('Test 007 : should add and remove platform from node_modules directory', function(done) { - cordova.raw.create('helloFetch') + cordova.create('helloFetch') .then(function() { process.chdir(project); - return cordova.raw.platform('add', 'browser', {'fetch':true}); + return cordova.platform('add', 'browser', {'fetch':true}); }) .then(function() { expect(path.join(nodeModulesDir, 'cordova-browser')).toExist(); expect(path.join(platformsDir, 'browser')).toExist(); - return cordova.raw.platform('add', 'android', {'fetch':true}); + return cordova.platform('add', 'android', {'fetch':true}); }) .then(function() { expect(path.join(nodeModulesDir, 'cordova-browser')).toExist(); expect(path.join(platformsDir, 'android')).toExist(); //Tests finish before this command finishes resolving - //return cordova.raw.platform('rm', 'ios', {'fetch':true}); + //return cordova.platform('rm', 'ios', {'fetch':true}); }) .then(function() { //expect(path.join(nodeModulesDir, 'cordova-ios')).not.toExist(); //expect(path.join(platformsDir, 'ios')).not.toExist(); //Tests finish before this command finishes resolving - //return cordova.raw.platform('rm', 'android', {'fetch':true}); + //return cordova.platform('rm', 'android', {'fetch':true}); }) .then(function() { //expect(path.join(nodeModulesDir, 'cordova-android')).not.toExist(); @@ -319,13 +319,13 @@ describe('plugin add and rm end-to-end --fetch', function () { it('Test 008 : should remove dependency when removing parent plugin', function(done) { - cordova.raw.create('hello3') + cordova.create('hello3') .then(function() { process.chdir(project); - return cordova.raw.platform('add', 'browser', {'fetch': true}); + return cordova.platform('add', 'browser', {'fetch': true}); }) .then(function() { - return cordova.raw.plugin('add', 'cordova-plugin-media', {'fetch': true}); + return cordova.plugin('add', 'cordova-plugin-media', {'fetch': true}); }) .then(function() { expect(path.join(pluginsDir, 'cordova-plugin-media')).toExist(); @@ -334,12 +334,12 @@ describe('plugin add and rm end-to-end --fetch', function () { expect(path.join(project, 'node_modules', 'cordova-plugin-media')).toExist(); expect(path.join(project, 'node_modules', 'cordova-plugin-file')).toExist(); expect(path.join(project, 'node_modules', 'cordova-plugin-compat')).toExist(); - return cordova.raw.platform('add', 'android', {'fetch':true}); + return cordova.platform('add', 'android', {'fetch':true}); }) .then(function() { expect(path.join(pluginsDir, 'cordova-plugin-media')).toExist(); expect(path.join(pluginsDir, 'cordova-plugin-file')).toExist(); - return cordova.raw.plugin('rm', 'cordova-plugin-media', {'fetch':true}); + return cordova.plugin('rm', 'cordova-plugin-media', {'fetch':true}); }) .then(function() { expect(path.join(pluginsDir, 'cordova-plugin-media')).not.toExist(); @@ -376,18 +376,18 @@ describe('non-core platform add and rm end-to-end --fetch', function () { it('Test 009 : should add and remove 3rd party platforms', function(done) { var installed; - cordova.raw.create('hello') + cordova.create('hello') .then(function() { process.chdir(project); //add cordova-android instead of android - return cordova.raw.platform('add', 'cordova-android', {'fetch': true}); + return cordova.platform('add', 'cordova-android', {'fetch': true}); }).then(function() { //3rd party platform from npm - return cordova.raw.platform('add', 'cordova-platform-test', {'fetch': true}); + return cordova.platform('add', 'cordova-platform-test', {'fetch': true}); }).then(function() { expect(path.join(project, 'platforms', 'android')).toExist(); expect(path.join(project, 'platforms', 'cordova-platform-test')).toExist(); - return cordova.raw.platform('ls'); + return cordova.platform('ls'); }) .then(function() { //use regex to grab installed platforms diff --git a/spec-cordova/platform1.spec.js b/spec-cordova/platform1.spec.js index c47aca1b8..134147dcc 100644 --- a/spec-cordova/platform1.spec.js +++ b/spec-cordova/platform1.spec.js @@ -5,7 +5,7 @@ var path = require('path'), platform = rewire('../src/cordova/platform'), cordova_util = require('../src/cordova/util'), prepare = require('../src/cordova/prepare'), - cordova = require('../src/cordova/cordova').raw, + cordova = require('../src/cordova/cordova'), platformMetadata = require('../src/cordova/platform_metadata'), platforms = require('../src/platforms/platforms'), lazy_load = require('../src/cordova/lazy_load'), diff --git a/spec-cordova/plugin.spec.js b/spec-cordova/plugin.spec.js index 1e4b60628..35fef7898 100644 --- a/spec-cordova/plugin.spec.js +++ b/spec-cordova/plugin.spec.js @@ -53,15 +53,15 @@ var results; // Runs: list, add, list function addPlugin(target, id, options) { // Check there are no plugins yet. - return cordova.raw.plugin('list').then(function() { + return cordova.plugin('list').then(function() { expect(results).toMatch(/No plugins added/gi); }).then(function() { // Add a fake plugin from fixtures. - return cordova.raw.plugin('add', target, options); + return cordova.plugin('add', target, options); }).then(function() { expect(path.join(project, 'plugins', id, 'plugin.xml')).toExist(); }).then(function() { - return cordova.raw.plugin('ls'); + return cordova.plugin('ls'); }).then(function() { expect(results).toContain(id); }); @@ -69,12 +69,12 @@ function addPlugin(target, id, options) { // Runs: remove, list function removePlugin(id) { - return cordova.raw.plugin('rm', id) + return cordova.plugin('rm', id) .then(function() { // The whole dir should be gone. expect(path.join(project, 'plugins', id)).not.toExist(); }).then(function() { - return cordova.raw.plugin('ls'); + return cordova.plugin('ls'); }).then(function() { expect(results).toMatch(/No plugins added/gi); }); @@ -91,7 +91,7 @@ var errorHandler = { // that use a searchpath. See loadLocalPlugins() in plugman/fetch.js for details. // The searchpath behavior gets tested in the plugman spec function mockPluginFetch(id, dir) { - spyOn(plugman.raw, 'fetch').and.callFake(function(target, pluginPath, fetchOptions) { + spyOn(plugman, 'fetch').and.callFake(function(target, pluginPath, fetchOptions) { var dest = path.join(project, 'plugins', id); var src = path.join(dir, 'plugin.xml'); @@ -200,7 +200,7 @@ describe('plugin end-to-end', function() { return addPlugin(npmInfoTestPlugin, npmInfoTestPlugin, {searchpath: pluginsDir}, done) .then(function() { expect(registry.info).not.toHaveBeenCalled(); - var fetchOptions = plugman.raw.fetch.calls.mostRecent().args[2]; + var fetchOptions = plugman.fetch.calls.mostRecent().args[2]; expect(fetchOptions.searchpath[0]).toExist(); }) .fail(function(err) { @@ -217,7 +217,7 @@ describe('plugin end-to-end', function() { .then(function() { expect(registry.info).not.toHaveBeenCalled(); - var fetchOptions = plugman.raw.fetch.calls.mostRecent().args[2]; + var fetchOptions = plugman.fetch.calls.mostRecent().args[2]; expect(fetchOptions.noregistry).toBeTruthy(); }) .fail(function(err) { @@ -246,7 +246,7 @@ describe('plugin end-to-end', function() { .then(function() { expect(registry.info).toHaveBeenCalled(); - var fetchTarget = plugman.raw.fetch.calls.mostRecent().args[0]; + var fetchTarget = plugman.fetch.calls.mostRecent().args[0]; expect(fetchTarget).toEqual(npmInfoTestPlugin + '@' + npmInfoTestPluginVersion); }) .fail(function(err) { @@ -267,7 +267,7 @@ describe('plugin end-to-end', function() { expect(registry.info).toHaveBeenCalledWith([scopedPackage]); - var fetchTarget = plugman.raw.fetch.calls.mostRecent().args[0]; + var fetchTarget = plugman.fetch.calls.mostRecent().args[0]; expect(fetchTarget).toEqual(scopedPackage); }) .fail(function(err) { @@ -285,7 +285,7 @@ describe('plugin end-to-end', function() { .then(function() { expect(registry.info).not.toHaveBeenCalled(); - var fetchTarget = plugman.raw.fetch.calls.mostRecent().args[0]; + var fetchTarget = plugman.fetch.calls.mostRecent().args[0]; expect(fetchTarget).toEqual(scopedPackage); }) .fail(function(err) { diff --git a/spec-cordova/project-metadata-apis.spec.js b/spec-cordova/project-metadata-apis.spec.js index ef2bfcaba..acffaf962 100644 --- a/spec-cordova/project-metadata-apis.spec.js +++ b/spec-cordova/project-metadata-apis.spec.js @@ -27,7 +27,7 @@ describe('retrieval of project metadata', function () { var androidVersion = '3.7.1'; var browserSrc = 'https://github.com/apache/cordova-browser.git'; - cordova.raw.projectMetadata.getPlatforms(projectRoot) + cordova.projectMetadata.getPlatforms(projectRoot) .then(function (platforms) { expect(platforms.length).toBe(2); @@ -57,7 +57,7 @@ describe('retrieval of project metadata', function () { var fileId = 'org.apache.cordova.file'; var fileSource = 'https://github.com/apache/cordova-plugin-file.git'; - cordova.raw.projectMetadata.getPlugins(projectRoot) + cordova.projectMetadata.getPlugins(projectRoot) .then(function (plugins) { expect(plugins.length).toBe(3); diff --git a/spec-cordova/run.spec.js b/spec-cordova/run.spec.js index 18e3fdde9..b1ab4fd56 100644 --- a/spec-cordova/run.spec.js +++ b/spec-cordova/run.spec.js @@ -34,7 +34,7 @@ describe('run command', function() { cd_project_root = spyOn(util, 'cdProjectRoot').and.returnValue(project_dir); list_platforms = spyOn(util, 'listPlatforms').and.returnValue(supported_platforms); fire = spyOn(HooksRunner.prototype, 'fire').and.returnValue(Q()); - prepare_spy = spyOn(cordova.raw, 'prepare').and.returnValue(Q()); + prepare_spy = spyOn(cordova, 'prepare').and.returnValue(Q()); platformApi = { run: jasmine.createSpy('run').and.returnValue(Q()), build: jasmine.createSpy('build').and.returnValue(Q()) @@ -44,7 +44,7 @@ describe('run command', function() { describe('failure', function() { it('Test 001 : should not run inside a Cordova-based project with no added platforms by calling util.listPlatforms', function(done) { list_platforms.and.returnValue([]); - Q().then(cordova.raw.run).then(function() { + Q().then(cordova.run).then(function() { expect('this call').toBe('fail'); }, function(err) { expect(err.message).toEqual('No platforms added to this project. Please use `cordova platform add `.'); @@ -54,7 +54,7 @@ describe('run command', function() { var msg = 'Dummy message about not being in a cordova dir.'; cd_project_root.and.throwError(new Error(msg)); is_cordova.and.returnValue(false); - Q().then(cordova.raw.run).then(function() { + Q().then(cordova.run).then(function() { expect('this call').toBe('fail'); }, function(err) { expect(err.message).toEqual(msg); @@ -64,14 +64,14 @@ describe('run command', function() { describe('success', function() { it('Test 003 : should call prepare before actually run platform ', function(done) { - cordova.raw.run(['android','ios']).then(function() { + cordova.run(['android','ios']).then(function() { expect(prepare_spy.calls.argsFor(0)).toEqual([ { platforms: [ 'android', 'ios' ], verbose: false, options: {} } ]); }, function(err) { expect(err).toBeUndefined(); }).fin(done); }); it('Test 004 : should get PlatformApi instance for each platform and call its\' run method', function(done) { - cordova.raw.run(['android','ios']).then(function() { + cordova.run(['android','ios']).then(function() { expect(getPlatformApi).toHaveBeenCalledWith('android'); expect(getPlatformApi).toHaveBeenCalledWith('ios'); expect(platformApi.build).toHaveBeenCalled(); @@ -81,7 +81,7 @@ describe('run command', function() { }).fin(done); }); it('Test 005 : should pass down parameters', function(done) { - cordova.raw.run({platforms: ['blackberry10'], options:{password: '1q1q'}}).then(function() { + cordova.run({platforms: ['blackberry10'], options:{password: '1q1q'}}).then(function() { expect(prepare_spy).toHaveBeenCalledWith({ platforms: [ 'blackberry10' ], options: { password: '1q1q' }, verbose: false }); expect(platformApi.build).toHaveBeenCalledWith({password: '1q1q'}); expect(platformApi.run).toHaveBeenCalledWith({password: '1q1q', nobuild: true}); @@ -91,11 +91,11 @@ describe('run command', function() { }); it('Test 006 : should convert parameters from old format and warn user about this', function (done) { function warnSpy(message) { - expect(message).toMatch('The format of cordova.raw.* methods "options" argument was changed'); + expect(message).toMatch('The format of cordova.* methods "options" argument was changed'); } cordova.on('warn', warnSpy); - cordova.raw.run({platforms: ['blackberry10'], options:['--password=1q1q']}).then(function() { + cordova.run({platforms: ['blackberry10'], options:['--password=1q1q']}).then(function() { expect(prepare_spy).toHaveBeenCalledWith({ platforms: [ 'blackberry10' ], options: jasmine.objectContaining({argv:['--password=1q1q']}), verbose: false }); expect(platformApi.run).toHaveBeenCalledWith(jasmine.objectContaining({argv:['--password=1q1q']})); @@ -109,7 +109,7 @@ describe('run command', function() { }); it('Test 007 : should call platform\'s build method', function (done) { - cordova.raw.run({platforms: ['blackberry10']}) + cordova.run({platforms: ['blackberry10']}) .then(function() { expect(prepare_spy).toHaveBeenCalled(); expect(platformApi.build).toHaveBeenCalledWith({}); @@ -121,7 +121,7 @@ describe('run command', function() { }); it('Test 008 : should not call build if --nobuild option is passed', function (done) { - cordova.raw.run({platforms: ['blackberry10'], options: { nobuild: true }}) + cordova.run({platforms: ['blackberry10'], options: { nobuild: true }}) .then(function() { expect(prepare_spy).toHaveBeenCalled(); expect(platformApi.build).not.toHaveBeenCalled(); @@ -145,7 +145,7 @@ describe('run command', function() { platformApi.build = originalBuildSpy; }); it('Test 009 : should leave parameters unchanged', function(done) { - cordova.raw.run({platforms: ['blackberry10'], options:{password: '1q1q'}}).then(function() { + cordova.run({platforms: ['blackberry10'], options:{password: '1q1q'}}).then(function() { expect(prepare_spy).toHaveBeenCalledWith({ platforms: [ 'blackberry10' ], options: { password: '1q1q', 'couldBeModified': 'insideBuild' }, verbose: false }); expect(platformApi.build).toHaveBeenCalledWith({password: '1q1q', 'couldBeModified': 'insideBuild'}); expect(platformApi.run).toHaveBeenCalledWith({password: '1q1q', nobuild: true}); @@ -159,14 +159,14 @@ describe('run command', function() { describe('hooks', function() { describe('when platforms are added', function() { it('Test 010 : should fire before hooks through the hooker module', function(done) { - cordova.raw.run(['android', 'ios']).then(function() { + cordova.run(['android', 'ios']).then(function() { expect(fire.calls.argsFor(0)).toEqual([ 'before_run', { platforms: [ 'android', 'ios' ], verbose: false, options: {} } ]); }, function(err) { expect(err).toBeUndefined(); }).fin(done); }); it('Test 011 : should fire after hooks through the hooker module', function(done) { - cordova.raw.run('android').then(function() { + cordova.run('android').then(function() { expect(fire.calls.argsFor(2)).toEqual([ 'after_run', { platforms: [ 'android' ], verbose: false, options: {} } ]); }, function(err) { expect(err).toBeUndefined(); @@ -177,7 +177,7 @@ describe('run command', function() { describe('with no platforms added', function() { it('Test 012 : should not fire the hooker', function(done) { list_platforms.and.returnValue([]); - Q().then(cordova.raw.run).then(function() { + Q().then(cordova.run).then(function() { expect('this call').toBe('fail'); }, function(err) { expect(fire).not.toHaveBeenCalled(); diff --git a/spec-cordova/save.spec.js b/spec-cordova/save.spec.js index 1af7d66f2..2a64208f6 100644 --- a/spec-cordova/save.spec.js +++ b/spec-cordova/save.spec.js @@ -104,7 +104,7 @@ describe('(save flag)', function () { //jasmine mocks spyOn(util, 'isCordova').and.returnValue(appPath); spyOn(util, 'cdProjectRoot').and.returnValue(appPath); - spyOn(cordova.raw, 'prepare').and.returnValue(Q()); + spyOn(cordova, 'prepare').and.returnValue(Q()); spyOn(prepare, 'preparePlatforms').and.returnValue(Q()); spyOn(PlatformApi, 'createPlatform').and.returnValue(Q()); @@ -114,7 +114,7 @@ describe('(save flag)', function () { revertInstallPluginsForNewPlatform = platform.__set__('installPluginsForNewPlatform', function () { return Q(); }); //creating test app - cordova.raw.create(appPath, undefined, undefined, {}, events).then(function () { + cordova.create(appPath, undefined, undefined, {}, events).then(function () { //removing unnecessary whitelist plugin from config helpers.removePlugin(appPath, 'cordova-plugin-whitelist'); done(); @@ -279,7 +279,7 @@ describe('(save flag)', function () { platform('add', platformLocalPathNewer) .then(function () { - return cordova.raw.platform('rm', platformName, { 'save': true }); + return cordova.platform('rm', platformName, { 'save': true }); }).then(function () { expect(helpers.getEngineSpec(appPath, platformName)).toBe(null); done(); @@ -295,7 +295,7 @@ describe('(save flag)', function () { platform('add', platformLocalPathNewer) .then(function () { - return cordova.raw.platform('rm', platformName, { 'save': true }); + return cordova.platform('rm', platformName, { 'save': true }); }).then(function () { expect(helpers.getEngineSpec(appPath, platformName)).toBe(null); done(); @@ -367,7 +367,7 @@ describe('(save flag)', function () { describe('plugin add --save', function () { it('Test 015 : spec.12 should save plugin to config', function (done) { - cordova.raw.plugin('add', pluginName, { 'save': true }) + cordova.plugin('add', pluginName, { 'save': true }) .then(function () { expect(helpers.getPluginSpec(appPath, pluginName)).not.toBe(null); done(); @@ -380,7 +380,7 @@ describe('(save flag)', function () { it('Test 016 : spec.13 should create new plugin tag in config with old plugin id when downgrading from plugin with new id', function (done) { helpers.setPluginSpec(appPath, pluginName, pluginOldVersion); - cordova.raw.plugin('add', pluginName, { 'save': true }) + cordova.plugin('add', pluginName, { 'save': true }) .then(function () { expect(helpers.getPluginSpec(appPath, pluginOldName)).toBe('~' + pluginOldVersion); done(); @@ -392,7 +392,7 @@ describe('(save flag)', function () { }, TIMEOUT); it('Test 017 : spec.14 should save variables', function (done) { - cordova.raw.plugin('add', variablePluginUrl, { + cordova.plugin('add', variablePluginUrl, { 'save': true, 'cli_variables': { 'APP_ID':'123456789', @@ -410,7 +410,7 @@ describe('(save flag)', function () { }, BIG_TIMEOUT); it('Test 018 : spec.14.1 should restore plugin with variables', function (done) { - cordova.raw.plugin('add', variablePluginUrl, { + cordova.plugin('add', variablePluginUrl, { 'save': true, 'cli_variables': { 'APP_ID':'123456789', @@ -419,10 +419,10 @@ describe('(save flag)', function () { }).then(function () { expect(helpers.getPluginVariable(appPath, variablePluginName, 'APP_ID')).toBe('123456789'); expect(helpers.getPluginVariable(appPath, variablePluginName, 'APP_NAME')).toBe('myApplication'); - return cordova.raw.plugin('rm', variablePluginName); + return cordova.plugin('rm', variablePluginName); }).then(function() { expect(path.join(appPath, 'plugins', variablePluginName)).not.toExist(); - return cordova.raw.plugin('add', variablePluginName); + return cordova.plugin('add', variablePluginName); }).then(function() { expect(path.join(appPath, 'plugins', variablePluginName)).toExist(); done(); @@ -434,7 +434,7 @@ describe('(save flag)', function () { }, BIG_TIMEOUT); it('Test 019 : spec.15 save git url as spec', function (done) { - cordova.raw.plugin('add', pluginGitUrl, { 'save': true }) + cordova.plugin('add', pluginGitUrl, { 'save': true }) .then(function () { expect(helpers.getPluginSpec(appPath, pluginName)).toBe(pluginGitUrl); done(); @@ -446,7 +446,7 @@ describe('(save flag)', function () { }, TIMEOUT); it('Test 020 : spec.16 should save local directory as spec', function (done) { - cordova.raw.plugin('add', localPluginPath, { 'save': true }) + cordova.plugin('add', localPluginPath, { 'save': true }) .then(function () { expect(helpers.getPluginSpec(appPath, localPluginName)).toBe(localPluginPath); done(); @@ -461,7 +461,7 @@ describe('(save flag)', function () { redirectRegistryCalls(pluginName + '@' + pluginVersion); var scopedPackage = '@test-scope/' + pluginName; - cordova.raw.plugin('add', scopedPackage + '@' + pluginVersion, { 'save': true }) + cordova.plugin('add', scopedPackage + '@' + pluginVersion, { 'save': true }) .then(function () { expect(registry.fetch).toHaveBeenCalledWith([scopedPackage + '@' + pluginVersion]); expect(helpers.getPluginSpec(appPath, pluginName)).toBe(scopedPackage + '@~' + pluginVersion); @@ -476,9 +476,9 @@ describe('(save flag)', function () { describe('plugin remove --save', function () { it('Test 022 : spec.17 should not add plugin to config', function (done) { - cordova.raw.plugin('add', pluginName) + cordova.plugin('add', pluginName) .then(function () { - return cordova.raw.plugin('rm', pluginName, { 'save': true }); + return cordova.plugin('rm', pluginName, { 'save': true }); }).then(function () { expect(helpers.getPluginSpec(appPath, pluginName)).toBe(null); done(); @@ -490,10 +490,10 @@ describe('(save flag)', function () { }, TIMEOUT); it('Test 023 : spec.18 should remove plugin from config', function (done) { - cordova.raw.plugin('add', pluginName) + cordova.plugin('add', pluginName) .then(function () { helpers.setPluginSpec(appPath, pluginName, pluginGitUrl); - return cordova.raw.plugin('rm', pluginName, { 'save': true }); + return cordova.plugin('rm', pluginName, { 'save': true }); }).then(function () { expect(helpers.getPluginSpec(appPath, pluginName)).toBe(null); done(); @@ -541,7 +541,7 @@ describe('(save flag)', function () { describe('plugin save', function () { it('Test 026: spec.21 should not update config when there are no plugins installed', function (done) { var configContent = helpers.getConfigContent(appPath); - cordova.raw.plugin('save') + cordova.plugin('save') .finally(function () { expect(helpers.getConfigContent(appPath)).toBe(configContent); done(); @@ -549,13 +549,13 @@ describe('(save flag)', function () { }, TIMEOUT); it('Test 027 : spec.22 should update config with plugins: one with version, one with local folder and another one vith git url', function (done) { - cordova.raw.plugin('add', pluginName + '@' + pluginVersion) + cordova.plugin('add', pluginName + '@' + pluginVersion) .then(function () { - return cordova.raw.plugin('add', gitPluginUrl); + return cordova.plugin('add', gitPluginUrl); }).then(function () { - return cordova.raw.plugin('add', localPluginPath); + return cordova.plugin('add', localPluginPath); }).then(function () { - return cordova.raw.plugin('save'); + return cordova.plugin('save'); }).then(function () { expect(helpers.getPluginSpec(appPath, pluginName)).toBe('~' + pluginVersion); expect(helpers.getPluginSpec(appPath, gitPluginName)).toBe(gitPluginUrl); @@ -572,9 +572,9 @@ describe('(save flag)', function () { // Fetching globalization rather than console to avoid conflicts with earlier tests redirectRegistryCalls(pluginName2 + '@' + pluginVersion2); var scopedPackage = '@test-scope/' + pluginName2; - cordova.raw.plugin('add', scopedPackage + '@' + pluginVersion2) + cordova.plugin('add', scopedPackage + '@' + pluginVersion2) .then(function () { - return cordova.raw.plugin('save'); + return cordova.plugin('save'); }).then(function () { expect(registry.fetch).toHaveBeenCalledWith([scopedPackage + '@' + pluginVersion2]); expect(helpers.getPluginSpec(appPath, pluginName2)).toBe(scopedPackage + '@~' + pluginVersion2); @@ -666,7 +666,7 @@ describe('(save flag)', function () { console.log(err.message); }); - cordova.raw.plugin('add', localPluginPath) + cordova.plugin('add', localPluginPath) .then(function() { helpers.setEngineSpec(appPath, platformName, platformLocalPathNewer); return prepare({ platforms: [ platformName ] }); diff --git a/spec-cordova/serve.spec.js b/spec-cordova/serve.spec.js index 0ec5e0242..f4a89cb59 100644 --- a/spec-cordova/serve.spec.js +++ b/spec-cordova/serve.spec.js @@ -84,14 +84,14 @@ xdescribe('serve command', function() { return function() { var server; runs(function() { - cordova.raw.create(tempDir).then(function () { + cordova.create(tempDir).then(function () { process.chdir(tempDir); process.env.PWD = tempDir; var plats = []; Object.getOwnPropertyNames(payloads).forEach(function(plat) { var d = Q.defer(); plats.push(d.promise); - cordova.raw.platform('add', plat, {spawnoutput:'ignore'}).then(function () { + cordova.platform('add', plat, {spawnoutput:'ignore'}).then(function () { var dir = path.join(tempDir, 'merges', plat); shell.mkdir('-p', dir); // Write testing HTML files into the directory. diff --git a/spec-cordova/util.spec.js b/spec-cordova/util.spec.js index 2df7a8de7..99a5e4aba 100644 --- a/spec-cordova/util.spec.js +++ b/spec-cordova/util.spec.js @@ -263,7 +263,7 @@ describe('util module', function() { events.on('warn', warnSpy); util.preProcessOptions({options: ['foo']}); expect(warnSpy).toHaveBeenCalled(); - expect(warnSpy.calls.argsFor(0)).toMatch('consider updating your cordova.raw.* method calls'); + expect(warnSpy.calls.argsFor(0)).toMatch('consider updating your cordova.* method calls'); events.removeListener('warn', warnSpy); }); @@ -307,4 +307,4 @@ describe('util module', function() { }); }); }); -}); \ No newline at end of file +}); diff --git a/spec-plugman/install.spec.js b/spec-plugman/install.spec.js index a265b70ed..388d27791 100644 --- a/spec-plugman/install.spec.js +++ b/spec-plugman/install.spec.js @@ -190,7 +190,7 @@ describe('install', function() { spyOn(shell, 'mkdir').and.returnValue(true); spyOn(platforms, 'copyFile').and.returnValue(true); - fetchSpy = spyOn(plugman.raw, 'fetch').and.returnValue( Q( plugins['com.cordova.engine'] ) ); + fetchSpy = spyOn(plugman, 'fetch').and.returnValue( Q( plugins['com.cordova.engine'] ) ); chmod = spyOn(fs, 'chmodSync').and.returnValue(true); spyOn(fs, 'writeFileSync').and.returnValue(true); cp = spyOn(shell, 'cp').and.returnValue(true); diff --git a/src/cordova/build.js b/src/cordova/build.js index fa3dca2eb..2293f9f41 100644 --- a/src/cordova/build.js +++ b/src/cordova/build.js @@ -31,9 +31,9 @@ module.exports = function build(options) { var hooksRunner = new HooksRunner(projectRoot); return hooksRunner.fire('before_build', options) .then(function() { - return require('./cordova').raw.prepare(options); + return require('./cordova').prepare(options); }).then(function() { - return require('./cordova').raw.compile(options); + return require('./cordova').compile(options); }).then(function() { return hooksRunner.fire('after_build', options); }); diff --git a/src/cordova/cordova.js b/src/cordova/cordova.js index f17cf69d1..5b091e3dc 100644 --- a/src/cordova/cordova.js +++ b/src/cordova/cordova.js @@ -19,6 +19,7 @@ var cordova_events = require('cordova-common').events; var cordova_util = require('./util'); +var aliasMethodToRawWithDeprecationNotice = require('../util/alias'); var off = function() { cordova_events.removeListener.apply(cordova_events, arguments); @@ -36,37 +37,41 @@ exports = module.exports = { }, off: off, removeListener:off, - removeAllListeners:function() { + removeAllListeners: function() { cordova_events.removeAllListeners.apply(cordova_events, arguments); }, emit: emit, trigger: emit, + findProjectRoot: function(opt_startDir) { + return cordova_util.isCordova(opt_startDir); + }, + prepare: require('./prepare'), + build: require('./build'), + config: require('./config'), + create: require('./create'), + emulate: require('./emulate'), + plugin: require('./plugin'), + plugins: require('./plugin'), + serve: require('./serve'), + platform: require('./platform'), + platforms: require('./platform'), + compile: require('./compile'), + run: require('./run'), + info: require('./info'), + targets: require('./targets'), + requirements: require('./requirements'), + projectMetadata: require('./project_metadata'), + clean: require('./clean'), raw: {} }; -exports.findProjectRoot = function(opt_startDir) { - return cordova_util.isCordova(opt_startDir); -}; +// Add the below top-level cordova methods/modules as "aliases" to the +// cordova.raw object. It will emit a warning deprecation notice about the +// impending removal of cordova.raw. +var modulesToAlias = ['prepare', 'build', 'config', 'emulate', 'plugin', + 'plugins', 'serve', 'platform', 'platforms', 'compile', 'run', 'info', + 'targets', 'requirements', 'projectMetadata', 'clean']; -// Each of these APIs takes a final parameter that is a callback function. -// The callback is passed the error object upon failure, or undefined upon success. -// To use a promise instead, call the APIs via cordova.raw.FOO(), which returns -// a promise instead of using a final-parameter-callback. -var addModuleProperty = cordova_util.addModuleProperty; -addModuleProperty(module, 'prepare', './prepare', true); -addModuleProperty(module, 'build', './build', true); -addModuleProperty(module, 'config', './config'); -addModuleProperty(module, 'create', './create', true); -addModuleProperty(module, 'emulate', './emulate', true); -addModuleProperty(module, 'plugin', './plugin', true); -addModuleProperty(module, 'plugins', './plugin', true); -addModuleProperty(module, 'serve', './serve'); -addModuleProperty(module, 'platform', './platform', true); -addModuleProperty(module, 'platforms', './platform', true); -addModuleProperty(module, 'compile', './compile', true); -addModuleProperty(module, 'run', './run', true); -addModuleProperty(module, 'info', './info', true); -addModuleProperty(module, 'targets', './targets', true); -addModuleProperty(module, 'requirements', './requirements', true); -addModuleProperty(module, 'projectMetadata', './project_metadata', true); -addModuleProperty(module, 'clean', './clean', true); +modulesToAlias.forEach(function(mod) { + aliasMethodToRawWithDeprecationNotice(mod, module.exports, 'cordova'); +}); diff --git a/src/cordova/emulate.js b/src/cordova/emulate.js index fdb0f1340..9f6505874 100644 --- a/src/cordova/emulate.js +++ b/src/cordova/emulate.js @@ -41,7 +41,7 @@ module.exports = function emulate(options) { .then(function() { if (!options.options.noprepare) { // Run a prepare first! - return require('./cordova').raw.prepare(options); + return require('./cordova').prepare(options); } }).then(function() { // Deploy in parallel (output gets intermixed though...) diff --git a/src/cordova/platform.js b/src/cordova/platform.js index 1ae0f2e29..3545b2910 100644 --- a/src/cordova/platform.js +++ b/src/cordova/platform.js @@ -215,7 +215,7 @@ function addHelper(cmd, hooksRunner, projectRoot, targets, opts) { fetch: opts.fetch || false, save: opts.save || false }; - return require('./cordova').raw.prepare(prepOpts); + return require('./cordova').prepare(prepOpts); } }) .then(function() { @@ -501,7 +501,7 @@ function check(hooksRunner, projectRoot) { /* oh well */ updateCordova.resolve(); }); - cordova.raw.create(scratch) + cordova.create(scratch) .then(function () { var h = new HooksRunner(scratch); // Acquire the version number of each platform we have installed, and output that too. @@ -749,7 +749,7 @@ function installPluginsForNewPlatform(platform, projectRoot, opts) { events.emit('verbose', 'Found variables for "' + plugin + '". Processing as cli_variables.'); options.cli_variables = variables; } - return plugman.raw.install(platform, output, plugin, plugins_dir, options); + return plugman.install(platform, output, plugin, plugins_dir, options); }); }, Q()); } diff --git a/src/cordova/plugin.js b/src/cordova/plugin.js index b7c955bc3..d631abc91 100644 --- a/src/cordova/plugin.js +++ b/src/cordova/plugin.js @@ -143,7 +143,7 @@ module.exports = function plugin(command, targets, opts) { .then(function(resolvedTarget) { target = resolvedTarget; events.emit('verbose', 'Calling plugman.fetch on plugin "' + target + '"'); - return plugman.raw.fetch(target, pluginPath, fetchOptions); + return plugman.fetch(target, pluginPath, fetchOptions); }) .then(function (directory) { return pluginInfoProvider.get(directory); @@ -195,7 +195,7 @@ module.exports = function plugin(command, targets, opts) { }; events.emit('verbose', 'Calling plugman.install on plugin "' + pluginInfo.dir + '" for platform "' + platform); - return plugman.raw.install(platform, platformRoot, path.basename(pluginInfo.dir), pluginPath, options) + return plugman.install(platform, platformRoot, path.basename(pluginInfo.dir), pluginPath, options) .then(function (didPrepare) { // If platform does not returned anything we'll need // to trigger a prepare after all plugins installed @@ -298,7 +298,7 @@ module.exports = function plugin(command, targets, opts) { var options = { force: opts.force || false }; - return plugman.raw.uninstall.uninstallPlatform(platform, platformRoot, target, pluginPath, options) + return plugman.uninstall.uninstallPlatform(platform, platformRoot, target, pluginPath, options) .then(function (didPrepare) { // If platform does not returned anything we'll need // to trigger a prepare after all plugins installed @@ -308,7 +308,7 @@ module.exports = function plugin(command, targets, opts) { }, Q()) .then(function() { // TODO: Should only uninstallPlugin when no platforms have it. - return plugman.raw.uninstall.uninstallPlugin(target, pluginPath, opts); + return plugman.uninstall.uninstallPlugin(target, pluginPath, opts); }).then(function(){ //remove plugin from config.xml if(saveToConfigXmlOn(config_json, opts)){ diff --git a/src/cordova/restore-util.js b/src/cordova/restore-util.js index e73e1f1d2..89fbada13 100644 --- a/src/cordova/restore-util.js +++ b/src/cordova/restore-util.js @@ -215,7 +215,7 @@ function installPlatformsFromConfigXML(platforms, opts) { // If the platform is already installed, no need to re-install it. if (!fs.existsSync(platformsInstalled) && (installAllPlatforms || platforms.indexOf(platformName) > -1)) { events.emit('log', 'Discovered platform \"' + target + '\" in config.xml or package.json. Adding it to the project'); - return cordova.raw.platform('add', target, opts); + return cordova.platform('add', target, opts); } } return Q(); diff --git a/src/cordova/run.js b/src/cordova/run.js index 34a76dad7..3d9979dfa 100644 --- a/src/cordova/run.js +++ b/src/cordova/run.js @@ -39,7 +39,7 @@ module.exports = function run(options) { .then(function() { if (!options.options.noprepare) { // Run a prepare first, then shell out to run - return require('./cordova').raw.prepare(options); + return require('./cordova').prepare(options); } }).then(function() { // Deploy in parallel (output gets intermixed though...) diff --git a/src/cordova/serve.js b/src/cordova/serve.js index 114edb5d0..2e1c04f6d 100644 --- a/src/cordova/serve.js +++ b/src/cordova/serve.js @@ -145,7 +145,7 @@ module.exports = function server(port, opts) { var hooksRunner = new HooksRunner(projectRoot); hooksRunner.fire('before_serve', opts).then(function () { // Run a prepare first! - return require('./cordova').raw.prepare([]); + return require('./cordova').prepare([]); }).then(function () { var server = serve(); diff --git a/src/cordova/util.js b/src/cordova/util.js index 8b62470e2..59c655d62 100644 --- a/src/cordova/util.js +++ b/src/cordova/util.js @@ -27,6 +27,7 @@ var fs = require('fs'), nopt = require('nopt'), Q = require('q'), semver = require('semver'), + aliasMethod = require('../util/alias'), platforms = require('../platforms/platforms'); // Global configuration paths @@ -55,14 +56,16 @@ Object.defineProperty(exports,'libDirectory', { } }); -addModuleProperty(module, 'plugin_parser', './plugin_parser'); - +exports.plugin_parser = require('./plugin_parser'); +exports.raw = {}; +// Alias the plugin_parser method to the raw:{} object above. +// Emits a deprecation warning if utilized, in prep for removal of `raw`. +aliasMethod('plugin_parser', exports, 'cordova_util'); exports.isCordova = isCordova; exports.cdProjectRoot = cdProjectRoot; exports.deleteSvnFolders = deleteSvnFolders; exports.listPlatforms = listPlatforms; exports.findPlugins = findPlugins; -exports.addModuleProperty = addModuleProperty; exports.appDir = appDir; exports.projectWww = projectWww; exports.projectConfig = projectConfig; @@ -318,9 +321,9 @@ function ensurePlatformOptionsCompatible (platformOptions) { if (!Array.isArray(opts)) return opts; - events.emit('warn', 'The format of cordova.raw.* methods "options" argument was changed in 5.4.0. ' + + events.emit('warn', 'The format of cordova.* methods "options" argument was changed in 5.4.0. ' + '"options.options" property now should be an object instead of an array of plain strings. Though the old format ' + - 'is still supported, consider updating your cordova.raw.* method calls to use new argument format.'); + 'is still supported, consider updating your cordova.* method calls to use new argument format.'); var knownArgs = [ 'debug', @@ -375,31 +378,6 @@ function isSymbolicLink(dir) { } } -// opt_wrap is a boolean: True means that a callback-based wrapper for the promise-based function -// should be created. -function addModuleProperty(module, symbol, modulePath, opt_wrap, opt_obj) { - var modewl = require(modulePath); - if (opt_wrap) { - module.exports[symbol] = function() { - if (arguments.length && typeof arguments[arguments.length - 1] === 'function') { - // If args exist and the last one is a function, it's the callback. - var args = Array.prototype.slice.call(arguments); - var cb = args.pop(); - modewl.apply(module.exports, args).done(function(result) { cb(undefined, result); }, cb); - } else { - modewl.apply(module.exports, arguments).done(null, function(err) { throw err; }); - } - }; - } else { - (opt_obj || module.exports)[symbol] = modewl; - } - - // Add the module.raw.foo as well. - if (module.exports.raw) { - module.exports.raw[symbol] = modewl; - } -} - /** * Returns the latest version of the specified module on npm that matches the specified version or range. * @param {string} module_name - npm module name. diff --git a/src/plugman/install.js b/src/plugman/install.js index fbc40aae1..d13d8fef7 100644 --- a/src/plugman/install.js +++ b/src/plugman/install.js @@ -98,7 +98,7 @@ function possiblyFetch(id, plugins_dir, options) { client: 'plugman' }); // TODO: without runtime require below, we have a circular dependency. - return require('./plugman').raw.fetch(id, plugins_dir, opts); + return require('./plugman').fetch(id, plugins_dir, opts); } function checkEngines(engines) { diff --git a/src/plugman/plugman.js b/src/plugman/plugman.js index 63102a457..f7c6bb697 100644 --- a/src/plugman/plugman.js +++ b/src/plugman/plugman.js @@ -20,51 +20,39 @@ // copyright (c) 2013 Andrew Lunny, Adobe Systems var events = require('cordova-common').events; +var aliasMethodToRawWithDeprecationNotice = require('../util/alias'); var Q = require('q'); -function addProperty(o, symbol, modulePath, doWrap) { - var modewl = require(modulePath); - - if (doWrap) { - o[symbol] = function() { - if (arguments.length && typeof arguments[arguments.length - 1] === 'function') { - // If args exist and the last one is a function, it's the callback. - var args = Array.prototype.slice.call(arguments); - var cb = args.pop(); - modewl.apply(o, args).done(function(result) {cb(undefined, result);}, cb); - } else { - modewl.apply(o, arguments).done(null, function(err){ throw err; }); - } - }; - } else { - // The top-level plugman.foo - o[symbol] = modewl; - } - - // The plugman.raw.foo - o.raw[symbol] = modewl; -} - var plugman = { on: events.on.bind(events), off: events.removeListener.bind(events), removeAllListeners: events.removeAllListeners.bind(events), emit: events.emit.bind(events), - raw: {} + install: require('./install'), + uninstall: require('./uninstall'), + fetch: require('./fetch'), + browserify: require('./browserify'), + help: require('./help'), + config: require('./config'), + owner: require('./owner'), + search: require('./search'), + info: require('./info'), + create: require('./create'), + platform: require('./platform_operation'), + createpackagejson: require('./createpackagejson'), + raw: {} }; -addProperty(plugman, 'install', './install', true); -addProperty(plugman, 'uninstall', './uninstall', true); -addProperty(plugman, 'fetch', './fetch', true); -addProperty(plugman, 'browserify', './browserify'); -addProperty(plugman, 'help', './help'); -addProperty(plugman, 'config', './config', true); -addProperty(plugman, 'owner', './owner', true); -addProperty(plugman, 'search', './search', true); -addProperty(plugman, 'info', './info', true); -addProperty(plugman, 'create', './create', true); -addProperty(plugman, 'platform', './platform_operation', true); -addProperty(plugman, 'createpackagejson', './createpackagejson', true); +// Add the below top-level plugman methods/modules as "aliases" to the +// plugman.raw object. It will emit a warning deprecation notice about the +// impending removal of plugman.raw. +var modulesToAlias = ['install', 'uninstall', 'fetch', 'browserify', 'help', + 'config', 'owner', 'search', 'info', 'create', 'platform', + 'createpackagejson']; + +modulesToAlias.forEach(function(mod) { + aliasMethodToRawWithDeprecationNotice(mod, plugman, 'plugman'); +}); plugman.commands = { 'config' : function(cli_opts) { @@ -106,7 +94,7 @@ plugman.commands = { var p = Q(); cli_opts.plugin.forEach(function (pluginSrc) { p = p.then(function () { - return plugman.raw.install(cli_opts.platform, cli_opts.project, pluginSrc, cli_opts.plugins_dir, opts); + return plugman.install(cli_opts.platform, cli_opts.project, pluginSrc, cli_opts.plugins_dir, opts); }); }); @@ -130,7 +118,7 @@ plugman.commands = { projectRoot: cli_opts.project }; p = p.then(function () { - return plugman.raw.uninstall(cli_opts.platform, cli_opts.project, pluginSrc, cli_opts.plugins_dir, opts); + return plugman.uninstall(cli_opts.platform, cli_opts.project, pluginSrc, cli_opts.plugins_dir, opts); }); }); diff --git a/src/util/alias.js b/src/util/alias.js new file mode 100644 index 000000000..4435c088f --- /dev/null +++ b/src/util/alias.js @@ -0,0 +1,27 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +var cordova_events = require('cordova-common').events; + +module.exports = function aliasMethodToRawWithDeprecationNotice(property, targetObj, component) { + targetObj.raw[property] = function() { + cordova_events.emit('warn', 'Use of `' + component + '.raw.*` methods is deprecated and `' + component + '.raw` will be removed in a future release. Please migrate to using the top-level `' + component + '.*` methods instead.'); + return targetObj[property].apply(targetObj, arguments); + }; +};