[ 
https://issues.apache.org/jira/browse/CB-13057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16290440#comment-16290440
 ] 

ASF GitHub Bot commented on CB-13057:
-------------------------------------

stevengill closed pull request #586: CB-13057 : Remove cordova platform save 
command
URL: https://github.com/apache/cordova-lib/pull/586
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/integration-tests/pkgJson-restore.spec.js 
b/integration-tests/pkgJson-restore.spec.js
index 04253e035..4e3e19048 100644
--- a/integration-tests/pkgJson-restore.spec.js
+++ b/integration-tests/pkgJson-restore.spec.js
@@ -140,8 +140,6 @@ describe('tests platform/spec restore with --save', 
function () {
         var cwd = process.cwd();
         var pkgJsonPath = path.join(cwd, 'package.json');
         var pkgJson;
-        var platformsFolderPath = path.join(cwd, 'platforms/platforms.json');
-        var platformsJson;
         var configXmlPath = path.join(cwd, 'config.xml');
         var bPlatform = 'browser';
         var engines;
@@ -167,9 +165,6 @@ describe('tests platform/spec restore with --save', 
function () {
             pkgJson = cordova_util.requireNoCache(pkgJsonPath);
             expect(pkgJson.cordova.platforms.indexOf('browser')).toBeDefined();
             
expect(pkgJson.dependencies['cordova-browser']).toEqual('git+https://github.com/apache/cordova-browser.git');
-            // Check that platform was added to platforms list successfully.
-            platformsJson = cordova_util.requireNoCache(platformsFolderPath);
-            expect(platformsJson[bPlatform]).toBeDefined();
         }).then(function () {
             // Remove platform without --save.
             return cordovaPlatform('rm', bPlatform, {'fetch': true});
@@ -178,9 +173,6 @@ describe('tests platform/spec restore with --save', 
function () {
             pkgJson = cordova_util.requireNoCache(pkgJsonPath);
             expect(pkgJson.cordova.platforms.indexOf('browser')).toBeDefined();
             
expect(pkgJson.dependencies['cordova-browser']).toEqual('git+https://github.com/apache/cordova-browser.git');
-            // Platform in platforms.json should not be there.
-            platformsJson = cordova_util.requireNoCache(platformsFolderPath);
-            expect(platformsJson[bPlatform]).toBeUndefined();
         }).then(function () {
             // Run cordova prepare
             return prepare({'fetch': true});
@@ -200,9 +192,6 @@ describe('tests platform/spec restore with --save', 
function () {
             pkgJson = cordova_util.requireNoCache(pkgJsonPath);
             expect(pkgJson.cordova.platforms.indexOf('browser')).toBeDefined();
             
expect(pkgJson.dependencies['cordova-browser']).toEqual('git+https://github.com/apache/cordova-browser.git');
-            // Check that platform was restored to platform.json list 
successfully.
-            platformsJson = cordova_util.requireNoCache(platformsFolderPath);
-            expect(platformsJson[bPlatform]).toBeDefined();
         }).fail(function (err) {
             expect(err).toBeUndefined();
         }).fin(done);
@@ -327,9 +316,7 @@ describe('tests platform/spec restore with --save', 
function () {
         var cwd = process.cwd();
         var pkgJsonPath = path.join(cwd, 'package.json');
         var pkgJson;
-        var platformsFolderPath = path.join(cwd, 'platforms/platforms.json');
         var secondPlatformAdded = 'ios';
-        var platformsJson;
 
         emptyPlatformList().then(function () {
             // Add 'browser' platform to project without --save
@@ -340,14 +327,10 @@ describe('tests platform/spec restore with --save', 
function () {
         }).then(function () {
             // Delete any previous caches of require(package.json) and 
(platformsJson)
             pkgJson = cordova_util.requireNoCache(pkgJsonPath);
-            platformsJson = cordova_util.requireNoCache(platformsFolderPath);
             // Check the platform add of only helpers.testPlatform was 
successful in package.json.
             expect(pkgJson.cordova.platforms).toBeDefined();
             
expect(pkgJson.cordova.platforms.indexOf('browser')).toBeGreaterThan(-1);
             
expect(pkgJson.cordova.platforms.indexOf(secondPlatformAdded)).toEqual(-1);
-            // Expect both platforms to be installed platform list in 
platforms.json
-            expect(platformsJson['browser']).toBeDefined();
-            expect(platformsJson[secondPlatformAdded]).toBeDefined();
         }).then(fullPlatformList) // Platforms should still be in platform ls.
             .then(function () {
                 // Remove helpers.testPlatform without --save.
@@ -357,23 +340,12 @@ describe('tests platform/spec restore with --save', 
function () {
                 return cordovaPlatform('rm', secondPlatformAdded);
             }).then(function () {
                 // Delete any previous caches of require(pkgJson) and 
(platformsJson)
-                platformsJson = 
cordova_util.requireNoCache(platformsFolderPath);
                 pkgJson = cordova_util.requireNoCache(pkgJsonPath);
                 // Check that the platform that was added with --save is still 
in package.json.
                 
expect(pkgJson.cordova.platforms.indexOf('browser')).toBeGreaterThan(-1);
-                // Check that both platforms were removed from the 
platforms.json.
-                expect(platformsJson[secondPlatformAdded]).toBeUndefined();
-                expect(platformsJson['browser']).toBeUndefined();
             }).then(function () {
                 // Run cordova prepare
                 return prepare({'fetch': true});
-            }).then(function () {
-                // Delete any previous caches of platformsJson
-                platformsJson = 
cordova_util.requireNoCache(platformsFolderPath);
-                // Expect "helpers.testPlatform" to be in the installed 
platforms list.
-                expect(platformsJson['browser']).toBeDefined();
-                // Expect that 'browser' will not be in platforms.json and has 
not been restored.
-                expect(platformsJson[secondPlatformAdded]).toBeUndefined();
             }).fail(function (err) {
                 expect(err).toBeUndefined();
             }).fin(done);
@@ -1278,9 +1250,7 @@ describe('platforms and plugins should be restored with 
config.xml even without
         });
         var configEngArray = engNames.slice();
         var configPlugins = cfg1.getPluginIdList();
-        var platformsFolderPath1 = path.join(cwd, 'platforms/platforms.json');
         var pluginsFolderPath16 = path.join(cwd, 'plugins');
-        var platformsJson;
         var androidPlatform = 'android';
         var browserPlatform = 'windows';
 
@@ -1303,12 +1273,6 @@ describe('platforms and plugins should be restored with 
config.xml even without
             });
             configEngArray = engNames.slice();
             expect(configEngArray.length === 2);
-            // Delete previouc caches of (pkg.json).
-            platformsJson = cordova_util.requireNoCache(platformsFolderPath1);
-            // Browser should be installed
-            expect(platformsJson).toBeDefined();
-            expect(platformsJson[androidPlatform]).not.toBeDefined();
-            expect(platformsJson[browserPlatform]).toBeDefined();
             // Package.json should be auto-created.
             expect(path.join(cwd, 'package.json')).toExist();
             var pkgJsonPath = path.join(cwd, 'package.json');
@@ -1321,12 +1285,6 @@ describe('platforms and plugins should be restored with 
config.xml even without
             expect(pkgJson.displayName).toEqual(cfg3.name());
             // Remove android without --save.
             return cordovaPlatform('rm', [browserPlatform]);
-        }).then(function () {
-            // Android should not be in the installed list (only browser).
-            platformsJson = cordova_util.requireNoCache(platformsFolderPath1);
-            expect(platformsJson).toBeDefined();
-            expect(platformsJson[browserPlatform]).toBeUndefined();
-            expect(platformsJson[androidPlatform]).not.toBeDefined();
         }).then(function () {
             // Run cordova prepare.
             return prepare({'fetch': true});
@@ -1341,10 +1299,6 @@ describe('platforms and plugins should be restored with 
config.xml even without
             
expect(configEngArray.indexOf(androidPlatform)).toBeGreaterThan(-1);
             
expect(configEngArray.indexOf(browserPlatform)).toBeGreaterThan(-1);
             expect(configEngArray.length === 2);
-            // Expect that android and browser were restored.
-            platformsJson = cordova_util.requireNoCache(platformsFolderPath1);
-            expect(platformsJson[androidPlatform]).toBeDefined();
-            expect(platformsJson[browserPlatform]).toBeDefined();
         }).then(function () {
             // Check plugins.
             var cfg5 = new ConfigParser(configXmlPath);
@@ -1435,42 +1389,27 @@ describe('tests platform/spec restore with --save', 
function () {
         var pkgJsonPath = path.join(cwd, 'package.json');
         cordova_util.requireNoCache(pkgJsonPath);
         var pkgJson;
-        var platformsFolderPath = path.join(cwd, 'platforms/platforms.json');
-        var platformsJson;
 
         emptyPlatformList().then(function () {
             // Add the testing platform with --save.
-            return cordovaPlatform('add', 'browser', {'save': true, 'fetch': 
true});
+            return cordovaPlatform('add', 'android', {'save': true, 'fetch': 
true});
         }).then(function () {
             pkgJson = cordova_util.requireNoCache(pkgJsonPath);
-            // Require platformsFolderPath
-            platformsJson = cordova_util.requireNoCache(platformsFolderPath);
             // Check the platform add was successful in package.json.
             expect(pkgJson.cordova.platforms).toBeDefined();
-            
expect(pkgJson.cordova.platforms.indexOf('browser')).toBeGreaterThan(-1);
-            // Expect that "helpers.testPlatform" in the installed platform 
list in platforms.json
-            expect(platformsJson).toBeDefined();
-            expect(platformsJson['browser']).toBeDefined();
-        }).then() // Platform should still be in platform ls.
+            
expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toBeGreaterThan(-1);
+        }).then(fullPlatformList) // Platform should still be in platform ls.
             .then(function () {
                 // And now remove helpers.testPlatform without --save.
                 return cordovaPlatform('rm', ['browser']);
             }).then(function () {
                 // Delete any previous caches of require(package.json) and 
(platforms.json)
-                platformsJson = 
cordova_util.requireNoCache(platformsFolderPath);
                 pkgJson = cordova_util.requireNoCache(pkgJsonPath);
                 // Check that the platform removed without --save is still in 
platforms key.
-                
expect(pkgJson.cordova.platforms.indexOf('browser')).toBeGreaterThan(-1);
-                // Check that the platform was removed from the platforms.json
-                expect(platformsJson['browser']).toBeUndefined();
+                
expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toBeGreaterThan(-1);
             }).then(function () {
                 // Run cordova prepare.
                 return prepare({'fetch': true});
-            }).then(function () {
-                // Delete any previous caches of platforms.json.
-                platformsJson = 
cordova_util.requireNoCache(platformsFolderPath);
-                // Expect "helpers.testPlatform" to be in the installed 
platforms list in platforms.json.
-                expect(platformsJson['browser']).toBeDefined();
             }).fail(function (err) {
                 expect(err).toBeUndefined();
             }).fin(done);
@@ -1486,9 +1425,7 @@ describe('tests platform/spec restore with --save', 
function () {
         var cwd = process.cwd();
         var pkgJsonPath = path.join(cwd, 'package.json');
         var pkgJson;
-        var platformsFolderPath = path.join(cwd, 'platforms/platforms.json');
-        var platformsJson;
-        var secondPlatformAdded = 'windows';
+        var secondPlatformAdded = 'browser';
 
         emptyPlatformList().then(function () {
             // Add the testing platform with --save.
@@ -1499,15 +1436,10 @@ describe('tests platform/spec restore with --save', 
function () {
         }).then(function () {
             // Delete any previous caches of require(package.json) and 
(platforms.json).
             pkgJson = cordova_util.requireNoCache(pkgJsonPath);
-            platformsJson = cordova_util.requireNoCache(platformsFolderPath);
             // Check the platform add of both platforms (to pkg.Json) was 
successful.
             expect(pkgJson.cordova.platforms).toBeDefined();
             
expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toEqual(0);
             
expect(pkgJson.cordova.platforms.indexOf(secondPlatformAdded)).toEqual(1);
-            // Expect that "helpers.testPlatform" in the installed platform 
list in platforms.json.
-            expect(platformsJson).toBeDefined();
-            expect(platformsJson[helpers.testPlatform]).toBeDefined();
-            expect(platformsJson[secondPlatformAdded]).toBeDefined();
         }).then(fullPlatformList) // Platform should still be in platform ls.
             .then(function () {
                 // Remove helpers.testPlatform with --save.
@@ -1516,25 +1448,14 @@ describe('tests platform/spec restore with --save', 
function () {
                 // Remove secondPlatformAdded without --save.
                 return cordovaPlatform('rm', secondPlatformAdded);
             }).then(function () {
-                // Delete any previous caches of require(package.json) and 
(platformsJson).
-                platformsJson = 
cordova_util.requireNoCache(platformsFolderPath);
+                // Delete any previous caches of require(package.json)
                 pkgJson = cordova_util.requireNoCache(pkgJsonPath);
                 // Check that ONLY the platform removed without --save is 
still in (pkg.json) platforms key.
                 
expect(pkgJson.cordova.platforms.indexOf(secondPlatformAdded)).toEqual(0);
                 
expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toEqual(-1);
-                // Check that both platforms were removed from the 
platforms.json list.
-                expect(platformsJson[helpers.testPlatform]).toBeUndefined();
-                expect(platformsJson[secondPlatformAdded]).toBeUndefined();
             }).then(function () {
                 // Run cordova prepare.
                 return prepare({'fetch': true});
-            }).then(function () {
-                // Delete any previous caches of platformsJson.
-                platformsJson = 
cordova_util.requireNoCache(platformsFolderPath);
-                // Expect "helpers.testPlatform" to be in the installed 
platforms list in platforms.json
-                expect(platformsJson[helpers.testPlatform]).toBeUndefined();
-                // Expect 'browser' not to be in platforms.json and has not 
been restored.
-                expect(platformsJson[secondPlatformAdded]).toBeDefined();
             }).fail(function (err) {
                 expect(err).toBeUndefined();
             }).fin(done);
diff --git a/integration-tests/pkgJson.spec.js 
b/integration-tests/pkgJson.spec.js
index 8cdd7ead2..79b32f6f7 100644
--- a/integration-tests/pkgJson.spec.js
+++ b/integration-tests/pkgJson.spec.js
@@ -621,7 +621,6 @@ describe('During add, if pkg.json has a platform/plugin 
spec, use that one.', fu
         var iosVersion;
         var cwd = process.cwd();
         var iosDirectory = path.join(cwd, 'platforms/ios/cordova/version');
-        var platformsFolderPath = path.join(cwd, 'platforms/platforms.json');
         var configXmlPath = path.join(cwd, 'config.xml');
         var pkgJsonPath = path.join(cwd, 'package.json');
         var pkgJson = cordova_util.requireNoCache(pkgJsonPath);
@@ -629,7 +628,6 @@ describe('During add, if pkg.json has a platform/plugin 
spec, use that one.', fu
         var engines = cfg.getEngines();
         var engNames;
         var engSpec; // eslint-disable-line no-unused-vars
-        var platformsJson;
         var configPlugins = cfg.getPluginIdList();
         var pluginPkgJsonDir = path.join(cwd, 
'plugins/cordova-plugin-splashscreen/package.json');
         var pluginPkgJsonVersion;
@@ -645,8 +643,6 @@ describe('During add, if pkg.json has a platform/plugin 
spec, use that one.', fu
             // Add ios with --save and --fetch.
             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);
             // Delete any previous caches of require(package.json).
             // ios has been added.
             pkgJson = cordova_util.requireNoCache(pkgJsonPath);
@@ -666,15 +662,11 @@ describe('During add, if pkg.json has a platform/plugin 
spec, use that one.', fu
                 // Check that config and ios/cordova/version versions "satify" 
each other.
                 iosVersion = cordova_util.requireNoCache(iosDirectory);
                 expect(semver.satisfies(iosVersion.version, 
elem.spec)).toEqual(true);
-                // Check that config and platforms.json "satisfy".
-                expect(semver.satisfies(platformsJson[iosPlatform], 
elem.spec)).toEqual(true);
             });
             // Config.xml added ios platform.
             expect(engNames).toEqual([ 'ios' ]);
             // Check that pkg.json and ios/cordova/version versions "satisfy" 
each other.
             expect(semver.satisfies(iosVersion.version, 
pkgJson.dependencies['cordova-ios'])).toEqual(true);
-            // Check that pkg.json and platforms.json "satisfy".
-            expect(semver.satisfies(platformsJson[iosPlatform], 
pkgJson.dependencies['cordova-ios'])).toEqual(true);
         }).then(function () {
             // Add splashscreen plugin with --save --fetch.
             return cordova.plugin('add', 'cordova-plugin-splashscreen', 
{'save': true, 'fetch': true});
diff --git a/spec/cordova/platform/addHelper.spec.js 
b/spec/cordova/platform/addHelper.spec.js
index 7a48c9532..264abe999 100644
--- a/spec/cordova/platform/addHelper.spec.js
+++ b/spec/cordova/platform/addHelper.spec.js
@@ -24,7 +24,6 @@ var events = require('cordova-common').events;
 var rewire = require('rewire');
 var platform_addHelper = rewire('../../../src/cordova/platform/addHelper');
 var platform_module = require('../../../src/cordova/platform');
-var platform_metadata = require('../../../src/cordova/platform_metadata');
 var cordova_util = require('../../../src/cordova/util');
 var cordova_config = require('../../../src/cordova/config');
 var plugman = require('../../../src/plugman/plugman');
@@ -88,7 +87,6 @@ describe('cordova/platform/addHelper', function () {
         platform_api_mock.createPlatform.and.returnValue(Q());
         platform_api_mock.updatePlatform.and.returnValue(Q());
         spyOn(cordova_util, 
'getPlatformApiFunction').and.returnValue(platform_api_mock);
-        spyOn(platform_metadata, 'save');
         spyOn(cordova_util, 'requireNoCache').and.returnValue({});
     });
     afterEach(function () {
@@ -261,15 +259,6 @@ describe('cordova/platform/addHelper', function () {
                 }).done(done);
             });
 
-            it('should save the platform metadata', function (done) {
-                platform_addHelper('add', hooks_mock, projectRoot, ['atari'], 
{save: true, fetch: true, restoring: true}).then(function (result) {
-                    
expect(platform_metadata.save).toHaveBeenCalledWith('/some/path', 'atari', 
undefined);
-                }).fail(function (err) {
-                    fail('unexpected failure handler invoked!');
-                    console.error(err);
-                }).done(done);
-            });
-
             it('should write out the version of platform just added/updated to 
config.xml if the save option is provided', function (done) {
                 platform_addHelper('add', hooks_mock, projectRoot, ['ios'], 
{save: true, restoring: true}).then(function (result) {
                     
expect(cfg_parser_mock.prototype.removeEngine).toHaveBeenCalled();
diff --git a/spec/cordova/platform/index.spec.js 
b/spec/cordova/platform/index.spec.js
index 51469025d..f15340a40 100644
--- a/spec/cordova/platform/index.spec.js
+++ b/spec/cordova/platform/index.spec.js
@@ -137,16 +137,6 @@ describe('cordova/platform', function () {
                         fail('did not expect fail handler to be invoked');
                     }).done(done);
             });
-            it('should direct `save` commands to the `save` method/module', 
function (done) {
-                spyOn(platform, 'save').and.returnValue(true);
-                platform('save', ['android'])
-                    .then(function () {
-                        expect(platform.save).toHaveBeenCalled();
-                    }).fail(function (e) {
-                        expect(e).toBeUndefined();
-                        fail('did not expect fail handler to be invoked');
-                    }).done(done);
-            });
             it('should direct `list`, all other commands and no command at all 
to the `list` method/module', function (done) {
                 spyOn(platform, 'list').and.returnValue(true);
                 // test the `list` command directly
diff --git a/spec/cordova/platform/list.spec.js 
b/spec/cordova/platform/list.spec.js
index 48c17f97a..9a5765422 100644
--- a/spec/cordova/platform/list.spec.js
+++ b/spec/cordova/platform/list.spec.js
@@ -18,7 +18,6 @@
 var events = require('cordova-common').events;
 var Q = require('q');
 var platform_list = require('../../../src/cordova/platform/list');
-var platform_metadata = require('../../../src/cordova/platform_metadata');
 var cordova_util = require('../../../src/cordova/util');
 var fail;
 
@@ -31,7 +30,6 @@ describe('cordova/platform/list', function () {
         hooks_mock.fire.and.returnValue(Q());
         spyOn(cordova_util, 
'getInstalledPlatformsWithVersions').and.callThrough();
         spyOn(events, 'emit');
-        spyOn(platform_metadata, 'save');
         spyOn(cordova_util, 'requireNoCache').and.returnValue({});
     });
 
diff --git a/spec/cordova/platform/remove.spec.js 
b/spec/cordova/platform/remove.spec.js
index 9e2e7b3e4..9f42fe8ce 100644
--- a/spec/cordova/platform/remove.spec.js
+++ b/spec/cordova/platform/remove.spec.js
@@ -21,7 +21,6 @@ var Q = require('q');
 var events = require('cordova-common').events;
 var rewire = require('rewire');
 var platform_remove = rewire('../../../src/cordova/platform/remove');
-var platform_metadata = require('../../../src/cordova/platform_metadata');
 var cordova_util = require('../../../src/cordova/util');
 var promiseutil = require('../../../src/util/promise-util');
 var fail;
@@ -113,29 +112,6 @@ describe('cordova/platform/remove', function () {
                 }).done(done);
         });
 
-        it('should only remove from platforms.json', function (done) {
-            spyOn(platform_metadata, 'remove').and.callThrough();
-            package_json_mock.cordova = {'platforms': ['atari']};
-            cordova_util.requireNoCache.and.returnValue(package_json_mock);
-            fs.existsSync.and.callFake(function (filePath) {
-                if (path.basename(filePath) === 'package.json') {
-                    return true;
-                } else {
-                    return false;
-                }
-            });
-            platform_remove(hooks_mock, projectRoot, ['atari'], {save: false})
-                .then(function () {
-                    expect(fs.writeFileSync).not.toHaveBeenCalled();
-                    
expect(cfg_parser_mock.prototype.write).not.toHaveBeenCalled();
-                    expect(platform_metadata.remove).toHaveBeenCalled();
-                    expect(events.emit).toHaveBeenCalledWith('verbose', 
jasmine.stringMatching(/Removing platform atari from platforms.json file/));
-                }).fail(function (e) {
-                    fail('fail handler unexpectedly invoked');
-                    console.error(e);
-                }).done(done);
-        });
-
         it('fetch should be called', function (done) {
             spyOn(promiseutil, 'Q_chainmap').and.returnValue(true);
             platform_remove(hooks_mock, projectRoot, ['atari'], {fetch: true})
diff --git a/spec/cordova/platform/save.spec.js 
b/spec/cordova/platform/save.spec.js
deleted file mode 100644
index 4b093f6b7..000000000
--- a/spec/cordova/platform/save.spec.js
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
-    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 Q = require('q');
-var rewire = require('rewire');
-var platform_save = rewire('../../../src/cordova/platform/save');
-var platform_metadata = require('../../../src/cordova/platform_metadata');
-var fail;
-var semver = require('semver');
-
-describe('cordova/platform/save', function () {
-    var hooks_mock;
-    var projectRoot = '/some/path';
-    var cfg_parser_mock = function () {};
-    var cfg_parser_revert_mock;
-
-    beforeEach(function () {
-        spyOn(semver, 'valid');
-        cfg_parser_mock.prototype = jasmine.createSpyObj('config parser mock', 
['write', 'removeEngine', 'addEngine', 'getEngines']);
-        cfg_parser_revert_mock = platform_save.__set__('ConfigParser', 
cfg_parser_mock);
-        cfg_parser_mock.prototype.getEngines.and.returnValue(['android']);
-    });
-
-    afterEach(function () {
-        cfg_parser_revert_mock();
-    });
-
-    it('should first remove platforms already in config.xml', function (done) {
-        platform_save(hooks_mock, projectRoot, {save: true})
-            .then(function (res) {
-                
expect(cfg_parser_mock.prototype.getEngines).toHaveBeenCalled();
-                
expect(cfg_parser_mock.prototype.removeEngine).toHaveBeenCalled();
-            }).fail(function (err) {
-                fail('unexpected failure handler invoked!');
-                console.error(err);
-            }).done(done);
-    });
-
-    it('add and write to config.xml', function (done) {
-        spyOn(platform_metadata, 
'getPlatformVersions').and.returnValue(Q([{platform: 'android', version: 
'6.3.0'}]));
-        semver.valid.and.returnValue('6.0.0');
-        platform_save(hooks_mock, projectRoot, {save: true})
-            .then(function (result) {
-                
expect(cfg_parser_mock.prototype.addEngine).toHaveBeenCalledWith('android', 
'~6.0.0');
-                expect(cfg_parser_mock.prototype.write).toHaveBeenCalled();
-            }).fail(function (err) {
-                fail('unexpected failure handler invoked!');
-                console.error(err);
-            }).done(done);
-    });
-
-    it('should return valid version', function (done) {
-        platform_save.getSpecString('~5.0.0');
-        expect(semver.valid).toHaveBeenCalledWith('~5.0.0', true);
-        done();
-    });
-});
diff --git a/src/cordova/platform/addHelper.js 
b/src/cordova/platform/addHelper.js
index 2b3ce97bc..5d7aabc3f 100644
--- a/src/cordova/platform/addHelper.js
+++ b/src/cordova/platform/addHelper.js
@@ -27,11 +27,8 @@ var ConfigParser = require('cordova-common').ConfigParser;
 var PlatformJson = require('cordova-common').PlatformJson;
 var events = require('cordova-common').events;
 var cordova_util = require('../util');
-// delete require.cache[require.resolve('../prepare')];
-// var prepare = require('../prepare');
 var promiseutil = require('../../util/promise-util');
 var config = require('../config');
-var platformMetadata = require('../platform_metadata');
 var platforms = require('../../platforms/platforms');
 var detectIndent = require('detect-indent');
 
@@ -228,7 +225,6 @@ function addHelper (cmd, hooksRunner, projectRoot, targets, 
opts) {
                             // actually installed.
                             var versionToSave = saveVersion ? 
platDetails.version : spec;
                             events.emit('verbose', 'Saving ' + platform + '@' 
+ versionToSave + ' into platforms.json');
-                            platformMetadata.save(projectRoot, platform, 
versionToSave);
 
                             if (opts.save || autosave) {
                                 // Similarly here, we save the source location 
if that was specified, otherwise the version that
diff --git a/src/cordova/platform/index.js b/src/cordova/platform/index.js
index c6dfaae02..05628856e 100644
--- a/src/cordova/platform/index.js
+++ b/src/cordova/platform/index.js
@@ -21,7 +21,6 @@ var HooksRunner = require('../../hooks/HooksRunner');
 var CordovaError = require('cordova-common').CordovaError;
 var platforms = require('../../platforms/platforms');
 var addHelper = require('./addHelper');
-var events = require('cordova-common').events;
 
 module.exports = platform;
 
@@ -34,7 +33,6 @@ module.exports.update = function update (hooksRunner, 
projectRoot, targets, opts
 module.exports.remove = require('./remove');
 module.exports.check = require('./check');
 module.exports.list = require('./list');
-module.exports.save = require('./save');
 module.exports.getPlatformDetailsFromDir = 
require('./getPlatformDetailsFromDir');
 
 // Expose the platform parsers on top of this command
@@ -80,9 +78,6 @@ function platform (command, targets, opts) {
             return module.exports.update(hooksRunner, projectRoot, targets, 
opts);
         case 'check':
             return module.exports.check(hooksRunner, projectRoot);
-        case 'save':
-            events.emit('warn', 'This command has been deprecated and will be 
removed in the next major release of cordova.');
-            return module.exports.save(hooksRunner, projectRoot, opts);
         default:
             return module.exports.list(hooksRunner, projectRoot, opts);
         }
diff --git a/src/cordova/platform/remove.js b/src/cordova/platform/remove.js
index 7490f3274..1fa5cb400 100644
--- a/src/cordova/platform/remove.js
+++ b/src/cordova/platform/remove.js
@@ -25,7 +25,6 @@ var events = require('cordova-common').events;
 var npmUninstall = require('cordova-fetch').uninstall;
 var cordova_util = require('../util');
 var config = require('../config');
-var platformMetadata = require('../platform_metadata');
 var promiseutil = require('../../util/promise-util');
 var platforms = require('../../platforms/platforms');
 var detectIndent = require('detect-indent');
@@ -82,7 +81,6 @@ function remove (hooksRunner, projectRoot, targets, opts) {
             // Remove targets from platforms.json.
             targets.forEach(function (target) {
                 events.emit('verbose', 'Removing platform ' + target + ' from 
platforms.json file...');
-                platformMetadata.remove(projectRoot, target);
             });
         }).then(function () {
             // Remove from node_modules if it exists and --fetch was used.
diff --git a/src/cordova/platform/save.js b/src/cordova/platform/save.js
deleted file mode 100644
index 9ba015268..000000000
--- a/src/cordova/platform/save.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
-    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 semver = require('semver');
-var cordova_util = require('../util');
-var ConfigParser = require('cordova-common').ConfigParser;
-var platformMetadata = require('../platform_metadata');
-
-module.exports = save;
-module.exports.getSpecString = getSpecString;
-
-function save (hooksRunner, projectRoot, opts) {
-    var xml = cordova_util.projectConfig(projectRoot);
-    var cfg = new ConfigParser(xml);
-
-    // First, remove all platforms that are already in config.xml
-    cfg.getEngines().forEach(function (engine) {
-        cfg.removeEngine(engine.name);
-    });
-
-    // Save installed platforms into config.xml
-    return platformMetadata.getPlatformVersions(projectRoot).then(function 
(platformVersions) {
-        platformVersions.forEach(function (platVer) {
-            cfg.addEngine(platVer.platform, 
module.exports.getSpecString(platVer.version));
-        });
-        cfg.write();
-    });
-}
-
-function getSpecString (spec) {
-    var validVersion = semver.valid(spec, true);
-    return validVersion ? '~' + validVersion : spec;
-}
diff --git a/src/cordova/platform_metadata.js b/src/cordova/platform_metadata.js
deleted file mode 100644
index 4dc101d04..000000000
--- a/src/cordova/platform_metadata.js
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
-    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 path = require('path');
-var cordova_util = require('./util');
-var fs = require('fs');
-var Q = require('q');
-var child_process = require('child_process');
-
-function getJson (jsonFile) {
-    return JSON.parse(fs.readFileSync(jsonFile, 'utf-8'));
-}
-
-// Retrieves the platforms and their versions from the platforms.json file
-// Returns an array of {platform: platform, version: version} ...
-// ... where version could be '3.4.0', '/path/to/platform' or 'git://...'
-function getVersions (projectRoot) {
-    var platformsDir = path.join(projectRoot, 'platforms');
-    var platformsJsonFile = path.join(platformsDir, 'platforms.json');
-
-    // If the platforms.json file doesn't exist, retrieve versions from 
platforms installed on the filesystem...
-    // ...Note that in this case, we won't be able to know what source(folder, 
git-url) the platform came from, we'll just use versions
-    return getPlatVersionsFromFile(platformsJsonFile).fail(function () {
-        return getPlatVersionsFromFileSystem(projectRoot);
-    });
-}
-
-// Returns a promise
-function getPlatVersionsFromFile (platformsJsonFile) {
-
-    var platformData;
-
-    // Handle 'file not found' exception and stay within the 'promise monad'
-    try {
-        platformData = getJson(platformsJsonFile);
-    } catch (e) {
-        return Q.reject(e);
-    }
-
-    var platformVersions = [];
-
-    platformVersions = Object.keys(platformData).map(function (p) {
-        return {platform: p, version: platformData[p]};
-    });
-
-    return Q(platformVersions);
-}
-
-// Returns a promise
-function getPlatVersionsFromFileSystem (projectRoot) {
-    var platforms_on_fs = cordova_util.listPlatforms(projectRoot);
-    var platformVersions = platforms_on_fs.map(function (platform) {
-        var script = path.join(projectRoot, 'platforms', platform, 'cordova', 
'version');
-        return Q.ninvoke(child_process, 'exec', script, {}).then(function 
(result) {
-            var version = result[0];
-
-            // clean the version we get back from the script
-            // This is necessary because the version script uses console.log 
to pass back
-            // the version. Using console.log ends up adding additional line 
breaks/newlines to the value returned.
-            // ToDO: version scripts should be refactored to not use 
console.log()
-            var versionCleaned = version.replace(/\r?\n|\r/g, '');
-            return {platform: platform, version: versionCleaned};
-        });
-    });
-
-    return Q.all(platformVersions);
-}
-
-// Saves platform@version into platforms.json
-function save (projectRoot, platform, version) {
-    var platformsDir = path.join(projectRoot, 'platforms');
-    var platformJsonFile = path.join(platformsDir, 'platforms.json');
-
-    var data = {};
-    if (fs.existsSync(platformJsonFile)) {
-        data = getJson(platformJsonFile);
-    }
-    data[platform] = version;
-    fs.writeFileSync(platformJsonFile, JSON.stringify(data, null, 2), 'utf-8');
-}
-
-function remove (projectRoot, platform) {
-    var platformsDir = path.join(projectRoot, 'platforms');
-    var platformJsonFile = path.join(platformsDir, 'platforms.json');
-    if (!fs.existsSync(platformJsonFile)) {
-        return;
-    }
-    var data = getJson(platformJsonFile);
-    delete data[platform];
-    fs.writeFileSync(platformJsonFile, JSON.stringify(data, null, 2), 'utf-8');
-}
-
-module.exports.getPlatformVersions = getVersions;
-module.exports.save = save;
-module.exports.remove = remove;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Remove cordova platform save command
> ------------------------------------
>
>                 Key: CB-13057
>                 URL: https://issues.apache.org/jira/browse/CB-13057
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: cordova-lib
>    Affects Versions: cordova@8
>            Reporter: Steve Gill
>            Assignee: Audrey So
>              Labels: backlog, tools-next
>             Fix For: cordova@8
>
>
> With autosaving now in place, we don't need `cordova platform save` anymore.
> By removing this command, we can also remove 
> cordovaProject/platforms/platforms.json & 
> cordova-lib/src/cordova/platform_metadata.js
> Deprecation notice will be added to cordova platform save until save command 
> is removed in cordova@8



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to