This repository has been archived by the owner on Nov 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 08c9a6a
Showing
8 changed files
with
277 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Fokke Zandbergen | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Ti-64 | ||
|
||
[![Dependencies](https://david-dm.org/fokkezb/ti-64/status.svg?style=flat-square)](https://david-dm.org/fokkezb/ti-html2as#info=dependencies) | ||
[![Dev Dependencies](https://david-dm.org/fokkezb/ti-64/dev-status.svg?style=flat-square)](https://david-dm.org/fokkezb/ti-html2as#info=devDependencies) | ||
|
||
Check all [Appcelerator Titanium](http://appcelerator.com/titanium) project and/or global modules for 64-bit iOS support. | ||
|
||
![screenshot](screenshot.png) | ||
|
||
## Install [![NPM version](https://badge.fury.io/js/ti-64.svg)](http://badge.fury.io/js/ti-64) | ||
|
||
As global CLI: | ||
|
||
$ npm install -g ti-64 | ||
|
||
As module: | ||
|
||
$ npm install ti-64 --save | ||
|
||
## Usage | ||
|
||
### CLI | ||
|
||
Check local and global modules required in a project's `tiapp.xml`: | ||
|
||
~/project $ ti-i64 | ||
$ ti-64 --project-dir ~/project | ||
|
||
Check all global modules: | ||
|
||
$ ti-64 --global | ||
|
||
### Module | ||
|
||
``` | ||
var ti64 = require('ti-64'); | ||
ti64({ | ||
projectDir: './project', | ||
global: false | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env node | ||
|
||
var program = require('commander'); | ||
|
||
var pkg = require('./package.json'); | ||
|
||
var ti64 = require('./index'); | ||
|
||
program | ||
.version(pkg.version, '-v, --version') | ||
.description(pkg.description) | ||
.option('-d, --project-dir [path]', 'the directory containing the project [.]', process.cwd()) | ||
.option('-g, --global', 'check all global modules'); | ||
|
||
program.parse(process.argv); | ||
|
||
ti64({ | ||
projectDir: program.projectDir, | ||
global: program.global | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// TODO: Alleen module ID+version tonen, niet volledig pad | ||
// TODO: Ook global modules (tiapp.xml uitlezen) | ||
|
||
var path = require('path'); | ||
|
||
var chalk = require('chalk'), | ||
timodules = require('timodules'), | ||
_ = require('lodash'); | ||
|
||
var xcrun = require('./lib/xcrun'); | ||
|
||
module.exports = function ti64(opts) { | ||
opts || (opts = {}); | ||
|
||
var projectDir = path.resolve(opts.projectDir); | ||
|
||
timodules.list(projectDir, function handle(err, res) { | ||
var allProjectModules, allGlobalModules, selectedGlobalModules = [], | ||
selectedProjectModules = []; | ||
|
||
if (err) { | ||
console.error(chalk.red(err)); | ||
process.exit(1); | ||
|
||
} else { | ||
allProjectModules = flatten(res.modules.project.iphone, false); | ||
allGlobalModules = flatten(res.modules.global.iphone, true); | ||
|
||
if (!opts.global) { | ||
selectedProjectModules = []; | ||
selectedGlobalModules = []; | ||
|
||
res.current.forEach(function forEach(currentModule) { | ||
var matchedModules; | ||
|
||
if ((currentModule.platform === undefined || currentModule.platform === 'iphone')) { | ||
matchedModules = _.filter(allProjectModules, filter, currentModule); | ||
|
||
if (matchedModules.length > 0) { | ||
selectedProjectModules = selectedProjectModules.concat(matchedModules); | ||
|
||
} else { | ||
selectedGlobalModules = selectedGlobalModules.concat(_.filter(allGlobalModules, filter, currentModule)); | ||
} | ||
} | ||
|
||
}); | ||
|
||
} else { | ||
selectedGlobalModules = allGlobalModules; | ||
} | ||
|
||
if (selectedProjectModules.length + selectedGlobalModules.length > 0) { | ||
|
||
if (selectedProjectModules.length > 0) { | ||
check(selectedProjectModules); | ||
} | ||
|
||
if (selectedGlobalModules) { | ||
check(selectedGlobalModules); | ||
} | ||
|
||
} else { | ||
console.warn('No modules found'); | ||
} | ||
} | ||
|
||
}); | ||
|
||
}; | ||
|
||
function filter(module) { | ||
var wantedModule = this; | ||
|
||
return (module.name === wantedModule.name && (wantedModule.version === undefined || wantedModule.version === module.version)); | ||
} | ||
|
||
function flatten(modules, global) { | ||
var flat = []; | ||
|
||
_.each(modules, function forEach(versions, name) { | ||
|
||
_.each(versions, function forEach(info, version) { | ||
|
||
flat.push({ | ||
name: name, | ||
platform: 'iphone', | ||
version: version, | ||
path: info.modulePath, | ||
global: global | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
return flat; | ||
} | ||
|
||
function check(modules) { | ||
|
||
modules.forEach(function forEach(module) { | ||
var prefix = chalk.yellow(module.name) + ':' + chalk.cyan(module.version) + '@' + chalk.yellow(module.global ? 'global' : 'project') + ' '; | ||
|
||
xcrun.getArchitectures(path.join(module.path, 'lib' + module.name + '.a'), function handle(err, architectures) { | ||
|
||
if (err) { | ||
console.error(prefix + chalk.red(err)); | ||
|
||
} else { | ||
|
||
if (architectures.indexOf('x86_64') !== -1 && architectures.indexOf('arm64') !== -1) { | ||
console.log(prefix + chalk.green(architectures.join(' '))); | ||
} else { | ||
console.error(prefix + chalk.red(architectures.join(' '))); | ||
} | ||
} | ||
|
||
}); | ||
|
||
}); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var child_process = require('child_process'); | ||
|
||
var REGEXP_ARCHITECTURES = / are: (.+) \n$/; | ||
|
||
exports.getArchitectures = function getArchitectures(path, callback) { | ||
var spawned = child_process.spawn('xcrun', ['lipo', '-info', path]); | ||
var output = ''; | ||
|
||
spawned.stdout.on('data', function(data) { | ||
output += data.toString(); | ||
}); | ||
|
||
spawned.on('close', function(code) { | ||
|
||
if (code !== 0) { | ||
callback('Failed to read architectures'); | ||
|
||
} else { | ||
|
||
var matches = output.match(REGEXP_ARCHITECTURES); | ||
|
||
if (matches === null) { | ||
callback('Failed to extract architectures'); | ||
} | ||
|
||
var architectures = matches[1].split(' '); | ||
|
||
callback(null, architectures); | ||
} | ||
|
||
}); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "ti-64", | ||
"version": "1.0.0", | ||
"description": "Check all Appcelerator Titanium project and/or global modules for 64-bit iOS support.", | ||
"main": "index.js", | ||
"bin": { | ||
"ti-64": "./cli.js" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/fokkezb/ti-64.git" | ||
}, | ||
"keywords": [ | ||
"ios", | ||
"titanium", | ||
"appcelerator", | ||
"64bit", | ||
"arm64", | ||
"x86_64", | ||
"cli" | ||
], | ||
"author": "Fokke Zandbergen", | ||
"license": "Apache Public License v2", | ||
"bugs": { | ||
"url": "https://github.com/fokkezb/ti-64/issues" | ||
}, | ||
"homepage": "https://github.com/fokkezb/ti-64", | ||
"dependencies": { | ||
"chalk": "^0.5.1", | ||
"commander": "^2.6.0", | ||
"lodash": "^2.4.1", | ||
"timodules": "^0.1.1" | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.