Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistensies in module detection #171

Merged
merged 3 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/timodule.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,15 @@ function find(modulesOrParams, platforms, deployType, tiManifest, searchPaths, l
return;
}

if (moduleAPIVersion && moduleAPIVersion[platform] && info.manifest && info.manifest.apiversion && info.manifest.apiversion !== moduleAPIVersion[platform]) {
let platformAPIVersion = moduleAPIVersion && moduleAPIVersion[platform] && parseInt(moduleAPIVersion[platform], 10);
if (!platformAPIVersion && platform === 'ios') {
platformAPIVersion = moduleAPIVersion && moduleAPIVersion['iphone'] && parseInt(moduleAPIVersion['iphone'], 10);
}
const modAPIVersion = info.manifest && parseInt(info.manifest.apiversion, 10);
if (platformAPIVersion && modAPIVersion && modAPIVersion !== platformAPIVersion) {
if (params.logger) {
params.logger.debug(__('Found incompatible Titanium module id=%s version=%s platform=%s api-version=%s deploy-type=%s', tmp.id.cyan, tmp.version.cyan, tmp.platform.join(',').cyan, String(info.manifest.apiversion).cyan, tmp.deployType.join(',').cyan));
params.logger.debug(__('Module %s has apiversion=%s, but the selected SDK supports module apiversion=%s on platform=%s', tmp.id.cyan, info.manifest.apiversion.cyan, moduleAPIVersion[platform].cyan, platform.cyan));
params.logger.debug(__('Module %s has apiversion=%s, but the selected SDK supports module apiversion=%s on platform=%s', tmp.id.cyan, String(modAPIVersion).cyan, String(platformAPIVersion).cyan, platform.cyan));
}
result.incompatible.push(tmp);
foundIncompatible = true;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"keywords": [
"appcelerator"
],
"version": "0.3.2",
"version": "0.3.3",
"author": {
"name": "Appcelerator, Inc.",
"email": "npmjs@appcelerator.com"
Expand Down
18 changes: 18 additions & 0 deletions test/resources/timodule5/modules/android/ti.map/3.1.0/manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 3.1.0
apiversion: 2
architectures: arm64-v8a armeabi-v7a x86
description: External version of Map module
author: Jeff Haynie, Jon Alter, Pedro Enrique, Hans Knöchel, Vijay Singh
license: Apache Public License v2
copyright: Copyright (c) 2013-present by Axway Appcelerator

# these should not be edited
name: map
moduleid: ti.map
guid: fee93b77-8eb3-418c-8f04-013664c4af83
platform: android
minsdk: 6.2.2.GA
41 changes: 41 additions & 0 deletions test/test-timodule.js
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,47 @@ describe('timodule', function () {
}
}, true);
});

it('should parse apiversion to an integer before comparing', function (done) {
appc.timodule.find([
{ id: 'ti.map', platform: 'android' }
], [ 'android' ], 'development', { sdkVersion: '6.3.0', moduleAPIVersion: { android: 2 } }, [ path.join(__dirname, 'resources', 'timodule5') ], logger, function (result) {
try {
logger.buffer.stripColors.should.containEql(
'Found Titanium module id=ti.map version=3.1.0 platform=android deploy-type=development'
);

const found = result.found.find(r => r.id === 'ti.map');
assert(found, '"ti.map" module not marked as found');

done();
} catch (e) {
done(e);
}
}, true);
});

it('should check apiversion for iphone if no ios value', function (done) {
appc.timodule.find([
{ id: 'cross-platform-with-manifest', platform: 'iphone' }
], [ 'iphone' ], 'development', { sdkVersion: '6.3.0', moduleAPIVersion: { iphone: '2' } }, [ path.join(__dirname, 'resources', 'cross-platform-native-module-with-manifest') ], logger, function (result) {
try {
console.log(logger.buffer.stripColors);
logger.buffer.stripColors.should.containEql(
'Found incompatible Titanium module id=cross-platform-with-manifest version=2.0.1 platform=ios api-version=1 deploy-type=development'
);

logger.buffer.stripColors.should.containEql(
'Module cross-platform-with-manifest has apiversion=1, but the selected SDK supports module apiversion=2 on platform=ios'
);

assert(result.found.length === 0, '"cross-platform-with-manifest" module was marked as found');
done();
} catch (e) {
done(e);
}
}, true);
});
});

describe('#detectNodeModules()', () => {
Expand Down