You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by dp...@apache.org on 2020/06/02 17:54:17 UTC

[cordova-lib] branch master updated: breaking: upgrade cordova dependencies for next major (#833)

This is an automated email from the ASF dual-hosted git repository.

dpogue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-lib.git


The following commit(s) were added to refs/heads/master by this push:
     new 7a20be8  breaking: upgrade cordova dependencies for next major (#833)
7a20be8 is described below

commit 7a20be8b67ee221e5e7c637ee1a7a18338619d76
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Wed Jun 3 02:54:10 2020 +0900

    breaking: upgrade cordova dependencies for next major (#833)
    
    * breaking: upgrade cordova dependencies for next major
    
    * ci: use the package's android dependency
    
    * ci: check on devDependencies for installed platform and plugins
    
    * ci: use fixed nightly platforms
    
    * ci: modify correct version location
    
    * ci: add back the disabled test
    
    * ci: pin cordova-android to 9.0.0-nightly.2020.5.12.e86b211c
    
    * ci: update api version mock
    
    * chore: drop nightly from ios
---
 integration-tests/pkgJson.spec.js  | 61 +++++++++++++++++++-------------------
 integration-tests/platform.spec.js | 20 ++++++-------
 integration-tests/plugin.spec.js   | 11 ++++---
 package.json                       |  8 ++---
 spec/cordova/util.spec.js          |  2 +-
 spec/fixture-helper.js             |  4 ++-
 spec/project-test-helpers.js       |  2 +-
 src/cordova/util.js                | 13 ++++++--
 src/platforms/platformsConfig.json |  4 +--
 9 files changed, 68 insertions(+), 57 deletions(-)

diff --git a/integration-tests/pkgJson.spec.js b/integration-tests/pkgJson.spec.js
index 9c12e94..b423208 100644
--- a/integration-tests/pkgJson.spec.js
+++ b/integration-tests/pkgJson.spec.js
@@ -61,9 +61,9 @@ describe('pkgJson', function () {
     }
 
     function platformVersion (platformName) {
-        const p = path.join(project, 'platforms', platformName, 'cordova/version');
+        const p = path.join(project, 'platforms', platformName, 'cordova/Api.js');
         expect(p).toExist();
-        return requireNoCache(p).version;
+        return requireNoCache(p).version();
     }
 
     function pluginVersion (pluginName) {
@@ -139,7 +139,7 @@ describe('pkgJson', function () {
                 .then(function () {
                     // Check that the plugin and spec add was successful to pkg.json.
                     expect(getPkgJson('cordova.plugins')[pluginId]).toBeDefined();
-                    expect(getPkgJson('dependencies')[pluginId]).tohaveMinSatisfyingVersion('1.1.2');
+                    expect(getPkgJson('devDependencies')[pluginId]).tohaveMinSatisfyingVersion('1.1.2');
 
                     expect(getCfg().getPluginIdList()).toEqual([]);
                 }).then(function () {
@@ -148,7 +148,7 @@ describe('pkgJson', function () {
                 }).then(function () {
                     // Expect plugin to be removed from pkg.json.
                     expect(getPkgJson('cordova.plugins')[pluginId]).toBeUndefined();
-                    expect(getPkgJson('dependencies')[pluginId]).toBeUndefined();
+                    expect(getPkgJson('devDependencies')[pluginId]).toBeUndefined();
                 });
         });
 
@@ -219,7 +219,7 @@ describe('pkgJson', function () {
                     expect(getPkgJson('cordova.plugins')).toEqual({
                         [pluginId]: {}, [OTHER_PLUGIN]: {}
                     });
-                    expect(getPkgJson('dependencies')).toEqual({
+                    expect(getPkgJson('devDependencies')).toEqual({
                         'cordova-android': jasmine.any(String),
                         [pluginId]: jasmine.any(String),
                         [OTHER_PLUGIN]: jasmine.any(String)
@@ -230,7 +230,7 @@ describe('pkgJson', function () {
                 }).then(function () {
                     // Checking that the plugin removed is in not in the platforms.
                     expect(getPkgJson('cordova.plugins')).toEqual({});
-                    expect(getPkgJson('dependencies')).toEqual({
+                    expect(getPkgJson('devDependencies')).toEqual({
                         'cordova-android': jasmine.any(String)
                     });
                 });
@@ -244,7 +244,7 @@ describe('pkgJson', function () {
 
             // Pkg.json has no platform or plugin or specs.
             expect(getPkgJson('cordova.platforms')).not.toContain(PLATFORM);
-            expect(getPkgJson(`dependencies.${PLUGIN}`)).toBeUndefined();
+            expect(getPkgJson(`devDependencies.${PLUGIN}`)).toBeUndefined();
 
             // Config.xml has no platform or plugin or specs.
             expect(getCfg().getEngines()).not.toContain(PLATFORM);
@@ -261,7 +261,7 @@ describe('pkgJson', function () {
 
                     // Check that installed version satisfies the dependency spec
                     const version = pluginVersion(PLUGIN);
-                    expect(version).toSatisfy(getPkgJson(`dependencies.${PLUGIN}`));
+                    expect(version).toSatisfy(getPkgJson(`devDependencies.${PLUGIN}`));
                 });
         });
 
@@ -275,7 +275,7 @@ describe('pkgJson', function () {
                 .then(() => {
                     // Pkg.json has test plugin.
                     expect(getPkgJson(`cordova.plugins.${PLUGIN}`)).toBeDefined();
-                    expect(getPkgJson(`dependencies.${PLUGIN}`)).toBeDefined();
+                    expect(getPkgJson(`devDependencies.${PLUGIN}`)).toBeDefined();
                 });
         });
 
@@ -283,11 +283,11 @@ describe('pkgJson', function () {
             const URL = 'https://github.com/apache/cordova-plugin-device.git#semver:2.0.x';
 
             expect(getPkgJson('cordova.plugins')).toBeUndefined();
-            expect(getPkgJson(`dependencies.${pluginId}`)).toBeUndefined();
+            expect(getPkgJson(`devDependencies.${pluginId}`)).toBeUndefined();
 
             await cordova.plugin('add', URL, { save: true });
             expect(getPkgJson('cordova.plugins')[pluginId]).toBeDefined();
-            expect(getPkgJson('dependencies')[pluginId]).toMatch(URL);
+            expect(getPkgJson('devDependencies')[pluginId]).toMatch(URL);
         });
     });
 
@@ -346,7 +346,7 @@ describe('pkgJson', function () {
         });
 
         it('Test#009 : should only add the platform to package.json with --save', function () {
-            const platformNotToAdd = 'browser';
+            const platformNotToAdd = 'ios';
             expect(pkgJsonPath).toExist();
 
             // Add a platform without --save.
@@ -367,25 +367,25 @@ describe('pkgJson', function () {
             expect(installedPlatforms()).toEqual([]);
 
             // Add the testing platform with --save and add specific version to android platform.
-            return cordova.platform('add', ['android@7.0.0', 'browser@5.0.1'], { save: true }).then(function () {
-                expect(installedPlatforms()).toEqual(['android', 'browser']);
+            return cordova.platform('add', ['android@9.0.0-nightly.2020.5.9.e86b211c', 'ios@6.0.0-nightly.2020.5.9.e65d685c'], { save: true }).then(function () {
+                expect(installedPlatforms()).toEqual(['android', 'ios']);
 
                 // Check the platform add was successful in platforms list and
                 // dependencies should have specific version from add.
-                expect(getPkgJson('cordova.platforms')).toEqual(['android', 'browser']);
-                expect(getPkgJson('dependencies')).toEqual({
-                    'cordova-android': specWithMinSatisfyingVersion('7.0.0'),
-                    'cordova-browser': specWithMinSatisfyingVersion('5.0.1')
+                expect(getPkgJson('cordova.platforms')).toEqual(['android', 'ios']);
+                expect(getPkgJson('devDependencies')).toEqual({
+                    'cordova-android': specWithMinSatisfyingVersion('9.0.0-nightly.2020.5.9.e86b211c'),
+                    'cordova-ios': specWithMinSatisfyingVersion('6.0.0-nightly.2020.5.9.e65d685c')
                 });
 
                 expect(getCfg().getEngines()).toEqual([]);
             }).then(function () {
                 // And now remove it with --save.
-                return cordova.platform('rm', ['android', 'browser'], { save: true });
+                return cordova.platform('rm', ['android', 'ios'], { save: true });
             }).then(function () {
                 // Expect platforms to be uninstalled & removed from config files
                 expect(getPkgJson('cordova.platforms')).toEqual([]);
-                expect(getPkgJson('dependencies')).toEqual({});
+                expect(getPkgJson('devDependencies')).toEqual({});
                 expect(getCfg().getEngines()).toEqual([]);
                 expect(installedPlatforms()).toEqual([]);
             });
@@ -405,7 +405,7 @@ describe('pkgJson', function () {
                 .then(() => {
                     expect(installedPlatforms()).toEqual([PLATFORM]);
                     expect(getPkgJson('cordova.platforms')).toEqual([PLATFORM]);
-                    expect(getPkgJson(`dependencies.cordova-${PLATFORM}`)).toBeDefined();
+                    expect(getPkgJson(`devDependencies.cordova-${PLATFORM}`)).toBeDefined();
                 });
         });
     });
@@ -417,14 +417,15 @@ describe('pkgJson', function () {
         /** Test#020 will check that pkg.json, config.xml, platforms.json, and cordova platform ls
         *   are updated with the correct (platform and plugin) specs from pkg.json.
         */
+        // @todo add a test to also support checking dependencies
         it('Test#020 : During add, if pkg.json has a spec, use that one.', function () {
             const PLATFORM = 'ios';
             const PLUGIN = 'cordova-plugin-splashscreen';
 
             setPkgJson('cordova.platforms', [PLATFORM]);
-            setPkgJson('dependencies', {
+            setPkgJson('devDependencies', {
                 [PLUGIN]: '^3.2.2',
-                [`cordova-${PLATFORM}`]: '^4.5.4'
+                [`cordova-${PLATFORM}`]: '^6.0.0-nightly.2020.5.12.e65d685c'
             });
 
             // config.xml has no platforms or plugins yet.
@@ -439,13 +440,13 @@ describe('pkgJson', function () {
                 // Config.xml and ios/cordova/version check.
                 const version = platformVersion(PLATFORM);
                 // Check that pkg.json and ios/cordova/version versions "satisfy" each other.
-                const pkgSpec = getPkgJson(`dependencies.cordova-${PLATFORM}`);
+                const pkgSpec = getPkgJson(`devDependencies.cordova-${PLATFORM}`);
                 expect(version).toSatisfy(pkgSpec);
             }).then(function () {
                 return cordova.plugin('add', PLUGIN, { save: true });
             }).then(function () {
                 // Check that installed version satisfies the dependency spec
-                expect(pluginVersion(PLUGIN)).toSatisfy(getPkgJson(`dependencies.${PLUGIN}`));
+                expect(pluginVersion(PLUGIN)).toSatisfy(getPkgJson(`devDependencies.${PLUGIN}`));
             });
         }, TIMEOUT * 2);
 
@@ -488,18 +489,18 @@ describe('pkgJson', function () {
             const PLUGIN = 'cordova-plugin-splashscreen';
 
             setPkgJson('cordova.platforms', [PLATFORM]);
-            setPkgJson('dependencies', {
-                [`cordova-${PLATFORM}`]: '^4.2.1',
+            setPkgJson('devDependencies', {
+                [`cordova-${PLATFORM}`]: '^6.0.0-nightly.2020.5.1.e65d685c',
                 [PLUGIN]: '^3.2.2'
             });
             getCfg()
-                .addEngine(PLATFORM, '~4.2.1')
+                .addEngine(PLATFORM, '~6.0.0-nightly.2020.5.1.e65d685c')
                 .addPlugin({ name: PLUGIN, spec: '~3.2.1' })
                 .write();
 
             expect(installedPlatforms()).toEqual([]);
 
-            return cordova.platform('add', `${PLATFORM}@4.5.4`, { save: true }).then(function () {
+            return cordova.platform('add', `${PLATFORM}@6.0.0-nightly.2020.5.9.e65d685c`, { save: true }).then(function () {
                 // Pkg.json has ios.
                 expect(getPkgJson('cordova.platforms')).toEqual([PLATFORM]);
             }).then(function () {
@@ -508,7 +509,7 @@ describe('pkgJson', function () {
                 // Check that installed version satisfies the dependency spec
                 const version = pluginVersion(PLUGIN);
                 expect(version).toSatisfy(getCfg().getPlugin(PLUGIN).spec);
-                expect(version).toSatisfy(getPkgJson(`dependencies.${PLUGIN}`));
+                expect(version).toSatisfy(getPkgJson(`devDependencies.${PLUGIN}`));
             });
         });
     });
diff --git a/integration-tests/platform.spec.js b/integration-tests/platform.spec.js
index 1f5b813..44888d7 100644
--- a/integration-tests/platform.spec.js
+++ b/integration-tests/platform.spec.js
@@ -127,22 +127,22 @@ describe('cordova/platform end-to-end', () => {
     it('Test 007 : should add and remove platform from node_modules directory', () => {
         return Promise.resolve()
             .then(() => {
-                return cordova.platform('add', 'browser', { save: true });
+                return cordova.platform('add', 'ios', { save: true });
             })
             .then(() => {
-                expect(path.join(nodeModulesDir, 'cordova-browser')).toExist();
-                expect(path.join(platformsDir, 'browser')).toExist();
-                return cordova.platform('add', 'android');
+                expect(path.join(nodeModulesDir, 'cordova-ios')).toExist();
+                expect(path.join(platformsDir, 'ios')).toExist();
+                return cordova.platform('add', 'android@9.0.0-nightly.2020.5.9.e86b211c');
             })
             .then(() => {
-                expect(path.join(nodeModulesDir, 'cordova-browser')).toExist();
+                expect(path.join(nodeModulesDir, 'cordova-android')).toExist();
                 expect(path.join(platformsDir, 'android')).toExist();
-                return cordova.platform('rm', 'browser');
+                return cordova.platform('rm', 'ios', { save: true });
             })
             .then(() => {
-                expect(path.join(nodeModulesDir, 'cordova-browser')).not.toExist();
-                expect(path.join(platformsDir, 'browser')).not.toExist();
-                return cordova.platform('rm', 'android');
+                expect(path.join(nodeModulesDir, 'cordova-ios')).not.toExist();
+                expect(path.join(platformsDir, 'ios')).not.toExist();
+                return cordova.platform('rm', 'android', { save: true });
             })
             .then(() => {
                 expect(path.join(nodeModulesDir, 'cordova-android')).not.toExist();
@@ -177,7 +177,7 @@ describe('cordova/platform end-to-end', () => {
         return Promise.resolve()
             .then(() => {
                 // add cordova-android instead of android
-                return cordova.platform('add', 'cordova-android');
+                return cordova.platform('add', 'cordova-android@9.0.0-nightly.2020.5.9.e86b211c');
             })
             .then(() => {
                 // 3rd party platform from npm
diff --git a/integration-tests/plugin.spec.js b/integration-tests/plugin.spec.js
index 5a100a0..5160808 100644
--- a/integration-tests/plugin.spec.js
+++ b/integration-tests/plugin.spec.js
@@ -210,12 +210,11 @@ describe('plugin end-to-end', function () {
 
         // Pretend to have cordova-android 5.2.2 installed to force the
         // expected version outcome for the plugin below
-        fs.writeFileSync(
-            path.join(project, 'platforms/android/cordova/version'),
-            `#!/usr/bin/env node
-            exports.version = '5.2.2';
-            if (!module.parent) console.log(exports.version);`
-        );
+        const targetVersion = '5.2.2';
+        const apiFile = path.join(project, 'platforms/android/cordova/Api.js');
+        const apiString = fs.readFileSync(apiFile, 'utf8')
+            .replace(/const VERSION = '9.0.0-nightly.2020.5.12.e86b211c';/, `const VERSION = '${targetVersion}';`);
+        fs.writeFileSync(apiFile, apiString, 'utf8');
 
         return addPlugin(npmInfoTestPlugin, npmInfoTestPlugin)
             .then(function () {
diff --git a/package.json b/package.json
index 67459d3..128464c 100644
--- a/package.json
+++ b/package.json
@@ -17,9 +17,9 @@
     "node": ">=10.0.0"
   },
   "dependencies": {
-    "cordova-common": "4.0.0-nightly.2019.11.8.40cb6cee",
-    "cordova-create": "^2.0.0",
-    "cordova-fetch": "^2.0.0",
+    "cordova-common": "^4.0.1",
+    "cordova-create": "^3.0.0",
+    "cordova-fetch": "^3.0.0",
     "cordova-serve": "^3.0.0",
     "dep-graph": "^1.1.0",
     "detect-indent": "^6.0.0",
@@ -36,7 +36,7 @@
   "devDependencies": {
     "@cordova/eslint-config": "^2.0.0",
     "codecov": "^3.2.0",
-    "cordova-android": "^8.1.0",
+    "cordova-android": "9.0.0-nightly.2020.5.12.e86b211c",
     "delay": "^4.1.0",
     "jasmine": "^3.5.0",
     "jasmine-spec-reporter": "^4.2.1",
diff --git a/spec/cordova/util.spec.js b/spec/cordova/util.spec.js
index c8042ad..a87062f 100644
--- a/spec/cordova/util.spec.js
+++ b/spec/cordova/util.spec.js
@@ -104,7 +104,7 @@ describe('util module', function () {
 
             return helpers.getFixture('androidApp').copyTo(platformPath)
                 .then(_ => util.getInstalledPlatformsWithVersions(temp))
-                .then(versions => expect(versions[PLATFORM]).toBe('8.1.0'));
+                .then(versions => expect(versions[PLATFORM]).toBe('9.0.0-nightly.2020.5.12.e86b211c'));
         });
     });
     describe('findPlugins method', function () {
diff --git a/spec/fixture-helper.js b/spec/fixture-helper.js
index 7ee0352..6615bba 100644
--- a/spec/fixture-helper.js
+++ b/spec/fixture-helper.js
@@ -65,7 +65,9 @@ module.exports = function fixtureHelper (tmpDir) {
             process.chdir(projectPath);
 
             // Talk about a clunky interface :(
-            const platforms = ['android'];
+            // @todo remove @nightly once Android next major is released.
+            const platformFromPackageDependencies = path.resolve(path.dirname(require.resolve('cordova-android')), '../../../');
+            const platforms = [platformFromPackageDependencies];
             const opts = { platforms, save: true };
             const hooksRunner = new HooksRunner(projectPath);
             await platformAdd(hooksRunner, projectPath, platforms, opts);
diff --git a/spec/project-test-helpers.js b/spec/project-test-helpers.js
index 986a19e..56d555e 100644
--- a/spec/project-test-helpers.js
+++ b/spec/project-test-helpers.js
@@ -48,7 +48,7 @@ module.exports = function projectTestHelpers (getProjectPath) {
         expect(getCfg().getPlugins()).toEqual([]);
         expect(getCfg().getEngines()).toEqual([]);
         expect(getPkgJson('cordova')).toBeUndefined();
-        expect(getPkgJson('dependencies')).toBeUndefined();
+        expect(getPkgJson('devDependencies')).toBeUndefined();
     }
 
     function getCfg () {
diff --git a/src/cordova/util.js b/src/cordova/util.js
index 97ef08b..3fb5f0f 100644
--- a/src/cordova/util.js
+++ b/src/cordova/util.js
@@ -200,8 +200,17 @@ function getInstalledPlatformsWithVersions (project_dir) {
 }
 
 function getPlatformVersion (platformPath) {
-    const versionPath = path.join(platformPath, 'cordova/version');
-    return requireNoCache(versionPath).version;
+    try {
+        // Major Platforms for Cordova 10+
+        return requireNoCache(
+            path.join(platformPath, 'cordova/Api')
+        ).version();
+    } catch (e) {
+        // Platforms pre-Cordova 10
+        return requireNoCache(
+            path.join(platformPath, 'cordova/version')
+        ).version;
+    }
 }
 
 function getPlatformVersionOrNull (platformPath) {
diff --git a/src/platforms/platformsConfig.json b/src/platforms/platformsConfig.json
index 0a45d64..ef7a8e3 100644
--- a/src/platforms/platformsConfig.json
+++ b/src/platforms/platformsConfig.json
@@ -2,7 +2,7 @@
     "ios": {
         "hostos": ["darwin"],
         "url": "https://github.com/apache/cordova-ios.git",
-        "version": "^5.0.0",
+        "version": "^6.0.0",
         "deprecated": false
     },
     "osx": {
@@ -13,7 +13,7 @@
     },
     "android": {
         "url": "https://github.com/apache/cordova-android.git",
-        "version": "^8.0.0",
+        "version": "^9.0.0-nightly.2020.5.11.e86b211c",
         "deprecated": false
     },
     "windows": {


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