http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-creator/bplistCreator.js ---------------------------------------------------------------------- diff --git a/node_modules/bplist-creator/bplistCreator.js b/node_modules/bplist-creator/bplistCreator.js new file mode 100644 index 0000000..b480826 --- /dev/null +++ b/node_modules/bplist-creator/bplistCreator.js @@ -0,0 +1,404 @@ +'use strict'; + +// adapted from http://code.google.com/p/plist/source/browse/trunk/src/main/java/com/dd/plist/BinaryPropertyListWriter.java + +var streamBuffers = require("stream-buffers"); + +var debug = false; + +function Real(value) { + this.value = value; +} + +module.exports = function(dicts) { + var buffer = new streamBuffers.WritableStreamBuffer(); + buffer.write(new Buffer("bplist00")); + + if (debug) { + console.log('create', require('util').inspect(dicts, false, 10)); + } + + if (dicts instanceof Array && dicts.length === 1) { + dicts = dicts[0]; + } + + var entries = toEntries(dicts); + if (debug) { + console.log('entries', entries); + } + var idSizeInBytes = computeIdSizeInBytes(entries.length); + var offsets = []; + var offsetSizeInBytes; + var offsetTableOffset; + + updateEntryIds(); + + entries.forEach(function(entry, entryIdx) { + offsets[entryIdx] = buffer.size(); + if (!entry) { + buffer.write(0x00); + } else { + write(entry); + } + }); + + writeOffsetTable(); + writeTrailer(); + return buffer.getContents(); + + function updateEntryIds() { + var strings = {}; + var entryId = 0; + entries.forEach(function(entry) { + if (entry.id) { + return; + } + if (entry.type === 'string') { + if (!entry.bplistOverride && strings.hasOwnProperty(entry.value)) { + entry.type = 'stringref'; + entry.id = strings[entry.value]; + } else { + strings[entry.value] = entry.id = entryId++; + } + } else { + entry.id = entryId++; + } + }); + + entries = entries.filter(function(entry) { + return (entry.type !== 'stringref'); + }); + } + + function writeTrailer() { + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeTrailer'); + } + // 6 null bytes + buffer.write(new Buffer([0, 0, 0, 0, 0, 0])); + + // size of an offset + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeTrailer(offsetSizeInBytes):', offsetSizeInBytes); + } + writeByte(offsetSizeInBytes); + + // size of a ref + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeTrailer(offsetSizeInBytes):', idSizeInBytes); + } + writeByte(idSizeInBytes); + + // number of objects + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeTrailer(number of objects):', entries.length); + } + writeLong(entries.length); + + // top object + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeTrailer(top object)'); + } + writeLong(0); + + // offset table offset + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeTrailer(offset table offset):', offsetTableOffset); + } + writeLong(offsetTableOffset); + } + + function writeOffsetTable() { + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeOffsetTable'); + } + offsetTableOffset = buffer.size(); + offsetSizeInBytes = computeOffsetSizeInBytes(offsetTableOffset); + offsets.forEach(function(offset) { + writeBytes(offset, offsetSizeInBytes); + }); + } + + function write(entry) { + switch (entry.type) { + case 'dict': + writeDict(entry); + break; + case 'number': + case 'double': + writeNumber(entry); + break; + case 'array': + writeArray(entry); + break; + case 'boolean': + writeBoolean(entry); + break; + case 'string': + case 'string-utf16': + writeString(entry); + break; + case 'data': + writeData(entry); + break; + default: + throw new Error("unhandled entry type: " + entry.type); + } + } + + function writeDict(entry) { + if (debug) { + var keysStr = entry.entryKeys.map(function(k) {return k.id;}); + var valsStr = entry.entryValues.map(function(k) {return k.id;}); + console.log('0x' + buffer.size().toString(16), 'writeDict', '(id: ' + entry.id + ')', '(keys: ' + keysStr + ')', '(values: ' + valsStr + ')'); + } + writeIntHeader(0xD, entry.entryKeys.length); + entry.entryKeys.forEach(function(entry) { + writeID(entry.id); + }); + entry.entryValues.forEach(function(entry) { + writeID(entry.id); + }); + } + + function writeNumber(entry) { + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeNumber', entry.value, ' (type: ' + entry.type + ')', '(id: ' + entry.id + ')'); + } + + if (entry.type !== 'double' && parseFloat(entry.value.toFixed()) == entry.value) { + if (entry.value < 0) { + writeByte(0x13); + writeBytes(entry.value, 8); + } else if (entry.value <= 0xff) { + writeByte(0x10); + writeBytes(entry.value, 1); + } else if (entry.value <= 0xffff) { + writeByte(0x11); + writeBytes(entry.value, 2); + } else if (entry.value <= 0xffffffff) { + writeByte(0x12); + writeBytes(entry.value, 4); + } else { + writeByte(0x13); + writeBytes(entry.value, 8); + } + } else { + writeByte(0x23); + writeDouble(entry.value); + } + } + + function writeArray(entry) { + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeArray (length: ' + entry.entries.length + ')', '(id: ' + entry.id + ')'); + } + writeIntHeader(0xA, entry.entries.length); + entry.entries.forEach(function(e) { + writeID(e.id); + }); + } + + function writeBoolean(entry) { + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeBoolean', entry.value, '(id: ' + entry.id + ')'); + } + writeByte(entry.value ? 0x09 : 0x08); + } + + function writeString(entry) { + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeString', entry.value, '(id: ' + entry.id + ')'); + } + if (entry.type === 'string-utf16') { + var utf16 = new Buffer(entry.value, 'ucs2'); + writeIntHeader(0x6, utf16.length / 2); + // needs to be big endian so swap the bytes + for (var i = 0; i < utf16.length; i += 2) { + var t = utf16[i + 0]; + utf16[i + 0] = utf16[i + 1]; + utf16[i + 1] = t; + } + buffer.write(utf16); + } else { + var utf8 = new Buffer(entry.value, 'utf8'); + writeIntHeader(0x5, utf8.length); + buffer.write(utf8); + } + } + + function writeData(entry) { + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeData', entry.value, '(id: ' + entry.id + ')'); + } + writeIntHeader(0x4, entry.value.length); + buffer.write(entry.value); + } + + function writeLong(l) { + writeBytes(l, 8); + } + + function writeByte(b) { + buffer.write(new Buffer([b])); + } + + function writeDouble(v) { + var buf = new Buffer(8); + buf.writeDoubleBE(v, 0); + buffer.write(buf); + } + + function writeIntHeader(kind, value) { + if (value < 15) { + writeByte((kind << 4) + value); + } else if (value < 256) { + writeByte((kind << 4) + 15); + writeByte(0x10); + writeBytes(value, 1); + } else if (value < 65536) { + writeByte((kind << 4) + 15); + writeByte(0x11); + writeBytes(value, 2); + } else { + writeByte((kind << 4) + 15); + writeByte(0x12); + writeBytes(value, 4); + } + } + + function writeID(id) { + writeBytes(id, idSizeInBytes); + } + + function writeBytes(value, bytes) { + // write low-order bytes big-endian style + var buf = new Buffer(bytes); + var z = 0; + // javascript doesn't handle large numbers + while (bytes > 4) { + buf[z++] = 0; + bytes--; + } + for (var i = bytes - 1; i >= 0; i--) { + buf[z++] = value >> (8 * i); + } + buffer.write(buf); + } +}; + +function toEntries(dicts) { + if (dicts.bplistOverride) { + return [dicts]; + } + + if (dicts instanceof Array) { + return toEntriesArray(dicts); + } else if (dicts instanceof Buffer) { + return [ + { + type: 'data', + value: dicts + } + ]; + } else if (dicts instanceof Real) { + return [ + { + type: 'double', + value: dicts.value + } + ]; + } else if (typeof(dicts) === 'object') { + return toEntriesObject(dicts); + } else if (typeof(dicts) === 'string') { + return [ + { + type: 'string', + value: dicts + } + ]; + } else if (typeof(dicts) === 'number') { + return [ + { + type: 'number', + value: dicts + } + ]; + } else if (typeof(dicts) === 'boolean') { + return [ + { + type: 'boolean', + value: dicts + } + ]; + } else { + throw new Error('unhandled entry: ' + dicts); + } +} + +function toEntriesArray(arr) { + if (debug) { + console.log('toEntriesArray'); + } + var results = [ + { + type: 'array', + entries: [] + } + ]; + arr.forEach(function(v) { + var entry = toEntries(v); + results[0].entries.push(entry[0]); + results = results.concat(entry); + }); + return results; +} + +function toEntriesObject(dict) { + if (debug) { + console.log('toEntriesObject'); + } + var results = [ + { + type: 'dict', + entryKeys: [], + entryValues: [] + } + ]; + Object.keys(dict).forEach(function(key) { + var entryKey = toEntries(key); + results[0].entryKeys.push(entryKey[0]); + results = results.concat(entryKey[0]); + }); + Object.keys(dict).forEach(function(key) { + var entryValue = toEntries(dict[key]); + results[0].entryValues.push(entryValue[0]); + results = results.concat(entryValue); + }); + return results; +} + +function computeOffsetSizeInBytes(maxOffset) { + if (maxOffset < 256) { + return 1; + } + if (maxOffset < 65536) { + return 2; + } + if (maxOffset < 4294967296) { + return 4; + } + return 8; +} + +function computeIdSizeInBytes(numberOfIds) { + if (numberOfIds < 256) { + return 1; + } + if (numberOfIds < 65536) { + return 2; + } + return 4; +} + +module.exports.Real = Real;
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-creator/package.json ---------------------------------------------------------------------- diff --git a/node_modules/bplist-creator/package.json b/node_modules/bplist-creator/package.json new file mode 100644 index 0000000..3d8d90b --- /dev/null +++ b/node_modules/bplist-creator/package.json @@ -0,0 +1,79 @@ +{ + "_args": [ + [ + "[email protected]", + "/Users/steveng/repo/cordova/cordova-osx/node_modules/simple-plist" + ] + ], + "_from": "[email protected]", + "_id": "[email protected]", + "_inCache": true, + "_installable": true, + "_location": "/bplist-creator", + "_npmUser": { + "email": "[email protected]", + "name": "joeferner" + }, + "_npmVersion": "1.4.10", + "_phantomChildren": {}, + "_requested": { + "name": "bplist-creator", + "raw": "[email protected]", + "rawSpec": "0.0.4", + "scope": null, + "spec": "0.0.4", + "type": "version" + }, + "_requiredBy": [ + "/simple-plist" + ], + "_resolved": "http://registry.npmjs.org/bplist-creator/-/bplist-creator-0.0.4.tgz", + "_shasum": "4ac0496782e127a85c1d2026a4f5eb22a7aff991", + "_shrinkwrap": null, + "_spec": "[email protected]", + "_where": "/Users/steveng/repo/cordova/cordova-osx/node_modules/simple-plist", + "author": { + "name": "https://github.com/nearinfinity/node-bplist-parser.git" + }, + "bugs": { + "url": "https://github.com/nearinfinity/node-bplist-creator/issues" + }, + "dependencies": { + "stream-buffers": "~0.2.3" + }, + "description": "Binary Mac OS X Plist (property list) creator.", + "devDependencies": { + "bplist-parser": "0.0.4", + "nodeunit": "0.7.4" + }, + "directories": {}, + "dist": { + "shasum": "4ac0496782e127a85c1d2026a4f5eb22a7aff991", + "tarball": "http://registry.npmjs.org/bplist-creator/-/bplist-creator-0.0.4.tgz" + }, + "homepage": "https://github.com/nearinfinity/node-bplist-creator", + "keywords": [ + "bplist", + "creator", + "plist" + ], + "license": "MIT", + "main": "bplistCreator.js", + "maintainers": [ + { + "name": "joeferner", + "email": "[email protected]" + } + ], + "name": "bplist-creator", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/nearinfinity/node-bplist-creator.git" + }, + "scripts": { + "test": "./node_modules/nodeunit/bin/nodeunit test" + }, + "version": "0.0.4" +} http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-creator/test/airplay.bplist ---------------------------------------------------------------------- diff --git a/node_modules/bplist-creator/test/airplay.bplist b/node_modules/bplist-creator/test/airplay.bplist new file mode 100644 index 0000000..931adea Binary files /dev/null and b/node_modules/bplist-creator/test/airplay.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-creator/test/binaryData.bplist ---------------------------------------------------------------------- diff --git a/node_modules/bplist-creator/test/binaryData.bplist b/node_modules/bplist-creator/test/binaryData.bplist new file mode 100644 index 0000000..4c03581 Binary files /dev/null and b/node_modules/bplist-creator/test/binaryData.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-creator/test/creatorTest.js ---------------------------------------------------------------------- diff --git a/node_modules/bplist-creator/test/creatorTest.js b/node_modules/bplist-creator/test/creatorTest.js new file mode 100644 index 0000000..af427a1 --- /dev/null +++ b/node_modules/bplist-creator/test/creatorTest.js @@ -0,0 +1,197 @@ +'use strict'; + +var fs = require('fs'); +var path = require('path'); +var nodeunit = require('nodeunit'); +var bplistParser = require('bplist-parser'); +var bplistCreator = require('../'); + +module.exports = { +// 'iTunes Small': function(test) { +// var file = path.join(__dirname, "iTunes-small.bplist"); +// testFile(test, file); +// }, + + 'sample1': function(test) { + var file = path.join(__dirname, "sample1.bplist"); + testFile(test, file); + }, + + 'sample2': function(test) { + var file = path.join(__dirname, "sample2.bplist"); + testFile(test, file); + }, + + 'binary data': function(test) { + var file = path.join(__dirname, "binaryData.bplist"); + testFile(test, file); + }, + + 'airplay': function(test) { + var file = path.join(__dirname, "airplay.bplist"); + testFile(test, file); + }, + +// 'utf16': function(test) { +// var file = path.join(__dirname, "utf16.bplist"); +// testFile(test, file); +// }, + +// 'uid': function(test) { +// var file = path.join(__dirname, "uid.bplist"); +// testFile(test, file); +// } +}; + +function testFile(test, file) { + fs.readFile(file, function(err, fileData) { + if (err) { + return test.done(err); + } + + bplistParser.parseFile(file, function(err, dicts) { + if (err) { + return test.done(err); + } + + // airplay overrides + if (dicts && dicts[0] && dicts[0].loadedTimeRanges && dicts[0].loadedTimeRanges[0] && dicts[0].loadedTimeRanges[0].hasOwnProperty('start')) { + dicts[0].loadedTimeRanges[0].start = { + bplistOverride: true, + type: 'double', + value: dicts[0].loadedTimeRanges[0].start + }; + } + if (dicts && dicts[0] && dicts[0].loadedTimeRanges && dicts[0].seekableTimeRanges[0] && dicts[0].seekableTimeRanges[0].hasOwnProperty('start')) { + dicts[0].seekableTimeRanges[0].start = { + bplistOverride: true, + type: 'double', + value: dicts[0].seekableTimeRanges[0].start + }; + } + if (dicts && dicts[0] && dicts[0].hasOwnProperty('rate')) { + dicts[0].rate = { + bplistOverride: true, + type: 'double', + value: dicts[0].rate + }; + } + + // utf16 + if (dicts && dicts[0] && dicts[0].hasOwnProperty('NSHumanReadableCopyright')) { + dicts[0].NSHumanReadableCopyright = { + bplistOverride: true, + type: 'string-utf16', + value: dicts[0].NSHumanReadableCopyright + }; + } + if (dicts && dicts[0] && dicts[0].hasOwnProperty('CFBundleExecutable')) { + dicts[0].CFBundleExecutable = { + bplistOverride: true, + type: 'string', + value: dicts[0].CFBundleExecutable + }; + } + if (dicts && dicts[0] && dicts[0].CFBundleURLTypes && dicts[0].CFBundleURLTypes[0] && dicts[0].CFBundleURLTypes[0].hasOwnProperty('CFBundleURLSchemes')) { + dicts[0].CFBundleURLTypes[0].CFBundleURLSchemes[0] = { + bplistOverride: true, + type: 'string', + value: dicts[0].CFBundleURLTypes[0].CFBundleURLSchemes[0] + }; + } + if (dicts && dicts[0] && dicts[0].hasOwnProperty('CFBundleDisplayName')) { + dicts[0].CFBundleDisplayName = { + bplistOverride: true, + type: 'string', + value: dicts[0].CFBundleDisplayName + }; + } + if (dicts && dicts[0] && dicts[0].hasOwnProperty('DTPlatformBuild')) { + dicts[0].DTPlatformBuild = { + bplistOverride: true, + type: 'string', + value: dicts[0].DTPlatformBuild + }; + } + + var buf = bplistCreator(dicts); + compareBuffers(test, buf, fileData); + return test.done(); + }); + }); +} + +function compareBuffers(test, buf1, buf2) { + if (buf1.length !== buf2.length) { + printBuffers(buf1, buf2); + return test.fail("buffer size mismatch. found: " + buf1.length + ", expected: " + buf2.length + "."); + } + for (var i = 0; i < buf1.length; i++) { + if (buf1[i] !== buf2[i]) { + printBuffers(buf1, buf2); + return test.fail("buffer mismatch at offset 0x" + i.toString(16) + ". found: 0x" + buf1[i].toString(16) + ", expected: 0x" + buf2[i].toString(16) + "."); + } + } +} + +function printBuffers(buf1, buf2) { + var i, t; + for (var lineOffset = 0; lineOffset < buf1.length || lineOffset < buf2.length; lineOffset += 16) { + var line = ''; + + t = ('000000000' + lineOffset.toString(16)); + line += t.substr(t.length - 8) + ': '; + + for (i = 0; i < 16; i++) { + if (i == 8) { + line += ' '; + } + if (lineOffset + i < buf1.length) { + t = ('00' + buf1[lineOffset + i].toString(16)); + line += t.substr(t.length - 2) + ' '; + } else { + line += ' '; + } + } + line += ' '; + for (i = 0; i < 16; i++) { + if (lineOffset + i < buf1.length) { + t = String.fromCharCode(buf1[lineOffset + i]); + if (t < ' ' || t > '~') { + t = '.'; + } + line += t; + } else { + line += ' '; + } + } + + line += ' - '; + + for (i = 0; i < 16; i++) { + if (i == 8) { + line += ' '; + } + if (lineOffset + i < buf2.length) { + t = ('00' + buf2[lineOffset + i].toString(16)); + line += t.substr(t.length - 2) + ' '; + } else { + line += ' '; + } + } + line += ' '; + for (i = 0; i < 16; i++) { + if (lineOffset + i < buf2.length) { + t = String.fromCharCode(buf2[lineOffset + i]); + if (t < ' ' || t > '~') { + t = '.'; + } + line += t; + } else { + line += ' '; + } + } + + console.log(line); + } +} http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-creator/test/iTunes-small.bplist ---------------------------------------------------------------------- diff --git a/node_modules/bplist-creator/test/iTunes-small.bplist b/node_modules/bplist-creator/test/iTunes-small.bplist new file mode 100644 index 0000000..b7edb14 Binary files /dev/null and b/node_modules/bplist-creator/test/iTunes-small.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-creator/test/sample1.bplist ---------------------------------------------------------------------- diff --git a/node_modules/bplist-creator/test/sample1.bplist b/node_modules/bplist-creator/test/sample1.bplist new file mode 100644 index 0000000..5b808ff Binary files /dev/null and b/node_modules/bplist-creator/test/sample1.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-creator/test/sample2.bplist ---------------------------------------------------------------------- diff --git a/node_modules/bplist-creator/test/sample2.bplist b/node_modules/bplist-creator/test/sample2.bplist new file mode 100644 index 0000000..fc42979 Binary files /dev/null and b/node_modules/bplist-creator/test/sample2.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-creator/test/uid.bplist ---------------------------------------------------------------------- diff --git a/node_modules/bplist-creator/test/uid.bplist b/node_modules/bplist-creator/test/uid.bplist new file mode 100644 index 0000000..59f341e Binary files /dev/null and b/node_modules/bplist-creator/test/uid.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-creator/test/utf16.bplist ---------------------------------------------------------------------- diff --git a/node_modules/bplist-creator/test/utf16.bplist b/node_modules/bplist-creator/test/utf16.bplist new file mode 100644 index 0000000..ba4bcfa Binary files /dev/null and b/node_modules/bplist-creator/test/utf16.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-parser/.npmignore ---------------------------------------------------------------------- diff --git a/node_modules/bplist-parser/.npmignore b/node_modules/bplist-parser/.npmignore new file mode 100644 index 0000000..a9b46ea --- /dev/null +++ b/node_modules/bplist-parser/.npmignore @@ -0,0 +1,8 @@ +/build/* +node_modules +*.node +*.sh +*.swp +.lock* +npm-debug.log +.idea http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-parser/README.md ---------------------------------------------------------------------- diff --git a/node_modules/bplist-parser/README.md b/node_modules/bplist-parser/README.md new file mode 100644 index 0000000..37e5e1c --- /dev/null +++ b/node_modules/bplist-parser/README.md @@ -0,0 +1,47 @@ +bplist-parser +============= + +Binary Mac OS X Plist (property list) parser. + +## Installation + +```bash +$ npm install bplist-parser +``` + +## Quick Examples + +```javascript +var bplist = require('bplist-parser'); + +bplist.parseFile('myPlist.bplist', function(err, obj) { + if (err) throw err; + + console.log(JSON.stringify(obj)); +}); +``` + +## License + +(The MIT License) + +Copyright (c) 2012 Near Infinity Corporation + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-parser/bplistParser.js ---------------------------------------------------------------------- diff --git a/node_modules/bplist-parser/bplistParser.js b/node_modules/bplist-parser/bplistParser.js new file mode 100644 index 0000000..f8335bc --- /dev/null +++ b/node_modules/bplist-parser/bplistParser.js @@ -0,0 +1,357 @@ +'use strict'; + +// adapted from http://code.google.com/p/plist/source/browse/trunk/src/com/dd/plist/BinaryPropertyListParser.java + +var fs = require('fs'); +var bigInt = require("big-integer"); +var debug = false; + +exports.maxObjectSize = 100 * 1000 * 1000; // 100Meg +exports.maxObjectCount = 32768; + +// EPOCH = new SimpleDateFormat("yyyy MM dd zzz").parse("2001 01 01 GMT").getTime(); +// ...but that's annoying in a static initializer because it can throw exceptions, ick. +// So we just hardcode the correct value. +var EPOCH = 978307200000; + +// UID object definition +var UID = exports.UID = function(id) { + this.UID = id; +} + +var parseFile = exports.parseFile = function (fileNameOrBuffer, callback) { + function tryParseBuffer(buffer) { + var err = null; + var result; + try { + result = parseBuffer(buffer); + } catch (ex) { + err = ex; + } + callback(err, result); + } + + if (Buffer.isBuffer(fileNameOrBuffer)) { + return tryParseBuffer(fileNameOrBuffer); + } else { + fs.readFile(fileNameOrBuffer, function (err, data) { + if (err) { return callback(err); } + tryParseBuffer(data); + }); + } +}; + +var parseBuffer = exports.parseBuffer = function (buffer) { + var result = {}; + + // check header + var header = buffer.slice(0, 'bplist'.length).toString('utf8'); + if (header !== 'bplist') { + throw new Error("Invalid binary plist. Expected 'bplist' at offset 0."); + } + + // Handle trailer, last 32 bytes of the file + var trailer = buffer.slice(buffer.length - 32, buffer.length); + // 6 null bytes (index 0 to 5) + var offsetSize = trailer.readUInt8(6); + if (debug) { + console.log("offsetSize: " + offsetSize); + } + var objectRefSize = trailer.readUInt8(7); + if (debug) { + console.log("objectRefSize: " + objectRefSize); + } + var numObjects = readUInt64BE(trailer, 8); + if (debug) { + console.log("numObjects: " + numObjects); + } + var topObject = readUInt64BE(trailer, 16); + if (debug) { + console.log("topObject: " + topObject); + } + var offsetTableOffset = readUInt64BE(trailer, 24); + if (debug) { + console.log("offsetTableOffset: " + offsetTableOffset); + } + + if (numObjects > exports.maxObjectCount) { + throw new Error("maxObjectCount exceeded"); + } + + // Handle offset table + var offsetTable = []; + + for (var i = 0; i < numObjects; i++) { + var offsetBytes = buffer.slice(offsetTableOffset + i * offsetSize, offsetTableOffset + (i + 1) * offsetSize); + offsetTable[i] = readUInt(offsetBytes, 0); + if (debug) { + console.log("Offset for Object #" + i + " is " + offsetTable[i] + " [" + offsetTable[i].toString(16) + "]"); + } + } + + // Parses an object inside the currently parsed binary property list. + // For the format specification check + // <a href="http://www.opensource.apple.com/source/CF/CF-635/CFBinaryPList.c"> + // Apple's binary property list parser implementation</a>. + function parseObject(tableOffset) { + var offset = offsetTable[tableOffset]; + var type = buffer[offset]; + var objType = (type & 0xF0) >> 4; //First 4 bits + var objInfo = (type & 0x0F); //Second 4 bits + switch (objType) { + case 0x0: + return parseSimple(); + case 0x1: + return parseInteger(); + case 0x8: + return parseUID(); + case 0x2: + return parseReal(); + case 0x3: + return parseDate(); + case 0x4: + return parseData(); + case 0x5: // ASCII + return parsePlistString(); + case 0x6: // UTF-16 + return parsePlistString(true); + case 0xA: + return parseArray(); + case 0xD: + return parseDictionary(); + default: + throw new Error("Unhandled type 0x" + objType.toString(16)); + } + + function parseSimple() { + //Simple + switch (objInfo) { + case 0x0: // null + return null; + case 0x8: // false + return false; + case 0x9: // true + return true; + case 0xF: // filler byte + return null; + default: + throw new Error("Unhandled simple type 0x" + objType.toString(16)); + } + } + + function bufferToHexString(buffer) { + var str = ''; + var i; + for (i = 0; i < buffer.length; i++) { + if (buffer[i] != 0x00) { + break; + } + } + for (; i < buffer.length; i++) { + var part = '00' + buffer[i].toString(16); + str += part.substr(part.length - 2); + } + return str; + } + + function parseInteger() { + var length = Math.pow(2, objInfo); + if (length > 4) { + var data = buffer.slice(offset + 1, offset + 1 + length); + var str = bufferToHexString(data); + return bigInt(str, 16); + } if (length < exports.maxObjectSize) { + return readUInt(buffer.slice(offset + 1, offset + 1 + length)); + } else { + throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); + } + } + + function parseUID() { + var length = objInfo + 1; + if (length < exports.maxObjectSize) { + return new UID(readUInt(buffer.slice(offset + 1, offset + 1 + length))); + } else { + throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); + } + } + + function parseReal() { + var length = Math.pow(2, objInfo); + if (length < exports.maxObjectSize) { + var realBuffer = buffer.slice(offset + 1, offset + 1 + length); + if (length === 4) { + return realBuffer.readFloatBE(0); + } + else if (length === 8) { + return realBuffer.readDoubleBE(0); + } + } else { + throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); + } + } + + function parseDate() { + if (objInfo != 0x3) { + console.error("Unknown date type :" + objInfo + ". Parsing anyway..."); + } + var dateBuffer = buffer.slice(offset + 1, offset + 9); + return new Date(EPOCH + (1000 * dateBuffer.readDoubleBE(0))); + } + + function parseData() { + var dataoffset = 1; + var length = objInfo; + if (objInfo == 0xF) { + var int_type = buffer[offset + 1]; + var intType = (int_type & 0xF0) / 0x10; + if (intType != 0x1) { + console.error("0x4: UNEXPECTED LENGTH-INT TYPE! " + intType); + } + var intInfo = int_type & 0x0F; + var intLength = Math.pow(2, intInfo); + dataoffset = 2 + intLength; + if (intLength < 3) { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } else { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } + } + if (length < exports.maxObjectSize) { + return buffer.slice(offset + dataoffset, offset + dataoffset + length); + } else { + throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); + } + } + + function parsePlistString (isUtf16) { + isUtf16 = isUtf16 || 0; + var enc = "utf8"; + var length = objInfo; + var stroffset = 1; + if (objInfo == 0xF) { + var int_type = buffer[offset + 1]; + var intType = (int_type & 0xF0) / 0x10; + if (intType != 0x1) { + console.err("UNEXPECTED LENGTH-INT TYPE! " + intType); + } + var intInfo = int_type & 0x0F; + var intLength = Math.pow(2, intInfo); + var stroffset = 2 + intLength; + if (intLength < 3) { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } else { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } + } + // length is String length -> to get byte length multiply by 2, as 1 character takes 2 bytes in UTF-16 + length *= (isUtf16 + 1); + if (length < exports.maxObjectSize) { + var plistString = new Buffer(buffer.slice(offset + stroffset, offset + stroffset + length)); + if (isUtf16) { + plistString = swapBytes(plistString); + enc = "ucs2"; + } + return plistString.toString(enc); + } else { + throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); + } + } + + function parseArray() { + var length = objInfo; + var arrayoffset = 1; + if (objInfo == 0xF) { + var int_type = buffer[offset + 1]; + var intType = (int_type & 0xF0) / 0x10; + if (intType != 0x1) { + console.error("0xa: UNEXPECTED LENGTH-INT TYPE! " + intType); + } + var intInfo = int_type & 0x0F; + var intLength = Math.pow(2, intInfo); + arrayoffset = 2 + intLength; + if (intLength < 3) { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } else { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } + } + if (length * objectRefSize > exports.maxObjectSize) { + throw new Error("To little heap space available!"); + } + var array = []; + for (var i = 0; i < length; i++) { + var objRef = readUInt(buffer.slice(offset + arrayoffset + i * objectRefSize, offset + arrayoffset + (i + 1) * objectRefSize)); + array[i] = parseObject(objRef); + } + return array; + } + + function parseDictionary() { + var length = objInfo; + var dictoffset = 1; + if (objInfo == 0xF) { + var int_type = buffer[offset + 1]; + var intType = (int_type & 0xF0) / 0x10; + if (intType != 0x1) { + console.error("0xD: UNEXPECTED LENGTH-INT TYPE! " + intType); + } + var intInfo = int_type & 0x0F; + var intLength = Math.pow(2, intInfo); + dictoffset = 2 + intLength; + if (intLength < 3) { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } else { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } + } + if (length * 2 * objectRefSize > exports.maxObjectSize) { + throw new Error("To little heap space available!"); + } + if (debug) { + console.log("Parsing dictionary #" + tableOffset); + } + var dict = {}; + for (var i = 0; i < length; i++) { + var keyRef = readUInt(buffer.slice(offset + dictoffset + i * objectRefSize, offset + dictoffset + (i + 1) * objectRefSize)); + var valRef = readUInt(buffer.slice(offset + dictoffset + (length * objectRefSize) + i * objectRefSize, offset + dictoffset + (length * objectRefSize) + (i + 1) * objectRefSize)); + var key = parseObject(keyRef); + var val = parseObject(valRef); + if (debug) { + console.log(" DICT #" + tableOffset + ": Mapped " + key + " to " + val); + } + dict[key] = val; + } + return dict; + } + } + + return [ parseObject(topObject) ]; +}; + +function readUInt(buffer, start) { + start = start || 0; + + var l = 0; + for (var i = start; i < buffer.length; i++) { + l <<= 8; + l |= buffer[i] & 0xFF; + } + return l; +} + +// we're just going to toss the high order bits because javascript doesn't have 64-bit ints +function readUInt64BE(buffer, start) { + var data = buffer.slice(start, start + 8); + return data.readUInt32BE(4, 8); +} + +function swapBytes(buffer) { + var len = buffer.length; + for (var i = 0; i < len; i += 2) { + var a = buffer[i]; + buffer[i] = buffer[i+1]; + buffer[i+1] = a; + } + return buffer; +} http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-parser/package.json ---------------------------------------------------------------------- diff --git a/node_modules/bplist-parser/package.json b/node_modules/bplist-parser/package.json new file mode 100644 index 0000000..f4d2d0f --- /dev/null +++ b/node_modules/bplist-parser/package.json @@ -0,0 +1,81 @@ +{ + "_args": [ + [ + "bplist-parser@^0.1.0", + "/Users/steveng/repo/cordova/cordova-osx/node_modules/cordova-common" + ] + ], + "_from": "bplist-parser@>=0.1.0 <0.2.0", + "_id": "[email protected]", + "_inCache": true, + "_installable": true, + "_location": "/bplist-parser", + "_nodeVersion": "5.1.0", + "_npmUser": { + "email": "[email protected]", + "name": "joeferner" + }, + "_npmVersion": "3.4.0", + "_phantomChildren": {}, + "_requested": { + "name": "bplist-parser", + "raw": "bplist-parser@^0.1.0", + "rawSpec": "^0.1.0", + "scope": null, + "spec": ">=0.1.0 <0.2.0", + "type": "range" + }, + "_requiredBy": [ + "/cordova-common" + ], + "_resolved": "http://registry.npmjs.org/bplist-parser/-/bplist-parser-0.1.1.tgz", + "_shasum": "d60d5dcc20cba6dc7e1f299b35d3e1f95dafbae6", + "_shrinkwrap": null, + "_spec": "bplist-parser@^0.1.0", + "_where": "/Users/steveng/repo/cordova/cordova-osx/node_modules/cordova-common", + "author": { + "email": "[email protected]", + "name": "Joe Ferner" + }, + "bugs": { + "url": "https://github.com/nearinfinity/node-bplist-parser/issues" + }, + "dependencies": { + "big-integer": "^1.6.7" + }, + "description": "Binary plist parser.", + "devDependencies": { + "nodeunit": "~0.9.1" + }, + "directories": {}, + "dist": { + "shasum": "d60d5dcc20cba6dc7e1f299b35d3e1f95dafbae6", + "tarball": "http://registry.npmjs.org/bplist-parser/-/bplist-parser-0.1.1.tgz" + }, + "gitHead": "c4f22650de2cc95edd21a6e609ff0654a2b951bd", + "homepage": "https://github.com/nearinfinity/node-bplist-parser#readme", + "keywords": [ + "bplist", + "parser", + "plist" + ], + "license": "MIT", + "main": "bplistParser.js", + "maintainers": [ + { + "name": "joeferner", + "email": "[email protected]" + } + ], + "name": "bplist-parser", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/nearinfinity/node-bplist-parser.git" + }, + "scripts": { + "test": "./node_modules/nodeunit/bin/nodeunit test" + }, + "version": "0.1.1" +} http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-parser/test/airplay.bplist ---------------------------------------------------------------------- diff --git a/node_modules/bplist-parser/test/airplay.bplist b/node_modules/bplist-parser/test/airplay.bplist new file mode 100644 index 0000000..931adea Binary files /dev/null and b/node_modules/bplist-parser/test/airplay.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-parser/test/iTunes-small.bplist ---------------------------------------------------------------------- diff --git a/node_modules/bplist-parser/test/iTunes-small.bplist b/node_modules/bplist-parser/test/iTunes-small.bplist new file mode 100644 index 0000000..b7edb14 Binary files /dev/null and b/node_modules/bplist-parser/test/iTunes-small.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-parser/test/int64.bplist ---------------------------------------------------------------------- diff --git a/node_modules/bplist-parser/test/int64.bplist b/node_modules/bplist-parser/test/int64.bplist new file mode 100644 index 0000000..6da9c04 Binary files /dev/null and b/node_modules/bplist-parser/test/int64.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-parser/test/int64.xml ---------------------------------------------------------------------- diff --git a/node_modules/bplist-parser/test/int64.xml b/node_modules/bplist-parser/test/int64.xml new file mode 100644 index 0000000..cc6cb03 --- /dev/null +++ b/node_modules/bplist-parser/test/int64.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> + <dict> + <key>zero</key> + <integer>0</integer> + <key>int64item</key> + <integer>12345678901234567890</integer> + </dict> +</plist> http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-parser/test/parseTest.js ---------------------------------------------------------------------- diff --git a/node_modules/bplist-parser/test/parseTest.js b/node_modules/bplist-parser/test/parseTest.js new file mode 100644 index 0000000..67e7bfa --- /dev/null +++ b/node_modules/bplist-parser/test/parseTest.js @@ -0,0 +1,159 @@ +'use strict'; + +// tests are adapted from https://github.com/TooTallNate/node-plist + +var path = require('path'); +var nodeunit = require('nodeunit'); +var bplist = require('../'); + +module.exports = { + 'iTunes Small': function (test) { + var file = path.join(__dirname, "iTunes-small.bplist"); + var startTime1 = new Date(); + + bplist.parseFile(file, function (err, dicts) { + if (err) { + throw err; + } + + var endTime = new Date(); + console.log('Parsed "' + file + '" in ' + (endTime - startTime1) + 'ms'); + var dict = dicts[0]; + test.equal(dict['Application Version'], "9.0.3"); + test.equal(dict['Library Persistent ID'], "6F81D37F95101437"); + test.done(); + }); + }, + + 'sample1': function (test) { + var file = path.join(__dirname, "sample1.bplist"); + var startTime = new Date(); + + bplist.parseFile(file, function (err, dicts) { + if (err) { + throw err; + } + + var endTime = new Date(); + console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms'); + var dict = dicts[0]; + test.equal(dict['CFBundleIdentifier'], 'com.apple.dictionary.MySample'); + test.done(); + }); + }, + + 'sample2': function (test) { + var file = path.join(__dirname, "sample2.bplist"); + var startTime = new Date(); + + bplist.parseFile(file, function (err, dicts) { + if (err) { + throw err; + } + + var endTime = new Date(); + console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms'); + var dict = dicts[0]; + test.equal(dict['PopupMenu'][2]['Key'], "\n #import <Cocoa/Cocoa.h>\n\n#import <MacRuby/MacRuby.h>\n\nint main(int argc, char *argv[])\n{\n return macruby_main(\"rb_main.rb\", argc, argv);\n}\n"); + test.done(); + }); + }, + + 'airplay': function (test) { + var file = path.join(__dirname, "airplay.bplist"); + var startTime = new Date(); + + bplist.parseFile(file, function (err, dicts) { + if (err) { + throw err; + } + + var endTime = new Date(); + console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms'); + + var dict = dicts[0]; + test.equal(dict['duration'], 5555.0495000000001); + test.equal(dict['position'], 4.6269989039999997); + test.done(); + }); + }, + + 'utf16': function (test) { + var file = path.join(__dirname, "utf16.bplist"); + var startTime = new Date(); + + bplist.parseFile(file, function (err, dicts) { + if (err) { + throw err; + } + + var endTime = new Date(); + console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms'); + + var dict = dicts[0]; + test.equal(dict['CFBundleName'], 'sellStuff'); + test.equal(dict['CFBundleShortVersionString'], '2.6.1'); + test.equal(dict['NSHumanReadableCopyright'], '©2008-2012, sellStuff, Inc.'); + test.done(); + }); + }, + + 'utf16chinese': function (test) { + var file = path.join(__dirname, "utf16_chinese.plist"); + var startTime = new Date(); + + bplist.parseFile(file, function (err, dicts) { + if (err) { + throw err; + } + + var endTime = new Date(); + console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms'); + + var dict = dicts[0]; + test.equal(dict['CFBundleName'], '天翼é 读'); + test.equal(dict['CFBundleDisplayName'], '天翼é 读'); + test.done(); + }); + }, + + + + 'uid': function (test) { + var file = path.join(__dirname, "uid.bplist"); + var startTime = new Date(); + + bplist.parseFile(file, function (err, dicts) { + if (err) { + throw err; + } + + var endTime = new Date(); + console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms'); + + var dict = dicts[0]; + test.deepEqual(dict['$objects'][1]['NS.keys'], [{UID:2}, {UID:3}, {UID:4}]); + test.deepEqual(dict['$objects'][1]['NS.objects'], [{UID: 5}, {UID:6}, {UID:7}]); + test.deepEqual(dict['$top']['root'], {UID:1}); + test.done(); + }); + }, + + 'int64': function (test) { + var file = path.join(__dirname, "int64.bplist"); + var startTime = new Date(); + + bplist.parseFile(file, function (err, dicts) { + if (err) { + throw err; + } + + var endTime = new Date(); + console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms'); + var dict = dicts[0]; + test.equal(dict['zero'], '0'); + test.equal(dict['int64item'], '12345678901234567890'); + test.done(); + }); + } +}; http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-parser/test/sample1.bplist ---------------------------------------------------------------------- diff --git a/node_modules/bplist-parser/test/sample1.bplist b/node_modules/bplist-parser/test/sample1.bplist new file mode 100644 index 0000000..5b808ff Binary files /dev/null and b/node_modules/bplist-parser/test/sample1.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-parser/test/sample2.bplist ---------------------------------------------------------------------- diff --git a/node_modules/bplist-parser/test/sample2.bplist b/node_modules/bplist-parser/test/sample2.bplist new file mode 100644 index 0000000..fc42979 Binary files /dev/null and b/node_modules/bplist-parser/test/sample2.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-parser/test/uid.bplist ---------------------------------------------------------------------- diff --git a/node_modules/bplist-parser/test/uid.bplist b/node_modules/bplist-parser/test/uid.bplist new file mode 100644 index 0000000..59f341e Binary files /dev/null and b/node_modules/bplist-parser/test/uid.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-parser/test/utf16.bplist ---------------------------------------------------------------------- diff --git a/node_modules/bplist-parser/test/utf16.bplist b/node_modules/bplist-parser/test/utf16.bplist new file mode 100644 index 0000000..ba4bcfa Binary files /dev/null and b/node_modules/bplist-parser/test/utf16.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/bplist-parser/test/utf16_chinese.plist ---------------------------------------------------------------------- diff --git a/node_modules/bplist-parser/test/utf16_chinese.plist b/node_modules/bplist-parser/test/utf16_chinese.plist new file mode 100755 index 0000000..ba1e2d7 Binary files /dev/null and b/node_modules/bplist-parser/test/utf16_chinese.plist differ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/brace-expansion/.npmignore ---------------------------------------------------------------------- diff --git a/node_modules/brace-expansion/.npmignore b/node_modules/brace-expansion/.npmignore new file mode 100644 index 0000000..353546a --- /dev/null +++ b/node_modules/brace-expansion/.npmignore @@ -0,0 +1,3 @@ +test +.gitignore +.travis.yml http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/brace-expansion/README.md ---------------------------------------------------------------------- diff --git a/node_modules/brace-expansion/README.md b/node_modules/brace-expansion/README.md new file mode 100644 index 0000000..1793929 --- /dev/null +++ b/node_modules/brace-expansion/README.md @@ -0,0 +1,122 @@ +# brace-expansion + +[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html), +as known from sh/bash, in JavaScript. + +[](http://travis-ci.org/juliangruber/brace-expansion) +[](https://www.npmjs.org/package/brace-expansion) + +[](https://ci.testling.com/juliangruber/brace-expansion) + +## Example + +```js +var expand = require('brace-expansion'); + +expand('file-{a,b,c}.jpg') +// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg'] + +expand('-v{,,}') +// => ['-v', '-v', '-v'] + +expand('file{0..2}.jpg') +// => ['file0.jpg', 'file1.jpg', 'file2.jpg'] + +expand('file-{a..c}.jpg') +// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg'] + +expand('file{2..0}.jpg') +// => ['file2.jpg', 'file1.jpg', 'file0.jpg'] + +expand('file{0..4..2}.jpg') +// => ['file0.jpg', 'file2.jpg', 'file4.jpg'] + +expand('file-{a..e..2}.jpg') +// => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg'] + +expand('file{00..10..5}.jpg') +// => ['file00.jpg', 'file05.jpg', 'file10.jpg'] + +expand('{{A..C},{a..c}}') +// => ['A', 'B', 'C', 'a', 'b', 'c'] + +expand('ppp{,config,oe{,conf}}') +// => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf'] +``` + +## API + +```js +var expand = require('brace-expansion'); +``` + +### var expanded = expand(str) + +Return an array of all possible and valid expansions of `str`. If none are +found, `[str]` is returned. + +Valid expansions are: + +```js +/^(.*,)+(.+)?$/ +// {a,b,...} +``` + +A comma seperated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`. + +```js +/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/ +// {x..y[..incr]} +``` + +A numeric sequence from `x` to `y` inclusive, with optional increment. +If `x` or `y` start with a leading `0`, all the numbers will be padded +to have equal length. Negative numbers and backwards iteration work too. + +```js +/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/ +// {x..y[..incr]} +``` + +An alphabetic sequence from `x` to `y` inclusive, with optional increment. +`x` and `y` must be exactly one character, and if given, `incr` must be a +number. + +For compatibility reasons, the string `${` is not eligible for brace expansion. + +## Installation + +With [npm](https://npmjs.org) do: + +```bash +npm install brace-expansion +``` + +## Contributors + +- [Julian Gruber](https://github.com/juliangruber) +- [Isaac Z. Schlueter](https://github.com/isaacs) + +## License + +(MIT) + +Copyright (c) 2013 Julian Gruber <[email protected]> + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/brace-expansion/example.js ---------------------------------------------------------------------- diff --git a/node_modules/brace-expansion/example.js b/node_modules/brace-expansion/example.js new file mode 100644 index 0000000..60ecfc7 --- /dev/null +++ b/node_modules/brace-expansion/example.js @@ -0,0 +1,8 @@ +var expand = require('./'); + +console.log(expand('http://any.org/archive{1996..1999}/vol{1..4}/part{a,b,c}.html')); +console.log(expand('http://www.numericals.com/file{1..100..10}.txt')); +console.log(expand('http://www.letters.com/file{a..z..2}.txt')); +console.log(expand('mkdir /usr/local/src/bash/{old,new,dist,bugs}')); +console.log(expand('chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}')); + http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/brace-expansion/index.js ---------------------------------------------------------------------- diff --git a/node_modules/brace-expansion/index.js b/node_modules/brace-expansion/index.js new file mode 100644 index 0000000..932718f --- /dev/null +++ b/node_modules/brace-expansion/index.js @@ -0,0 +1,191 @@ +var concatMap = require('concat-map'); +var balanced = require('balanced-match'); + +module.exports = expandTop; + +var escSlash = '\0SLASH'+Math.random()+'\0'; +var escOpen = '\0OPEN'+Math.random()+'\0'; +var escClose = '\0CLOSE'+Math.random()+'\0'; +var escComma = '\0COMMA'+Math.random()+'\0'; +var escPeriod = '\0PERIOD'+Math.random()+'\0'; + +function numeric(str) { + return parseInt(str, 10) == str + ? parseInt(str, 10) + : str.charCodeAt(0); +} + +function escapeBraces(str) { + return str.split('\\\\').join(escSlash) + .split('\\{').join(escOpen) + .split('\\}').join(escClose) + .split('\\,').join(escComma) + .split('\\.').join(escPeriod); +} + +function unescapeBraces(str) { + return str.split(escSlash).join('\\') + .split(escOpen).join('{') + .split(escClose).join('}') + .split(escComma).join(',') + .split(escPeriod).join('.'); +} + + +// Basically just str.split(","), but handling cases +// where we have nested braced sections, which should be +// treated as individual members, like {a,{b,c},d} +function parseCommaParts(str) { + if (!str) + return ['']; + + var parts = []; + var m = balanced('{', '}', str); + + if (!m) + return str.split(','); + + var pre = m.pre; + var body = m.body; + var post = m.post; + var p = pre.split(','); + + p[p.length-1] += '{' + body + '}'; + var postParts = parseCommaParts(post); + if (post.length) { + p[p.length-1] += postParts.shift(); + p.push.apply(p, postParts); + } + + parts.push.apply(parts, p); + + return parts; +} + +function expandTop(str) { + if (!str) + return []; + + return expand(escapeBraces(str), true).map(unescapeBraces); +} + +function identity(e) { + return e; +} + +function embrace(str) { + return '{' + str + '}'; +} +function isPadded(el) { + return /^-?0\d/.test(el); +} + +function lte(i, y) { + return i <= y; +} +function gte(i, y) { + return i >= y; +} + +function expand(str, isTop) { + var expansions = []; + + var m = balanced('{', '}', str); + if (!m || /\$$/.test(m.pre)) return [str]; + + 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); + if (!isSequence && !isOptions) { + // {a},b} + if (m.post.match(/,.*\}/)) { + str = m.pre + '{' + m.body + escClose + m.post; + return expand(str); + } + return [str]; + } + + var n; + if (isSequence) { + n = m.body.split(/\.\./); + } else { + n = parseCommaParts(m.body); + if (n.length === 1) { + // x{{a,b}}y ==> x{a}y x{b}y + n = expand(n[0], false).map(embrace); + if (n.length === 1) { + var post = m.post.length + ? expand(m.post, false) + : ['']; + return post.map(function(p) { + return m.pre + n[0] + p; + }); + } + } + } + + // at this point, n is the parts, and we know it's not a comma set + // with a single entry. + + // no need to expand pre, since it is guaranteed to be free of brace-sets + var pre = m.pre; + var post = m.post.length + ? expand(m.post, false) + : ['']; + + var N; + + if (isSequence) { + var x = numeric(n[0]); + var y = numeric(n[1]); + var width = Math.max(n[0].length, n[1].length) + var incr = n.length == 3 + ? Math.abs(numeric(n[2])) + : 1; + var test = lte; + var reverse = y < x; + if (reverse) { + incr *= -1; + test = gte; + } + var pad = n.some(isPadded); + + N = []; + + for (var i = x; test(i, y); i += incr) { + var c; + if (isAlphaSequence) { + c = String.fromCharCode(i); + if (c === '\\') + c = ''; + } else { + c = String(i); + if (pad) { + var need = width - c.length; + if (need > 0) { + var z = new Array(need + 1).join('0'); + if (i < 0) + c = '-' + z + c.slice(1); + else + c = z + c; + } + } + } + N.push(c); + } + } else { + N = concatMap(n, function(el) { return expand(el, false) }); + } + + for (var j = 0; j < N.length; j++) { + for (var k = 0; k < post.length; k++) { + var expansion = pre + N[j] + post[k]; + if (!isTop || isSequence || expansion) + expansions.push(expansion); + } + } + + return expansions; +} + http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/brace-expansion/package.json ---------------------------------------------------------------------- diff --git a/node_modules/brace-expansion/package.json b/node_modules/brace-expansion/package.json new file mode 100644 index 0000000..acbbaa3 --- /dev/null +++ b/node_modules/brace-expansion/package.json @@ -0,0 +1,104 @@ +{ + "_args": [ + [ + "brace-expansion@^1.0.0", + "/Users/steveng/repo/cordova/cordova-osx/node_modules/minimatch" + ] + ], + "_from": "brace-expansion@>=1.0.0 <2.0.0", + "_id": "[email protected]", + "_inCache": true, + "_installable": true, + "_location": "/brace-expansion", + "_nodeVersion": "5.5.0", + "_npmOperationalInternal": { + "host": "packages-6-west.internal.npmjs.com", + "tmp": "tmp/brace-expansion-1.1.3.tgz_1455216688668_0.948847763473168" + }, + "_npmUser": { + "email": "[email protected]", + "name": "juliangruber" + }, + "_npmVersion": "3.3.12", + "_phantomChildren": {}, + "_requested": { + "name": "brace-expansion", + "raw": "brace-expansion@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/minimatch" + ], + "_resolved": "http://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.3.tgz", + "_shasum": "46bff50115d47fc9ab89854abb87d98078a10991", + "_shrinkwrap": null, + "_spec": "brace-expansion@^1.0.0", + "_where": "/Users/steveng/repo/cordova/cordova-osx/node_modules/minimatch", + "author": { + "email": "[email protected]", + "name": "Julian Gruber", + "url": "http://juliangruber.com" + }, + "bugs": { + "url": "https://github.com/juliangruber/brace-expansion/issues" + }, + "dependencies": { + "balanced-match": "^0.3.0", + "concat-map": "0.0.1" + }, + "description": "Brace expansion as known from sh/bash", + "devDependencies": { + "tape": "4.4.0" + }, + "directories": {}, + "dist": { + "shasum": "46bff50115d47fc9ab89854abb87d98078a10991", + "tarball": "http://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.3.tgz" + }, + "gitHead": "f0da1bb668e655f67b6b2d660c6e1c19e2a6f231", + "homepage": "https://github.com/juliangruber/brace-expansion", + "keywords": [], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "juliangruber", + "email": "[email protected]" + }, + { + "name": "isaacs", + "email": "[email protected]" + } + ], + "name": "brace-expansion", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/juliangruber/brace-expansion.git" + }, + "scripts": { + "gentest": "bash test/generate.sh", + "test": "tape test/*.js" + }, + "testling": { + "browsers": [ + "android-browser/4.2..latest", + "chrome/25..latest", + "chrome/canary", + "firefox/20..latest", + "firefox/nightly", + "ie/8..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "opera/12..latest", + "opera/next", + "safari/5.1..latest" + ], + "files": "test/*.js" + }, + "version": "1.1.3" +} http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/concat-map/.travis.yml ---------------------------------------------------------------------- diff --git a/node_modules/concat-map/.travis.yml b/node_modules/concat-map/.travis.yml new file mode 100644 index 0000000..f1d0f13 --- /dev/null +++ b/node_modules/concat-map/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - 0.4 + - 0.6 http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/concat-map/LICENSE ---------------------------------------------------------------------- diff --git a/node_modules/concat-map/LICENSE b/node_modules/concat-map/LICENSE new file mode 100644 index 0000000..ee27ba4 --- /dev/null +++ b/node_modules/concat-map/LICENSE @@ -0,0 +1,18 @@ +This software is released under the MIT license: + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/concat-map/README.markdown ---------------------------------------------------------------------- diff --git a/node_modules/concat-map/README.markdown b/node_modules/concat-map/README.markdown new file mode 100644 index 0000000..408f70a --- /dev/null +++ b/node_modules/concat-map/README.markdown @@ -0,0 +1,62 @@ +concat-map +========== + +Concatenative mapdashery. + +[](http://ci.testling.com/substack/node-concat-map) + +[](http://travis-ci.org/substack/node-concat-map) + +example +======= + +``` js +var concatMap = require('concat-map'); +var xs = [ 1, 2, 3, 4, 5, 6 ]; +var ys = concatMap(xs, function (x) { + return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; +}); +console.dir(ys); +``` + +*** + +``` +[ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ] +``` + +methods +======= + +``` js +var concatMap = require('concat-map') +``` + +concatMap(xs, fn) +----------------- + +Return an array of concatenated elements by calling `fn(x, i)` for each element +`x` and each index `i` in the array `xs`. + +When `fn(x, i)` returns an array, its result will be concatenated with the +result array. If `fn(x, i)` returns anything else, that value will be pushed +onto the end of the result array. + +install +======= + +With [npm](http://npmjs.org) do: + +``` +npm install concat-map +``` + +license +======= + +MIT + +notes +===== + +This module was written while sitting high above the ground in a tree. http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/concat-map/example/map.js ---------------------------------------------------------------------- diff --git a/node_modules/concat-map/example/map.js b/node_modules/concat-map/example/map.js new file mode 100644 index 0000000..3365621 --- /dev/null +++ b/node_modules/concat-map/example/map.js @@ -0,0 +1,6 @@ +var concatMap = require('../'); +var xs = [ 1, 2, 3, 4, 5, 6 ]; +var ys = concatMap(xs, function (x) { + return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; +}); +console.dir(ys); http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/concat-map/index.js ---------------------------------------------------------------------- diff --git a/node_modules/concat-map/index.js b/node_modules/concat-map/index.js new file mode 100644 index 0000000..b29a781 --- /dev/null +++ b/node_modules/concat-map/index.js @@ -0,0 +1,13 @@ +module.exports = function (xs, fn) { + var res = []; + for (var i = 0; i < xs.length; i++) { + var x = fn(xs[i], i); + if (isArray(x)) res.push.apply(res, x); + else res.push(x); + } + return res; +}; + +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/concat-map/package.json ---------------------------------------------------------------------- diff --git a/node_modules/concat-map/package.json b/node_modules/concat-map/package.json new file mode 100644 index 0000000..586e812 --- /dev/null +++ b/node_modules/concat-map/package.json @@ -0,0 +1,109 @@ +{ + "_args": [ + [ + "[email protected]", + "/Users/steveng/repo/cordova/cordova-osx/node_modules/brace-expansion" + ] + ], + "_from": "[email protected]", + "_id": "[email protected]", + "_inCache": true, + "_installable": true, + "_location": "/concat-map", + "_npmUser": { + "email": "[email protected]", + "name": "substack" + }, + "_npmVersion": "1.3.21", + "_phantomChildren": {}, + "_requested": { + "name": "concat-map", + "raw": "[email protected]", + "rawSpec": "0.0.1", + "scope": null, + "spec": "0.0.1", + "type": "version" + }, + "_requiredBy": [ + "/brace-expansion" + ], + "_resolved": "http://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "_shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b", + "_shrinkwrap": null, + "_spec": "[email protected]", + "_where": "/Users/steveng/repo/cordova/cordova-osx/node_modules/brace-expansion", + "author": { + "email": "[email protected]", + "name": "James Halliday", + "url": "http://substack.net" + }, + "bugs": { + "url": "https://github.com/substack/node-concat-map/issues" + }, + "dependencies": {}, + "description": "concatenative mapdashery", + "devDependencies": { + "tape": "~2.4.0" + }, + "directories": { + "example": "example", + "test": "test" + }, + "dist": { + "shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b", + "tarball": "http://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" + }, + "homepage": "https://github.com/substack/node-concat-map", + "keywords": [ + "concat", + "concatMap", + "functional", + "higher-order", + "map" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "substack", + "email": "[email protected]" + } + ], + "name": "concat-map", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/substack/node-concat-map.git" + }, + "scripts": { + "test": "tape test/*.js" + }, + "testling": { + "browsers": { + "chrome": [ + 10, + 22 + ], + "ff": [ + 10, + 15, + 3.5 + ], + "ie": [ + 6, + 7, + 8, + 9 + ], + "opera": [ + 12 + ], + "safari": [ + 5.1 + ] + }, + "files": "test/*.js" + }, + "version": "0.0.1" +} http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/concat-map/test/map.js ---------------------------------------------------------------------- diff --git a/node_modules/concat-map/test/map.js b/node_modules/concat-map/test/map.js new file mode 100644 index 0000000..fdbd702 --- /dev/null +++ b/node_modules/concat-map/test/map.js @@ -0,0 +1,39 @@ +var concatMap = require('../'); +var test = require('tape'); + +test('empty or not', function (t) { + var xs = [ 1, 2, 3, 4, 5, 6 ]; + var ixes = []; + var ys = concatMap(xs, function (x, ix) { + ixes.push(ix); + return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; + }); + t.same(ys, [ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ]); + t.same(ixes, [ 0, 1, 2, 3, 4, 5 ]); + t.end(); +}); + +test('always something', function (t) { + var xs = [ 'a', 'b', 'c', 'd' ]; + var ys = concatMap(xs, function (x) { + return x === 'b' ? [ 'B', 'B', 'B' ] : [ x ]; + }); + t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]); + t.end(); +}); + +test('scalars', function (t) { + var xs = [ 'a', 'b', 'c', 'd' ]; + var ys = concatMap(xs, function (x) { + return x === 'b' ? [ 'B', 'B', 'B' ] : x; + }); + t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]); + t.end(); +}); + +test('undefs', function (t) { + var xs = [ 'a', 'b', 'c', 'd' ]; + var ys = concatMap(xs, function () {}); + t.same(ys, [ undefined, undefined, undefined, undefined ]); + t.end(); +}); http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/cordova-common/.jscs.json ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/.jscs.json b/node_modules/cordova-common/.jscs.json new file mode 100644 index 0000000..5cc7e26 --- /dev/null +++ b/node_modules/cordova-common/.jscs.json @@ -0,0 +1,24 @@ +{ + "disallowMixedSpacesAndTabs": true, + "disallowTrailingWhitespace": true, + "validateLineBreaks": "LF", + "validateIndentation": 4, + "requireLineFeedAtFileEnd": true, + + "disallowSpaceAfterPrefixUnaryOperators": true, + "disallowSpaceBeforePostfixUnaryOperators": true, + "requireSpaceAfterLineComment": true, + "requireCapitalizedConstructors": true, + + "disallowSpacesInNamedFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + + "requireSpaceAfterKeywords": [ + "if", + "else", + "for", + "while", + "do" + ] +} http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/cordova-common/.jshintignore ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/.jshintignore b/node_modules/cordova-common/.jshintignore new file mode 100644 index 0000000..d606f61 --- /dev/null +++ b/node_modules/cordova-common/.jshintignore @@ -0,0 +1 @@ +spec/fixtures/* http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/cordova-common/.npmignore ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/.npmignore b/node_modules/cordova-common/.npmignore new file mode 100644 index 0000000..5d14118 --- /dev/null +++ b/node_modules/cordova-common/.npmignore @@ -0,0 +1,2 @@ +spec +coverage http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/cordova-common/.ratignore ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/.ratignore b/node_modules/cordova-common/.ratignore new file mode 100644 index 0000000..26f7205 --- /dev/null +++ b/node_modules/cordova-common/.ratignore @@ -0,0 +1,2 @@ +fixtures +coverage http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/cordova-common/README.md ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/README.md b/node_modules/cordova-common/README.md new file mode 100644 index 0000000..6454481 --- /dev/null +++ b/node_modules/cordova-common/README.md @@ -0,0 +1,153 @@ +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +--> + +# cordova-common +Expoeses shared functionality used by [cordova-lib](https://github.com/apache/cordova-lib/) and Cordova platforms. +## Exposed APIs + +### `events` + +Represents special instance of NodeJS EventEmitter which is intended to be used to post events to cordova-lib and cordova-cli + +Usage: +``` +var events = require('cordova-common').events; +events.emit('warn', 'Some warning message') +``` + +There are the following events supported by cordova-cli: `verbose`, `log`, `info`, `warn`, `error`. + +### `CordovaError` + +An 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). + +Usage: + +``` +var CordovaError = require('cordova-common').CordovaError; +throw new CordovaError('Some error message', SOME_ERR_CODE); +``` + +See [CordovaError](src/CordovaError/CordovaError.js) for supported error codes. + +### `ConfigParser` + +Exposes functionality to deal with cordova project `config.xml` files. For ConfigParser API reference check [ConfigParser Readme](src/ConfigParser/README.md). + +Usage: +``` +var ConfigParser = require('cordova-common').ConfigParser; +var appConfig = new ConfigParser('path/to/cordova-app/config.xml'); +console.log(appconfig.name() + ':' + appConfig.version()); +``` + +### `PluginInfoProvider` and `PluginInfo` + +`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. + +Usage: +``` +var PluginInfo: require('cordova-common').PluginInfo; +var PluginInfoProvider: require('cordova-common').PluginInfoProvider; + +// The following instances are equal +var plugin1 = new PluginInfo('path/to/plugin_directory'); +var plugin2 = new PluginInfoProvider().get('path/to/plugin_directory'); + +console.log('The plugin ' + plugin1.id + ' has version ' + plugin1.version) +``` + +### `ActionStack` + +Utility 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. + +Usage: +``` +var ActionStack = require('cordova-common').ActionStack; +var stack = new ActionStack() + +var action1 = stack.createAction(task1, [<task parameters>], task1_reverter, [<reverter_parameters>]); +var action2 = stack.createAction(task2, [<task parameters>], task2_reverter, [<reverter_parameters>]); + +stack.push(action1); +stack.push(action2); + +stack.process() +.then(function() { + // all actions succeded +}) +.catch(function(error){ + // One of actions failed with error +}) +``` + +### `superspawn` + +Module for spawning child processes with some advanced logic. + +Usage: +``` +var superspawn = require('cordova-common').superspawn; +superspawn.spawn('adb', ['devices']) +.progress(function(data){ + if (data.stderr) + console.error('"adb devices" raised an error: ' + data.stderr); +}) +.then(function(devices){ + // Do something... +}) +``` + +### `xmlHelpers` + +A set of utility methods for dealing with xml files. + +Usage: +``` +var xml = require('cordova-common').xmlHelpers; + +var xmlDoc1 = xml.parseElementtreeSync('some/xml/file'); +var xmlDoc2 = xml.parseElementtreeSync('another/xml/file'); + +xml.mergeXml(doc1, doc2); // doc2 now contains all the nodes from doc1 +``` + +### Other APIs + +The APIs listed below are also exposed but are intended to be only used internally by cordova plugin installation routines. + +``` +PlatformJson +ConfigChanges +ConfigKeeper +ConfigFile +mungeUtil +``` + +## Setup +* Clone this repository onto your local machine + `git clone https://git-wip-us.apache.org/repos/asf/cordova-lib.git` +* In terminal, navigate to the inner cordova-common directory + `cd cordova-lib/cordova-common` +* Install dependencies and npm-link + `npm install && npm link` +* Navigate to cordova-lib directory and link cordova-common + `cd ../cordova-lib && npm link cordova-common && npm install` http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/cordova-common/RELEASENOTES.md ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/RELEASENOTES.md b/node_modules/cordova-common/RELEASENOTES.md new file mode 100644 index 0000000..e7db69c --- /dev/null +++ b/node_modules/cordova-common/RELEASENOTES.md @@ -0,0 +1,42 @@ +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +--> +# Cordova-common Release Notes + +### 1.1.0 (Feb 16, 2016) +* CB-10482 Remove references to windows8 from cordova-lib/cli +* CB-10430 Adds forwardEvents method to easily connect two EventEmitters +* CB-10176 Adds CordovaLogger class, based on logger module from cordova-cli +* CB-10052 Expose child process' io streams via promise progress notification +* CB-10497 Prefer .bat over .cmd on windows platform +* CB-9984 Bumps plist version and fixes failing cordova-common test + +### 1.0.0 (Oct 29, 2015) + +* CB-9890 Documents cordova-common +* CB-9598 Correct cordova-lib -> cordova-common in README +* Pick ConfigParser changes from apache@0c3614e +* CB-9743 Removes system frameworks handling from ConfigChanges +* CB-9598 Cleans out code which has been moved to `cordova-common` +* Pick ConfigParser changes from apache@ddb027b +* Picking CordovaError changes from apache@a3b1fca +* CB-9598 Adds tests and fixtures based on existing cordova-lib ones +* CB-9598 Initial implementation for cordova-common + http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/cordova-common/cordova-common.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/cordova-common.js b/node_modules/cordova-common/cordova-common.js new file mode 100644 index 0000000..22e90a7 --- /dev/null +++ b/node_modules/cordova-common/cordova-common.js @@ -0,0 +1,43 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +/* jshint node:true */ + +// For now expose plugman and cordova just as they were in the old repos +exports = module.exports = { + events: require('./src/events'), + superspawn: require('./src/superspawn'), + + ActionStack: require('./src/ActionStack'), + CordovaError: require('./src/CordovaError/CordovaError'), + CordovaLogger: require('./src/CordovaLogger'), + CordovaExternalToolErrorContext: require('./src/CordovaError/CordovaExternalToolErrorContext'), + PlatformJson: require('./src/PlatformJson'), + ConfigParser: require('./src/ConfigParser/ConfigParser.js'), + + PluginInfo: require('./src/PluginInfo/PluginInfo.js'), + PluginInfoProvider: require('./src/PluginInfo/PluginInfoProvider.js'), + + ConfigChanges: require('./src/ConfigChanges/ConfigChanges.js'), + ConfigKeeper: require('./src/ConfigChanges/ConfigKeeper.js'), + ConfigFile: require('./src/ConfigChanges/ConfigFile.js'), + mungeUtil: require('./src/ConfigChanges/munge-util.js'), + + xmlHelpers: require('./src/util/xml-helpers') +}; http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/cordova-common/node_modules/.bin/shjs ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/node_modules/.bin/shjs b/node_modules/cordova-common/node_modules/.bin/shjs new file mode 120000 index 0000000..a044997 --- /dev/null +++ b/node_modules/cordova-common/node_modules/.bin/shjs @@ -0,0 +1 @@ +../shelljs/bin/shjs \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/cordova-common/node_modules/shelljs/.documentup.json ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/node_modules/shelljs/.documentup.json b/node_modules/cordova-common/node_modules/shelljs/.documentup.json new file mode 100644 index 0000000..57fe301 --- /dev/null +++ b/node_modules/cordova-common/node_modules/shelljs/.documentup.json @@ -0,0 +1,6 @@ +{ + "name": "ShellJS", + "twitter": [ + "r2r" + ] +} http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/cordova-common/node_modules/shelljs/.jshintrc ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/node_modules/shelljs/.jshintrc b/node_modules/cordova-common/node_modules/shelljs/.jshintrc new file mode 100644 index 0000000..a80c559 --- /dev/null +++ b/node_modules/cordova-common/node_modules/shelljs/.jshintrc @@ -0,0 +1,7 @@ +{ + "loopfunc": true, + "sub": true, + "undef": true, + "unused": true, + "node": true +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/cordova-common/node_modules/shelljs/.npmignore ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/node_modules/shelljs/.npmignore b/node_modules/cordova-common/node_modules/shelljs/.npmignore new file mode 100644 index 0000000..6b20c38 --- /dev/null +++ b/node_modules/cordova-common/node_modules/shelljs/.npmignore @@ -0,0 +1,2 @@ +test/ +tmp/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/cordova-common/node_modules/shelljs/.travis.yml ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/node_modules/shelljs/.travis.yml b/node_modules/cordova-common/node_modules/shelljs/.travis.yml new file mode 100644 index 0000000..1b3280a --- /dev/null +++ b/node_modules/cordova-common/node_modules/shelljs/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.10" + - "0.11" + - "0.12" + http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/7a58a67b/node_modules/cordova-common/node_modules/shelljs/LICENSE ---------------------------------------------------------------------- diff --git a/node_modules/cordova-common/node_modules/shelljs/LICENSE b/node_modules/cordova-common/node_modules/shelljs/LICENSE new file mode 100644 index 0000000..1b35ee9 --- /dev/null +++ b/node_modules/cordova-common/node_modules/shelljs/LICENSE @@ -0,0 +1,26 @@ +Copyright (c) 2012, Artur Adib <[email protected]> +All rights reserved. + +You may use this project under the terms of the New BSD license as follows: + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Artur Adib nor the + names of the contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL ARTUR ADIB BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
