Commit 144c524a by Sebastián Katzer

Update to the latest dev cycle

parent 5b7238a2
......@@ -13,9 +13,9 @@
<preference name="uap-target-min-version" value="10.0.15063.0" />
<preference name="Windows.Universal-MinVersion" value="10.0.15063.0" />
<preference name="Windows.Universal" value="10.0.15063.0" />
<engine name="ios" spec="latest" />
<engine name="windows" spec="^5.0.0" />
<plugin name="cordova-plugin-device" spec="~1.1.6" />
<plugin name="cordova-plugin-x-toast" spec="~2.6.0" />
<plugin name="cordova-plugin-local-notifications" spec="~0.0.0" />
<engine name="ios" spec="latest" />
</widget>
bin/node_modules/*
bin/templates/project/*
tests/spec/unit/fixtures/*
tests/spec/unit/fixtures/*
\ No newline at end of file
root: true
extends: semistandard
rules:
indent:
- error
- 4
camelcase: off
padded-blocks: off
operator-linebreak: off
no-throw-literal: off
{
"node": true
, "bitwise": true
, "undef": true
, "trailing": true
, "quotmark": true
, "indent": 4
, "unused": "vars"
, "latedef": "nofunc"
, "esversion": "6"
}
......@@ -8,6 +8,7 @@ tmp
xcuserdata
console.log
node_modules/jshint
node_modules/eslint
node_modules/jasmine-node
node_modules/rewire
node_modules/istanbul
......@@ -18,6 +19,7 @@ node_modules/.bin/color-support
node_modules/.bin/coveralls
node_modules/.bin/escodegen
node_modules/.bin/esgenerate
node_modules/.bin/eslint
node_modules/.bin/esparse
node_modules/.bin/esvalidate
node_modules/.bin/handlebars
......@@ -224,3 +226,4 @@ node_modules/color-support/
node_modules/fs.realpath/
node_modules/jasmine-core/
node_modules/jasmine/
node_modules/eslint-*
\ No newline at end of file
language: objective-c
osx_image: xcode7.3
osx_image: xcode8.3
sudo: false
env:
matrix:
- TRAVIS_NODE_VERSION: '4.2'
- TRAVIS_NODE_VERSION: '6.11'
before_install:
- npm cache clean -f
- npm install -g n
- node --version
- npm cache clean -f
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm
&& git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm
install $TRAVIS_NODE_VERSION
- node --version
install:
- npm install
- npm install ios-deploy
- npm install -g codecov
- npm install
- npm install ios-deploy
- npm install -g codecov
script:
- npm run jshint
- npm run unit-tests
- npm run e2e-tests
- open -b com.apple.iphonesimulator
- npm run objc-tests
- npm run cover
- npm run eslint
after_script: codecov
......@@ -66,9 +66,9 @@
id object = [NSJSONSerialization JSONObjectWithData:[self dataUsingEncoding:NSUTF8StringEncoding]
options:NSJSONReadingMutableContainers
error:&error];
if (error != nil) {
NSLog(@"NSString JSONObject error: %@", [error localizedDescription]);
NSLog(@"NSString JSONObject error: %@, Malformed Data: %@", [error localizedDescription], self);
}
return object;
......
/*
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.
*/
#import "CDVPlugin.h"
@interface CDVLogger : CDVPlugin
- (void)logLevel:(CDVInvokedUrlCommand*)command;
@end
/*
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.
*/
#import "CDVLogger.h"
@implementation CDVLogger
/* log a message */
- (void)logLevel:(CDVInvokedUrlCommand*)command
{
id level = [command argumentAtIndex:0];
id message = [command argumentAtIndex:1];
if ([level isEqualToString:@"LOG"]) {
NSLog(@"%@", message);
} else {
NSLog(@"%@: %@", level, message);
}
}
@end
......@@ -256,11 +256,10 @@ static NSString *stripFragment(NSString* url)
NSLog(@"%@", description);
_loadCount = 0;
_state = STATE_WAITING_FOR_LOAD_START;
if ([_delegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
NSDictionary* errorDictionary = @{NSLocalizedDescriptionKey : description};
NSError* error = [[NSError alloc] initWithDomain:@"CDVUIWebViewDelegate" code:1 userInfo:errorDictionary];
[_delegate webView:webView didFailLoadWithError:error];
}
NSDictionary* errorDictionary = @{NSLocalizedDescriptionKey : description};
NSError* error = [[NSError alloc] initWithDomain:@"CDVUIWebViewDelegate" code:1 userInfo:errorDictionary];
[self webView:webView didFailLoadWithError:error];
}
}
} else {
......
......@@ -80,7 +80,9 @@
if (errorUrl) {
errorUrl = [NSURL URLWithString:[NSString stringWithFormat:@"?error=%@", [message stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLPathAllowedCharacterSet]] relativeToURL:errorUrl];
NSLog(@"%@", [errorUrl absoluteString]);
[theWebView loadRequest:[NSURLRequest requestWithURL:errorUrl]];
if(error.code != NSURLErrorCancelled) {
[theWebView loadRequest:[NSURLRequest requestWithURL:errorUrl]];
}
}
}
......
......@@ -79,8 +79,21 @@
return NO;
}
NSMutableDictionary * openURLData = [[NSMutableDictionary alloc] init];
[openURLData setValue:url forKey:@"url"];
if (sourceApplication) {
[openURLData setValue:sourceApplication forKey:@"sourceApplication"];
}
if (annotation) {
[openURLData setValue:annotation forKey:@"annotation"];
}
// all plugins will get the notification, and their handlers will be called
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLWithAppSourceAndAnnotationNotification object:openURLData]];
return YES;
}
......
......@@ -67,6 +67,7 @@
#define __CORDOVA_4_3_0 40300
#define __CORDOVA_4_3_1 40301
#define __CORDOVA_4_4_0 40400
#define __CORDOVA_4_5_0 40500
/* coho:next-version,insert-before */
#define __CORDOVA_NA 99999 /* not available */
......@@ -79,7 +80,7 @@
*/
#ifndef CORDOVA_VERSION_MIN_REQUIRED
/* coho:next-version-min-required,replace-after */
#define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_4_4_0
#define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_4_5_0
#endif
/*
......
......@@ -32,6 +32,7 @@
extern NSString* const CDVPageDidLoadNotification;
extern NSString* const CDVPluginHandleOpenURLNotification;
extern NSString* const CDVPluginHandleOpenURLWithAppSourceAndAnnotationNotification;
extern NSString* const CDVPluginResetNotification;
extern NSString* const CDVViewWillAppearNotification;
extern NSString* const CDVViewDidAppearNotification;
......@@ -65,6 +66,7 @@ extern NSString* const CDVRemoteNotificationError CDV_DEPRECATED(4.0, "Functiona
- (void)pluginInitialize;
- (void)handleOpenURL:(NSNotification*)notification;
- (void)handleOpenURLWithApplicationSourceAndAnnotation:(NSNotification*)notification;
- (void)onAppTerminate;
- (void)onMemoryWarning;
- (void)onReset;
......
......@@ -42,6 +42,7 @@
NSString* const CDVPageDidLoadNotification = @"CDVPageDidLoadNotification";
NSString* const CDVPluginHandleOpenURLNotification = @"CDVPluginHandleOpenURLNotification";
NSString* const CDVPluginHandleOpenURLWithAppSourceAndAnnotationNotification = @"CDVPluginHandleOpenURLWithAppSourceAndAnnotationNotification";
NSString* const CDVPluginResetNotification = @"CDVPluginResetNotification";
NSString* const CDVLocalNotification = @"CDVLocalNotification";
NSString* const CDVRemoteNotification = @"CDVRemoteNotification";
......@@ -73,6 +74,7 @@ NSString* const CDVViewWillTransitionToSizeNotification = @"CDVViewWillTransitio
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppTerminate) name:UIApplicationWillTerminateNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:CDVPluginHandleOpenURLNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURLWithApplicationSourceAndAnnotation:) name:CDVPluginHandleOpenURLWithAppSourceAndAnnotationNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onReset) name:CDVPluginResetNotification object:theWebViewEngine.engineWebView];
self.webViewEngine = theWebViewEngine;
......@@ -140,6 +142,37 @@ NSString* const CDVViewWillTransitionToSizeNotification = @"CDVViewWillTransitio
}
}
/*
NOTE: calls into JavaScript must not call or trigger any blocking UI, like alerts
*/
- (void)handleOpenURLWithApplicationSourceAndAnnotation: (NSNotification*)notification
{
// override to handle urls sent to your app
// register your url schemes in your App-Info.plist
// The notification object is an NSDictionary which contains
// - url which is a type of NSURL
// - sourceApplication which is a type of NSString and represents the package
// id of the app that calls our app
// - annotation which a type of Property list which can be several different types
// please see https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html
NSDictionary* notificationData = [notification object];
if ([notificationData isKindOfClass: NSDictionary.class]){
NSURL* url = notificationData[@"url"];
NSString* sourceApplication = notificationData[@"sourceApplication"];
id annotation = notificationData[@"annotation"];
if ([url isKindOfClass:NSURL.class] && [sourceApplication isKindOfClass:NSString.class] && annotation) {
/* Do your thing! */
}
}
}
/* NOTE: calls into JavaScript must not call or trigger any blocking UI, like alerts */
- (void)onAppTerminate
{
......
......@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
28BFF9141F355A4E00DDF01A /* CDVLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 28BFF9121F355A4E00DDF01A /* CDVLogger.h */; };
28BFF9151F355A4E00DDF01A /* CDVLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 28BFF9131F355A4E00DDF01A /* CDVLogger.m */; };
30193A501AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 30193A4E1AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.m */; };
30193A511AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 30193A4F1AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.h */; };
3093E2231B16D6A3003F381A /* CDVIntentAndNavigationFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 3093E2211B16D6A3003F381A /* CDVIntentAndNavigationFilter.h */; };
......@@ -98,6 +100,8 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
28BFF9121F355A4E00DDF01A /* CDVLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVLogger.h; sourceTree = "<group>"; };
28BFF9131F355A4E00DDF01A /* CDVLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVLogger.m; sourceTree = "<group>"; };
30193A4E1AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVUIWebViewNavigationDelegate.m; sourceTree = "<group>"; };
30193A4F1AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVUIWebViewNavigationDelegate.h; sourceTree = "<group>"; };
30325A0B136B343700982B63 /* VERSION */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VERSION; sourceTree = "<group>"; };
......@@ -200,6 +204,15 @@
name = CordovaLib;
sourceTree = "<group>";
};
28BFF9111F355A1D00DDF01A /* CDVLogger */ = {
isa = PBXGroup;
children = (
28BFF9121F355A4E00DDF01A /* CDVLogger.h */,
28BFF9131F355A4E00DDF01A /* CDVLogger.m */,
);
path = CDVLogger;
sourceTree = "<group>";
};
3093E2201B16D6A3003F381A /* CDVIntentAndNavigationFilter */ = {
isa = PBXGroup;
children = (
......@@ -226,6 +239,7 @@
7ED95CF61AB9028C008C4574 /* Plugins */ = {
isa = PBXGroup;
children = (
28BFF9111F355A1D00DDF01A /* CDVLogger */,
A3B082D11BB15CEA00D8DC35 /* CDVGestureHandler */,
3093E2201B16D6A3003F381A /* CDVIntentAndNavigationFilter */,
7ED95CF71AB9028C008C4574 /* CDVHandleOpenURL */,
......@@ -395,6 +409,7 @@
3093E2231B16D6A3003F381A /* CDVIntentAndNavigationFilter.h in Headers */,
7E7F69B81ABA368F007546F4 /* CDVUIWebViewEngine.h in Headers */,
7E7F69B91ABA3692007546F4 /* CDVHandleOpenURL.h in Headers */,
28BFF9141F355A4E00DDF01A /* CDVLogger.h in Headers */,
30193A511AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
......@@ -515,6 +530,7 @@
7ED95D481AB9029B008C4574 /* CDVPluginResult.m in Sources */,
7ED95D441AB9029B008C4574 /* CDVPlugin+Resources.m in Sources */,
7ED95D4D1AB9029B008C4574 /* CDVURLProtocol.m in Sources */,
28BFF9151F355A4E00DDF01A /* CDVLogger.m in Sources */,
7ED95D0D1AB9028C008C4574 /* CDVUIWebViewEngine.m in Sources */,
7ED95D461AB9029B008C4574 /* CDVPlugin.m in Sources */,
7ED95D091AB9028C008C4574 /* CDVLocalStorage.m in Sources */,
......
......@@ -22,6 +22,38 @@
Cordova is a static library that enables developers to include the Cordova API in their iOS application projects easily, and also create new Cordova-based iOS application projects through the command-line.
### 4.5.1 (Sep 21, 2017)
* [CB-13310](https://issues.apache.org/jira/browse/CB-13310) Updated checked-in node_modules
* [CB-13191](https://issues.apache.org/jira/browse/CB-13191) (ios) Support marketing icon (#337)
* [CB-12888](https://issues.apache.org/jira/browse/CB-12888) - cordova emulate **iOS** doesn't work in **iOS** 11
### 4.5.0 (Sep 06, 2017)
* [CB-13247](https://issues.apache.org/jira/browse/CB-13247) updated checked-in node_modules
* [CB-13212](https://issues.apache.org/jira/browse/CB-13212) - Update `cordova-ios` with new cordova-common that parses new attribute for access tag
* [CB-13240](https://issues.apache.org/jira/browse/CB-13240) - Update **iOS**-deploy dependency to 1.9.2
* [CB-12830](https://issues.apache.org/jira/browse/CB-12830) - cordova emulate **iOS** with --target throws undefined error (#332)
* [CB-13210](https://issues.apache.org/jira/browse/CB-13210) - App Transport Security Key is wrong (#331)
* [CB-13164](https://issues.apache.org/jira/browse/CB-13164) fixed local require, updated cordova.js (#333)
* [CB-13222](https://issues.apache.org/jira/browse/CB-13222) - (iOS) Infinite Loop when a "NSURLErrorCancelled -999" is received on didFailLoadWithError (#334)
* [CB-12937](https://issues.apache.org/jira/browse/CB-12937) - (iOS) added new method handleOpenURLWithApplicationSourceAndAnno… (#321)
* [CB-13164](https://issues.apache.org/jira/browse/CB-13164) Integrated cordova-plugin-console to build in support for window.console. (#330)
* [CB-13112](https://issues.apache.org/jira/browse/CB-13112) - <resource-file> should not create a new file reference on each "cordova prepare" (#329)
* [CB-13093](https://issues.apache.org/jira/browse/CB-13093) (iOS) Infinite looping when stressing navigation (#328)
* [CB-12966](https://issues.apache.org/jira/browse/CB-12966) (ios) Fix bug by escaping project name in podfile template
* [CB-12895](https://issues.apache.org/jira/browse/CB-12895) : removed jshint and added eslint
* [CB-12960](https://issues.apache.org/jira/browse/CB-12960) Run tests on Node 4.x and 6.x This closes #323
* [CB-12948](https://issues.apache.org/jira/browse/CB-12948) - Add a warning to updateProject for **iOS**
* [CB-10916](https://issues.apache.org/jira/browse/CB-10916) Support display name for **iOS**
* [CB-12887](https://issues.apache.org/jira/browse/CB-12887) - cordova run --list does not show virtual devices in **iOS** 11
* [CB-12762](https://issues.apache.org/jira/browse/CB-12762) : point `package.json` repo items to github mirrors instead of apache repos site
* [CB-12675](https://issues.apache.org/jira/browse/CB-12675) - Travis xcode 8.3. os-x image fails an e2e test
* [CB-12869](https://issues.apache.org/jira/browse/CB-12869) - Update bundled **iOS**-sim to 5.0.13
* [CB-12856](https://issues.apache.org/jira/browse/CB-12856) - Skip CocoaPods check_reqs if on non-darwin (macOS) platform
* [CB-8980](https://issues.apache.org/jira/browse/CB-8980) Ensure copied resource-files are cleaned
* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`.
* Updated cordova-common to 2.1.0 and other bundled node_modules
* Update bundled ios-sim to 6.0.0
### 4.4.0 (Apr 22, 2017)
* [CB-12009](https://issues.apache.org/jira/browse/CB-12009) - <resource-file> target attribute ignored on iOS when installing a Cordova plugin
* [CB-12673](https://issues.apache.org/jira/browse/CB-12673) - ios platform does not build on Xcode 8.3.2
......
......@@ -7,12 +7,14 @@ install:
- ps: Install-Product node $env:nodejs_version
# Lines below required due to uncrustify installation failure on Windows
- npm install --prod
- npm install jshint jasmine rewire
- npm install eslint eslint-config-semistandard jasmine rewire
- npm install eslint-config-standard eslint-plugin-import eslint-plugin-node
- npm install eslint-plugin-promise eslint-plugin-standard
build: off
test_script:
- node --version
- npm --version
- npm run jshint
- npm run unit-tests
- npm run eslint
......@@ -19,7 +19,7 @@
under the License.
*/
var versions = require('./lib/versions.js');
var versions = require('./templates/scripts/cordova/lib/versions.js');
versions.get_apple_ios_version().done(null, function(err) {
console.log(err);
......
......@@ -19,7 +19,7 @@
under the License.
*/
var versions = require('./lib/versions.js');
var versions = require('./templates/scripts/cordova/lib/versions.js');
versions.get_apple_osx_version().done(null, function(err) {
console.log(err);
......
......@@ -19,7 +19,7 @@
under the License.
*/
var versions = require('./lib/versions.js');
var versions = require('./templates/scripts/cordova/lib/versions.js');
versions.get_apple_xcode_version().done(function (version) {
console.log(version);
......
......@@ -19,7 +19,7 @@
under the License.
*/
var check_reqs = require('./lib/check_reqs');
var check_reqs = require('./templates/scripts/cordova/lib/check_reqs');
// check for help flag
if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) > -1) {
......
......@@ -121,6 +121,12 @@
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "icon-1024.png",
"scale" : "1x"
},
{
"size" : "24x24",
"idiom" : "watch",
"scale" : "2x",
......
......@@ -65,6 +65,10 @@
<feature name="LocalStorage">
<param name="ios-package" value="CDVLocalStorage"/>
</feature>
<feature name="Console">
<param name="ios-package" value="CDVLogger"/>
<param name="onload" value="true"/>
</feature>
<feature name="HandleOpenUrl">
<param name="ios-package" value="CDVHandleOpenURL"/>
<param name="onload" value="true"/>
......
......@@ -18,25 +18,25 @@
*/
var app = {
// Application Constructor
initialize: function() {
initialize: function () {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
bindEvents: function () {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
onDeviceReady: function () {
app.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
receivedEvent: function (id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
......@@ -48,4 +48,4 @@ var app = {
}
};
app.initialize();
\ No newline at end of file
app.initialize();
......@@ -39,6 +39,10 @@
<feature name="LocalStorage">
<param name="ios-package" value="CDVLocalStorage"/>
</feature>
<feature name="Console">
<param name="ios-package" value="CDVLogger"/>
<param name="onload" value="true"/>
</feature>
<feature name="HandleOpenUrl">
<param name="ios-package" value="CDVHandleOpenURL"/>
<param name="onload" value="true"/>
......
......@@ -16,18 +16,19 @@
specific language governing permissions and limitations
under the License.
*/
'use strict';
var fs = require('fs'),
path = require('path'),
util = require('util'),
events = require('cordova-common').events,
Q = require('q'),
superspawn = require('cordova-common').superspawn,
CordovaError = require('cordova-common').CordovaError;
var fs = require('fs');
var path = require('path');
var util = require('util');
var events = require('cordova-common').events;
var Q = require('q');
var superspawn = require('cordova-common').superspawn;
var CordovaError = require('cordova-common').CordovaError;
Podfile.FILENAME = 'Podfile';
function Podfile(podFilePath, projectName) {
function Podfile (podFilePath, projectName) {
this.podToken = '##INSERT_POD##';
this.path = podFilePath;
......@@ -53,12 +54,12 @@ function Podfile(podFilePath, projectName) {
this.write();
} else {
events.emit('verbose', 'Podfile found in platforms/ios');
// parse for pods
// parse for pods
this.pods = this.__parseForPods(fs.readFileSync(this.path, 'utf8'));
}
}
Podfile.prototype.__parseForPods = function(text) {
Podfile.prototype.__parseForPods = function (text) {
// split by \n
var arr = text.split('\n');
......@@ -69,38 +70,45 @@ Podfile.prototype.__parseForPods = function(text) {
var podRE = new RegExp('pod \'([^\']*)\'\\s*,?\\s*(.*)');
// only grab lines that don't have the pod spec'
return arr.filter(function(line) {
return arr.filter(function (line) {
var m = podRE.exec(line);
return (m !== null);
})
.reduce(function(obj, line){
var m = podRE.exec(line);
.reduce(function (obj, line) {
var m = podRE.exec(line);
if (m !== null) {
// strip out any single quotes around the value m[2]
var podSpec = m[2].replace(/^\'|\'$/g, '');
obj[m[1]] = podSpec; // i.e pod 'Foo', '1.2' ==> { 'Foo' : '1.2'}
}
if (m !== null) {
// strip out any single quotes around the value m[2]
var podSpec = m[2].replace(/^\'|\'$/g, ''); /* eslint no-useless-escape : 0 */
obj[m[1]] = podSpec; // i.e pod 'Foo', '1.2' ==> { 'Foo' : '1.2'}
}
return obj;
}, {});
return obj;
}, {});
};
Podfile.prototype.getTemplate = function() {
Podfile.prototype.escapeSingleQuotes = function (string) {
return string.replace('\'', '\\\'');
};
Podfile.prototype.getTemplate = function () {
// Escaping possible ' in the project name
var projectName = this.escapeSingleQuotes(this.projectName);
return util.format(
'# DO NOT MODIFY -- auto-generated by Apache Cordova\n' +
'# DO NOT MODIFY -- auto-generated by Apache Cordova\n' +
'platform :ios, \'8.0\'\n' +
'target \'%s\' do\n' +
'\tproject \'%s.xcodeproj\'\n' +
'%s\n' +
'end\n',
this.projectName, this.projectName, this.podToken);
projectName, projectName, this.podToken);
};
Podfile.prototype.addSpec = function(name, spec) {
Podfile.prototype.addSpec = function (name, spec) {
name = name || '';
spec = spec; // optional
// optional
spec = spec; /* eslint no-self-assign : 0 */
if (!name.length) { // blank names are not allowed
throw new CordovaError('Podfile addSpec: name is not specified.');
......@@ -112,39 +120,39 @@ Podfile.prototype.addSpec = function(name, spec) {
events.emit('verbose', util.format('Added pod line for `%s`', name));
};
Podfile.prototype.removeSpec = function(name) {
Podfile.prototype.removeSpec = function (name) {
if (this.existsSpec(name)) {
delete this.pods[name];
this.__dirty = true;
}
events.emit('verbose', util.format('Removed pod line for `%s`', name));
};
Podfile.prototype.getSpec = function(name) {
Podfile.prototype.getSpec = function (name) {
return this.pods[name];
};
Podfile.prototype.existsSpec = function(name) {
Podfile.prototype.existsSpec = function (name) {
return (name in this.pods);
};
Podfile.prototype.clear = function() {
Podfile.prototype.clear = function () {
this.pods = {};
this.__dirty = true;
};
Podfile.prototype.destroy = function() {
Podfile.prototype.destroy = function () {
fs.unlinkSync(this.path);
events.emit('verbose', util.format('Deleted `%s`', this.path));
};
Podfile.prototype.write = function() {
Podfile.prototype.write = function () {
var text = this.getTemplate();
var self = this;
var podsString =
Object.keys(this.pods).map(function(key) {
Object.keys(this.pods).map(function (key) {
var name = key;
var spec = self.pods[key];
......@@ -159,8 +167,7 @@ Podfile.prototype.write = function() {
} else {
return util.format('\tpod \'%s\'', name);
}
})
.join('\n');
}).join('\n');
text = text.replace(this.podToken, podsString);
fs.writeFileSync(this.path, text, 'utf8');
......@@ -169,14 +176,16 @@ Podfile.prototype.write = function() {
events.emit('verbose', 'Wrote to Podfile.');
};
Podfile.prototype.isDirty = function() {
Podfile.prototype.isDirty = function () {
return this.__dirty;
};
Podfile.prototype.before_install = function() {
Podfile.prototype.before_install = function (toolOptions) {
toolOptions = toolOptions || {};
// Template tokens in order: project name, project name, debug | release
var template =
'// DO NOT MODIFY -- auto-generated by Apache Cordova\n' +
'// DO NOT MODIFY -- auto-generated by Apache Cordova\n' +
'#include "Pods/Target Support Files/Pods-%s/Pods-%s.%s.xcconfig"';
var debugContents = util.format(template, this.projectName, this.projectName, 'debug');
......@@ -188,10 +197,10 @@ Podfile.prototype.before_install = function() {
fs.writeFileSync(debugConfigPath, debugContents, 'utf8');
fs.writeFileSync(releaseConfigPath, releaseContents, 'utf8');
return Q.resolve();
return Q.resolve(toolOptions);
};
Podfile.prototype.install = function(requirementsCheckerFunction) {
Podfile.prototype.install = function (requirementsCheckerFunction) {
var opts = {};
opts.cwd = path.join(this.path, '..'); // parent path of this Podfile
opts.stdio = 'pipe';
......@@ -203,28 +212,34 @@ Podfile.prototype.install = function(requirementsCheckerFunction) {
}
return requirementsCheckerFunction()
.then(function() {
return self.before_install();
})
.then(function() {
return superspawn.spawn('pod', ['install', '--verbose'], opts)
.progress(function (stdio){
if (stdio.stderr) { console.error(stdio.stderr); }
if (stdio.stdout) {
if (first) {
events.emit('verbose', '==== pod install start ====\n');
first = false;
}
events.emit('verbose', stdio.stdout);
}
.then(function (toolOptions) {
return self.before_install(toolOptions);
})
.then(function (toolOptions) {
if (toolOptions.ignore) {
events.emit('verbose', '==== pod install start ====\n');
events.emit('verbose', toolOptions.ignoreMessage);
return Q.resolve();
} else {
return superspawn.spawn('pod', ['install', '--verbose'], opts)
.progress(function (stdio) {
if (stdio.stderr) { console.error(stdio.stderr); }
if (stdio.stdout) {
if (first) {
events.emit('verbose', '==== pod install start ====\n');
first = false;
}
events.emit('verbose', stdio.stdout);
}
});
}
})
.then(function () { // done
events.emit('verbose', '==== pod install end ====\n');
})
.fail(function (error) {
throw error;
});
})
.then(function() { // done
events.emit('verbose', '==== pod install end ====\n');
})
.fail(function(error){
throw error;
});
};
module.exports.Podfile = Podfile;
\ No newline at end of file
module.exports.Podfile = Podfile;
......@@ -17,15 +17,15 @@
under the License.
*/
var fs = require('fs'),
path = require('path'),
util = require('util'),
events = require('cordova-common').events,
CordovaError = require('cordova-common').CordovaError;
var fs = require('fs');
var path = require('path');
var util = require('util');
var events = require('cordova-common').events;
var CordovaError = require('cordova-common').CordovaError;
PodsJson.FILENAME = 'pods.json';
function PodsJson(podsJsonPath) {
function PodsJson (podsJsonPath) {
this.path = podsJsonPath;
this.contents = null;
this.__dirty = false;
......@@ -41,18 +41,18 @@ function PodsJson(podsJsonPath) {
this.clear();
this.write();
} else {
events.emit('verbose', 'pods.json found in platforms/ios');
events.emit('verbose', 'pods.json found in platforms/ios');
// load contents
this.contents = fs.readFileSync(this.path, 'utf8');
this.contents = JSON.parse(this.contents);
}
}
PodsJson.prototype.get = function(name) {
PodsJson.prototype.get = function (name) {
return this.contents[name];
};
PodsJson.prototype.remove = function(name) {
PodsJson.prototype.remove = function (name) {
if (this.contents[name]) {
delete this.contents[name];
this.__dirty = true;
......@@ -60,17 +60,17 @@ PodsJson.prototype.remove = function(name) {
}
};
PodsJson.prototype.clear = function() {
PodsJson.prototype.clear = function () {
this.contents = {};
this.__dirty = true;
};
PodsJson.prototype.destroy = function() {
PodsJson.prototype.destroy = function () {
fs.unlinkSync(this.path);
events.emit('verbose', util.format('Deleted `%s`', this.path));
};
PodsJson.prototype.write = function() {
PodsJson.prototype.write = function () {
if (this.contents) {
fs.writeFileSync(this.path, JSON.stringify(this.contents, null, 4));
this.__dirty = false;
......@@ -78,11 +78,11 @@ PodsJson.prototype.write = function() {
}
};
PodsJson.prototype.set = function(name, type, spec, count) {
PodsJson.prototype.set = function (name, type, spec, count) {
this.setJson(name, { name: name, type: type, spec: spec, count: count });
};
PodsJson.prototype.increment = function(name) {
PodsJson.prototype.increment = function (name) {
var val = this.get(name);
if (val) {
val.count++;
......@@ -90,7 +90,7 @@ PodsJson.prototype.increment = function(name) {
}
};
PodsJson.prototype.decrement = function(name) {
PodsJson.prototype.decrement = function (name) {
var val = this.get(name);
if (val) {
val.count--;
......@@ -102,13 +102,13 @@ PodsJson.prototype.decrement = function(name) {
}
};
PodsJson.prototype.setJson = function(name, json) {
PodsJson.prototype.setJson = function (name, json) {
this.contents[name] = json;
this.__dirty = true;
events.emit('verbose', util.format('Set pods.json for `%s`', name));
};
PodsJson.prototype.isDirty = function() {
PodsJson.prototype.isDirty = function () {
return this.__dirty;
};
......
......@@ -6,9 +6,9 @@
* 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
......@@ -17,16 +17,14 @@
* under the License.
*/
/*jshint node: true*/
var Q = require('q'),
path = require('path'),
shell = require('shelljs'),
spawn = require('./spawn');
var Q = require('q');
var path = require('path');
var shell = require('shelljs');
var spawn = require('./spawn');
var projectPath = path.join(__dirname, '..', '..');
module.exports.run = function() {
module.exports.run = function () {
var projectName = shell.ls(projectPath).filter(function (name) {
return path.extname(name) === '.xcodeproj';
})[0];
......@@ -36,9 +34,9 @@ module.exports.run = function() {
}
return spawn('xcodebuild', ['-project', projectName, '-configuration', 'Debug', '-alltargets', 'clean'], projectPath)
.then(function () {
return spawn('xcodebuild', ['-project', projectName, '-configuration', 'Release', '-alltargets', 'clean'], projectPath);
}).then(function () {
return shell.rm('-rf', path.join(projectPath, 'build'));
});
.then(function () {
return spawn('xcodebuild', ['-project', projectName, '-configuration', 'Release', '-alltargets', 'clean'], projectPath);
}).then(function () {
return shell.rm('-rf', path.join(projectPath, 'build'));
});
};
......@@ -24,19 +24,19 @@
// This script should not be called directly.
// It is called as a build step from Xcode.
var BUILT_PRODUCTS_DIR = process.env.BUILT_PRODUCTS_DIR,
FULL_PRODUCT_NAME = process.env.FULL_PRODUCT_NAME,
COPY_HIDDEN = process.env.COPY_HIDDEN,
PROJECT_FILE_PATH = process.env.PROJECT_FILE_PATH;
var BUILT_PRODUCTS_DIR = process.env.BUILT_PRODUCTS_DIR;
var FULL_PRODUCT_NAME = process.env.FULL_PRODUCT_NAME;
var COPY_HIDDEN = process.env.COPY_HIDDEN;
var PROJECT_FILE_PATH = process.env.PROJECT_FILE_PATH;
var path = require('path'),
fs = require('fs'),
shell = require('shelljs'),
srcDir = 'www',
dstDir = path.join(BUILT_PRODUCTS_DIR, FULL_PRODUCT_NAME),
dstWwwDir = path.join(dstDir, 'www');
var path = require('path');
var fs = require('fs');
var shell = require('shelljs');
var srcDir = 'www';
var dstDir = path.join(BUILT_PRODUCTS_DIR, FULL_PRODUCT_NAME);
var dstWwwDir = path.join(dstDir, 'www');
if(!BUILT_PRODUCTS_DIR) {
if (!BUILT_PRODUCTS_DIR) {
console.error('The script is meant to be run as an Xcode build step and relies on env variables set by Xcode.');
process.exit(1);
}
......@@ -57,13 +57,13 @@ shell.rm('-rf', path.join(dstDir, 'embedded.mobileprovision'));
// Copy www dir recursively
var code;
if(!!COPY_HIDDEN) {
if (COPY_HIDDEN) {
code = shell.exec('rsync -Lra "' + srcDir + '" "' + dstDir + '"').code;
} else {
code = shell.exec('rsync -Lra --exclude="- .*" "' + srcDir + '" "' + dstDir + '"').code;
}
if(code !== 0) {
if (code !== 0) {
console.error('Error occured on copying www. Code: ' + code);
process.exit(3);
}
......
......@@ -19,7 +19,6 @@
under the License.
*/
/*jshint node: true*/
var Q = require('q'),
exec = require('child_process').exec;
......
......@@ -19,7 +19,6 @@
under the License.
*/
/*jshint node: true*/
var Q = require('q'),
exec = require('child_process').exec;
......
......@@ -19,7 +19,6 @@
under the License.
*/
/*jshint node: true*/
var Q = require('q'),
iossim = require('ios-sim'),
......
......@@ -19,7 +19,6 @@
under the License.
*/
/*jshint node: true*/
var Q = require('q'),
exec = require('child_process').exec;
......
......@@ -17,8 +17,6 @@
under the License.
*/
/*jshint node: true*/
var xcode = require('xcode');
var plist = require('plist');
var _ = require('underscore');
......@@ -31,7 +29,7 @@ var CordovaError = require('cordova-common').CordovaError;
var cachedProjectFiles = {};
function parseProjectFile(locations) {
function parseProjectFile (locations) {
var project_dir = locations.root;
var pbxPath = locations.pbxproj;
......@@ -62,24 +60,24 @@ function parseProjectFile(locations) {
var resourcesDir = path.resolve(xcode_dir, 'Resources');
cachedProjectFiles[project_dir] = {
plugins_dir:pluginsDir,
resources_dir:resourcesDir,
xcode:xcodeproj,
xcode_path:xcode_dir,
plugins_dir: pluginsDir,
resources_dir: resourcesDir,
xcode: xcodeproj,
xcode_path: xcode_dir,
pbx: pbxPath,
projectDir: project_dir,
platformWww: path.join(project_dir, 'platform_www'),
www: path.join(project_dir, 'www'),
write: function () {
fs.writeFileSync(pbxPath, xcodeproj.writeSync());
if (Object.keys(this.frameworks).length === 0){
if (Object.keys(this.frameworks).length === 0) {
// If there is no framework references remain in the project, just remove this file
shell.rm('-rf', frameworks_file);
return;
}
fs.writeFileSync(frameworks_file, JSON.stringify(this.frameworks, null, 4));
},
getPackageName: function() {
getPackageName: function () {
return plist.parse(fs.readFileSync(plist_file, 'utf8')).CFBundleIdentifier;
},
getInstaller: function (name) {
......@@ -93,7 +91,7 @@ function parseProjectFile(locations) {
return cachedProjectFiles[project_dir];
}
function purgeProjectFileCache(project_dir) {
function purgeProjectFileCache (project_dir) {
delete cachedProjectFiles[project_dir];
}
......@@ -115,7 +113,7 @@ xcode.project.prototype.addToPbxEmbedFrameworksBuildPhase = function (file) {
xcode.project.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file) {
var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target);
if (sources) {
sources.files = _.reject(sources.files, function(file){
sources.files = _.reject(sources.files, function (file) {
return file.comment === longComment(file);
});
}
......@@ -124,13 +122,13 @@ xcode.project.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file)
// special handlers to add frameworks to the 'Embed Frameworks' build phase, needed for custom frameworks
// see CB-9517. should probably be moved to node-xcode.
var util = require('util');
function pbxBuildPhaseObj(file) {
function pbxBuildPhaseObj (file) {
var obj = Object.create(null);
obj.value = file.uuid;
obj.comment = longComment(file);
return obj;
}
function longComment(file) {
function longComment (file) {
return util.format('%s in %s', file.basename, file.group);
}
......@@ -17,32 +17,30 @@
under the License.
*/
/*jshint node: true*/
var Q = require('q'),
proc = require('child_process');
var Q = require('q');
var proc = require('child_process');
/**
* Run specified command with arguments
* Run specified command with arguments
* @param {String} cmd Command
* @param {Array} args Array of arguments that should be passed to command
* @param {String} opt_cwd Working directory for command
* @param {String} opt_verbosity Verbosity level for command stdout output, "verbose" by default
* @return {Promise} Promise either fullfilled or rejected with error code
*/
module.exports = function(cmd, args, opt_cwd) {
module.exports = function (cmd, args, opt_cwd) {
var d = Q.defer();
try {
var child = proc.spawn(cmd, args, {cwd: opt_cwd, stdio: 'inherit'});
child.on('exit', function(code) {
child.on('exit', function (code) {
if (code) {
d.reject('Error code ' + code + ' for command: ' + cmd + ' with args: ' + args);
} else {
d.resolve();
}
});
} catch(e) {
} catch (e) {
d.reject(e);
}
return d.promise;
......
......@@ -19,53 +19,51 @@
under the License.
*/
var child_process = require('child_process'),
Q = require('q');
var child_process = require('child_process');
var Q = require('q');
exports.get_apple_ios_version = function() {
exports.get_apple_ios_version = function () {
var d = Q.defer();
child_process.exec('xcodebuild -showsdks', function(error, stdout, stderr) {
child_process.exec('xcodebuild -showsdks', function (error, stdout, stderr) {
if (error) {
d.reject(stderr);
}
else {
} else {
d.resolve(stdout);
}
});
return d.promise.then(function(output) {
var regex = /[0-9]*\.[0-9]*/,
versions = [],
regexIOS = /^iOS \d+/;
return d.promise.then(function (output) {
var regex = /[0-9]*\.[0-9]*/;
var versions = [];
var regexIOS = /^iOS \d+/;
output = output.split('\n');
for (var i = 0; i < output.length; i++) {
if (output[i].trim().match(regexIOS)) {
versions[versions.length] = parseFloat(output[i].match(regex)[0]);
}
}
}
versions.sort();
console.log(versions[0]);
return Q();
}, function(stderr) {
}, function (stderr) {
return Q.reject(stderr);
});
};
exports.get_apple_osx_version = function() {
exports.get_apple_osx_version = function () {
var d = Q.defer();
child_process.exec('xcodebuild -showsdks', function(error, stdout, stderr) {
child_process.exec('xcodebuild -showsdks', function (error, stdout, stderr) {
if (error) {
d.reject(stderr);
}
else {
} else {
d.resolve(stdout);
}
});
return d.promise.then(function(output) {
var regex = /[0-9]*\.[0-9]*/,
versions = [],
regexOSX = /^OS X \d+/;
return d.promise.then(function (output) {
var regex = /[0-9]*\.[0-9]*/;
var versions = [];
var regexOSX = /^OS X \d+/;
output = output.split('\n');
for (var i = 0; i < output.length; i++) {
if (output[i].trim().match(regexOSX)) {
......@@ -75,14 +73,14 @@ exports.get_apple_osx_version = function() {
versions.sort();
console.log(versions[0]);
return Q();
}, function(stderr) {
}, function (stderr) {
return Q.reject(stderr);
});
};
exports.get_apple_xcode_version = function() {
exports.get_apple_xcode_version = function () {
var d = Q.defer();
child_process.exec('xcodebuild -version', function(error, stdout, stderr) {
child_process.exec('xcodebuild -version', function (error, stdout, stderr) {
var versionMatch = /Xcode (.*)/.exec(stdout);
if (error || !versionMatch) {
d.reject(stderr);
......@@ -98,9 +96,9 @@ exports.get_apple_xcode_version = function() {
* @return {Promise} Promise that either resolved with ios-deploy version
* or rejected in case of error
*/
exports.get_ios_deploy_version = function() {
exports.get_ios_deploy_version = function () {
var d = Q.defer();
child_process.exec('ios-deploy --version', function(error, stdout, stderr) {
child_process.exec('ios-deploy --version', function (error, stdout, stderr) {
if (error) {
d.reject(stderr);
} else {
......@@ -115,9 +113,9 @@ exports.get_ios_deploy_version = function() {
* @return {Promise} Promise that either resolved with pod version
* or rejected in case of error
*/
exports.get_cocoapods_version = function() {
exports.get_cocoapods_version = function () {
var d = Q.defer();
child_process.exec('pod --version', function(error, stdout, stderr) {
child_process.exec('pod --version', function (error, stdout, stderr) {
if (error) {
d.reject(stderr);
} else {
......@@ -132,9 +130,9 @@ exports.get_cocoapods_version = function() {
* @return {Promise} Promise that either resolved with ios-sim version
* or rejected in case of error
*/
exports.get_ios_sim_version = function() {
exports.get_ios_sim_version = function () {
var d = Q.defer();
child_process.exec('ios-sim --version', function(error, stdout, stderr) {
child_process.exec('ios-sim --version', function (error, stdout, stderr) {
if (error) {
d.reject(stderr);
} else {
......@@ -152,11 +150,11 @@ exports.get_ios_sim_version = function() {
*/
exports.get_tool_version = function (toolName) {
switch (toolName) {
case 'xcodebuild': return exports.get_apple_xcode_version();
case 'ios-sim': return exports.get_ios_sim_version();
case 'ios-deploy': return exports.get_ios_deploy_version();
case 'pod': return exports.get_cocoapods_version();
default: return Q.reject(toolName + ' is not valid tool name. Valid names are: \'xcodebuild\', \'ios-sim\', \'ios-deploy\', and \'pod\'');
case 'xcodebuild': return exports.get_apple_xcode_version();
case 'ios-sim': return exports.get_ios_sim_version();
case 'ios-deploy': return exports.get_ios_deploy_version();
case 'pod': return exports.get_cocoapods_version();
default: return Q.reject(toolName + ' is not valid tool name. Valid names are: \'xcodebuild\', \'ios-sim\', \'ios-deploy\', and \'pod\'');
}
};
......
......@@ -26,7 +26,7 @@
*/
// Coho updates this line
var VERSION="4.4.0";
var VERSION="4.5.1";
module.exports.version = VERSION;
......
......@@ -21,8 +21,11 @@
module.exports = {
id: 'ios',
bootstrap: function() {
bootstrap: function () {
// Attach the console polyfill that is iOS-only to window.console
// see the file under plugin/ios/console.js
require('cordova/modulemapper').clobbers('cordova/plugin/ios/console', 'window.console');
require('cordova/channel').onNativeReady.fire();
}
};
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
//------------------------------------------------------------------------------
var logger = require('cordova/plugin/ios/logger');
//------------------------------------------------------------------------------
// object that we're exporting
//------------------------------------------------------------------------------
var console = module.exports;
//------------------------------------------------------------------------------
// copy of the original console object
//------------------------------------------------------------------------------
var WinConsole = window.console;
//------------------------------------------------------------------------------
// whether to use the logger
//------------------------------------------------------------------------------
var UseLogger = false;
//------------------------------------------------------------------------------
// Timers
//------------------------------------------------------------------------------
var Timers = {};
//------------------------------------------------------------------------------
// used for unimplemented methods
//------------------------------------------------------------------------------
function noop() {}
//------------------------------------------------------------------------------
// used for unimplemented methods
//------------------------------------------------------------------------------
console.useLogger = function (value) {
if (arguments.length) UseLogger = !!value;
if (UseLogger) {
if (logger.useConsole()) {
throw new Error("console and logger are too intertwingly");
}
}
return UseLogger;
};
//------------------------------------------------------------------------------
console.log = function() {
if (logger.useConsole()) return;
logger.log.apply(logger, [].slice.call(arguments));
};
//------------------------------------------------------------------------------
console.error = function() {
if (logger.useConsole()) return;
logger.error.apply(logger, [].slice.call(arguments));
};
//------------------------------------------------------------------------------
console.warn = function() {
if (logger.useConsole()) return;
logger.warn.apply(logger, [].slice.call(arguments));
};
//------------------------------------------------------------------------------
console.info = function() {
if (logger.useConsole()) return;
logger.info.apply(logger, [].slice.call(arguments));
};
//------------------------------------------------------------------------------
console.debug = function() {
if (logger.useConsole()) return;
logger.debug.apply(logger, [].slice.call(arguments));
};
//------------------------------------------------------------------------------
console.assert = function(expression) {
if (expression) return;
var message = logger.format.apply(logger.format, [].slice.call(arguments, 1));
console.log("ASSERT: " + message);
};
//------------------------------------------------------------------------------
console.clear = function() {};
//------------------------------------------------------------------------------
console.dir = function(object) {
console.log("%o", object);
};
//------------------------------------------------------------------------------
console.dirxml = function(node) {
console.log(node.innerHTML);
};
//------------------------------------------------------------------------------
console.trace = noop;
//------------------------------------------------------------------------------
console.group = console.log;
//------------------------------------------------------------------------------
console.groupCollapsed = console.log;
//------------------------------------------------------------------------------
console.groupEnd = noop;
//------------------------------------------------------------------------------
console.time = function(name) {
Timers[name] = new Date().valueOf();
};
//------------------------------------------------------------------------------
console.timeEnd = function(name) {
var timeStart = Timers[name];
if (!timeStart) {
console.warn("unknown timer: " + name);
return;
}
var timeElapsed = new Date().valueOf() - timeStart;
console.log(name + ": " + timeElapsed + "ms");
};
//------------------------------------------------------------------------------
console.timeStamp = noop;
//------------------------------------------------------------------------------
console.profile = noop;
//------------------------------------------------------------------------------
console.profileEnd = noop;
//------------------------------------------------------------------------------
console.count = noop;
//------------------------------------------------------------------------------
console.exception = console.log;
//------------------------------------------------------------------------------
console.table = function(data, columns) {
console.log("%o", data);
};
//------------------------------------------------------------------------------
// return a new function that calls both functions passed as args
//------------------------------------------------------------------------------
function wrappedOrigCall(orgFunc, newFunc) {
return function() {
var args = [].slice.call(arguments);
try { orgFunc.apply(WinConsole, args); } catch (e) {}
try { newFunc.apply(console, args); } catch (e) {}
};
}
//------------------------------------------------------------------------------
// For every function that exists in the original console object, that
// also exists in the new console object, wrap the new console method
// with one that calls both
//------------------------------------------------------------------------------
for (var key in console) {
if (typeof WinConsole[key] == "function") {
console[key] = wrappedOrigCall(WinConsole[key], console[key]);
}
}
../node-uuid/bin/uuid
\ No newline at end of file
../uuid/bin/uuid
\ No newline at end of file
module.exports = exports = abbrev.abbrev = abbrev
abbrev.monkeyPatch = monkeyPatch
......
{
"_args": [
[
{
"raw": "abbrev@1",
"scope": null,
"escapedName": "abbrev",
"name": "abbrev",
"rawSpec": "1",
"spec": ">=1.0.0 <2.0.0",
"type": "range"
},
"/Users/shazron/Documents/git/apache/cordova-ios/node_modules/ios-sim/node_modules/nopt"
"abbrev@1.1.0",
"/Users/spindori/Documents/Cordova/cordova-ios"
]
],
"_from": "abbrev@>=1.0.0 <2.0.0",
"_id": "abbrev@1.0.9",
"_inCache": true,
"_from": "abbrev@1.1.0",
"_id": "abbrev@1.1.0",
"_inBundle": true,
"_integrity": "sha1-0FVMIlZjbi9W58LlrRg/hZQo2B8=",
"_location": "/cordova-ios/abbrev",
"_nodeVersion": "4.4.4",
"_npmOperationalInternal": {
"host": "packages-16-east.internal.npmjs.com",
"tmp": "tmp/abbrev-1.0.9.tgz_1466016055839_0.7825860097073019"
},
"_npmUser": {
"name": "isaacs",
"email": "i@izs.me"
},
"_npmVersion": "3.9.1",
"_phantomChildren": {},
"_requested": {
"raw": "abbrev@1",
"scope": null,
"escapedName": "abbrev",
"type": "version",
"registry": true,
"raw": "abbrev@1.1.0",
"name": "abbrev",
"rawSpec": "1",
"spec": ">=1.0.0 <2.0.0",
"type": "range"
"escapedName": "abbrev",
"rawSpec": "1.1.0",
"saveSpec": null,
"fetchSpec": "1.1.0"
},
"_requiredBy": [
"/cordova-ios/ios-sim/nopt",
"/cordova-ios/nopt"
],
"_resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz",
"_shasum": "91b4792588a7738c25f35dd6f63752a2f8776135",
"_shrinkwrap": null,
"_spec": "abbrev@1",
"_where": "/Users/shazron/Documents/git/apache/cordova-ios/node_modules/ios-sim/node_modules/nopt",
"_resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz",
"_spec": "1.1.0",
"_where": "/Users/spindori/Documents/Cordova/cordova-ios",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me"
......@@ -53,38 +35,26 @@
"bugs": {
"url": "https://github.com/isaacs/abbrev-js/issues"
},
"dependencies": {},
"description": "Like ruby's abbrev module, but in js",
"devDependencies": {
"tap": "^5.7.2"
},
"directories": {},
"dist": {
"shasum": "91b4792588a7738c25f35dd6f63752a2f8776135",
"tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz"
"tap": "^10.1"
},
"files": [
"abbrev.js"
],
"gitHead": "c386cd9dbb1d8d7581718c54d4ba944cc9298d6f",
"homepage": "https://github.com/isaacs/abbrev-js#readme",
"license": "ISC",
"main": "abbrev.js",
"maintainers": [
{
"name": "isaacs",
"email": "i@izs.me"
}
],
"name": "abbrev",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/isaacs/abbrev-js.git"
},
"scripts": {
"test": "tap test.js --cov"
"postpublish": "git push origin --all; git push origin --tags",
"postversion": "npm publish",
"preversion": "npm test",
"test": "tap test.js --100"
},
"version": "1.0.9"
"version": "1.1.0"
}
{
"_args": [
[
{
"raw": "ansi@^0.3.1",
"scope": null,
"escapedName": "ansi",
"name": "ansi",
"rawSpec": "^0.3.1",
"spec": ">=0.3.1 <0.4.0",
"type": "range"
},
"/Users/shazron/Documents/git/apache/cordova-ios/node_modules/cordova-common"
"ansi@0.3.1",
"/Users/spindori/Documents/Cordova/cordova-ios"
]
],
"_from": "ansi@>=0.3.1 <0.4.0",
"_from": "ansi@0.3.1",
"_id": "ansi@0.3.1",
"_inCache": true,
"_inBundle": true,
"_integrity": "sha1-DELU+xcWDVqa8eSEus4cZpIsGyE=",
"_location": "/cordova-ios/ansi",
"_nodeVersion": "5.3.0",
"_npmUser": {
"name": "tootallnate",
"email": "nathan@tootallnate.net"
},
"_npmVersion": "3.3.12",
"_phantomChildren": {},
"_requested": {
"raw": "ansi@^0.3.1",
"scope": null,
"escapedName": "ansi",
"type": "version",
"registry": true,
"raw": "ansi@0.3.1",
"name": "ansi",
"rawSpec": "^0.3.1",
"spec": ">=0.3.1 <0.4.0",
"type": "range"
"escapedName": "ansi",
"rawSpec": "0.3.1",
"saveSpec": null,
"fetchSpec": "0.3.1"
},
"_requiredBy": [
"/cordova-ios/cordova-common"
],
"_resolved": "https://registry.npmjs.org/ansi/-/ansi-0.3.1.tgz",
"_shasum": "0c42d4fb17160d5a9af1e484bace1c66922c1b21",
"_shrinkwrap": null,
"_spec": "ansi@^0.3.1",
"_where": "/Users/shazron/Documents/git/apache/cordova-ios/node_modules/cordova-common",
"_spec": "0.3.1",
"_where": "/Users/spindori/Documents/Cordova/cordova-ios",
"author": {
"name": "Nathan Rajlich",
"email": "nathan@tootallnate.net",
......@@ -49,15 +35,7 @@
"bugs": {
"url": "https://github.com/TooTallNate/ansi.js/issues"
},
"dependencies": {},
"description": "Advanced ANSI formatting tool for Node.js",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "0c42d4fb17160d5a9af1e484bace1c66922c1b21",
"tarball": "https://registry.npmjs.org/ansi/-/ansi-0.3.1.tgz"
},
"gitHead": "4d0d4af94e0bdaa648bd7262acd3bde4b98d5246",
"homepage": "https://github.com/TooTallNate/ansi.js#readme",
"keywords": [
"ansi",
......@@ -71,23 +49,10 @@
],
"license": "MIT",
"main": "./lib/ansi.js",
"maintainers": [
{
"name": "TooTallNate",
"email": "nathan@tootallnate.net"
},
{
"name": "tootallnate",
"email": "nathan@tootallnate.net"
}
],
"name": "ansi",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/TooTallNate/ansi.js.git"
},
"scripts": {},
"version": "0.3.1"
}
'use strict';
module.exports = balanced;
function balanced(a, b, str) {
if (a instanceof RegExp) a = maybeMatch(a, str);
......
{
"_args": [
[
{
"raw": "balanced-match@^0.4.1",
"scope": null,
"escapedName": "balanced-match",
"name": "balanced-match",
"rawSpec": "^0.4.1",
"spec": ">=0.4.1 <0.5.0",
"type": "range"
},
"/Users/shazron/Documents/git/apache/cordova-ios/node_modules/brace-expansion"
"balanced-match@1.0.0",
"/Users/spindori/Documents/Cordova/cordova-ios"
]
],
"_from": "balanced-match@>=0.4.1 <0.5.0",
"_id": "balanced-match@0.4.2",
"_inCache": true,
"_from": "balanced-match@1.0.0",
"_id": "balanced-match@1.0.0",
"_inBundle": true,
"_integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"_location": "/cordova-ios/balanced-match",
"_nodeVersion": "4.4.7",
"_npmOperationalInternal": {
"host": "packages-16-east.internal.npmjs.com",
"tmp": "tmp/balanced-match-0.4.2.tgz_1468834991581_0.6590619895141572"
},
"_npmUser": {
"name": "juliangruber",
"email": "julian@juliangruber.com"
},
"_npmVersion": "2.15.8",
"_phantomChildren": {},
"_requested": {
"raw": "balanced-match@^0.4.1",
"scope": null,
"escapedName": "balanced-match",
"type": "version",
"registry": true,
"raw": "balanced-match@1.0.0",
"name": "balanced-match",
"rawSpec": "^0.4.1",
"spec": ">=0.4.1 <0.5.0",
"type": "range"
"escapedName": "balanced-match",
"rawSpec": "1.0.0",
"saveSpec": null,
"fetchSpec": "1.0.0"
},
"_requiredBy": [
"/cordova-ios/brace-expansion"
],
"_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz",
"_shasum": "cb3f3e3c732dc0f01ee70b403f302e61d7709838",
"_shrinkwrap": null,
"_spec": "balanced-match@^0.4.1",
"_where": "/Users/shazron/Documents/git/apache/cordova-ios/node_modules/brace-expansion",
"_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"_spec": "1.0.0",
"_where": "/Users/spindori/Documents/Cordova/cordova-ios",
"author": {
"name": "Julian Gruber",
"email": "mail@juliangruber.com",
......@@ -56,14 +38,9 @@
"dependencies": {},
"description": "Match balanced character pairs, like \"{\" and \"}\"",
"devDependencies": {
"matcha": "^0.7.0",
"tape": "^4.6.0"
},
"directories": {},
"dist": {
"shasum": "cb3f3e3c732dc0f01ee70b403f302e61d7709838",
"tarball": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz"
},
"gitHead": "57c2ea29d89a2844ae3bdcc637c6e2cbb73725e2",
"homepage": "https://github.com/juliangruber/balanced-match",
"keywords": [
"match",
......@@ -74,20 +51,13 @@
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "juliangruber",
"email": "julian@juliangruber.com"
}
],
"name": "balanced-match",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/juliangruber/balanced-match.git"
},
"scripts": {
"bench": "make bench",
"test": "make test"
},
"testling": {
......@@ -106,5 +76,5 @@
"android-browser/4.2..latest"
]
},
"version": "0.4.2"
"version": "1.0.0"
}
{
"_args": [
[
{
"raw": "base64-js@0.0.8",
"scope": null,
"escapedName": "base64-js",
"name": "base64-js",
"rawSpec": "0.0.8",
"spec": "0.0.8",
"type": "version"
},
"/Users/shazron/Documents/git/apache/cordova-ios/node_modules/plist"
"base64-js@0.0.8",
"/Users/spindori/Documents/Cordova/cordova-ios"
]
],
"_from": "base64-js@0.0.8",
"_id": "base64-js@0.0.8",
"_inCache": true,
"_inBundle": true,
"_integrity": "sha1-EQHpVE9KdrG8OybUUsqW16NeeXg=",
"_location": "/cordova-ios/base64-js",
"_nodeVersion": "0.10.35",
"_npmUser": {
"name": "feross",
"email": "feross@feross.org"
},
"_npmVersion": "2.1.16",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "base64-js@0.0.8",
"scope": null,
"escapedName": "base64-js",
"name": "base64-js",
"escapedName": "base64-js",
"rawSpec": "0.0.8",
"spec": "0.0.8",
"type": "version"
"saveSpec": null,
"fetchSpec": "0.0.8"
},
"_requiredBy": [
"/cordova-ios/plist"
],
"_resolved": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz",
"_shasum": "1101e9544f4a76b1bc3b26d452ca96d7a35e7978",
"_shrinkwrap": null,
"_spec": "base64-js@0.0.8",
"_where": "/Users/shazron/Documents/git/apache/cordova-ios/node_modules/plist",
"_spec": "0.0.8",
"_where": "/Users/spindori/Documents/Cordova/cordova-ios",
"author": {
"name": "T. Jameson Little",
"email": "t.jameson.little@gmail.com"
......@@ -53,31 +39,13 @@
"devDependencies": {
"tape": "~2.3.2"
},
"directories": {},
"dist": {
"shasum": "1101e9544f4a76b1bc3b26d452ca96d7a35e7978",
"tarball": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz"
},
"engines": {
"node": ">= 0.4"
},
"gitHead": "b4a8a5fa9b0caeddb5ad94dd1108253d8f2a315f",
"homepage": "https://github.com/beatgammit/base64-js",
"homepage": "https://github.com/beatgammit/base64-js#readme",
"license": "MIT",
"main": "lib/b64.js",
"maintainers": [
{
"name": "beatgammit",
"email": "t.jameson.little@gmail.com"
},
{
"name": "feross",
"email": "feross@feross.org"
}
],
"name": "base64-js",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/beatgammit/base64-js.git"
......
......@@ -118,7 +118,7 @@ var bigInt = (function (undefined) {
}
BigInteger.prototype.add = function (v) {
var value, n = parseValue(v);
var n = parseValue(v);
if (this.sign !== n.sign) {
return this.subtract(n.negate());
}
......@@ -177,7 +177,7 @@ var bigInt = (function (undefined) {
}
function subtractAny(a, b, sign) {
var value, isSmall;
var value;
if (compareAbs(a, b) >= 0) {
value = subtract(a,b);
} else {
......@@ -326,7 +326,7 @@ var bigInt = (function (undefined) {
}
BigInteger.prototype.multiply = function (v) {
var value, n = parseValue(v),
var n = parseValue(v),
a = this.value, b = n.value,
sign = this.sign !== n.sign,
abs;
......@@ -467,6 +467,7 @@ var bigInt = (function (undefined) {
guess, xlen, highx, highy, check;
while (a_l) {
part.unshift(a[--a_l]);
trim(part);
if (compareAbs(part, b) < 0) {
result.push(0);
continue;
......@@ -825,20 +826,24 @@ var bigInt = (function (undefined) {
BigInteger.prototype.modInv = function (n) {
var t = bigInt.zero, newT = bigInt.one, r = parseValue(n), newR = this.abs(), q, lastT, lastR;
while (!newR.equals(bigInt.zero)) {
q = r.divide(newR);
lastT = t;
lastR = r;
t = newT;
r = newR;
newT = lastT.subtract(q.multiply(newT));
newR = lastR.subtract(q.multiply(newR));
q = r.divide(newR);
lastT = t;
lastR = r;
t = newT;
r = newR;
newT = lastT.subtract(q.multiply(newT));
newR = lastR.subtract(q.multiply(newR));
}
if (!r.equals(1)) throw new Error(this.toString() + " and " + n.toString() + " are not co-prime");
if (t.compare(0) === -1) {
t = t.add(n);
t = t.add(n);
}
if (this.isNegative()) {
return t.negate();
}
return t;
}
};
SmallInteger.prototype.modInv = BigInteger.prototype.modInv;
BigInteger.prototype.next = function () {
......@@ -977,7 +982,7 @@ var bigInt = (function (undefined) {
b = parseValue(b);
return a.greater(b) ? a : b;
}
function min(a,b) {
function min(a, b) {
a = parseValue(a);
b = parseValue(b);
return a.lesser(b) ? a : b;
......@@ -1032,16 +1037,32 @@ var bigInt = (function (undefined) {
return low.add(typeof result === "number" ? new SmallInteger(result) : new BigInteger(result, false));
}
var parseBase = function (text, base) {
var val = Integer[0], pow = Integer[1],
length = text.length;
var 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 (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));
}
}
base = parseValue(base);
var digits = [];
var i;
var isNegative = text[0] === "-";
for (i = isNegative ? 1 : 0; i < text.length; i++) {
var c = text[i].toLowerCase(),
......@@ -1055,13 +1076,17 @@ var bigInt = (function (undefined) {
}
else throw new Error(c + " is not a valid character");
}
digits.reverse();
for (i = 0; i < digits.length; i++) {
return parseBaseFromArray(digits, base, isNegative);
};
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));
pow = pow.times(base);
}
return isNegative ? val.negate() : val;
};
}
function stringify(digit) {
var v = digit.value;
......@@ -1118,11 +1143,13 @@ var bigInt = (function (undefined) {
var sign = this.sign ? "-" : "";
return sign + str;
};
SmallInteger.prototype.toString = function (radix) {
if (radix === undefined) radix = 10;
if (radix != 10) return toBase(this, radix);
return String(this.value);
};
BigInteger.prototype.toJSON = SmallInteger.prototype.toJSON = function() { return this.toString(); }
BigInteger.prototype.valueOf = function () {
return +this.toString();
......@@ -1205,6 +1232,11 @@ var bigInt = (function (undefined) {
Integer.lcm = lcm;
Integer.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger; };
Integer.randBetween = randBetween;
Integer.fromArray = function (digits, base, isNegative) {
return parseBaseFromArray(digits.map(parseValue), parseValue(base || 10), isNegative);
};
return Integer;
})();
......@@ -1212,3 +1244,10 @@ var bigInt = (function (undefined) {
if (typeof module !== "undefined" && module.hasOwnProperty("exports")) {
module.exports = bigInt;
}
//amd check
if ( typeof define === "function" && define.amd ) {
define( "big-integer", [], function() {
return bigInt;
});
}
......@@ -211,7 +211,7 @@ Returns `true` if the number is prime, `false` otherwise.
#### `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.
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
#### `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)`
Finds the greatest common denominator of `a` and `b`.
......@@ -510,4 +517,4 @@ There are performance benchmarks that can be viewed from the `benchmarks/index.h
## License
This project is public domain. For more details, read about the [Unlicense](http://unlicense.org/).
\ No newline at end of file
This project is public domain. For more details, read about the [Unlicense](http://unlicense.org/).
......@@ -24,7 +24,6 @@
"bower_components",
"test",
"coverage",
"spec",
"tests"
]
}
{
"_args": [
[
{
"raw": "big-integer@^1.6.7",
"scope": null,
"escapedName": "big-integer",
"name": "big-integer",
"rawSpec": "^1.6.7",
"spec": ">=1.6.7 <2.0.0",
"type": "range"
},
"/Users/shazron/Documents/git/apache/cordova-ios/node_modules/bplist-parser"
"big-integer@1.6.25",
"/Users/spindori/Documents/Cordova/cordova-ios"
]
],
"_from": "big-integer@>=1.6.7 <2.0.0",
"_id": "big-integer@1.6.17",
"_inCache": true,
"_from": "big-integer@1.6.25",
"_id": "big-integer@1.6.25",
"_inBundle": true,
"_integrity": "sha1-HeRan1dUKsIBIcaC+NZCIgo06CM=",
"_location": "/cordova-ios/big-integer",
"_nodeVersion": "4.4.5",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/big-integer-1.6.17.tgz_1478721202721_0.8068355675786734"
},
"_npmUser": {
"name": "peterolson",
"email": "peter.e.c.olson+npm@gmail.com"
},
"_npmVersion": "2.15.5",
"_phantomChildren": {},
"_requested": {
"raw": "big-integer@^1.6.7",
"scope": null,
"escapedName": "big-integer",
"type": "version",
"registry": true,
"raw": "big-integer@1.6.25",
"name": "big-integer",
"rawSpec": "^1.6.7",
"spec": ">=1.6.7 <2.0.0",
"type": "range"
"escapedName": "big-integer",
"rawSpec": "1.6.25",
"saveSpec": null,
"fetchSpec": "1.6.25"
},
"_requiredBy": [
"/cordova-ios/bplist-parser"
],
"_resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.17.tgz",
"_shasum": "f0dcf5109a949e42a993ee3e8fb2070452817b51",
"_shrinkwrap": null,
"_spec": "big-integer@^1.6.7",
"_where": "/Users/shazron/Documents/git/apache/cordova-ios/node_modules/bplist-parser",
"_resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.25.tgz",
"_spec": "1.6.25",
"_where": "/Users/spindori/Documents/Cordova/cordova-ios",
"author": {
"name": "Peter Olson",
"email": "peter.e.c.olson+npm@gmail.com"
......@@ -54,26 +36,24 @@
"url": "https://github.com/peterolson/BigInteger.js/issues"
},
"contributors": [],
"dependencies": {},
"description": "An arbitrary length integer library for Javascript",
"devDependencies": {
"@types/lodash": "^4.14.64",
"@types/node": "^7.0.22",
"coveralls": "^2.11.4",
"jasmine": "2.1.x",
"jasmine-core": "^2.3.4",
"karma": "^0.13.3",
"karma-coverage": "^0.4.2",
"karma-jasmine": "^0.3.6",
"karma-phantomjs-launcher": "~0.1"
},
"directories": {},
"dist": {
"shasum": "f0dcf5109a949e42a993ee3e8fb2070452817b51",
"tarball": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.17.tgz"
"karma-phantomjs-launcher": "^1.0.4",
"lodash": "^4.17.4",
"typescript": "^2.3.3",
"uglifyjs": "^2.4.10"
},
"engines": {
"node": ">=0.6"
},
"gitHead": "d25d0bfcd96f31001ec8572c8d01de4770d99e63",
"homepage": "https://github.com/peterolson/BigInteger.js#readme",
"keywords": [
"math",
......@@ -88,21 +68,15 @@
],
"license": "Unlicense",
"main": "./BigInteger",
"maintainers": [
{
"name": "peterolson",
"email": "peter.e.c.olson+npm@gmail.com"
}
],
"name": "big-integer",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/peterolson/BigInteger.js.git"
},
"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"
}
{
"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"
]
}
\ No newline at end of file
......@@ -128,6 +128,9 @@ module.exports = function(dicts) {
case 'double':
writeNumber(entry);
break;
case 'UID':
writeUID(entry);
break;
case 'array':
writeArray(entry);
break;
......@@ -138,6 +141,9 @@ module.exports = function(dicts) {
case 'string-utf16':
writeString(entry);
break;
case 'date':
writeDate(entry);
break;
case 'data':
writeData(entry);
break;
......@@ -146,6 +152,12 @@ module.exports = function(dicts) {
}
}
function writeDate(entry) {
writeByte(0x33);
var date = (Date.parse(entry.value)/1000) - 978307200
writeDouble(date)
}
function writeDict(entry) {
if (debug) {
var keysStr = entry.entryKeys.map(function(k) {return k.id;});
......@@ -189,6 +201,15 @@ module.exports = function(dicts) {
}
}
function writeUID(entry) {
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeUID', entry.value, ' (type: ' + entry.type + ')', '(id: ' + entry.id + ')');
}
writeIntHeader(0x8, 0x0);
writeID(entry.value);
}
function writeArray(entry) {
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeArray (length: ' + entry.entries.length + ')', '(id: ' + entry.id + ')');
......@@ -210,7 +231,7 @@ module.exports = function(dicts) {
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeString', entry.value, '(id: ' + entry.id + ')');
}
if (entry.type === 'string-utf16') {
if (entry.type === 'string-utf16' || mustBeUtf16(entry.value)) {
var utf16 = new Buffer(entry.value, 'ucs2');
writeIntHeader(0x6, utf16.length / 2);
// needs to be big endian so swap the bytes
......@@ -221,7 +242,7 @@ module.exports = function(dicts) {
}
buffer.write(utf16);
} else {
var utf8 = new Buffer(entry.value, 'utf8');
var utf8 = new Buffer(entry.value, 'ascii');
writeIntHeader(0x5, utf8.length);
buffer.write(utf8);
}
......@@ -285,6 +306,10 @@ module.exports = function(dicts) {
}
buffer.write(buf);
}
function mustBeUtf16(string) {
return Buffer.byteLength(string, 'utf8') != string.length;
}
};
function toEntries(dicts) {
......@@ -309,7 +334,23 @@ function toEntries(dicts) {
}
];
} else if (typeof(dicts) === 'object') {
return toEntriesObject(dicts);
if (dicts instanceof Date) {
return [
{
type: 'date',
value: dicts
}
]
} else if (Object.keys(dicts).length == 1 && typeof(dicts.UID) === 'number') {
return [
{
type: 'UID',
value: dicts.UID
}
]
} else {
return toEntriesObject(dicts);
}
} else if (typeof(dicts) === 'string') {
return [
{
......
{
"_args": [
[
{
"raw": "bplist-creator@0.0.4",
"scope": null,
"escapedName": "bplist-creator",
"name": "bplist-creator",
"rawSpec": "0.0.4",
"spec": "0.0.4",
"type": "version"
},
"/Users/shazron/Documents/git/apache/cordova-ios/node_modules/simple-plist"
"bplist-creator@0.0.7",
"/Users/spindori/Documents/Cordova/cordova-ios"
]
],
"_from": "bplist-creator@0.0.4",
"_id": "bplist-creator@0.0.4",
"_inCache": true,
"_from": "bplist-creator@0.0.7",
"_id": "bplist-creator@0.0.7",
"_inBundle": true,
"_integrity": "sha1-N98VNgkoJLh8QvlXsBNEEXNyrkU=",
"_location": "/cordova-ios/bplist-creator",
"_npmUser": {
"name": "joeferner",
"email": "joe@fernsroth.com"
},
"_npmVersion": "1.4.10",
"_phantomChildren": {},
"_requested": {
"raw": "bplist-creator@0.0.4",
"scope": null,
"escapedName": "bplist-creator",
"type": "version",
"registry": true,
"raw": "bplist-creator@0.0.7",
"name": "bplist-creator",
"rawSpec": "0.0.4",
"spec": "0.0.4",
"type": "version"
"escapedName": "bplist-creator",
"rawSpec": "0.0.7",
"saveSpec": null,
"fetchSpec": "0.0.7"
},
"_requiredBy": [
"/cordova-ios/simple-plist"
],
"_resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.0.4.tgz",
"_shasum": "4ac0496782e127a85c1d2026a4f5eb22a7aff991",
"_shrinkwrap": null,
"_spec": "bplist-creator@0.0.4",
"_where": "/Users/shazron/Documents/git/apache/cordova-ios/node_modules/simple-plist",
"_resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.0.7.tgz",
"_spec": "0.0.7",
"_where": "/Users/spindori/Documents/Cordova/cordova-ios",
"author": {
"name": "https://github.com/nearinfinity/node-bplist-parser.git"
},
......@@ -47,19 +34,14 @@
"url": "https://github.com/nearinfinity/node-bplist-creator/issues"
},
"dependencies": {
"stream-buffers": "~0.2.3"
"stream-buffers": "~2.2.0"
},
"description": "Binary Mac OS X Plist (property list) creator.",
"devDependencies": {
"bplist-parser": "0.0.4",
"nodeunit": "0.7.4"
"bplist-parser": "~0.1.0",
"nodeunit": "0.9.1"
},
"directories": {},
"dist": {
"shasum": "4ac0496782e127a85c1d2026a4f5eb22a7aff991",
"tarball": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.0.4.tgz"
},
"homepage": "https://github.com/nearinfinity/node-bplist-creator",
"homepage": "https://github.com/nearinfinity/node-bplist-creator#readme",
"keywords": [
"bplist",
"plist",
......@@ -67,15 +49,7 @@
],
"license": "MIT",
"main": "bplistCreator.js",
"maintainers": [
{
"name": "joeferner",
"email": "joe@fernsroth.com"
}
],
"name": "bplist-creator",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/nearinfinity/node-bplist-creator.git"
......@@ -83,5 +57,5 @@
"scripts": {
"test": "./node_modules/nodeunit/bin/nodeunit test"
},
"version": "0.0.4"
"version": "0.0.7"
}
{
"_args": [
[
{
"raw": "bplist-parser@^0.1.0",
"scope": null,
"escapedName": "bplist-parser",
"name": "bplist-parser",
"rawSpec": "^0.1.0",
"spec": ">=0.1.0 <0.2.0",
"type": "range"
},
"/Users/shazron/Documents/git/apache/cordova-ios/node_modules/cordova-common"
"bplist-parser@0.1.1",
"/Users/spindori/Documents/Cordova/cordova-ios"
]
],
"_from": "bplist-parser@>=0.1.0 <0.2.0",
"_from": "bplist-parser@0.1.1",
"_id": "bplist-parser@0.1.1",
"_inCache": true,
"_inBundle": true,
"_integrity": "sha1-1g1dzCDLptx+HymbNdPh+V2vuuY=",
"_location": "/cordova-ios/bplist-parser",
"_nodeVersion": "5.1.0",
"_npmUser": {
"name": "joeferner",
"email": "joe@fernsroth.com"
},
"_npmVersion": "3.4.0",
"_phantomChildren": {},
"_requested": {
"raw": "bplist-parser@^0.1.0",
"scope": null,
"escapedName": "bplist-parser",
"type": "version",
"registry": true,
"raw": "bplist-parser@0.1.1",
"name": "bplist-parser",
"rawSpec": "^0.1.0",
"spec": ">=0.1.0 <0.2.0",
"type": "range"
"escapedName": "bplist-parser",
"rawSpec": "0.1.1",
"saveSpec": null,
"fetchSpec": "0.1.1"
},
"_requiredBy": [
"/cordova-ios/cordova-common",
"/cordova-ios/xcode/simple-plist"
"/cordova-ios/simple-plist"
],
"_resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.1.1.tgz",
"_shasum": "d60d5dcc20cba6dc7e1f299b35d3e1f95dafbae6",
"_shrinkwrap": null,
"_spec": "bplist-parser@^0.1.0",
"_where": "/Users/shazron/Documents/git/apache/cordova-ios/node_modules/cordova-common",
"_spec": "0.1.1",
"_where": "/Users/spindori/Documents/Cordova/cordova-ios",
"author": {
"name": "Joe Ferner",
"email": "joe.ferner@nearinfinity.com"
......@@ -56,12 +42,6 @@
"devDependencies": {
"nodeunit": "~0.9.1"
},
"directories": {},
"dist": {
"shasum": "d60d5dcc20cba6dc7e1f299b35d3e1f95dafbae6",
"tarball": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.1.1.tgz"
},
"gitHead": "c4f22650de2cc95edd21a6e609ff0654a2b951bd",
"homepage": "https://github.com/nearinfinity/node-bplist-parser#readme",
"keywords": [
"bplist",
......@@ -70,15 +50,7 @@
],
"license": "MIT",
"main": "bplistParser.js",
"maintainers": [
{
"name": "joeferner",
"email": "joe@fernsroth.com"
}
],
"name": "bplist-parser",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/nearinfinity/node-bplist-parser.git"
......
......@@ -5,6 +5,7 @@ as known from sh/bash, in JavaScript.
[![build status](https://secure.travis-ci.org/juliangruber/brace-expansion.svg)](http://travis-ci.org/juliangruber/brace-expansion)
[![downloads](https://img.shields.io/npm/dm/brace-expansion.svg)](https://www.npmjs.org/package/brace-expansion)
[![Greenkeeper badge](https://badges.greenkeeper.io/juliangruber/brace-expansion.svg)](https://greenkeeper.io/)
[![testling badge](https://ci.testling.com/juliangruber/brace-expansion.png)](https://ci.testling.com/juliangruber/brace-expansion)
......
......@@ -106,7 +106,7 @@ function expand(str, isTop) {
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
var isSequence = isNumericSequence || isAlphaSequence;
var isOptions = /^(.*,)+(.+)?$/.test(m.body);
var isOptions = m.body.indexOf(',') >= 0;
if (!isSequence && !isOptions) {
// {a},b}
if (m.post.match(/,.*\}/)) {
......
{
"_args": [
[
{
"raw": "brace-expansion@^1.0.0",
"scope": null,
"escapedName": "brace-expansion",
"name": "brace-expansion",
"rawSpec": "^1.0.0",
"spec": ">=1.0.0 <2.0.0",
"type": "range"
},
"/Users/shazron/Documents/git/apache/cordova-ios/node_modules/minimatch"
"brace-expansion@1.1.8",
"/Users/spindori/Documents/Cordova/cordova-ios"
]
],
"_from": "brace-expansion@>=1.0.0 <2.0.0",
"_id": "brace-expansion@1.1.6",
"_inCache": true,
"_from": "brace-expansion@1.1.8",
"_id": "brace-expansion@1.1.8",
"_inBundle": true,
"_integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=",
"_location": "/cordova-ios/brace-expansion",
"_nodeVersion": "4.4.7",
"_npmOperationalInternal": {
"host": "packages-16-east.internal.npmjs.com",
"tmp": "tmp/brace-expansion-1.1.6.tgz_1469047715600_0.9362958471756428"
},
"_npmUser": {
"name": "juliangruber",
"email": "julian@juliangruber.com"
},
"_npmVersion": "2.15.8",
"_phantomChildren": {},
"_requested": {
"raw": "brace-expansion@^1.0.0",
"scope": null,
"escapedName": "brace-expansion",
"type": "version",
"registry": true,
"raw": "brace-expansion@1.1.8",
"name": "brace-expansion",
"rawSpec": "^1.0.0",
"spec": ">=1.0.0 <2.0.0",
"type": "range"
"escapedName": "brace-expansion",
"rawSpec": "1.1.8",
"saveSpec": null,
"fetchSpec": "1.1.8"
},
"_requiredBy": [
"/cordova-ios/minimatch"
],
"_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz",
"_shasum": "7197d7eaa9b87e648390ea61fc66c84427420df9",
"_shrinkwrap": null,
"_spec": "brace-expansion@^1.0.0",
"_where": "/Users/shazron/Documents/git/apache/cordova-ios/node_modules/minimatch",
"_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
"_spec": "1.1.8",
"_where": "/Users/spindori/Documents/Cordova/cordova-ios",
"author": {
"name": "Julian Gruber",
"email": "mail@juliangruber.com",
......@@ -54,41 +36,25 @@
"url": "https://github.com/juliangruber/brace-expansion/issues"
},
"dependencies": {
"balanced-match": "^0.4.1",
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
},
"description": "Brace expansion as known from sh/bash",
"devDependencies": {
"matcha": "^0.7.0",
"tape": "^4.6.0"
},
"directories": {},
"dist": {
"shasum": "7197d7eaa9b87e648390ea61fc66c84427420df9",
"tarball": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz"
},
"gitHead": "791262fa06625e9c5594cde529a21d82086af5f2",
"homepage": "https://github.com/juliangruber/brace-expansion",
"keywords": [],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "juliangruber",
"email": "julian@juliangruber.com"
},
{
"name": "isaacs",
"email": "isaacs@npmjs.com"
}
],
"name": "brace-expansion",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/juliangruber/brace-expansion.git"
},
"scripts": {
"bench": "matcha test/perf/bench.js",
"gentest": "bash test/generate.sh",
"test": "tape test/*.js"
},
......@@ -108,5 +74,5 @@
"android-browser/4.2..latest"
]
},
"version": "1.1.6"
"version": "1.1.8"
}
{
"_args": [
[
{
"raw": "concat-map@0.0.1",
"scope": null,
"escapedName": "concat-map",
"name": "concat-map",
"rawSpec": "0.0.1",
"spec": "0.0.1",
"type": "version"
},
"/Users/shazron/Documents/git/apache/cordova-ios/node_modules/brace-expansion"
"concat-map@0.0.1",
"/Users/spindori/Documents/Cordova/cordova-ios"
]
],
"_from": "concat-map@0.0.1",
"_id": "concat-map@0.0.1",
"_inCache": true,
"_inBundle": true,
"_integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"_location": "/cordova-ios/concat-map",
"_npmUser": {
"name": "substack",
"email": "mail@substack.net"
},
"_npmVersion": "1.3.21",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "concat-map@0.0.1",
"scope": null,
"escapedName": "concat-map",
"name": "concat-map",
"escapedName": "concat-map",
"rawSpec": "0.0.1",
"spec": "0.0.1",
"type": "version"
"saveSpec": null,
"fetchSpec": "0.0.1"
},
"_requiredBy": [
"/cordova-ios/brace-expansion"
],
"_resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"_shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b",
"_shrinkwrap": null,
"_spec": "concat-map@0.0.1",
"_where": "/Users/shazron/Documents/git/apache/cordova-ios/node_modules/brace-expansion",
"_spec": "0.0.1",
"_where": "/Users/spindori/Documents/Cordova/cordova-ios",
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
......@@ -48,7 +35,6 @@
"bugs": {
"url": "https://github.com/substack/node-concat-map/issues"
},
"dependencies": {},
"description": "concatenative mapdashery",
"devDependencies": {
"tape": "~2.4.0"
......@@ -57,11 +43,7 @@
"example": "example",
"test": "test"
},
"dist": {
"shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b",
"tarball": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz"
},
"homepage": "https://github.com/substack/node-concat-map",
"homepage": "https://github.com/substack/node-concat-map#readme",
"keywords": [
"concat",
"concatMap",
......@@ -71,15 +53,7 @@
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "substack",
"email": "mail@substack.net"
}
],
"name": "concat-map",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/substack/node-concat-map.git"
......
root: true
extends: semistandard
rules:
indent:
- error
- 4
camelcase: off
padded-blocks: off
operator-linebreak: off
no-throw-literal: off
\ No newline at end of file
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
......@@ -19,6 +19,10 @@
#
-->
[![Build status](https://ci.appveyor.com/api/projects/status/wxkmo0jalsr8gane?svg=true)](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-common/branch/master)
[![Build Status](https://travis-ci.org/apache/cordova-common.svg?branch=master)](https://travis-ci.org/apache/cordova-common)
[![NPM](https://nodei.co/npm/cordova-common.png)](https://nodei.co/npm/cordova-common/)
# cordova-common
Expoeses shared functionality used by [cordova-lib](https://github.com/apache/cordova-lib/) and Cordova platforms.
## Exposed APIs
......
......@@ -20,6 +20,21 @@
-->
# 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
......
# 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
{
"_from": "cordova-common@2.0.2",
"_id": "cordova-common@2.0.2",
"_args": [
[
"cordova-common@2.1.0",
"/Users/spindori/Documents/Cordova/cordova-ios"
]
],
"_from": "cordova-common@2.1.0",
"_id": "cordova-common@2.1.0",
"_inBundle": true,
"_integrity": "sha1-uzV+4bmCUDHtnbPFa1ku/pc9FkA=",
"_location": "/cordova-ios/cordova-common",
"_nodeVersion": "4.7.3",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/cordova-common-2.0.2.tgz_1492453798445_0.6290795875247568"
},
"_npmUser": {
"name": "shazron",
"email": "shazron@gmail.com"
},
"_npmVersion": "2.15.11",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "cordova-common@2.1.0",
"name": "cordova-common",
"escapedName": "cordova-common",
"rawSpec": "2.1.0",
"saveSpec": null,
"fetchSpec": "2.1.0"
},
"_requiredBy": [
"/cordova-ios"
],
"_resolved": "https://registry.npmjs.org/cordova-common/-/cordova-common-2.0.2.tgz",
"_shasum": "57467976b8afd5e0bd0a13111b66a420441601cb",
"_shrinkwrap": null,
"_resolved": "https://registry.npmjs.org/cordova-common/-/cordova-common-2.1.0.tgz",
"_spec": "2.1.0",
"_where": "/Users/spindori/Documents/Cordova/cordova-ios",
"author": {
"name": "Apache Software Foundation"
},
......@@ -31,7 +39,7 @@
"ansi": "^0.3.1",
"bplist-parser": "^0.1.0",
"cordova-registry-mapper": "^1.1.8",
"elementtree": "^0.1.6",
"elementtree": "0.1.6",
"glob": "^5.0.13",
"minimatch": "^3.0.0",
"osenv": "^0.1.3",
......@@ -44,66 +52,34 @@
},
"description": "Apache Cordova tools and platforms shared routines",
"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",
"jasmine": "^2.5.2",
"jshint": "^2.8.0",
"promise-matchers": "^0.9.6",
"rewire": "^2.5.1"
},
"directories": {},
"dist": {
"shasum": "57467976b8afd5e0bd0a13111b66a420441601cb",
"tarball": "https://registry.npmjs.org/cordova-common/-/cordova-common-2.0.2.tgz"
},
"engineStrict": true,
"engines": {
"node": ">=4.0.0"
},
"homepage": "https://github.com/apache/cordova-lib#readme",
"license": "Apache-2.0",
"main": "cordova-common.js",
"maintainers": [
{
"name": "bowserj",
"email": "bowserj@apache.org"
},
{
"name": "filmaj",
"email": "maj.fil@gmail.com"
},
{
"name": "kotikov.vladimir",
"email": "kotikov.vladimir@gmail.com"
},
{
"name": "purplecabbage",
"email": "purplecabbage@gmail.com"
},
{
"name": "shazron",
"email": "shazron@gmail.com"
},
{
"name": "stevegill",
"email": "stevengill97@gmail.com"
},
{
"name": "timbarham",
"email": "npmjs@barhams.info"
}
],
"name": "cordova-common",
"optionalDependencies": {},
"readme": "<!--\n#\n# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements. See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership. The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License. You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied. See the License for the\n# specific language governing permissions and limitations\n# under the License.\n#\n-->\n\n# cordova-common\nExpoeses shared functionality used by [cordova-lib](https://github.com/apache/cordova-lib/) and Cordova platforms.\n## Exposed APIs\n\n### `events`\n \nRepresents special instance of NodeJS EventEmitter which is intended to be used to post events to cordova-lib and cordova-cli\n\nUsage:\n```js\nvar events = require('cordova-common').events;\nevents.emit('warn', 'Some warning message')\n```\n\nThere are the following events supported by cordova-cli: `verbose`, `log`, `info`, `warn`, `error`.\n\n### `CordovaError`\n\nAn error class used by Cordova to throw cordova-specific errors. The CordovaError class is inherited from Error, so CordovaError instances is also valid Error instances (`instanceof` check succeeds).\n\nUsage:\n\n```js\nvar CordovaError = require('cordova-common').CordovaError;\nthrow new CordovaError('Some error message', SOME_ERR_CODE);\n```\n\nSee [CordovaError](src/CordovaError/CordovaError.js) for supported error codes.\n\n### `ConfigParser`\n\nExposes functionality to deal with cordova project `config.xml` files. For ConfigParser API reference check [ConfigParser Readme](src/ConfigParser/README.md).\n\nUsage:\n```js\nvar ConfigParser = require('cordova-common').ConfigParser;\nvar appConfig = new ConfigParser('path/to/cordova-app/config.xml');\nconsole.log(appconfig.name() + ':' + appConfig.version());\n```\n\n### `PluginInfoProvider` and `PluginInfo`\n\n`PluginInfo` is a wrapper for cordova plugins' `plugin.xml` files. This class may be instantiated directly or via `PluginInfoProvider`. The difference is that `PluginInfoProvider` caches `PluginInfo` instances based on plugin source directory.\n\nUsage:\n```js\nvar PluginInfo: require('cordova-common').PluginInfo;\nvar PluginInfoProvider: require('cordova-common').PluginInfoProvider;\n\n// The following instances are equal\nvar plugin1 = new PluginInfo('path/to/plugin_directory');\nvar plugin2 = new PluginInfoProvider().get('path/to/plugin_directory');\n\nconsole.log('The plugin ' + plugin1.id + ' has version ' + plugin1.version)\n```\n\n### `ActionStack`\n\nUtility module for dealing with sequential tasks. Provides a set of tasks that are needed to be done and reverts all tasks that are already completed if one of those tasks fail to complete. Used internally by cordova-lib and platform's plugin installation routines.\n\nUsage:\n```js\nvar ActionStack = require('cordova-common').ActionStack;\nvar stack = new ActionStack()\n\nvar action1 = stack.createAction(task1, [<task parameters>], task1_reverter, [<reverter_parameters>]);\nvar action2 = stack.createAction(task2, [<task parameters>], task2_reverter, [<reverter_parameters>]);\n\nstack.push(action1);\nstack.push(action2);\n\nstack.process()\n.then(function() {\n // all actions succeded\n})\n.catch(function(error){\n // One of actions failed with error\n})\n```\n\n### `superspawn`\n\nModule for spawning child processes with some advanced logic.\n\nUsage:\n```js\nvar superspawn = require('cordova-common').superspawn;\nsuperspawn.spawn('adb', ['devices'])\n.progress(function(data){\n if (data.stderr)\n console.error('\"adb devices\" raised an error: ' + data.stderr);\n})\n.then(function(devices){\n // Do something...\n})\n```\n\n### `xmlHelpers`\n\nA set of utility methods for dealing with xml files.\n\nUsage:\n```js\nvar xml = require('cordova-common').xmlHelpers;\n\nvar xmlDoc1 = xml.parseElementtreeSync('some/xml/file');\nvar xmlDoc2 = xml.parseElementtreeSync('another/xml/file');\n\nxml.mergeXml(doc1, doc2); // doc2 now contains all the nodes from doc1\n```\n\n### Other APIs\n\nThe APIs listed below are also exposed but are intended to be only used internally by cordova plugin installation routines.\n\n```\nPlatformJson\nConfigChanges\nConfigKeeper\nConfigFile\nmungeUtil\n```\n\n## Setup\n* Clone this repository onto your local machine\n `git clone https://git-wip-us.apache.org/repos/asf/cordova-lib.git`\n* In terminal, navigate to the inner cordova-common directory\n `cd cordova-lib/cordova-common`\n* Install dependencies and npm-link\n `npm install && npm link`\n* Navigate to cordova-lib directory and link cordova-common\n `cd ../cordova-lib && npm link cordova-common && npm install`\n",
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "git://git-wip-us.apache.org/repos/asf/cordova-common.git"
"url": "git+https://github.com/apache/cordova-lib.git"
},
"scripts": {
"cover": "istanbul cover --root src --print detail jasmine",
"jasmine": "jasmine --captureExceptions --color",
"jshint": "jshint src && jshint spec",
"test": "npm run jshint && npm run jasmine"
"eslint": "eslint src && eslint spec",
"jasmine": "jasmine JASMINE_CONFIG_PATH=spec/support/jasmine.json",
"test": "npm run eslint && npm run jasmine"
},
"version": "2.0.2"
"version": "2.1.0"
}
{
"node": true
, "bitwise": true
, "undef": true
, "trailing": true
, "quotmark": true
, "indent": 4
, "unused": "vars"
, "latedef": "nofunc"
}
......@@ -19,32 +19,32 @@
/* jshint quotmark:false */
var events = require('./events'),
Q = require('q');
var events = require('./events');
var Q = require('q');
function ActionStack() {
function ActionStack () {
this.stack = [];
this.completed = [];
}
ActionStack.prototype = {
createAction:function(handler, action_params, reverter, revert_params) {
createAction: function (handler, action_params, reverter, revert_params) {
return {
handler:{
run:handler,
params:action_params
handler: {
run: handler,
params: action_params
},
reverter:{
run:reverter,
params:revert_params
reverter: {
run: reverter,
params: revert_params
}
};
},
push:function(tx) {
push: function (tx) {
this.stack.push(tx);
},
// Returns a promise.
process:function(platform) {
process: function (platform) {
events.emit('verbose', 'Beginning processing of action stack for ' + platform + ' project...');
while (this.stack.length) {
......@@ -54,19 +54,19 @@ ActionStack.prototype = {
try {
handler.apply(null, action_params);
} catch(e) {
} catch (e) {
events.emit('warn', 'Error during processing of action! Attempting to revert...');
this.stack.unshift(action);
var issue = 'Uh oh!\n';
// revert completed tasks
while(this.completed.length) {
while (this.completed.length) {
var undo = this.completed.shift();
var revert = undo.reverter.run;
var revert_params = undo.reverter.params;
try {
revert.apply(null, revert_params);
} catch(err) {
} catch (err) {
events.emit('warn', 'Error during reversion of action! We probably really messed up your project now, sorry! D:');
issue += 'A reversion action failed: ' + err.message + '\n';
}
......
......@@ -14,6 +14,8 @@
*
*/
/* eslint no-control-regex: 0 */
var fs = require('fs');
var path = require('path');
......@@ -42,7 +44,7 @@ addProperty(module, 'xml_helpers', '../util/xml-helpers', modules);
* TODO: Consider moving it out to a separate file and maybe partially with
* overrides in platform handlers.
******************************************************************************/
function ConfigFile(project_dir, platform, file_tag) {
function ConfigFile (project_dir, platform, file_tag) {
this.project_dir = project_dir;
this.platform = platform;
this.file_tag = file_tag;
......@@ -53,13 +55,13 @@ function ConfigFile(project_dir, platform, file_tag) {
// ConfigFile.load()
ConfigFile.prototype.load = ConfigFile_load;
function ConfigFile_load() {
function ConfigFile_load () {
var self = this;
// config file may be in a place not exactly specified in the target
var filepath = self.filepath = resolveConfigFilePath(self.project_dir, self.platform, self.file_tag);
if ( !filepath || !fs.existsSync(filepath) ) {
if (!filepath || !fs.existsSync(filepath)) {
self.exists = false;
return;
}
......@@ -69,7 +71,7 @@ function ConfigFile_load() {
var ext = path.extname(filepath);
// Windows8 uses an appxmanifest, and wp8 will likely use
// the same in a future release
if (ext == '.xml' || ext == '.appxmanifest') {
if (ext === '.xml' || ext === '.appxmanifest') {
self.type = 'xml';
self.data = modules.xml_helpers.parseElementtreeSync(filepath);
} else {
......@@ -80,12 +82,12 @@ function ConfigFile_load() {
// Do we still need to support binary plist?
// If yes, use plist.parseStringSync() and read the file once.
self.data = isBinaryPlist(filepath) ?
modules.bplist.parseBuffer(fs.readFileSync(filepath)) :
modules.plist.parse(fs.readFileSync(filepath, 'utf8'));
modules.bplist.parseBuffer(fs.readFileSync(filepath)) :
modules.plist.parse(fs.readFileSync(filepath, 'utf8'));
}
}
ConfigFile.prototype.save = function ConfigFile_save() {
ConfigFile.prototype.save = function ConfigFile_save () {
var self = this;
if (self.type === 'xml') {
fs.writeFileSync(self.filepath, self.data.write({indent: 4}), 'utf-8');
......@@ -97,54 +99,54 @@ ConfigFile.prototype.save = function ConfigFile_save() {
self.is_changed = false;
};
ConfigFile.prototype.graft_child = function ConfigFile_graft_child(selector, xml_child) {
ConfigFile.prototype.graft_child = function ConfigFile_graft_child (selector, xml_child) {
var self = this;
var filepath = self.filepath;
var result;
if (self.type === 'xml') {
var xml_to_graft = [modules.et.XML(xml_child.xml)];
switch (xml_child.mode) {
case 'merge':
result = modules.xml_helpers.graftXMLMerge(self.data, xml_to_graft, selector, xml_child);
break;
case 'overwrite':
result = modules.xml_helpers.graftXMLOverwrite(self.data, xml_to_graft, selector, xml_child);
break;
case 'remove':
result= true;
break;
default:
result = modules.xml_helpers.graftXML(self.data, xml_to_graft, selector, xml_child.after);
case 'merge':
result = modules.xml_helpers.graftXMLMerge(self.data, xml_to_graft, selector, xml_child);
break;
case 'overwrite':
result = modules.xml_helpers.graftXMLOverwrite(self.data, xml_to_graft, selector, xml_child);
break;
case 'remove':
result = modules.xml_helpers.pruneXMLRemove(self.data, selector, xml_to_graft);
break;
default:
result = modules.xml_helpers.graftXML(self.data, xml_to_graft, selector, xml_child.after);
}
if ( !result) {
if (!result) {
throw new Error('Unable to graft xml at selector "' + selector + '" from "' + filepath + '" during config install');
}
} else {
// plist file
result = modules.plist_helpers.graftPLIST(self.data, xml_child.xml, selector);
if ( !result ) {
if (!result) {
throw new Error('Unable to graft plist "' + filepath + '" during config install');
}
}
self.is_changed = true;
};
ConfigFile.prototype.prune_child = function ConfigFile_prune_child(selector, xml_child) {
ConfigFile.prototype.prune_child = function ConfigFile_prune_child (selector, xml_child) {
var self = this;
var filepath = self.filepath;
var result;
if (self.type === 'xml') {
var xml_to_graft = [modules.et.XML(xml_child.xml)];
switch (xml_child.mode) {
case 'merge':
case 'overwrite':
result = modules.xml_helpers.pruneXMLRestore(self.data, selector, xml_child);
break;
case 'remove':
result = modules.xml_helpers.prunXMLRemove(self.data, selector, xml_to_graft);
break;
default:
result = modules.xml_helpers.pruneXML(self.data, xml_to_graft, selector);
case 'merge':
case 'overwrite':
result = modules.xml_helpers.pruneXMLRestore(self.data, selector, xml_child);
break;
case 'remove':
result = modules.xml_helpers.pruneXMLRemove(self.data, selector, xml_to_graft);
break;
default:
result = modules.xml_helpers.pruneXML(self.data, xml_to_graft, selector);
}
} else {
// plist file
......@@ -160,7 +162,7 @@ ConfigFile.prototype.prune_child = function ConfigFile_prune_child(selector, xml
// Some config-file target attributes are not qualified with a full leading directory, or contain wildcards.
// Resolve to a real path in this function.
// TODO: getIOSProjectname is slow because of glob, try to avoid calling it several times per project.
function resolveConfigFilePath(project_dir, platform, file) {
function resolveConfigFilePath (project_dir, platform, file) {
var filepath = path.join(project_dir, file);
var matches;
......@@ -170,10 +172,10 @@ function resolveConfigFilePath(project_dir, platform, file) {
if (matches.length) filepath = matches[0];
// [CB-5989] multiple Info.plist files may exist. default to $PROJECT_NAME-Info.plist
if(matches.length > 1 && file.indexOf('-Info.plist')>-1){
var plistName = getIOSProjectname(project_dir)+'-Info.plist';
for (var i=0; i < matches.length; i++) {
if(matches[i].indexOf(plistName) > -1){
if (matches.length > 1 && file.indexOf('-Info.plist') > -1) {
var plistName = getIOSProjectname(project_dir) + '-Info.plist';
for (var i = 0; i < matches.length; i++) {
if (matches[i].indexOf(plistName) > -1) {
filepath = matches[i];
break;
}
......@@ -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.
// TODO: move the logic that contains the locations of config.xml from cordova CLI into plugman.
if (file == 'config.xml') {
if (platform == 'ubuntu') {
if (file === 'config.xml') {
if (platform === 'ubuntu') {
filepath = path.join(project_dir, 'config.xml');
} else if (platform == 'ios') {
} else if (platform === 'ios') {
var iospath = getIOSProjectname(project_dir);
filepath = path.join(project_dir,iospath, 'config.xml');
} else if (platform == 'android') {
filepath = path.join(project_dir, iospath, 'config.xml');
} else if (platform === 'android') {
filepath = path.join(project_dir, 'res', 'xml', 'config.xml');
} else {
matches = modules.glob.sync(path.join(project_dir, '**', 'config.xml'));
......@@ -201,8 +203,8 @@ function resolveConfigFilePath(project_dir, platform, file) {
// XXX this checks for android studio projects
// only if none of the options above are satisfied does this get called
if(platform === 'android' && !fs.existsSync(filepath)) {
filepath = path.join(project_dir, 'app', 'src', 'main', 'res', 'xml', 'config.xml');
if (platform === 'android' && !fs.existsSync(filepath)) {
filepath = path.join(project_dir, 'app', 'src', 'main', 'res', 'xml', 'config.xml');
}
// None of the special cases matched, returning project_dir/file.
......@@ -211,11 +213,11 @@ function resolveConfigFilePath(project_dir, platform, file) {
// Find out the real name of an iOS project
// TODO: glob is slow, need a better way or caching, or avoid using more than once.
function getIOSProjectname(project_dir) {
function getIOSProjectname (project_dir) {
var matches = modules.glob.sync(path.join(project_dir, '*.xcodeproj'));
var iospath;
if (matches.length === 1) {
iospath = path.basename(matches[0],'.xcodeproj');
iospath = path.basename(matches[0], '.xcodeproj');
} else {
var msg;
if (matches.length === 0) {
......@@ -229,7 +231,7 @@ function getIOSProjectname(project_dir) {
}
// determine if a plist file is binary
function isBinaryPlist(filename) {
function isBinaryPlist (filename) {
// I wish there was a synchronous way to read only the first 6 bytes of a
// file. This is wasteful :/
var buf = '' + fs.readFileSync(filename, 'utf8');
......
......@@ -28,18 +28,18 @@ var ConfigFile = require('./ConfigFile');
* project_dir/platform/file
* where file is the name used for the file in config munges.
******************************************************************************/
function ConfigKeeper(project_dir, plugins_dir) {
function ConfigKeeper (project_dir, plugins_dir) {
this.project_dir = project_dir;
this.plugins_dir = plugins_dir;
this._cached = {};
}
ConfigKeeper.prototype.get = function ConfigKeeper_get(project_dir, platform, file) {
ConfigKeeper.prototype.get = function ConfigKeeper_get (project_dir, platform, file) {
var self = this;
// 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
if(file == 'config.xml' && platform == 'android'){
if (file === 'config.xml' && platform === 'android') {
file = 'res/xml/config.xml';
}
var fake_path = path.join(project_dir, platform, file);
......@@ -53,8 +53,7 @@ ConfigKeeper.prototype.get = function ConfigKeeper_get(project_dir, platform, fi
return config_file;
};
ConfigKeeper.prototype.save_all = function ConfigKeeper_save_all() {
ConfigKeeper.prototype.save_all = function ConfigKeeper_save_all () {
var self = this;
Object.keys(self._cached).forEach(function (fake_path) {
var config_file = self._cached[fake_path];
......
......@@ -19,14 +19,14 @@ var _ = require('underscore');
// add the count of [key1][key2]...[keyN] to obj
// return true if it didn't exist before
exports.deep_add = function deep_add(obj, keys /* or key1, key2 .... */ ) {
if ( !Array.isArray(keys) ) {
exports.deep_add = function deep_add (obj, keys /* or key1, key2 .... */) {
if (!Array.isArray(keys)) {
keys = Array.prototype.slice.call(arguments, 1);
}
return exports.process_munge(obj, true/*createParents*/, function (parentArray, k) {
var found = _.find(parentArray, function(element) {
return element.xml == k.xml;
return exports.process_munge(obj, true/* createParents */, function (parentArray, k) {
var found = _.find(parentArray, function (element) {
return element.xml === k.xml;
});
if (found) {
found.after = found.after || k.after;
......@@ -40,16 +40,16 @@ exports.deep_add = function deep_add(obj, keys /* or key1, key2 .... */ ) {
// decrement the count of [key1][key2]...[keyN] from obj and remove if it reaches 0
// return true if it was removed or not found
exports.deep_remove = function deep_remove(obj, keys /* or key1, key2 .... */ ) {
if ( !Array.isArray(keys) ) {
exports.deep_remove = function deep_remove (obj, keys /* or key1, key2 .... */) {
if (!Array.isArray(keys)) {
keys = Array.prototype.slice.call(arguments, 1);
}
var result = exports.process_munge(obj, false/*createParents*/, function (parentArray, k) {
var result = exports.process_munge(obj, false/* createParents */, function (parentArray, k) {
var index = -1;
var found = _.find(parentArray, function (element) {
index++;
return element.xml == k.xml;
return element.xml === k.xml;
});
if (found) {
if (parentArray[index].oldAttrib) {
......@@ -58,8 +58,7 @@ exports.deep_remove = function deep_remove(obj, keys /* or key1, key2 .... */ )
found.count -= k.count;
if (found.count > 0) {
return false;
}
else {
} else {
parentArray.splice(index, 1);
}
}
......@@ -71,14 +70,14 @@ exports.deep_remove = function deep_remove(obj, keys /* or key1, key2 .... */ )
// search for [key1][key2]...[keyN]
// return the object or undefined if not found
exports.deep_find = function deep_find(obj, keys /* or key1, key2 .... */ ) {
if ( !Array.isArray(keys) ) {
exports.deep_find = function deep_find (obj, keys /* or key1, key2 .... */) {
if (!Array.isArray(keys)) {
keys = Array.prototype.slice.call(arguments, 1);
}
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 element.xml == (k.xml || k);
return element.xml === (k.xml || k);
});
}, keys);
};
......@@ -87,20 +86,20 @@ exports.deep_find = function deep_find(obj, keys /* or key1, key2 .... */ ) {
// When createParents is true, add the file and parent items they are missing
// When createParents is false, stop and return undefined if the file and/or parent items are missing
exports.process_munge = function process_munge(obj, createParents, func, keys /* or key1, key2 .... */ ) {
if ( !Array.isArray(keys) ) {
exports.process_munge = function process_munge (obj, createParents, func, keys /* or key1, key2 .... */) {
if (!Array.isArray(keys)) {
keys = Array.prototype.slice.call(arguments, 1);
}
var k = keys[0];
if (keys.length == 1) {
if (keys.length === 1) {
return func(obj, k);
} else if (keys.length == 2) {
} else if (keys.length === 2) {
if (!obj.parents[k] && !createParents) {
return undefined;
}
obj.parents[k] = obj.parents[k] || [];
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) {
return undefined;
}
......@@ -115,7 +114,7 @@ exports.process_munge = function process_munge(obj, createParents, func, keys /*
// base[file][selector][child] += munge[file][selector][child]
// Returns a munge object containing values that exist in munge
// but not in base.
exports.increment_munge = function increment_munge(base, munge) {
exports.increment_munge = function increment_munge (base, munge) {
var diff = { files: {} };
for (var file in munge.files) {
......@@ -138,7 +137,7 @@ exports.increment_munge = function increment_munge(base, munge) {
// base[file][selector][child] -= munge[file][selector][child]
// nodes that reached zero value are removed from base and added to the returned munge
// object.
exports.decrement_munge = function decrement_munge(base, munge) {
exports.decrement_munge = function decrement_munge (base, munge) {
var zeroed = { files: {} };
for (var file in munge.files) {
......@@ -158,6 +157,6 @@ exports.decrement_munge = function decrement_munge(base, munge) {
};
// For better readability where used
exports.clone_munge = function clone_munge(munge) {
exports.clone_munge = function clone_munge (munge) {
return exports.increment_munge({}, munge);
};
......@@ -17,10 +17,10 @@
under the License.
*/
var fs = require('fs'),
path = require('path');
var fs = require('fs');
var path = require('path');
function isRootDir(dir) {
function isRootDir (dir) {
if (fs.existsSync(path.join(dir, 'www'))) {
if (fs.existsSync(path.join(dir, 'config.xml'))) {
// For sure is.
......@@ -41,12 +41,12 @@ function isRootDir(dir) {
// Runs up the directory chain looking for a .cordova directory.
// IF it is found we are in a Cordova project.
// Omit argument to use CWD.
function isCordova(dir) {
function isCordova (dir) {
if (!dir) {
// Prefer PWD over cwd so that symlinked dirs within your PWD work correctly (CB-5687).
var pwd = process.env.PWD;
var cwd = process.cwd();
if (pwd && pwd != cwd && pwd != 'undefined') {
if (pwd && pwd !== cwd && pwd !== 'undefined') {
return isCordova(pwd) || isCordova(cwd);
}
return isCordova(cwd);
......@@ -62,7 +62,7 @@ function isCordova(dir) {
}
var parentDir = path.normalize(path.join(dir, '..'));
// Detect fs root.
if (parentDir == dir) {
if (parentDir === dir) {
return bestReturnValueSoFar;
}
dir = parentDir;
......@@ -72,5 +72,5 @@ function isCordova(dir) {
}
module.exports = {
findProjectRoot : isCordova
findProjectRoot: isCordova
};
......@@ -17,7 +17,7 @@
under the License.
*/
/* jshint proto:true */
/* eslint no-proto: 0 */
var EOL = require('os').EOL;
......@@ -30,7 +30,7 @@ var EOL = require('os').EOL;
* @param {CordovaExternalToolErrorContext} [context] External tool error context object
* @constructor
*/
function CordovaError(message, code, context) {
function CordovaError (message, code, context) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
......@@ -47,10 +47,10 @@ CordovaError.EXTERNAL_TOOL_ERROR = 1;
* Translates instance's error code number into error code name, e.g. 0 -> UNKNOWN_ERROR
* @returns {string} Error code string name
*/
CordovaError.prototype.getErrorCodeName = function() {
for(var key in CordovaError) {
if(CordovaError.hasOwnProperty(key)) {
if(CordovaError[key] === this.code) {
CordovaError.prototype.getErrorCodeName = function () {
for (var key in CordovaError) {
if (CordovaError.hasOwnProperty(key)) {
if (CordovaError[key] === this.code) {
return key;
}
}
......@@ -63,16 +63,17 @@ CordovaError.prototype.getErrorCodeName = function() {
* details including information about error code name and context
* @return {String} Stringified error representation
*/
CordovaError.prototype.toString = function(isVerbose) {
var message = '', codePrefix = '';
CordovaError.prototype.toString = function (isVerbose) {
var message = '';
var codePrefix = '';
if(this.code !== CordovaError.UNKNOWN_ERROR) {
if (this.code !== CordovaError.UNKNOWN_ERROR) {
codePrefix = 'code: ' + this.code + (isVerbose ? (' (' + this.getErrorCodeName() + ')') : '') + ' ';
}
if(this.code === CordovaError.EXTERNAL_TOOL_ERROR) {
if(typeof this.context !== 'undefined') {
if(isVerbose) {
if (this.code === CordovaError.EXTERNAL_TOOL_ERROR) {
if (typeof this.context !== 'undefined') {
if (isVerbose) {
message = codePrefix + EOL + this.context.toString(isVerbose) + '\n failed with an error: ' +
this.message + EOL + 'Stack trace: ' + this.stack;
} else {
......
......@@ -27,7 +27,7 @@ var path = require('path');
* @param {String} [cwd] Command working directory
* @constructor
*/
function CordovaExternalToolErrorContext(cmd, args, cwd) {
function CordovaExternalToolErrorContext (cmd, args, cwd) {
this.cmd = cmd;
// Helper field for readability
this.cmdShortName = path.basename(cmd);
......@@ -35,8 +35,8 @@ function CordovaExternalToolErrorContext(cmd, args, cwd) {
this.cwd = cwd;
}
CordovaExternalToolErrorContext.prototype.toString = function(isVerbose) {
if(isVerbose) {
CordovaExternalToolErrorContext.prototype.toString = function (isVerbose) {
if (isVerbose) {
return 'External tool \'' + this.cmdShortName + '\'' +
'\nCommand full path: ' + this.cmd + '\nCommand args: ' + this.args +
(typeof this.cwd !== 'undefined' ? '\nCommand cwd: ' + this.cwd : '');
......
......@@ -41,11 +41,11 @@ function CordovaLogger () {
this.stderrCursor = ansi(this.stderr);
this.addLevel('verbose', 1000, 'grey');
this.addLevel('normal' , 2000);
this.addLevel('warn' , 2000, 'yellow');
this.addLevel('info' , 3000, 'blue');
this.addLevel('error' , 5000, 'red');
this.addLevel('results' , 10000);
this.addLevel('normal', 2000);
this.addLevel('warn', 2000, 'yellow');
this.addLevel('info', 3000, 'blue');
this.addLevel('error', 5000, 'red');
this.addLevel('results', 10000);
this.setLevel('normal');
}
......@@ -82,9 +82,10 @@ CordovaLogger.RESULTS = 'results';
CordovaLogger.prototype.log = function (logLevel, message) {
// if there is no such logLevel defined, or provided level has
// 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 this;
}
var isVerbose = this.logLevel === 'verbose';
var cursor = this.stdoutCursor;
......@@ -179,8 +180,7 @@ CordovaLogger.prototype.adjustLevel = function (opts) {
*/
CordovaLogger.prototype.subscribe = function (eventEmitter) {
if (!(eventEmitter instanceof EventEmitter))
throw new Error('Subscribe method only accepts an EventEmitter instance as argument');
if (!(eventEmitter instanceof EventEmitter)) { throw new Error('Subscribe method only accepts an EventEmitter instance as argument'); }
eventEmitter.on('verbose', this.verbose)
.on('log', this.normal)
......@@ -193,7 +193,7 @@ CordovaLogger.prototype.subscribe = function (eventEmitter) {
return this;
};
function formatError(error, isVerbose) {
function formatError (error, isVerbose) {
var message = '';
if (error instanceof CordovaError) {
......
......@@ -13,7 +13,6 @@
* under the License.
*
*/
/* jshint sub:true */
var fs = require('fs');
var path = require('path');
......@@ -22,13 +21,13 @@ var mungeutil = require('./ConfigChanges/munge-util');
var pluginMappernto = require('cordova-registry-mapper').newToOld;
var pluginMapperotn = require('cordova-registry-mapper').oldToNew;
function PlatformJson(filePath, platform, root) {
function PlatformJson (filePath, platform, root) {
this.filePath = filePath;
this.platform = platform;
this.root = fix_munge(root || {});
}
PlatformJson.load = function(plugins_dir, platform) {
PlatformJson.load = function (plugins_dir, platform) {
var filePath = path.join(plugins_dir, platform + '.json');
var root = null;
if (fs.existsSync(filePath)) {
......@@ -37,9 +36,9 @@ PlatformJson.load = function(plugins_dir, platform) {
return new PlatformJson(filePath, platform, root);
};
PlatformJson.prototype.save = function() {
PlatformJson.prototype.save = function () {
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');
};
/**
......@@ -49,7 +48,7 @@ PlatformJson.prototype.save = function() {
* @param {String} pluginId A plugin id to check for.
* @return {Boolean} true if plugin installed as top-level, otherwise false.
*/
PlatformJson.prototype.isPluginTopLevel = function(pluginId) {
PlatformJson.prototype.isPluginTopLevel = function (pluginId) {
var installedPlugins = this.root.installed_plugins;
return installedPlugins[pluginId] ||
installedPlugins[pluginMappernto[pluginId]] ||
......@@ -63,7 +62,7 @@ PlatformJson.prototype.isPluginTopLevel = function(pluginId) {
* @param {String} pluginId A plugin id to check for.
* @return {Boolean} true if plugin installed as a dependency, otherwise false.
*/
PlatformJson.prototype.isPluginDependent = function(pluginId) {
PlatformJson.prototype.isPluginDependent = function (pluginId) {
var dependentPlugins = this.root.dependent_plugins;
return dependentPlugins[pluginId] ||
dependentPlugins[pluginMappernto[pluginId]] ||
......@@ -76,12 +75,12 @@ PlatformJson.prototype.isPluginDependent = function(pluginId) {
* @param {String} pluginId A plugin id to check for.
* @return {Boolean} true if plugin installed, otherwise false.
*/
PlatformJson.prototype.isPluginInstalled = function(pluginId) {
PlatformJson.prototype.isPluginInstalled = function (pluginId) {
return this.isPluginTopLevel(pluginId) ||
this.isPluginDependent(pluginId);
};
PlatformJson.prototype.addPlugin = function(pluginId, variables, isTopLevel) {
PlatformJson.prototype.addPlugin = function (pluginId, variables, isTopLevel) {
var pluginsList = isTopLevel ?
this.root.installed_plugins :
this.root.dependent_plugins;
......@@ -107,13 +106,13 @@ PlatformJson.prototype.addPluginMetadata = function (pluginInfo) {
});
var modulesToInstall = pluginInfo.getJsModules(this.platform)
.map(function (module) {
return new ModuleMetadata(pluginInfo.id, module);
})
.filter(function (metadata) {
// Filter out modules which are already added to metadata
return installedPaths.indexOf(metadata.file) === -1;
});
.map(function (module) {
return new ModuleMetadata(pluginInfo.id, module);
})
.filter(function (metadata) {
// Filter out modules which are already added to metadata
return installedPaths.indexOf(metadata.file) === -1;
});
this.root.modules = installedModules.concat(modulesToInstall);
......@@ -123,7 +122,7 @@ PlatformJson.prototype.addPluginMetadata = function (pluginInfo) {
return this;
};
PlatformJson.prototype.removePlugin = function(pluginId, isTopLevel) {
PlatformJson.prototype.removePlugin = function (pluginId, isTopLevel) {
var pluginsList = isTopLevel ?
this.root.installed_plugins :
this.root.dependent_plugins;
......@@ -144,16 +143,16 @@ PlatformJson.prototype.removePlugin = function(pluginId, isTopLevel) {
*/
PlatformJson.prototype.removePluginMetadata = function (pluginInfo) {
var modulesToRemove = pluginInfo.getJsModules(this.platform)
.map(function (jsModule) {
return ['plugins', pluginInfo.id, jsModule.src].join('/');
});
.map(function (jsModule) {
return ['plugins', pluginInfo.id, jsModule.src].join('/');
});
var installedModules = this.root.modules || [];
this.root.modules = installedModules
.filter(function (installedModule) {
// Leave only those metadatas which 'file' is not in removed modules
return (modulesToRemove.indexOf(installedModule.file) === -1);
});
.filter(function (installedModule) {
// Leave only those metadatas which 'file' is not in removed modules
return (modulesToRemove.indexOf(installedModule.file) === -1);
});
if (this.root.plugin_metadata) {
delete this.root.plugin_metadata[pluginInfo.id];
......@@ -162,12 +161,12 @@ PlatformJson.prototype.removePluginMetadata = function (pluginInfo) {
return this;
};
PlatformJson.prototype.addInstalledPluginToPrepareQueue = function(pluginDirName, vars, is_top_level, force) {
this.root.prepare_queue.installed.push({'plugin':pluginDirName, 'vars':vars, 'topLevel':is_top_level, 'force':force});
PlatformJson.prototype.addInstalledPluginToPrepareQueue = function (pluginDirName, vars, is_top_level, force) {
this.root.prepare_queue.installed.push({'plugin': pluginDirName, 'vars': vars, 'topLevel': is_top_level, 'force': force});
};
PlatformJson.prototype.addUninstalledPluginToPrepareQueue = function(pluginId, is_top_level) {
this.root.prepare_queue.uninstalled.push({'plugin':pluginId, 'id':pluginId, 'topLevel':is_top_level});
PlatformJson.prototype.addUninstalledPluginToPrepareQueue = function (pluginId, is_top_level) {
this.root.prepare_queue.uninstalled.push({'plugin': pluginId, 'id': pluginId, 'topLevel': is_top_level});
};
/**
......@@ -177,7 +176,7 @@ PlatformJson.prototype.addUninstalledPluginToPrepareQueue = function(pluginId, i
* @param {String} pluginId A plugin id to make top-level.
* @return {PlatformJson} PlatformJson instance.
*/
PlatformJson.prototype.makeTopLevel = function(pluginId) {
PlatformJson.prototype.makeTopLevel = function (pluginId) {
var plugin = this.root.dependent_plugins[pluginId];
if (plugin) {
delete this.root.dependent_plugins[pluginId];
......@@ -195,10 +194,10 @@ PlatformJson.prototype.makeTopLevel = function(pluginId) {
PlatformJson.prototype.generateMetadata = function () {
return [
'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 = ',
'// TOP OF METADATA',
JSON.stringify(this.root.plugin_metadata, null, 4) + ';',
JSON.stringify(this.root.plugin_metadata, null, 2) + ';',
'// BOTTOM OF METADATA',
'});' // Close cordova.define.
].join('\n');
......@@ -220,8 +219,8 @@ PlatformJson.prototype.generateAndSaveMetadata = function (destination) {
};
// convert a munge from the old format ([file][parent][xml] = count) to the current one
function fix_munge(root) {
root.prepare_queue = root.prepare_queue || {installed:[], uninstalled:[]};
function fix_munge (root) {
root.prepare_queue = root.prepare_queue || {installed: [], uninstalled: []};
root.config_munge = root.config_munge || {files: {}};
root.installed_plugins = root.installed_plugins || {};
root.dependent_plugins = root.dependent_plugins || {};
......@@ -260,15 +259,15 @@ function ModuleMetadata (pluginId, jsModule) {
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');
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.pluginId = pluginId;
if (jsModule.clobbers && jsModule.clobbers.length > 0) {
this.clobbers = jsModule.clobbers.map(function(o) { return o.target; });
this.clobbers = jsModule.clobbers.map(function (o) { return o.target; });
}
if (jsModule.merges && jsModule.merges.length > 0) {
this.merges = jsModule.merges.map(function(o) { return o.target; });
this.merges = jsModule.merges.map(function (o) { return o.target; });
}
if (jsModule.runs) {
this.runs = true;
......
......@@ -24,12 +24,12 @@ var path = require('path');
var PluginInfo = require('./PluginInfo');
var events = require('../events');
function PluginInfoProvider() {
function PluginInfoProvider () {
this._cache = {};
this._getAllCache = {};
}
PluginInfoProvider.prototype.get = function(dirName) {
PluginInfoProvider.prototype.get = function (dirName) {
var absPath = path.resolve(dirName);
if (!this._cache[absPath]) {
this._cache[absPath] = new PluginInfo(dirName);
......@@ -39,7 +39,7 @@ PluginInfoProvider.prototype.get = function(dirName) {
// Normally you don't need to put() entries, but it's used
// when copying plugins, and in unit tests.
PluginInfoProvider.prototype.put = function(pluginInfo) {
PluginInfoProvider.prototype.put = function (pluginInfo) {
var absPath = path.resolve(pluginInfo.dir);
this._cache[absPath] = pluginInfo;
};
......@@ -48,7 +48,7 @@ PluginInfoProvider.prototype.put = function(pluginInfo) {
// Given a dir containing multiple plugins, create a PluginInfo object for
// each of them and return as array.
// Should load them all in parallel and return a promise, but not yet.
PluginInfoProvider.prototype.getAllWithinSearchPath = function(dirName) {
PluginInfoProvider.prototype.getAllWithinSearchPath = function (dirName) {
var absPath = path.resolve(dirName);
if (!this._getAllCache[absPath]) {
this._getAllCache[absPath] = getAllHelper(absPath, this);
......@@ -56,8 +56,8 @@ PluginInfoProvider.prototype.getAllWithinSearchPath = function(dirName) {
return this._getAllCache[absPath];
};
function getAllHelper(absPath, provider) {
if (!fs.existsSync(absPath)){
function getAllHelper (absPath, provider) {
if (!fs.existsSync(absPath)) {
return [];
}
// If dir itself is a plugin, return it in an array with one element.
......@@ -66,7 +66,7 @@ function getAllHelper(absPath, provider) {
}
var subdirs = fs.readdirSync(absPath);
var plugins = [];
subdirs.forEach(function(subdir) {
subdirs.forEach(function (subdir) {
var d = path.join(absPath, subdir);
if (fs.existsSync(path.join(d, 'plugin.xml'))) {
try {
......
......@@ -36,7 +36,7 @@ var PluginInfoProvider = require('./PluginInfo/PluginInfoProvider');
* @param {Object} locations - Platform files and directories
* @param {IDEProject} ideProject The IDE project to add/remove plugin changes to/from
*/
function PluginManager(platform, locations, ideProject) {
function PluginManager (platform, locations, ideProject) {
this.platform = platform;
this.locations = locations;
this.project = ideProject;
......@@ -45,7 +45,6 @@ function PluginManager(platform, locations, ideProject) {
this.munger = new PlatformMunger(platform, locations.root, platformJson, new PluginInfoProvider());
}
/**
* @constructs PluginManager
* A convenience shortcut to new PluginManager(...)
......@@ -55,7 +54,7 @@ function PluginManager(platform, locations, ideProject) {
* @param {IDEProject} ideProject The IDE project to add/remove plugin changes to/from
* @returns new PluginManager instance
*/
PluginManager.get = function(platform, locations, ideProject) {
PluginManager.get = function (platform, locations, ideProject) {
return new PluginManager(platform, locations, ideProject);
};
......@@ -82,11 +81,9 @@ module.exports = PluginManager;
* @returns {Promise} Returns a Q promise, either resolved in case of success, rejected otherwise.
*/
PluginManager.prototype.doOperation = function (operation, plugin, options) {
if (operation !== PluginManager.INSTALL && operation !== PluginManager.UNINSTALL)
return Q.reject(new CordovaError('The parameter is incorrect. The opeation must be either "add" or "remove"'));
if (operation !== PluginManager.INSTALL && operation !== PluginManager.UNINSTALL) { return Q.reject(new CordovaError('The parameter is incorrect. The opeation must be either "add" or "remove"')); }
if (!plugin || plugin.constructor.name !== 'PluginInfo')
return Q.reject(new CordovaError('The parameter is incorrect. The first parameter should be a PluginInfo instance'));
if (!plugin || plugin.constructor.name !== 'PluginInfo') { 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
options = options || {};
......@@ -95,52 +92,52 @@ PluginManager.prototype.doOperation = function (operation, plugin, options) {
var actions = new ActionStack();
// 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.getJsModules(this.platform))
// ... put them into stack ...
.forEach(function(item) {
var installer = self.project.getInstaller(item.itemType);
var uninstaller = self.project.getUninstaller(item.itemType);
var actionArgs = [item, plugin, self.project, options];
var action;
if (operation === PluginManager.INSTALL) {
action = actions.createAction.apply(actions, [installer, actionArgs, uninstaller, actionArgs]);
} else /* op === PluginManager.UNINSTALL */{
action = actions.createAction.apply(actions, [uninstaller, actionArgs, installer, actionArgs]);
}
actions.push(action);
});
// ... put them into stack ...
.forEach(function (item) {
var installer = self.project.getInstaller(item.itemType);
var uninstaller = self.project.getUninstaller(item.itemType);
var actionArgs = [item, plugin, self.project, options];
var action;
if (operation === PluginManager.INSTALL) {
action = actions.createAction.apply(actions, [installer, actionArgs, uninstaller, actionArgs]); /* eslint no-useless-call: 0 */
} else /* op === PluginManager.UNINSTALL */{
action = actions.createAction.apply(actions, [uninstaller, actionArgs, installer, actionArgs]); /* eslint no-useless-call: 0 */
}
actions.push(action);
});
// ... and run through the action stack
return actions.process(this.platform)
.then(function () {
if (self.project.write) {
self.project.write();
}
if (operation === PluginManager.INSTALL) {
// Ignore passed `is_top_level` option since platform itself doesn't know
// anything about managing dependencies - it's responsibility of caller.
self.munger.add_plugin_changes(plugin, options.variables, /*is_top_level=*/true, /*should_increment=*/true, options.force);
self.munger.platformJson.addPluginMetadata(plugin);
} else {
self.munger.remove_plugin_changes(plugin, /*is_top_level=*/true);
self.munger.platformJson.removePluginMetadata(plugin);
}
// Save everything (munge and plugin/modules metadata)
self.munger.save_all();
var metadata = self.munger.platformJson.generateMetadata();
fs.writeFileSync(path.join(self.locations.www, 'cordova_plugins.js'), metadata, 'utf-8');
// CB-11022 save plugin metadata to both www and platform_www if options.usePlatformWww is specified
if (options.usePlatformWww) {
fs.writeFileSync(path.join(self.locations.platformWww, 'cordova_plugins.js'), metadata, 'utf-8');
}
});
.then(function () {
if (self.project.write) {
self.project.write();
}
if (operation === PluginManager.INSTALL) {
// Ignore passed `is_top_level` option since platform itself doesn't know
// anything about managing dependencies - it's responsibility of caller.
self.munger.add_plugin_changes(plugin, options.variables, /* is_top_level= */true, /* should_increment= */true, options.force);
self.munger.platformJson.addPluginMetadata(plugin);
} else {
self.munger.remove_plugin_changes(plugin, /* is_top_level= */true);
self.munger.platformJson.removePluginMetadata(plugin);
}
// Save everything (munge and plugin/modules metadata)
self.munger.save_all();
var metadata = self.munger.platformJson.generateMetadata();
fs.writeFileSync(path.join(self.locations.www, 'cordova_plugins.js'), metadata, 'utf-8');
// CB-11022 save plugin metadata to both www and platform_www if options.usePlatformWww is specified
if (options.usePlatformWww) {
fs.writeFileSync(path.join(self.locations.platformWww, 'cordova_plugins.js'), metadata, 'utf-8');
}
});
};
PluginManager.prototype.addPlugin = function (plugin, installOptions) {
......
......@@ -40,8 +40,7 @@ module.exports.forwardEventsTo = function (eventEmitter) {
return;
}
if (!(eventEmitter instanceof EventEmitter))
throw new Error('Cordova events can be redirected to another EventEmitter instance only');
if (!(eventEmitter instanceof EventEmitter)) { throw new Error('Cordova events can be redirected to another EventEmitter instance only'); }
// CB-10940 Skipping forwarding to self to avoid infinite recursion.
// This is the case when the modules are npm-linked.
......
......@@ -24,12 +24,12 @@ var _ = require('underscore');
var Q = require('q');
var shell = require('shelljs');
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.
function resolveWindowsExe(cmd) {
function resolveWindowsExe (cmd) {
var winExtensions = ['.exe', '.bat', '.cmd', '.js', '.vbs'];
function isValidExe(c) {
function isValidExe (c) {
return winExtensions.indexOf(path.extname(c)) !== -1 && fs.existsSync(c);
}
if (isValidExe(cmd)) {
......@@ -37,7 +37,7 @@ function resolveWindowsExe(cmd) {
}
cmd = shell.which(cmd) || cmd;
if (!isValidExe(cmd)) {
winExtensions.some(function(ext) {
winExtensions.some(function (ext) {
if (fs.existsSync(cmd + ext)) {
cmd = cmd + ext;
return true;
......@@ -47,7 +47,7 @@ function resolveWindowsExe(cmd) {
return cmd;
}
function maybeQuote(a) {
function maybeQuote (a) {
if (/^[^"].*[ &].*[^"]/.test(a)) return '"' + a + '"';
return a;
}
......@@ -85,7 +85,7 @@ function maybeQuote(a) {
* 'stderr': ...
* }
*/
exports.spawn = function(cmd, args, opts) {
exports.spawn = function (cmd, args, opts) {
args = args || [];
opts = opts || {};
var spawnOpts = {};
......@@ -95,7 +95,7 @@ exports.spawn = function(cmd, args, opts) {
cmd = resolveWindowsExe(cmd);
// If we couldn't find the file, likely we'll end up failing,
// 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(' ') + '"';
// We need to use /s to ensure that spaces are parsed properly with cmd spawned content
args = [['/s', '/c', cmdArgs].join(' ')];
......@@ -137,7 +137,7 @@ exports.spawn = function(cmd, args, opts) {
if (child.stdout) {
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(data) {
child.stdout.on('data', function (data) {
capturedOut += data;
d.notify({'stdout': data});
});
......@@ -145,7 +145,7 @@ exports.spawn = function(cmd, args, opts) {
if (child.stderr) {
child.stderr.setEncoding('utf8');
child.stderr.on('data', function(data) {
child.stderr.on('data', function (data) {
capturedErr += data;
d.notify({'stderr': data});
});
......@@ -153,10 +153,10 @@ exports.spawn = function(cmd, args, opts) {
child.on('close', whenDone);
child.on('error', whenDone);
function whenDone(arg) {
function whenDone (arg) {
child.removeListener('close', 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);
if (code === 0) {
......@@ -181,10 +181,9 @@ exports.spawn = function(cmd, args, opts) {
return d.promise;
};
exports.maybeSpawn = function(cmd, args, opts) {
exports.maybeSpawn = function (cmd, args, opts) {
if (fs.existsSync(cmd)) {
return exports.spawn(cmd, args, opts);
}
return Q(null);
};
......@@ -17,8 +17,8 @@
under the License.
*/
module.exports = function addProperty(module, property, modulePath, obj) {
module.exports = function addProperty (module, property, modulePath, obj) {
obj = obj || module.exports;
// Add properties as getter to delay load the modules on first invocation
Object.defineProperty(obj, property, {
......
......@@ -15,32 +15,32 @@
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
*/
/* eslint no-useless-escape: 0 */
// contains PLIST utility functions
var __ = require('underscore');
var __ = require('underscore');
var plist = require('plist');
// adds node to doc at selector
module.exports.graftPLIST = graftPLIST;
function graftPLIST(doc, xml, selector) {
var obj = plist.parse('<plist>'+xml+'</plist>');
function graftPLIST (doc, xml, selector) {
var obj = plist.parse('<plist>' + xml + '</plist>');
var node = doc[selector];
if (node && Array.isArray(node) && Array.isArray(obj)){
if (node && Array.isArray(node) && Array.isArray(obj)) {
node = node.concat(obj);
for (var i =0;i<node.length; i++){
for (var j=i+1; j<node.length; ++j) {
if (nodeEqual(node[i], node[j]))
node.splice(j--,1);
for (var i = 0; i < node.length; i++) {
for (var j = i + 1; j < node.length; ++j) {
if (nodeEqual(node[i], node[j])) { node.splice(j--, 1); }
}
}
doc[selector] = node;
} else {
//plist uses objects for <dict>. If we have two dicts we merge them instead of
// plist uses objects for <dict>. If we have two dicts we merge them instead of
// overriding the old one. See CB-6472
if (node && __.isObject(node) && __.isObject(obj) && !__.isDate(node) && !__.isDate(obj)){//arrays checked above
__.extend(obj,node);
if (node && __.isObject(node) && __.isObject(obj) && !__.isDate(node) && !__.isDate(obj)) { // arrays checked above
__.extend(obj, node);
}
doc[selector] = obj;
}
......@@ -50,15 +50,15 @@ function graftPLIST(doc, xml, selector) {
// removes node from doc at selector
module.exports.prunePLIST = prunePLIST;
function prunePLIST(doc, xml, selector) {
var obj = plist.parse('<plist>'+xml+'</plist>');
function prunePLIST (doc, xml, selector) {
var obj = plist.parse('<plist>' + xml + '</plist>');
pruneOBJECT(doc, selector, obj);
return true;
}
function pruneOBJECT(doc, selector, fragment) {
function pruneOBJECT (doc, selector, fragment) {
if (Array.isArray(fragment) && Array.isArray(doc[selector])) {
var empty = true;
for (var i in fragment) {
......@@ -66,13 +66,11 @@ function pruneOBJECT(doc, selector, fragment) {
empty = pruneOBJECT(doc[selector], j, fragment[i]) && empty;
}
}
if (empty)
{
if (empty) {
delete doc[selector];
return true;
}
}
else if (nodeEqual(doc[selector], fragment)) {
} else if (nodeEqual(doc[selector], fragment)) {
delete doc[selector];
return true;
}
......@@ -80,14 +78,11 @@ function pruneOBJECT(doc, selector, fragment) {
return false;
}
function nodeEqual(node1, node2) {
if (typeof node1 != typeof node2)
return false;
else if (typeof node1 == 'string') {
node2 = escapeRE(node2).replace(new RegExp('\\$[a-zA-Z0-9-_]+','gm'),'(.*?)');
function nodeEqual (node1, node2) {
if (typeof node1 !== typeof node2) { return false; } else if (typeof node1 === 'string') {
node2 = escapeRE(node2).replace(/\\\$\S+/gm, '(.*?)');
return new RegExp('^' + node2 + '$').test(node1);
}
else {
} else {
for (var key in node2) {
if (!nodeEqual(node1[key], node2[key])) return false;
}
......@@ -96,6 +91,6 @@ function nodeEqual(node1, node2) {
}
// escape string for use in regex
function escapeRE(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '$&');
function escapeRE (str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment