use cordova, not phonegap

This commit is contained in:
Manuel Friedli 2015-03-05 17:26:23 +01:00
parent 445ddeab85
commit 72c3cd0c06
364 changed files with 55371 additions and 0 deletions

View file

@ -0,0 +1,27 @@
#!/usr/bin/env node
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
var versions = require('./lib/versions.js');
versions.get_apple_ios_version().done(null, function(err) {
console.log(err);
process.exit(2);
});

View file

@ -0,0 +1,27 @@
#!/usr/bin/env node
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
var versions = require('./lib/versions.js');
versions.get_apple_osx_version().done(null, function(err) {
console.log(err);
process.exit(2);
});

View file

@ -0,0 +1,29 @@
#!/usr/bin/env node
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
var versions = require('./lib/versions.js');
versions.get_apple_xcode_version().done(function (version) {
console.log(version);
}, function(err) {
console.error(err);
process.exit(2);
});

View file

@ -0,0 +1,36 @@
#!/usr/bin/env node
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
var build = require('./lib/build'),
args = process.argv;
// Handle help flag
if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(args[2]) > -1) {
build.help();
} else {
build.run(args).done(function() {
console.log('** BUILD SUCCEEDED **');
}, function(err) {
var errorMessage = (err && err.stack) ? err.stack : err;
console.error(errorMessage);
process.exit(2);
});
}

View file

@ -0,0 +1,24 @@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
//
// XCode Build settings for "Debug" Build Configuration.
//
#include "build.xcconfig"

View file

@ -0,0 +1,27 @@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
//
// XCode Build settings for "Release" Build Configuration.
//
#include "build.xcconfig"
CODE_SIGN_IDENTITY = iPhone Distribution
CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Distribution

View file

@ -0,0 +1,32 @@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
//
// XCode build settings shared by all Build Configurations.
// Settings are overridden by configuration-level .xcconfig file (build-release/build-debug).
//
// Type of signing identity used for codesigning, resolves to first match of given type.
// "iPhone Developer": Development builds (default, local only; iOS Development certificate) or "iPhone Distribution": Distribution builds (Adhoc/In-House/AppStore; iOS Distribution certificate)
CODE_SIGN_IDENTITY = iPhone Developer
CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Developer
// (CB-7872) Solution for XCode 6.1 signing errors related to resource envelope format deprecation
CODE_SIGN_RESOURCE_RULES_PATH = $(SDKROOT)/ResourceRules.plist

View file

@ -0,0 +1,32 @@
#!/usr/bin/env node
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
var check_reqs = require('./lib/check_reqs');
// check for help flag
if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) > -1) {
check_reqs.help();
} else {
check_reqs.run().done(null, function (err) {
console.error('Failed to check requirements due to ' + err);
process.exit(2);
});
}

View file

@ -0,0 +1,29 @@
#!/usr/bin/env node
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
var clean = require('./lib/clean');
clean.run(process.argv).done(function () {
console.log('** CLEAN SUCCEEDED **');
}, function(err) {
console.error(err);
process.exit(2);
});

View file

@ -0,0 +1,25 @@
:: Licensed to the Apache Software Foundation (ASF) under one
:: or more contributor license agreements. See the NOTICE file
:: distributed with this work for additional information
:: regarding copyright ownership. The ASF licenses this file
:: to you under the Apache License, Version 2.0 (the
:: "License"); you may not use this file except in compliance
:: with the License. You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing,
:: software distributed under the License is distributed on an
:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
:: KIND, either express or implied. See the License for the
:: specific language governing permissions and limitations
:: under the License
@ECHO OFF
SET script_path="%~dp0clean"
IF EXIST %script_path% (
node %script_path% %*
) ELSE (
ECHO.
ECHO ERROR: Could not find 'clean' script in 'cordova' folder, aborting...>&2
EXIT /B 1
)

View file

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<widget xmlns = "http://www.w3.org/ns/widgets"
id = "io.cordova.helloCordova"
version = "2.0.0">
<!-- Preferences for iOS -->
<preference name="AllowInlineMediaPlayback" value="false" />
<preference name="BackupWebStorage" value="cloud" />
<preference name="DisallowOverscroll" value="false" />
<preference name="EnableViewportScale" value="false" />
<preference name="KeyboardDisplayRequiresUserAction" value="true" />
<preference name="MediaPlaybackRequiresUserAction" value="false" />
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="GapBetweenPages" value="0" />
<preference name="PageLength" value="0" />
<preference name="PaginationBreakingMode" value="page" /> <!-- page, column -->
<preference name="PaginationMode" value="unpaginated" /> <!-- unpaginated, leftToRight, topToBottom, bottomToTop, rightToLeft -->
<feature name="LocalStorage">
<param name="ios-package" value="CDVLocalStorage"/>
</feature>
</widget>

View file

@ -0,0 +1,148 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*jshint node: true*/
var Q = require('q'),
nopt = require('nopt'),
path = require('path'),
shell = require('shelljs'),
spawn = require('./spawn'),
check_reqs = require('./check_reqs');
var projectPath = path.join(__dirname, '..', '..');
module.exports.run = function (argv) {
var args = nopt({
// "archs": String, // TODO: add support for building different archs
'debug': Boolean,
'release': Boolean,
'device': Boolean,
'emulator': Boolean,
}, {'-r': '--release'}, argv);
if (args.debug && args.release) {
return Q.reject('Only one of "debug"/"release" options should be specified');
}
if (args.device && args.emulator) {
return Q.reject('Only one of "device"/"emulator" options should be specified');
}
return check_reqs.run().then(function () {
return findXCodeProjectIn(projectPath);
}).then(function (projectName) {
var configuration = args.release ? 'Release' : 'Debug';
console.log('Building project : ' + path.join(projectPath, projectName + '.xcodeproj'));
console.log('\tConfiguration : ' + configuration);
console.log('\tPlatform : ' + (args.device ? 'device' : 'emulator'));
var xcodebuildArgs = getXcodeArgs(projectName, projectPath, configuration, args.device);
return spawn('xcodebuild', xcodebuildArgs, projectPath);
});
};
/**
* Searches for first XCode project in specified folder
* @param {String} projectPath Path where to search project
* @return {Promise} Promise either fulfilled with project name or rejected
*/
function findXCodeProjectIn(projectPath) {
// 'Searching for Xcode project in ' + projectPath);
var xcodeProjFiles = shell.ls(projectPath).filter(function (name) {
return path.extname(name) === '.xcodeproj';
});
if (xcodeProjFiles.length === 0) {
return Q.reject('No Xcode project found in ' + projectPath);
}
if (xcodeProjFiles.length > 1) {
console.warn('Found multiple .xcodeproj directories in \n' +
projectPath + '\nUsing first one');
}
var projectName = path.basename(xcodeProjFiles[0], '.xcodeproj');
return Q.resolve(projectName);
}
module.exports.findXCodeProjectIn = findXCodeProjectIn;
/**
* Returns array of arguments for xcodebuild
* @param {String} projectName Name of xcode project
* @param {String} projectPath Path to project file. Will be used to set CWD for xcodebuild
* @param {String} configuration Configuration name: debug|release
* @param {Boolean} isDevice Flag that specify target for package (device/emulator)
* @return {Array} Array of arguments that could be passed directly to spawn method
*/
function getXcodeArgs(projectName, projectPath, configuration, isDevice) {
var xcodebuildArgs;
if (isDevice) {
xcodebuildArgs = [
'-xcconfig', path.join(__dirname, '..', 'build-' + configuration.toLowerCase() + '.xcconfig'),
'-project', projectName + '.xcodeproj',
'ARCHS=armv7 armv7s arm64',
'-target', projectName,
'-configuration', configuration,
'-sdk', 'iphoneos',
'build',
'VALID_ARCHS=armv7 armv7s arm64',
'CONFIGURATION_BUILD_DIR=' + path.join(projectPath, 'build', 'device'),
'SHARED_PRECOMPS_DIR=' + path.join(projectPath, 'build', 'sharedpch')
];
} else { // emulator
xcodebuildArgs = [
'-xcconfig', path.join(__dirname, '..', 'build-' + configuration.toLowerCase() + '.xcconfig'),
'-project', projectName + '.xcodeproj',
'ARCHS=i386',
'-target', projectName ,
'-configuration', configuration,
'-sdk', 'iphonesimulator',
'build',
'VALID_ARCHS=i386',
'CONFIGURATION_BUILD_DIR=' + path.join(projectPath, 'build', 'emulator'),
'SHARED_PRECOMPS_DIR=' + path.join(projectPath, 'build', 'sharedpch')
];
}
return xcodebuildArgs;
}
// help/usage function
module.exports.help = function help() {
console.log('');
console.log('Usage: build [ --debug | --release ] [--archs=\"<list of architectures...>\"] [--device | --simulator]');
console.log(' --help : Displays this dialog.');
console.log(' --debug : Builds project in debug mode. (Default)');
console.log(' --release : Builds project in release mode.');
console.log(' -r : Shortcut :: builds project in release mode.');
// TODO: add support for building different archs
// console.log(" --archs : Builds project binaries for specific chip architectures (`anycpu`, `arm`, `x86`, `x64`).");
console.log(' --device, --simulator');
console.log(' : Specifies, what type of project to build');
console.log('examples:');
console.log(' build ');
console.log(' build --debug');
console.log(' build --release');
// TODO: add support for building different archs
// console.log(" build --release --archs=\"armv7\"");
console.log('');
process.exit(0);
};

View file

@ -0,0 +1,94 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
indent:4, unused:vars, latedef:nofunc,
sub:true, laxcomma:true, laxbreak:true
*/
var Q = require('Q'),
os = require('os'),
shell = require('shelljs'),
versions = require('./versions');
var XCODEBUILD_MIN_VERSION = '4.6.0';
var IOS_SIM_MIN_VERSION = '3.0.0';
var IOS_SIM_NOT_FOUND_MESSAGE = 'ios-sim was not found. Please download, build and install version ' + IOS_SIM_MIN_VERSION +
' or greater from https://github.com/phonegap/ios-sim into your path.' +
' Or \'npm install -g ios-sim\' using node.js: http://nodejs.org';
var IOS_DEPLOY_MIN_VERSION = '1.2.0';
var IOS_DEPLOY_NOT_FOUND_MESSAGE = 'ios-deploy was not found. Please download, build and install version ' + IOS_DEPLOY_MIN_VERSION +
' or greater from https://github.com/phonegap/ios-deploy into your path.' +
' Or \'npm install -g ios-deploy\' using node.js: http://nodejs.org';
/**
* Checks if xcode util is available
* @return {Promise} Returns a promise either resolved with xcode version or rejected
*/
module.exports.run = module.exports.check_xcodebuild = function () {
return checkTool('xcodebuild', XCODEBUILD_MIN_VERSION);
};
/**
* Checks if ios-deploy util is available
* @return {Promise} Returns a promise either resolved with ios-deploy version or rejected
*/
module.exports.check_ios_deploy = function () {
return checkTool('ios-deploy', IOS_DEPLOY_MIN_VERSION, IOS_DEPLOY_NOT_FOUND_MESSAGE);
};
/**
* Checks if ios-sim util is available
* @return {Promise} Returns a promise either resolved with ios-sim version or rejected
*/
module.exports.check_ios_sim = function () {
return checkTool('ios-sim', IOS_SIM_MIN_VERSION, IOS_SIM_NOT_FOUND_MESSAGE);
};
module.exports.help = function () {
console.log('Usage: check_reqs or node check_reqs');
};
/**
* Checks if specific tool is available.
* @param {String} tool Tool name to check. Known tools are 'xcodebuild', 'ios-sim' and 'ios-deploy'
* @param {Number} minVersion Min allowed tool version.
* @param {String} optMessage Message that will be used to reject promise.
* @return {Promise} Returns a promise either resolved with tool version or rejected
*/
function checkTool (tool, minVersion, optMessage) {
if (os.platform() !== 'darwin'){
// Build iOS apps available for OSX platform only, so we reject on others platforms
return Q.reject('Cordova tooling for iOS requires Apple OS X');
}
// Check whether tool command is available at all
var tool_command = shell.which(tool);
if (!tool_command) {
return Q.reject(optMessage || (tool + 'command is unavailable.'));
}
// check if tool version is greater than specified one
return versions.get_tool_version(tool).then(function (version) {
return versions.compareVersions(version, minVersion) >= 0 ?
Q.resolve(version) :
Q.reject('Cordova needs ' + tool + ' version ' + minVersion +
' or greater, you have version ' + version + '.');
});
}

View file

@ -0,0 +1,46 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*jshint node: true*/
var Q = require('q'),
path = require('path'),
shell = require('shelljs'),
spawn = require('./spawn'),
check_reqs = require('./check_reqs');
var projectPath = path.join(__dirname, '..', '..');
module.exports.run = function() {
var projectName = shell.ls(projectPath).filter(function (name) {
return path.extname(name) === '.xcodeproj';
})[0];
if (!projectName) {
return Q.reject('No Xcode project found in ' + projectPath);
}
return check_reqs.run().then(function() {
return spawn('xcodebuild', ['-project', projectName, '-configuration', 'Debug', '-alltargets', 'clean'], projectPath);
}).then(function () {
return spawn('xcodebuild', ['-project', projectName, '-configuration', 'Release', '-alltargets', 'clean'], projectPath);
}).then(function () {
return shell.rm('-rf', path.join(projectPath, 'build'));
});
};

View file

@ -0,0 +1,87 @@
#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
# This script copies the www directory into the Xcode project.
#
# This script should not be called directly.
# It is called as a build step from Xcode.
SRC_DIR="www/"
DST_DIR="$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME/www"
COPY_HIDDEN=
ORIG_IFS=$IFS
IFS=$(echo -en "\n\b")
if [[ -z "$BUILT_PRODUCTS_DIR" ]]; then
echo "The script is meant to be run as an Xcode build step and relies on env variables set by Xcode."
exit 1
fi
if [[ ! -e "$SRC_DIR" ]]; then
echo "Path does not exist: $SRC_DIR"
exit 1
fi
# Use full path to find to avoid conflict with macports find (CB-6383).
if [[ -n $COPY_HIDDEN ]]; then
alias do_find='/usr/bin/find "$SRC_DIR"'
else
alias do_find='/usr/bin/find -L "$SRC_DIR" -name ".*" -prune -o'
fi
time (
# Code signing files must be removed or else there are
# resource signing errors.
rm -rf "$DST_DIR" \
"$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME/_CodeSignature" \
"$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME/PkgInfo" \
"$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME/embedded.mobileprovision"
# Directories
for p in $(do_find -type d -print); do
subpath="${p#$SRC_DIR}"
mkdir "$DST_DIR$subpath" || exit 1
done
# Symlinks
for p in $(do_find -type l -print); do
subpath="${p#$SRC_DIR}"
source=$(readlink $SRC_DIR$subpath)
sourcetype=$(stat -f "%HT%SY" $source)
if [ "$sourcetype" = "Directory" ]; then
mkdir "$DST_DIR$subpath" || exit 2
else
rsync -a "$source" "$DST_DIR$subpath" || exit 3
fi
done
# Files
for p in $(do_find -type f -print); do
subpath="${p#$SRC_DIR}"
if ! ln "$SRC_DIR$subpath" "$DST_DIR$subpath" 2>/dev/null; then
rsync -a "$SRC_DIR$subpath" "$DST_DIR$subpath" || exit 4
fi
done
# Copy the config.xml file.
cp -f "${PROJECT_FILE_PATH%.xcodeproj}/config.xml" "$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME"
)
IFS=$ORIG_IFS

View file

@ -0,0 +1,62 @@
#!/usr/bin/env node
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
/*jshint node: true*/
var Q = require('Q'),
exec = require('child_process').exec;
/**
* Gets list of connected iOS devices
* @return {Promise} Promise fulfilled with list of available iOS devices
*/
function listDevices() {
var commands = [
Q.nfcall(exec, 'system_profiler SPUSBDataType | sed -n -e \'/iPad/,/Serial/p\' | grep "Serial Number:" | awk -F ": " \'{print $2 " iPad"}\''),
Q.nfcall(exec, 'system_profiler SPUSBDataType | sed -n -e \'/iPhone/,/Serial/p\' | grep "Serial Number:" | awk -F ": " \'{print $2 " iPhone"}\''),
Q.nfcall(exec, 'system_profiler SPUSBDataType | sed -n -e \'/iPod/,/Serial/p\' | grep "Serial Number:" | awk -F ": " \'{print $2 " iPod"}\'')
];
// wrap al lexec calls into promises and wait until they're fullfilled
return Q.all(commands).then(function (promises) {
var accumulator = [];
promises.forEach(function (promise) {
if (promise.state === 'fulfilled') {
// Each command promise resolves with array [stout, stderr], and we need stdout only
// Append stdout lines to accumulator
accumulator.concat(promise.value[0].trim().split('\n'));
}
});
return accumulator;
});
}
exports.run = listDevices;
// Check if module is started as separate script.
// If so, then invoke main method and print out results.
if (!module.parent) {
listDevices().then(function (devices) {
devices.forEach(function (device) {
console.log(device);
});
});
}

View file

@ -0,0 +1,53 @@
#!/usr/bin/env node
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
/*jshint node: true*/
var Q = require('q'),
exec = require('child_process').exec,
check_reqs = require('./check_reqs');
/**
* Gets list of iOS devices available for simulation
* @return {Promise} Promise fulfilled with list of devices available for simulation
*/
function listEmulatorImages () {
return check_reqs.check_ios_sim().then(function () {
return Q.nfcall(exec, 'ios-sim showdevicetypes 2>&1 | ' +
'sed "s/com.apple.CoreSimulator.SimDeviceType.//g" | ' +
'awk -F\',\' \'{print $1}\'');
}).then(function (stdio) {
// Exec promise resolves with array [stout, stderr], and we need stdout only
return stdio[0].trim().split('\n');
});
}
exports.run = listEmulatorImages;
// Check if module is started as separate script.
// If so, then invoke main method and print out results.
if (!module.parent) {
listEmulatorImages().then(function (names) {
names.forEach(function (name) {
console.log(name);
});
});
}

View file

@ -0,0 +1,51 @@
#!/usr/bin/env node
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
/*jshint node: true*/
var Q = require('q'),
exec = require('child_process').exec;
/**
* Gets list of running iOS simulators
* @return {Promise} Promise fulfilled with list of running iOS simulators
*/
function listStartedEmulators () {
// wrap exec call into promise
return Q.nfcall(exec, 'ps aux | grep -i "[i]OS Simulator"')
.then(function () {
return Q.nfcall(exec, 'defaults read com.apple.iphonesimulator "SimulateDevice"');
}).then(function (stdio) {
return stdio[0].trim().split('\n');
});
}
exports.run = listStartedEmulators;
// Check if module is started as separate script.
// If so, then invoke main method and print out results.
if (!module.parent) {
listStartedEmulators().then(function (emulators) {
emulators.forEach(function (emulator) {
console.log(emulator);
});
});
}

View file

@ -0,0 +1,177 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
/*jshint node: true*/
var Q = require('q'),
nopt = require('nopt'),
path = require('path'),
build = require('./build'),
spawn = require('./spawn'),
check_reqs = require('./check_reqs');
var cordovaPath = path.join(__dirname, '..');
var projectPath = path.join(__dirname, '..', '..');
module.exports.run = function (argv) {
// parse args here
// --debug and --release args not parsed here
// but still valid since they can be passed down to build command
var args = nopt({
// "archs": String, // TODO: add support for building different archs
'list': Boolean,
'nobuild': Boolean,
'device': Boolean, 'emulator': Boolean, 'target': String
}, {}, argv);
// Validate args
if (args.device && args.emulator) {
return Q.reject('Only one of "device"/"emulator" options should be specified');
}
// validate target device for ios-sim
// Valid values for "--target" (case sensitive):
var validTargets = ['iPhone-4s', 'iPhone-5', 'iPhone-5s', 'iPhone-6-Plus', 'iPhone-6',
'iPad-2', 'iPad-Retina', 'iPad-Air', 'Resizable-iPhone', 'Resizable-iPad'];
if (args.target && validTargets.indexOf(args.target) < 0 ) {
return Q.reject(args.target + ' is not a valid target for emulator');
}
// support for CB-8168 `cordova/run --list`
if (args.list) {
if (args.device) return listDevices();
if (args.emulator) return listEmulators();
// if no --device or --emulator flag is specified, list both devices and emulators
return listDevices().then(function () {
return listEmulators();
});
}
// check for either ios-sim or ios-deploy is available
// depending on arguments provided
var checkTools = args.device ? check_reqs.check_ios_deploy() : check_reqs.check_ios_sim();
return checkTools.then(function () {
// if --nobuild isn't specified then build app first
if (!args.nobuild) {
return build.run(argv);
}
}).then(function () {
return build.findXCodeProjectIn(projectPath);
}).then(function (projectName) {
var appPath = path.join(projectPath, 'build', (args.device ? 'device' : 'emulator'), projectName + '.app');
// select command to run and arguments depending whether
// we're running on device/emulator
if (args.device) {
return checkDeviceConnected().then(function () {
return deployToDevice(appPath);
}, function () {
// if device connection check failed use emulator then
return deployToSim(appPath, args.target);
});
} else {
return deployToSim(appPath, args.target);
}
});
};
/**
* Checks if any iOS device is connected
* @return {Promise} Fullfilled when any device is connected, rejected otherwise
*/
function checkDeviceConnected() {
return spawn('ios-deploy', ['-c']);
}
/**
* Deploy specified app package to connected device
* using ios-deploy command
* @param {String} appPath Path to application package
* @return {Promise} Resolves when deploy succeeds otherwise rejects
*/
function deployToDevice(appPath) {
// Deploying to device...
return spawn('ios-deploy', ['-d', '-b', appPath]);
}
/**
* Deploy specified app package to ios-sim simulator
* @param {String} appPath Path to application package
* @param {String} target Target device type
* @return {Promise} Resolves when deploy succeeds otherwise rejects
*/
function deployToSim(appPath, target) {
// Select target device for emulator. Default is 'iPhone-6'
if (!target) {
target = 'iPhone-6';
console.log('No target specified for emulator. Deploying to ' + target + ' simulator');
}
var logPath = path.join(cordovaPath, 'console.log');
var simArgs = ['launch', appPath,
'--devicetypeid', 'com.apple.CoreSimulator.SimDeviceType.' + target,
// We need to redirect simulator output here to use cordova/log command
// TODO: Is there any other way to get emulator's output to use in log command?
'--stderr', logPath, '--stdout', logPath,
'--exit'];
return spawn('ios-sim', simArgs);
}
function listDevices() {
return require('./list-devices').run()
.then(function (devices) {
console.log('Available iOS Devices:');
devices.forEach(function (device) {
console.log('\t' + device);
});
});
}
function listEmulators() {
return require('./list-emulator-images').run()
.then(function (emulators) {
console.log('Available iOS Virtual Devices:');
emulators.forEach(function (emulator) {
console.log('\t' + emulator);
});
});
}
module.exports.help = function () {
console.log('\nUsage: run [ --device | [ --emulator [ --target=<id> ] ] ] [ --debug | --release | --nobuild ]');
// TODO: add support for building different archs
// console.log(" [ --archs=\"<list of target architectures>\" ] ");
console.log(' --device : Deploys and runs the project on the connected device.');
console.log(' --emulator : Deploys and runs the project on an emulator.');
console.log(' --target=<id> : Deploys and runs the project on the specified target.');
console.log(' --debug : Builds project in debug mode. (Passed down to build command, if necessary)');
console.log(' --release : Builds project in release mode. (Passed down to build command, if necessary)');
console.log(' --nobuild : Uses pre-built package, or errors if project is not built.');
// TODO: add support for building different archs
// console.log(" --archs : Specific chip architectures (`anycpu`, `arm`, `x86`, `x64`).");
console.log('');
console.log('Examples:');
console.log(' run');
console.log(' run --device');
console.log(' run --emulator --target=\"iPhone-6-Plus\"');
console.log(' run --device --release');
console.log(' run --emulator --debug');
console.log('');
process.exit(0);
};

View file

@ -0,0 +1,50 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
/*jshint node: true*/
var Q = require('q'),
proc = require('child_process');
/**
* Run specified command with arguments
* @param {String} cmd Command
* @param {Array} args Array of arguments that should be passed to command
* @param {String} opt_cwd Working directory for command
* @param {String} opt_verbosity Verbosity level for command stdout output, "verbose" by default
* @return {Promise} Promise either fullfilled or rejected with error code
*/
module.exports = function(cmd, args, opt_cwd) {
var d = Q.defer();
try {
var child = proc.spawn(cmd, args, {cwd: opt_cwd, stdio: 'inherit'});
child.on('exit', function(code) {
if (code) {
d.reject('Error code ' + code + ' for command: ' + cmd + ' with args: ' + args);
} else {
d.resolve();
}
});
} catch(e) {
console.error('error caught: ' + e);
d.reject(e);
}
return d.promise;
};

View file

@ -0,0 +1,30 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# Run the below to get the device targets:
# xcrun instruments -s
set -e
DEFAULT_TARGET="iPhone 5s"
TARGET=${1:-$DEFAULT_TARGET}
LIB_PATH=$( cd "$( dirname "$0" )" && pwd -P)
xcrun instruments -w "$TARGET" &> /dev/null

View file

@ -0,0 +1,178 @@
#!/usr/bin/env node
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
var child_process = require('child_process'),
Q = require('q');
exports.get_apple_ios_version = function() {
var d = Q.defer();
child_process.exec('xcodebuild -showsdks', function(error, stdout, stderr) {
if (error) {
d.reject(stderr);
}
else {
d.resolve(stdout);
}
});
return d.promise.then(function(output) {
var regex = /[0-9]*\.[0-9]*/,
versions = [],
regexIOS = /^iOS \d+/;
output = output.split('\n');
for (var i = 0; i < output.length; i++) {
if (output[i].trim().match(regexIOS)) {
versions[versions.length] = parseFloat(output[i].match(regex)[0]);
}
}
versions.sort();
console.log(versions[0]);
return Q();
}, function(stderr) {
return Q.reject(stderr);
});
};
exports.get_apple_osx_version = function() {
var d = Q.defer();
child_process.exec('xcodebuild -showsdks', function(error, stdout, stderr) {
if (error) {
d.reject(stderr);
}
else {
d.resolve(stdout);
}
});
return d.promise.then(function(output) {
var regex = /[0-9]*\.[0-9]*/,
versions = [],
regexOSX = /^OS X \d+/;
output = output.split('\n');
for (var i = 0; i < output.length; i++) {
if (output[i].trim().match(regexOSX)) {
versions[versions.length] = parseFloat(output[i].match(regex)[0]);
}
}
versions.sort();
console.log(versions[0]);
return Q();
}, function(stderr) {
return Q.reject(stderr);
});
};
exports.get_apple_xcode_version = function() {
var d = Q.defer();
child_process.exec('xcodebuild -version', function(error, stdout, stderr) {
var versionMatch = /Xcode (.*)/.exec(stdout);
if (error || !versionMatch) {
d.reject(stderr);
} else {
d.resolve(versionMatch[1]);
}
});
return d.promise;
};
/**
* Gets ios-deploy util version
* @return {Promise} Promise that either resolved with ios-deploy version
* or rejected in case of error
*/
exports.get_ios_deploy_version = function() {
var d = Q.defer();
child_process.exec('ios-deploy --version', function(error, stdout, stderr) {
if (error) {
d.reject(stderr);
} else {
d.resolve(stdout);
}
});
return d.promise;
};
/**
* Gets ios-sim util version
* @return {Promise} Promise that either resolved with ios-sim version
* or rejected in case of error
*/
exports.get_ios_sim_version = function() {
var d = Q.defer();
child_process.exec('ios-sim --version', function(error, stdout, stderr) {
if (error) {
d.reject(stderr);
} else {
d.resolve(stdout);
}
});
return d.promise;
};
/**
* Gets specific tool version
* @param {String} toolName Tool name to check. Known tools are 'xcodebuild', 'ios-sim' and 'ios-deploy'
* @return {Promise} Promise that either resolved with tool version
* or rejected in case of error
*/
exports.get_tool_version = function (toolName) {
switch (toolName) {
case 'xcodebuild': return exports.get_apple_xcode_version();
case 'ios-sim': return exports.get_ios_sim_version();
case 'ios-deploy': return exports.get_ios_deploy_version();
default: return Q.reject(toolName + ' is not valid tool name. Valid names are: \'xcodebuild\', \'ios-sim\' and \'ios-deploy\'');
}
};
/**
* Compares two semver-notated version strings. Returns number
* that indicates equality of provided version strings.
* @param {String} version1 Version to compare
* @param {String} version2 Another version to compare
* @return {Number} Negative number if first version is lower than the second,
* positive otherwise and 0 if versions are equal.
*/
exports.compareVersions = function (version1, version2) {
function parseVer (version) {
return version.split('.').map(function (value) {
// try to convert version segment to Number
var parsed = Number(value);
// Number constructor is strict enough and will return NaN
// if conversion fails. In this case we won't be able to compare versions properly
if (isNaN(parsed)) {
throw 'Version should contain only numbers and dots';
}
return parsed;
});
}
var parsedVer1 = parseVer(version1);
var parsedVer2 = parseVer(version2);
// Compare corresponding segments of each version
for (var i = 0; i < Math.max(parsedVer1.length, parsedVer2.length); i++) {
// if segment is not specified, assume that it is 0
// E.g. 3.1 is equal to 3.1.0
var ret = (parsedVer1[i] || 0) - (parsedVer2[i] || 0);
// if segments are not equal, we're finished
if (ret !== 0) return ret;
}
return 0;
};

View file

@ -0,0 +1,23 @@
#! /bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd -P)
tail -f "$CORDOVA_PATH/console.log"

View file

@ -0,0 +1,23 @@
Copyright 2009, 2010, 2011 Isaac Z. Schlueter.
All rights reserved.
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.

View file

@ -0,0 +1,414 @@
// info about each config option.
var debug = process.env.DEBUG_NOPT || process.env.NOPT_DEBUG
? function () { console.error.apply(console, arguments) }
: function () {}
var url = require("url")
, path = require("path")
, Stream = require("stream").Stream
, abbrev = require("abbrev")
module.exports = exports = nopt
exports.clean = clean
exports.typeDefs =
{ String : { type: String, validate: validateString }
, Boolean : { type: Boolean, validate: validateBoolean }
, url : { type: url, validate: validateUrl }
, Number : { type: Number, validate: validateNumber }
, path : { type: path, validate: validatePath }
, Stream : { type: Stream, validate: validateStream }
, Date : { type: Date, validate: validateDate }
}
function nopt (types, shorthands, args, slice) {
args = args || process.argv
types = types || {}
shorthands = shorthands || {}
if (typeof slice !== "number") slice = 2
debug(types, shorthands, args, slice)
args = args.slice(slice)
var data = {}
, key
, remain = []
, cooked = args
, original = args.slice(0)
parse(args, data, remain, types, shorthands)
// now data is full
clean(data, types, exports.typeDefs)
data.argv = {remain:remain,cooked:cooked,original:original}
Object.defineProperty(data.argv, 'toString', { value: function () {
return this.original.map(JSON.stringify).join(" ")
}, enumerable: false })
return data
}
function clean (data, types, typeDefs) {
typeDefs = typeDefs || exports.typeDefs
var remove = {}
, typeDefault = [false, true, null, String, Array]
Object.keys(data).forEach(function (k) {
if (k === "argv") return
var val = data[k]
, isArray = Array.isArray(val)
, type = types[k]
if (!isArray) val = [val]
if (!type) type = typeDefault
if (type === Array) type = typeDefault.concat(Array)
if (!Array.isArray(type)) type = [type]
debug("val=%j", val)
debug("types=", type)
val = val.map(function (val) {
// if it's an unknown value, then parse false/true/null/numbers/dates
if (typeof val === "string") {
debug("string %j", val)
val = val.trim()
if ((val === "null" && ~type.indexOf(null))
|| (val === "true" &&
(~type.indexOf(true) || ~type.indexOf(Boolean)))
|| (val === "false" &&
(~type.indexOf(false) || ~type.indexOf(Boolean)))) {
val = JSON.parse(val)
debug("jsonable %j", val)
} else if (~type.indexOf(Number) && !isNaN(val)) {
debug("convert to number", val)
val = +val
} else if (~type.indexOf(Date) && !isNaN(Date.parse(val))) {
debug("convert to date", val)
val = new Date(val)
}
}
if (!types.hasOwnProperty(k)) {
return val
}
// allow `--no-blah` to set 'blah' to null if null is allowed
if (val === false && ~type.indexOf(null) &&
!(~type.indexOf(false) || ~type.indexOf(Boolean))) {
val = null
}
var d = {}
d[k] = val
debug("prevalidated val", d, val, types[k])
if (!validate(d, k, val, types[k], typeDefs)) {
if (exports.invalidHandler) {
exports.invalidHandler(k, val, types[k], data)
} else if (exports.invalidHandler !== false) {
debug("invalid: "+k+"="+val, types[k])
}
return remove
}
debug("validated val", d, val, types[k])
return d[k]
}).filter(function (val) { return val !== remove })
if (!val.length) delete data[k]
else if (isArray) {
debug(isArray, data[k], val)
data[k] = val
} else data[k] = val[0]
debug("k=%s val=%j", k, val, data[k])
})
}
function validateString (data, k, val) {
data[k] = String(val)
}
function validatePath (data, k, val) {
if (val === true) return false
if (val === null) return true
val = String(val)
var homePattern = process.platform === 'win32' ? /^~(\/|\\)/ : /^~\//
if (val.match(homePattern) && process.env.HOME) {
val = path.resolve(process.env.HOME, val.substr(2))
}
data[k] = path.resolve(String(val))
return true
}
function validateNumber (data, k, val) {
debug("validate Number %j %j %j", k, val, isNaN(val))
if (isNaN(val)) return false
data[k] = +val
}
function validateDate (data, k, val) {
debug("validate Date %j %j %j", k, val, Date.parse(val))
var s = Date.parse(val)
if (isNaN(s)) return false
data[k] = new Date(val)
}
function validateBoolean (data, k, val) {
if (val instanceof Boolean) val = val.valueOf()
else if (typeof val === "string") {
if (!isNaN(val)) val = !!(+val)
else if (val === "null" || val === "false") val = false
else val = true
} else val = !!val
data[k] = val
}
function validateUrl (data, k, val) {
val = url.parse(String(val))
if (!val.host) return false
data[k] = val.href
}
function validateStream (data, k, val) {
if (!(val instanceof Stream)) return false
data[k] = val
}
function validate (data, k, val, type, typeDefs) {
// arrays are lists of types.
if (Array.isArray(type)) {
for (var i = 0, l = type.length; i < l; i ++) {
if (type[i] === Array) continue
if (validate(data, k, val, type[i], typeDefs)) return true
}
delete data[k]
return false
}
// an array of anything?
if (type === Array) return true
// NaN is poisonous. Means that something is not allowed.
if (type !== type) {
debug("Poison NaN", k, val, type)
delete data[k]
return false
}
// explicit list of values
if (val === type) {
debug("Explicitly allowed %j", val)
// if (isArray) (data[k] = data[k] || []).push(val)
// else data[k] = val
data[k] = val
return true
}
// now go through the list of typeDefs, validate against each one.
var ok = false
, types = Object.keys(typeDefs)
for (var i = 0, l = types.length; i < l; i ++) {
debug("test type %j %j %j", k, val, types[i])
var t = typeDefs[types[i]]
if (t && type === t.type) {
var d = {}
ok = false !== t.validate(d, k, val)
val = d[k]
if (ok) {
// if (isArray) (data[k] = data[k] || []).push(val)
// else data[k] = val
data[k] = val
break
}
}
}
debug("OK? %j (%j %j %j)", ok, k, val, types[i])
if (!ok) delete data[k]
return ok
}
function parse (args, data, remain, types, shorthands) {
debug("parse", args, data, remain)
var key = null
, abbrevs = abbrev(Object.keys(types))
, shortAbbr = abbrev(Object.keys(shorthands))
for (var i = 0; i < args.length; i ++) {
var arg = args[i]
debug("arg", arg)
if (arg.match(/^-{2,}$/)) {
// done with keys.
// the rest are args.
remain.push.apply(remain, args.slice(i + 1))
args[i] = "--"
break
}
var hadEq = false
if (arg.charAt(0) === "-" && arg.length > 1) {
if (arg.indexOf("=") !== -1) {
hadEq = true
var v = arg.split("=")
arg = v.shift()
v = v.join("=")
args.splice.apply(args, [i, 1].concat([arg, v]))
}
// see if it's a shorthand
// if so, splice and back up to re-parse it.
var shRes = resolveShort(arg, shorthands, shortAbbr, abbrevs)
debug("arg=%j shRes=%j", arg, shRes)
if (shRes) {
debug(arg, shRes)
args.splice.apply(args, [i, 1].concat(shRes))
if (arg !== shRes[0]) {
i --
continue
}
}
arg = arg.replace(/^-+/, "")
var no = null
while (arg.toLowerCase().indexOf("no-") === 0) {
no = !no
arg = arg.substr(3)
}
if (abbrevs[arg]) arg = abbrevs[arg]
var isArray = types[arg] === Array ||
Array.isArray(types[arg]) && types[arg].indexOf(Array) !== -1
// allow unknown things to be arrays if specified multiple times.
if (!types.hasOwnProperty(arg) && data.hasOwnProperty(arg)) {
if (!Array.isArray(data[arg]))
data[arg] = [data[arg]]
isArray = true
}
var val
, la = args[i + 1]
var isBool = typeof no === 'boolean' ||
types[arg] === Boolean ||
Array.isArray(types[arg]) && types[arg].indexOf(Boolean) !== -1 ||
(typeof types[arg] === 'undefined' && !hadEq) ||
(la === "false" &&
(types[arg] === null ||
Array.isArray(types[arg]) && ~types[arg].indexOf(null)))
if (isBool) {
// just set and move along
val = !no
// however, also support --bool true or --bool false
if (la === "true" || la === "false") {
val = JSON.parse(la)
la = null
if (no) val = !val
i ++
}
// also support "foo":[Boolean, "bar"] and "--foo bar"
if (Array.isArray(types[arg]) && la) {
if (~types[arg].indexOf(la)) {
// an explicit type
val = la
i ++
} else if ( la === "null" && ~types[arg].indexOf(null) ) {
// null allowed
val = null
i ++
} else if ( !la.match(/^-{2,}[^-]/) &&
!isNaN(la) &&
~types[arg].indexOf(Number) ) {
// number
val = +la
i ++
} else if ( !la.match(/^-[^-]/) && ~types[arg].indexOf(String) ) {
// string
val = la
i ++
}
}
if (isArray) (data[arg] = data[arg] || []).push(val)
else data[arg] = val
continue
}
if (types[arg] === String && la === undefined)
la = ""
if (la && la.match(/^-{2,}$/)) {
la = undefined
i --
}
val = la === undefined ? true : la
if (isArray) (data[arg] = data[arg] || []).push(val)
else data[arg] = val
i ++
continue
}
remain.push(arg)
}
}
function resolveShort (arg, shorthands, shortAbbr, abbrevs) {
// handle single-char shorthands glommed together, like
// npm ls -glp, but only if there is one dash, and only if
// all of the chars are single-char shorthands, and it's
// not a match to some other abbrev.
arg = arg.replace(/^-+/, '')
// if it's an exact known option, then don't go any further
if (abbrevs[arg] === arg)
return null
// if it's an exact known shortopt, same deal
if (shorthands[arg]) {
// make it an array, if it's a list of words
if (shorthands[arg] && !Array.isArray(shorthands[arg]))
shorthands[arg] = shorthands[arg].split(/\s+/)
return shorthands[arg]
}
// first check to see if this arg is a set of single-char shorthands
var singles = shorthands.___singles
if (!singles) {
singles = Object.keys(shorthands).filter(function (s) {
return s.length === 1
}).reduce(function (l,r) {
l[r] = true
return l
}, {})
shorthands.___singles = singles
debug('shorthand singles', singles)
}
var chrs = arg.split("").filter(function (c) {
return singles[c]
})
if (chrs.join("") === arg) return chrs.map(function (c) {
return shorthands[c]
}).reduce(function (l, r) {
return l.concat(r)
}, [])
// if it's an arg abbrev, and not a literal shorthand, then prefer the arg
if (abbrevs[arg] && !shorthands[arg])
return null
// if it's an abbr for a shorthand, then use that
if (shortAbbr[arg])
arg = shortAbbr[arg]
// make it an array, if it's a list of words
if (shorthands[arg] && !Array.isArray(shorthands[arg]))
shorthands[arg] = shorthands[arg].split(/\s+/)
return shorthands[arg]
}

View file

@ -0,0 +1,23 @@
Copyright 2009, 2010, 2011 Isaac Z. Schlueter.
All rights reserved.
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.

View file

@ -0,0 +1,62 @@
module.exports = exports = abbrev.abbrev = abbrev
abbrev.monkeyPatch = monkeyPatch
function monkeyPatch () {
Object.defineProperty(Array.prototype, 'abbrev', {
value: function () { return abbrev(this) },
enumerable: false, configurable: true, writable: true
})
Object.defineProperty(Object.prototype, 'abbrev', {
value: function () { return abbrev(Object.keys(this)) },
enumerable: false, configurable: true, writable: true
})
}
function abbrev (list) {
if (arguments.length !== 1 || !Array.isArray(list)) {
list = Array.prototype.slice.call(arguments, 0)
}
for (var i = 0, l = list.length, args = [] ; i < l ; i ++) {
args[i] = typeof list[i] === "string" ? list[i] : String(list[i])
}
// sort them lexicographically, so that they're next to their nearest kin
args = args.sort(lexSort)
// walk through each, seeing how much it has in common with the next and previous
var abbrevs = {}
, prev = ""
for (var i = 0, l = args.length ; i < l ; i ++) {
var current = args[i]
, next = args[i + 1] || ""
, nextMatches = true
, prevMatches = true
if (current === next) continue
for (var j = 0, cl = current.length ; j < cl ; j ++) {
var curChar = current.charAt(j)
nextMatches = nextMatches && curChar === next.charAt(j)
prevMatches = prevMatches && curChar === prev.charAt(j)
if (!nextMatches && !prevMatches) {
j ++
break
}
}
prev = current
if (j === cl) {
abbrevs[current] = current
continue
}
for (var a = current.substr(0, j) ; j <= cl ; j ++) {
abbrevs[a] = current
a += current.charAt(j)
}
}
return abbrevs
}
function lexSort (a, b) {
return a === b ? 0 : a > b ? 1 : -1
}

View file

@ -0,0 +1,31 @@
{
"name": "abbrev",
"version": "1.0.5",
"description": "Like ruby's abbrev module, but in js",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me"
},
"main": "abbrev.js",
"scripts": {
"test": "node test.js"
},
"repository": {
"type": "git",
"url": "http://github.com/isaacs/abbrev-js"
},
"license": {
"type": "MIT",
"url": "https://github.com/isaacs/abbrev-js/raw/master/LICENSE"
},
"readme": "# abbrev-js\n\nJust like [ruby's Abbrev](http://apidock.com/ruby/Abbrev).\n\nUsage:\n\n var abbrev = require(\"abbrev\");\n abbrev(\"foo\", \"fool\", \"folding\", \"flop\");\n \n // returns:\n { fl: 'flop'\n , flo: 'flop'\n , flop: 'flop'\n , fol: 'folding'\n , fold: 'folding'\n , foldi: 'folding'\n , foldin: 'folding'\n , folding: 'folding'\n , foo: 'foo'\n , fool: 'fool'\n }\n\nThis is handy for command-line scripts, or other cases where you want to be able to accept shorthands.\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/isaacs/abbrev-js/issues"
},
"homepage": "https://github.com/isaacs/abbrev-js",
"_id": "abbrev@1.0.5",
"_shasum": "5d8257bd9ebe435e698b2fa431afde4fe7b10b03",
"_from": "abbrev@1",
"_resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.5.tgz"
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,18 @@
Copyright 20092014 Kristopher Michael Kowal. All rights reserved.
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.

View file

@ -0,0 +1,112 @@
{
"name": "q",
"version": "1.0.1",
"description": "A library for promises (CommonJS/Promises/A,B,D)",
"homepage": "https://github.com/kriskowal/q",
"author": {
"name": "Kris Kowal",
"email": "kris@cixar.com",
"url": "https://github.com/kriskowal"
},
"keywords": [
"q",
"promise",
"promises",
"promises-a",
"promises-aplus",
"deferred",
"future",
"async",
"flow control",
"fluent",
"browser",
"node"
],
"contributors": [
{
"name": "Kris Kowal",
"email": "kris@cixar.com",
"url": "https://github.com/kriskowal"
},
{
"name": "Irakli Gozalishvili",
"email": "rfobic@gmail.com",
"url": "http://jeditoolkit.com"
},
{
"name": "Domenic Denicola",
"email": "domenic@domenicdenicola.com",
"url": "http://domenicdenicola.com"
}
],
"bugs": {
"url": "http://github.com/kriskowal/q/issues"
},
"license": {
"type": "MIT",
"url": "http://github.com/kriskowal/q/raw/master/LICENSE"
},
"main": "q.js",
"repository": {
"type": "git",
"url": "git://github.com/kriskowal/q.git"
},
"engines": {
"node": ">=0.6.0",
"teleport": ">=0.2.0"
},
"dependencies": {},
"devDependencies": {
"jshint": "~2.1.9",
"cover": "*",
"jasmine-node": "1.11.0",
"opener": "*",
"promises-aplus-tests": "1.x",
"grunt": "~0.4.1",
"grunt-cli": "~0.1.9",
"grunt-contrib-uglify": "~0.2.2",
"matcha": "~0.2.0"
},
"scripts": {
"test": "jasmine-node spec && promises-aplus-tests spec/aplus-adapter",
"test-browser": "opener spec/q-spec.html",
"benchmark": "matcha",
"lint": "jshint q.js",
"cover": "cover run node_modules/jasmine-node/bin/jasmine-node spec && cover report html && opener cover_html/index.html",
"minify": "grunt",
"prepublish": "grunt"
},
"overlay": {
"teleport": {
"dependencies": {
"system": ">=0.0.4"
}
}
},
"directories": {
"test": "./spec"
},
"_id": "q@1.0.1",
"dist": {
"shasum": "11872aeedee89268110b10a718448ffb10112a14",
"tarball": "http://registry.npmjs.org/q/-/q-1.0.1.tgz"
},
"_from": "q@",
"_npmVersion": "1.4.4",
"_npmUser": {
"name": "kriskowal",
"email": "kris.kowal@cixar.com"
},
"maintainers": [
{
"name": "kriskowal",
"email": "kris.kowal@cixar.com"
},
{
"name": "domenic",
"email": "domenic@domenicdenicola.com"
}
],
"_shasum": "11872aeedee89268110b10a718448ffb10112a14",
"_resolved": "https://registry.npmjs.org/q/-/q-1.0.1.tgz"
}

1904
fritteliuhr/platforms/ios/cordova/node_modules/q/q.js generated vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,35 @@
var Q = require("./q");
module.exports = Queue;
function Queue() {
var ends = Q.defer();
var closed = Q.defer();
return {
put: function (value) {
var next = Q.defer();
ends.resolve({
head: value,
tail: next.promise
});
ends.resolve = next.resolve;
},
get: function () {
var result = ends.promise.get("head");
ends.promise = ends.promise.get("tail");
return result.fail(function (error) {
closed.resolve(error);
throw error;
});
},
closed: closed.promise,
close: function (error) {
error = error || new Error("Can't get value from closed queue");
var end = {head: Q.reject(error)};
end.tail = end;
ends.resolve(end);
return closed.promise;
}
};
}

View file

@ -0,0 +1,26 @@
Copyright (c) 2012, Artur Adib <aadib@mozilla.com>
All rights reserved.
You may use this project under the terms of the New BSD license as follows:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Artur Adib nor the
names of the contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL ARTUR ADIB BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,36 @@
#!/usr/bin/env node
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
var args = process.argv,
run = require('./lib/run');
// Handle help flag
if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(args[2]) > -1) {
run.help();
} else {
run.run(args).done(function() {
console.log('** RUN SUCCEEDED **');
}, function (err) {
var errorMessage = (err && err.stack) ? err.stack : err;
console.error(errorMessage);
process.exit(2);
});
}

View file

@ -0,0 +1,25 @@
:: Licensed to the Apache Software Foundation (ASF) under one
:: or more contributor license agreements. See the NOTICE file
:: distributed with this work for additional information
:: regarding copyright ownership. The ASF licenses this file
:: to you under the Apache License, Version 2.0 (the
:: "License"); you may not use this file except in compliance
:: with the License. You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing,
:: software distributed under the License is distributed on an
:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
:: KIND, either express or implied. See the License for the
:: specific language governing permissions and limitations
:: under the License
@ECHO OFF
SET script_path="%~dp0run"
IF EXIST %script_path% (
node %script_path% %*
) ELSE (
ECHO.
ECHO ERROR: Could not find 'run' script in 'cordova' folder, aborting...>&2
EXIT /B 1
)

View file

@ -0,0 +1,30 @@
#!/usr/bin/env node
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
/*
Returns the VERSION of CordovaLib used.
Note: it does not work if the --shared option was used to create the project.
*/
var VERSION="3.8.0"
console.log(VERSION);

View file

@ -0,0 +1,26 @@
:: Licensed to the Apache Software Foundation (ASF) under one
:: or more contributor license agreements. See the NOTICE file
:: distributed with this work for additional information
:: regarding copyright ownership. The ASF licenses this file
:: to you under the Apache License, Version 2.0 (the
:: "License"); you may not use this file except in compliance
:: with the License. You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing,
:: software distributed under the License is distributed on an
:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
:: KIND, either express or implied. See the License for the
:: specific language governing permissions and limitations
:: under the License.
@ECHO OFF
SET script="%~dp0version"
IF EXIST %script% (
node %script% %*
) ELSE (
ECHO.
ECHO ERROR: Could not find 'version' script in 'cordova' folder, aborting...>&2
EXIT /B 1
)