Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
iOS and Titanium SDK checks, user input config
  • Loading branch information
Mindelusions committed Feb 12, 2012
1 parent dd0281b commit e4d64f9
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
.DS_Store
node_modules
1 change: 1 addition & 0 deletions index.js
@@ -0,0 +1 @@
module.exports = require('./lib/titanium');
121 changes: 121 additions & 0 deletions lib/configure.js
@@ -0,0 +1,121 @@
#!/usr/bin/env node

var fs = require('fs'),
p = require('commander'),
path = require('path'),
exec = require('child_process').exec,
consta = require('./constants'),
child = null,
props = {},
platform = process.platform,
configPrompts = [
{
name: 'appIdPrefix',
msg: 'Application ID Prefix [com.youcompany]:'
},
{
name: 'appPublisher',
msg: 'Default Application Publisher [YourCompany, Inc.]:'
},
{
name: 'appPublisherURL',
msg: 'Default Publisher URL [yourcompany.com]:'
},
{
name: 'appCopyright',
msg: 'Default Copyright Message [2011 YourCompany, Inc.]:'

}],
i = 0, len = configPrompts.length;

console.log('Configuring Titanium CLI.');

function getUserConfig() {
// This is just effin ridiculous!
p.prompt('Application ID Prefix [com.youcompany]:', function(val) {
props.appIdPrefix = val;

p.prompt('Default Application Publisher [YourCompany, Inc.]:', function(val) {
props.appPublisher = val;

p.prompt('Default Publisher URL [yourcompany.com]:', function(val) {
props.appPublisherURL = val;

p.prompt('Default Copyright Message [2011 YourCompany, Inc.]:', function(val) {
props.appCopyright = val;
process.stdin.destroy();
console.log(JSON.stringify(props));
});
});
});
});
}

function mobileSDKLocator() {
fs.readdir(props.sdkRoot, function(err, files) {
if (err) throw err;
if (files.length > 1) {
console.log('Titanium SDK located!');
getUserConfig();
} else {
// Download and install latest sdk
console.log('Downloading latest Titanium SDK ..');
}
});
}

function iOSSDKLocator() {
console.log('Locating iOS SDKs ... ');

child = exec("xcode-select -print-path", function(err, stdout, stderr) {
if (err) throw err;

var developerPath = stdout.replace('\n','');
fs.stat(developerPath, function(error, stats) {
if (error) throw error;
if (stats.isDirectory()) {
props.developerPath = developerPath;
console.log('Found developer path!');

var subchild = exec("xcodebuild -showsdks", function(err, stdout, stderr) {
if (err) throw err;
var sdkRoot = path.join(props.developerPath, 'Platforms/iPhoneSimulator.platform/Developer/SDKs');
fs.stat(sdkRoot, function(error, stats) {
if (error) throw error;
if(stats.isDirectory()) {
console.log('Found iOS SDKs!');
mobileSDKLocator();
}
});
});
} else {
console.log('Could not detect a path to the Xcode folder');
}
});
});


}





if (platform === 'darwin') {
props.sdkRoot = consta.SDK_ROOT_PATH_MACOSX;
props.mobileSdkRoot = path.join(props.sdkRoot, 'mobilesdk/osx');
props.modulesDir = path.join(props.sdkRoot, 'modules');
iOSSDKLocator();
}

if (platform === 'linux') {
props.sdkRoot = consta.SDK_ROOT_PATH_LINUX;
props.mobileSdkRoot = path.join(props.sdkRoot, 'mobilesdk/linux');
props.modulesDir = path.join(props.sdkRoot, 'modules');
}

if (platform === 'win32') {
props.sdkRoot = consta.SDK_ROOT_PATH_WIN32;
props.mobileSdkRoot = path.join(props.sdkRoot, 'mobilesdk\\win32');
props.modulesDir = path.join(props.sdkRoot, 'modules');
}
8 changes: 8 additions & 0 deletions lib/constants.js
@@ -0,0 +1,8 @@
#!/usr/bin/env node

module.exports = {
SDK_ROOT_PATH_LINUX:"~/.titanium/",
SDK_ROOT_PATH_WIN32:"%APPDATA%\\Titanium\\",
SDK_ROOT_PATH_MACOSX:"/Library/Application Support/Titanium/",
SDK_ROOT_PATH_MACOSX_ALT:"~/Library/Application Support/Titanium/"
};
15 changes: 15 additions & 0 deletions lib/titanium
@@ -0,0 +1,15 @@
#!/usr/bin/env node

/**
* Dependencies
*/

var p = require('commander');
p
.version('0.0.1')
.option('configure', 'CLI configuration options')
.parse(process.argv);

if (p.configure) {
module.exports = require('./configure');
}
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -2,4 +2,5 @@
, "description": "Appcelerator Titanium CLI package"
, "version": "0.0.1"
, "author": "Anthony A. Decena <adecena@appcelerator.com>"
, "main": "index"
}

0 comments on commit e4d64f9

Please sign in to comment.