mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Implement CORDOVA_COMPATIBILITY_VERSION_IOS/ANDROID and EXCLUDE (#8581)
* Implement CORDOVA_COMPATIBILITY_VERSION_EXCLUDE and CORDOVA_COMPATIBILITY_VERSION_IOS/ANDROID CORDOVA_COMPATIBILITY_VERSION_IOS or CORDOVA_COMPATIBILITY_VERSION_ANDROID allows to override compatibility version for a specified platform. CORDOVA_COMPATIBILITY_VERSION_EXCLUDE provides a way of excluding a certain plugin from compatibility version calculation. You can pass several plugin names with ';'. For example: `CORDOVA_COMPATIBILITY_VERSION_EXCLUDE='cordova-plugin-crosswalk-webview;cordova-plugin-device'` * Changes after review
This commit is contained in:
committed by
Jesse Rosenberger
parent
9da6767447
commit
5a4d5035c3
@@ -1522,11 +1522,22 @@ class ClientTarget extends Target {
|
||||
if (this.arch === 'web.cordova') {
|
||||
const { WebAppHashing } =
|
||||
loadIsopacket('cordova-support')['webapp-hashing'];
|
||||
|
||||
const cordovaCompatibilityVersions =
|
||||
_.object(_.map(CORDOVA_PLATFORM_VERSIONS, (version, platform) => {
|
||||
const hash = WebAppHashing.calculateCordovaCompatibilityHash(
|
||||
version,
|
||||
this.cordovaDependencies);
|
||||
|
||||
const pluginsExcludedFromCompatibilityHash = (process.env.METEOR_CORDOVA_COMPAT_VERSION_EXCLUDE || '')
|
||||
.split(',');
|
||||
|
||||
const cordovaDependencies = Object.assign(
|
||||
Object.create(null),
|
||||
_.omit(this.cordovaDependencies, pluginsExcludedFromCompatibilityHash)
|
||||
);
|
||||
|
||||
const hash = process.env[`METEOR_CORDOVA_COMPAT_VERSION_${platform.toUpperCase()}`] ||
|
||||
WebAppHashing.calculateCordovaCompatibilityHash(
|
||||
version,
|
||||
cordovaDependencies);
|
||||
return [platform, hash];
|
||||
}));
|
||||
program.cordovaCompatibilityVersions = cordovaCompatibilityVersions;
|
||||
|
||||
47
tools/tests/cordova-hcp.js
vendored
47
tools/tests/cordova-hcp.js
vendored
@@ -39,3 +39,50 @@ selftest.define(
|
||||
|
||||
run.stop();
|
||||
});
|
||||
|
||||
selftest.define(
|
||||
"cordova METEOR_CORDOVA_COMPAT_VERSION_* works", ["cordova", "slow"], function () {
|
||||
var s = new Sandbox();
|
||||
var run;
|
||||
|
||||
var androidCompatibilityVersion = '2.0';
|
||||
|
||||
// Override the compatibility version for android with METEOR_CORDOVA_COMPAT_VERSION_ANDROID.
|
||||
s.env.METEOR_CORDOVA_COMPAT_VERSION_ANDROID = androidCompatibilityVersion;
|
||||
|
||||
s.createApp("myapp", "standard-app");
|
||||
s.cd("myapp");
|
||||
|
||||
var platforms = s.read(".meteor/platforms");
|
||||
s.write(".meteor/platforms", platforms + "\nandroid\n");
|
||||
|
||||
run = s.run("run", "android", "--mobile-server", "example.com");
|
||||
run.waitSecs(30);
|
||||
run.match("Started your app");
|
||||
|
||||
var result = JSON.parse(httpHelpers.getUrl(
|
||||
"http://localhost:3000/__cordova/manifest.json"));
|
||||
|
||||
// Check in the manifest if the overridden version was used.
|
||||
selftest.expectEqual(result.cordovaCompatibilityVersions.android, androidCompatibilityVersion);
|
||||
|
||||
run.stop();
|
||||
// Save the iOS compatibility version.
|
||||
var iosCompatibilityVersion = result.cordovaCompatibilityVersions.ios;
|
||||
|
||||
// Now exclude one of the plugins from compatibility version calculation.
|
||||
s.env.METEOR_CORDOVA_COMPAT_VERSION_EXCLUDE = 'cordova-plugin-meteor-webapp,any-other-plugin';
|
||||
|
||||
run = s.run("run", "android", "--mobile-server", "example.com");
|
||||
run.waitSecs(30);
|
||||
run.match("Started your app");
|
||||
|
||||
result = JSON.parse(httpHelpers.getUrl(
|
||||
"http://localhost:3000/__cordova/manifest.json"));
|
||||
|
||||
// Version should be different. There is no need to check if the particular plugin was not taken into account,
|
||||
// if the version has changed it's proof enough.
|
||||
selftest.expectFalse(result.cordovaCompatibilityVersions.ios === iosCompatibilityVersion);
|
||||
|
||||
run.stop();
|
||||
});
|
||||
Reference in New Issue
Block a user