mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-30 00:00:04 +08:00
Compare commits
61 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 021c9c19e8 | |||
| 0c475b5ec4 | |||
| 2a2a11a729 | |||
| 7203b740fd | |||
| 97aab900da | |||
| dddb2837dd | |||
| 1637937664 | |||
| 03144eb160 | |||
| 53210710ba | |||
| e7a972df77 | |||
| cb2f396e33 | |||
| 2377aa7ac2 | |||
| dce3b7ed6c | |||
| 5bda4df7fa | |||
| 1a8e36ccd3 | |||
| 14816c7c81 | |||
| d364f46baa | |||
| 2b53c98cf5 | |||
| 36d07d7a15 | |||
| 458e479681 | |||
| c3ce2f8a07 | |||
| 893356abcd | |||
| 22645d9158 | |||
| 76dd8613ca | |||
| 5917d4ef0b | |||
| 90053eb9df | |||
| 540929c6a0 | |||
| 3ff32092a3 | |||
| 55d7cf3865 | |||
| ac4ac935f6 | |||
| d83d49d83b | |||
| e36158a0da | |||
| 5cc14b8031 | |||
| 3a6e898b12 | |||
| 0cc3df3747 | |||
| 2bc842a2b3 | |||
| 1c6f640026 | |||
| 6daad829cc | |||
| 7d926822ed | |||
| d4dcbb13fc | |||
| f396712f59 | |||
| d97250f968 | |||
| e7e8e95242 | |||
| d518a655a8 | |||
| b6a5844027 | |||
| 9d9abea157 | |||
| ee1165ea33 | |||
| 2704ee54cf | |||
| ad01d28351 | |||
| a215c1cf30 | |||
| cadea2f6c3 | |||
| e13e15d3e9 | |||
| 6ef2f67ae8 | |||
| 765c4ee9f6 | |||
| a4103d8dc8 | |||
| 8e0f021cad | |||
| 002ab85f76 | |||
| 4a0f69a3f0 | |||
| 8a2e96d995 | |||
| 13dbd2f5d4 | |||
| bcf3f8611a |
@@ -0,0 +1,10 @@
|
|||||||
|
root: true
|
||||||
|
extends: semistandard
|
||||||
|
rules:
|
||||||
|
indent:
|
||||||
|
- error
|
||||||
|
- 4
|
||||||
|
camelcase: off
|
||||||
|
padded-blocks: off
|
||||||
|
operator-linebreak: off
|
||||||
|
no-throw-literal: off
|
||||||
+19
-17
@@ -1,11 +1,21 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
.gradle
|
||||||
|
.metadata
|
||||||
|
Thumbs.db
|
||||||
|
Desktop.ini
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
|
*.class
|
||||||
|
*.jar
|
||||||
default.properties
|
default.properties
|
||||||
gen
|
gen
|
||||||
assets/www/cordova.js
|
assets/www/cordova.js
|
||||||
local.properties
|
local.properties
|
||||||
proguard.cfg
|
proguard.cfg
|
||||||
proguard.cfg
|
|
||||||
proguard-project.txt
|
proguard-project.txt
|
||||||
|
example
|
||||||
|
/coverage
|
||||||
/framework/lib
|
/framework/lib
|
||||||
/framework/build
|
/framework/build
|
||||||
/framework/bin
|
/framework/bin
|
||||||
@@ -15,30 +25,23 @@ proguard-project.txt
|
|||||||
/framework/libs
|
/framework/libs
|
||||||
/framework/javadoc-public
|
/framework/javadoc-public
|
||||||
/framework/javadoc-private
|
/framework/javadoc-private
|
||||||
/test/libs
|
/test/.externalNativeBuild
|
||||||
example
|
/test/build.gradle
|
||||||
/test/bin
|
|
||||||
/test/assets/www/.tmp*
|
|
||||||
/test/assets/www/cordova.js
|
|
||||||
/test/gradle
|
/test/gradle
|
||||||
/test/gradlew
|
/test/gradlew
|
||||||
/test/gradlew.bat
|
/test/gradlew.bat
|
||||||
|
/test/assets/www/.tmp*
|
||||||
|
/test/assets/www/cordova.js
|
||||||
|
/test/bin
|
||||||
/test/build
|
/test/build
|
||||||
.gradle
|
/test/captures
|
||||||
|
/test/libs
|
||||||
tmp/**
|
tmp/**
|
||||||
.metadata
|
|
||||||
tmp/**/*
|
tmp/**/*
|
||||||
Thumbs.db
|
|
||||||
Desktop.ini
|
|
||||||
*.tmp
|
|
||||||
*.bak
|
|
||||||
*.swp
|
|
||||||
*.class
|
|
||||||
*.jar
|
|
||||||
!/spec/fixtures/org.test.plugins.dummyplugin/src/android/TestLib.jar
|
!/spec/fixtures/org.test.plugins.dummyplugin/src/android/TestLib.jar
|
||||||
# IntelliJ IDEA files
|
# IntelliJ IDEA files
|
||||||
|
**/.idea/**/*
|
||||||
*.iml
|
*.iml
|
||||||
.idea
|
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
node_modules/jshint
|
node_modules/jshint
|
||||||
node_modules/promise-matchers
|
node_modules/promise-matchers
|
||||||
@@ -130,4 +133,3 @@ node_modules/wordwrap/
|
|||||||
node_modules/yargs/
|
node_modules/yargs/
|
||||||
node_modules/jasmine-core/
|
node_modules/jasmine-core/
|
||||||
node_modules/fs.realpath/
|
node_modules/fs.realpath/
|
||||||
/coverage
|
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
bin/node_modules/*
|
|
||||||
bin/templates/project/*
|
|
||||||
spec/fixtures/*
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"node": true
|
|
||||||
, "bitwise": true
|
|
||||||
, "undef": true
|
|
||||||
, "trailing": true
|
|
||||||
, "quotmark": true
|
|
||||||
, "indent": 4
|
|
||||||
, "unused": "vars"
|
|
||||||
, "latedef": "nofunc"
|
|
||||||
}
|
|
||||||
+13
-7
@@ -2,21 +2,27 @@ language: android
|
|||||||
sudo: false
|
sudo: false
|
||||||
jdk:
|
jdk:
|
||||||
- oraclejdk8
|
- oraclejdk8
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
- ANDROID_TOOLS=${ANDROID_HOME}/tools
|
||||||
before_install:
|
before_install:
|
||||||
- nvm install 6
|
- nvm install 6
|
||||||
|
# ensure at least gradle 3.3 is in place.
|
||||||
|
- wget http://services.gradle.org/distributions/gradle-3.3-bin.zip
|
||||||
|
- unzip gradle-3.3-bin.zip
|
||||||
|
- export GRADLE_HOME=$PWD/gradle-3.3
|
||||||
|
- export PATH=${GRADLE_HOME}/bin:${ANDROID_HOME}:${ANDROID_HOME}/emulator:${ANDROID_TOOLS}:${ANDROID_TOOLS}/bin:${ANDROID_HOME}/platform-tools:$PATH
|
||||||
- node --version
|
- node --version
|
||||||
- gradle --version
|
- gradle --version
|
||||||
install:
|
- echo y | android --silent update sdk --no-ui --all --filter platform-tools,tools,build-tools-26.0.0,android-26,android-25,extra-google-m2repository,extra-android-m2repository
|
||||||
- npm install
|
|
||||||
- npm install -g codecov
|
|
||||||
- echo y | android update sdk -u --filter android-22,android-23,android-24,android-25
|
|
||||||
android:
|
android:
|
||||||
components:
|
components:
|
||||||
- tools
|
- tools
|
||||||
- tools
|
install:
|
||||||
|
- npm install
|
||||||
|
- npm install -g codecov
|
||||||
script:
|
script:
|
||||||
- npm run jshint
|
- npm test
|
||||||
- npm run cover
|
- npm run cover
|
||||||
- npm run test-build
|
|
||||||
after_script:
|
after_script:
|
||||||
- codecov
|
- codecov
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ at the core, applications written with web technology: HTML, CSS and JavaScript.
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
- Java JDK 1.6 or greater
|
- Java JDK 1.8 or greater
|
||||||
- Android SDK [http://developer.android.com](http://developer.android.com)
|
- Android SDK [http://developer.android.com](http://developer.android.com)
|
||||||
|
|
||||||
|
|
||||||
@@ -62,3 +62,9 @@ These commands live in a generated Cordova Android project. Any interactions wit
|
|||||||
|
|
||||||
1. Create a project
|
1. Create a project
|
||||||
2. Import it via "Non-Android Studio Project"
|
2. Import it via "Non-Android Studio Project"
|
||||||
|
|
||||||
|
## Running the Native Tests
|
||||||
|
|
||||||
|
The `test/` directory in this project contains an Android test project that can
|
||||||
|
be used to run different kinds of native tests. Check out the
|
||||||
|
[README contained therein](test/README.md) for more details!
|
||||||
|
|||||||
@@ -20,6 +20,34 @@
|
|||||||
-->
|
-->
|
||||||
## Release Notes for Cordova (Android) ##
|
## Release Notes for Cordova (Android) ##
|
||||||
|
|
||||||
|
### 6.3.0 (Sep 25, 2017)
|
||||||
|
* [CB-6936](https://issues.apache.org/jira/browse/CB-6936) fix crash when calling methods on a destroyed webview
|
||||||
|
* [CB-12981](https://issues.apache.org/jira/browse/CB-12981) handle SDK 26.0.2 slightly different AVD list output for **Android** 8+ AVDs. Would cause "cannot read property replace of undefined" errors when trying to deploy an **Android** 8 emulator.
|
||||||
|
* Updated maven repo to include most recent lib versions
|
||||||
|
* [CB-13177](https://issues.apache.org/jira/browse/CB-13177) Updating to API Level 26
|
||||||
|
* Revert [CB-12015](https://issues.apache.org/jira/browse/CB-12015) initial-scale values less than 1.0 are ignored on **Android**
|
||||||
|
* [CB-12730](https://issues.apache.org/jira/browse/CB-12730) The Cordova Compatibility Plugin is now integrated into cordova-android
|
||||||
|
* [CB-12453](https://issues.apache.org/jira/browse/CB-12453) Remove unnecessary double quotes from .bat files which are the causes of crash if project path contains spaces
|
||||||
|
* [CB-13031](https://issues.apache.org/jira/browse/CB-13031) Fix bug with case-sensitivity of **Android**-packageName
|
||||||
|
* [CB-10916](https://issues.apache.org/jira/browse/CB-10916) Support display name for **Android**
|
||||||
|
* [CB-12423](https://issues.apache.org/jira/browse/CB-12423) make explicit JDK 1.8 or greater is needed in the `README`, we require 1.8 for compilation, but do not have 1.8 Java features yet
|
||||||
|
* [CB-13006](https://issues.apache.org/jira/browse/CB-13006) removed create and update end-to-end tests, and instead added more unit test coverage. tweaked code coverage invocation so that we get coverage details on the create.js module. slight changes to the create.js module so that it is slightly easier to test.
|
||||||
|
* [CB-12950](https://issues.apache.org/jira/browse/CB-12950) lots of tweaks for end-to-end test runs, especially on CI: - rename npm tasks to reflect what they do (npm run unit-tests, npm run e2e-tests). main `npm test` runs linter, unit tests and e2e tests now. - locked jasmine down to ~2.6.0. - consolidate gitignores. - updated travis to run `npm test`. add **Android** sdk installation to appveyor ci run.align **Android** dpendencies across travis and appveyor. have appveyor install gradle. force gradle to version 3.4.1 in appveyor, as that seems to be the only version choco has. explicitly invoke sdkmanager to move license accepting process along.
|
||||||
|
* [CB-12605](https://issues.apache.org/jira/browse/CB-12605) In **Windows** get **Android** studio path from the registry
|
||||||
|
* [CB-12762](https://issues.apache.org/jira/browse/CB-12762) : pointed `package.json` repo items to github mirrors instead of apache repos site
|
||||||
|
* [CB-12617](https://issues.apache.org/jira/browse/CB-12617) : removed node0.x support for platforms and added engineStrict
|
||||||
|
|
||||||
|
### 6.2.3 (May 2, 2017)
|
||||||
|
* [CB-12640](https://issues.apache.org/jira/browse/CB-12640) better handling of unrecognized Android SDK commands on **Windows**.
|
||||||
|
* [CB-12640](https://issues.apache.org/jira/browse/CB-12640) flipped avd parsing logic so that it always tries to use avdmanager to retrieve avds first, then falls back to android command if avdmanager cannot be found (and errors with ENOENT). updated tests - and added explicit tests to ensure to shell out to singular forms of sub-commands when executing `android`
|
||||||
|
* [CB-12640](https://issues.apache.org/jira/browse/CB-12640) support for android sdk tools 26.0.1.
|
||||||
|
|
||||||
|
### 6.2.2 (Apr 24, 2017)
|
||||||
|
* [CB-12697](https://issues.apache.org/jira/browse/CB-12697) Updated checked-in `node_modules`
|
||||||
|
|
||||||
|
### 6.2.1 (Apr 02, 2017)
|
||||||
|
* [CB-12621](https://issues.apache.org/jira/browse/CB-12621) reverted elementtree dep to 0.1.6
|
||||||
|
|
||||||
### 6.2.0 (Mar 28, 2017)
|
### 6.2.0 (Mar 28, 2017)
|
||||||
* [CB-12614](https://issues.apache.org/jira/browse/CB-12614) Adding headers to tests
|
* [CB-12614](https://issues.apache.org/jira/browse/CB-12614) Adding headers to tests
|
||||||
* [CB-8978](https://issues.apache.org/jira/browse/CB-8978) Prepare copy `resource-files` from `config.xml`
|
* [CB-8978](https://issues.apache.org/jira/browse/CB-8978) Prepare copy `resource-files` from `config.xml`
|
||||||
|
|||||||
+23
-6
@@ -1,20 +1,37 @@
|
|||||||
|
image:
|
||||||
|
- Previous Visual Studio 2015
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
ANDROID_HOME: "C:\\android"
|
||||||
matrix:
|
matrix:
|
||||||
- nodejs_version: "0.10"
|
|
||||||
- nodejs_version: "0.12"
|
|
||||||
- nodejs_version: "4"
|
- nodejs_version: "4"
|
||||||
- nodejs_version: "6"
|
- nodejs_version: "6"
|
||||||
|
|
||||||
|
init:
|
||||||
|
- mkdir "%ANDROID_HOME%
|
||||||
|
- cd "%ANDROID_HOME%"
|
||||||
|
- appveyor DownloadFile "https://dl.google.com/android/repository/tools_r25.2.3-windows.zip"
|
||||||
|
- 7z x "tools_r25.2.3-windows.zip" > nul
|
||||||
|
- cd "C:\projects\cordova-android"
|
||||||
|
|
||||||
install:
|
install:
|
||||||
# - cinst android-sdk
|
- choco install gradle -version 3.4.1
|
||||||
# - echo y | android update sdk -u --filter android-22,android-23
|
- gradle -version
|
||||||
|
- echo y | "%ANDROID_HOME%\tools\android.bat" --silent update sdk --no-ui --all --filter platform-tools,tools,build-tools-26.0.0,android-26,android-25,extra-google-m2repository,extra-android-m2repository
|
||||||
|
# on windows we need to accept sublicenses for the new tooling, wee. 30 is an arbitrary number,
|
||||||
|
# but should be the maximum number of licenses we explicitly need to type "Y ENTER" for.
|
||||||
|
# also, the sdkmanager in all its glory leaks a bit of output to stderr, and powershell
|
||||||
|
# and appveyor interpret that as errors, and blows up. so, when piping in our "Y ENTER"
|
||||||
|
# responses, we invoke cmd so we can redirect stderr to stdout, and tell it to --update itself.
|
||||||
|
- ps: for($i=0;$i -lt 30;$i++) { $response += "y`n"}; $response | cmd /c 'C:\android\tools\bin\sdkmanager.bat 2>&1' --update
|
||||||
- ps: Install-Product node $env:nodejs_version
|
- ps: Install-Product node $env:nodejs_version
|
||||||
- npm install
|
- npm install
|
||||||
|
# below is a workaround on using gradle installed via choco on appveyor
|
||||||
|
- set path=C:\ProgramData\chocolatey\lib\gradle\tools\gradle-3.4.1\bin;%path%
|
||||||
|
|
||||||
build: off
|
build: off
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- node --version
|
- node --version
|
||||||
- npm --version
|
- npm --version
|
||||||
- npm run test
|
- npm test
|
||||||
# - npm run test-build
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
SET script_path="%~dp0android_sdk_version"
|
SET script_path="%~dp0android_sdk_version"
|
||||||
IF EXIST %script_path% (
|
IF EXIST %script_path% (
|
||||||
node "%script_path%" %*
|
node %script_path% %*
|
||||||
) ELSE (
|
) ELSE (
|
||||||
ECHO.
|
ECHO.
|
||||||
ECHO ERROR: Could not find 'android_sdk_version' script in 'bin' folder, aborting...>&2
|
ECHO ERROR: Could not find 'android_sdk_version' script in 'bin' folder, aborting...>&2
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@
|
|||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
SET script_path="%~dp0check_reqs"
|
SET script_path="%~dp0check_reqs"
|
||||||
IF EXIST %script_path% (
|
IF EXIST %script_path% (
|
||||||
node "%script_path%" %*
|
node %script_path% %*
|
||||||
) ELSE (
|
) ELSE (
|
||||||
ECHO.
|
ECHO.
|
||||||
ECHO ERROR: Could not find 'check_reqs' script in 'bin' folder, aborting...>&2
|
ECHO ERROR: Could not find 'check_reqs' script in 'bin' folder, aborting...>&2
|
||||||
|
|||||||
+37
-30
@@ -19,18 +19,30 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var shell = require('shelljs'),
|
var shell = require('shelljs');
|
||||||
Q = require('q'),
|
var Q = require('q');
|
||||||
path = require('path'),
|
var path = require('path');
|
||||||
fs = require('fs'),
|
var fs = require('fs');
|
||||||
check_reqs = require('./../templates/cordova/lib/check_reqs'),
|
var check_reqs = require('./../templates/cordova/lib/check_reqs');
|
||||||
ROOT = path.join(__dirname, '..', '..');
|
var ROOT = path.join(__dirname, '..', '..');
|
||||||
|
|
||||||
var MIN_SDK_VERSION = 16;
|
var MIN_SDK_VERSION = 16;
|
||||||
|
|
||||||
var CordovaError = require('cordova-common').CordovaError;
|
var CordovaError = require('cordova-common').CordovaError;
|
||||||
var AndroidManifest = require('../templates/cordova/lib/AndroidManifest');
|
var AndroidManifest = require('../templates/cordova/lib/AndroidManifest');
|
||||||
|
|
||||||
|
// Export all helper functions, and make sure internally within this module, we
|
||||||
|
// reference these methods via the `exports` object - this helps with testing
|
||||||
|
// (since we can then mock and control behaviour of all of these functions)
|
||||||
|
exports.validatePackageName = validatePackageName;
|
||||||
|
exports.validateProjectName = validateProjectName;
|
||||||
|
exports.setShellFatal = setShellFatal;
|
||||||
|
exports.copyJsAndLibrary = copyJsAndLibrary;
|
||||||
|
exports.copyScripts = copyScripts;
|
||||||
|
exports.copyBuildRules = copyBuildRules;
|
||||||
|
exports.writeProjectProperties = writeProjectProperties;
|
||||||
|
exports.prepBuildFiles = prepBuildFiles;
|
||||||
|
|
||||||
function setShellFatal (value, func) {
|
function setShellFatal (value, func) {
|
||||||
var oldVal = shell.config.fatal;
|
var oldVal = shell.config.fatal;
|
||||||
shell.config.fatal = value;
|
shell.config.fatal = value;
|
||||||
@@ -57,7 +69,7 @@ function copyJsAndLibrary(projectPath, shared, projectName) {
|
|||||||
shell.cp('-rf', path.join(ROOT, 'cordova-js-src'), path.join(projectPath, 'platform_www'));
|
shell.cp('-rf', path.join(ROOT, 'cordova-js-src'), path.join(projectPath, 'platform_www'));
|
||||||
|
|
||||||
// Don't fail if there are no old jars.
|
// Don't fail if there are no old jars.
|
||||||
setShellFatal(false, function() {
|
exports.setShellFatal(false, function () {
|
||||||
shell.ls(path.join(projectPath, 'libs', 'cordova-*.jar')).forEach(function (oldJar) {
|
shell.ls(path.join(projectPath, 'libs', 'cordova-*.jar')).forEach(function (oldJar) {
|
||||||
console.log('Deleting ' + oldJar);
|
console.log('Deleting ' + oldJar);
|
||||||
shell.rm('-f', oldJar);
|
shell.rm('-f', oldJar);
|
||||||
@@ -110,9 +122,8 @@ function writeProjectProperties(projectPath, target_api) {
|
|||||||
var subProjects = extractSubProjectPaths(data);
|
var subProjects = extractSubProjectPaths(data);
|
||||||
subProjects = subProjects.filter(function (p) {
|
subProjects = subProjects.filter(function (p) {
|
||||||
return !(/^CordovaLib$/m.exec(p) ||
|
return !(/^CordovaLib$/m.exec(p) ||
|
||||||
/[\\\/]cordova-android[\\\/]framework$/m.exec(p) ||
|
/[\\/]cordova-android[\\/]framework$/m.exec(p) ||
|
||||||
/^(\.\.[\\\/])+framework$/m.exec(p)
|
/^(\.\.[\\/])+framework$/m.exec(p));
|
||||||
);
|
|
||||||
});
|
});
|
||||||
subProjects.unshift('CordovaLib');
|
subProjects.unshift('CordovaLib');
|
||||||
data = data.replace(/^\s*android\.library\.reference\.\d+=.*\n/mg, '');
|
data = data.replace(/^\s*android\.library\.reference\.\d+=.*\n/mg, '');
|
||||||
@@ -169,6 +180,7 @@ function validatePackageName(package_name) {
|
|||||||
// http://developer.android.com/guide/topics/manifest/manifest-element.html#package
|
// http://developer.android.com/guide/topics/manifest/manifest-element.html#package
|
||||||
// Enforce underscore limitation
|
// Enforce underscore limitation
|
||||||
var msg = 'Error validating package name. ';
|
var msg = 'Error validating package name. ';
|
||||||
|
|
||||||
if (!/^[a-zA-Z][a-zA-Z0-9_]+(\.[a-zA-Z][a-zA-Z0-9_]*)+$/.test(package_name)) {
|
if (!/^[a-zA-Z][a-zA-Z0-9_]+(\.[a-zA-Z][a-zA-Z0-9_]*)+$/.test(package_name)) {
|
||||||
return Q.reject(new CordovaError(msg + 'Package name must look like: com.company.Name'));
|
return Q.reject(new CordovaError(msg + 'Package name must look like: com.company.Name'));
|
||||||
}
|
}
|
||||||
@@ -235,7 +247,7 @@ exports.create = function(project_path, config, options, events) {
|
|||||||
return Q.reject(new CordovaError('Project already exists! Delete and recreate'));
|
return Q.reject(new CordovaError('Project already exists! Delete and recreate'));
|
||||||
}
|
}
|
||||||
|
|
||||||
var package_name = config.packageName() || 'my.cordova.project';
|
var package_name = config.android_packageName() || config.packageName() || 'my.cordova.project';
|
||||||
var project_name = config.name() ?
|
var project_name = config.name() ?
|
||||||
config.name().replace(/[^\w.]/g, '_') : 'CordovaExample';
|
config.name().replace(/[^\w.]/g, '_') : 'CordovaExample';
|
||||||
|
|
||||||
@@ -243,9 +255,9 @@ exports.create = function(project_path, config, options, events) {
|
|||||||
var target_api = check_reqs.get_target();
|
var target_api = check_reqs.get_target();
|
||||||
|
|
||||||
// Make the package conform to Java package types
|
// Make the package conform to Java package types
|
||||||
return validatePackageName(package_name)
|
return exports.validatePackageName(package_name)
|
||||||
.then(function () {
|
.then(function () {
|
||||||
validateProjectName(project_name);
|
exports.validateProjectName(project_name);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
// Log the given values for the project
|
// Log the given values for the project
|
||||||
events.emit('log', 'Creating Cordova project for the Android platform:');
|
events.emit('log', 'Creating Cordova project for the Android platform:');
|
||||||
@@ -257,7 +269,7 @@ exports.create = function(project_path, config, options, events) {
|
|||||||
|
|
||||||
events.emit('verbose', 'Copying android template project to ' + project_path);
|
events.emit('verbose', 'Copying android template project to ' + project_path);
|
||||||
|
|
||||||
setShellFatal(true, function() {
|
exports.setShellFatal(true, function () {
|
||||||
var project_template_dir = options.customTemplate || path.join(ROOT, 'bin', 'templates', 'project');
|
var project_template_dir = options.customTemplate || path.join(ROOT, 'bin', 'templates', 'project');
|
||||||
// copy project template
|
// copy project template
|
||||||
shell.cp('-r', path.join(project_template_dir, 'assets'), project_path);
|
shell.cp('-r', path.join(project_template_dir, 'assets'), project_path);
|
||||||
@@ -268,7 +280,7 @@ exports.create = function(project_path, config, options, events) {
|
|||||||
shell.mkdir(path.join(project_path, 'libs'));
|
shell.mkdir(path.join(project_path, 'libs'));
|
||||||
|
|
||||||
// copy cordova.js, cordova.jar
|
// copy cordova.js, cordova.jar
|
||||||
copyJsAndLibrary(project_path, options.link, safe_activity_name);
|
exports.copyJsAndLibrary(project_path, options.link, safe_activity_name);
|
||||||
|
|
||||||
// interpolate the activity name and package
|
// interpolate the activity name and package
|
||||||
var packagePath = package_name.replace(/\./g, path.sep);
|
var packagePath = package_name.replace(/\./g, path.sep);
|
||||||
@@ -288,19 +300,19 @@ exports.create = function(project_path, config, options, events) {
|
|||||||
var manifest_path = path.join(project_path, 'AndroidManifest.xml');
|
var manifest_path = path.join(project_path, 'AndroidManifest.xml');
|
||||||
manifest.write(manifest_path);
|
manifest.write(manifest_path);
|
||||||
|
|
||||||
copyScripts(project_path);
|
exports.copyScripts(project_path);
|
||||||
copyBuildRules(project_path);
|
exports.copyBuildRules(project_path);
|
||||||
});
|
});
|
||||||
// Link it to local android install.
|
// Link it to local android install.
|
||||||
writeProjectProperties(project_path, target_api);
|
exports.writeProjectProperties(project_path, target_api);
|
||||||
prepBuildFiles(project_path);
|
exports.prepBuildFiles(project_path);
|
||||||
events.emit('log', generateDoneMessage('create', options.link));
|
events.emit('log', generateDoneMessage('create', options.link));
|
||||||
}).thenResolve(project_path);
|
}).thenResolve(project_path);
|
||||||
};
|
};
|
||||||
|
|
||||||
function generateDoneMessage (type, link) {
|
function generateDoneMessage (type, link) {
|
||||||
var pkg = require('../../package');
|
var pkg = require('../../package');
|
||||||
var msg = 'Android project ' + (type == 'update' ? 'updated ' : 'created ') + 'with ' + pkg.name + '@' + pkg.version;
|
var msg = 'Android project ' + (type === 'update' ? 'updated ' : 'created ') + 'with ' + pkg.name + '@' + pkg.version;
|
||||||
if (link) {
|
if (link) {
|
||||||
msg += ' and has a linked CordovaLib';
|
msg += ' and has a linked CordovaLib';
|
||||||
}
|
}
|
||||||
@@ -326,16 +338,11 @@ exports.update = function(projectPath, options, events) {
|
|||||||
var projectName = manifest.getActivity().getName();
|
var projectName = manifest.getActivity().getName();
|
||||||
var target_api = check_reqs.get_target();
|
var target_api = check_reqs.get_target();
|
||||||
|
|
||||||
copyJsAndLibrary(projectPath, options.link, projectName);
|
exports.copyJsAndLibrary(projectPath, options.link, projectName);
|
||||||
copyScripts(projectPath);
|
exports.copyScripts(projectPath);
|
||||||
copyBuildRules(projectPath);
|
exports.copyBuildRules(projectPath);
|
||||||
writeProjectProperties(projectPath, target_api);
|
exports.writeProjectProperties(projectPath, target_api);
|
||||||
prepBuildFiles(projectPath);
|
exports.prepBuildFiles(projectPath);
|
||||||
events.emit('log', generateDoneMessage('update', options.link));
|
events.emit('log', generateDoneMessage('update', options.link));
|
||||||
}).thenResolve(projectPath);
|
}).thenResolve(projectPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// For testing
|
|
||||||
exports.validatePackageName = validatePackageName;
|
|
||||||
exports.validateProjectName = validateProjectName;
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"node": true
|
|
||||||
, "bitwise": true
|
|
||||||
, "undef": true
|
|
||||||
, "trailing": true
|
|
||||||
, "quotmark": true
|
|
||||||
, "indent": 4
|
|
||||||
, "unused": "vars"
|
|
||||||
, "latedef": "nofunc"
|
|
||||||
}
|
|
||||||
Vendored
+13
-32
@@ -29,7 +29,6 @@ var selfEvents = require('cordova-common').events;
|
|||||||
|
|
||||||
var PLATFORM = 'android';
|
var PLATFORM = 'android';
|
||||||
|
|
||||||
|
|
||||||
function setupEvents (externalEventEmitter) {
|
function setupEvents (externalEventEmitter) {
|
||||||
if (externalEventEmitter) {
|
if (externalEventEmitter) {
|
||||||
// This will make the platform internal events visible outside
|
// This will make the platform internal events visible outside
|
||||||
@@ -43,7 +42,6 @@ function setupEvents(externalEventEmitter) {
|
|||||||
return selfEvents;
|
return selfEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class, that acts as abstraction over particular platform. Encapsulates the
|
* Class, that acts as abstraction over particular platform. Encapsulates the
|
||||||
* platform's properties and methods.
|
* platform's properties and methods.
|
||||||
@@ -112,14 +110,11 @@ Api.createPlatform = function (destination, config, options, events) {
|
|||||||
events = setupEvents(events);
|
events = setupEvents(events);
|
||||||
var result;
|
var result;
|
||||||
try {
|
try {
|
||||||
result = require('../../lib/create')
|
result = require('../../lib/create').create(destination, config, options, events).then(function (destination) {
|
||||||
.create(destination, config, options, events)
|
|
||||||
.then(function (destination) {
|
|
||||||
var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
|
var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
|
||||||
return new PlatformApi(PLATFORM, destination, events);
|
return new PlatformApi(PLATFORM, destination, events);
|
||||||
});
|
});
|
||||||
}
|
} catch (e) {
|
||||||
catch (e) {
|
|
||||||
events.emit('error', 'createPlatform is not callable from the android project API.');
|
events.emit('error', 'createPlatform is not callable from the android project API.');
|
||||||
throw (e);
|
throw (e);
|
||||||
}
|
}
|
||||||
@@ -146,14 +141,11 @@ Api.updatePlatform = function (destination, options, events) {
|
|||||||
events = setupEvents(events);
|
events = setupEvents(events);
|
||||||
var result;
|
var result;
|
||||||
try {
|
try {
|
||||||
result = require('../../lib/create')
|
result = require('../../lib/create').update(destination, options, events).then(function (destination) {
|
||||||
.update(destination, options, events)
|
|
||||||
.then(function (destination) {
|
|
||||||
var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
|
var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
|
||||||
return new PlatformApi('android', destination, events);
|
return new PlatformApi('android', destination, events);
|
||||||
});
|
});
|
||||||
}
|
} catch (e) {
|
||||||
catch (e) {
|
|
||||||
events.emit('error', 'updatePlatform is not callable from the android project API, you will need to do this manually.');
|
events.emit('error', 'updatePlatform is not callable from the android project API, you will need to do this manually.');
|
||||||
throw (e);
|
throw (e);
|
||||||
}
|
}
|
||||||
@@ -230,8 +222,7 @@ Api.prototype.addPlugin = function (plugin, installOptions) {
|
|||||||
installOptions.android_studio = true;
|
installOptions.android_studio = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Q()
|
return Q().then(function () {
|
||||||
.then(function () {
|
|
||||||
// CB-11964: Do a clean when installing the plugin code to get around
|
// CB-11964: Do a clean when installing the plugin code to get around
|
||||||
// the Gradle bug introduced by the Android Gradle Plugin Version 2.2
|
// the Gradle bug introduced by the Android Gradle Plugin Version 2.2
|
||||||
// TODO: Delete when the next version of Android Gradle plugin comes out
|
// TODO: Delete when the next version of Android Gradle plugin comes out
|
||||||
@@ -248,12 +239,9 @@ Api.prototype.addPlugin = function (plugin, installOptions) {
|
|||||||
if (!AndroidStudio.isAndroidStudioProject(self.root) && !project.isClean()) {
|
if (!AndroidStudio.isAndroidStudioProject(self.root) && !project.isClean()) {
|
||||||
return self.clean(opts);
|
return self.clean(opts);
|
||||||
}
|
}
|
||||||
})
|
}).then(function () {
|
||||||
.then(function () {
|
return PluginManager.get(self.platform, self.locations, project).addPlugin(plugin, installOptions);
|
||||||
return PluginManager.get(self.platform, self.locations, project)
|
}).then(function () {
|
||||||
.addPlugin(plugin, installOptions);
|
|
||||||
})
|
|
||||||
.then(function () {
|
|
||||||
if (plugin.getFrameworks(this.platform).length === 0) return;
|
if (plugin.getFrameworks(this.platform).length === 0) return;
|
||||||
|
|
||||||
selfEvents.emit('verbose', 'Updating build files since android plugin contained <framework>');
|
selfEvents.emit('verbose', 'Updating build files since android plugin contained <framework>');
|
||||||
@@ -343,11 +331,9 @@ Api.prototype.removePlugin = function (plugin, uninstallOptions) {
|
|||||||
*/
|
*/
|
||||||
Api.prototype.build = function (buildOptions) {
|
Api.prototype.build = function (buildOptions) {
|
||||||
var self = this;
|
var self = this;
|
||||||
return require('./lib/check_reqs').run()
|
return require('./lib/check_reqs').run().then(function () {
|
||||||
.then(function () {
|
|
||||||
return require('./lib/build').run.call(self, buildOptions);
|
return require('./lib/build').run.call(self, buildOptions);
|
||||||
})
|
}).then(function (buildResults) {
|
||||||
.then(function (buildResults) {
|
|
||||||
// Cast build result to array of build artifacts
|
// Cast build result to array of build artifacts
|
||||||
return buildResults.apkPaths.map(function (apkPath) {
|
return buildResults.apkPaths.map(function (apkPath) {
|
||||||
return {
|
return {
|
||||||
@@ -374,8 +360,7 @@ Api.prototype.build = function (buildOptions) {
|
|||||||
*/
|
*/
|
||||||
Api.prototype.run = function (runOptions) {
|
Api.prototype.run = function (runOptions) {
|
||||||
var self = this;
|
var self = this;
|
||||||
return require('./lib/check_reqs').run()
|
return require('./lib/check_reqs').run().then(function () {
|
||||||
.then(function () {
|
|
||||||
return require('./lib/run').run.call(self, runOptions);
|
return require('./lib/run').run.call(self, runOptions);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -389,17 +374,13 @@ Api.prototype.run = function(runOptions) {
|
|||||||
*/
|
*/
|
||||||
Api.prototype.clean = function (cleanOptions) {
|
Api.prototype.clean = function (cleanOptions) {
|
||||||
var self = this;
|
var self = this;
|
||||||
return require('./lib/check_reqs').run()
|
return require('./lib/check_reqs').run().then(function () {
|
||||||
.then(function () {
|
|
||||||
return require('./lib/build').runClean.call(self, cleanOptions);
|
return require('./lib/build').runClean.call(self, cleanOptions);
|
||||||
})
|
}).then(function () {
|
||||||
.then(function () {
|
|
||||||
return require('./lib/prepare').clean.call(self, cleanOptions);
|
return require('./lib/prepare').clean.call(self, cleanOptions);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a requirements check for current platform. Each platform defines its
|
* Performs a requirements check for current platform. Each platform defines its
|
||||||
* own set of requirements, which should be resolved before platform can be
|
* own set of requirements, which should be resolved before platform can be
|
||||||
|
|||||||
Vendored
+4
-8
@@ -44,8 +44,7 @@ function isEmulator(line) {
|
|||||||
* devices/emulators
|
* devices/emulators
|
||||||
*/
|
*/
|
||||||
Adb.devices = function (opts) {
|
Adb.devices = function (opts) {
|
||||||
return spawn('adb', ['devices'], {cwd: os.tmpdir()})
|
return spawn('adb', ['devices'], {cwd: os.tmpdir()}).then(function (output) {
|
||||||
.then(function(output) {
|
|
||||||
return output.split('\n').filter(function (line) {
|
return output.split('\n').filter(function (line) {
|
||||||
// Filter out either real devices or emulators, depending on options
|
// Filter out either real devices or emulators, depending on options
|
||||||
return (line && opts && opts.emulators) ? isEmulator(line) : isDevice(line);
|
return (line && opts && opts.emulators) ? isEmulator(line) : isDevice(line);
|
||||||
@@ -59,8 +58,7 @@ Adb.install = function (target, packagePath, opts) {
|
|||||||
events.emit('verbose', 'Installing apk ' + packagePath + ' on target ' + target + '...');
|
events.emit('verbose', 'Installing apk ' + packagePath + ' on target ' + target + '...');
|
||||||
var args = ['-s', target, 'install'];
|
var args = ['-s', target, 'install'];
|
||||||
if (opts && opts.replace) args.push('-r');
|
if (opts && opts.replace) args.push('-r');
|
||||||
return spawn('adb', args.concat(packagePath), {cwd: os.tmpdir()})
|
return spawn('adb', args.concat(packagePath), {cwd: os.tmpdir()}).then(function (output) {
|
||||||
.then(function(output) {
|
|
||||||
// 'adb install' seems to always returns no error, even if installation fails
|
// 'adb install' seems to always returns no error, even if installation fails
|
||||||
// so we catching output to detect installation failure
|
// so we catching output to detect installation failure
|
||||||
if (output.match(/Failure/)) {
|
if (output.match(/Failure/)) {
|
||||||
@@ -86,8 +84,7 @@ Adb.shell = function (target, shellCommand) {
|
|||||||
events.emit('verbose', 'Running adb shell command "' + shellCommand + '" on target ' + target + '...');
|
events.emit('verbose', 'Running adb shell command "' + shellCommand + '" on target ' + target + '...');
|
||||||
var args = ['-s', target, 'shell'];
|
var args = ['-s', target, 'shell'];
|
||||||
shellCommand = shellCommand.split(/\s+/);
|
shellCommand = shellCommand.split(/\s+/);
|
||||||
return spawn('adb', args.concat(shellCommand), {cwd: os.tmpdir()})
|
return spawn('adb', args.concat(shellCommand), {cwd: os.tmpdir()}).catch(function (output) {
|
||||||
.catch(function (output) {
|
|
||||||
return Q.reject(new CordovaError('Failed to execute shell command "' +
|
return Q.reject(new CordovaError('Failed to execute shell command "' +
|
||||||
shellCommand + '"" on device: ' + output));
|
shellCommand + '"" on device: ' + output));
|
||||||
});
|
});
|
||||||
@@ -95,8 +92,7 @@ Adb.shell = function (target, shellCommand) {
|
|||||||
|
|
||||||
Adb.start = function (target, activityName) {
|
Adb.start = function (target, activityName) {
|
||||||
events.emit('verbose', 'Starting application "' + activityName + '" on target ' + target + '...');
|
events.emit('verbose', 'Starting application "' + activityName + '" on target ' + target + '...');
|
||||||
return Adb.shell(target, 'am start -W -a android.intent.action.MAIN -n' + activityName)
|
return Adb.shell(target, 'am start -W -a android.intent.action.MAIN -n' + activityName).catch(function (output) {
|
||||||
.catch(function (output) {
|
|
||||||
return Q.reject(new CordovaError('Failed to start application "' +
|
return Q.reject(new CordovaError('Failed to start application "' +
|
||||||
activityName + '"" on device: ' + output));
|
activityName + '"" on device: ' + output));
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-2
@@ -102,8 +102,7 @@ AndroidManifest.prototype.getActivity = function() {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
['minSdkVersion', 'maxSdkVersion', 'targetSdkVersion']
|
['minSdkVersion', 'maxSdkVersion', 'targetSdkVersion'].forEach(function (sdkPrefName) {
|
||||||
.forEach(function(sdkPrefName) {
|
|
||||||
// Copy variable reference to avoid closure issues
|
// Copy variable reference to avoid closure issues
|
||||||
var prefName = sdkPrefName;
|
var prefName = sdkPrefName;
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -28,8 +28,7 @@ var projectFileCache = {};
|
|||||||
|
|
||||||
function addToPropertyList (projectProperties, key, value) {
|
function addToPropertyList (projectProperties, key, value) {
|
||||||
var i = 1;
|
var i = 1;
|
||||||
while (projectProperties.get(key + '.' + i))
|
while (projectProperties.get(key + '.' + i)) { i++; }
|
||||||
i++;
|
|
||||||
|
|
||||||
projectProperties.set(key + '.' + i, value);
|
projectProperties.set(key + '.' + i, value);
|
||||||
projectProperties.dirty = true;
|
projectProperties.dirty = true;
|
||||||
@@ -54,7 +53,7 @@ function removeFromPropertyList(projectProperties, key, value) {
|
|||||||
|
|
||||||
function getRelativeLibraryPath (parentDir, subDir) {
|
function getRelativeLibraryPath (parentDir, subDir) {
|
||||||
var libraryPath = path.relative(parentDir, subDir);
|
var libraryPath = path.relative(parentDir, subDir);
|
||||||
return (path.sep == '\\') ? libraryPath.replace(/\\/g, '/') : libraryPath;
|
return (path.sep === '\\') ? libraryPath.replace(/\\/g, '/') : libraryPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
function AndroidProject (projectDir) {
|
function AndroidProject (projectDir) {
|
||||||
|
|||||||
+19
-53
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file
|
||||||
@@ -19,8 +17,8 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Q = require('q'),
|
var Q = require('q');
|
||||||
superspawn = require('cordova-common').superspawn;
|
var superspawn = require('cordova-common').superspawn;
|
||||||
|
|
||||||
var suffix_number_regex = /(\d+)$/;
|
var suffix_number_regex = /(\d+)$/;
|
||||||
// Used for sorting Android targets, example strings to sort:
|
// Used for sorting Android targets, example strings to sort:
|
||||||
@@ -46,8 +44,7 @@ function sort_by_largest_numerical_suffix(a, b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports.print_newest_available_sdk_target = function () {
|
module.exports.print_newest_available_sdk_target = function () {
|
||||||
return module.exports.list_targets()
|
return module.exports.list_targets().then(function (targets) {
|
||||||
.then(function(targets) {
|
|
||||||
targets.sort(sort_by_largest_numerical_suffix);
|
targets.sort(sort_by_largest_numerical_suffix);
|
||||||
console.log(targets[0]);
|
console.log(targets[0]);
|
||||||
});
|
});
|
||||||
@@ -68,63 +65,32 @@ module.exports.version_string_to_api_level = {
|
|||||||
'7.1.1': 25
|
'7.1.1': 25
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.list_targets_with_android = function() {
|
function parse_targets (output) {
|
||||||
return superspawn.spawn('android', ['list', 'targets'])
|
var target_out = output.split('\n');
|
||||||
.then(function(stdout) {
|
|
||||||
var target_out = stdout.split('\n');
|
|
||||||
var targets = [];
|
var targets = [];
|
||||||
for (var i = target_out.length - 1; i >= 0; i--) {
|
for (var i = target_out.length - 1; i >= 0; i--) {
|
||||||
if(target_out[i].match(/id:/)) {
|
if (target_out[i].match(/id:/)) { // if "id:" is in the line...
|
||||||
targets.push(target_out[i].match(/"(.+)"/)[1]);
|
targets.push(target_out[i].match(/"(.+)"/)[1]); // .. match whatever is in quotes.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return targets;
|
return targets;
|
||||||
});
|
}
|
||||||
|
|
||||||
|
module.exports.list_targets_with_android = function () {
|
||||||
|
return superspawn.spawn('android', ['list', 'target']).then(parse_targets);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.list_targets_with_sdkmanager = function() {
|
module.exports.list_targets_with_avdmanager = function () {
|
||||||
return superspawn.spawn('sdkmanager', ['--list'])
|
return superspawn.spawn('avdmanager', ['list', 'target']).then(parse_targets);
|
||||||
.then(function(stdout) {
|
|
||||||
var parsing_installed_packages = false;
|
|
||||||
var lines = stdout.split('\n');
|
|
||||||
var targets = [];
|
|
||||||
for (var i = 0, l = lines.length; i < l; i++) {
|
|
||||||
var line = lines[i];
|
|
||||||
if (line.match(/Installed packages/)) {
|
|
||||||
parsing_installed_packages = true;
|
|
||||||
} else if (line.match(/Available Packages/) || line.match(/Available Updates/)) {
|
|
||||||
// we are done working through installed packages, exit
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (parsing_installed_packages) {
|
|
||||||
// Match stock android platform
|
|
||||||
if (line.match(/platforms;android-\d+/)) {
|
|
||||||
targets.push(line.match(/(android-\d+)/)[1]);
|
|
||||||
}
|
|
||||||
// Match Google APIs
|
|
||||||
if (line.match(/addon-google_apis-google-\d+/)) {
|
|
||||||
var description = lines[i + 1];
|
|
||||||
// munge description to match output from old android sdk tooling
|
|
||||||
var api_level = description.match(/Android (\d+)/); //[1];
|
|
||||||
if (api_level) {
|
|
||||||
targets.push('Google Inc.:Google APIs:' + api_level[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO: match anything else?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return targets;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.list_targets = function () {
|
module.exports.list_targets = function () {
|
||||||
return module.exports.list_targets_with_android()
|
return module.exports.list_targets_with_avdmanager().catch(function (err) {
|
||||||
.catch(function(err) {
|
// If there's an error, like avdmanager could not be found, we can try
|
||||||
// there's a chance `android` no longer works.
|
// as a last resort, to run `android`, in case this is a super old
|
||||||
// lets see if `sdkmanager` is available and we can figure it out
|
// SDK installation.
|
||||||
var avail_regex = /"?android"? command is no longer available/;
|
if (err && (err.code === 'ENOENT' || (err.stderr && err.stderr.match(/not recognized/)))) {
|
||||||
if (err.code && ((err.stdout && err.stdout.match(avail_regex)) || (err.stderr && err.stderr.match(avail_regex)))) {
|
return module.exports.list_targets_with_android();
|
||||||
return module.exports.list_targets_with_sdkmanager();
|
|
||||||
} else throw err;
|
} else throw err;
|
||||||
}).then(function (targets) {
|
}).then(function (targets) {
|
||||||
if (targets.length === 0) {
|
if (targets.length === 0) {
|
||||||
|
|||||||
Vendored
+19
-34
@@ -19,10 +19,10 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Q = require('q'),
|
var Q = require('q');
|
||||||
path = require('path'),
|
var path = require('path');
|
||||||
fs = require('fs'),
|
var fs = require('fs');
|
||||||
nopt = require('nopt');
|
var nopt = require('nopt');
|
||||||
|
|
||||||
var Adb = require('./Adb');
|
var Adb = require('./Adb');
|
||||||
|
|
||||||
@@ -55,16 +55,13 @@ function parseOpts(options, resolvedTarget, projectRoot) {
|
|||||||
extraArgs: []
|
extraArgs: []
|
||||||
};
|
};
|
||||||
|
|
||||||
if (options.argv.ant || options.argv.gradle)
|
if (options.argv.ant || options.argv.gradle) { ret.buildMethod = options.argv.ant ? 'ant' : 'gradle'; }
|
||||||
ret.buildMethod = options.argv.ant ? 'ant' : 'gradle';
|
|
||||||
|
|
||||||
if (options.nobuild) ret.buildMethod = 'none';
|
if (options.nobuild) ret.buildMethod = 'none';
|
||||||
|
|
||||||
if (options.argv.versionCode)
|
if (options.argv.versionCode) { ret.extraArgs.push('-PcdvVersionCode=' + options.argv.versionCode); }
|
||||||
ret.extraArgs.push('-PcdvVersionCode=' + options.argv.versionCode);
|
|
||||||
|
|
||||||
if (options.argv.minSdkVersion)
|
if (options.argv.minSdkVersion) { ret.extraArgs.push('-PcdvMinSdkVersion=' + options.argv.minSdkVersion); }
|
||||||
ret.extraArgs.push('-PcdvMinSdkVersion=' + options.argv.minSdkVersion);
|
|
||||||
|
|
||||||
if (options.argv.gradleArg) {
|
if (options.argv.gradleArg) {
|
||||||
ret.extraArgs = ret.extraArgs.concat(options.argv.gradleArg);
|
ret.extraArgs = ret.extraArgs.concat(options.argv.gradleArg);
|
||||||
@@ -72,12 +69,10 @@ function parseOpts(options, resolvedTarget, projectRoot) {
|
|||||||
|
|
||||||
var packageArgs = {};
|
var packageArgs = {};
|
||||||
|
|
||||||
if (options.argv.keystore)
|
if (options.argv.keystore) { packageArgs.keystore = path.relative(projectRoot, path.resolve(options.argv.keystore)); }
|
||||||
packageArgs.keystore = path.relative(projectRoot, path.resolve(options.argv.keystore));
|
|
||||||
|
|
||||||
['alias', 'storePassword', 'password', 'keystoreType'].forEach(function (flagName) {
|
['alias', 'storePassword', 'password', 'keystoreType'].forEach(function (flagName) {
|
||||||
if (options.argv[flagName])
|
if (options.argv[flagName]) { packageArgs[flagName] = options.argv[flagName]; }
|
||||||
packageArgs[flagName] = options.argv[flagName];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var buildConfig = options.buildConfig;
|
var buildConfig = options.buildConfig;
|
||||||
@@ -128,8 +123,7 @@ function parseOpts(options, resolvedTarget, projectRoot) {
|
|||||||
module.exports.runClean = function (options) {
|
module.exports.runClean = function (options) {
|
||||||
var opts = parseOpts(options, null, this.root);
|
var opts = parseOpts(options, null, this.root);
|
||||||
var builder = builders.getBuilder(opts.buildMethod);
|
var builder = builders.getBuilder(opts.buildMethod);
|
||||||
return builder.prepEnv(opts)
|
return builder.prepEnv(opts).then(function () {
|
||||||
.then(function() {
|
|
||||||
return builder.clean(opts);
|
return builder.clean(opts);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -149,14 +143,12 @@ module.exports.runClean = function(options) {
|
|||||||
module.exports.run = function (options, optResolvedTarget) {
|
module.exports.run = function (options, optResolvedTarget) {
|
||||||
var opts = parseOpts(options, optResolvedTarget, this.root);
|
var opts = parseOpts(options, optResolvedTarget, this.root);
|
||||||
var builder = builders.getBuilder(opts.buildMethod);
|
var builder = builders.getBuilder(opts.buildMethod);
|
||||||
return builder.prepEnv(opts)
|
return builder.prepEnv(opts).then(function () {
|
||||||
.then(function() {
|
|
||||||
if (opts.prepEnv) {
|
if (opts.prepEnv) {
|
||||||
events.emit('verbose', 'Build file successfully prepared.');
|
events.emit('verbose', 'Build file successfully prepared.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return builder.build(opts)
|
return builder.build(opts).then(function () {
|
||||||
.then(function() {
|
|
||||||
var apkPaths = builder.findOutputApks(opts.buildType, opts.arch);
|
var apkPaths = builder.findOutputApks(opts.buildType, opts.arch);
|
||||||
events.emit('log', 'Built the following apk(s): \n\t' + apkPaths.join('\n\t'));
|
events.emit('log', 'Built the following apk(s): \n\t' + apkPaths.join('\n\t'));
|
||||||
return {
|
return {
|
||||||
@@ -174,31 +166,24 @@ module.exports.run = function(options, optResolvedTarget) {
|
|||||||
*/
|
*/
|
||||||
module.exports.detectArchitecture = function (target) {
|
module.exports.detectArchitecture = function (target) {
|
||||||
function helper () {
|
function helper () {
|
||||||
return Adb.shell(target, 'cat /proc/cpuinfo')
|
return Adb.shell(target, 'cat /proc/cpuinfo').then(function (output) {
|
||||||
.then(function(output) {
|
|
||||||
return /intel/i.exec(output) ? 'x86' : 'arm';
|
return /intel/i.exec(output) ? 'x86' : 'arm';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// It sometimes happens (at least on OS X), that this command will hang forever.
|
// It sometimes happens (at least on OS X), that this command will hang forever.
|
||||||
// To fix it, either unplug & replug device, or restart adb server.
|
// To fix it, either unplug & replug device, or restart adb server.
|
||||||
return helper()
|
return helper().timeout(1000, new CordovaError('Device communication timed out. Try unplugging & replugging the device.')).then(null, function (err) {
|
||||||
.timeout(1000, new CordovaError('Device communication timed out. Try unplugging & replugging the device.'))
|
|
||||||
.then(null, function(err) {
|
|
||||||
if (/timed out/.exec('' + err)) {
|
if (/timed out/.exec('' + err)) {
|
||||||
// adb kill-server doesn't seem to do the trick.
|
// adb kill-server doesn't seem to do the trick.
|
||||||
// Could probably find a x-platform version of killall, but I'm not actually
|
// Could probably find a x-platform version of killall, but I'm not actually
|
||||||
// sure that this scenario even happens on non-OSX machines.
|
// sure that this scenario even happens on non-OSX machines.
|
||||||
events.emit('verbose', 'adb timed out while detecting device/emulator architecture. Killing adb and trying again.');
|
events.emit('verbose', 'adb timed out while detecting device/emulator architecture. Killing adb and trying again.');
|
||||||
return spawn('killall', ['adb'])
|
return spawn('killall', ['adb']).then(function () {
|
||||||
.then(function() {
|
return helper().then(null, function () {
|
||||||
return helper()
|
|
||||||
.then(null, function() {
|
|
||||||
// The double kill is sadly often necessary, at least on mac.
|
// The double kill is sadly often necessary, at least on mac.
|
||||||
events.emit('warn', 'adb timed out a second time while detecting device/emulator architecture. Killing adb and trying again.');
|
events.emit('warn', 'adb timed out a second time while detecting device/emulator architecture. Killing adb and trying again.');
|
||||||
return spawn('killall', ['adb'])
|
return spawn('killall', ['adb']).then(function () {
|
||||||
.then(function() {
|
return helper().then(null, function () {
|
||||||
return helper()
|
|
||||||
.then(null, function() {
|
|
||||||
return Q.reject(new CordovaError('adb timed out a third time while detecting device/emulator architecture. Try unplugging & replugging the device.'));
|
return Q.reject(new CordovaError('adb timed out a third time while detecting device/emulator architecture. Try unplugging & replugging the device.'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -215,7 +200,7 @@ module.exports.detectArchitecture = function(target) {
|
|||||||
module.exports.findBestApkForArchitecture = function (buildResults, arch) {
|
module.exports.findBestApkForArchitecture = function (buildResults, arch) {
|
||||||
var paths = buildResults.apkPaths.filter(function (p) {
|
var paths = buildResults.apkPaths.filter(function (p) {
|
||||||
var apkName = path.basename(p);
|
var apkName = path.basename(p);
|
||||||
if (buildResults.buildType == 'debug') {
|
if (buildResults.buildType === 'debug') {
|
||||||
return /-debug/.exec(apkName);
|
return /-debug/.exec(apkName);
|
||||||
}
|
}
|
||||||
return !/-debug/.exec(apkName);
|
return !/-debug/.exec(apkName);
|
||||||
|
|||||||
+6
-9
@@ -16,6 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
/* eslint no-unused-vars: 0 */
|
||||||
|
|
||||||
var Q = require('q');
|
var Q = require('q');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
@@ -56,8 +57,7 @@ AntBuilder.prototype.getArgs = function(cmd, opts) {
|
|||||||
|
|
||||||
AntBuilder.prototype.prepEnv = function (opts) {
|
AntBuilder.prototype.prepEnv = function (opts) {
|
||||||
var self = this;
|
var self = this;
|
||||||
return check_reqs.check_ant()
|
return check_reqs.check_ant().then(function () {
|
||||||
.then(function() {
|
|
||||||
// Copy in build.xml on each build so that:
|
// Copy in build.xml on each build so that:
|
||||||
// A) we don't require the Android SDK at project creation time, and
|
// A) we don't require the Android SDK at project creation time, and
|
||||||
// B) we always use the SDK's latest version of it.
|
// B) we always use the SDK's latest version of it.
|
||||||
@@ -104,9 +104,8 @@ AntBuilder.prototype.build = function(opts) {
|
|||||||
ret = this.clean(opts);
|
ret = this.clean(opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
var args = this.getArgs(opts.buildType == 'debug' ? 'debug' : 'release', opts);
|
var args = this.getArgs(opts.buildType === 'debug' ? 'debug' : 'release', opts);
|
||||||
return check_reqs.check_ant()
|
return check_reqs.check_ant().then(function () {
|
||||||
.then(function() {
|
|
||||||
return spawn('ant', args, {stdio: 'pipe'});
|
return spawn('ant', args, {stdio: 'pipe'});
|
||||||
}).progress(function (stdio) {
|
}).progress(function (stdio) {
|
||||||
if (stdio.stderr) {
|
if (stdio.stderr) {
|
||||||
@@ -129,11 +128,9 @@ AntBuilder.prototype.build = function(opts) {
|
|||||||
AntBuilder.prototype.clean = function (opts) {
|
AntBuilder.prototype.clean = function (opts) {
|
||||||
var args = this.getArgs('clean', opts);
|
var args = this.getArgs('clean', opts);
|
||||||
var self = this;
|
var self = this;
|
||||||
return check_reqs.check_ant()
|
return check_reqs.check_ant().then(function () {
|
||||||
.then(function() {
|
|
||||||
return spawn('ant', args, {stdio: 'inherit'});
|
return spawn('ant', args, {stdio: 'inherit'});
|
||||||
})
|
}).then(function () {
|
||||||
.then(function () {
|
|
||||||
shell.rm('-rf', path.join(self.root, 'out'));
|
shell.rm('-rf', path.join(self.root, 'out'));
|
||||||
|
|
||||||
['debug', 'release'].forEach(function (config) {
|
['debug', 'release'].forEach(function (config) {
|
||||||
|
|||||||
+8
-10
@@ -16,6 +16,8 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
/* eslint no-self-assign: 0 */
|
||||||
|
/* eslint no-unused-vars: 0 */
|
||||||
|
|
||||||
var Q = require('q');
|
var Q = require('q');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
@@ -51,12 +53,10 @@ GenericBuilder.prototype.clean = function() {
|
|||||||
|
|
||||||
GenericBuilder.prototype.findOutputApks = function (build_type, arch) {
|
GenericBuilder.prototype.findOutputApks = function (build_type, arch) {
|
||||||
var self = this;
|
var self = this;
|
||||||
return Object.keys(this.binDirs)
|
return Object.keys(this.binDirs).reduce(function (result, builderName) {
|
||||||
.reduce(function (result, builderName) {
|
|
||||||
var binDir = self.binDirs[builderName];
|
var binDir = self.binDirs[builderName];
|
||||||
return result.concat(findOutputApksHelper(binDir, build_type, builderName === 'ant' ? null : arch));
|
return result.concat(findOutputApksHelper(binDir, build_type, builderName === 'ant' ? null : arch));
|
||||||
}, [])
|
}, []).sort(apkSorter);
|
||||||
.sort(apkSorter);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GenericBuilder.prototype.readProjectProperties = function () {
|
GenericBuilder.prototype.readProjectProperties = function () {
|
||||||
@@ -109,8 +109,7 @@ function findOutputApksHelper(dir, build_type, arch) {
|
|||||||
var shellSilent = shell.config.silent;
|
var shellSilent = shell.config.silent;
|
||||||
shell.config.silent = true;
|
shell.config.silent = true;
|
||||||
|
|
||||||
var ret = shell.ls(path.join(dir, '*.apk'))
|
var ret = shell.ls(path.join(dir, '*.apk')).filter(function (candidate) {
|
||||||
.filter(function(candidate) {
|
|
||||||
var apkName = path.basename(candidate);
|
var apkName = path.basename(candidate);
|
||||||
// Need to choose between release and debug .apk.
|
// Need to choose between release and debug .apk.
|
||||||
if (build_type === 'debug') {
|
if (build_type === 'debug') {
|
||||||
@@ -120,8 +119,7 @@ function findOutputApksHelper(dir, build_type, arch) {
|
|||||||
return /-release/.exec(apkName) && !/-unaligned/.exec(apkName);
|
return /-release/.exec(apkName) && !/-unaligned/.exec(apkName);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
})
|
}).sort(apkSorter);
|
||||||
.sort(apkSorter);
|
|
||||||
|
|
||||||
shellSilent = shellSilent;
|
shellSilent = shellSilent;
|
||||||
|
|
||||||
@@ -133,13 +131,13 @@ function findOutputApksHelper(dir, build_type, arch) {
|
|||||||
// And show only arch-specific ones (or non-arch-specific)
|
// And show only arch-specific ones (or non-arch-specific)
|
||||||
ret = ret.filter(function (p) {
|
ret = ret.filter(function (p) {
|
||||||
/* jshint -W018 */
|
/* jshint -W018 */
|
||||||
return !!/-x86|-arm/.exec(path.basename(p)) == archSpecific;
|
return !!/-x86|-arm/.exec(path.basename(p)) === archSpecific;
|
||||||
/* jshint +W018 */
|
/* jshint +W018 */
|
||||||
});
|
});
|
||||||
|
|
||||||
if (archSpecific && ret.length > 1 && arch) {
|
if (archSpecific && ret.length > 1 && arch) {
|
||||||
ret = ret.filter(function (p) {
|
ret = ret.filter(function (p) {
|
||||||
return path.basename(p).indexOf('-' + arch) != -1;
|
return path.basename(p).indexOf('-' + arch) !== -1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+37
-35
@@ -22,7 +22,7 @@ var fs = require('fs');
|
|||||||
var util = require('util');
|
var util = require('util');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var shell = require('shelljs');
|
var shell = require('shelljs');
|
||||||
var spawn = require('cordova-common').superspawn.spawn;
|
var superspawn = require('cordova-common').superspawn;
|
||||||
var CordovaError = require('cordova-common').CordovaError;
|
var CordovaError = require('cordova-common').CordovaError;
|
||||||
var check_reqs = require('../check_reqs');
|
var check_reqs = require('../check_reqs');
|
||||||
|
|
||||||
@@ -43,9 +43,9 @@ function GradleBuilder (projectRoot) {
|
|||||||
util.inherits(GradleBuilder, GenericBuilder);
|
util.inherits(GradleBuilder, GenericBuilder);
|
||||||
|
|
||||||
GradleBuilder.prototype.getArgs = function (cmd, opts) {
|
GradleBuilder.prototype.getArgs = function (cmd, opts) {
|
||||||
if (cmd == 'release') {
|
if (cmd === 'release') {
|
||||||
cmd = 'cdvBuildRelease';
|
cmd = 'cdvBuildRelease';
|
||||||
} else if (cmd == 'debug') {
|
} else if (cmd === 'debug') {
|
||||||
cmd = 'cdvBuildDebug';
|
cmd = 'cdvBuildDebug';
|
||||||
}
|
}
|
||||||
var args = [cmd, '-b', path.join(this.root, 'build.gradle')];
|
var args = [cmd, '-b', path.join(this.root, 'build.gradle')];
|
||||||
@@ -69,17 +69,19 @@ GradleBuilder.prototype.getArgs = function(cmd, opts) {
|
|||||||
* This returns a promise
|
* This returns a promise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GradleBuilder.prototype.runGradleWrapper = function(gradle_cmd) {
|
GradleBuilder.prototype.runGradleWrapper = function (gradle_cmd, gradle_file) {
|
||||||
var gradlePath = path.join(this.root, 'gradlew');
|
var gradlePath = path.join(this.root, 'gradlew');
|
||||||
var wrapperGradle = path.join(this.root, 'wrapper.gradle');
|
gradle_file = path.join(this.root, (gradle_file || 'wrapper.gradle'));
|
||||||
if (fs.existsSync(gradlePath)) {
|
if (fs.existsSync(gradlePath)) {
|
||||||
// Literally do nothing, for some reason this works, while !fs.existsSync didn't on Windows
|
// Literally do nothing, for some reason this works, while !fs.existsSync didn't on Windows
|
||||||
} else {
|
} else {
|
||||||
return spawn(gradle_cmd, ['-p', this.root, 'wrapper', '-b', wrapperGradle], {stdio: 'inherit'});
|
return superspawn.spawn(gradle_cmd, ['-p', this.root, 'wrapper', '-b', gradle_file], { stdio: 'pipe' })
|
||||||
|
.progress(function (stdio) {
|
||||||
|
suppressJavaOptionsInfo(stdio);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Makes the project buildable, minus the gradle wrapper.
|
// Makes the project buildable, minus the gradle wrapper.
|
||||||
GradleBuilder.prototype.prepBuildFiles = function () {
|
GradleBuilder.prototype.prepBuildFiles = function () {
|
||||||
// Update the version of build.gradle in each dependent library.
|
// Update the version of build.gradle in each dependent library.
|
||||||
@@ -107,8 +109,7 @@ GradleBuilder.prototype.prepBuildFiles = function() {
|
|||||||
var realDir = p.replace(/[/\\]/g, ':');
|
var realDir = p.replace(/[/\\]/g, ':');
|
||||||
var libName = realDir.replace(name + '-', '');
|
var libName = realDir.replace(name + '-', '');
|
||||||
var str = 'include ":' + libName + '"\n';
|
var str = 'include ":' + libName + '"\n';
|
||||||
if(realDir.indexOf(name+'-')!==-1)
|
if (realDir.indexOf(name + '-') !== -1) { str += 'project(":' + libName + '").projectDir = new File("' + p + '")\n'; }
|
||||||
str+='project(":'+libName+'").projectDir = new File("'+p+'")\n';
|
|
||||||
return str;
|
return str;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -123,10 +124,9 @@ GradleBuilder.prototype.prepBuildFiles = function() {
|
|||||||
var insertExclude = function (p) {
|
var insertExclude = function (p) {
|
||||||
var gradlePath = path.join(root, p, 'build.gradle');
|
var gradlePath = path.join(root, p, 'build.gradle');
|
||||||
var projectGradleFile = fs.readFileSync(gradlePath, 'utf-8');
|
var projectGradleFile = fs.readFileSync(gradlePath, 'utf-8');
|
||||||
if(projectGradleFile.indexOf('CordovaLib') != -1) {
|
if (projectGradleFile.indexOf('CordovaLib') !== -1) {
|
||||||
depsList += '{\n exclude module:("CordovaLib")\n }\n';
|
depsList += '{\n exclude module:("CordovaLib")\n }\n';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
depsList += '\n';
|
depsList += '\n';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -173,8 +173,7 @@ GradleBuilder.prototype.prepBuildFiles = function() {
|
|||||||
|
|
||||||
GradleBuilder.prototype.prepEnv = function (opts) {
|
GradleBuilder.prototype.prepEnv = function (opts) {
|
||||||
var self = this;
|
var self = this;
|
||||||
return check_reqs.check_gradle()
|
return check_reqs.check_gradle().then(function (gradlePath) {
|
||||||
.then(function(gradlePath) {
|
|
||||||
return self.runGradleWrapper(gradlePath);
|
return self.runGradleWrapper(gradlePath);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return self.prepBuildFiles();
|
return self.prepBuildFiles();
|
||||||
@@ -221,26 +220,11 @@ GradleBuilder.prototype.prepEnv = function(opts) {
|
|||||||
*/
|
*/
|
||||||
GradleBuilder.prototype.build = function (opts) {
|
GradleBuilder.prototype.build = function (opts) {
|
||||||
var wrapper = path.join(this.root, 'gradlew');
|
var wrapper = path.join(this.root, 'gradlew');
|
||||||
var args = this.getArgs(opts.buildType == 'debug' ? 'debug' : 'release', opts);
|
var args = this.getArgs(opts.buildType === 'debug' ? 'debug' : 'release', opts);
|
||||||
|
|
||||||
return spawn(wrapper, args, {stdio: 'pipe'})
|
return superspawn.spawn(wrapper, args, { stdio: 'pipe' })
|
||||||
.progress(function (stdio) {
|
.progress(function (stdio) {
|
||||||
if (stdio.stderr) {
|
suppressJavaOptionsInfo(stdio);
|
||||||
/*
|
|
||||||
* Workaround for the issue with Java printing some unwanted information to
|
|
||||||
* stderr instead of stdout.
|
|
||||||
* This function suppresses 'Picked up _JAVA_OPTIONS' message from being
|
|
||||||
* printed to stderr. See https://issues.apache.org/jira/browse/CB-9971 for
|
|
||||||
* explanation.
|
|
||||||
*/
|
|
||||||
var suppressThisLine = /^Picked up _JAVA_OPTIONS: /i.test(stdio.stderr.toString());
|
|
||||||
if (suppressThisLine) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
process.stderr.write(stdio.stderr);
|
|
||||||
} else {
|
|
||||||
process.stdout.write(stdio.stdout);
|
|
||||||
}
|
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
if (error.toString().indexOf('failed to find target with hash string') >= 0) {
|
if (error.toString().indexOf('failed to find target with hash string') >= 0) {
|
||||||
return check_reqs.check_android_target(error).then(function () {
|
return check_reqs.check_android_target(error).then(function () {
|
||||||
@@ -258,9 +242,8 @@ GradleBuilder.prototype.clean = function(opts) {
|
|||||||
var wrapper = path.join(this.root, 'gradlew');
|
var wrapper = path.join(this.root, 'gradlew');
|
||||||
var args = builder.getArgs('clean', opts);
|
var args = builder.getArgs('clean', opts);
|
||||||
return Q().then(function () {
|
return Q().then(function () {
|
||||||
return spawn(wrapper, args, {stdio: 'inherit'});
|
return superspawn.spawn(wrapper, args, { stdio: 'inherit' });
|
||||||
})
|
}).then(function () {
|
||||||
.then(function () {
|
|
||||||
shell.rm('-rf', path.join(builder.root, 'out'));
|
shell.rm('-rf', path.join(builder.root, 'out'));
|
||||||
|
|
||||||
['debug', 'release'].forEach(function (config) {
|
['debug', 'release'].forEach(function (config) {
|
||||||
@@ -274,6 +257,25 @@ GradleBuilder.prototype.clean = function(opts) {
|
|||||||
|
|
||||||
module.exports = GradleBuilder;
|
module.exports = GradleBuilder;
|
||||||
|
|
||||||
|
function suppressJavaOptionsInfo (stdio) {
|
||||||
|
if (stdio.stderr) {
|
||||||
|
/*
|
||||||
|
* Workaround for the issue with Java printing some unwanted information to
|
||||||
|
* stderr instead of stdout.
|
||||||
|
* This function suppresses 'Picked up _JAVA_OPTIONS' message from being
|
||||||
|
* printed to stderr. See https://issues.apache.org/jira/browse/CB-9971 for
|
||||||
|
* explanation.
|
||||||
|
*/
|
||||||
|
var suppressThisLine = /^Picked up _JAVA_OPTIONS: /i.test(stdio.stderr.toString());
|
||||||
|
if (suppressThisLine) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
process.stderr.write(stdio.stderr);
|
||||||
|
} else {
|
||||||
|
process.stdout.write(stdio.stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function isAutoGenerated (file) {
|
function isAutoGenerated (file) {
|
||||||
return fs.existsSync(file) && fs.readFileSync(file, 'utf8').indexOf(MARKER) > 0;
|
return fs.existsSync(file) && fs.readFileSync(file, 'utf8').indexOf(MARKER) > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -35,8 +35,7 @@ var knownBuilders = {
|
|||||||
* @return {Builder} A builder instance for specified build type.
|
* @return {Builder} A builder instance for specified build type.
|
||||||
*/
|
*/
|
||||||
module.exports.getBuilder = function (builderType, projectRoot) {
|
module.exports.getBuilder = function (builderType, projectRoot) {
|
||||||
if (!knownBuilders[builderType])
|
if (!knownBuilders[builderType]) { throw new CordovaError('Builder ' + builderType + ' is not supported.'); }
|
||||||
throw new CordovaError('Builder ' + builderType + ' is not supported.');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var Builder = require('./' + knownBuilders[builderType]);
|
var Builder = require('./' + knownBuilders[builderType]);
|
||||||
|
|||||||
+42
-34
@@ -21,14 +21,14 @@
|
|||||||
|
|
||||||
/* jshint sub:true */
|
/* jshint sub:true */
|
||||||
|
|
||||||
var shelljs = require('shelljs'),
|
var shelljs = require('shelljs');
|
||||||
child_process = require('child_process'),
|
var child_process = require('child_process');
|
||||||
Q = require('q'),
|
var Q = require('q');
|
||||||
path = require('path'),
|
var path = require('path');
|
||||||
fs = require('fs'),
|
var fs = require('fs');
|
||||||
os = require('os'),
|
var os = require('os');
|
||||||
REPO_ROOT = path.join(__dirname, '..', '..', '..', '..'),
|
var REPO_ROOT = path.join(__dirname, '..', '..', '..', '..');
|
||||||
PROJECT_ROOT = path.join(__dirname, '..', '..');
|
var PROJECT_ROOT = path.join(__dirname, '..', '..');
|
||||||
var CordovaError = require('cordova-common').CordovaError;
|
var CordovaError = require('cordova-common').CordovaError;
|
||||||
var superspawn = require('cordova-common').superspawn;
|
var superspawn = require('cordova-common').superspawn;
|
||||||
var android_sdk = require('./android_sdk');
|
var android_sdk = require('./android_sdk');
|
||||||
@@ -53,11 +53,11 @@ function tryCommand(cmd, errMsg, catchStderr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports.isWindows = function () {
|
module.exports.isWindows = function () {
|
||||||
return (os.platform() == 'win32');
|
return (os.platform() === 'win32');
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.isDarwin = function () {
|
module.exports.isDarwin = function () {
|
||||||
return (os.platform() == 'darwin');
|
return (os.platform() === 'darwin');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get valid target from framework/project.properties if run from this repo
|
// Get valid target from framework/project.properties if run from this repo
|
||||||
@@ -84,12 +84,13 @@ module.exports.get_target = function() {
|
|||||||
|
|
||||||
// Returns a promise. Called only by build and clean commands.
|
// Returns a promise. Called only by build and clean commands.
|
||||||
module.exports.check_ant = function () {
|
module.exports.check_ant = function () {
|
||||||
return superspawn.spawn('ant', ['-version'])
|
return superspawn.spawn('ant', ['-version']).then(function (output) {
|
||||||
.then(function(output) {
|
|
||||||
// Parse Ant version from command output
|
// Parse Ant version from command output
|
||||||
return /version ((?:\d+\.)+(?:\d+))/i.exec(output)[1];
|
return /version ((?:\d+\.)+(?:\d+))/i.exec(output)[1];
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
|
if (err) {
|
||||||
throw new CordovaError('Failed to run `ant -version`. Make sure you have `ant` on your $PATH.');
|
throw new CordovaError('Failed to run `ant -version`. Make sure you have `ant` on your $PATH.');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -108,6 +109,12 @@ module.exports.get_gradle_wrapper = function() {
|
|||||||
} else { ++i; }
|
} else { ++i; }
|
||||||
}
|
}
|
||||||
} else if (module.exports.isWindows()) {
|
} else if (module.exports.isWindows()) {
|
||||||
|
|
||||||
|
var result = child_process.spawnSync(path.join(__dirname, 'getASPath.bat'));
|
||||||
|
// console.log('result.stdout =' + result.stdout.toString());
|
||||||
|
// console.log('result.stderr =' + result.stderr.toString());
|
||||||
|
|
||||||
|
if (result.stderr.toString().length > 0) {
|
||||||
var androidPath = path.join(process.env['ProgramFiles'], 'Android') + '/';
|
var androidPath = path.join(process.env['ProgramFiles'], 'Android') + '/';
|
||||||
if (fs.existsSync(androidPath)) {
|
if (fs.existsSync(androidPath)) {
|
||||||
program_dir = fs.readdirSync(androidPath);
|
program_dir = fs.readdirSync(androidPath);
|
||||||
@@ -118,11 +125,17 @@ module.exports.get_gradle_wrapper = function() {
|
|||||||
} else { ++i; }
|
} else { ++i; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// console.log('got android studio path from registry');
|
||||||
|
// remove the (os independent) new line char at the end of stdout
|
||||||
|
// add gradle to match the above.
|
||||||
|
androidStudioPath = path.join(result.stdout.toString().split('\r\n')[0], 'gradle');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (androidStudioPath !== null && fs.existsSync(androidStudioPath)) {
|
if (androidStudioPath !== null && fs.existsSync(androidStudioPath)) {
|
||||||
var dirs = fs.readdirSync(androidStudioPath);
|
var dirs = fs.readdirSync(androidStudioPath);
|
||||||
if(dirs[0].split('-')[0] == 'gradle') {
|
if (dirs[0].split('-')[0] === 'gradle') {
|
||||||
return path.join(androidStudioPath, dirs[0], 'bin', 'gradle');
|
return path.join(androidStudioPath, dirs[0], 'bin', 'gradle');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -135,17 +148,17 @@ module.exports.get_gradle_wrapper = function() {
|
|||||||
module.exports.check_gradle = function () {
|
module.exports.check_gradle = function () {
|
||||||
var sdkDir = process.env['ANDROID_HOME'];
|
var sdkDir = process.env['ANDROID_HOME'];
|
||||||
var d = Q.defer();
|
var d = Q.defer();
|
||||||
if (!sdkDir)
|
if (!sdkDir) {
|
||||||
return Q.reject(new CordovaError('Could not find gradle wrapper within Android SDK. Could not find Android SDK directory.\n' +
|
return Q.reject(new CordovaError('Could not find gradle wrapper within Android SDK. Could not find Android SDK directory.\n' +
|
||||||
'Might need to install Android SDK or set up \'ANDROID_HOME\' env variable.'));
|
'Might need to install Android SDK or set up \'ANDROID_HOME\' env variable.'));
|
||||||
|
}
|
||||||
|
|
||||||
var gradlePath = module.exports.get_gradle_wrapper();
|
var gradlePath = module.exports.get_gradle_wrapper();
|
||||||
if (gradlePath.length !== 0)
|
if (gradlePath.length !== 0) { d.resolve(gradlePath); } else {
|
||||||
d.resolve(gradlePath);
|
|
||||||
else
|
|
||||||
d.reject(new CordovaError('Could not find an installed version of Gradle either in Android Studio,\n' +
|
d.reject(new CordovaError('Could not find an installed version of Gradle either in Android Studio,\n' +
|
||||||
'or on your system to install the gradle wrapper. Please include gradle \n' +
|
'or on your system to install the gradle wrapper. Please include gradle \n' +
|
||||||
'in your path, or install Android Studio'));
|
'in your path, or install Android Studio'));
|
||||||
|
}
|
||||||
return d.promise;
|
return d.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -165,11 +178,12 @@ module.exports.check_java = function() {
|
|||||||
var find_java = '/usr/libexec/java_home';
|
var find_java = '/usr/libexec/java_home';
|
||||||
var default_java_error_msg = 'Failed to find \'JAVA_HOME\' environment variable. Try setting setting it manually.';
|
var default_java_error_msg = 'Failed to find \'JAVA_HOME\' environment variable. Try setting setting it manually.';
|
||||||
if (fs.existsSync(find_java)) {
|
if (fs.existsSync(find_java)) {
|
||||||
return superspawn.spawn(find_java)
|
return superspawn.spawn(find_java).then(function (stdout) {
|
||||||
.then(function(stdout) {
|
|
||||||
process.env['JAVA_HOME'] = stdout.trim();
|
process.env['JAVA_HOME'] = stdout.trim();
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
|
if (err) {
|
||||||
throw new CordovaError(default_java_error_msg);
|
throw new CordovaError(default_java_error_msg);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// See if we can derive it from javac's location.
|
// See if we can derive it from javac's location.
|
||||||
@@ -209,8 +223,7 @@ module.exports.check_java = function() {
|
|||||||
}
|
}
|
||||||
// We use tryCommand with catchStderr = true, because
|
// We use tryCommand with catchStderr = true, because
|
||||||
// javac writes version info to stderr instead of stdout
|
// javac writes version info to stderr instead of stdout
|
||||||
return tryCommand('javac -version', msg, true)
|
return tryCommand('javac -version', msg, true).then(function (output) {
|
||||||
.then(function (output) {
|
|
||||||
// Let's check for at least Java 8, and keep it future proof so we can support Java 10
|
// Let's check for at least Java 8, and keep it future proof so we can support Java 10
|
||||||
var match = /javac ((?:1\.)(?:[8-9]\.)(?:\d+))|((?:1\.)(?:[1-9]\d+\.)(?:\d+))/i.exec(output);
|
var match = /javac ((?:1\.)(?:[8-9]\.)(?:\d+))|((?:1\.)(?:[1-9]\d+\.)(?:\d+))/i.exec(output);
|
||||||
return match && match[1];
|
return match && match[1];
|
||||||
@@ -265,7 +278,7 @@ module.exports.check_android = function() {
|
|||||||
if (androidCmdPath) {
|
if (androidCmdPath) {
|
||||||
parentDir = path.dirname(androidCmdPath);
|
parentDir = path.dirname(androidCmdPath);
|
||||||
grandParentDir = path.dirname(parentDir);
|
grandParentDir = path.dirname(parentDir);
|
||||||
if (path.basename(parentDir) == 'tools' || fs.existsSync(path.join(grandParentDir, 'tools', 'android'))) {
|
if (path.basename(parentDir) === 'tools' || fs.existsSync(path.join(grandParentDir, 'tools', 'android'))) {
|
||||||
maybeSetAndroidHome(grandParentDir);
|
maybeSetAndroidHome(grandParentDir);
|
||||||
} else {
|
} else {
|
||||||
throw new CordovaError('Failed to find \'ANDROID_HOME\' environment variable. Try setting setting it manually.\n' +
|
throw new CordovaError('Failed to find \'ANDROID_HOME\' environment variable. Try setting setting it manually.\n' +
|
||||||
@@ -276,7 +289,7 @@ module.exports.check_android = function() {
|
|||||||
if (adbInPath) {
|
if (adbInPath) {
|
||||||
parentDir = path.dirname(adbInPath);
|
parentDir = path.dirname(adbInPath);
|
||||||
grandParentDir = path.dirname(parentDir);
|
grandParentDir = path.dirname(parentDir);
|
||||||
if (path.basename(parentDir) == 'platform-tools') {
|
if (path.basename(parentDir) === 'platform-tools') {
|
||||||
maybeSetAndroidHome(grandParentDir);
|
maybeSetAndroidHome(grandParentDir);
|
||||||
} else {
|
} else {
|
||||||
throw new CordovaError('Failed to find \'ANDROID_HOME\' environment variable. Try setting setting it manually.\n' +
|
throw new CordovaError('Failed to find \'ANDROID_HOME\' environment variable. Try setting setting it manually.\n' +
|
||||||
@@ -287,7 +300,7 @@ module.exports.check_android = function() {
|
|||||||
if (avdmanagerInPath) {
|
if (avdmanagerInPath) {
|
||||||
parentDir = path.dirname(avdmanagerInPath);
|
parentDir = path.dirname(avdmanagerInPath);
|
||||||
grandParentDir = path.dirname(parentDir);
|
grandParentDir = path.dirname(parentDir);
|
||||||
if (path.basename(parentDir) == 'bin' && path.basename(grandParentDir) == 'tools') {
|
if (path.basename(parentDir) === 'bin' && path.basename(grandParentDir) === 'tools') {
|
||||||
maybeSetAndroidHome(path.dirname(grandParentDir));
|
maybeSetAndroidHome(path.dirname(grandParentDir));
|
||||||
} else {
|
} else {
|
||||||
throw new CordovaError('Failed to find \'ANDROID_HOME\' environment variable. Try setting setting it manually.\n' +
|
throw new CordovaError('Failed to find \'ANDROID_HOME\' environment variable. Try setting setting it manually.\n' +
|
||||||
@@ -337,8 +350,7 @@ module.exports.check_android_target = function(originalError) {
|
|||||||
// Google Inc.:Google APIs:20
|
// Google Inc.:Google APIs:20
|
||||||
// Google Inc.:Glass Development Kit Preview:20
|
// Google Inc.:Glass Development Kit Preview:20
|
||||||
var desired_api_level = module.exports.get_target();
|
var desired_api_level = module.exports.get_target();
|
||||||
return android_sdk.list_targets()
|
return android_sdk.list_targets().then(function (targets) {
|
||||||
.then(function(targets) {
|
|
||||||
if (targets.indexOf(desired_api_level) >= 0) {
|
if (targets.indexOf(desired_api_level) >= 0) {
|
||||||
return targets;
|
return targets;
|
||||||
}
|
}
|
||||||
@@ -358,8 +370,7 @@ module.exports.check_android_target = function(originalError) {
|
|||||||
|
|
||||||
// Returns a promise.
|
// Returns a promise.
|
||||||
module.exports.run = function () {
|
module.exports.run = function () {
|
||||||
return Q.all([this.check_java(), this.check_android()])
|
return Q.all([this.check_java(), this.check_android()]).then(function (values) {
|
||||||
.then(function(values) {
|
|
||||||
console.log('ANDROID_HOME=' + process.env['ANDROID_HOME']);
|
console.log('ANDROID_HOME=' + process.env['ANDROID_HOME']);
|
||||||
console.log('JAVA_HOME=' + process.env['JAVA_HOME']);
|
console.log('JAVA_HOME=' + process.env['JAVA_HOME']);
|
||||||
|
|
||||||
@@ -373,7 +384,6 @@ module.exports.run = function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object thar represents one of requirements for current platform.
|
* Object thar represents one of requirements for current platform.
|
||||||
* @param {String} id The unique identifier for this requirements.
|
* @param {String} id The unique identifier for this requirements.
|
||||||
@@ -387,7 +397,7 @@ var Requirement = function (id, name, version, installed) {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
this.installed = installed || false;
|
this.installed = installed || false;
|
||||||
this.metadata = {
|
this.metadata = {
|
||||||
version: version,
|
version: version
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -417,15 +427,13 @@ module.exports.check_all = function() {
|
|||||||
return checkFns.reduce(function (promise, checkFn, idx) {
|
return checkFns.reduce(function (promise, checkFn, idx) {
|
||||||
// Update each requirement with results
|
// Update each requirement with results
|
||||||
var requirement = requirements[idx];
|
var requirement = requirements[idx];
|
||||||
return promise.then(checkFn)
|
return promise.then(checkFn).then(function (version) {
|
||||||
.then(function (version) {
|
|
||||||
requirement.installed = true;
|
requirement.installed = true;
|
||||||
requirement.metadata.version = version;
|
requirement.metadata.version = version;
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
requirement.metadata.reason = err instanceof Error ? err.message : err;
|
requirement.metadata.reason = err instanceof Error ? err.message : err;
|
||||||
});
|
});
|
||||||
}, Q())
|
}, Q()).then(function () {
|
||||||
.then(function () {
|
|
||||||
// When chain is completed, return requirements array to upstream API
|
// When chain is completed, return requirements array to upstream API
|
||||||
return requirements;
|
return requirements;
|
||||||
});
|
});
|
||||||
|
|||||||
Vendored
+11
-19
@@ -19,8 +19,8 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Q = require('q'),
|
var Q = require('q');
|
||||||
build = require('./build');
|
var build = require('./build');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var Adb = require('./Adb');
|
var Adb = require('./Adb');
|
||||||
var AndroidManifest = require('./AndroidManifest');
|
var AndroidManifest = require('./AndroidManifest');
|
||||||
@@ -33,14 +33,12 @@ var events = require('cordova-common').events;
|
|||||||
* @param lookHarder When true, try restarting adb if no devices are found.
|
* @param lookHarder When true, try restarting adb if no devices are found.
|
||||||
*/
|
*/
|
||||||
module.exports.list = function (lookHarder) {
|
module.exports.list = function (lookHarder) {
|
||||||
return Adb.devices()
|
return Adb.devices().then(function (list) {
|
||||||
.then(function(list) {
|
|
||||||
if (list.length === 0 && lookHarder) {
|
if (list.length === 0 && lookHarder) {
|
||||||
// adb kill-server doesn't seem to do the trick.
|
// adb kill-server doesn't seem to do the trick.
|
||||||
// Could probably find a x-platform version of killall, but I'm not actually
|
// Could probably find a x-platform version of killall, but I'm not actually
|
||||||
// sure that this scenario even happens on non-OSX machines.
|
// sure that this scenario even happens on non-OSX machines.
|
||||||
return spawn('killall', ['adb'])
|
return spawn('killall', ['adb']).then(function () {
|
||||||
.then(function() {
|
|
||||||
events.emit('verbose', 'Restarting adb to see if more devices are detected.');
|
events.emit('verbose', 'Restarting adb to see if more devices are detected.');
|
||||||
return Adb.devices();
|
return Adb.devices();
|
||||||
}, function () {
|
}, function () {
|
||||||
@@ -53,8 +51,7 @@ module.exports.list = function(lookHarder) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports.resolveTarget = function (target) {
|
module.exports.resolveTarget = function (target) {
|
||||||
return this.list(true)
|
return this.list(true).then(function (device_list) {
|
||||||
.then(function(device_list) {
|
|
||||||
if (!device_list || !device_list.length) {
|
if (!device_list || !device_list.length) {
|
||||||
return Q.reject(new CordovaError('Failed to deploy to device, no devices found.'));
|
return Q.reject(new CordovaError('Failed to deploy to device, no devices found.'));
|
||||||
}
|
}
|
||||||
@@ -65,8 +62,7 @@ module.exports.resolveTarget = function(target) {
|
|||||||
return Q.reject('ERROR: Unable to find target \'' + target + '\'.');
|
return Q.reject('ERROR: Unable to find target \'' + target + '\'.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return build.detectArchitecture(target)
|
return build.detectArchitecture(target).then(function (arch) {
|
||||||
.then(function(arch) {
|
|
||||||
return { target: target, arch: arch, isEmulator: false };
|
return { target: target, arch: arch, isEmulator: false };
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -79,7 +75,7 @@ module.exports.resolveTarget = function(target) {
|
|||||||
*/
|
*/
|
||||||
module.exports.install = function (target, buildResults) {
|
module.exports.install = function (target, buildResults) {
|
||||||
return Q().then(function () {
|
return Q().then(function () {
|
||||||
if (target && typeof target == 'object') {
|
if (target && typeof target === 'object') {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
return module.exports.resolveTarget(target);
|
return module.exports.resolveTarget(target);
|
||||||
@@ -91,24 +87,20 @@ module.exports.install = function(target, buildResults) {
|
|||||||
events.emit('log', 'Using apk: ' + apk_path);
|
events.emit('log', 'Using apk: ' + apk_path);
|
||||||
events.emit('log', 'Package name: ' + pkgName);
|
events.emit('log', 'Package name: ' + pkgName);
|
||||||
|
|
||||||
return Adb.install(resolvedTarget.target, apk_path, {replace: true})
|
return Adb.install(resolvedTarget.target, apk_path, {replace: true}).catch(function (error) {
|
||||||
.catch(function (error) {
|
|
||||||
// CB-9557 CB-10157 only uninstall and reinstall app if the one that
|
// CB-9557 CB-10157 only uninstall and reinstall app if the one that
|
||||||
// is already installed on device was signed w/different certificate
|
// is already installed on device was signed w/different certificate
|
||||||
if (!/INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES/.test(error.toString()))
|
if (!/INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES/.test(error.toString())) { throw error; }
|
||||||
throw error;
|
|
||||||
|
|
||||||
events.emit('warn', 'Uninstalling app from device and reinstalling it again because the ' +
|
events.emit('warn', 'Uninstalling app from device and reinstalling it again because the ' +
|
||||||
'installed app already signed with different key');
|
'installed app already signed with different key');
|
||||||
|
|
||||||
// This promise is always resolved, even if 'adb uninstall' fails to uninstall app
|
// This promise is always resolved, even if 'adb uninstall' fails to uninstall app
|
||||||
// or the app doesn't installed at all, so no error catching needed.
|
// or the app doesn't installed at all, so no error catching needed.
|
||||||
return Adb.uninstall(resolvedTarget.target, pkgName)
|
return Adb.uninstall(resolvedTarget.target, pkgName).then(function () {
|
||||||
.then(function() {
|
|
||||||
return Adb.install(resolvedTarget.target, apk_path, {replace: true});
|
return Adb.install(resolvedTarget.target, apk_path, {replace: true});
|
||||||
});
|
});
|
||||||
})
|
}).then(function () {
|
||||||
.then(function() {
|
|
||||||
// unlock screen
|
// unlock screen
|
||||||
return Adb.shell(resolvedTarget.target, 'input keyevent 82');
|
return Adb.shell(resolvedTarget.target, 'input keyevent 82');
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
|
|||||||
+46
-60
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
/* jshint sub:true */
|
/* jshint sub:true */
|
||||||
|
|
||||||
|
var android_versions = require('android-versions');
|
||||||
var retry = require('./retry');
|
var retry = require('./retry');
|
||||||
var build = require('./build');
|
var build = require('./build');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
@@ -55,8 +56,7 @@ function forgivingWhichSync(cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports.list_images_using_avdmanager = function () {
|
module.exports.list_images_using_avdmanager = function () {
|
||||||
return superspawn.spawn('avdmanager', ['list', 'avd'])
|
return superspawn.spawn('avdmanager', ['list', 'avd']).then(function (output) {
|
||||||
.then(function(output) {
|
|
||||||
var response = output.split('\n');
|
var response = output.split('\n');
|
||||||
var emulator_list = [];
|
var emulator_list = [];
|
||||||
for (var i = 1; i < response.length; i++) {
|
for (var i = 1; i < response.length; i++) {
|
||||||
@@ -116,8 +116,7 @@ module.exports.list_images_using_avdmanager = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports.list_images_using_android = function () {
|
module.exports.list_images_using_android = function () {
|
||||||
return superspawn.spawn('android', ['list', 'avds'])
|
return superspawn.spawn('android', ['list', 'avd']).then(function (output) {
|
||||||
.then(function(output) {
|
|
||||||
var response = output.split('\n');
|
var response = output.split('\n');
|
||||||
var emulator_list = [];
|
var emulator_list = [];
|
||||||
for (var i = 1; i < response.length; i++) {
|
for (var i = 1; i < response.length; i++) {
|
||||||
@@ -171,25 +170,29 @@ module.exports.list_images_using_android = function() {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
module.exports.list_images = function () {
|
module.exports.list_images = function () {
|
||||||
if (forgivingWhichSync('android')) {
|
return Q.fcall(function () {
|
||||||
return module.exports.list_images_using_android()
|
if (forgivingWhichSync('avdmanager')) {
|
||||||
.catch(function(err) {
|
|
||||||
// try to use `avdmanager` in case `android` reports it is no longer available.
|
|
||||||
// this likely means the target machine is using a newer version of
|
|
||||||
// the android sdk, and possibly `avdmanager` is available.
|
|
||||||
if (err.code == 1 && err.stdout.indexOf('android command is no longer available')) {
|
|
||||||
return module.exports.list_images_using_avdmanager();
|
|
||||||
} else {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (forgivingWhichSync('avdmanager')) {
|
|
||||||
return module.exports.list_images_using_avdmanager();
|
return module.exports.list_images_using_avdmanager();
|
||||||
|
} else if (forgivingWhichSync('android')) {
|
||||||
|
return module.exports.list_images_using_android();
|
||||||
} else {
|
} else {
|
||||||
return Q().then(function () {
|
return Q().then(function () {
|
||||||
throw new CordovaError('Could not find either `android` or `avdmanager` on your $PATH! Are you sure the Android SDK is installed and available?');
|
throw new CordovaError('Could not find either `android` or `avdmanager` on your $PATH! Are you sure the Android SDK is installed and available?');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}).then(function (avds) {
|
||||||
|
// In case we're missing the Android OS version string from the target description, add it.
|
||||||
|
return avds.map(function (avd) {
|
||||||
|
if (avd.target && avd.target.indexOf('Android API') > -1 && avd.target.indexOf('API level') < 0) {
|
||||||
|
var api_level = avd.target.match(/\d+/);
|
||||||
|
if (api_level) {
|
||||||
|
var level = android_versions.get(api_level);
|
||||||
|
avd.target = 'Android ' + level.semver + ' (API level ' + api_level + ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return avd;
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -198,8 +201,7 @@ module.exports.list_images = function() {
|
|||||||
* Returns a promise.
|
* Returns a promise.
|
||||||
*/
|
*/
|
||||||
module.exports.best_image = function () {
|
module.exports.best_image = function () {
|
||||||
return this.list_images()
|
return this.list_images().then(function (images) {
|
||||||
.then(function(images) {
|
|
||||||
// Just return undefined if there is no images
|
// Just return undefined if there is no images
|
||||||
if (images.length === 0) return;
|
if (images.length === 0) return;
|
||||||
|
|
||||||
@@ -210,7 +212,7 @@ module.exports.best_image = function() {
|
|||||||
var target = images[i].target;
|
var target = images[i].target;
|
||||||
if (target) {
|
if (target) {
|
||||||
var num = target.split('(API level ')[1].replace(')', '');
|
var num = target.split('(API level ')[1].replace(')', '');
|
||||||
if (num == project_target) {
|
if (num === project_target) {
|
||||||
return images[i];
|
return images[i];
|
||||||
} else if (project_target - num < closest && project_target > num) {
|
} else if (project_target - num < closest && project_target > num) {
|
||||||
closest = project_target - num;
|
closest = project_target - num;
|
||||||
@@ -228,9 +230,9 @@ module.exports.list_started = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Returns a promise.
|
// Returns a promise.
|
||||||
|
// TODO: we should remove this, there's a more robust method under android_sdk.js
|
||||||
module.exports.list_targets = function () {
|
module.exports.list_targets = function () {
|
||||||
return superspawn.spawn('android', ['list', 'targets'], {cwd: os.tmpdir()})
|
return superspawn.spawn('android', ['list', 'targets'], {cwd: os.tmpdir()}).then(function (output) {
|
||||||
.then(function(output) {
|
|
||||||
var target_out = output.split('\n');
|
var target_out = output.split('\n');
|
||||||
var targets = [];
|
var targets = [];
|
||||||
for (var i = target_out.length; i >= 0; i--) {
|
for (var i = target_out.length; i >= 0; i--) {
|
||||||
@@ -249,8 +251,7 @@ module.exports.list_targets = function() {
|
|||||||
module.exports.get_available_port = function () {
|
module.exports.get_available_port = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
return self.list_started()
|
return self.list_started().then(function (emulators) {
|
||||||
.then(function (emulators) {
|
|
||||||
for (var p = 5584; p >= 5554; p -= 2) {
|
for (var p = 5584; p >= 5554; p -= 2) {
|
||||||
if (emulators.indexOf('emulator-' + p) === -1) {
|
if (emulators.indexOf('emulator-' + p) === -1) {
|
||||||
events.emit('verbose', 'Found available port: ' + p);
|
events.emit('verbose', 'Found available port: ' + p);
|
||||||
@@ -277,8 +278,7 @@ module.exports.start = function(emulator_ID, boot_timeout) {
|
|||||||
return Q().then(function () {
|
return Q().then(function () {
|
||||||
if (emulator_ID) return Q(emulator_ID);
|
if (emulator_ID) return Q(emulator_ID);
|
||||||
|
|
||||||
return self.best_image()
|
return self.best_image().then(function (best) {
|
||||||
.then(function(best) {
|
|
||||||
if (best && best.name) {
|
if (best && best.name) {
|
||||||
events.emit('warn', 'No emulator specified, defaulting to ' + best.name);
|
events.emit('warn', 'No emulator specified, defaulting to ' + best.name);
|
||||||
return best.name;
|
return best.name;
|
||||||
@@ -291,8 +291,7 @@ module.exports.start = function(emulator_ID, boot_timeout) {
|
|||||||
'HINT: For a faster emulator, use an Intel System Image and install the HAXM device driver\n'));
|
'HINT: For a faster emulator, use an Intel System Image and install the HAXM device driver\n'));
|
||||||
});
|
});
|
||||||
}).then(function (emulatorId) {
|
}).then(function (emulatorId) {
|
||||||
return self.get_available_port()
|
return self.get_available_port().then(function (port) {
|
||||||
.then(function (port) {
|
|
||||||
// Figure out the directory the emulator binary runs in, and set the cwd to that directory.
|
// Figure out the directory the emulator binary runs in, and set the cwd to that directory.
|
||||||
// Workaround for https://code.google.com/p/android/issues/detail?id=235461
|
// Workaround for https://code.google.com/p/android/issues/detail?id=235461
|
||||||
var emulator_dir = path.dirname(shelljs.which('emulator'));
|
var emulator_dir = path.dirname(shelljs.which('emulator'));
|
||||||
@@ -307,18 +306,15 @@ module.exports.start = function(emulator_ID, boot_timeout) {
|
|||||||
return self.wait_for_emulator(port);
|
return self.wait_for_emulator(port);
|
||||||
});
|
});
|
||||||
}).then(function (emulatorId) {
|
}).then(function (emulatorId) {
|
||||||
if (!emulatorId)
|
if (!emulatorId) { return Q.reject(new CordovaError('Failed to start emulator')); }
|
||||||
return Q.reject(new CordovaError('Failed to start emulator'));
|
|
||||||
|
|
||||||
// wait for emulator to boot up
|
// wait for emulator to boot up
|
||||||
process.stdout.write('Waiting for emulator to boot (this may take a while)...');
|
process.stdout.write('Waiting for emulator to boot (this may take a while)...');
|
||||||
return self.wait_for_boot(emulatorId, boot_timeout)
|
return self.wait_for_boot(emulatorId, boot_timeout).then(function (success) {
|
||||||
.then(function(success) {
|
|
||||||
if (success) {
|
if (success) {
|
||||||
events.emit('log', 'BOOT COMPLETE');
|
events.emit('log', 'BOOT COMPLETE');
|
||||||
// unlock screen
|
// unlock screen
|
||||||
return Adb.shell(emulatorId, 'input keyevent 82')
|
return Adb.shell(emulatorId, 'input keyevent 82').then(function () {
|
||||||
.then(function() {
|
|
||||||
// return the new emulator id for the started emulators
|
// return the new emulator id for the started emulators
|
||||||
return emulatorId;
|
return emulatorId;
|
||||||
});
|
});
|
||||||
@@ -338,16 +334,15 @@ module.exports.wait_for_emulator = function(port) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
return Q().then(function () {
|
return Q().then(function () {
|
||||||
var emulator_id = 'emulator-' + port;
|
var emulator_id = 'emulator-' + port;
|
||||||
return Adb.shell(emulator_id, 'getprop dev.bootcomplete')
|
return Adb.shell(emulator_id, 'getprop dev.bootcomplete').then(function (output) {
|
||||||
.then(function (output) {
|
|
||||||
if (output.indexOf('1') >= 0) {
|
if (output.indexOf('1') >= 0) {
|
||||||
return emulator_id;
|
return emulator_id;
|
||||||
}
|
}
|
||||||
return self.wait_for_emulator(port);
|
return self.wait_for_emulator(port);
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
if (error && error.message &&
|
if ((error && error.message &&
|
||||||
(error.message.indexOf('not found') > -1) ||
|
(error.message.indexOf('not found') > -1)) ||
|
||||||
error.message.indexOf('device offline') > -1) {
|
(error.message.indexOf('device offline') > -1)) {
|
||||||
// emulator not yet started, continue waiting
|
// emulator not yet started, continue waiting
|
||||||
return self.wait_for_emulator(port);
|
return self.wait_for_emulator(port);
|
||||||
} else {
|
} else {
|
||||||
@@ -365,8 +360,7 @@ module.exports.wait_for_emulator = function(port) {
|
|||||||
*/
|
*/
|
||||||
module.exports.wait_for_boot = function (emulator_id, time_remaining) {
|
module.exports.wait_for_boot = function (emulator_id, time_remaining) {
|
||||||
var self = this;
|
var self = this;
|
||||||
return Adb.shell(emulator_id, 'ps')
|
return Adb.shell(emulator_id, 'ps').then(function (output) {
|
||||||
.then(function(output) {
|
|
||||||
if (output.match(/android\.process\.acore/)) {
|
if (output.match(/android\.process\.acore/)) {
|
||||||
return true;
|
return true;
|
||||||
} else if (time_remaining === 0) {
|
} else if (time_remaining === 0) {
|
||||||
@@ -391,16 +385,15 @@ module.exports.wait_for_boot = function(emulator_id, time_remaining) {
|
|||||||
module.exports.create_image = function (name, target) {
|
module.exports.create_image = function (name, target) {
|
||||||
console.log('Creating new avd named ' + name);
|
console.log('Creating new avd named ' + name);
|
||||||
if (target) {
|
if (target) {
|
||||||
return superspawn.spawn('android', ['create', 'avd', '--name', name, '--target', target])
|
return superspawn.spawn('android', ['create', 'avd', '--name', name, '--target', target]).then(null, function (error) {
|
||||||
.then(null, function(error) {
|
|
||||||
console.error('ERROR : Failed to create emulator image : ');
|
console.error('ERROR : Failed to create emulator image : ');
|
||||||
console.error(' Do you have the latest android targets including ' + target + '?');
|
console.error(' Do you have the latest android targets including ' + target + '?');
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log('WARNING : Project target not found, creating avd with a different target but the project may fail to install.');
|
console.log('WARNING : Project target not found, creating avd with a different target but the project may fail to install.');
|
||||||
return superspawn.spawn('android', ['create', 'avd', '--name', name, '--target', this.list_targets()[0]])
|
// TODO: there's a more robust method for finding targets in android_sdk.js
|
||||||
.then(function() {
|
return superspawn.spawn('android', ['create', 'avd', '--name', name, '--target', this.list_targets()[0]]).then(function () {
|
||||||
// TODO: This seems like another error case, even though it always happens.
|
// TODO: This seems like another error case, even though it always happens.
|
||||||
console.error('ERROR : Unable to create an avd emulator, no targets found.');
|
console.error('ERROR : Unable to create an avd emulator, no targets found.');
|
||||||
console.error('Ensure you have targets available by running the "android" command');
|
console.error('Ensure you have targets available by running the "android" command');
|
||||||
@@ -413,8 +406,7 @@ module.exports.create_image = function(name, target) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports.resolveTarget = function (target) {
|
module.exports.resolveTarget = function (target) {
|
||||||
return this.list_started()
|
return this.list_started().then(function (emulator_list) {
|
||||||
.then(function(emulator_list) {
|
|
||||||
if (emulator_list.length < 1) {
|
if (emulator_list.length < 1) {
|
||||||
return Q.reject('No running Android emulators found, please start an emulator before deploying your project.');
|
return Q.reject('No running Android emulators found, please start an emulator before deploying your project.');
|
||||||
}
|
}
|
||||||
@@ -425,8 +417,7 @@ module.exports.resolveTarget = function(target) {
|
|||||||
return Q.reject('Unable to find target \'' + target + '\'. Failed to deploy to emulator.');
|
return Q.reject('Unable to find target \'' + target + '\'. Failed to deploy to emulator.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return build.detectArchitecture(target)
|
return build.detectArchitecture(target).then(function (arch) {
|
||||||
.then(function(arch) {
|
|
||||||
return {target: target, arch: arch, isEmulator: true};
|
return {target: target, arch: arch, isEmulator: true};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -446,7 +437,7 @@ module.exports.install = function(givenTarget, buildResults) {
|
|||||||
|
|
||||||
// resolve the target emulator
|
// resolve the target emulator
|
||||||
return Q().then(function () {
|
return Q().then(function () {
|
||||||
if (givenTarget && typeof givenTarget == 'object') {
|
if (givenTarget && typeof givenTarget === 'object') {
|
||||||
return givenTarget;
|
return givenTarget;
|
||||||
} else {
|
} else {
|
||||||
return module.exports.resolveTarget(givenTarget);
|
return module.exports.resolveTarget(givenTarget);
|
||||||
@@ -460,8 +451,7 @@ module.exports.install = function(givenTarget, buildResults) {
|
|||||||
}).then(function () {
|
}).then(function () {
|
||||||
// This promise is always resolved, even if 'adb uninstall' fails to uninstall app
|
// This promise is always resolved, even if 'adb uninstall' fails to uninstall app
|
||||||
// or the app doesn't installed at all, so no error catching needed.
|
// or the app doesn't installed at all, so no error catching needed.
|
||||||
return Q.when()
|
return Q.when().then(function () {
|
||||||
.then(function() {
|
|
||||||
|
|
||||||
var apk_path = build.findBestApkForArchitecture(buildResults, target.arch);
|
var apk_path = build.findBestApkForArchitecture(buildResults, target.arch);
|
||||||
var execOptions = {
|
var execOptions = {
|
||||||
@@ -502,27 +492,23 @@ module.exports.install = function(givenTarget, buildResults) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function installPromise () {
|
function installPromise () {
|
||||||
return adbInstallWithOptions(target.target, apk_path, execOptions)
|
return adbInstallWithOptions(target.target, apk_path, execOptions).catch(function (error) {
|
||||||
.catch(function (error) {
|
|
||||||
// CB-9557 CB-10157 only uninstall and reinstall app if the one that
|
// CB-9557 CB-10157 only uninstall and reinstall app if the one that
|
||||||
// is already installed on device was signed w/different certificate
|
// is already installed on device was signed w/different certificate
|
||||||
if (!/INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES/.test(error.toString()))
|
if (!/INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES/.test(error.toString())) { throw error; }
|
||||||
throw error;
|
|
||||||
|
|
||||||
events.emit('warn', 'Uninstalling app from device and reinstalling it because the ' +
|
events.emit('warn', 'Uninstalling app from device and reinstalling it because the ' +
|
||||||
'currently installed app was signed with different key');
|
'currently installed app was signed with different key');
|
||||||
|
|
||||||
// This promise is always resolved, even if 'adb uninstall' fails to uninstall app
|
// This promise is always resolved, even if 'adb uninstall' fails to uninstall app
|
||||||
// or the app doesn't installed at all, so no error catching needed.
|
// or the app doesn't installed at all, so no error catching needed.
|
||||||
return Adb.uninstall(target.target, pkgName)
|
return Adb.uninstall(target.target, pkgName).then(function () {
|
||||||
.then(function() {
|
|
||||||
return adbInstallWithOptions(target.target, apk_path, execOptions);
|
return adbInstallWithOptions(target.target, apk_path, execOptions);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return retry.retryPromise(NUM_INSTALL_RETRIES, installPromise)
|
return retry.retryPromise(NUM_INSTALL_RETRIES, installPromise).then(function (output) {
|
||||||
.then(function (output) {
|
|
||||||
events.emit('log', 'INSTALL SUCCESS');
|
events.emit('log', 'INSTALL SUCCESS');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
for /f "tokens=2*" %%a in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Android Studio" /v Path') do set "ASPath=%%~b"
|
||||||
|
ECHO %ASPath%
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
SET script_path="%~dp0install-device"
|
SET script_path="%~dp0install-device"
|
||||||
IF EXIST %script_path% (
|
IF EXIST %script_path% (
|
||||||
node "%script_path%" %*
|
node %script_path% %*
|
||||||
) ELSE (
|
) ELSE (
|
||||||
ECHO.
|
ECHO.
|
||||||
ECHO ERROR: Could not find 'install-device' script in 'cordova\lib' folder, aborting...>&2
|
ECHO ERROR: Could not find 'install-device' script in 'cordova\lib' folder, aborting...>&2
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
SET script_path="%~dp0install-emulator"
|
SET script_path="%~dp0install-emulator"
|
||||||
IF EXIST %script_path% (
|
IF EXIST %script_path% (
|
||||||
node "%script_path%" %*
|
node %script_path% %*
|
||||||
) ELSE (
|
) ELSE (
|
||||||
ECHO.
|
ECHO.
|
||||||
ECHO ERROR: Could not find 'install-emulator' script in 'cordova\lib' folder, aborting...>&2
|
ECHO ERROR: Could not find 'install-emulator' script in 'cordova\lib' folder, aborting...>&2
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
SET script_path="%~dp0list-devices"
|
SET script_path="%~dp0list-devices"
|
||||||
IF EXIST %script_path% (
|
IF EXIST %script_path% (
|
||||||
node "%script_path%" %*
|
node %script_path% %*
|
||||||
) ELSE (
|
) ELSE (
|
||||||
ECHO.
|
ECHO.
|
||||||
ECHO ERROR: Could not find 'list-devices' script in 'cordova\lib' folder, aborting...>&2
|
ECHO ERROR: Could not find 'list-devices' script in 'cordova\lib' folder, aborting...>&2
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
SET script_path="%~dp0list-emulator-images"
|
SET script_path="%~dp0list-emulator-images"
|
||||||
IF EXIST %script_path% (
|
IF EXIST %script_path% (
|
||||||
node "%script_path%" %*
|
node %script_path% %*
|
||||||
) ELSE (
|
) ELSE (
|
||||||
ECHO.
|
ECHO.
|
||||||
ECHO ERROR: Could not find 'list-emulator-images' script in 'cordova\lib' folder, aborting...>&2
|
ECHO ERROR: Could not find 'list-emulator-images' script in 'cordova\lib' folder, aborting...>&2
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
SET script_path="%~dp0list-started-emulators"
|
SET script_path="%~dp0list-started-emulators"
|
||||||
IF EXIST %script_path% (
|
IF EXIST %script_path% (
|
||||||
node "%script_path%" %*
|
node %script_path% %*
|
||||||
) ELSE (
|
) ELSE (
|
||||||
ECHO.
|
ECHO.
|
||||||
ECHO ERROR: Could not find 'list-started-emulators' script in 'cordova\lib' folder, aborting...>&2
|
ECHO ERROR: Could not find 'list-started-emulators' script in 'cordova\lib' folder, aborting...>&2
|
||||||
|
|||||||
Vendored
+5
-5
@@ -19,11 +19,11 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var path = require('path'),
|
var path = require('path');
|
||||||
os = require('os'),
|
var os = require('os');
|
||||||
Q = require('q'),
|
var Q = require('q');
|
||||||
child_process = require('child_process'),
|
var child_process = require('child_process');
|
||||||
ROOT = path.join(__dirname, '..', '..');
|
var ROOT = path.join(__dirname, '..', '..');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Starts running logcat in the shell.
|
* Starts running logcat in the shell.
|
||||||
|
|||||||
@@ -20,8 +20,10 @@
|
|||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url "https://maven.google.com"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch the Android Gradle plugin version requirement depending on the
|
// Switch the Android Gradle plugin version requirement depending on the
|
||||||
|
|||||||
+8
-12
@@ -95,9 +95,9 @@ var handlers = {
|
|||||||
subDir = src;
|
subDir = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.type == 'gradleReference') {
|
if (obj.type === 'gradleReference') {
|
||||||
project.addGradleReference(parentDir, subDir);
|
project.addGradleReference(parentDir, subDir);
|
||||||
} else if (obj.type == 'sys') {
|
} else if (obj.type === 'sys') {
|
||||||
project.addSystemLibrary(parentDir, subDir);
|
project.addSystemLibrary(parentDir, subDir);
|
||||||
} else {
|
} else {
|
||||||
project.addSubProject(parentDir, subDir);
|
project.addSubProject(parentDir, subDir);
|
||||||
@@ -125,9 +125,9 @@ var handlers = {
|
|||||||
subDir = src;
|
subDir = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.type == 'gradleReference') {
|
if (obj.type === 'gradleReference') {
|
||||||
project.removeGradleReference(parentDir, subDir);
|
project.removeGradleReference(parentDir, subDir);
|
||||||
} else if (obj.type == 'sys') {
|
} else if (obj.type === 'sys') {
|
||||||
project.removeSystemLibrary(parentDir, subDir);
|
project.removeSystemLibrary(parentDir, subDir);
|
||||||
} else {
|
} else {
|
||||||
project.removeSubProject(parentDir, subDir);
|
project.removeSubProject(parentDir, subDir);
|
||||||
@@ -221,14 +221,12 @@ function copyFile (plugin_dir, src, project_dir, dest, link) {
|
|||||||
// check that src path is inside plugin directory
|
// check that src path is inside plugin directory
|
||||||
var real_path = fs.realpathSync(src);
|
var real_path = fs.realpathSync(src);
|
||||||
var real_plugin_path = fs.realpathSync(plugin_dir);
|
var real_plugin_path = fs.realpathSync(plugin_dir);
|
||||||
if (real_path.indexOf(real_plugin_path) !== 0)
|
if (real_path.indexOf(real_plugin_path) !== 0) { throw new CordovaError('File "' + src + '" is located outside the plugin directory "' + plugin_dir + '"'); }
|
||||||
throw new CordovaError('File "' + src + '" is located outside the plugin directory "' + plugin_dir + '"');
|
|
||||||
|
|
||||||
dest = path.resolve(project_dir, dest);
|
dest = path.resolve(project_dir, dest);
|
||||||
|
|
||||||
// check that dest path is located in project directory
|
// check that dest path is located in project directory
|
||||||
if (dest.indexOf(project_dir) !== 0)
|
if (dest.indexOf(project_dir) !== 0) { throw new CordovaError('Destination "' + dest + '" for source file "' + src + '" is located outside the project'); }
|
||||||
throw new CordovaError('Destination "' + dest + '" for source file "' + src + '" is located outside the project');
|
|
||||||
|
|
||||||
shell.mkdir('-p', path.dirname(dest));
|
shell.mkdir('-p', path.dirname(dest));
|
||||||
if (link) {
|
if (link) {
|
||||||
@@ -244,8 +242,7 @@ function copyFile (plugin_dir, src, project_dir, dest, link) {
|
|||||||
// Same as copy file but throws error if target exists
|
// Same as copy file but throws error if target exists
|
||||||
function copyNewFile (plugin_dir, src, project_dir, dest, link) {
|
function copyNewFile (plugin_dir, src, project_dir, dest, link) {
|
||||||
var target_path = path.resolve(project_dir, dest);
|
var target_path = path.resolve(project_dir, dest);
|
||||||
if (fs.existsSync(target_path))
|
if (fs.existsSync(target_path)) { throw new CordovaError('"' + target_path + '" already exists!'); }
|
||||||
throw new CordovaError('"' + target_path + '" already exists!');
|
|
||||||
|
|
||||||
copyFile(plugin_dir, src, project_dir, dest, !!link);
|
copyFile(plugin_dir, src, project_dir, dest, !!link);
|
||||||
}
|
}
|
||||||
@@ -260,8 +257,7 @@ function symlinkFileOrDirTree(src, dest) {
|
|||||||
fs.readdirSync(src).forEach(function (entry) {
|
fs.readdirSync(src).forEach(function (entry) {
|
||||||
symlinkFileOrDirTree(path.join(src, entry), path.join(dest, entry));
|
symlinkFileOrDirTree(path.join(src, entry), path.join(dest, entry));
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
fs.symlinkSync(path.relative(fs.realpathSync(path.dirname(dest)), src), dest);
|
fs.symlinkSync(path.relative(fs.realpathSync(path.dirname(dest)), src), dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+30
-22
@@ -16,6 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
/* eslint no-useless-escape: 0 */
|
||||||
|
|
||||||
var Q = require('q');
|
var Q = require('q');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
@@ -23,6 +24,7 @@ var path = require('path');
|
|||||||
var shell = require('shelljs');
|
var shell = require('shelljs');
|
||||||
var events = require('cordova-common').events;
|
var events = require('cordova-common').events;
|
||||||
var AndroidManifest = require('./AndroidManifest');
|
var AndroidManifest = require('./AndroidManifest');
|
||||||
|
var checkReqs = require('./check_reqs');
|
||||||
var xmlHelpers = require('cordova-common').xmlHelpers;
|
var xmlHelpers = require('cordova-common').xmlHelpers;
|
||||||
var CordovaError = require('cordova-common').CordovaError;
|
var CordovaError = require('cordova-common').CordovaError;
|
||||||
var ConfigParser = require('cordova-common').ConfigParser;
|
var ConfigParser = require('cordova-common').ConfigParser;
|
||||||
@@ -40,17 +42,14 @@ module.exports.prepare = function (cordovaProject, options) {
|
|||||||
this._config = updateConfigFilesFrom(cordovaProject.projectConfig, munger, this.locations);
|
this._config = updateConfigFilesFrom(cordovaProject.projectConfig, munger, this.locations);
|
||||||
|
|
||||||
// Update own www dir with project's www assets and plugins' assets and js-files
|
// Update own www dir with project's www assets and plugins' assets and js-files
|
||||||
return Q.when(updateWww(cordovaProject, this.locations))
|
return Q.when(updateWww(cordovaProject, this.locations)).then(function () {
|
||||||
.then(function () {
|
|
||||||
// update project according to config.xml changes.
|
// update project according to config.xml changes.
|
||||||
return updateProjectAccordingTo(self._config, self.locations);
|
return updateProjectAccordingTo(self._config, self.locations);
|
||||||
})
|
}).then(function () {
|
||||||
.then(function () {
|
|
||||||
updateIcons(cordovaProject, path.relative(cordovaProject.root, self.locations.res));
|
updateIcons(cordovaProject, path.relative(cordovaProject.root, self.locations.res));
|
||||||
updateSplashes(cordovaProject, path.relative(cordovaProject.root, self.locations.res));
|
updateSplashes(cordovaProject, path.relative(cordovaProject.root, self.locations.res));
|
||||||
updateFileResources(cordovaProject, path.relative(cordovaProject.root, self.locations.root));
|
updateFileResources(cordovaProject, path.relative(cordovaProject.root, self.locations.root));
|
||||||
})
|
}).then(function () {
|
||||||
.then(function () {
|
|
||||||
events.emit('verbose', 'Prepared android project successfully');
|
events.emit('verbose', 'Prepared android project successfully');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -169,17 +168,24 @@ function cleanWww(projectRoot, locations) {
|
|||||||
*/
|
*/
|
||||||
function updateProjectAccordingTo (platformConfig, locations) {
|
function updateProjectAccordingTo (platformConfig, locations) {
|
||||||
// Update app name by editing res/values/strings.xml
|
// Update app name by editing res/values/strings.xml
|
||||||
var name = platformConfig.name();
|
|
||||||
var strings = xmlHelpers.parseElementtreeSync(locations.strings);
|
var strings = xmlHelpers.parseElementtreeSync(locations.strings);
|
||||||
|
|
||||||
|
var name = platformConfig.name();
|
||||||
strings.find('string[@name="app_name"]').text = name.replace(/\'/g, '\\\'');
|
strings.find('string[@name="app_name"]').text = name.replace(/\'/g, '\\\'');
|
||||||
|
|
||||||
|
var shortName = platformConfig.shortName && platformConfig.shortName();
|
||||||
|
if (shortName && shortName !== name) {
|
||||||
|
strings.find('string[@name="launcher_name"]').text = shortName.replace(/\'/g, '\\\'');
|
||||||
|
}
|
||||||
|
|
||||||
fs.writeFileSync(locations.strings, strings.write({indent: 4}), 'utf-8');
|
fs.writeFileSync(locations.strings, strings.write({indent: 4}), 'utf-8');
|
||||||
events.emit('verbose', 'Wrote out android application name "' + name + '" to ' + locations.strings);
|
events.emit('verbose', 'Wrote out android application name "' + name + '" to ' + locations.strings);
|
||||||
|
|
||||||
// Java packages cannot support dashes
|
// Java packages cannot support dashes
|
||||||
var pkg = (platformConfig.android_packageName() || platformConfig.packageName()).replace(/-/g, '_');
|
var androidPkgName = (platformConfig.android_packageName() || platformConfig.packageName()).replace(/-/g, '_');
|
||||||
|
|
||||||
var manifest = new AndroidManifest(locations.manifest);
|
var manifest = new AndroidManifest(locations.manifest);
|
||||||
var orig_pkg = manifest.getPackageId();
|
var manifestId = manifest.getPackageId();
|
||||||
|
|
||||||
manifest.getActivity()
|
manifest.getActivity()
|
||||||
.setOrientation(platformConfig.getPreference('orientation'))
|
.setOrientation(platformConfig.getPreference('orientation'))
|
||||||
@@ -187,13 +193,13 @@ function updateProjectAccordingTo(platformConfig, locations) {
|
|||||||
|
|
||||||
manifest.setVersionName(platformConfig.version())
|
manifest.setVersionName(platformConfig.version())
|
||||||
.setVersionCode(platformConfig.android_versionCode() || default_versionCode(platformConfig.version()))
|
.setVersionCode(platformConfig.android_versionCode() || default_versionCode(platformConfig.version()))
|
||||||
.setPackageId(pkg)
|
.setPackageId(androidPkgName)
|
||||||
.setMinSdkVersion(platformConfig.getPreference('android-minSdkVersion', 'android'))
|
.setMinSdkVersion(platformConfig.getPreference('android-minSdkVersion', 'android'))
|
||||||
.setMaxSdkVersion(platformConfig.getPreference('android-maxSdkVersion', 'android'))
|
.setMaxSdkVersion(platformConfig.getPreference('android-maxSdkVersion', 'android'))
|
||||||
.setTargetSdkVersion(platformConfig.getPreference('android-targetSdkVersion', 'android'))
|
.setTargetSdkVersion(platformConfig.getPreference('android-targetSdkVersion', 'android'))
|
||||||
.write();
|
.write();
|
||||||
|
|
||||||
var javaPattern = path.join(locations.root, 'src', orig_pkg.replace(/\./g, '/'), '*.java');
|
var javaPattern = path.join(locations.root, 'src', manifestId.replace(/\./g, '/'), '*.java');
|
||||||
var java_files = shell.ls(javaPattern).filter(function (f) {
|
var java_files = shell.ls(javaPattern).filter(function (f) {
|
||||||
return shell.grep(/extends\s+CordovaActivity/g, f);
|
return shell.grep(/extends\s+CordovaActivity/g, f);
|
||||||
});
|
});
|
||||||
@@ -204,12 +210,16 @@ function updateProjectAccordingTo(platformConfig, locations) {
|
|||||||
events.emit('log', 'Multiple candidate Java files that extend CordovaActivity found. Guessing at the first one, ' + java_files[0]);
|
events.emit('log', 'Multiple candidate Java files that extend CordovaActivity found. Guessing at the first one, ' + java_files[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var destFile = path.join(locations.root, 'src', pkg.replace(/\./g, '/'), path.basename(java_files[0]));
|
var destFile = path.join(locations.root, 'src', androidPkgName.replace(/\./g, '/'), path.basename(java_files[0]));
|
||||||
shell.mkdir('-p', path.dirname(destFile));
|
shell.mkdir('-p', path.dirname(destFile));
|
||||||
shell.sed(/package [\w\.]*;/, 'package ' + pkg + ';', java_files[0]).to(destFile);
|
shell.sed(/package [\w\.]*;/, 'package ' + androidPkgName + ';', java_files[0]).to(destFile);
|
||||||
events.emit('verbose', 'Wrote out Android package name "' + pkg + '" to ' + destFile);
|
events.emit('verbose', 'Wrote out Android package name "' + androidPkgName + '" to ' + destFile);
|
||||||
|
|
||||||
if (orig_pkg !== pkg) {
|
var removeOrigPkg = checkReqs.isWindows() || checkReqs.isDarwin() ?
|
||||||
|
manifestId.toUpperCase() !== androidPkgName.toUpperCase() :
|
||||||
|
manifestId !== androidPkgName;
|
||||||
|
|
||||||
|
if (removeOrigPkg) {
|
||||||
// If package was name changed we need to remove old java with main activity
|
// If package was name changed we need to remove old java with main activity
|
||||||
shell.rm('-Rf', java_files[0]);
|
shell.rm('-Rf', java_files[0]);
|
||||||
// remove any empty directories
|
// remove any empty directories
|
||||||
@@ -270,7 +280,7 @@ function updateSplashes(cordovaProject, platformResourcesDir) {
|
|||||||
if (!resource.density) {
|
if (!resource.density) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (resource.density == 'mdpi') {
|
if (resource.density === 'mdpi') {
|
||||||
hadMdpi = true;
|
hadMdpi = true;
|
||||||
}
|
}
|
||||||
var targetPath = getImageResourcePath(
|
var targetPath = getImageResourcePath(
|
||||||
@@ -395,15 +405,13 @@ function cleanIcons(projectRoot, projectConfig, platformResourcesDir) {
|
|||||||
*/
|
*/
|
||||||
function mapImageResources (rootDir, subDir, type, resourceName) {
|
function mapImageResources (rootDir, subDir, type, resourceName) {
|
||||||
var pathMap = {};
|
var pathMap = {};
|
||||||
shell.ls(path.join(rootDir, subDir, type + '-*'))
|
shell.ls(path.join(rootDir, subDir, type + '-*')).forEach(function (drawableFolder) {
|
||||||
.forEach(function (drawableFolder) {
|
|
||||||
var imagePath = path.join(subDir, path.basename(drawableFolder), resourceName);
|
var imagePath = path.join(subDir, path.basename(drawableFolder), resourceName);
|
||||||
pathMap[imagePath] = null;
|
pathMap[imagePath] = null;
|
||||||
});
|
});
|
||||||
return pathMap;
|
return pathMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function updateFileResources (cordovaProject, platformDir) {
|
function updateFileResources (cordovaProject, platformDir) {
|
||||||
var files = cordovaProject.projectConfig.getFileResources('android');
|
var files = cordovaProject.projectConfig.getFileResources('android');
|
||||||
|
|
||||||
@@ -424,9 +432,8 @@ function updateFileResources(cordovaProject, platformDir) {
|
|||||||
resourceMap, { rootDir: cordovaProject.root }, logFileOp);
|
resourceMap, { rootDir: cordovaProject.root }, logFileOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function cleanFileResources (projectRoot, projectConfig, platformDir) {
|
function cleanFileResources (projectRoot, projectConfig, platformDir) {
|
||||||
var files = projectConfig.getFileResources('android');
|
var files = projectConfig.getFileResources('android', true);
|
||||||
if (files.length > 0) {
|
if (files.length > 0) {
|
||||||
events.emit('verbose', 'Cleaning resource files at ' + platformDir);
|
events.emit('verbose', 'Cleaning resource files at ' + platformDir);
|
||||||
|
|
||||||
@@ -437,7 +444,8 @@ function cleanFileResources(projectRoot, projectConfig, platformDir) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
FileUpdater.updatePaths(
|
FileUpdater.updatePaths(
|
||||||
resourceMap, { rootDir: projectRoot, all: true}, logFileOp);
|
resourceMap, {
|
||||||
|
rootDir: projectRoot, all: true}, logFileOp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+18
-27
@@ -21,12 +21,12 @@
|
|||||||
|
|
||||||
/* jshint loopfunc:true */
|
/* jshint loopfunc:true */
|
||||||
|
|
||||||
var path = require('path'),
|
var path = require('path');
|
||||||
build = require('./build'),
|
var build = require('./build');
|
||||||
emulator = require('./emulator'),
|
var emulator = require('./emulator');
|
||||||
device = require('./device'),
|
var device = require('./device');
|
||||||
Q = require('q'),
|
var Q = require('q');
|
||||||
events = require('cordova-common').events;
|
var events = require('cordova-common').events;
|
||||||
|
|
||||||
function getInstallTarget (runOptions) {
|
function getInstallTarget (runOptions) {
|
||||||
var install_target;
|
var install_target;
|
||||||
@@ -56,12 +56,10 @@ function getInstallTarget(runOptions) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
var install_target = getInstallTarget(runOptions);
|
var install_target = getInstallTarget(runOptions);
|
||||||
|
|
||||||
return Q()
|
return Q().then(function () {
|
||||||
.then(function() {
|
|
||||||
if (!install_target) {
|
if (!install_target) {
|
||||||
// no target given, deploy to device if available, otherwise use the emulator.
|
// no target given, deploy to device if available, otherwise use the emulator.
|
||||||
return device.list()
|
return device.list().then(function (device_list) {
|
||||||
.then(function(device_list) {
|
|
||||||
if (device_list.length > 0) {
|
if (device_list.length > 0) {
|
||||||
events.emit('warn', 'No target specified, deploying to device \'' + device_list[0] + '\'.');
|
events.emit('warn', 'No target specified, deploying to device \'' + device_list[0] + '\'.');
|
||||||
install_target = device_list[0];
|
install_target = device_list[0];
|
||||||
@@ -72,35 +70,30 @@ function getInstallTarget(runOptions) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
if (install_target == '--device') {
|
if (install_target === '--device') {
|
||||||
return device.resolveTarget(null);
|
return device.resolveTarget(null);
|
||||||
} else if (install_target == '--emulator') {
|
} else if (install_target === '--emulator') {
|
||||||
// Give preference to any already started emulators. Else, start one.
|
// Give preference to any already started emulators. Else, start one.
|
||||||
return emulator.list_started()
|
return emulator.list_started().then(function (started) {
|
||||||
.then(function(started) {
|
|
||||||
return started && started.length > 0 ? started[0] : emulator.start();
|
return started && started.length > 0 ? started[0] : emulator.start();
|
||||||
}).then(function (emulatorId) {
|
}).then(function (emulatorId) {
|
||||||
return emulator.resolveTarget(emulatorId);
|
return emulator.resolveTarget(emulatorId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// They specified a specific device/emulator ID.
|
// They specified a specific device/emulator ID.
|
||||||
return device.list()
|
return device.list().then(function (devices) {
|
||||||
.then(function(devices) {
|
|
||||||
if (devices.indexOf(install_target) > -1) {
|
if (devices.indexOf(install_target) > -1) {
|
||||||
return device.resolveTarget(install_target);
|
return device.resolveTarget(install_target);
|
||||||
}
|
}
|
||||||
return emulator.list_started()
|
return emulator.list_started().then(function (started_emulators) {
|
||||||
.then(function(started_emulators) {
|
|
||||||
if (started_emulators.indexOf(install_target) > -1) {
|
if (started_emulators.indexOf(install_target) > -1) {
|
||||||
return emulator.resolveTarget(install_target);
|
return emulator.resolveTarget(install_target);
|
||||||
}
|
}
|
||||||
return emulator.list_images()
|
return emulator.list_images().then(function (avds) {
|
||||||
.then(function(avds) {
|
|
||||||
// if target emulator isn't started, then start it.
|
// if target emulator isn't started, then start it.
|
||||||
for (var avd in avds) {
|
for (var avd in avds) {
|
||||||
if (avds[avd].name == install_target) {
|
if (avds[avd].name === install_target) {
|
||||||
return emulator.start(install_target)
|
return emulator.start(install_target).then(function (emulatorId) {
|
||||||
.then(function(emulatorId) {
|
|
||||||
return emulator.resolveTarget(emulatorId);
|
return emulator.resolveTarget(emulatorId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -114,11 +107,9 @@ function getInstallTarget(runOptions) {
|
|||||||
// build results (according to platformApi spec) so they are in different
|
// build results (according to platformApi spec) so they are in different
|
||||||
// format than emulator.install expects.
|
// format than emulator.install expects.
|
||||||
// TODO: Update emulator/device.install to handle this change
|
// TODO: Update emulator/device.install to handle this change
|
||||||
return build.run.call(self, runOptions, resolvedTarget)
|
return build.run.call(self, runOptions, resolvedTarget).then(function (buildResults) {
|
||||||
.then(function(buildResults) {
|
|
||||||
if (resolvedTarget.isEmulator) {
|
if (resolvedTarget.isEmulator) {
|
||||||
return emulator.wait_for_boot(resolvedTarget.target)
|
return emulator.wait_for_boot(resolvedTarget.target).then(function () {
|
||||||
.then(function () {
|
|
||||||
return emulator.install(resolvedTarget, buildResults);
|
return emulator.install(resolvedTarget, buildResults);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
SET script_path="%~dp0start-emulator"
|
SET script_path="%~dp0start-emulator"
|
||||||
IF EXIST %script_path% (
|
IF EXIST %script_path% (
|
||||||
node "%script_path%" %*
|
node %script_path% %*
|
||||||
) ELSE (
|
) ELSE (
|
||||||
ECHO.
|
ECHO.
|
||||||
ECHO ERROR: Could not find 'start-emulator' script in 'cordova\lib' folder, aborting...>&2
|
ECHO ERROR: Could not find 'start-emulator' script in 'cordova\lib' folder, aborting...>&2
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Coho updates this line:
|
// Coho updates this line:
|
||||||
var VERSION = "6.2.0-dev";
|
var VERSION = "6.3.0";
|
||||||
|
|
||||||
module.exports.version = VERSION;
|
module.exports.version = VERSION;
|
||||||
|
|
||||||
|
|||||||
+8
-7
@@ -1,5 +1,6 @@
|
|||||||
|
/* eslint-disable */
|
||||||
// Platform: android
|
// Platform: android
|
||||||
// 7c5fcc5a5adfbf3fb8ceaf36fbdd4bd970bd9c20
|
// 74a4adc2d0fddb1e0cfb9be1961494ef0afc9893
|
||||||
/*
|
/*
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file
|
||||||
@@ -19,7 +20,7 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
;(function() {
|
;(function() {
|
||||||
var PLATFORM_VERSION_BUILD_LABEL = '6.2.0-dev';
|
var PLATFORM_VERSION_BUILD_LABEL = '6.3.0';
|
||||||
// file: src/scripts/require.js
|
// file: src/scripts/require.js
|
||||||
|
|
||||||
/*jshint -W079 */
|
/*jshint -W079 */
|
||||||
@@ -330,7 +331,7 @@ module.exports = cordova;
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/android/nativeapiprovider.js
|
// file: /Users/jbowser/cordova/cordova-android/cordova-js-src/android/nativeapiprovider.js
|
||||||
define("cordova/android/nativeapiprovider", function(require, exports, module) {
|
define("cordova/android/nativeapiprovider", function(require, exports, module) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -353,7 +354,7 @@ module.exports = {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/android/promptbasednativeapi.js
|
// file: /Users/jbowser/cordova/cordova-android/cordova-js-src/android/promptbasednativeapi.js
|
||||||
define("cordova/android/promptbasednativeapi", function(require, exports, module) {
|
define("cordova/android/promptbasednativeapi", function(require, exports, module) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -886,7 +887,7 @@ module.exports = channel;
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/exec.js
|
// file: /Users/jbowser/cordova/cordova-android/cordova-js-src/exec.js
|
||||||
define("cordova/exec", function(require, exports, module) {
|
define("cordova/exec", function(require, exports, module) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1649,7 +1650,7 @@ exports.reset();
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/platform.js
|
// file: /Users/jbowser/cordova/cordova-android/cordova-js-src/platform.js
|
||||||
define("cordova/platform", function(require, exports, module) {
|
define("cordova/platform", function(require, exports, module) {
|
||||||
|
|
||||||
// The last resume event that was received that had the result of a plugin call.
|
// The last resume event that was received that had the result of a plugin call.
|
||||||
@@ -1759,7 +1760,7 @@ function onMessageFromNative(msg) {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/plugin/android/app.js
|
// file: /Users/jbowser/cordova/cordova-android/cordova-js-src/plugin/android/app.js
|
||||||
define("cordova/plugin/android/app", function(require, exports, module) {
|
define("cordova/plugin/android/app", function(require, exports, module) {
|
||||||
|
|
||||||
var exec = require('cordova/exec');
|
var exec = require('cordova/exec');
|
||||||
|
|||||||
@@ -21,8 +21,10 @@ apply plugin: 'com.android.application'
|
|||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url "https://maven.google.com"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch the Android Gradle plugin version requirement depending on the
|
// Switch the Android Gradle plugin version requirement depending on the
|
||||||
@@ -37,8 +39,10 @@ buildscript {
|
|||||||
// Allow plugins to declare Maven dependencies via build-extras.gradle.
|
// Allow plugins to declare Maven dependencies via build-extras.gradle.
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral();
|
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url "https://maven.google.com"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,10 @@ ext {
|
|||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url "https://maven.google.com"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -40,7 +42,7 @@ apply plugin: 'com.github.dcendents.android-maven'
|
|||||||
apply plugin: 'com.jfrog.bintray'
|
apply plugin: 'com.jfrog.bintray'
|
||||||
|
|
||||||
group = 'org.apache.cordova'
|
group = 'org.apache.cordova'
|
||||||
version = '6.2.0'
|
version = '6.3.0'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion cdvCompileSdkVersion
|
compileSdkVersion cdvCompileSdkVersion
|
||||||
@@ -127,9 +129,9 @@ bintray {
|
|||||||
licenses = ['Apache-2.0']
|
licenses = ['Apache-2.0']
|
||||||
labels = ['android', 'cordova', 'phonegap']
|
labels = ['android', 'cordova', 'phonegap']
|
||||||
version {
|
version {
|
||||||
name = '6.2.0'
|
name = '6.3.0'
|
||||||
released = new Date()
|
released = new Date()
|
||||||
vcsTag = '6.2.0'
|
vcsTag = '6.3.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
# Indicates whether an apk should be generated for each density.
|
# Indicates whether an apk should be generated for each density.
|
||||||
split.density=false
|
split.density=false
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-25
|
target=android-26
|
||||||
apk-configurations=
|
apk-configurations=
|
||||||
renderscript.opt.level=O0
|
renderscript.opt.level=O0
|
||||||
android.library=true
|
android.library=true
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.cordova;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is a utility class that allows us to get the BuildConfig variable, which is required
|
||||||
|
* for the use of different providers. This is not guaranteed to work, and it's better for this
|
||||||
|
* to be set in the build step in config.xml
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
|
||||||
|
public class BuildHelper {
|
||||||
|
|
||||||
|
|
||||||
|
private static String TAG="BuildHelper";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This needs to be implemented if you wish to use the Camera Plugin or other plugins
|
||||||
|
* that read the Build Configuration.
|
||||||
|
*
|
||||||
|
* Thanks to Phil@Medtronic and Graham Borland for finding the answer and posting it to
|
||||||
|
* StackOverflow. This is annoying as hell! However, this method does not work with
|
||||||
|
* ProGuard, and you should use the config.xml to define the application_id
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static Object getBuildConfigValue(Context ctx, String key)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Class<?> clazz = Class.forName(ctx.getPackageName() + ".BuildConfig");
|
||||||
|
Field field = clazz.getField(key);
|
||||||
|
return field.get(null);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
LOG.d(TAG, "Unable to get the BuildConfig, is this built with ANT?");
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
LOG.d(TAG, key + " is not a valid field. Check your build.gradle");
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
LOG.d(TAG, "Illegal Access Exception: Let's print a stack trace.");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -31,7 +31,7 @@ import android.webkit.WebChromeClient.CustomViewCallback;
|
|||||||
* are not expected to implement it.
|
* are not expected to implement it.
|
||||||
*/
|
*/
|
||||||
public interface CordovaWebView {
|
public interface CordovaWebView {
|
||||||
public static final String CORDOVA_VERSION = "6.2.0-dev";
|
public static final String CORDOVA_VERSION = "6.3.0";
|
||||||
|
|
||||||
void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences);
|
void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
package org.apache.cordova;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides reflective methods for permission requesting and checking so that plugins
|
||||||
|
* written for cordova-android 5.0.0+ can still compile with earlier cordova-android versions.
|
||||||
|
*/
|
||||||
|
public class PermissionHelper {
|
||||||
|
private static final String LOG_TAG = "CordovaPermissionHelper";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests a "dangerous" permission for the application at runtime. This is a helper method
|
||||||
|
* alternative to cordovaInterface.requestPermission() that does not require the project to be
|
||||||
|
* built with cordova-android 5.0.0+
|
||||||
|
*
|
||||||
|
* @param plugin The plugin the permission is being requested for
|
||||||
|
* @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult()
|
||||||
|
* along with the result of the permission request
|
||||||
|
* @param permission The permission to be requested
|
||||||
|
*/
|
||||||
|
public static void requestPermission(CordovaPlugin plugin, int requestCode, String permission) {
|
||||||
|
PermissionHelper.requestPermissions(plugin, requestCode, new String[] {permission});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests "dangerous" permissions for the application at runtime. This is a helper method
|
||||||
|
* alternative to cordovaInterface.requestPermissions() that does not require the project to be
|
||||||
|
* built with cordova-android 5.0.0+
|
||||||
|
*
|
||||||
|
* @param plugin The plugin the permissions are being requested for
|
||||||
|
* @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult()
|
||||||
|
* along with the result of the permissions request
|
||||||
|
* @param permissions The permissions to be requested
|
||||||
|
*/
|
||||||
|
public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) {
|
||||||
|
plugin.cordova.requestPermissions(plugin, requestCode, permissions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks at runtime to see if the application has been granted a permission. This is a helper
|
||||||
|
* method alternative to cordovaInterface.hasPermission() that does not require the project to
|
||||||
|
* be built with cordova-android 5.0.0+
|
||||||
|
*
|
||||||
|
* @param plugin The plugin the permission is being checked against
|
||||||
|
* @param permission The permission to be checked
|
||||||
|
*
|
||||||
|
* @return True if the permission has already been granted and false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean hasPermission(CordovaPlugin plugin, String permission) {
|
||||||
|
return plugin.cordova.hasPermission(permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void deliverPermissionResult(CordovaPlugin plugin, int requestCode, String[] permissions) {
|
||||||
|
// Generate the request results
|
||||||
|
int[] requestResults = new int[permissions.length];
|
||||||
|
Arrays.fill(requestResults, PackageManager.PERMISSION_GRANTED);
|
||||||
|
|
||||||
|
try {
|
||||||
|
plugin.onRequestPermissionResult(requestCode, permissions, requestResults);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
LOG.e(LOG_TAG, "JSONException when delivering permissions results", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -110,8 +110,12 @@ public class SystemWebViewEngine implements CordovaWebViewEngine {
|
|||||||
nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() {
|
nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() {
|
||||||
@Override
|
@Override
|
||||||
public void setNetworkAvailable(boolean value) {
|
public void setNetworkAvailable(boolean value) {
|
||||||
|
//sometimes this can be called after calling webview.destroy() on destroy()
|
||||||
|
//thus resulting in a NullPointerException
|
||||||
|
if(webView!=null) {
|
||||||
webView.setNetworkAvailable(value);
|
webView.setNetworkAvailable(value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void runOnUiThread(Runnable r) {
|
public void runOnUiThread(Runnable r) {
|
||||||
SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r);
|
SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r);
|
||||||
|
|||||||
+3
-3
@@ -10,7 +10,7 @@
|
|||||||
"spec": ">=1.0.0 <2.0.0",
|
"spec": ">=1.0.0 <2.0.0",
|
||||||
"type": "range"
|
"type": "range"
|
||||||
},
|
},
|
||||||
"/Users/steveng/repo/cordova/cordova-android/node_modules/nopt"
|
"/Users/jbowser/cordova/cordova-android/node_modules/nopt"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"_from": "abbrev@>=1.0.0 <2.0.0",
|
"_from": "abbrev@>=1.0.0 <2.0.0",
|
||||||
@@ -40,11 +40,11 @@
|
|||||||
"_requiredBy": [
|
"_requiredBy": [
|
||||||
"/nopt"
|
"/nopt"
|
||||||
],
|
],
|
||||||
"_resolved": "http://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz",
|
"_resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz",
|
||||||
"_shasum": "d0554c2256636e2f56e7c2e5ad183f859428d81f",
|
"_shasum": "d0554c2256636e2f56e7c2e5ad183f859428d81f",
|
||||||
"_shrinkwrap": null,
|
"_shrinkwrap": null,
|
||||||
"_spec": "abbrev@1",
|
"_spec": "abbrev@1",
|
||||||
"_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/nopt",
|
"_where": "/Users/jbowser/cordova/cordova-android/node_modules/nopt",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Isaac Z. Schlueter",
|
"name": "Isaac Z. Schlueter",
|
||||||
"email": "i@izs.me"
|
"email": "i@izs.me"
|
||||||
|
|||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
.git/
|
||||||
|
node_modules/
|
||||||
|
coverage/
|
||||||
|
build/
|
||||||
|
assets/
|
||||||
|
dist/
|
||||||
|
docs/
|
||||||
|
tests/
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"indent": 2,
|
||||||
|
"forin": true,
|
||||||
|
"noarg": true,
|
||||||
|
"bitwise": true,
|
||||||
|
"nonew": true,
|
||||||
|
"strict": true,
|
||||||
|
|
||||||
|
"browser": true,
|
||||||
|
"devel": true,
|
||||||
|
"node": false,
|
||||||
|
"jquery": false,
|
||||||
|
"esnext": false,
|
||||||
|
"moz": false,
|
||||||
|
"es3": false,
|
||||||
|
|
||||||
|
"asi": true,
|
||||||
|
|
||||||
|
"eqnull": true,
|
||||||
|
"debug": true,
|
||||||
|
"boss": true,
|
||||||
|
"evil": true,
|
||||||
|
"loopfunc": true,
|
||||||
|
"laxbreak": true,
|
||||||
|
|
||||||
|
"unused": true,
|
||||||
|
"undef": true
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- "6.1.0"
|
||||||
+87
@@ -0,0 +1,87 @@
|
|||||||
|
Android Versions
|
||||||
|
================
|
||||||
|
|
||||||
|
A node module to get Android versions by API level, NDK level, semantic version, or version name.
|
||||||
|
|
||||||
|
Versions are referenced from [source.android.com/source/build-numbers.html](https://source.android.com/source/build-numbers.html#platform-code-names-versions-api-levels-and-ndk-releases). The version for "Current Development Build" (`"CUR_DEVELOPMENT"`) is not included in the list of `VERSIONS`.
|
||||||
|
|
||||||
|
[![NPM version][npm-image]][npm-url]
|
||||||
|
[![build status][travis-image]][travis-url]
|
||||||
|
|
||||||
|
[npm-image]: https://img.shields.io/npm/v/android-versions.svg?style=flat-square
|
||||||
|
[npm-url]: https://npmjs.org/package/android-versions
|
||||||
|
[travis-image]: https://img.shields.io/travis/dvoiss/android-versions.svg?style=flat-square
|
||||||
|
[travis-url]: https://travis-ci.org/dvoiss/android-versions
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# NPM
|
||||||
|
npm install android-versions --save
|
||||||
|
# YARN
|
||||||
|
yarn add android-versions
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
View the tests for more advanced usage.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const android = require('android-versions')
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Get by API level:
|
||||||
|
```javascript
|
||||||
|
console.log(android.get(23))
|
||||||
|
|
||||||
|
=> { api: 23, ndk: 8, semver: "6.0", name: "Marshmallow", versionCode: "M" }
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Get by version:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
console.log(android.get("2.3.3"))
|
||||||
|
|
||||||
|
=> { api: 10, ndk: 5, semver: "2.3.3", name: "Gingerbread", versionCode: "GINGERBREAD_MR1" }
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Get all by predicate:
|
||||||
|
|
||||||
|
```
|
||||||
|
android.getAll((version) => {
|
||||||
|
return version.ndk > 5 && version.api < 15
|
||||||
|
}).map((version) => version.versionCode)
|
||||||
|
|
||||||
|
=> [ "HONEYCOMB_MR1", "HONEYCOMB_MR2", "ICE_CREAM_SANDWICH" ]
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Access a specific version with all info:
|
||||||
|
|
||||||
|
```
|
||||||
|
android.LOLLIPOP
|
||||||
|
|
||||||
|
=> { api: 21, ndk: 8, semver: "5.0", name: "Lollipop", versionCode: "LOLLIPOP" }
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Access the complete reference of Android versions with all info:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
android.VERSIONS
|
||||||
|
|
||||||
|
=> {
|
||||||
|
BASE: { api: 1, ndk: 0, semver: "1.0", name: "(no code name)", versionCode: "BASE" },
|
||||||
|
...
|
||||||
|
N: { api: 24, ndk: 8, semver: "7.0", name: "Nougat", versionCode: "N" }
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run test
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT
|
||||||
+153
@@ -0,0 +1,153 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2016, David Voiss <davidvoiss@gmail.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any purpose
|
||||||
|
* with or without fee is hereby granted, provided that the above copyright notice
|
||||||
|
* and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||||
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||||
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||||
|
* THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* jshint node: true */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A module to get Android versions by API level, NDK level, semantic version, or version name.
|
||||||
|
*
|
||||||
|
* Versions are referenced from here:
|
||||||
|
* {@link https://source.android.com/source/build-numbers.html#platform-code-names-versions-api-levels-and-ndk-releases}
|
||||||
|
* {@link https://github.com/android/platform_frameworks_base/blob/master/core/java/android/os/Build.java}
|
||||||
|
*
|
||||||
|
* The version for "Current Development Build" ("CUR_DEVELOPMENT") is not included.
|
||||||
|
*
|
||||||
|
* @module android-versions
|
||||||
|
*/
|
||||||
|
|
||||||
|
var VERSIONS = {
|
||||||
|
BASE: { api: 1, ndk: 0, semver: "1.0", name: "(no code name)", versionCode: "BASE" },
|
||||||
|
BASE_1_1: { api: 2, ndk: 0, semver: "1.1", name: "(no code name)", versionCode: "BASE_1_1" },
|
||||||
|
CUPCAKE: { api: 3, ndk: 1, semver: "1.5", name: "Cupcake", versionCode: "CUPCAKE" },
|
||||||
|
DONUT: { api: 4, ndk: 2, semver: "1.6", name: "Donut", versionCode: "DONUT" },
|
||||||
|
ECLAIR: { api: 5, ndk: 2, semver: "2.0", name: "Eclair", versionCode: "ECLAIR" },
|
||||||
|
ECLAIR_0_1: { api: 6, ndk: 2, semver: "2.0.1", name: "Eclair", versionCode: "ECLAIR_0_1" },
|
||||||
|
ECLAIR_MR1: { api: 7, ndk: 3, semver: "2.1", name: "Eclair", versionCode: "ECLAIR_MR1" },
|
||||||
|
FROYO: { api: 8, ndk: 4, semver: "2.2", name: "Froyo", versionCode: "FROYO" },
|
||||||
|
GINGERBREAD: { api: 9, ndk: 5, semver: "2.3", name: "Gingerbread", versionCode: "GINGERBREAD" },
|
||||||
|
GINGERBREAD_MR1: { api: 10, ndk: 5, semver: "2.3.3", name: "Gingerbread", versionCode: "GINGERBREAD_MR1" },
|
||||||
|
HONEYCOMB: { api: 11, ndk: 5, semver: "3.0", name: "Honeycomb", versionCode: "HONEYCOMB" },
|
||||||
|
HONEYCOMB_MR1: { api: 12, ndk: 6, semver: "3.1", name: "Honeycomb", versionCode: "HONEYCOMB_MR1" },
|
||||||
|
HONEYCOMB_MR2: { api: 13, ndk: 6, semver: "3.2", name: "Honeycomb", versionCode: "HONEYCOMB_MR2" },
|
||||||
|
ICE_CREAM_SANDWICH: { api: 14, ndk: 7, semver: "4.0", name: "Ice Cream Sandwich", versionCode: "ICE_CREAM_SANDWICH" },
|
||||||
|
ICE_CREAM_SANDWICH_MR1: { api: 15, ndk: 8, semver: "4.0.3", name: "Ice Cream Sandwich", versionCode: "ICE_CREAM_SANDWICH_MR1" },
|
||||||
|
JELLY_BEAN: { api: 16, ndk: 8, semver: "4.1", name: "Jellybean", versionCode: "JELLY_BEAN" },
|
||||||
|
JELLY_BEAN_MR1: { api: 17, ndk: 8, semver: "4.2", name: "Jellybean", versionCode: "JELLY_BEAN_MR1" },
|
||||||
|
JELLY_BEAN_MR2: { api: 18, ndk: 8, semver: "4.3", name: "Jellybean", versionCode: "JELLY_BEAN_MR2" },
|
||||||
|
KITKAT: { api: 19, ndk: 8, semver: "4.4", name: "KitKat", versionCode: "KITKAT" },
|
||||||
|
KITKAT_WATCH: { api: 20, ndk: 8, semver: "4.4", name: "KitKat Watch", versionCode: "KITKAT_WATCH" },
|
||||||
|
LOLLIPOP: { api: 21, ndk: 8, semver: "5.0", name: "Lollipop", versionCode: "LOLLIPOP" },
|
||||||
|
LOLLIPOP_MR1: { api: 22, ndk: 8, semver: "5.1", name: "Lollipop", versionCode: "LOLLIPOP_MR1" },
|
||||||
|
M: { api: 23, ndk: 8, semver: "6.0", name: "Marshmallow", versionCode: "M" },
|
||||||
|
N: { api: 24, ndk: 8, semver: "7.0", name: "Nougat", versionCode: "N" },
|
||||||
|
N_MR1: { api: 25, ndk: 8, semver: "7.1", name: "Nougat", versionCode: "N_MR1" },
|
||||||
|
O: { api: 26, ndk: 8, semver: "8.0.0", name: "Oreo", versionCode: "O" }
|
||||||
|
}
|
||||||
|
|
||||||
|
// This altSemVer accomodates the variations of semantic versions in the table above.
|
||||||
|
// For instance, Oreo is 8.0.0 while N is 7.0, searching for "8.0" or "8.0.0" will
|
||||||
|
// return Oreo, or searching for "7.0" or "7.0.0" will return N. "2.2.0" will return Froyo.
|
||||||
|
function getAlternateSemVer(semver) {
|
||||||
|
if (semver.match(/\d+.\d+.0/)) {
|
||||||
|
return semver.replace(/.\d+$/, '')
|
||||||
|
} else if (semver.match(/^\d+.\d+$/)) {
|
||||||
|
return semver + '.0'
|
||||||
|
} else {
|
||||||
|
return semver
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The default predicate compares against API level, semver, name, or code.
|
||||||
|
function getFromDefaultPredicate(arg) {
|
||||||
|
// Coerce arg to string for comparisons below.
|
||||||
|
arg = arg.toString()
|
||||||
|
|
||||||
|
return getFromPredicate(function(version) {
|
||||||
|
// Check API level before all else.
|
||||||
|
if (arg === version.api.toString()) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare semver and alternate semver (see above).
|
||||||
|
var altSemVer = getAlternateSemVer(arg)
|
||||||
|
if (version.semver === arg || version.semver === altSemVer) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare version name and code.
|
||||||
|
return arg === version.name || arg === version.versionCode
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// The function to allow passing a predicate.
|
||||||
|
function getFromPredicate(predicate) {
|
||||||
|
if (predicate === null) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return Object.keys(VERSIONS).filter(function(version) {
|
||||||
|
return predicate(VERSIONS[version])
|
||||||
|
}).map(function(key) { return VERSIONS[key] })
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Android version codes available as keys for easier look-up.
|
||||||
|
*/
|
||||||
|
Object.keys(VERSIONS).forEach(function(name) {
|
||||||
|
exports[name] = VERSIONS[name]
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The complete reference of Android versions for easier look-up.
|
||||||
|
*/
|
||||||
|
exports.VERSIONS = VERSIONS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a single Android version.
|
||||||
|
*
|
||||||
|
* @param {object | Function} arg - The value or predicate to use to retrieve values.
|
||||||
|
*
|
||||||
|
* @return {object} An object representing the version found or null if none found.
|
||||||
|
*/
|
||||||
|
exports.get = function(arg) {
|
||||||
|
var result = exports.getAll(arg)
|
||||||
|
|
||||||
|
if (result === null || result.length === 0) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return result[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve all Android versions that meet the criteria of the argument.
|
||||||
|
*
|
||||||
|
* @param {object | Function} arg - The value or predicate to use to retrieve values.
|
||||||
|
*
|
||||||
|
* @return {object} An object representing the version found or null if none found.
|
||||||
|
*/
|
||||||
|
exports.getAll = function(arg) {
|
||||||
|
if (arg === null) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof arg === "function") {
|
||||||
|
return getFromPredicate(arg)
|
||||||
|
} else {
|
||||||
|
return getFromDefaultPredicate(arg)
|
||||||
|
}
|
||||||
|
}
|
||||||
+103
@@ -0,0 +1,103 @@
|
|||||||
|
{
|
||||||
|
"_args": [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"raw": "android-versions@^1.2.0",
|
||||||
|
"scope": null,
|
||||||
|
"escapedName": "android-versions",
|
||||||
|
"name": "android-versions",
|
||||||
|
"rawSpec": "^1.2.0",
|
||||||
|
"spec": ">=1.2.0 <2.0.0",
|
||||||
|
"type": "range"
|
||||||
|
},
|
||||||
|
"/Users/jbowser/cordova/cordova-android"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"_from": "android-versions@>=1.2.0 <2.0.0",
|
||||||
|
"_id": "android-versions@1.2.1",
|
||||||
|
"_inCache": true,
|
||||||
|
"_location": "/android-versions",
|
||||||
|
"_nodeVersion": "8.0.0",
|
||||||
|
"_npmOperationalInternal": {
|
||||||
|
"host": "s3://npm-registry-packages",
|
||||||
|
"tmp": "tmp/android-versions-1.2.1.tgz_1505373302036_0.5689644906669855"
|
||||||
|
},
|
||||||
|
"_npmUser": {
|
||||||
|
"name": "dvoiss",
|
||||||
|
"email": "davidvoiss@gmail.com"
|
||||||
|
},
|
||||||
|
"_npmVersion": "5.4.0",
|
||||||
|
"_phantomChildren": {},
|
||||||
|
"_requested": {
|
||||||
|
"raw": "android-versions@^1.2.0",
|
||||||
|
"scope": null,
|
||||||
|
"escapedName": "android-versions",
|
||||||
|
"name": "android-versions",
|
||||||
|
"rawSpec": "^1.2.0",
|
||||||
|
"spec": ">=1.2.0 <2.0.0",
|
||||||
|
"type": "range"
|
||||||
|
},
|
||||||
|
"_requiredBy": [
|
||||||
|
"/"
|
||||||
|
],
|
||||||
|
"_resolved": "https://registry.npmjs.org/android-versions/-/android-versions-1.2.1.tgz",
|
||||||
|
"_shasum": "3f50baf693e73a512c3c5403542291cead900063",
|
||||||
|
"_shrinkwrap": null,
|
||||||
|
"_spec": "android-versions@^1.2.0",
|
||||||
|
"_where": "/Users/jbowser/cordova/cordova-android",
|
||||||
|
"author": {
|
||||||
|
"name": "dvoiss"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/dvoiss/android-versions/issues"
|
||||||
|
},
|
||||||
|
"dependencies": {},
|
||||||
|
"description": "Get the name, API level, version level, NDK level, or version code from any version of Android.",
|
||||||
|
"devDependencies": {
|
||||||
|
"jsdoc": "^3.4.0",
|
||||||
|
"jshint": "^2.9.2",
|
||||||
|
"tape": "^4.6.0"
|
||||||
|
},
|
||||||
|
"directories": {},
|
||||||
|
"dist": {
|
||||||
|
"integrity": "sha512-k6zlrtWbJ3tx1ZsyyJ0Bo3r6cqPA3JUnFGv7pnIaLr1XVxSi2Tcem2lg3kBebFp27v/A40tZqdlouPyakpyKrw==",
|
||||||
|
"shasum": "3f50baf693e73a512c3c5403542291cead900063",
|
||||||
|
"tarball": "https://registry.npmjs.org/android-versions/-/android-versions-1.2.1.tgz"
|
||||||
|
},
|
||||||
|
"gitHead": "7e2def6e70634a4ebcaaa639a4c4955ae2a566e7",
|
||||||
|
"homepage": "https://github.com/dvoiss/android-versions#readme",
|
||||||
|
"keywords": [
|
||||||
|
"android",
|
||||||
|
"version",
|
||||||
|
"versions",
|
||||||
|
"ndk",
|
||||||
|
"nougat",
|
||||||
|
"marshmallow",
|
||||||
|
"api",
|
||||||
|
"level"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "index.js",
|
||||||
|
"maintainers": [
|
||||||
|
{
|
||||||
|
"name": "dvoiss",
|
||||||
|
"email": "davidvoiss@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "android-versions",
|
||||||
|
"optionalDependencies": {},
|
||||||
|
"pre-commit": [
|
||||||
|
"jshint"
|
||||||
|
],
|
||||||
|
"readme": "ERROR: No README data found!",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/dvoiss/android-versions.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"docs": "jsdoc index.js -d ./docs/ -R README.md --debug",
|
||||||
|
"jshint": "jshint .",
|
||||||
|
"test": "tape tests/**/*.js"
|
||||||
|
},
|
||||||
|
"version": "1.2.1"
|
||||||
|
}
|
||||||
+3
-3
@@ -10,7 +10,7 @@
|
|||||||
"spec": ">=0.3.1 <0.4.0",
|
"spec": ">=0.3.1 <0.4.0",
|
||||||
"type": "range"
|
"type": "range"
|
||||||
},
|
},
|
||||||
"/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common"
|
"/Users/jbowser/cordova/cordova-android/node_modules/cordova-common"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"_from": "ansi@>=0.3.1 <0.4.0",
|
"_from": "ansi@>=0.3.1 <0.4.0",
|
||||||
@@ -36,11 +36,11 @@
|
|||||||
"_requiredBy": [
|
"_requiredBy": [
|
||||||
"/cordova-common"
|
"/cordova-common"
|
||||||
],
|
],
|
||||||
"_resolved": "http://registry.npmjs.org/ansi/-/ansi-0.3.1.tgz",
|
"_resolved": "https://registry.npmjs.org/ansi/-/ansi-0.3.1.tgz",
|
||||||
"_shasum": "0c42d4fb17160d5a9af1e484bace1c66922c1b21",
|
"_shasum": "0c42d4fb17160d5a9af1e484bace1c66922c1b21",
|
||||||
"_shrinkwrap": null,
|
"_shrinkwrap": null,
|
||||||
"_spec": "ansi@^0.3.1",
|
"_spec": "ansi@^0.3.1",
|
||||||
"_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common",
|
"_where": "/Users/jbowser/cordova/cordova-android/node_modules/cordova-common",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Nathan Rajlich",
|
"name": "Nathan Rajlich",
|
||||||
"email": "nathan@tootallnate.net",
|
"email": "nathan@tootallnate.net",
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
'use strict';
|
||||||
module.exports = balanced;
|
module.exports = balanced;
|
||||||
function balanced(a, b, str) {
|
function balanced(a, b, str) {
|
||||||
if (a instanceof RegExp) a = maybeMatch(a, str);
|
if (a instanceof RegExp) a = maybeMatch(a, str);
|
||||||
|
|||||||
+23
-21
@@ -2,49 +2,49 @@
|
|||||||
"_args": [
|
"_args": [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"raw": "balanced-match@^0.4.1",
|
"raw": "balanced-match@^1.0.0",
|
||||||
"scope": null,
|
"scope": null,
|
||||||
"escapedName": "balanced-match",
|
"escapedName": "balanced-match",
|
||||||
"name": "balanced-match",
|
"name": "balanced-match",
|
||||||
"rawSpec": "^0.4.1",
|
"rawSpec": "^1.0.0",
|
||||||
"spec": ">=0.4.1 <0.5.0",
|
"spec": ">=1.0.0 <2.0.0",
|
||||||
"type": "range"
|
"type": "range"
|
||||||
},
|
},
|
||||||
"/Users/steveng/repo/cordova/cordova-android/node_modules/brace-expansion"
|
"/Users/jbowser/cordova/cordova-android/node_modules/brace-expansion"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"_from": "balanced-match@>=0.4.1 <0.5.0",
|
"_from": "balanced-match@>=1.0.0 <2.0.0",
|
||||||
"_id": "balanced-match@0.4.2",
|
"_id": "balanced-match@1.0.0",
|
||||||
"_inCache": true,
|
"_inCache": true,
|
||||||
"_location": "/balanced-match",
|
"_location": "/balanced-match",
|
||||||
"_nodeVersion": "4.4.7",
|
"_nodeVersion": "7.8.0",
|
||||||
"_npmOperationalInternal": {
|
"_npmOperationalInternal": {
|
||||||
"host": "packages-16-east.internal.npmjs.com",
|
"host": "s3://npm-registry-packages",
|
||||||
"tmp": "tmp/balanced-match-0.4.2.tgz_1468834991581_0.6590619895141572"
|
"tmp": "tmp/balanced-match-1.0.0.tgz_1497251909645_0.8755026108119637"
|
||||||
},
|
},
|
||||||
"_npmUser": {
|
"_npmUser": {
|
||||||
"name": "juliangruber",
|
"name": "juliangruber",
|
||||||
"email": "julian@juliangruber.com"
|
"email": "julian@juliangruber.com"
|
||||||
},
|
},
|
||||||
"_npmVersion": "2.15.8",
|
"_npmVersion": "4.2.0",
|
||||||
"_phantomChildren": {},
|
"_phantomChildren": {},
|
||||||
"_requested": {
|
"_requested": {
|
||||||
"raw": "balanced-match@^0.4.1",
|
"raw": "balanced-match@^1.0.0",
|
||||||
"scope": null,
|
"scope": null,
|
||||||
"escapedName": "balanced-match",
|
"escapedName": "balanced-match",
|
||||||
"name": "balanced-match",
|
"name": "balanced-match",
|
||||||
"rawSpec": "^0.4.1",
|
"rawSpec": "^1.0.0",
|
||||||
"spec": ">=0.4.1 <0.5.0",
|
"spec": ">=1.0.0 <2.0.0",
|
||||||
"type": "range"
|
"type": "range"
|
||||||
},
|
},
|
||||||
"_requiredBy": [
|
"_requiredBy": [
|
||||||
"/brace-expansion"
|
"/brace-expansion"
|
||||||
],
|
],
|
||||||
"_resolved": "http://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz",
|
"_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||||
"_shasum": "cb3f3e3c732dc0f01ee70b403f302e61d7709838",
|
"_shasum": "89b4d199ab2bee49de164ea02b89ce462d71b767",
|
||||||
"_shrinkwrap": null,
|
"_shrinkwrap": null,
|
||||||
"_spec": "balanced-match@^0.4.1",
|
"_spec": "balanced-match@^1.0.0",
|
||||||
"_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/brace-expansion",
|
"_where": "/Users/jbowser/cordova/cordova-android/node_modules/brace-expansion",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Julian Gruber",
|
"name": "Julian Gruber",
|
||||||
"email": "mail@juliangruber.com",
|
"email": "mail@juliangruber.com",
|
||||||
@@ -56,14 +56,15 @@
|
|||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"description": "Match balanced character pairs, like \"{\" and \"}\"",
|
"description": "Match balanced character pairs, like \"{\" and \"}\"",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"matcha": "^0.7.0",
|
||||||
"tape": "^4.6.0"
|
"tape": "^4.6.0"
|
||||||
},
|
},
|
||||||
"directories": {},
|
"directories": {},
|
||||||
"dist": {
|
"dist": {
|
||||||
"shasum": "cb3f3e3c732dc0f01ee70b403f302e61d7709838",
|
"shasum": "89b4d199ab2bee49de164ea02b89ce462d71b767",
|
||||||
"tarball": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz"
|
"tarball": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz"
|
||||||
},
|
},
|
||||||
"gitHead": "57c2ea29d89a2844ae3bdcc637c6e2cbb73725e2",
|
"gitHead": "d701a549a7653a874eebce7eca25d3577dc868ac",
|
||||||
"homepage": "https://github.com/juliangruber/balanced-match",
|
"homepage": "https://github.com/juliangruber/balanced-match",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"match",
|
"match",
|
||||||
@@ -88,6 +89,7 @@
|
|||||||
"url": "git://github.com/juliangruber/balanced-match.git"
|
"url": "git://github.com/juliangruber/balanced-match.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"bench": "make bench",
|
||||||
"test": "make test"
|
"test": "make test"
|
||||||
},
|
},
|
||||||
"testling": {
|
"testling": {
|
||||||
@@ -106,5 +108,5 @@
|
|||||||
"android-browser/4.2..latest"
|
"android-browser/4.2..latest"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"version": "0.4.2"
|
"version": "1.0.0"
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -10,7 +10,7 @@
|
|||||||
"spec": "0.0.8",
|
"spec": "0.0.8",
|
||||||
"type": "version"
|
"type": "version"
|
||||||
},
|
},
|
||||||
"/Users/steveng/repo/cordova/cordova-android/node_modules/plist"
|
"/Users/jbowser/cordova/cordova-android/node_modules/plist"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"_from": "base64-js@0.0.8",
|
"_from": "base64-js@0.0.8",
|
||||||
@@ -36,11 +36,11 @@
|
|||||||
"_requiredBy": [
|
"_requiredBy": [
|
||||||
"/plist"
|
"/plist"
|
||||||
],
|
],
|
||||||
"_resolved": "http://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz",
|
"_resolved": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz",
|
||||||
"_shasum": "1101e9544f4a76b1bc3b26d452ca96d7a35e7978",
|
"_shasum": "1101e9544f4a76b1bc3b26d452ca96d7a35e7978",
|
||||||
"_shrinkwrap": null,
|
"_shrinkwrap": null,
|
||||||
"_spec": "base64-js@0.0.8",
|
"_spec": "base64-js@0.0.8",
|
||||||
"_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/plist",
|
"_where": "/Users/jbowser/cordova/cordova-android/node_modules/plist",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "T. Jameson Little",
|
"name": "T. Jameson Little",
|
||||||
"email": "t.jameson.little@gmail.com"
|
"email": "t.jameson.little@gmail.com"
|
||||||
|
|||||||
+2364
File diff suppressed because it is too large
Load Diff
+49
-10
@@ -118,7 +118,7 @@ var bigInt = (function (undefined) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BigInteger.prototype.add = function (v) {
|
BigInteger.prototype.add = function (v) {
|
||||||
var value, n = parseValue(v);
|
var n = parseValue(v);
|
||||||
if (this.sign !== n.sign) {
|
if (this.sign !== n.sign) {
|
||||||
return this.subtract(n.negate());
|
return this.subtract(n.negate());
|
||||||
}
|
}
|
||||||
@@ -177,7 +177,7 @@ var bigInt = (function (undefined) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function subtractAny(a, b, sign) {
|
function subtractAny(a, b, sign) {
|
||||||
var value, isSmall;
|
var value;
|
||||||
if (compareAbs(a, b) >= 0) {
|
if (compareAbs(a, b) >= 0) {
|
||||||
value = subtract(a,b);
|
value = subtract(a,b);
|
||||||
} else {
|
} else {
|
||||||
@@ -326,7 +326,7 @@ var bigInt = (function (undefined) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BigInteger.prototype.multiply = function (v) {
|
BigInteger.prototype.multiply = function (v) {
|
||||||
var value, n = parseValue(v),
|
var n = parseValue(v),
|
||||||
a = this.value, b = n.value,
|
a = this.value, b = n.value,
|
||||||
sign = this.sign !== n.sign,
|
sign = this.sign !== n.sign,
|
||||||
abs;
|
abs;
|
||||||
@@ -467,6 +467,7 @@ var bigInt = (function (undefined) {
|
|||||||
guess, xlen, highx, highy, check;
|
guess, xlen, highx, highy, check;
|
||||||
while (a_l) {
|
while (a_l) {
|
||||||
part.unshift(a[--a_l]);
|
part.unshift(a[--a_l]);
|
||||||
|
trim(part);
|
||||||
if (compareAbs(part, b) < 0) {
|
if (compareAbs(part, b) < 0) {
|
||||||
result.push(0);
|
result.push(0);
|
||||||
continue;
|
continue;
|
||||||
@@ -837,8 +838,12 @@ var bigInt = (function (undefined) {
|
|||||||
if (t.compare(0) === -1) {
|
if (t.compare(0) === -1) {
|
||||||
t = t.add(n);
|
t = t.add(n);
|
||||||
}
|
}
|
||||||
return t;
|
if (this.isNegative()) {
|
||||||
|
return t.negate();
|
||||||
}
|
}
|
||||||
|
return t;
|
||||||
|
};
|
||||||
|
|
||||||
SmallInteger.prototype.modInv = BigInteger.prototype.modInv;
|
SmallInteger.prototype.modInv = BigInteger.prototype.modInv;
|
||||||
|
|
||||||
BigInteger.prototype.next = function () {
|
BigInteger.prototype.next = function () {
|
||||||
@@ -1032,16 +1037,32 @@ var bigInt = (function (undefined) {
|
|||||||
return low.add(typeof result === "number" ? new SmallInteger(result) : new BigInteger(result, false));
|
return low.add(typeof result === "number" ? new SmallInteger(result) : new BigInteger(result, false));
|
||||||
}
|
}
|
||||||
var parseBase = function (text, base) {
|
var parseBase = function (text, base) {
|
||||||
var val = Integer[0], pow = Integer[1],
|
var length = text.length;
|
||||||
length = text.length;
|
var i;
|
||||||
|
var absBase = Math.abs(base);
|
||||||
|
for(var i = 0; i < length; i++) {
|
||||||
|
var c = text[i].toLowerCase();
|
||||||
|
if(c === "-") continue;
|
||||||
|
if(/[a-z0-9]/.test(c)) {
|
||||||
|
if(/[0-9]/.test(c) && +c >= absBase) {
|
||||||
|
if(c === "1" && absBase === 1) continue;
|
||||||
|
throw new Error(c + " is not a valid digit in base " + base + ".");
|
||||||
|
} else if(c.charCodeAt(0) - 87 >= absBase) {
|
||||||
|
throw new Error(c + " is not a valid digit in base " + base + ".");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (2 <= base && base <= 36) {
|
if (2 <= base && base <= 36) {
|
||||||
if (length <= LOG_MAX_INT / Math.log(base)) {
|
if (length <= LOG_MAX_INT / Math.log(base)) {
|
||||||
|
var result = parseInt(text, base);
|
||||||
|
if(isNaN(result)) {
|
||||||
|
throw new Error(c + " is not a valid digit in base " + base + ".");
|
||||||
|
}
|
||||||
return new SmallInteger(parseInt(text, base));
|
return new SmallInteger(parseInt(text, base));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
base = parseValue(base);
|
base = parseValue(base);
|
||||||
var digits = [];
|
var digits = [];
|
||||||
var i;
|
|
||||||
var isNegative = text[0] === "-";
|
var isNegative = text[0] === "-";
|
||||||
for (i = isNegative ? 1 : 0; i < text.length; i++) {
|
for (i = isNegative ? 1 : 0; i < text.length; i++) {
|
||||||
var c = text[i].toLowerCase(),
|
var c = text[i].toLowerCase(),
|
||||||
@@ -1055,13 +1076,17 @@ var bigInt = (function (undefined) {
|
|||||||
}
|
}
|
||||||
else throw new Error(c + " is not a valid character");
|
else throw new Error(c + " is not a valid character");
|
||||||
}
|
}
|
||||||
digits.reverse();
|
return parseBaseFromArray(digits, base, isNegative);
|
||||||
for (i = 0; i < digits.length; i++) {
|
};
|
||||||
|
|
||||||
|
function parseBaseFromArray(digits, base, isNegative) {
|
||||||
|
var val = Integer[0], pow = Integer[1], i;
|
||||||
|
for (i = digits.length - 1; i >= 0; i--) {
|
||||||
val = val.add(digits[i].times(pow));
|
val = val.add(digits[i].times(pow));
|
||||||
pow = pow.times(base);
|
pow = pow.times(base);
|
||||||
}
|
}
|
||||||
return isNegative ? val.negate() : val;
|
return isNegative ? val.negate() : val;
|
||||||
};
|
}
|
||||||
|
|
||||||
function stringify(digit) {
|
function stringify(digit) {
|
||||||
var v = digit.value;
|
var v = digit.value;
|
||||||
@@ -1118,11 +1143,13 @@ var bigInt = (function (undefined) {
|
|||||||
var sign = this.sign ? "-" : "";
|
var sign = this.sign ? "-" : "";
|
||||||
return sign + str;
|
return sign + str;
|
||||||
};
|
};
|
||||||
|
|
||||||
SmallInteger.prototype.toString = function (radix) {
|
SmallInteger.prototype.toString = function (radix) {
|
||||||
if (radix === undefined) radix = 10;
|
if (radix === undefined) radix = 10;
|
||||||
if (radix != 10) return toBase(this, radix);
|
if (radix != 10) return toBase(this, radix);
|
||||||
return String(this.value);
|
return String(this.value);
|
||||||
};
|
};
|
||||||
|
BigInteger.prototype.toJSON = SmallInteger.prototype.toJSON = function() { return this.toString(); }
|
||||||
|
|
||||||
BigInteger.prototype.valueOf = function () {
|
BigInteger.prototype.valueOf = function () {
|
||||||
return +this.toString();
|
return +this.toString();
|
||||||
@@ -1205,6 +1232,11 @@ var bigInt = (function (undefined) {
|
|||||||
Integer.lcm = lcm;
|
Integer.lcm = lcm;
|
||||||
Integer.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger; };
|
Integer.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger; };
|
||||||
Integer.randBetween = randBetween;
|
Integer.randBetween = randBetween;
|
||||||
|
|
||||||
|
Integer.fromArray = function (digits, base, isNegative) {
|
||||||
|
return parseBaseFromArray(digits.map(parseValue), parseValue(base || 10), isNegative);
|
||||||
|
};
|
||||||
|
|
||||||
return Integer;
|
return Integer;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@@ -1212,3 +1244,10 @@ var bigInt = (function (undefined) {
|
|||||||
if (typeof module !== "undefined" && module.hasOwnProperty("exports")) {
|
if (typeof module !== "undefined" && module.hasOwnProperty("exports")) {
|
||||||
module.exports = bigInt;
|
module.exports = bigInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//amd check
|
||||||
|
if ( typeof define === "function" && define.amd ) {
|
||||||
|
define( "big-integer", [], function() {
|
||||||
|
return bigInt;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+8
-1
@@ -211,7 +211,7 @@ Returns `true` if the number is prime, `false` otherwise.
|
|||||||
|
|
||||||
#### `isProbablePrime([iterations])`
|
#### `isProbablePrime([iterations])`
|
||||||
|
|
||||||
Returns `true` if the number is very likely to be positive, `false` otherwise.
|
Returns `true` if the number is very likely to be prime, `false` otherwise.
|
||||||
Argument is optional and determines the amount of iterations of the test (default: `5`). The more iterations, the lower chance of getting a false positive.
|
Argument is optional and determines the amount of iterations of the test (default: `5`). The more iterations, the lower chance of getting a false positive.
|
||||||
This uses the [Fermat primality test](https://en.wikipedia.org/wiki/Fermat_primality_test).
|
This uses the [Fermat primality test](https://en.wikipedia.org/wiki/Fermat_primality_test).
|
||||||
|
|
||||||
@@ -421,6 +421,13 @@ Performs the bitwise XOR operation. The operands are treated as if they were rep
|
|||||||
|
|
||||||
### Static Methods
|
### Static Methods
|
||||||
|
|
||||||
|
#### `fromArray(digits, base = 10, isNegative?)`
|
||||||
|
|
||||||
|
Constructs a bigInt from an array of digits in base `base`. The optional `isNegative` flag will make the number negative.
|
||||||
|
|
||||||
|
- `bigInt.fromArray([1, 2, 3, 4, 5], 10)` => `12345`
|
||||||
|
- `bigInt.fromArray([1, 0, 0], 2, true)` => `-4`
|
||||||
|
|
||||||
#### `gcd(a, b)`
|
#### `gcd(a, b)`
|
||||||
|
|
||||||
Finds the greatest common denominator of `a` and `b`.
|
Finds the greatest common denominator of `a` and `b`.
|
||||||
|
|||||||
-1
@@ -24,7 +24,6 @@
|
|||||||
"bower_components",
|
"bower_components",
|
||||||
"test",
|
"test",
|
||||||
"coverage",
|
"coverage",
|
||||||
"spec",
|
|
||||||
"tests"
|
"tests"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-15
@@ -10,23 +10,23 @@
|
|||||||
"spec": ">=1.6.7 <2.0.0",
|
"spec": ">=1.6.7 <2.0.0",
|
||||||
"type": "range"
|
"type": "range"
|
||||||
},
|
},
|
||||||
"/Users/steveng/repo/cordova/cordova-android/node_modules/bplist-parser"
|
"/Users/jbowser/cordova/cordova-android/node_modules/bplist-parser"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"_from": "big-integer@>=1.6.7 <2.0.0",
|
"_from": "big-integer@>=1.6.7 <2.0.0",
|
||||||
"_id": "big-integer@1.6.17",
|
"_id": "big-integer@1.6.25",
|
||||||
"_inCache": true,
|
"_inCache": true,
|
||||||
"_location": "/big-integer",
|
"_location": "/big-integer",
|
||||||
"_nodeVersion": "4.4.5",
|
"_nodeVersion": "6.10.3",
|
||||||
"_npmOperationalInternal": {
|
"_npmOperationalInternal": {
|
||||||
"host": "packages-12-west.internal.npmjs.com",
|
"host": "s3://npm-registry-packages",
|
||||||
"tmp": "tmp/big-integer-1.6.17.tgz_1478721202721_0.8068355675786734"
|
"tmp": "tmp/big-integer-1.6.25.tgz_1504748727289_0.9231066561769694"
|
||||||
},
|
},
|
||||||
"_npmUser": {
|
"_npmUser": {
|
||||||
"name": "peterolson",
|
"name": "peterolson",
|
||||||
"email": "peter.e.c.olson+npm@gmail.com"
|
"email": "peter.e.c.olson+npm@gmail.com"
|
||||||
},
|
},
|
||||||
"_npmVersion": "2.15.5",
|
"_npmVersion": "3.10.10",
|
||||||
"_phantomChildren": {},
|
"_phantomChildren": {},
|
||||||
"_requested": {
|
"_requested": {
|
||||||
"raw": "big-integer@^1.6.7",
|
"raw": "big-integer@^1.6.7",
|
||||||
@@ -40,11 +40,11 @@
|
|||||||
"_requiredBy": [
|
"_requiredBy": [
|
||||||
"/bplist-parser"
|
"/bplist-parser"
|
||||||
],
|
],
|
||||||
"_resolved": "http://registry.npmjs.org/big-integer/-/big-integer-1.6.17.tgz",
|
"_resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.25.tgz",
|
||||||
"_shasum": "f0dcf5109a949e42a993ee3e8fb2070452817b51",
|
"_shasum": "1de45a9f57542ac20121c682f8d642220a34e823",
|
||||||
"_shrinkwrap": null,
|
"_shrinkwrap": null,
|
||||||
"_spec": "big-integer@^1.6.7",
|
"_spec": "big-integer@^1.6.7",
|
||||||
"_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/bplist-parser",
|
"_where": "/Users/jbowser/cordova/cordova-android/node_modules/bplist-parser",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Peter Olson",
|
"name": "Peter Olson",
|
||||||
"email": "peter.e.c.olson+npm@gmail.com"
|
"email": "peter.e.c.olson+npm@gmail.com"
|
||||||
@@ -57,23 +57,28 @@
|
|||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"description": "An arbitrary length integer library for Javascript",
|
"description": "An arbitrary length integer library for Javascript",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/lodash": "^4.14.64",
|
||||||
|
"@types/node": "^7.0.22",
|
||||||
"coveralls": "^2.11.4",
|
"coveralls": "^2.11.4",
|
||||||
"jasmine": "2.1.x",
|
"jasmine": "2.1.x",
|
||||||
"jasmine-core": "^2.3.4",
|
"jasmine-core": "^2.3.4",
|
||||||
"karma": "^0.13.3",
|
"karma": "^0.13.3",
|
||||||
"karma-coverage": "^0.4.2",
|
"karma-coverage": "^0.4.2",
|
||||||
"karma-jasmine": "^0.3.6",
|
"karma-jasmine": "^0.3.6",
|
||||||
"karma-phantomjs-launcher": "~0.1"
|
"karma-phantomjs-launcher": "^1.0.4",
|
||||||
|
"lodash": "^4.17.4",
|
||||||
|
"typescript": "^2.3.3",
|
||||||
|
"uglifyjs": "^2.4.10"
|
||||||
},
|
},
|
||||||
"directories": {},
|
"directories": {},
|
||||||
"dist": {
|
"dist": {
|
||||||
"shasum": "f0dcf5109a949e42a993ee3e8fb2070452817b51",
|
"shasum": "1de45a9f57542ac20121c682f8d642220a34e823",
|
||||||
"tarball": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.17.tgz"
|
"tarball": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.25.tgz"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.6"
|
"node": ">=0.6"
|
||||||
},
|
},
|
||||||
"gitHead": "d25d0bfcd96f31001ec8572c8d01de4770d99e63",
|
"gitHead": "a0c10d68aae8f5df56a67b3e3eb353b428abf170",
|
||||||
"homepage": "https://github.com/peterolson/BigInteger.js#readme",
|
"homepage": "https://github.com/peterolson/BigInteger.js#readme",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"math",
|
"math",
|
||||||
@@ -102,7 +107,9 @@
|
|||||||
"url": "git+ssh://git@github.com/peterolson/BigInteger.js.git"
|
"url": "git+ssh://git@github.com/peterolson/BigInteger.js.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "karma start my.conf.js"
|
"minify": "uglifyjs BigInteger.js -o BigInteger.min.js",
|
||||||
|
"test": "tsc && node_modules/.bin/karma start my.conf.js && node spec/tsDefinitions.js"
|
||||||
},
|
},
|
||||||
"version": "1.6.17"
|
"typings": "./BigInteger.d.ts",
|
||||||
|
"version": "1.6.25"
|
||||||
}
|
}
|
||||||
|
|||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
|
"lib": [
|
||||||
|
"es6"
|
||||||
|
],
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"strictNullChecks": false,
|
||||||
|
"baseUrl": "./",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"allowJs": true,
|
||||||
|
"typeRoots": [
|
||||||
|
"./"
|
||||||
|
],
|
||||||
|
"types": [
|
||||||
|
"node"
|
||||||
|
],
|
||||||
|
"forceConsistentCasingInFileNames": true
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"BigInteger.d.ts",
|
||||||
|
"spec/tsDefinitions.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
+3
-3
@@ -10,7 +10,7 @@
|
|||||||
"spec": ">=0.1.0 <0.2.0",
|
"spec": ">=0.1.0 <0.2.0",
|
||||||
"type": "range"
|
"type": "range"
|
||||||
},
|
},
|
||||||
"/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common"
|
"/Users/jbowser/cordova/cordova-android/node_modules/cordova-common"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"_from": "bplist-parser@>=0.1.0 <0.2.0",
|
"_from": "bplist-parser@>=0.1.0 <0.2.0",
|
||||||
@@ -36,11 +36,11 @@
|
|||||||
"_requiredBy": [
|
"_requiredBy": [
|
||||||
"/cordova-common"
|
"/cordova-common"
|
||||||
],
|
],
|
||||||
"_resolved": "http://registry.npmjs.org/bplist-parser/-/bplist-parser-0.1.1.tgz",
|
"_resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.1.1.tgz",
|
||||||
"_shasum": "d60d5dcc20cba6dc7e1f299b35d3e1f95dafbae6",
|
"_shasum": "d60d5dcc20cba6dc7e1f299b35d3e1f95dafbae6",
|
||||||
"_shrinkwrap": null,
|
"_shrinkwrap": null,
|
||||||
"_spec": "bplist-parser@^0.1.0",
|
"_spec": "bplist-parser@^0.1.0",
|
||||||
"_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common",
|
"_where": "/Users/jbowser/cordova/cordova-android/node_modules/cordova-common",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Joe Ferner",
|
"name": "Joe Ferner",
|
||||||
"email": "joe.ferner@nearinfinity.com"
|
"email": "joe.ferner@nearinfinity.com"
|
||||||
|
|||||||
+1
@@ -5,6 +5,7 @@ as known from sh/bash, in JavaScript.
|
|||||||
|
|
||||||
[](http://travis-ci.org/juliangruber/brace-expansion)
|
[](http://travis-ci.org/juliangruber/brace-expansion)
|
||||||
[](https://www.npmjs.org/package/brace-expansion)
|
[](https://www.npmjs.org/package/brace-expansion)
|
||||||
|
[](https://greenkeeper.io/)
|
||||||
|
|
||||||
[](https://ci.testling.com/juliangruber/brace-expansion)
|
[](https://ci.testling.com/juliangruber/brace-expansion)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -106,7 +106,7 @@ function expand(str, isTop) {
|
|||||||
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
||||||
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
||||||
var isSequence = isNumericSequence || isAlphaSequence;
|
var isSequence = isNumericSequence || isAlphaSequence;
|
||||||
var isOptions = /^(.*,)+(.+)?$/.test(m.body);
|
var isOptions = m.body.indexOf(',') >= 0;
|
||||||
if (!isSequence && !isOptions) {
|
if (!isSequence && !isOptions) {
|
||||||
// {a},b}
|
// {a},b}
|
||||||
if (m.post.match(/,.*\}/)) {
|
if (m.post.match(/,.*\}/)) {
|
||||||
|
|||||||
+24
-22
@@ -2,49 +2,49 @@
|
|||||||
"_args": [
|
"_args": [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"raw": "brace-expansion@^1.0.0",
|
"raw": "brace-expansion@^1.1.7",
|
||||||
"scope": null,
|
"scope": null,
|
||||||
"escapedName": "brace-expansion",
|
"escapedName": "brace-expansion",
|
||||||
"name": "brace-expansion",
|
"name": "brace-expansion",
|
||||||
"rawSpec": "^1.0.0",
|
"rawSpec": "^1.1.7",
|
||||||
"spec": ">=1.0.0 <2.0.0",
|
"spec": ">=1.1.7 <2.0.0",
|
||||||
"type": "range"
|
"type": "range"
|
||||||
},
|
},
|
||||||
"/Users/steveng/repo/cordova/cordova-android/node_modules/minimatch"
|
"/Users/jbowser/cordova/cordova-android/node_modules/minimatch"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"_from": "brace-expansion@>=1.0.0 <2.0.0",
|
"_from": "brace-expansion@>=1.1.7 <2.0.0",
|
||||||
"_id": "brace-expansion@1.1.6",
|
"_id": "brace-expansion@1.1.8",
|
||||||
"_inCache": true,
|
"_inCache": true,
|
||||||
"_location": "/brace-expansion",
|
"_location": "/brace-expansion",
|
||||||
"_nodeVersion": "4.4.7",
|
"_nodeVersion": "7.8.0",
|
||||||
"_npmOperationalInternal": {
|
"_npmOperationalInternal": {
|
||||||
"host": "packages-16-east.internal.npmjs.com",
|
"host": "s3://npm-registry-packages",
|
||||||
"tmp": "tmp/brace-expansion-1.1.6.tgz_1469047715600_0.9362958471756428"
|
"tmp": "tmp/brace-expansion-1.1.8.tgz_1497251980593_0.6575565172825009"
|
||||||
},
|
},
|
||||||
"_npmUser": {
|
"_npmUser": {
|
||||||
"name": "juliangruber",
|
"name": "juliangruber",
|
||||||
"email": "julian@juliangruber.com"
|
"email": "julian@juliangruber.com"
|
||||||
},
|
},
|
||||||
"_npmVersion": "2.15.8",
|
"_npmVersion": "4.2.0",
|
||||||
"_phantomChildren": {},
|
"_phantomChildren": {},
|
||||||
"_requested": {
|
"_requested": {
|
||||||
"raw": "brace-expansion@^1.0.0",
|
"raw": "brace-expansion@^1.1.7",
|
||||||
"scope": null,
|
"scope": null,
|
||||||
"escapedName": "brace-expansion",
|
"escapedName": "brace-expansion",
|
||||||
"name": "brace-expansion",
|
"name": "brace-expansion",
|
||||||
"rawSpec": "^1.0.0",
|
"rawSpec": "^1.1.7",
|
||||||
"spec": ">=1.0.0 <2.0.0",
|
"spec": ">=1.1.7 <2.0.0",
|
||||||
"type": "range"
|
"type": "range"
|
||||||
},
|
},
|
||||||
"_requiredBy": [
|
"_requiredBy": [
|
||||||
"/minimatch"
|
"/minimatch"
|
||||||
],
|
],
|
||||||
"_resolved": "http://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz",
|
"_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
|
||||||
"_shasum": "7197d7eaa9b87e648390ea61fc66c84427420df9",
|
"_shasum": "c07b211c7c952ec1f8efd51a77ef0d1d3990a292",
|
||||||
"_shrinkwrap": null,
|
"_shrinkwrap": null,
|
||||||
"_spec": "brace-expansion@^1.0.0",
|
"_spec": "brace-expansion@^1.1.7",
|
||||||
"_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/minimatch",
|
"_where": "/Users/jbowser/cordova/cordova-android/node_modules/minimatch",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Julian Gruber",
|
"name": "Julian Gruber",
|
||||||
"email": "mail@juliangruber.com",
|
"email": "mail@juliangruber.com",
|
||||||
@@ -54,19 +54,20 @@
|
|||||||
"url": "https://github.com/juliangruber/brace-expansion/issues"
|
"url": "https://github.com/juliangruber/brace-expansion/issues"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^0.4.1",
|
"balanced-match": "^1.0.0",
|
||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
},
|
},
|
||||||
"description": "Brace expansion as known from sh/bash",
|
"description": "Brace expansion as known from sh/bash",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"matcha": "^0.7.0",
|
||||||
"tape": "^4.6.0"
|
"tape": "^4.6.0"
|
||||||
},
|
},
|
||||||
"directories": {},
|
"directories": {},
|
||||||
"dist": {
|
"dist": {
|
||||||
"shasum": "7197d7eaa9b87e648390ea61fc66c84427420df9",
|
"shasum": "c07b211c7c952ec1f8efd51a77ef0d1d3990a292",
|
||||||
"tarball": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz"
|
"tarball": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz"
|
||||||
},
|
},
|
||||||
"gitHead": "791262fa06625e9c5594cde529a21d82086af5f2",
|
"gitHead": "8f59e68bd5c915a0d624e8e39354e1ccf672edf6",
|
||||||
"homepage": "https://github.com/juliangruber/brace-expansion",
|
"homepage": "https://github.com/juliangruber/brace-expansion",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -89,6 +90,7 @@
|
|||||||
"url": "git://github.com/juliangruber/brace-expansion.git"
|
"url": "git://github.com/juliangruber/brace-expansion.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"bench": "matcha test/perf/bench.js",
|
||||||
"gentest": "bash test/generate.sh",
|
"gentest": "bash test/generate.sh",
|
||||||
"test": "tape test/*.js"
|
"test": "tape test/*.js"
|
||||||
},
|
},
|
||||||
@@ -108,5 +110,5 @@
|
|||||||
"android-browser/4.2..latest"
|
"android-browser/4.2..latest"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"version": "1.1.6"
|
"version": "1.1.8"
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -10,7 +10,7 @@
|
|||||||
"spec": "0.0.1",
|
"spec": "0.0.1",
|
||||||
"type": "version"
|
"type": "version"
|
||||||
},
|
},
|
||||||
"/Users/steveng/repo/cordova/cordova-android/node_modules/brace-expansion"
|
"/Users/jbowser/cordova/cordova-android/node_modules/brace-expansion"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"_from": "concat-map@0.0.1",
|
"_from": "concat-map@0.0.1",
|
||||||
@@ -35,11 +35,11 @@
|
|||||||
"_requiredBy": [
|
"_requiredBy": [
|
||||||
"/brace-expansion"
|
"/brace-expansion"
|
||||||
],
|
],
|
||||||
"_resolved": "http://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
"_resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||||
"_shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b",
|
"_shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b",
|
||||||
"_shrinkwrap": null,
|
"_shrinkwrap": null,
|
||||||
"_spec": "concat-map@0.0.1",
|
"_spec": "concat-map@0.0.1",
|
||||||
"_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/brace-expansion",
|
"_where": "/Users/jbowser/cordova/cordova-android/node_modules/brace-expansion",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "James Halliday",
|
"name": "James Halliday",
|
||||||
"email": "mail@substack.net",
|
"email": "mail@substack.net",
|
||||||
|
|||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
spec/fixtures/*
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
root: true
|
||||||
|
extends: semistandard
|
||||||
|
rules:
|
||||||
|
indent:
|
||||||
|
- error
|
||||||
|
- 4
|
||||||
|
camelcase: off
|
||||||
|
padded-blocks: off
|
||||||
|
operator-linebreak: off
|
||||||
|
no-throw-literal: off
|
||||||
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
spec/fixtures/*
|
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
fixtures
|
fixtures
|
||||||
coverage
|
coverage
|
||||||
jasmine.json
|
jasmine.json
|
||||||
|
appveyor.yml
|
||||||
|
|||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
language: node_js
|
||||||
|
sudo: false
|
||||||
|
git:
|
||||||
|
depth: 10
|
||||||
|
node_js:
|
||||||
|
- "4"
|
||||||
|
- "6"
|
||||||
|
install:
|
||||||
|
- npm install
|
||||||
|
- npm install -g codecov
|
||||||
|
script:
|
||||||
|
- npm test
|
||||||
|
- npm run cover
|
||||||
|
after_script:
|
||||||
|
- codecov
|
||||||
+4
@@ -19,6 +19,10 @@
|
|||||||
#
|
#
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
[](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-common/branch/master)
|
||||||
|
[](https://travis-ci.org/apache/cordova-common)
|
||||||
|
[](https://nodei.co/npm/cordova-common/)
|
||||||
|
|
||||||
# cordova-common
|
# cordova-common
|
||||||
Expoeses shared functionality used by [cordova-lib](https://github.com/apache/cordova-lib/) and Cordova platforms.
|
Expoeses shared functionality used by [cordova-lib](https://github.com/apache/cordova-lib/) and Cordova platforms.
|
||||||
## Exposed APIs
|
## Exposed APIs
|
||||||
|
|||||||
+22
@@ -20,6 +20,28 @@
|
|||||||
-->
|
-->
|
||||||
# Cordova-common Release Notes
|
# Cordova-common Release Notes
|
||||||
|
|
||||||
|
### 2.1.0 (August 30, 2017)
|
||||||
|
* [CB-13145](https://issues.apache.org/jira/browse/CB-13145) added variable replacing to `framework` tag
|
||||||
|
* [CB-13211](https://issues.apache.org/jira/browse/CB-13211) Add `allows-arbitrary-loads-for-media` attribute parsing for `getAccesses`
|
||||||
|
* [CB-11968](https://issues.apache.org/jira/browse/CB-11968) Added support for `<config-file>` in `config.xml`
|
||||||
|
* [CB-12895](https://issues.apache.org/jira/browse/CB-12895) set up `eslint` and removed `jshint`
|
||||||
|
* [CB-12785](https://issues.apache.org/jira/browse/CB-12785) added `.gitignore`, `travis`, and `appveyor` support
|
||||||
|
* [CB-12250](https://issues.apache.org/jira/browse/CB-12250) & [CB-12409](https://issues.apache.org/jira/browse/CB-12409) *iOS*: Fix bug with escaping properties from `plist` file
|
||||||
|
* [CB-12762](https://issues.apache.org/jira/browse/CB-12762) updated `common`, `fetch`, and `serve` `pkgJson` to point `pkgJson` repo items to github mirrors
|
||||||
|
* [CB-12766](https://issues.apache.org/jira/browse/CB-12766) Consistently write `JSON` with 2 spaces indentation
|
||||||
|
|
||||||
|
### 2.0.3 (May 02, 2017)
|
||||||
|
* [CB-8978](https://issues.apache.org/jira/browse/CB-8978) Add option to get `resource-file` from `root`
|
||||||
|
* [CB-11908](https://issues.apache.org/jira/browse/CB-11908) Add tests for `edit-config` in `config.xml`
|
||||||
|
* [CB-12665](https://issues.apache.org/jira/browse/CB-12665) removed `enginestrict` since it is deprecated
|
||||||
|
|
||||||
|
### 2.0.2 (Apr 14, 2017)
|
||||||
|
* [CB-11233](https://issues.apache.org/jira/browse/CB-11233) - Support installing frameworks into 'Embedded Binaries' section of the Xcode project
|
||||||
|
* [CB-10438](https://issues.apache.org/jira/browse/CB-10438) - Install correct dependency version. Removed shell.remove, added pkg.json to dependency tests 1-3, and updated install.js (.replace) to fix tests in uninstall.spec.js and update to workw with jasmine 2.0
|
||||||
|
* [CB-11120](https://issues.apache.org/jira/browse/CB-11120) - Allow short/display name in config.xml
|
||||||
|
* [CB-11346](https://issues.apache.org/jira/browse/CB-11346) - Remove known platforms check
|
||||||
|
* [CB-11977](https://issues.apache.org/jira/browse/CB-11977) - updated engines and enginescript for common, fetch, and serve
|
||||||
|
|
||||||
### 2.0.1 (Mar 09, 2017)
|
### 2.0.1 (Mar 09, 2017)
|
||||||
* [CB-12557](https://issues.apache.org/jira/browse/CB-12557) add both stdout and stderr properties to the error object passed to superspawn reject handler.
|
* [CB-12557](https://issues.apache.org/jira/browse/CB-12557) add both stdout and stderr properties to the error object passed to superspawn reject handler.
|
||||||
|
|
||||||
|
|||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
# appveyor file
|
||||||
|
# http://www.appveyor.com/docs/appveyor-yml
|
||||||
|
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- nodejs_version: "4"
|
||||||
|
- nodejs_version: "6"
|
||||||
|
|
||||||
|
install:
|
||||||
|
- ps: Install-Product node $env:nodejs_version
|
||||||
|
- npm install
|
||||||
|
|
||||||
|
build: off
|
||||||
|
|
||||||
|
test_script:
|
||||||
|
- node --version
|
||||||
|
- npm --version
|
||||||
|
- npm test
|
||||||
+54
-39
@@ -2,49 +2,49 @@
|
|||||||
"_args": [
|
"_args": [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"raw": "cordova-common@^2.0.1",
|
"raw": "cordova-common@^2.1.0",
|
||||||
"scope": null,
|
"scope": null,
|
||||||
"escapedName": "cordova-common",
|
"escapedName": "cordova-common",
|
||||||
"name": "cordova-common",
|
"name": "cordova-common",
|
||||||
"rawSpec": "^2.0.1",
|
"rawSpec": "^2.1.0",
|
||||||
"spec": ">=2.0.1 <3.0.0",
|
"spec": ">=2.1.0 <3.0.0",
|
||||||
"type": "range"
|
"type": "range"
|
||||||
},
|
},
|
||||||
"/Users/steveng/repo/cordova/cordova-android"
|
"/Users/jbowser/cordova/cordova-android"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"_from": "cordova-common@>=2.0.1 <3.0.0",
|
"_from": "cordova-common@>=2.1.0 <3.0.0",
|
||||||
"_id": "cordova-common@2.0.1",
|
"_id": "cordova-common@2.1.0",
|
||||||
"_inCache": true,
|
"_inCache": true,
|
||||||
"_location": "/cordova-common",
|
"_location": "/cordova-common",
|
||||||
"_nodeVersion": "6.9.4",
|
"_nodeVersion": "6.6.0",
|
||||||
"_npmOperationalInternal": {
|
"_npmOperationalInternal": {
|
||||||
"host": "packages-18-east.internal.npmjs.com",
|
"host": "s3://npm-registry-packages",
|
||||||
"tmp": "tmp/cordova-common-2.0.1.tgz_1489432932737_0.5238456283695996"
|
"tmp": "tmp/cordova-common-2.1.0.tgz_1504306462859_0.04064799007028341"
|
||||||
},
|
},
|
||||||
"_npmUser": {
|
"_npmUser": {
|
||||||
"name": "filmaj",
|
"name": "audreyso",
|
||||||
"email": "maj.fil@gmail.com"
|
"email": "audreyeso@gmail.com"
|
||||||
},
|
},
|
||||||
"_npmVersion": "3.10.10",
|
"_npmVersion": "4.6.1",
|
||||||
"_phantomChildren": {},
|
"_phantomChildren": {},
|
||||||
"_requested": {
|
"_requested": {
|
||||||
"raw": "cordova-common@^2.0.1",
|
"raw": "cordova-common@^2.1.0",
|
||||||
"scope": null,
|
"scope": null,
|
||||||
"escapedName": "cordova-common",
|
"escapedName": "cordova-common",
|
||||||
"name": "cordova-common",
|
"name": "cordova-common",
|
||||||
"rawSpec": "^2.0.1",
|
"rawSpec": "^2.1.0",
|
||||||
"spec": ">=2.0.1 <3.0.0",
|
"spec": ">=2.1.0 <3.0.0",
|
||||||
"type": "range"
|
"type": "range"
|
||||||
},
|
},
|
||||||
"_requiredBy": [
|
"_requiredBy": [
|
||||||
"/"
|
"/"
|
||||||
],
|
],
|
||||||
"_resolved": "http://registry.npmjs.org/cordova-common/-/cordova-common-2.0.1.tgz",
|
"_resolved": "https://registry.npmjs.org/cordova-common/-/cordova-common-2.1.0.tgz",
|
||||||
"_shasum": "99af318d7cb8988047cfe37bb9f25ea881d52815",
|
"_shasum": "bb357ee1b9825031ed9db3c56b592efe973d1640",
|
||||||
"_shrinkwrap": null,
|
"_shrinkwrap": null,
|
||||||
"_spec": "cordova-common@^2.0.1",
|
"_spec": "cordova-common@^2.1.0",
|
||||||
"_where": "/Users/steveng/repo/cordova/cordova-android",
|
"_where": "/Users/jbowser/cordova/cordova-android",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Apache Software Foundation"
|
"name": "Apache Software Foundation"
|
||||||
},
|
},
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
"ansi": "^0.3.1",
|
"ansi": "^0.3.1",
|
||||||
"bplist-parser": "^0.1.0",
|
"bplist-parser": "^0.1.0",
|
||||||
"cordova-registry-mapper": "^1.1.8",
|
"cordova-registry-mapper": "^1.1.8",
|
||||||
"elementtree": "^0.1.6",
|
"elementtree": "0.1.6",
|
||||||
"glob": "^5.0.13",
|
"glob": "^5.0.13",
|
||||||
"minimatch": "^3.0.0",
|
"minimatch": "^3.0.0",
|
||||||
"osenv": "^0.1.3",
|
"osenv": "^0.1.3",
|
||||||
@@ -70,50 +70,65 @@
|
|||||||
},
|
},
|
||||||
"description": "Apache Cordova tools and platforms shared routines",
|
"description": "Apache Cordova tools and platforms shared routines",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"eslint": "^4.0.0",
|
||||||
|
"eslint-config-semistandard": "^11.0.0",
|
||||||
|
"eslint-config-standard": "^10.2.1",
|
||||||
|
"eslint-plugin-import": "^2.3.0",
|
||||||
|
"eslint-plugin-node": "^5.0.0",
|
||||||
|
"eslint-plugin-promise": "^3.5.0",
|
||||||
|
"eslint-plugin-standard": "^3.0.1",
|
||||||
"istanbul": "^0.4.5",
|
"istanbul": "^0.4.5",
|
||||||
"jasmine": "^2.5.2",
|
"jasmine": "^2.5.2",
|
||||||
"jshint": "^2.8.0",
|
|
||||||
"promise-matchers": "^0.9.6",
|
"promise-matchers": "^0.9.6",
|
||||||
"rewire": "^2.5.1"
|
"rewire": "^2.5.1"
|
||||||
},
|
},
|
||||||
"directories": {},
|
"directories": {},
|
||||||
"dist": {
|
"dist": {
|
||||||
"shasum": "99af318d7cb8988047cfe37bb9f25ea881d52815",
|
"shasum": "bb357ee1b9825031ed9db3c56b592efe973d1640",
|
||||||
"tarball": "https://registry.npmjs.org/cordova-common/-/cordova-common-2.0.1.tgz"
|
"tarball": "https://registry.npmjs.org/cordova-common/-/cordova-common-2.1.0.tgz"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.9.9"
|
"node": ">=4.0.0"
|
||||||
},
|
},
|
||||||
|
"homepage": "https://github.com/apache/cordova-lib#readme",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"main": "cordova-common.js",
|
"main": "cordova-common.js",
|
||||||
"maintainers": [
|
"maintainers": [
|
||||||
{
|
{
|
||||||
"name": "bowserj",
|
"name": "audreyso",
|
||||||
"email": "bowserj@apache.org"
|
"email": "audreyeso@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "apachebuilds",
|
||||||
|
"email": "root@apache.org"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "filmaj",
|
"name": "filmaj",
|
||||||
"email": "maj.fil@gmail.com"
|
"email": "maj.fil@gmail.com"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "kotikov.vladimir",
|
"name": "timbarham",
|
||||||
"email": "kotikov.vladimir@gmail.com"
|
"email": "npmjs@barhams.info"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "purplecabbage",
|
|
||||||
"email": "purplecabbage@gmail.com"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "shazron",
|
"name": "shazron",
|
||||||
"email": "shazron@gmail.com"
|
"email": "shazron@gmail.com"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "bowserj",
|
||||||
|
"email": "bowserj@apache.org"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "purplecabbage",
|
||||||
|
"email": "purplecabbage@gmail.com"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "stevegill",
|
"name": "stevegill",
|
||||||
"email": "stevengill97@gmail.com"
|
"email": "stevengill97@gmail.com"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "timbarham",
|
"name": "kotikov.vladimir",
|
||||||
"email": "npmjs@barhams.info"
|
"email": "kotikov.vladimir@gmail.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "cordova-common",
|
"name": "cordova-common",
|
||||||
@@ -121,13 +136,13 @@
|
|||||||
"readme": "ERROR: No README data found!",
|
"readme": "ERROR: No README data found!",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://git-wip-us.apache.org/repos/asf/cordova-common.git"
|
"url": "git+https://github.com/apache/cordova-lib.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"cover": "istanbul cover --root src --print detail jasmine",
|
"cover": "istanbul cover --root src --print detail jasmine",
|
||||||
"jasmine": "jasmine --captureExceptions --color",
|
"eslint": "eslint src && eslint spec",
|
||||||
"jshint": "jshint src && jshint spec",
|
"jasmine": "jasmine JASMINE_CONFIG_PATH=spec/support/jasmine.json",
|
||||||
"test": "npm run jshint && npm run jasmine"
|
"test": "npm run eslint && npm run jasmine"
|
||||||
},
|
},
|
||||||
"version": "2.0.1"
|
"version": "2.1.0"
|
||||||
}
|
}
|
||||||
|
|||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"node": true
|
|
||||||
, "bitwise": true
|
|
||||||
, "undef": true
|
|
||||||
, "trailing": true
|
|
||||||
, "quotmark": true
|
|
||||||
, "indent": 4
|
|
||||||
, "unused": "vars"
|
|
||||||
, "latedef": "nofunc"
|
|
||||||
}
|
|
||||||
+2
-2
@@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
/* jshint quotmark:false */
|
/* jshint quotmark:false */
|
||||||
|
|
||||||
var events = require('./events'),
|
var events = require('./events');
|
||||||
Q = require('q');
|
var Q = require('q');
|
||||||
|
|
||||||
function ActionStack () {
|
function ActionStack () {
|
||||||
this.stack = [];
|
this.stack = [];
|
||||||
|
|||||||
+39
-46
@@ -29,12 +29,10 @@
|
|||||||
* reference counts.
|
* reference counts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* jshint sub:true */
|
var path = require('path');
|
||||||
|
var et = require('elementtree');
|
||||||
var path = require('path'),
|
var ConfigKeeper = require('./ConfigKeeper');
|
||||||
et = require('elementtree'),
|
var CordovaLogger = require('../CordovaLogger');
|
||||||
ConfigKeeper = require('./ConfigKeeper'),
|
|
||||||
CordovaLogger = require('../CordovaLogger');
|
|
||||||
|
|
||||||
var mungeutil = require('./munge-util');
|
var mungeutil = require('./munge-util');
|
||||||
var xml_helpers = require('../util/xml-helpers');
|
var xml_helpers = require('../util/xml-helpers');
|
||||||
@@ -86,7 +84,6 @@ function PlatformMunger_apply_file_munge(file, munge, remove) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlatformMunger.prototype.remove_plugin_changes = remove_plugin_changes;
|
PlatformMunger.prototype.remove_plugin_changes = remove_plugin_changes;
|
||||||
function remove_plugin_changes (pluginInfo, is_top_level) {
|
function remove_plugin_changes (pluginInfo, is_top_level) {
|
||||||
var self = this;
|
var self = this;
|
||||||
@@ -114,7 +111,6 @@ function remove_plugin_changes(pluginInfo, is_top_level) {
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlatformMunger.prototype.add_plugin_changes = add_plugin_changes;
|
PlatformMunger.prototype.add_plugin_changes = add_plugin_changes;
|
||||||
function add_plugin_changes (pluginInfo, plugin_vars, is_top_level, should_increment, plugin_force) {
|
function add_plugin_changes (pluginInfo, plugin_vars, is_top_level, should_increment, plugin_force) {
|
||||||
var self = this;
|
var self = this;
|
||||||
@@ -130,8 +126,7 @@ function add_plugin_changes(pluginInfo, plugin_vars, is_top_level, should_increm
|
|||||||
if (!edit_config_changes || edit_config_changes.length === 0) {
|
if (!edit_config_changes || edit_config_changes.length === 0) {
|
||||||
// get config munge, aka how should this plugin change various config files
|
// get config munge, aka how should this plugin change various config files
|
||||||
config_munge = self.generate_plugin_config_munge(pluginInfo, plugin_vars);
|
config_munge = self.generate_plugin_config_munge(pluginInfo, plugin_vars);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
var isConflictingInfo = is_conflicting(edit_config_changes, platform_config.config_munge, self, plugin_force);
|
var isConflictingInfo = is_conflicting(edit_config_changes, platform_config.config_munge, self, plugin_force);
|
||||||
|
|
||||||
if (isConflictingInfo.conflictWithConfigxml) {
|
if (isConflictingInfo.conflictWithConfigxml) {
|
||||||
@@ -149,13 +144,11 @@ function add_plugin_changes(pluginInfo, plugin_vars, is_top_level, should_increm
|
|||||||
|
|
||||||
// force add new munges
|
// force add new munges
|
||||||
config_munge = self.generate_plugin_config_munge(pluginInfo, plugin_vars, edit_config_changes);
|
config_munge = self.generate_plugin_config_munge(pluginInfo, plugin_vars, edit_config_changes);
|
||||||
}
|
} else if (isConflictingInfo.conflictFound) {
|
||||||
else if(isConflictingInfo.conflictFound) {
|
|
||||||
throw new Error('There was a conflict trying to modify attributes with <edit-config> in plugin ' + pluginInfo.id +
|
throw new Error('There was a conflict trying to modify attributes with <edit-config> in plugin ' + pluginInfo.id +
|
||||||
'. The conflicting plugin, ' + isConflictingInfo.conflictingPlugin + ', already modified the same attributes. The conflict must be resolved before ' +
|
'. The conflicting plugin, ' + isConflictingInfo.conflictingPlugin + ', already modified the same attributes. The conflict must be resolved before ' +
|
||||||
pluginInfo.id + ' can be added. You may use --force to add the plugin and overwrite the conflicting attributes.');
|
pluginInfo.id + ' can be added. You may use --force to add the plugin and overwrite the conflicting attributes.');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// no conflicts, will handle edit-config
|
// no conflicts, will handle edit-config
|
||||||
config_munge = self.generate_plugin_config_munge(pluginInfo, plugin_vars, edit_config_changes);
|
config_munge = self.generate_plugin_config_munge(pluginInfo, plugin_vars, edit_config_changes);
|
||||||
}
|
}
|
||||||
@@ -168,7 +161,6 @@ function add_plugin_changes(pluginInfo, plugin_vars, is_top_level, should_increm
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Handle edit-config changes from config.xml
|
// Handle edit-config changes from config.xml
|
||||||
PlatformMunger.prototype.add_config_changes = add_config_changes;
|
PlatformMunger.prototype.add_config_changes = add_config_changes;
|
||||||
function add_config_changes (config, should_increment) {
|
function add_config_changes (config, should_increment) {
|
||||||
@@ -176,18 +168,24 @@ function add_config_changes(config, should_increment) {
|
|||||||
var platform_config = self.platformJson.root;
|
var platform_config = self.platformJson.root;
|
||||||
|
|
||||||
var config_munge;
|
var config_munge;
|
||||||
var edit_config_changes = null;
|
var changes = [];
|
||||||
|
|
||||||
if (config.getEditConfigs) {
|
if (config.getEditConfigs) {
|
||||||
edit_config_changes = config.getEditConfigs(self.platform);
|
var edit_config_changes = config.getEditConfigs(self.platform);
|
||||||
|
if (edit_config_changes) {
|
||||||
|
changes = changes.concat(edit_config_changes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!edit_config_changes || edit_config_changes.length === 0) {
|
if (config.getConfigFiles) {
|
||||||
// There are no edit-config changes to add, return here
|
var config_files_changes = config.getConfigFiles(self.platform);
|
||||||
return self;
|
if (config_files_changes) {
|
||||||
|
changes = changes.concat(config_files_changes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
var isConflictingInfo = is_conflicting(edit_config_changes, platform_config.config_munge, self, true /*always force overwrite other edit-config*/);
|
|
||||||
|
|
||||||
|
if (changes && changes.length > 0) {
|
||||||
|
var isConflictingInfo = is_conflicting(changes, platform_config.config_munge, self, true /* always force overwrite other edit-config */);
|
||||||
if (isConflictingInfo.conflictFound) {
|
if (isConflictingInfo.conflictFound) {
|
||||||
var conflict_munge;
|
var conflict_munge;
|
||||||
var conflict_file;
|
var conflict_file;
|
||||||
@@ -209,10 +207,10 @@ function add_config_changes(config, should_increment) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add config.xml edit-config munges
|
|
||||||
config_munge = self.generate_config_xml_munge(config, edit_config_changes, 'config.xml');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add config.xml edit-config and config-file munges
|
||||||
|
config_munge = self.generate_config_xml_munge(config, changes, 'config.xml');
|
||||||
self = munge_helper(should_increment, self, platform_config, config_munge);
|
self = munge_helper(should_increment, self, platform_config, config_munge);
|
||||||
|
|
||||||
// Move to installed/dependent_plugins
|
// Move to installed/dependent_plugins
|
||||||
@@ -241,7 +239,6 @@ function munge_helper(should_increment, self, platform_config, config_munge) {
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Load the global munge from platform json and apply all of it.
|
// Load the global munge from platform json and apply all of it.
|
||||||
// Used by cordova prepare to re-generate some config file from platform
|
// Used by cordova prepare to re-generate some config file from platform
|
||||||
// defaults and the global munge.
|
// defaults and the global munge.
|
||||||
@@ -261,37 +258,35 @@ function reapply_global_munge () {
|
|||||||
// generate_plugin_config_munge
|
// generate_plugin_config_munge
|
||||||
// Generate the munge object from config.xml
|
// Generate the munge object from config.xml
|
||||||
PlatformMunger.prototype.generate_config_xml_munge = generate_config_xml_munge;
|
PlatformMunger.prototype.generate_config_xml_munge = generate_config_xml_munge;
|
||||||
function generate_config_xml_munge(config, edit_config_changes, type) {
|
function generate_config_xml_munge (config, config_changes, type) {
|
||||||
|
|
||||||
var munge = { files: {} };
|
var munge = { files: {} };
|
||||||
var changes = edit_config_changes;
|
|
||||||
var id;
|
var id;
|
||||||
|
|
||||||
if(!changes) {
|
if (!config_changes) {
|
||||||
return munge;
|
return munge;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'config.xml') {
|
if (type === 'config.xml') {
|
||||||
id = type;
|
id = type;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
id = config.id;
|
id = config.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
changes.forEach(function(change) {
|
config_changes.forEach(function (change) {
|
||||||
change.xmls.forEach(function (xml) {
|
change.xmls.forEach(function (xml) {
|
||||||
// 1. stringify each xml
|
// 1. stringify each xml
|
||||||
var stringified = (new et.ElementTree(xml)).write({xml_declaration: false});
|
var stringified = (new et.ElementTree(xml)).write({xml_declaration: false});
|
||||||
// 2. add into munge
|
// 2. add into munge
|
||||||
if (change.mode) {
|
if (change.mode) {
|
||||||
mungeutil.deep_add(munge, change.file, change.target, { xml: stringified, count: 1, mode: change.mode, id: id });
|
mungeutil.deep_add(munge, change.file, change.target, { xml: stringified, count: 1, mode: change.mode, id: id });
|
||||||
|
} else {
|
||||||
|
mungeutil.deep_add(munge, change.target, change.parent, { xml: stringified, count: 1, after: change.after });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return munge;
|
return munge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// generate_plugin_config_munge
|
// generate_plugin_config_munge
|
||||||
// Generate the munge object from plugin.xml + vars
|
// Generate the munge object from plugin.xml + vars
|
||||||
PlatformMunger.prototype.generate_plugin_config_munge = generate_plugin_config_munge;
|
PlatformMunger.prototype.generate_plugin_config_munge = generate_plugin_config_munge;
|
||||||
@@ -322,8 +317,7 @@ function generate_plugin_config_munge(pluginInfo, vars, edit_config_changes) {
|
|||||||
if (change.mode !== 'remove') {
|
if (change.mode !== 'remove') {
|
||||||
mungeutil.deep_add(munge, change.file, change.target, { xml: stringified, count: 1, mode: change.mode, plugin: pluginInfo.id });
|
mungeutil.deep_add(munge, change.file, change.target, { xml: stringified, count: 1, mode: change.mode, plugin: pluginInfo.id });
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
mungeutil.deep_add(munge, change.target, change.parent, { xml: stringified, count: 1, after: change.after });
|
mungeutil.deep_add(munge, change.target, change.parent, { xml: stringified, count: 1, after: change.after });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -361,8 +355,7 @@ function is_conflicting(editchanges, config_munge, self, force) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
conflictingParent = editchange.target;
|
conflictingParent = editchange.target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,13 +367,11 @@ function is_conflicting(editchanges, config_munge, self, force) {
|
|||||||
if (target[0].id === 'config.xml') {
|
if (target[0].id === 'config.xml') {
|
||||||
// Keep track of config.xml/config.xml edit-config conflicts
|
// Keep track of config.xml/config.xml edit-config conflicts
|
||||||
mungeutil.deep_add(configxmlMunge, editchange.file, conflictingParent, target[0]);
|
mungeutil.deep_add(configxmlMunge, editchange.file, conflictingParent, target[0]);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Keep track of config.xml x plugin.xml edit-config conflicts
|
// Keep track of config.xml x plugin.xml edit-config conflicts
|
||||||
mungeutil.deep_add(conflictingMunge, editchange.file, conflictingParent, target[0]);
|
mungeutil.deep_add(conflictingMunge, editchange.file, conflictingParent, target[0]);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (target[0].id === 'config.xml') {
|
if (target[0].id === 'config.xml') {
|
||||||
// plugin.xml cannot overwrite config.xml changes even if --force is used
|
// plugin.xml cannot overwrite config.xml changes even if --force is used
|
||||||
conflictWithConfigxml = true;
|
conflictWithConfigxml = true;
|
||||||
@@ -390,19 +381,21 @@ function is_conflicting(editchanges, config_munge, self, force) {
|
|||||||
if (force) {
|
if (force) {
|
||||||
// Need to find all conflicts when --force is used, track conflicting munges
|
// Need to find all conflicts when --force is used, track conflicting munges
|
||||||
mungeutil.deep_add(conflictingMunge, editchange.file, conflictingParent, target[0]);
|
mungeutil.deep_add(conflictingMunge, editchange.file, conflictingParent, target[0]);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// plugin cannot overwrite other plugin changes without --force
|
// plugin cannot overwrite other plugin changes without --force
|
||||||
conflictingPlugin = target[0].plugin;
|
conflictingPlugin = target[0].plugin;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return {conflictFound: conflictFound, conflictingPlugin: conflictingPlugin, conflictingMunge: conflictingMunge,
|
return {conflictFound: conflictFound,
|
||||||
configxmlMunge: configxmlMunge, conflictWithConfigxml:conflictWithConfigxml};
|
conflictingPlugin: conflictingPlugin,
|
||||||
|
conflictingMunge: conflictingMunge,
|
||||||
|
configxmlMunge: configxmlMunge,
|
||||||
|
conflictWithConfigxml: conflictWithConfigxml};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go over the prepare queue and apply the config munges for each plugin
|
// Go over the prepare queue and apply the config munges for each plugin
|
||||||
|
|||||||
+9
-7
@@ -14,6 +14,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* eslint no-control-regex: 0 */
|
||||||
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
@@ -69,7 +71,7 @@ function ConfigFile_load() {
|
|||||||
var ext = path.extname(filepath);
|
var ext = path.extname(filepath);
|
||||||
// Windows8 uses an appxmanifest, and wp8 will likely use
|
// Windows8 uses an appxmanifest, and wp8 will likely use
|
||||||
// the same in a future release
|
// the same in a future release
|
||||||
if (ext == '.xml' || ext == '.appxmanifest') {
|
if (ext === '.xml' || ext === '.appxmanifest') {
|
||||||
self.type = 'xml';
|
self.type = 'xml';
|
||||||
self.data = modules.xml_helpers.parseElementtreeSync(filepath);
|
self.data = modules.xml_helpers.parseElementtreeSync(filepath);
|
||||||
} else {
|
} else {
|
||||||
@@ -111,7 +113,7 @@ ConfigFile.prototype.graft_child = function ConfigFile_graft_child(selector, xml
|
|||||||
result = modules.xml_helpers.graftXMLOverwrite(self.data, xml_to_graft, selector, xml_child);
|
result = modules.xml_helpers.graftXMLOverwrite(self.data, xml_to_graft, selector, xml_child);
|
||||||
break;
|
break;
|
||||||
case 'remove':
|
case 'remove':
|
||||||
result= true;
|
result = modules.xml_helpers.pruneXMLRemove(self.data, selector, xml_to_graft);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result = modules.xml_helpers.graftXML(self.data, xml_to_graft, selector, xml_child.after);
|
result = modules.xml_helpers.graftXML(self.data, xml_to_graft, selector, xml_child.after);
|
||||||
@@ -141,7 +143,7 @@ ConfigFile.prototype.prune_child = function ConfigFile_prune_child(selector, xml
|
|||||||
result = modules.xml_helpers.pruneXMLRestore(self.data, selector, xml_child);
|
result = modules.xml_helpers.pruneXMLRestore(self.data, selector, xml_child);
|
||||||
break;
|
break;
|
||||||
case 'remove':
|
case 'remove':
|
||||||
result = modules.xml_helpers.prunXMLRemove(self.data, selector, xml_to_graft);
|
result = modules.xml_helpers.pruneXMLRemove(self.data, selector, xml_to_graft);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result = modules.xml_helpers.pruneXML(self.data, xml_to_graft, selector);
|
result = modules.xml_helpers.pruneXML(self.data, xml_to_graft, selector);
|
||||||
@@ -184,13 +186,13 @@ function resolveConfigFilePath(project_dir, platform, file) {
|
|||||||
|
|
||||||
// special-case config.xml target that is just "config.xml". This should be resolved to the real location of the file.
|
// special-case config.xml target that is just "config.xml". This should be resolved to the real location of the file.
|
||||||
// TODO: move the logic that contains the locations of config.xml from cordova CLI into plugman.
|
// TODO: move the logic that contains the locations of config.xml from cordova CLI into plugman.
|
||||||
if (file == 'config.xml') {
|
if (file === 'config.xml') {
|
||||||
if (platform == 'ubuntu') {
|
if (platform === 'ubuntu') {
|
||||||
filepath = path.join(project_dir, 'config.xml');
|
filepath = path.join(project_dir, 'config.xml');
|
||||||
} else if (platform == 'ios') {
|
} else if (platform === 'ios') {
|
||||||
var iospath = getIOSProjectname(project_dir);
|
var iospath = getIOSProjectname(project_dir);
|
||||||
filepath = path.join(project_dir, iospath, 'config.xml');
|
filepath = path.join(project_dir, iospath, 'config.xml');
|
||||||
} else if (platform == 'android') {
|
} else if (platform === 'android') {
|
||||||
filepath = path.join(project_dir, 'res', 'xml', 'config.xml');
|
filepath = path.join(project_dir, 'res', 'xml', 'config.xml');
|
||||||
} else {
|
} else {
|
||||||
matches = modules.glob.sync(path.join(project_dir, '**', 'config.xml'));
|
matches = modules.glob.sync(path.join(project_dir, '**', 'config.xml'));
|
||||||
|
|||||||
+1
-2
@@ -39,7 +39,7 @@ ConfigKeeper.prototype.get = function ConfigKeeper_get(project_dir, platform, fi
|
|||||||
|
|
||||||
// This fixes a bug with older plugins - when specifying config xml instead of res/xml/config.xml
|
// This fixes a bug with older plugins - when specifying config xml instead of res/xml/config.xml
|
||||||
// https://issues.apache.org/jira/browse/CB-6414
|
// https://issues.apache.org/jira/browse/CB-6414
|
||||||
if(file == 'config.xml' && platform == 'android'){
|
if (file === 'config.xml' && platform === 'android') {
|
||||||
file = 'res/xml/config.xml';
|
file = 'res/xml/config.xml';
|
||||||
}
|
}
|
||||||
var fake_path = path.join(project_dir, platform, file);
|
var fake_path = path.join(project_dir, platform, file);
|
||||||
@@ -53,7 +53,6 @@ ConfigKeeper.prototype.get = function ConfigKeeper_get(project_dir, platform, fi
|
|||||||
return config_file;
|
return config_file;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ConfigKeeper.prototype.save_all = function ConfigKeeper_save_all () {
|
ConfigKeeper.prototype.save_all = function ConfigKeeper_save_all () {
|
||||||
var self = this;
|
var self = this;
|
||||||
Object.keys(self._cached).forEach(function (fake_path) {
|
Object.keys(self._cached).forEach(function (fake_path) {
|
||||||
|
|||||||
+7
-8
@@ -26,7 +26,7 @@ exports.deep_add = function deep_add(obj, keys /* or key1, key2 .... */ ) {
|
|||||||
|
|
||||||
return exports.process_munge(obj, true/* createParents */, function (parentArray, k) {
|
return exports.process_munge(obj, true/* createParents */, function (parentArray, k) {
|
||||||
var found = _.find(parentArray, function (element) {
|
var found = _.find(parentArray, function (element) {
|
||||||
return element.xml == k.xml;
|
return element.xml === k.xml;
|
||||||
});
|
});
|
||||||
if (found) {
|
if (found) {
|
||||||
found.after = found.after || k.after;
|
found.after = found.after || k.after;
|
||||||
@@ -49,7 +49,7 @@ exports.deep_remove = function deep_remove(obj, keys /* or key1, key2 .... */ )
|
|||||||
var index = -1;
|
var index = -1;
|
||||||
var found = _.find(parentArray, function (element) {
|
var found = _.find(parentArray, function (element) {
|
||||||
index++;
|
index++;
|
||||||
return element.xml == k.xml;
|
return element.xml === k.xml;
|
||||||
});
|
});
|
||||||
if (found) {
|
if (found) {
|
||||||
if (parentArray[index].oldAttrib) {
|
if (parentArray[index].oldAttrib) {
|
||||||
@@ -58,8 +58,7 @@ exports.deep_remove = function deep_remove(obj, keys /* or key1, key2 .... */ )
|
|||||||
found.count -= k.count;
|
found.count -= k.count;
|
||||||
if (found.count > 0) {
|
if (found.count > 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
parentArray.splice(index, 1);
|
parentArray.splice(index, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,7 +77,7 @@ exports.deep_find = function deep_find(obj, keys /* or key1, key2 .... */ ) {
|
|||||||
|
|
||||||
return exports.process_munge(obj, false/* createParents? */, function (parentArray, k) {
|
return exports.process_munge(obj, false/* createParents? */, function (parentArray, k) {
|
||||||
return _.find(parentArray, function (element) {
|
return _.find(parentArray, function (element) {
|
||||||
return element.xml == (k.xml || k);
|
return element.xml === (k.xml || k);
|
||||||
});
|
});
|
||||||
}, keys);
|
}, keys);
|
||||||
};
|
};
|
||||||
@@ -92,15 +91,15 @@ exports.process_munge = function process_munge(obj, createParents, func, keys /*
|
|||||||
keys = Array.prototype.slice.call(arguments, 1);
|
keys = Array.prototype.slice.call(arguments, 1);
|
||||||
}
|
}
|
||||||
var k = keys[0];
|
var k = keys[0];
|
||||||
if (keys.length == 1) {
|
if (keys.length === 1) {
|
||||||
return func(obj, k);
|
return func(obj, k);
|
||||||
} else if (keys.length == 2) {
|
} else if (keys.length === 2) {
|
||||||
if (!obj.parents[k] && !createParents) {
|
if (!obj.parents[k] && !createParents) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
obj.parents[k] = obj.parents[k] || [];
|
obj.parents[k] = obj.parents[k] || [];
|
||||||
return exports.process_munge(obj.parents[k], createParents, func, keys.slice(1));
|
return exports.process_munge(obj.parents[k], createParents, func, keys.slice(1));
|
||||||
} else if (keys.length == 3){
|
} else if (keys.length === 3) {
|
||||||
if (!obj.files[k] && !createParents) {
|
if (!obj.files[k] && !createParents) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
+66
-19
@@ -17,14 +17,11 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* jshint sub:true */
|
var et = require('elementtree');
|
||||||
|
var xml = require('../util/xml-helpers');
|
||||||
var et = require('elementtree'),
|
var CordovaError = require('../CordovaError/CordovaError');
|
||||||
xml= require('../util/xml-helpers'),
|
var fs = require('fs');
|
||||||
CordovaError = require('../CordovaError/CordovaError'),
|
var events = require('../events');
|
||||||
fs = require('fs'),
|
|
||||||
events = require('../events');
|
|
||||||
|
|
||||||
|
|
||||||
/** Wraps a config.xml file */
|
/** Wraps a config.xml file */
|
||||||
function ConfigParser (path) {
|
function ConfigParser (path) {
|
||||||
@@ -86,7 +83,7 @@ function findElementAttributeValue(attributeName, elems) {
|
|||||||
return filteredElems.attrib.value;
|
return filteredElems.attrib.value;
|
||||||
}).pop();
|
}).pop();
|
||||||
|
|
||||||
return value ? value : '';
|
return value || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigParser.prototype = {
|
ConfigParser.prototype = {
|
||||||
@@ -116,6 +113,16 @@ ConfigParser.prototype = {
|
|||||||
var el = findOrCreate(this.doc, 'name');
|
var el = findOrCreate(this.doc, 'name');
|
||||||
el.text = name;
|
el.text = name;
|
||||||
},
|
},
|
||||||
|
shortName: function () {
|
||||||
|
return this.doc.find('name').attrib['short'] || this.name();
|
||||||
|
},
|
||||||
|
setShortName: function (shortname) {
|
||||||
|
var el = findOrCreate(this.doc, 'name');
|
||||||
|
if (!el.text) {
|
||||||
|
el.text = shortname;
|
||||||
|
}
|
||||||
|
el.attrib['short'] = shortname;
|
||||||
|
},
|
||||||
description: function () {
|
description: function () {
|
||||||
return getNodeTextSafe(this.doc.find('description'));
|
return getNodeTextSafe(this.doc.find('description'));
|
||||||
},
|
},
|
||||||
@@ -164,7 +171,7 @@ ConfigParser.prototype = {
|
|||||||
platformPreference = this.getPlatformPreference(name, platform);
|
platformPreference = this.getPlatformPreference(name, platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
return platformPreference ? platformPreference : this.getGlobalPreference(name);
|
return platformPreference || this.getGlobalPreference(name);
|
||||||
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -175,8 +182,8 @@ ConfigParser.prototype = {
|
|||||||
* @return {Array} Resources for the platform specified.
|
* @return {Array} Resources for the platform specified.
|
||||||
*/
|
*/
|
||||||
getStaticResources: function (platform, resourceName) {
|
getStaticResources: function (platform, resourceName) {
|
||||||
var ret = [],
|
var ret = [];
|
||||||
staticResources = [];
|
var staticResources = [];
|
||||||
if (platform) { // platform specific icons
|
if (platform) { // platform specific icons
|
||||||
this.doc.findall('platform[@name=\'' + platform + '\']/' + resourceName).forEach(function (elt) {
|
this.doc.findall('platform[@name=\'' + platform + '\']/' + resourceName).forEach(function (elt) {
|
||||||
elt.platform = platform; // mark as platform specific resource
|
elt.platform = platform; // mark as platform specific resource
|
||||||
@@ -214,8 +221,8 @@ ConfigParser.prototype = {
|
|||||||
if (!res.width && !res.height) {
|
if (!res.width && !res.height) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return ((!res.width || (width == res.width)) &&
|
return ((!res.width || (width === res.width)) &&
|
||||||
(!res.height || (height == res.height)));
|
(!res.height || (height === res.height)));
|
||||||
})[0] || null;
|
})[0] || null;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -226,7 +233,7 @@ ConfigParser.prototype = {
|
|||||||
*/
|
*/
|
||||||
ret.getByDensity = function (density) {
|
ret.getByDensity = function (density) {
|
||||||
return ret.filter(function (res) {
|
return ret.filter(function (res) {
|
||||||
return res.density == density;
|
return res.density === density;
|
||||||
})[0] || null;
|
})[0] || null;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -259,9 +266,11 @@ ConfigParser.prototype = {
|
|||||||
/**
|
/**
|
||||||
* Returns all resource-files for a specific platform.
|
* Returns all resource-files for a specific platform.
|
||||||
* @param {string} platform Platform name
|
* @param {string} platform Platform name
|
||||||
|
* @param {boolean} includeGlobal Whether to return resource-files at the
|
||||||
|
* root level.
|
||||||
* @return {Resource[]} Array of resource file objects.
|
* @return {Resource[]} Array of resource file objects.
|
||||||
*/
|
*/
|
||||||
getFileResources: function(platform) {
|
getFileResources: function (platform, includeGlobal) {
|
||||||
var fileResources = [];
|
var fileResources = [];
|
||||||
|
|
||||||
if (platform) { // platform specific resources
|
if (platform) { // platform specific resources
|
||||||
@@ -277,6 +286,19 @@ ConfigParser.prototype = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (includeGlobal) {
|
||||||
|
this.doc.findall('resource-file').forEach(function (tag) {
|
||||||
|
fileResources.push({
|
||||||
|
platform: platform || null,
|
||||||
|
src: tag.attrib.src,
|
||||||
|
target: tag.attrib.target,
|
||||||
|
versions: tag.attrib.versions,
|
||||||
|
deviceTarget: tag.attrib['device-target'],
|
||||||
|
arch: tag.attrib.arch
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return fileResources;
|
return fileResources;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -373,7 +395,7 @@ ConfigParser.prototype = {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
var pluginElement = this.doc.find('./plugin/[@name="' + id + '"]');
|
var pluginElement = this.doc.find('./plugin/[@name="' + id + '"]');
|
||||||
if (null === pluginElement) {
|
if (pluginElement === null) {
|
||||||
var legacyFeature = this.doc.find('./feature/param[@name="id"][@value="' + id + '"]/..');
|
var legacyFeature = this.doc.find('./feature/param[@name="id"][@value="' + id + '"]/..');
|
||||||
if (legacyFeature) {
|
if (legacyFeature) {
|
||||||
events.emit('log', 'Found deprecated feature entry for ' + id + ' in config.xml.');
|
events.emit('log', 'Found deprecated feature entry for ' + id + ' in config.xml.');
|
||||||
@@ -462,7 +484,7 @@ ConfigParser.prototype = {
|
|||||||
var spec = engine.attrib.spec || engine.attrib.version;
|
var spec = engine.attrib.spec || engine.attrib.version;
|
||||||
return {
|
return {
|
||||||
'name': engine.attrib.name,
|
'name': engine.attrib.name,
|
||||||
'spec': spec ? spec : null
|
'spec': spec || null
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -474,7 +496,8 @@ ConfigParser.prototype = {
|
|||||||
var requires_forward_secrecy = access.attrib['requires-forward-secrecy']; /* Boolean */
|
var requires_forward_secrecy = access.attrib['requires-forward-secrecy']; /* Boolean */
|
||||||
var requires_certificate_transparency = access.attrib['requires-certificate-transparency']; /* Boolean */
|
var requires_certificate_transparency = access.attrib['requires-certificate-transparency']; /* Boolean */
|
||||||
var allows_arbitrary_loads_in_web_content = access.attrib['allows-arbitrary-loads-in-web-content']; /* Boolean */
|
var allows_arbitrary_loads_in_web_content = access.attrib['allows-arbitrary-loads-in-web-content']; /* Boolean */
|
||||||
var allows_arbitrary_loads_in_media = access.attrib['allows-arbitrary-loads-in-media']; /* Boolean */
|
var allows_arbitrary_loads_in_media = access.attrib['allows-arbitrary-loads-in-media']; /* Boolean (DEPRECATED) */
|
||||||
|
var allows_arbitrary_loads_for_media = access.attrib['allows-arbitrary-loads-for-media']; /* Boolean */
|
||||||
var allows_local_networking = access.attrib['allows-local-networking']; /* Boolean */
|
var allows_local_networking = access.attrib['allows-local-networking']; /* Boolean */
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -484,6 +507,7 @@ ConfigParser.prototype = {
|
|||||||
'requires_certificate_transparency': requires_certificate_transparency,
|
'requires_certificate_transparency': requires_certificate_transparency,
|
||||||
'allows_arbitrary_loads_in_web_content': allows_arbitrary_loads_in_web_content,
|
'allows_arbitrary_loads_in_web_content': allows_arbitrary_loads_in_web_content,
|
||||||
'allows_arbitrary_loads_in_media': allows_arbitrary_loads_in_media,
|
'allows_arbitrary_loads_in_media': allows_arbitrary_loads_in_media,
|
||||||
|
'allows_arbitrary_loads_for_media': allows_arbitrary_loads_for_media,
|
||||||
'allows_local_networking': allows_local_networking
|
'allows_local_networking': allows_local_networking
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -532,6 +556,29 @@ ConfigParser.prototype = {
|
|||||||
return editConfig;
|
return editConfig;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* Get all config-file tags */
|
||||||
|
getConfigFiles: function (platform) {
|
||||||
|
var platform_tag = this.doc.find('./platform[@name="' + platform + '"]');
|
||||||
|
var platform_config_files = platform_tag ? platform_tag.findall('config-file') : [];
|
||||||
|
|
||||||
|
var config_files = this.doc.findall('config-file').concat(platform_config_files);
|
||||||
|
|
||||||
|
return config_files.map(function (tag) {
|
||||||
|
var configFile =
|
||||||
|
{
|
||||||
|
target: tag.attrib['target'],
|
||||||
|
parent: tag.attrib['parent'],
|
||||||
|
after: tag.attrib['after'],
|
||||||
|
xmls: tag.getchildren(),
|
||||||
|
// To support demuxing via versions
|
||||||
|
versions: tag.attrib['versions'],
|
||||||
|
deviceTarget: tag.attrib['device-target']
|
||||||
|
};
|
||||||
|
return configFile;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
write: function () {
|
write: function () {
|
||||||
fs.writeFileSync(this.path, this.doc.write({indent: 4}), 'utf-8');
|
fs.writeFileSync(this.path, this.doc.write({indent: 4}), 'utf-8');
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -17,8 +17,8 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var fs = require('fs'),
|
var fs = require('fs');
|
||||||
path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
function isRootDir (dir) {
|
function isRootDir (dir) {
|
||||||
if (fs.existsSync(path.join(dir, 'www'))) {
|
if (fs.existsSync(path.join(dir, 'www'))) {
|
||||||
@@ -46,7 +46,7 @@ function isCordova(dir) {
|
|||||||
// Prefer PWD over cwd so that symlinked dirs within your PWD work correctly (CB-5687).
|
// Prefer PWD over cwd so that symlinked dirs within your PWD work correctly (CB-5687).
|
||||||
var pwd = process.env.PWD;
|
var pwd = process.env.PWD;
|
||||||
var cwd = process.cwd();
|
var cwd = process.cwd();
|
||||||
if (pwd && pwd != cwd && pwd != 'undefined') {
|
if (pwd && pwd !== cwd && pwd !== 'undefined') {
|
||||||
return isCordova(pwd) || isCordova(cwd);
|
return isCordova(pwd) || isCordova(cwd);
|
||||||
}
|
}
|
||||||
return isCordova(cwd);
|
return isCordova(cwd);
|
||||||
@@ -62,7 +62,7 @@ function isCordova(dir) {
|
|||||||
}
|
}
|
||||||
var parentDir = path.normalize(path.join(dir, '..'));
|
var parentDir = path.normalize(path.join(dir, '..'));
|
||||||
// Detect fs root.
|
// Detect fs root.
|
||||||
if (parentDir == dir) {
|
if (parentDir === dir) {
|
||||||
return bestReturnValueSoFar;
|
return bestReturnValueSoFar;
|
||||||
}
|
}
|
||||||
dir = parentDir;
|
dir = parentDir;
|
||||||
|
|||||||
+3
-2
@@ -17,7 +17,7 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* jshint proto:true */
|
/* eslint no-proto: 0 */
|
||||||
|
|
||||||
var EOL = require('os').EOL;
|
var EOL = require('os').EOL;
|
||||||
|
|
||||||
@@ -64,7 +64,8 @@ CordovaError.prototype.getErrorCodeName = function() {
|
|||||||
* @return {String} Stringified error representation
|
* @return {String} Stringified error representation
|
||||||
*/
|
*/
|
||||||
CordovaError.prototype.toString = function (isVerbose) {
|
CordovaError.prototype.toString = function (isVerbose) {
|
||||||
var message = '', codePrefix = '';
|
var message = '';
|
||||||
|
var codePrefix = '';
|
||||||
|
|
||||||
if (this.code !== CordovaError.UNKNOWN_ERROR) {
|
if (this.code !== CordovaError.UNKNOWN_ERROR) {
|
||||||
codePrefix = 'code: ' + this.code + (isVerbose ? (' (' + this.getErrorCodeName() + ')') : '') + ' ';
|
codePrefix = 'code: ' + this.code + (isVerbose ? (' (' + this.getErrorCodeName() + ')') : '') + ' ';
|
||||||
|
|||||||
+3
-3
@@ -82,9 +82,10 @@ CordovaLogger.RESULTS = 'results';
|
|||||||
CordovaLogger.prototype.log = function (logLevel, message) {
|
CordovaLogger.prototype.log = function (logLevel, message) {
|
||||||
// if there is no such logLevel defined, or provided level has
|
// if there is no such logLevel defined, or provided level has
|
||||||
// less severity than active level, then just ignore this call and return
|
// less severity than active level, then just ignore this call and return
|
||||||
if (!this.levels[logLevel] || this.levels[logLevel] < this.levels[this.logLevel])
|
if (!this.levels[logLevel] || this.levels[logLevel] < this.levels[this.logLevel]) {
|
||||||
// return instance to allow to chain calls
|
// return instance to allow to chain calls
|
||||||
return this;
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
var isVerbose = this.logLevel === 'verbose';
|
var isVerbose = this.logLevel === 'verbose';
|
||||||
var cursor = this.stdoutCursor;
|
var cursor = this.stdoutCursor;
|
||||||
@@ -179,8 +180,7 @@ CordovaLogger.prototype.adjustLevel = function (opts) {
|
|||||||
*/
|
*/
|
||||||
CordovaLogger.prototype.subscribe = function (eventEmitter) {
|
CordovaLogger.prototype.subscribe = function (eventEmitter) {
|
||||||
|
|
||||||
if (!(eventEmitter instanceof EventEmitter))
|
if (!(eventEmitter instanceof EventEmitter)) { throw new Error('Subscribe method only accepts an EventEmitter instance as argument'); }
|
||||||
throw new Error('Subscribe method only accepts an EventEmitter instance as argument');
|
|
||||||
|
|
||||||
eventEmitter.on('verbose', this.verbose)
|
eventEmitter.on('verbose', this.verbose)
|
||||||
.on('log', this.normal)
|
.on('log', this.normal)
|
||||||
|
|||||||
+46
-47
@@ -17,12 +17,12 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
"use strict";
|
'use strict';
|
||||||
|
|
||||||
var fs = require("fs");
|
var fs = require('fs');
|
||||||
var path = require("path");
|
var path = require('path');
|
||||||
var shell = require("shelljs");
|
var shell = require('shelljs');
|
||||||
var minimatch = require("minimatch");
|
var minimatch = require('minimatch');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logging callback used in the FileUpdater methods.
|
* Logging callback used in the FileUpdater methods.
|
||||||
@@ -58,24 +58,24 @@ var minimatch = require("minimatch");
|
|||||||
function updatePathWithStats (sourcePath, sourceStats, targetPath, targetStats, options, log) {
|
function updatePathWithStats (sourcePath, sourceStats, targetPath, targetStats, options, log) {
|
||||||
var updated = false;
|
var updated = false;
|
||||||
|
|
||||||
var rootDir = (options && options.rootDir) || "";
|
var rootDir = (options && options.rootDir) || '';
|
||||||
var copyAll = (options && options.all) || false;
|
var copyAll = (options && options.all) || false;
|
||||||
|
|
||||||
var targetFullPath = path.join(rootDir || "", targetPath);
|
var targetFullPath = path.join(rootDir || '', targetPath);
|
||||||
|
|
||||||
if (sourceStats) {
|
if (sourceStats) {
|
||||||
var sourceFullPath = path.join(rootDir || "", sourcePath);
|
var sourceFullPath = path.join(rootDir || '', sourcePath);
|
||||||
|
|
||||||
if (targetStats) {
|
if (targetStats) {
|
||||||
// The target exists. But if the directory status doesn't match the source, delete it.
|
// The target exists. But if the directory status doesn't match the source, delete it.
|
||||||
if (targetStats.isDirectory() && !sourceStats.isDirectory()) {
|
if (targetStats.isDirectory() && !sourceStats.isDirectory()) {
|
||||||
log("rmdir " + targetPath + " (source is a file)");
|
log('rmdir ' + targetPath + ' (source is a file)');
|
||||||
shell.rm("-rf", targetFullPath);
|
shell.rm('-rf', targetFullPath);
|
||||||
targetStats = null;
|
targetStats = null;
|
||||||
updated = true;
|
updated = true;
|
||||||
} else if (!targetStats.isDirectory() && sourceStats.isDirectory()) {
|
} else if (!targetStats.isDirectory() && sourceStats.isDirectory()) {
|
||||||
log("delete " + targetPath + " (source is a directory)");
|
log('delete ' + targetPath + ' (source is a directory)');
|
||||||
shell.rm("-f", targetFullPath);
|
shell.rm('-f', targetFullPath);
|
||||||
targetStats = null;
|
targetStats = null;
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
@@ -84,21 +84,21 @@ function updatePathWithStats(sourcePath, sourceStats, targetPath, targetStats, o
|
|||||||
if (!targetStats) {
|
if (!targetStats) {
|
||||||
if (sourceStats.isDirectory()) {
|
if (sourceStats.isDirectory()) {
|
||||||
// The target directory does not exist, so it should be created.
|
// The target directory does not exist, so it should be created.
|
||||||
log("mkdir " + targetPath);
|
log('mkdir ' + targetPath);
|
||||||
shell.mkdir("-p", targetFullPath);
|
shell.mkdir('-p', targetFullPath);
|
||||||
updated = true;
|
updated = true;
|
||||||
} else if (sourceStats.isFile()) {
|
} else if (sourceStats.isFile()) {
|
||||||
// The target file does not exist, so it should be copied from the source.
|
// The target file does not exist, so it should be copied from the source.
|
||||||
log("copy " + sourcePath + " " + targetPath + (copyAll ? "" : " (new file)"));
|
log('copy ' + sourcePath + ' ' + targetPath + (copyAll ? '' : ' (new file)'));
|
||||||
shell.cp("-f", sourceFullPath, targetFullPath);
|
shell.cp('-f', sourceFullPath, targetFullPath);
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
} else if (sourceStats.isFile() && targetStats.isFile()) {
|
} else if (sourceStats.isFile() && targetStats.isFile()) {
|
||||||
// The source and target paths both exist and are files.
|
// The source and target paths both exist and are files.
|
||||||
if (copyAll) {
|
if (copyAll) {
|
||||||
// The caller specified all files should be copied.
|
// The caller specified all files should be copied.
|
||||||
log("copy " + sourcePath + " " + targetPath);
|
log('copy ' + sourcePath + ' ' + targetPath);
|
||||||
shell.cp("-f", sourceFullPath, targetFullPath);
|
shell.cp('-f', sourceFullPath, targetFullPath);
|
||||||
updated = true;
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
// Copy if the source has been modified since it was copied to the target, or if
|
// Copy if the source has been modified since it was copied to the target, or if
|
||||||
@@ -107,8 +107,8 @@ function updatePathWithStats(sourcePath, sourceStats, targetPath, targetStats, o
|
|||||||
// for timestamps lacking sub-second precision in some filesystems.
|
// for timestamps lacking sub-second precision in some filesystems.
|
||||||
if (sourceStats.mtime.getTime() >= targetStats.mtime.getTime() ||
|
if (sourceStats.mtime.getTime() >= targetStats.mtime.getTime() ||
|
||||||
sourceStats.size !== targetStats.size) {
|
sourceStats.size !== targetStats.size) {
|
||||||
log("copy " + sourcePath + " " + targetPath + " (updated file)");
|
log('copy ' + sourcePath + ' ' + targetPath + ' (updated file)');
|
||||||
shell.cp("-f", sourceFullPath, targetFullPath);
|
shell.cp('-f', sourceFullPath, targetFullPath);
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,11 +116,11 @@ function updatePathWithStats(sourcePath, sourceStats, targetPath, targetStats, o
|
|||||||
} else if (targetStats) {
|
} else if (targetStats) {
|
||||||
// The target exists but the source is null, so the target should be deleted.
|
// The target exists but the source is null, so the target should be deleted.
|
||||||
if (targetStats.isDirectory()) {
|
if (targetStats.isDirectory()) {
|
||||||
log("rmdir " + targetPath + (copyAll ? "" : " (no source)"));
|
log('rmdir ' + targetPath + (copyAll ? '' : ' (no source)'));
|
||||||
shell.rm("-rf", targetFullPath);
|
shell.rm('-rf', targetFullPath);
|
||||||
} else {
|
} else {
|
||||||
log("delete " + targetPath + (copyAll ? "" : " (no source)"));
|
log('delete ' + targetPath + (copyAll ? '' : ' (no source)'));
|
||||||
shell.rm("-f", targetFullPath);
|
shell.rm('-f', targetFullPath);
|
||||||
}
|
}
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ function updatePathWithStats(sourcePath, sourceStats, targetPath, targetStats, o
|
|||||||
* and ensures target directory exists before copying a file.
|
* and ensures target directory exists before copying a file.
|
||||||
*/
|
*/
|
||||||
function updatePathInternal (sourcePath, targetPath, options, log) {
|
function updatePathInternal (sourcePath, targetPath, options, log) {
|
||||||
var rootDir = (options && options.rootDir) || "";
|
var rootDir = (options && options.rootDir) || '';
|
||||||
var targetFullPath = path.join(rootDir, targetPath);
|
var targetFullPath = path.join(rootDir, targetPath);
|
||||||
var targetStats = fs.existsSync(targetFullPath) ? fs.statSync(targetFullPath) : null;
|
var targetStats = fs.existsSync(targetFullPath) ? fs.statSync(targetFullPath) : null;
|
||||||
var sourceStats = null;
|
var sourceStats = null;
|
||||||
@@ -142,7 +142,7 @@ function updatePathInternal(sourcePath, targetPath, options, log) {
|
|||||||
// A non-null source path was specified. It should exist.
|
// A non-null source path was specified. It should exist.
|
||||||
var sourceFullPath = path.join(rootDir, sourcePath);
|
var sourceFullPath = path.join(rootDir, sourcePath);
|
||||||
if (!fs.existsSync(sourceFullPath)) {
|
if (!fs.existsSync(sourceFullPath)) {
|
||||||
throw new Error("Source path does not exist: " + sourcePath);
|
throw new Error('Source path does not exist: ' + sourcePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceStats = fs.statSync(sourceFullPath);
|
sourceStats = fs.statSync(sourceFullPath);
|
||||||
@@ -150,7 +150,7 @@ function updatePathInternal(sourcePath, targetPath, options, log) {
|
|||||||
// Create the target's parent directory if it doesn't exist.
|
// Create the target's parent directory if it doesn't exist.
|
||||||
var parentDir = path.dirname(targetFullPath);
|
var parentDir = path.dirname(targetFullPath);
|
||||||
if (!fs.existsSync(parentDir)) {
|
if (!fs.existsSync(parentDir)) {
|
||||||
shell.mkdir("-p", parentDir);
|
shell.mkdir('-p', parentDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,12 +178,12 @@ function updatePathInternal(sourcePath, targetPath, options, log) {
|
|||||||
* and everything was up to date
|
* and everything was up to date
|
||||||
*/
|
*/
|
||||||
function updatePath (sourcePath, targetPath, options, log) {
|
function updatePath (sourcePath, targetPath, options, log) {
|
||||||
if (sourcePath !== null && typeof sourcePath !== "string") {
|
if (sourcePath !== null && typeof sourcePath !== 'string') {
|
||||||
throw new Error("A source path (or null) is required.");
|
throw new Error('A source path (or null) is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!targetPath || typeof targetPath !== "string") {
|
if (!targetPath || typeof targetPath !== 'string') {
|
||||||
throw new Error("A target path is required.");
|
throw new Error('A target path is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
log = log || function (message) { };
|
log = log || function (message) { };
|
||||||
@@ -209,8 +209,8 @@ function updatePath(sourcePath, targetPath, options, log) {
|
|||||||
* and everything was up to date
|
* and everything was up to date
|
||||||
*/
|
*/
|
||||||
function updatePaths (pathMap, options, log) {
|
function updatePaths (pathMap, options, log) {
|
||||||
if (!pathMap || typeof pathMap !== "object" || Array.isArray(pathMap)) {
|
if (!pathMap || typeof pathMap !== 'object' || Array.isArray(pathMap)) {
|
||||||
throw new Error("An object mapping from target paths to source paths is required.");
|
throw new Error('An object mapping from target paths to source paths is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
log = log || function (message) { };
|
log = log || function (message) { };
|
||||||
@@ -256,32 +256,32 @@ function updatePaths(pathMap, options, log) {
|
|||||||
* and everything was up to date
|
* and everything was up to date
|
||||||
*/
|
*/
|
||||||
function mergeAndUpdateDir (sourceDirs, targetDir, options, log) {
|
function mergeAndUpdateDir (sourceDirs, targetDir, options, log) {
|
||||||
if (sourceDirs && typeof sourceDirs === "string") {
|
if (sourceDirs && typeof sourceDirs === 'string') {
|
||||||
sourceDirs = [ sourceDirs ];
|
sourceDirs = [ sourceDirs ];
|
||||||
} else if (!Array.isArray(sourceDirs)) {
|
} else if (!Array.isArray(sourceDirs)) {
|
||||||
throw new Error("A source directory path or array of paths is required.");
|
throw new Error('A source directory path or array of paths is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!targetDir || typeof targetDir !== "string") {
|
if (!targetDir || typeof targetDir !== 'string') {
|
||||||
throw new Error("A target directory path is required.");
|
throw new Error('A target directory path is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
log = log || function (message) { };
|
log = log || function (message) { };
|
||||||
|
|
||||||
var rootDir = (options && options.rootDir) || "";
|
var rootDir = (options && options.rootDir) || '';
|
||||||
|
|
||||||
var include = (options && options.include) || [ "**" ];
|
var include = (options && options.include) || [ '**' ];
|
||||||
if (typeof include === "string") {
|
if (typeof include === 'string') {
|
||||||
include = [ include ];
|
include = [ include ];
|
||||||
} else if (!Array.isArray(include)) {
|
} else if (!Array.isArray(include)) {
|
||||||
throw new Error("Include parameter must be a glob string or array of glob strings.");
|
throw new Error('Include parameter must be a glob string or array of glob strings.');
|
||||||
}
|
}
|
||||||
|
|
||||||
var exclude = (options && options.exclude) || [];
|
var exclude = (options && options.exclude) || [];
|
||||||
if (typeof exclude === "string") {
|
if (typeof exclude === 'string') {
|
||||||
exclude = [ exclude ];
|
exclude = [ exclude ];
|
||||||
} else if (!Array.isArray(exclude)) {
|
} else if (!Array.isArray(exclude)) {
|
||||||
throw new Error("Exclude parameter must be a glob string or array of glob strings.");
|
throw new Error('Exclude parameter must be a glob string or array of glob strings.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan the files in each of the source directories.
|
// Scan the files in each of the source directories.
|
||||||
@@ -289,7 +289,7 @@ function mergeAndUpdateDir(sourceDirs, targetDir, options, log) {
|
|||||||
return path.join(rootDir, sourceDir);
|
return path.join(rootDir, sourceDir);
|
||||||
}).map(function (sourcePath) {
|
}).map(function (sourcePath) {
|
||||||
if (!fs.existsSync(sourcePath)) {
|
if (!fs.existsSync(sourcePath)) {
|
||||||
throw new Error("Source directory does not exist: " + sourcePath);
|
throw new Error('Source directory does not exist: ' + sourcePath);
|
||||||
}
|
}
|
||||||
return mapDirectory(rootDir, path.relative(rootDir, sourcePath), include, exclude);
|
return mapDirectory(rootDir, path.relative(rootDir, sourcePath), include, exclude);
|
||||||
});
|
});
|
||||||
@@ -324,8 +324,8 @@ function mergeAndUpdateDir(sourceDirs, targetDir, options, log) {
|
|||||||
* Creates a dictionary map of all files and directories under a path.
|
* Creates a dictionary map of all files and directories under a path.
|
||||||
*/
|
*/
|
||||||
function mapDirectory (rootDir, subDir, include, exclude) {
|
function mapDirectory (rootDir, subDir, include, exclude) {
|
||||||
var dirMap = { "": { subDir: subDir, stats: fs.statSync(path.join(rootDir, subDir)) } };
|
var dirMap = { '': { subDir: subDir, stats: fs.statSync(path.join(rootDir, subDir)) } };
|
||||||
mapSubdirectory(rootDir, subDir, "", include, exclude, dirMap);
|
mapSubdirectory(rootDir, subDir, '', include, exclude, dirMap);
|
||||||
return dirMap;
|
return dirMap;
|
||||||
|
|
||||||
function mapSubdirectory (rootDir, subDir, relativeDir, include, exclude, dirMap) {
|
function mapSubdirectory (rootDir, subDir, relativeDir, include, exclude, dirMap) {
|
||||||
@@ -413,4 +413,3 @@ module.exports = {
|
|||||||
updatePaths: updatePaths,
|
updatePaths: updatePaths,
|
||||||
mergeAndUpdateDir: mergeAndUpdateDir
|
mergeAndUpdateDir: mergeAndUpdateDir
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+4
-5
@@ -13,7 +13,6 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/* jshint sub:true */
|
|
||||||
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
@@ -39,7 +38,7 @@ PlatformJson.load = function(plugins_dir, platform) {
|
|||||||
|
|
||||||
PlatformJson.prototype.save = function () {
|
PlatformJson.prototype.save = function () {
|
||||||
shelljs.mkdir('-p', path.dirname(this.filePath));
|
shelljs.mkdir('-p', path.dirname(this.filePath));
|
||||||
fs.writeFileSync(this.filePath, JSON.stringify(this.root, null, 4), 'utf-8');
|
fs.writeFileSync(this.filePath, JSON.stringify(this.root, null, 2), 'utf-8');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -195,10 +194,10 @@ PlatformJson.prototype.makeTopLevel = function(pluginId) {
|
|||||||
PlatformJson.prototype.generateMetadata = function () {
|
PlatformJson.prototype.generateMetadata = function () {
|
||||||
return [
|
return [
|
||||||
'cordova.define(\'cordova/plugin_list\', function(require, exports, module) {',
|
'cordova.define(\'cordova/plugin_list\', function(require, exports, module) {',
|
||||||
'module.exports = ' + JSON.stringify(this.root.modules, null, 4) + ';',
|
'module.exports = ' + JSON.stringify(this.root.modules, null, 2) + ';',
|
||||||
'module.exports.metadata = ',
|
'module.exports.metadata = ',
|
||||||
'// TOP OF METADATA',
|
'// TOP OF METADATA',
|
||||||
JSON.stringify(this.root.plugin_metadata, null, 4) + ';',
|
JSON.stringify(this.root.plugin_metadata, null, 2) + ';',
|
||||||
'// BOTTOM OF METADATA',
|
'// BOTTOM OF METADATA',
|
||||||
'});' // Close cordova.define.
|
'});' // Close cordova.define.
|
||||||
].join('\n');
|
].join('\n');
|
||||||
@@ -260,7 +259,7 @@ function ModuleMetadata (pluginId, jsModule) {
|
|||||||
if (!pluginId) throw new TypeError('pluginId argument must be a valid plugin id');
|
if (!pluginId) throw new TypeError('pluginId argument must be a valid plugin id');
|
||||||
if (!jsModule.src && !jsModule.name) throw new TypeError('jsModule argument must contain src or/and name properties');
|
if (!jsModule.src && !jsModule.name) throw new TypeError('jsModule argument must contain src or/and name properties');
|
||||||
|
|
||||||
this.id = pluginId + '.' + ( jsModule.name || jsModule.src.match(/([^\/]+)\.js/)[1] );
|
this.id = pluginId + '.' + (jsModule.name || jsModule.src.match(/([^\/]+)\.js/)[1]); /* eslint no-useless-escape: 0 */
|
||||||
this.file = ['plugins', pluginId, jsModule.src].join('/');
|
this.file = ['plugins', pluginId, jsModule.src].join('/');
|
||||||
this.pluginId = pluginId;
|
this.pluginId = pluginId;
|
||||||
|
|
||||||
|
|||||||
+39
-30
@@ -17,8 +17,6 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* jshint sub:true, laxcomma:true, laxbreak:true */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
A class for holidng the information currently stored in plugin.xml
|
A class for holidng the information currently stored in plugin.xml
|
||||||
It should also be able to answer questions like whether the plugin
|
It should also be able to answer questions like whether the plugin
|
||||||
@@ -27,12 +25,10 @@ is compatible with a given engine version.
|
|||||||
TODO (kamrik): refactor this to not use sync functions and return promises.
|
TODO (kamrik): refactor this to not use sync functions and return promises.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var path = require('path');
|
||||||
var path = require('path')
|
var fs = require('fs');
|
||||||
, fs = require('fs')
|
var xml_helpers = require('../util/xml-helpers');
|
||||||
, xml_helpers = require('../util/xml-helpers')
|
var CordovaError = require('../CordovaError/CordovaError');
|
||||||
, CordovaError = require('../CordovaError/CordovaError')
|
|
||||||
;
|
|
||||||
|
|
||||||
function PluginInfo (dirname) {
|
function PluginInfo (dirname) {
|
||||||
var self = this;
|
var self = this;
|
||||||
@@ -87,7 +83,6 @@ function PluginInfo(dirname) {
|
|||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// <dependency>
|
// <dependency>
|
||||||
// Example:
|
// Example:
|
||||||
// <dependency id="com.plugin.id"
|
// <dependency id="com.plugin.id"
|
||||||
@@ -107,10 +102,11 @@ function PluginInfo(dirname) {
|
|||||||
|
|
||||||
function _parseDependency (tag) {
|
function _parseDependency (tag) {
|
||||||
var dep =
|
var dep =
|
||||||
{ id : tag.attrib.id
|
{ id: tag.attrib.id,
|
||||||
, url : tag.attrib.url || ''
|
version: tag.attrib.version || '',
|
||||||
, subdir : tag.attrib.subdir || ''
|
url: tag.attrib.url || '',
|
||||||
, commit : tag.attrib.commit
|
subdir: tag.attrib.subdir || '',
|
||||||
|
commit: tag.attrib.commit
|
||||||
};
|
};
|
||||||
|
|
||||||
dep.git_ref = dep.commit;
|
dep.git_ref = dep.commit;
|
||||||
@@ -125,7 +121,6 @@ function PluginInfo(dirname) {
|
|||||||
return dep;
|
return dep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// <config-file> tag
|
// <config-file> tag
|
||||||
self.getConfigFiles = getConfigFiles;
|
self.getConfigFiles = getConfigFiles;
|
||||||
function getConfigFiles (platform) {
|
function getConfigFiles (platform) {
|
||||||
@@ -135,13 +130,13 @@ function PluginInfo(dirname) {
|
|||||||
|
|
||||||
function _parseConfigFile (tag) {
|
function _parseConfigFile (tag) {
|
||||||
var configFile =
|
var configFile =
|
||||||
{ target : tag.attrib['target']
|
{ target: tag.attrib['target'],
|
||||||
, parent : tag.attrib['parent']
|
parent: tag.attrib['parent'],
|
||||||
, after : tag.attrib['after']
|
after: tag.attrib['after'],
|
||||||
, xmls : tag.getchildren()
|
xmls: tag.getchildren(),
|
||||||
// To support demuxing via versions
|
// To support demuxing via versions
|
||||||
, versions : tag.attrib['versions']
|
versions: tag.attrib['versions'],
|
||||||
, deviceTarget: tag.attrib['device-target']
|
deviceTarget: tag.attrib['device-target']
|
||||||
};
|
};
|
||||||
return configFile;
|
return configFile;
|
||||||
}
|
}
|
||||||
@@ -154,10 +149,10 @@ function PluginInfo(dirname) {
|
|||||||
|
|
||||||
function _parseEditConfigs (tag) {
|
function _parseEditConfigs (tag) {
|
||||||
var editConfig =
|
var editConfig =
|
||||||
{ file : tag.attrib['file']
|
{ file: tag.attrib['file'],
|
||||||
, target : tag.attrib['target']
|
target: tag.attrib['target'],
|
||||||
, mode : tag.attrib['mode']
|
mode: tag.attrib['mode'],
|
||||||
, xmls : tag.getchildren()
|
xmls: tag.getchildren()
|
||||||
};
|
};
|
||||||
return editConfig;
|
return editConfig;
|
||||||
}
|
}
|
||||||
@@ -311,14 +306,29 @@ function PluginInfo(dirname) {
|
|||||||
return n.attrib.name;
|
return n.attrib.name;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
self.getFrameworks = function(platform) {
|
|
||||||
|
self.getFrameworks = function (platform, options) {
|
||||||
return _getTags(self._et, 'framework', platform, function (el) {
|
return _getTags(self._et, 'framework', platform, function (el) {
|
||||||
|
var src = el.attrib.src;
|
||||||
|
if (options) {
|
||||||
|
var vars = options.cli_variables || {};
|
||||||
|
var regExp;
|
||||||
|
// Iterate over plugin variables.
|
||||||
|
// Replace them in framework src if they exist
|
||||||
|
Object.keys(vars).forEach(function (name) {
|
||||||
|
if (vars[name]) {
|
||||||
|
regExp = new RegExp('\\$' + name, 'g');
|
||||||
|
src = src.replace(regExp, vars[name]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
var ret = {
|
var ret = {
|
||||||
itemType: 'framework',
|
itemType: 'framework',
|
||||||
type: el.attrib.type,
|
type: el.attrib.type,
|
||||||
parent: el.attrib.parent,
|
parent: el.attrib.parent,
|
||||||
custom: isStrTrue(el.attrib.custom),
|
custom: isStrTrue(el.attrib.custom),
|
||||||
src: el.attrib.src,
|
embed: isStrTrue(el.attrib.embed),
|
||||||
|
src: src,
|
||||||
spec: el.attrib.spec,
|
spec: el.attrib.spec,
|
||||||
weak: isStrTrue(el.attrib.weak),
|
weak: isStrTrue(el.attrib.weak),
|
||||||
versions: el.attrib.versions,
|
versions: el.attrib.versions,
|
||||||
@@ -332,21 +342,20 @@ function PluginInfo(dirname) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
self.getFilesAndFrameworks = getFilesAndFrameworks;
|
self.getFilesAndFrameworks = getFilesAndFrameworks;
|
||||||
function getFilesAndFrameworks(platform) {
|
function getFilesAndFrameworks (platform, options) {
|
||||||
// Please avoid changing the order of the calls below, files will be
|
// Please avoid changing the order of the calls below, files will be
|
||||||
// installed in this order.
|
// installed in this order.
|
||||||
var items = [].concat(
|
var items = [].concat(
|
||||||
self.getSourceFiles(platform),
|
self.getSourceFiles(platform),
|
||||||
self.getHeaderFiles(platform),
|
self.getHeaderFiles(platform),
|
||||||
self.getResourceFiles(platform),
|
self.getResourceFiles(platform),
|
||||||
self.getFrameworks(platform),
|
self.getFrameworks(platform, options),
|
||||||
self.getLibFiles(platform)
|
self.getLibFiles(platform)
|
||||||
);
|
);
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
/// // End of PluginInfo methods /////
|
/// // End of PluginInfo methods /////
|
||||||
|
|
||||||
|
|
||||||
/// // PluginInfo Constructor logic /////
|
/// // PluginInfo Constructor logic /////
|
||||||
self.filepath = path.join(dirname, 'plugin.xml');
|
self.filepath = path.join(dirname, 'plugin.xml');
|
||||||
if (!fs.existsSync(self.filepath)) {
|
if (!fs.existsSync(self.filepath)) {
|
||||||
@@ -413,7 +422,7 @@ function _getTagsInPlatform(pelem, tag, platform, transform) {
|
|||||||
|
|
||||||
// Check if x is a string 'true'.
|
// Check if x is a string 'true'.
|
||||||
function isStrTrue (x) {
|
function isStrTrue (x) {
|
||||||
return String(x).toLowerCase() == 'true';
|
return String(x).toLowerCase() === 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = PluginInfo;
|
module.exports = PluginInfo;
|
||||||
|
|||||||
+5
-8
@@ -45,7 +45,6 @@ function PluginManager(platform, locations, ideProject) {
|
|||||||
this.munger = new PlatformMunger(platform, locations.root, platformJson, new PluginInfoProvider());
|
this.munger = new PlatformMunger(platform, locations.root, platformJson, new PluginInfoProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructs PluginManager
|
* @constructs PluginManager
|
||||||
* A convenience shortcut to new PluginManager(...)
|
* A convenience shortcut to new PluginManager(...)
|
||||||
@@ -82,11 +81,9 @@ module.exports = PluginManager;
|
|||||||
* @returns {Promise} Returns a Q promise, either resolved in case of success, rejected otherwise.
|
* @returns {Promise} Returns a Q promise, either resolved in case of success, rejected otherwise.
|
||||||
*/
|
*/
|
||||||
PluginManager.prototype.doOperation = function (operation, plugin, options) {
|
PluginManager.prototype.doOperation = function (operation, plugin, options) {
|
||||||
if (operation !== PluginManager.INSTALL && operation !== PluginManager.UNINSTALL)
|
if (operation !== PluginManager.INSTALL && operation !== PluginManager.UNINSTALL) { return Q.reject(new CordovaError('The parameter is incorrect. The opeation must be either "add" or "remove"')); }
|
||||||
return Q.reject(new CordovaError('The parameter is incorrect. The opeation must be either "add" or "remove"'));
|
|
||||||
|
|
||||||
if (!plugin || plugin.constructor.name !== 'PluginInfo')
|
if (!plugin || plugin.constructor.name !== 'PluginInfo') { return Q.reject(new CordovaError('The parameter is incorrect. The first parameter should be a PluginInfo instance')); }
|
||||||
return Q.reject(new CordovaError('The parameter is incorrect. The first parameter should be a PluginInfo instance'));
|
|
||||||
|
|
||||||
// Set default to empty object to play safe when accesing properties
|
// Set default to empty object to play safe when accesing properties
|
||||||
options = options || {};
|
options = options || {};
|
||||||
@@ -95,7 +92,7 @@ PluginManager.prototype.doOperation = function (operation, plugin, options) {
|
|||||||
var actions = new ActionStack();
|
var actions = new ActionStack();
|
||||||
|
|
||||||
// gather all files need to be handled during operation ...
|
// gather all files need to be handled during operation ...
|
||||||
plugin.getFilesAndFrameworks(this.platform)
|
plugin.getFilesAndFrameworks(this.platform, options)
|
||||||
.concat(plugin.getAssets(this.platform))
|
.concat(plugin.getAssets(this.platform))
|
||||||
.concat(plugin.getJsModules(this.platform))
|
.concat(plugin.getJsModules(this.platform))
|
||||||
// ... put them into stack ...
|
// ... put them into stack ...
|
||||||
@@ -106,9 +103,9 @@ PluginManager.prototype.doOperation = function (operation, plugin, options) {
|
|||||||
|
|
||||||
var action;
|
var action;
|
||||||
if (operation === PluginManager.INSTALL) {
|
if (operation === PluginManager.INSTALL) {
|
||||||
action = actions.createAction.apply(actions, [installer, actionArgs, uninstaller, actionArgs]);
|
action = actions.createAction.apply(actions, [installer, actionArgs, uninstaller, actionArgs]); /* eslint no-useless-call: 0 */
|
||||||
} else /* op === PluginManager.UNINSTALL */{
|
} else /* op === PluginManager.UNINSTALL */{
|
||||||
action = actions.createAction.apply(actions, [uninstaller, actionArgs, installer, actionArgs]);
|
action = actions.createAction.apply(actions, [uninstaller, actionArgs, installer, actionArgs]); /* eslint no-useless-call: 0 */
|
||||||
}
|
}
|
||||||
actions.push(action);
|
actions.push(action);
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-2
@@ -20,6 +20,7 @@
|
|||||||
var EventEmitter = require('events').EventEmitter;
|
var EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
var INSTANCE = new EventEmitter();
|
var INSTANCE = new EventEmitter();
|
||||||
|
INSTANCE.setMaxListeners(20);
|
||||||
var EVENTS_RECEIVER;
|
var EVENTS_RECEIVER;
|
||||||
|
|
||||||
module.exports = INSTANCE;
|
module.exports = INSTANCE;
|
||||||
@@ -39,8 +40,7 @@ module.exports.forwardEventsTo = function (eventEmitter) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(eventEmitter instanceof EventEmitter))
|
if (!(eventEmitter instanceof EventEmitter)) { throw new Error('Cordova events can be redirected to another EventEmitter instance only'); }
|
||||||
throw new Error('Cordova events can be redirected to another EventEmitter instance only');
|
|
||||||
|
|
||||||
// CB-10940 Skipping forwarding to self to avoid infinite recursion.
|
// CB-10940 Skipping forwarding to self to avoid infinite recursion.
|
||||||
// This is the case when the modules are npm-linked.
|
// This is the case when the modules are npm-linked.
|
||||||
|
|||||||
+3
-4
@@ -24,7 +24,7 @@ var _ = require('underscore');
|
|||||||
var Q = require('q');
|
var Q = require('q');
|
||||||
var shell = require('shelljs');
|
var shell = require('shelljs');
|
||||||
var events = require('./events');
|
var events = require('./events');
|
||||||
var iswin32 = process.platform == 'win32';
|
var iswin32 = process.platform === 'win32';
|
||||||
|
|
||||||
// On Windows, spawn() for batch files requires absolute path & having the extension.
|
// On Windows, spawn() for batch files requires absolute path & having the extension.
|
||||||
function resolveWindowsExe (cmd) {
|
function resolveWindowsExe (cmd) {
|
||||||
@@ -95,7 +95,7 @@ exports.spawn = function(cmd, args, opts) {
|
|||||||
cmd = resolveWindowsExe(cmd);
|
cmd = resolveWindowsExe(cmd);
|
||||||
// If we couldn't find the file, likely we'll end up failing,
|
// If we couldn't find the file, likely we'll end up failing,
|
||||||
// but for things like "del", cmd will do the trick.
|
// but for things like "del", cmd will do the trick.
|
||||||
if (path.extname(cmd) != '.exe') {
|
if (path.extname(cmd) !== '.exe') {
|
||||||
var cmdArgs = '"' + [cmd].concat(args).map(maybeQuote).join(' ') + '"';
|
var cmdArgs = '"' + [cmd].concat(args).map(maybeQuote).join(' ') + '"';
|
||||||
// We need to use /s to ensure that spaces are parsed properly with cmd spawned content
|
// We need to use /s to ensure that spaces are parsed properly with cmd spawned content
|
||||||
args = [['/s', '/c', cmdArgs].join(' ')];
|
args = [['/s', '/c', cmdArgs].join(' ')];
|
||||||
@@ -156,7 +156,7 @@ exports.spawn = function(cmd, args, opts) {
|
|||||||
function whenDone (arg) {
|
function whenDone (arg) {
|
||||||
child.removeListener('close', whenDone);
|
child.removeListener('close', whenDone);
|
||||||
child.removeListener('error', whenDone);
|
child.removeListener('error', whenDone);
|
||||||
var code = typeof arg == 'number' ? arg : arg && arg.code;
|
var code = typeof arg === 'number' ? arg : arg && arg.code;
|
||||||
|
|
||||||
events.emit('verbose', 'Command finished with error code ' + code + ': ' + cmd + ' ' + args);
|
events.emit('verbose', 'Command finished with error code ' + code + ': ' + cmd + ' ' + args);
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
@@ -187,4 +187,3 @@ exports.maybeSpawn = function(cmd, args, opts) {
|
|||||||
}
|
}
|
||||||
return Q(null);
|
return Q(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+8
-13
@@ -16,6 +16,7 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
/* eslint no-useless-escape: 0 */
|
||||||
|
|
||||||
// contains PLIST utility functions
|
// contains PLIST utility functions
|
||||||
var __ = require('underscore');
|
var __ = require('underscore');
|
||||||
@@ -31,8 +32,7 @@ function graftPLIST(doc, xml, selector) {
|
|||||||
node = node.concat(obj);
|
node = node.concat(obj);
|
||||||
for (var i = 0; i < node.length; i++) {
|
for (var i = 0; i < node.length; i++) {
|
||||||
for (var j = i + 1; j < node.length; ++j) {
|
for (var j = i + 1; j < node.length; ++j) {
|
||||||
if (nodeEqual(node[i], node[j]))
|
if (nodeEqual(node[i], node[j])) { node.splice(j--, 1); }
|
||||||
node.splice(j--,1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doc[selector] = node;
|
doc[selector] = node;
|
||||||
@@ -66,13 +66,11 @@ function pruneOBJECT(doc, selector, fragment) {
|
|||||||
empty = pruneOBJECT(doc[selector], j, fragment[i]) && empty;
|
empty = pruneOBJECT(doc[selector], j, fragment[i]) && empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty)
|
if (empty) {
|
||||||
{
|
|
||||||
delete doc[selector];
|
delete doc[selector];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} else if (nodeEqual(doc[selector], fragment)) {
|
||||||
else if (nodeEqual(doc[selector], fragment)) {
|
|
||||||
delete doc[selector];
|
delete doc[selector];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -81,13 +79,10 @@ function pruneOBJECT(doc, selector, fragment) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function nodeEqual (node1, node2) {
|
function nodeEqual (node1, node2) {
|
||||||
if (typeof node1 != typeof node2)
|
if (typeof node1 !== typeof node2) { return false; } else if (typeof node1 === 'string') {
|
||||||
return false;
|
node2 = escapeRE(node2).replace(/\\\$\S+/gm, '(.*?)');
|
||||||
else if (typeof node1 == 'string') {
|
|
||||||
node2 = escapeRE(node2).replace(new RegExp('\\$[a-zA-Z0-9-_]+','gm'),'(.*?)');
|
|
||||||
return new RegExp('^' + node2 + '$').test(node1);
|
return new RegExp('^' + node2 + '$').test(node1);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for (var key in node2) {
|
for (var key in node2) {
|
||||||
if (!nodeEqual(node1[key], node2[key])) return false;
|
if (!nodeEqual(node1[key], node2[key])) return false;
|
||||||
}
|
}
|
||||||
@@ -97,5 +92,5 @@ function nodeEqual(node1, node2) {
|
|||||||
|
|
||||||
// escape string for use in regex
|
// escape string for use in regex
|
||||||
function escapeRE (str) {
|
function escapeRE (str) {
|
||||||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '$&');
|
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-32
@@ -17,30 +17,29 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* jshint sub:true, laxcomma:true */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* contains XML utility functions, some of which are specific to elementtree
|
* contains XML utility functions, some of which are specific to elementtree
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var fs = require('fs')
|
var fs = require('fs');
|
||||||
, path = require('path')
|
var path = require('path');
|
||||||
, _ = require('underscore')
|
var _ = require('underscore');
|
||||||
, et = require('elementtree')
|
var et = require('elementtree');
|
||||||
;
|
|
||||||
|
|
||||||
var ROOT = /^\/([^\/]*)/,
|
/* eslint-disable no-useless-escape */
|
||||||
ABSOLUTE = /^\/([^\/]*)\/(.*)/;
|
var ROOT = /^\/([^\/]*)/;
|
||||||
|
var ABSOLUTE = /^\/([^\/]*)\/(.*)/;
|
||||||
|
/* eslint-enable no-useless-escape */
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// compare two et.XML nodes, see if they match
|
// compare two et.XML nodes, see if they match
|
||||||
// compares tagName, text, attributes and children (recursively)
|
// compares tagName, text, attributes and children (recursively)
|
||||||
equalNodes: function (one, two) {
|
equalNodes: function (one, two) {
|
||||||
if (one.tag != two.tag) {
|
if (one.tag !== two.tag) {
|
||||||
return false;
|
return false;
|
||||||
} else if (one.text.trim() != two.text.trim()) {
|
} else if (one.text.trim() !== two.text.trim()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (one._children.length != two._children.length) {
|
} else if (one._children.length !== two._children.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,8 +60,8 @@ module.exports = {
|
|||||||
if (!parent) {
|
if (!parent) {
|
||||||
// Try to create the parent recursively if necessary
|
// Try to create the parent recursively if necessary
|
||||||
try {
|
try {
|
||||||
var parentToCreate = et.XML('<' + path.basename(selector) + '>'),
|
var parentToCreate = et.XML('<' + path.basename(selector) + '>');
|
||||||
parentSelector = path.dirname(selector);
|
var parentSelector = path.dirname(selector);
|
||||||
|
|
||||||
this.graftXML(doc, [parentToCreate], parentSelector);
|
this.graftXML(doc, [parentToCreate], parentSelector);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -160,7 +159,7 @@ module.exports = {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
prunXMLRemove: function(doc, selector, nodes) {
|
pruneXMLRemove: function (doc, selector, nodes) {
|
||||||
var target = module.exports.resolveParent(doc, selector);
|
var target = module.exports.resolveParent(doc, selector);
|
||||||
if (!target) return false;
|
if (!target) return false;
|
||||||
|
|
||||||
@@ -177,7 +176,6 @@ module.exports = {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
parseElementtreeSync: function (filename) {
|
parseElementtreeSync: function (filename) {
|
||||||
var contents = fs.readFileSync(filename, 'utf-8');
|
var contents = fs.readFileSync(filename, 'utf-8');
|
||||||
if (contents) {
|
if (contents) {
|
||||||
@@ -194,7 +192,7 @@ module.exports = {
|
|||||||
if (ROOT.test(selector)) {
|
if (ROOT.test(selector)) {
|
||||||
tagName = selector.match(ROOT)[1];
|
tagName = selector.match(ROOT)[1];
|
||||||
// test for wildcard "any-tag" root selector
|
// test for wildcard "any-tag" root selector
|
||||||
if (tagName == '*' || tagName === doc._root.tag) {
|
if (tagName === '*' || tagName === doc._root.tag) {
|
||||||
parent = doc._root;
|
parent = doc._root;
|
||||||
|
|
||||||
// could be an absolute path, but not selecting the root
|
// could be an absolute path, but not selecting the root
|
||||||
@@ -213,8 +211,9 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function findChild (node, parent) {
|
function findChild (node, parent) {
|
||||||
var matchingKids = parent.findall(node.tag)
|
var matchingKids = parent.findall(node.tag);
|
||||||
, i, j;
|
var i;
|
||||||
|
var j;
|
||||||
|
|
||||||
for (i = 0, j = matchingKids.length; i < j; i++) {
|
for (i = 0, j = matchingKids.length; i < j; i++) {
|
||||||
if (module.exports.equalNodes(node, matchingKids[i])) {
|
if (module.exports.equalNodes(node, matchingKids[i])) {
|
||||||
@@ -225,8 +224,8 @@ function findChild(node, parent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function uniqueChild (node, parent) {
|
function uniqueChild (node, parent) {
|
||||||
var matchingKids = parent.findall(node.tag)
|
var matchingKids = parent.findall(node.tag);
|
||||||
, i = 0;
|
var i = 0;
|
||||||
|
|
||||||
if (matchingKids.length === 0) {
|
if (matchingKids.length === 0) {
|
||||||
return true;
|
return true;
|
||||||
@@ -248,7 +247,7 @@ function findInsertIdx(children, after) {
|
|||||||
var childrenTags = children.map(function (child) { return child.tag; });
|
var childrenTags = children.map(function (child) { return child.tag; });
|
||||||
var afters = after.split(';');
|
var afters = after.split(';');
|
||||||
var afterIndexes = afters.map(function (current) { return childrenTags.lastIndexOf(current); });
|
var afterIndexes = afters.map(function (current) { return childrenTags.lastIndexOf(current); });
|
||||||
var foundIndex = _.find(afterIndexes, function(index) { return index != -1; });
|
var foundIndex = _.find(afterIndexes, function (index) { return index !== -1; });
|
||||||
|
|
||||||
// add to the beginning if no matching nodes are found
|
// add to the beginning if no matching nodes are found
|
||||||
return typeof foundIndex === 'undefined' ? 0 : foundIndex + 1;
|
return typeof foundIndex === 'undefined' ? 0 : foundIndex + 1;
|
||||||
@@ -258,7 +257,7 @@ var BLACKLIST = ['platform', 'feature','plugin','engine'];
|
|||||||
var SINGLETONS = ['content', 'author', 'name'];
|
var SINGLETONS = ['content', 'author', 'name'];
|
||||||
function mergeXml (src, dest, platform, clobber) {
|
function mergeXml (src, dest, platform, clobber) {
|
||||||
// Do nothing for blacklisted tags.
|
// Do nothing for blacklisted tags.
|
||||||
if (BLACKLIST.indexOf(src.tag) != -1) return;
|
if (BLACKLIST.indexOf(src.tag) !== -1) return;
|
||||||
|
|
||||||
// Handle attributes
|
// Handle attributes
|
||||||
Object.getOwnPropertyNames(src.attrib).forEach(function (attribute) {
|
Object.getOwnPropertyNames(src.attrib).forEach(function (attribute) {
|
||||||
@@ -284,11 +283,11 @@ function mergeXml(src, dest, platform, clobber) {
|
|||||||
removeDuplicatePreferences(dest);
|
removeDuplicatePreferences(dest);
|
||||||
|
|
||||||
function mergeChild (srcChild) {
|
function mergeChild (srcChild) {
|
||||||
var srcTag = srcChild.tag,
|
var srcTag = srcChild.tag;
|
||||||
destChild = new et.Element(srcTag),
|
var destChild = new et.Element(srcTag);
|
||||||
foundChild,
|
var foundChild;
|
||||||
query = srcTag + '',
|
var query = srcTag + '';
|
||||||
shouldMerge = true;
|
var shouldMerge = true;
|
||||||
|
|
||||||
if (BLACKLIST.indexOf(srcTag) !== -1) return;
|
if (BLACKLIST.indexOf(srcTag) !== -1) return;
|
||||||
|
|
||||||
@@ -341,8 +340,8 @@ function mergeXml(src, dest, platform, clobber) {
|
|||||||
module.exports.mergeXml = mergeXml;
|
module.exports.mergeXml = mergeXml;
|
||||||
|
|
||||||
function textMatch (elm1, elm2) {
|
function textMatch (elm1, elm2) {
|
||||||
var text1 = elm1.text ? elm1.text.replace(/\s+/, '') : '',
|
var text1 = elm1.text ? elm1.text.replace(/\s+/, '') : '';
|
||||||
text2 = elm2.text ? elm2.text.replace(/\s+/, '') : '';
|
var text2 = elm2.text ? elm2.text.replace(/\s+/, '') : '';
|
||||||
return (text1 === '' || text1 === text2);
|
return (text1 === '' || text1 === text2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,14 +349,14 @@ function attribMatch(one, two) {
|
|||||||
var oneAttribKeys = Object.keys(one.attrib);
|
var oneAttribKeys = Object.keys(one.attrib);
|
||||||
var twoAttribKeys = Object.keys(two.attrib);
|
var twoAttribKeys = Object.keys(two.attrib);
|
||||||
|
|
||||||
if (oneAttribKeys.length != twoAttribKeys.length) {
|
if (oneAttribKeys.length !== twoAttribKeys.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < oneAttribKeys.length; i++) {
|
for (var i = 0; i < oneAttribKeys.length; i++) {
|
||||||
var attribName = oneAttribKeys[i];
|
var attribName = oneAttribKeys[i];
|
||||||
|
|
||||||
if (one.attrib[attribName] != two.attrib[attribName]) {
|
if (one.attrib[attribName] !== two.attrib[attribName]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -10,7 +10,7 @@
|
|||||||
"spec": ">=1.1.8 <2.0.0",
|
"spec": ">=1.1.8 <2.0.0",
|
||||||
"type": "range"
|
"type": "range"
|
||||||
},
|
},
|
||||||
"/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common"
|
"/Users/jbowser/cordova/cordova-android/node_modules/cordova-common"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"_from": "cordova-registry-mapper@>=1.1.8 <2.0.0",
|
"_from": "cordova-registry-mapper@>=1.1.8 <2.0.0",
|
||||||
@@ -36,11 +36,11 @@
|
|||||||
"_requiredBy": [
|
"_requiredBy": [
|
||||||
"/cordova-common"
|
"/cordova-common"
|
||||||
],
|
],
|
||||||
"_resolved": "http://registry.npmjs.org/cordova-registry-mapper/-/cordova-registry-mapper-1.1.15.tgz",
|
"_resolved": "https://registry.npmjs.org/cordova-registry-mapper/-/cordova-registry-mapper-1.1.15.tgz",
|
||||||
"_shasum": "e244b9185b8175473bff6079324905115f83dc7c",
|
"_shasum": "e244b9185b8175473bff6079324905115f83dc7c",
|
||||||
"_shrinkwrap": null,
|
"_shrinkwrap": null,
|
||||||
"_spec": "cordova-registry-mapper@^1.1.8",
|
"_spec": "cordova-registry-mapper@^1.1.8",
|
||||||
"_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common",
|
"_where": "/Users/jbowser/cordova/cordova-android/node_modules/cordova-common",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Steve Gill"
|
"name": "Steve Gill"
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-5
@@ -1,11 +1,7 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
sudo: false
|
|
||||||
|
|
||||||
node_js:
|
node_js:
|
||||||
- "0.10"
|
- 0.6
|
||||||
- "0.11"
|
|
||||||
- "0.12"
|
|
||||||
- "iojs"
|
|
||||||
|
|
||||||
script: make test
|
script: make test
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
elementtree v0.1.6 - 2014-02-06
|
elementtree v0.1.6 (in development)
|
||||||
|
|
||||||
* Add support for CData elements. (#14)
|
* Add support for CData elements. (#14)
|
||||||
[hermannpencole]
|
[hermannpencole]
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user