cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [10/17] cordova-lib git commit: Keep `raw` object around, alias to module directly, but drop in a deprecation warning if it is used. Update all code and specs to stop using the `raw` object.
Date Fri, 09 Jun 2017 23:26:38 GMT
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/spec-cordova/plugin.spec.js
----------------------------------------------------------------------
diff --git a/spec-cordova/plugin.spec.js b/spec-cordova/plugin.spec.js
index 1e4b606..35fef78 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) {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/spec-cordova/project-metadata-apis.spec.js
----------------------------------------------------------------------
diff --git a/spec-cordova/project-metadata-apis.spec.js b/spec-cordova/project-metadata-apis.spec.js
index ef2bfca..acffaf9 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);
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/spec-cordova/run.spec.js
----------------------------------------------------------------------
diff --git a/spec-cordova/run.spec.js b/spec-cordova/run.spec.js
index 18e3fdd..b1ab4fd 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 <platform>`.');
@@ -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();

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/spec-cordova/save.spec.js
----------------------------------------------------------------------
diff --git a/spec-cordova/save.spec.js b/spec-cordova/save.spec.js
index 1af7d66..2a64208 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 ] });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/spec-cordova/serve.spec.js
----------------------------------------------------------------------
diff --git a/spec-cordova/serve.spec.js b/spec-cordova/serve.spec.js
index 0ec5e02..f4a89cb 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.

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/spec-cordova/util.spec.js
----------------------------------------------------------------------
diff --git a/spec-cordova/util.spec.js b/spec-cordova/util.spec.js
index 2df7a8d..99a5e4a 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
+});

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/spec-plugman/install.spec.js
----------------------------------------------------------------------
diff --git a/spec-plugman/install.spec.js b/spec-plugman/install.spec.js
index a265b70..388d277 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);

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/src/cordova/build.js
----------------------------------------------------------------------
diff --git a/src/cordova/build.js b/src/cordova/build.js
index fa3dca2..2293f9f 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);
         });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/src/cordova/cordova.js
----------------------------------------------------------------------
diff --git a/src/cordova/cordova.js b/src/cordova/cordova.js
index f17cf69..c180f7d 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');
+});

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/src/cordova/emulate.js
----------------------------------------------------------------------
diff --git a/src/cordova/emulate.js b/src/cordova/emulate.js
index fdb0f13..9f65058 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...)

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/src/cordova/platform.js b/src/cordova/platform.js
index 1ae0f2e..3545b29 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());
 }

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/src/cordova/plugin.js b/src/cordova/plugin.js
index b7c955b..d631abc 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)){

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/src/cordova/restore-util.js
----------------------------------------------------------------------
diff --git a/src/cordova/restore-util.js b/src/cordova/restore-util.js
index e73e1f1..89fbada 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();

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/src/cordova/run.js
----------------------------------------------------------------------
diff --git a/src/cordova/run.js b/src/cordova/run.js
index 34a76da..3d9979d 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...)

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/src/cordova/serve.js
----------------------------------------------------------------------
diff --git a/src/cordova/serve.js b/src/cordova/serve.js
index 114edb5..2e1c04f 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();
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/src/cordova/util.js
----------------------------------------------------------------------
diff --git a/src/cordova/util.js b/src/cordova/util.js
index 8b62470..cf6845d 100644
--- a/src/cordova/util.js
+++ b/src/cordova/util.js
@@ -318,9 +318,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 +375,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.

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/src/plugman/install.js
----------------------------------------------------------------------
diff --git a/src/plugman/install.js b/src/plugman/install.js
index fbc40aa..d13d8fe 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) {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/src/plugman/plugman.js
----------------------------------------------------------------------
diff --git a/src/plugman/plugman.js b/src/plugman/plugman.js
index 63102a4..3b65b73 100644
--- a/src/plugman/plugman.js
+++ b/src/plugman/plugman.js
@@ -22,49 +22,36 @@
 var events = require('cordova-common').events;
 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, module.exports, 'plugman');
+});
 
 plugman.commands =  {
     'config'   : function(cli_opts) {
@@ -106,7 +93,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 +117,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);
             });
         });
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ca7a068e/src/util/alias.js
----------------------------------------------------------------------
diff --git a/src/util/alias.js b/src/util/alias.js
new file mode 100644
index 0000000..d44cb0b
--- /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.');
+        targetObj[property].apply(targetObj, arguments);
+    };
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message