Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
._*
.DS_Store
dist
npm-debug.log
node_modules
env.properties
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
._*
.DS_Store
.git*
dist
node_modules
npm-debug.log
env.properties
Expand Down
23 changes: 15 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Main namespace for the ioslib.
*
* @copyright
* Copyright (c) 2014-2015 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2014-2016 by Appcelerator, Inc. All Rights Reserved.
*
* @license
* Licensed under the terms of the Apache Public License.
Expand All @@ -18,6 +18,7 @@ const
magik = exports.magik = require('./lib/utilities').magik,
provisioning = exports.provisioning = require('./lib/provisioning'),
simulator = exports.simulator = require('./lib/simulator'),
teams = exports.teams = require('./lib/teams'),
utilities = exports.utilities = require('./lib/utilities'),
xcode = exports.xcode = require('./lib/xcode');

Expand Down Expand Up @@ -73,37 +74,43 @@ function detect(options, callback) {
}

async.parallel([
function certificates(done) {
function detectCertificates(done) {
certs.detect(options, function (err, result) {
err || mix(result, results);
done(err);
});
},
function devices(done) {
function detectDevices(done) {
device.detect(options, function (err, result) {
err || mix(result, results);
done(err);
});
},
function environment(done) {
function detectEnvironment(done) {
env.detect(options, function (err, result) {
err || mix(result, results);
done(err);
});
},
function provisioningProfiles(done) {
function detectProvisioning(done) {
provisioning.detect(options, function (err, result) {
err || mix(result, results);
done(err);
});
},
function simulators(done) {
function detectSimulator(done) {
simulator.detect(options, function (err, result) {
err || mix(result, results);
done(err);
});
},
function xcodes(done) {
function detectTeams(done) {
teams.detect(options, function (err, result) {
err || mix(result, results);
done(err);
});
},
function detectXcode(done) {
xcode.detect(options, function (err, result) {
err || mix(result, results);
done(err);
Expand Down Expand Up @@ -196,4 +203,4 @@ function findValidDeviceCertProfileCombos(options, callback) {
});
});
});
}
}
99 changes: 99 additions & 0 deletions lib/teams.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
* Detects the Apple developer teams.
*
* @module teams
*
* @copyright
* Copyright (c) 2014-2016 by Appcelerator, Inc. All Rights Reserved.
*
* @license
* Licensed under the terms of the Apache Public License.
* Please see the LICENSE included with this distribution for details.
*/

const
async = require('async'),
magik = require('./utilities').magik,
provisioning = require('./provisioning'),
xcode = require('./xcode');

/**
* Fired when the developer profiles have been updated.
* @event module:env#detected
* @type {Object}
*/

/**
* Fired when there was an error retreiving the provisioning profiles.
* @event module:env#error
* @type {Error}
*/

/**
* Detects the Apple developer teams from the provisioning profiles and Xcodes.
*
* @param {Object} [options] - An object containing various settings
* @param {Function} [callback(err, results)] - A function to call with the development environment information
*
* @emits module:env#detected
* @emits module:env#error
*
* @returns {EventEmitter}
*/
exports.detect = function detect(options, callback) {
return magik(options, callback, function (emitter, options, callback) {
async.parallel({
provisioning: function (next) {
provisioning.detect(options, next);
},
xcode: function (next) {
xcode.detect(options, next);
}
}, function (err, iosInfo) {
if (err) {
return callback(err);
}

var provisioning = iosInfo.provisioning.provisioning;
var xcodes = iosInfo.xcode.xcode;
var teams = {};

['development', 'adhoc', 'distribution'].forEach(function (type) {
provisioning[type].forEach(function (pp) {
if (Array.isArray(pp.team)) {
pp.team.forEach(function (id) {
teams[id] = id;
});
}
});
});

Object.keys(xcodes).forEach(function (xcodeId) {
var t = xcodes[xcodeId].teams;
Object.keys(t).forEach(function (id) {
teams[id] = t[id];
});
});

var results = {
teams: Object.keys(teams).map(function (id) {
var team = teams[id];
if (typeof team === 'string') {
return {
id: team,
name: 'Unknown',
};
}

return {
id: id,
name: team.name
};
})
};

emitter.emit('detected', results);
callback(null, results);
});
});
};
23 changes: 15 additions & 8 deletions lib/xcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @module xcode
*
* @copyright
* Copyright (c) 2014-2015 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2014-2016 by Appcelerator, Inc. All Rights Reserved.
*
* Copyright (c) 2010-2014 Digital Bazaar, Inc.
* {@link https://github.com/digitalbazaar/forge}
Expand Down Expand Up @@ -35,6 +35,7 @@ var cache,
* @param {Object} [options] - An object containing various settings.
* @param {Boolean} [options.bypassCache=false] - When true, re-detects all Xcode installations.
* @param {String|Array<String>} [options.searchPath] - One or more path to scan for Xcode installations.
* @param {String} [options.minTVosVersion] - The minimum AppleTV SDK to detect.
* @param {String} [options.minIosVersion] - The minimum iOS SDK to detect.
* @param {String} [options.minWatchosVersion] - The minimum WatchOS SDK to detect.
* @param {String} [options.sqlite] - Path to the <code>sqlite</code> executable (most likely named sqlite3)
Expand Down Expand Up @@ -112,18 +113,18 @@ exports.detect = function detect(options, callback) {
return vers.sort().reverse();
}

function findIosSims(dir, xcodeVer) {
var vers = findSDKs(dir, /^iPhoneSimulator(.+)\.sdk$/),
function findSims(dir, sdkRegExp, simRuntimeRegExp, minVer, xcodeVer) {
var vers = findSDKs(dir, sdkRegExp),
simRuntimesDir = '/Library/Developer/CoreSimulator/Profiles/Runtimes';

// for Xcode >=6.2 <7.0, the simulators are in a global directory
if (fs.existsSync(simRuntimesDir) && appc.version.gte(xcodeVer, '6.2')) {
if (fs.existsSync(simRuntimesDir) && (!xcodeVer || appc.version.gte(xcodeVer, '6.2'))) {
fs.readdirSync(simRuntimesDir).forEach(function (name) {
var file = path.join(simRuntimesDir, name);
if (!fs.existsSync(file) || !fs.statSync(file).isDirectory()) return;

var m = name.match(/^iOS (.+)\.simruntime$/);
if (m && (!options.minIosVersion || appc.version.gte(m[1], options.minIosVersion))) {
var m = name.match(simRuntimeRegExp);
if (m && (!minVer || appc.version.gte(m[1], minVer))) {
var ver = m[1];
file = path.join(file, 'Contents', 'Resources', 'RuntimeRoot', 'System', 'Library', 'CoreServices', 'SystemVersion.plist');
if (fs.existsSync(file)) {
Expand Down Expand Up @@ -228,7 +229,7 @@ exports.detect = function detect(options, callback) {
if (appc.version.gte(p.CFBundleShortVersionString, '7.0')) {
watchos = {
sdks: findSDKs(path.join(dir, 'Platforms', 'WatchOS.platform', 'Developer', 'SDKs'), /^WatchOS(.+)\.sdk$/, options.minWatchosVersion),
sims: findSDKs(path.join(dir, 'Platforms', 'WatchSimulator.platform', 'Developer', 'SDKs'), /^WatchSimulator(.+)\.sdk$/, options.minWatchosVersion)
sims: findSims(path.join(dir, 'Platforms', 'WatchSimulator.platform', 'Developer', 'SDKs'), /^WatchSimulator(.+)\.sdk$/, /^watchOS (.+)\.simruntime$/, options.minWatchosVersion)
};
} else if (appc.version.gte(p.CFBundleShortVersionString, '6.2')) {
watchos = {
Expand All @@ -237,6 +238,11 @@ exports.detect = function detect(options, callback) {
};
}

var tvos = {
sdks: findSDKs(path.join(dir, 'Platforms', 'AppleTVOS.platform', 'Developer', 'SDKs'), /^AppleTVOS(.+)\.sdk$/, options.minTVosVersion),
sims: findSims(path.join(dir, 'Platforms', 'AppleTVSimulator.platform', 'Developer', 'SDKs'), /^AppleTVSimulator(.+)\.sdk$/, /^tvOS (.+)\.simruntime$/, options.minTVosVersion)
};

var xc = results.xcode[ver] = {
xcodeapp: dir.replace(/\/Contents\/Developer\/?$/, ''),
path: dir,
Expand All @@ -246,10 +252,11 @@ exports.detect = function detect(options, callback) {
supported: supported,
eulaAccepted: false,
sdks: findSDKs(path.join(dir, 'Platforms', 'iPhoneOS.platform', 'Developer', 'SDKs'), /^iPhoneOS(.+)\.sdk$/, options.minIosVersion),
sims: findIosSims(path.join(dir, 'Platforms', 'iPhoneSimulator.platform', 'Developer', 'SDKs'), p.CFBundleShortVersionString),
sims: findSims(path.join(dir, 'Platforms', 'iPhoneSimulator.platform', 'Developer', 'SDKs'), /^iPhoneSimulator(.+)\.sdk$/, /^iPhoneOS(.+)\.sdk$/, options.minIosVersion, p.CFBundleShortVersionString),
simDeviceTypes: {},
simRuntimes: appc.util.mix({}, globalSimRuntimes),
watchos: watchos,
tvos: tvos,
teams: {},
executables: {
xcodebuild: fs.existsSync(f = path.join(dir, 'usr', 'bin', 'xcodebuild')) ? f : null,
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ioslib",
"version": "0.11.0",
"version": "0.12.0",
"description": "iOS Utility Library",
"keywords": [
"appcelerator",
Expand Down Expand Up @@ -41,12 +41,12 @@
"async": "1.5.2",
"bplist-parser": "0.1.1",
"mkdirp": "0.5.1",
"node-appc": "0.2.35",
"node-appc": "0.2.36",
"node-ios-device": "0.9.5"
},
"devDependencies": {
"mocha": "^2.4.5",
"should": "^8.2.2"
"mocha": "^2.5.3",
"should": "^9.0.2"
},
"scripts": {
"test": "mocha --require test/init --reporter spec --check-leaks test/",
Expand All @@ -56,6 +56,7 @@
"test-ioslib": "mocha --require test/init --reporter spec --check-leaks test/test-ioslib",
"test-provisioning": "mocha --require test/init --reporter spec --check-leaks test/test-provisioning",
"test-simulator": "mocha --require test/init --reporter spec --check-leaks test/test-simulator",
"test-teams": "mocha --require test/init --reporter spec --check-leaks test/test-teams",
"test-xcode": "mocha --require test/init --reporter spec --check-leaks test/test-xcode"
},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions test/test-ioslib.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('ioslib', function () {

should(results).be.an.Object;
should(results).have.keys('detectVersion', 'issues', 'devices', 'provisioning', 'executables', 'selectedXcode',
'xcode', 'certs', 'simulators');
'xcode', 'certs', 'teams', 'simulators');

should(results.detectVersion).be.a.String;

Expand Down Expand Up @@ -162,7 +162,7 @@ describe('ioslib', function () {

function checkXcode(xcode) {
should(xcode).be.an.Object;
should(xcode).have.keys('xcodeapp', 'path', 'selected', 'version', 'build', 'supported', 'eulaAccepted', 'sdks', 'sims', 'simDeviceTypes', 'simRuntimes', 'watchos', 'teams', 'executables');
should(xcode).have.keys('xcodeapp', 'path', 'selected', 'version', 'build', 'supported', 'eulaAccepted', 'sdks', 'sims', 'simDeviceTypes', 'simRuntimes', 'watchos', 'tvos', 'teams', 'executables');

should(xcode.xcodeapp).be.a.String;
should(xcode.xcodeapp).not.equal('');
Expand Down
59 changes: 59 additions & 0 deletions test/test-teams.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Tests ioslib's teams module.
*
* @copyright
* Copyright (c) 2016 by Appcelerator, Inc. All Rights Reserved.
*
* @license
* Licensed under the terms of the Apache Public License.
* Please see the LICENSE included with this distribution for details.
*/

const ioslib = require('..');

describe('teams', function () {
it('namespace should be an object', function () {
should(ioslib.teams).be.an.Object;
});

it('detect teams', function (done) {
this.timeout(5000);
this.slow(2000);

ioslib.teams.detect(function (err, results) {
if (err) {
return done(err);
}

validateResults(results);
done();
});
});

it('return a emitter', function (done) {
this.timeout(5000);
this.slow(2000);

ioslib.teams.detect({ bypassCache: true })
.on('detected', function (results) {
validateResults(results);
done();
})
.on('error', done);
});
});

function validateResults(results) {
should(results).be.an.Object;
should(results).have.keys('teams');
should(results.teams).be.an.Array;

results.teams.forEach(function (team) {
should(team).be.an.Object;
should(team).have.keys('id', 'name');
should(team.id).be.a.String;
should(team.id).not.equal('');
should(team.name).be.a.String;
should(team.name).not.equal('');
});
}
6 changes: 4 additions & 2 deletions test/test-xcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Tests ioslib's xcode module.
*
* @copyright
* Copyright (c) 2014-2015 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2014-2016 by Appcelerator, Inc. All Rights Reserved.
*
* @license
* Licensed under the terms of the Apache Public License.
Expand All @@ -15,7 +15,9 @@ const

function checkXcode(xcode) {
should(xcode).be.an.Object;
should(xcode).have.keys('xcodeapp', 'path', 'selected', 'version', 'build', 'supported', 'eulaAccepted', 'sdks', 'sims', 'simDeviceTypes', 'simRuntimes', 'watchos', 'teams', 'executables');
should(xcode).have.keys('xcodeapp', 'path', 'selected', 'version', 'build',
'supported', 'eulaAccepted', 'sdks', 'sims', 'simDeviceTypes',
'simRuntimes', 'watchos', 'tvos', 'teams', 'executables');

should(xcode.xcodeapp).be.a.String;
should(xcode.xcodeapp).not.equal('');
Expand Down