diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 70c4efc9065..00000000000 --- a/.babelrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - presets: ["babel-preset-ts-node4-bluebird"], - plugins: [ - "./scripts/babel-plugin-version-transform.js" - ] -} \ No newline at end of file diff --git a/package.json b/package.json index d14723897f8..092f0a36d94 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "test-linux": "docker run --rm -ti -v ~/Library/Caches/electron:/root/.cache/electron -v ${PWD}:/project -v ${PWD##*/}-node-modules:/project/node_modules -v ~/.electron:/root/.electron electronuserland/builder:wine /bin/bash -c \"yarn && TEST_FILES=linux node ./test/out/helpers/runTests.js\"", "whitespace": "whitespace 'src/**/*.ts'", "docker-images": "docker/build.sh", - "update-deps": "npm-check-updates -a -x gitbook-plugin-github && node ./scripts/update-deps.js", + "update-deps": "npm-check-updates -a -x gitbook-plugin-github,chalk && node ./scripts/update-deps.js", "set-versions": "node test/out/helpers/setVersions.js", "release": "yarn set-versions && yarn compile && sh ./__publish.sh && conventional-changelog -p angular -i CHANGELOG.md -s", "schema": "typescript-json-schema packages/electron-builder/tsconfig.json Configuration --out packages/electron-builder/scheme.json --noExtraProps --useTypeOfKeyword --strictNullChecks --titles --required", @@ -31,9 +31,9 @@ "7zip-bin": "^2.2.7", "archiver": "^2.1.0", "async-exit-hook": "^2.0.1", - "aws-sdk": "^2.134.0", - "bluebird-lst": "^1.0.4", - "chalk": "^2.1.0", + "aws-sdk": "^2.135.0", + "bluebird-lst": "^1.0.5", + "chalk": "2.1.0", "chromium-pickle-js": "^0.2.0", "cuint": "^0.2.2", "debug": "^3.1.0", @@ -78,7 +78,7 @@ "@types/electron-is-dev": "^0.3.0", "@types/iconv-lite": "^0.0.1", "@types/ini": "^1.3.29", - "@types/jest": "^21.1.3", + "@types/jest": "^21.1.4", "@types/js-yaml": "^3.9.1", "@types/lodash.isequal": "^4.5.2", "@types/node-emoji": "^1.4.0", @@ -87,7 +87,7 @@ "@types/semver": "^5.4.0", "@types/source-map-support": "^0.4.0", "@types/stat-mode": "^0.2.0", - "babel-preset-ts-node4-bluebird": "^0.1.1", + "babel-preset-ts-node6-bluebird": "^1.0.1", "convert-source-map": "^1.5.0", "decompress-zip": "^0.3.0", "depcheck": "^0.6.8", @@ -106,7 +106,7 @@ "jsdoc-to-markdown": "^3.0.0", "path-sort": "^0.1.0", "serve-static": "^1.13.1", - "ts-babel": "^4.1.6", + "ts-babel": "^4.1.7", "ts-jsdoc": "^2.0.6", "tslint": "^5.7.0", "typescript": "^2.6.0-rc", @@ -134,5 +134,13 @@ }, "yargs": { "camel-case-expansion": false + }, + "babel": { + "presets": [ + "babel-preset-ts-node6-bluebird" + ], + "plugins": [ + "./scripts/babel-plugin-version-transform.js" + ] } } diff --git a/packages/app-package-builder/blake2s.js b/packages/app-package-builder/blake2s.js index 8ee4f2744dd..48bc3423063 100644 --- a/packages/app-package-builder/blake2s.js +++ b/packages/app-package-builder/blake2s.js @@ -1,1398 +1,1377 @@ /* Written in 2012-2014 by Dmitry Chestnykh. Public domain */ -var BLAKE2s = (function() { - var MAX_DIGEST_LENGTH = 32; - var BLOCK_LENGTH = 64; - var MAX_KEY_LENGTH = 32; - var PERSONALIZATION_LENGTH = 8; - var SALT_LENGTH = 8; +"use strict"; - var IV = new Uint32Array([ - 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 - ]); +const MAX_DIGEST_LENGTH = 32; +const BLOCK_LENGTH = 64; +const MAX_KEY_LENGTH = 32; +const PERSONALIZATION_LENGTH = 8; +const SALT_LENGTH = 8; - function isByteArray(a) { - var kind = Object.prototype.toString.call(a); - return kind === '[object Uint8Array]' || kind === '[object Array]'; - } +const IV = new Uint32Array([ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 +]); + +function isByteArray(a) { + let kind = Object.prototype.toString.call(a); + return kind === '[object Uint8Array]' || kind === '[object Array]'; +} - function checkConfig(config) { - for (var key in config) { - switch (key) { - case 'key': - case 'personalization': - case 'salt': - if (!isByteArray(config[key])) { - throw new TypeError(key + ' must be a Uint8Array or an Array of bytes'); - } - break; - default: - throw new Error('unexpected key in config: ' + key) +function checkConfig(config) { + for (const key in config) { + switch (key) { + case 'key': + case 'personalization': + case 'salt': + if (!isByteArray(config[key])) { + throw new TypeError(key + ' must be a Uint8Array or an Array of bytes'); } + break; + default: + throw new Error('unexpected key in config: ' + key) } } +} - function load32(a, i) { - return (a[i + 0] & 0xff) | ((a[i + 1] & 0xff) << 8) | - ((a[i + 2] & 0xff) << 16) | ((a[i + 3] & 0xff) << 24); - } +function load32(a, i) { + return (a[i + 0] & 0xff) | ((a[i + 1] & 0xff) << 8) | + ((a[i + 2] & 0xff) << 16) | ((a[i + 3] & 0xff) << 24); +} - function BLAKE2s(digestLength, keyOrConfig) { - if (typeof digestLength === 'undefined') - digestLength = MAX_DIGEST_LENGTH; +function BLAKE2s(digestLength, keyOrConfig) { + if (typeof digestLength === 'undefined') + digestLength = MAX_DIGEST_LENGTH; - if (digestLength <= 0 || digestLength > MAX_DIGEST_LENGTH) - throw new Error('bad digestLength'); + if (digestLength <= 0 || digestLength > MAX_DIGEST_LENGTH) + throw new Error('bad digestLength'); - this.digestLength = digestLength; + this.digestLength = digestLength; - var key, personalization, salt; - var keyLength = 0; + let key, personalization, salt; + let keyLength = 0; - if (isByteArray(keyOrConfig)) { - key = keyOrConfig; - keyLength = key.length; - } else if (typeof keyOrConfig === 'object') { - checkConfig(keyOrConfig); + if (isByteArray(keyOrConfig)) { + key = keyOrConfig; + keyLength = key.length; + } else if (typeof keyOrConfig === 'object') { + checkConfig(keyOrConfig); - key = keyOrConfig.key; - keyLength = key ? key.length : 0; - - salt = keyOrConfig.salt; - personalization = keyOrConfig.personalization; - } else if (keyOrConfig) { - throw new Error('unexpected key or config type'); - } + key = keyOrConfig.key; + keyLength = key ? key.length : 0; - if (keyLength > MAX_KEY_LENGTH) - throw new Error('key is too long'); - if (salt && salt.length !== SALT_LENGTH) - throw new Error('salt must be ' + SALT_LENGTH + ' bytes'); - if (personalization && personalization.length !== PERSONALIZATION_LENGTH) - throw new Error('personalization must be ' + PERSONALIZATION_LENGTH + ' bytes'); - - this.isFinished = false; + salt = keyOrConfig.salt; + personalization = keyOrConfig.personalization; + } else if (keyOrConfig) { + throw new Error('unexpected key or config type'); + } - // Hash state. - this.h = new Uint32Array(IV); + if (keyLength > MAX_KEY_LENGTH) + throw new Error('key is too long'); + if (salt && salt.length !== SALT_LENGTH) + throw new Error('salt must be ' + SALT_LENGTH + ' bytes'); + if (personalization && personalization.length !== PERSONALIZATION_LENGTH) + throw new Error('personalization must be ' + PERSONALIZATION_LENGTH + ' bytes'); - // XOR parts of parameter block into initial state. - var param = Buffer.from([digestLength & 0xff, keyLength, 1, 1]); - this.h[0] ^= load32(param, 0); + this.isFinished = false; - if (salt) { - this.h[4] ^= load32(salt, 0); - this.h[5] ^= load32(salt, 4); - } + // Hash state. + this.h = new Uint32Array(IV); - if (personalization) { - this.h[6] ^= load32(personalization, 0); - this.h[7] ^= load32(personalization, 4); - } + // XOR parts of parameter block into initial state. + let param = Buffer.from([digestLength & 0xff, keyLength, 1, 1]) + this.h[0] ^= load32(param, 0); - // Buffer for data. - this.x = Buffer.alloc(BLOCK_LENGTH); - this.nx = 0; - - // Byte counter. - this.t0 = 0; - this.t1 = 0; - - // Flags. - this.f0 = 0; - this.f1 = 0; + if (salt) { + this.h[4] ^= load32(salt, 0); + this.h[5] ^= load32(salt, 4); + } - // Fill buffer with key, if present. - if (keyLength > 0) { - for (var i = 0; i < keyLength; i++) this.x[i] = key[i]; - for (i = keyLength; i < BLOCK_LENGTH; i++) this.x[i] = 0; - this.nx = BLOCK_LENGTH; - } + if (personalization) { + this.h[6] ^= load32(personalization, 0); + this.h[7] ^= load32(personalization, 4); } - BLAKE2s.prototype.processBlock = function(length) { - this.t0 += length; - if (this.t0 != this.t0 >>> 0) { - this.t0 = 0; - this.t1++; - } + // Buffer for data. + this.x = Buffer.alloc(BLOCK_LENGTH); + this.nx = 0; - var v0 = this.h[0], - v1 = this.h[1], - v2 = this.h[2], - v3 = this.h[3], - v4 = this.h[4], - v5 = this.h[5], - v6 = this.h[6], - v7 = this.h[7], - v8 = IV[0], - v9 = IV[1], - v10 = IV[2], - v11 = IV[3], - v12 = IV[4] ^ this.t0, - v13 = IV[5] ^ this.t1, - v14 = IV[6] ^ this.f0, - v15 = IV[7] ^ this.f1; + // Byte counter. + this.t0 = 0; + this.t1 = 0; - var x = this.x; - var m0 = x[ 0] & 0xff | (x[ 1] & 0xff) << 8 | (x[ 2] & 0xff) << 16 | (x[ 3] & 0xff) << 24, - m1 = x[ 4] & 0xff | (x[ 5] & 0xff) << 8 | (x[ 6] & 0xff) << 16 | (x[ 7] & 0xff) << 24, - m2 = x[ 8] & 0xff | (x[ 9] & 0xff) << 8 | (x[10] & 0xff) << 16 | (x[11] & 0xff) << 24, - m3 = x[12] & 0xff | (x[13] & 0xff) << 8 | (x[14] & 0xff) << 16 | (x[15] & 0xff) << 24, - m4 = x[16] & 0xff | (x[17] & 0xff) << 8 | (x[18] & 0xff) << 16 | (x[19] & 0xff) << 24, - m5 = x[20] & 0xff | (x[21] & 0xff) << 8 | (x[22] & 0xff) << 16 | (x[23] & 0xff) << 24, - m6 = x[24] & 0xff | (x[25] & 0xff) << 8 | (x[26] & 0xff) << 16 | (x[27] & 0xff) << 24, - m7 = x[28] & 0xff | (x[29] & 0xff) << 8 | (x[30] & 0xff) << 16 | (x[31] & 0xff) << 24, - m8 = x[32] & 0xff | (x[33] & 0xff) << 8 | (x[34] & 0xff) << 16 | (x[35] & 0xff) << 24, - m9 = x[36] & 0xff | (x[37] & 0xff) << 8 | (x[38] & 0xff) << 16 | (x[39] & 0xff) << 24, - m10 = x[40] & 0xff | (x[41] & 0xff) << 8 | (x[42] & 0xff) << 16 | (x[43] & 0xff) << 24, - m11 = x[44] & 0xff | (x[45] & 0xff) << 8 | (x[46] & 0xff) << 16 | (x[47] & 0xff) << 24, - m12 = x[48] & 0xff | (x[49] & 0xff) << 8 | (x[50] & 0xff) << 16 | (x[51] & 0xff) << 24, - m13 = x[52] & 0xff | (x[53] & 0xff) << 8 | (x[54] & 0xff) << 16 | (x[55] & 0xff) << 24, - m14 = x[56] & 0xff | (x[57] & 0xff) << 8 | (x[58] & 0xff) << 16 | (x[59] & 0xff) << 24, - m15 = x[60] & 0xff | (x[61] & 0xff) << 8 | (x[62] & 0xff) << 16 | (x[63] & 0xff) << 24; + // Flags. + this.f0 = 0; + this.f1 = 0; - // Round 1. - v0 = v0 + m0 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 16) | v12 >>> 16; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 12) | v4 >>> 12; - v1 = v1 + m2 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 16) | v13 >>> 16; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 12) | v5 >>> 12; - v2 = v2 + m4 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 16) | v14 >>> 16; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 12) | v6 >>> 12; - v3 = v3 + m6 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 16) | v15 >>> 16; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 12) | v7 >>> 12; - v2 = v2 + m5 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 8) | v14 >>> 8; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 7) | v6 >>> 7; - v3 = v3 + m7 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 8) | v15 >>> 8; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 7) | v7 >>> 7; - v1 = v1 + m3 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 8) | v13 >>> 8; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 7) | v5 >>> 7; - v0 = v0 + m1 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 8) | v12 >>> 8; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 7) | v4 >>> 7; - v0 = v0 + m8 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 16) | v15 >>> 16; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 12) | v5 >>> 12; - v1 = v1 + m10 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 16) | v12 >>> 16; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 12) | v6 >>> 12; - v2 = v2 + m12 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 16) | v13 >>> 16; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 12) | v7 >>> 12; - v3 = v3 + m14 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 16) | v14 >>> 16; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 12) | v4 >>> 12; - v2 = v2 + m13 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 8) | v13 >>> 8; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 7) | v7 >>> 7; - v3 = v3 + m15 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 8) | v14 >>> 8; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 7) | v4 >>> 7; - v1 = v1 + m11 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 8) | v12 >>> 8; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 7) | v6 >>> 7; - v0 = v0 + m9 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 8) | v15 >>> 8; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 7) | v5 >>> 7; + // Fill buffer with key, if present. + if (keyLength > 0) { + for (let i = 0; i < keyLength; i++) this.x[i] = key[i]; + for (let i = keyLength; i < BLOCK_LENGTH; i++) this.x[i] = 0; + this.nx = BLOCK_LENGTH; + } +} - // Round 2. - v0 = v0 + m14 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 16) | v12 >>> 16; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 12) | v4 >>> 12; - v1 = v1 + m4 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 16) | v13 >>> 16; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 12) | v5 >>> 12; - v2 = v2 + m9 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 16) | v14 >>> 16; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 12) | v6 >>> 12; - v3 = v3 + m13 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 16) | v15 >>> 16; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 12) | v7 >>> 12; - v2 = v2 + m15 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 8) | v14 >>> 8; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 7) | v6 >>> 7; - v3 = v3 + m6 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 8) | v15 >>> 8; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 7) | v7 >>> 7; - v1 = v1 + m8 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 8) | v13 >>> 8; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 7) | v5 >>> 7; - v0 = v0 + m10 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 8) | v12 >>> 8; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 7) | v4 >>> 7; - v0 = v0 + m1 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 16) | v15 >>> 16; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 12) | v5 >>> 12; - v1 = v1 + m0 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 16) | v12 >>> 16; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 12) | v6 >>> 12; - v2 = v2 + m11 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 16) | v13 >>> 16; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 12) | v7 >>> 12; - v3 = v3 + m5 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 16) | v14 >>> 16; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 12) | v4 >>> 12; - v2 = v2 + m7 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 8) | v13 >>> 8; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 7) | v7 >>> 7; - v3 = v3 + m3 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 8) | v14 >>> 8; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 7) | v4 >>> 7; - v1 = v1 + m2 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 8) | v12 >>> 8; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 7) | v6 >>> 7; - v0 = v0 + m12 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 8) | v15 >>> 8; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 7) | v5 >>> 7; +BLAKE2s.prototype.processBlock = function(length) { + this.t0 += length; + if (this.t0 != this.t0 >>> 0) { + this.t0 = 0; + this.t1++; + } - // Round 3. - v0 = v0 + m11 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 16) | v12 >>> 16; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 12) | v4 >>> 12; - v1 = v1 + m12 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 16) | v13 >>> 16; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 12) | v5 >>> 12; - v2 = v2 + m5 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 16) | v14 >>> 16; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 12) | v6 >>> 12; - v3 = v3 + m15 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 16) | v15 >>> 16; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 12) | v7 >>> 12; - v2 = v2 + m2 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 8) | v14 >>> 8; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 7) | v6 >>> 7; - v3 = v3 + m13 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 8) | v15 >>> 8; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 7) | v7 >>> 7; - v1 = v1 + m0 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 8) | v13 >>> 8; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 7) | v5 >>> 7; - v0 = v0 + m8 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 8) | v12 >>> 8; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 7) | v4 >>> 7; - v0 = v0 + m10 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 16) | v15 >>> 16; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 12) | v5 >>> 12; - v1 = v1 + m3 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 16) | v12 >>> 16; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 12) | v6 >>> 12; - v2 = v2 + m7 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 16) | v13 >>> 16; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 12) | v7 >>> 12; - v3 = v3 + m9 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 16) | v14 >>> 16; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 12) | v4 >>> 12; - v2 = v2 + m1 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 8) | v13 >>> 8; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 7) | v7 >>> 7; - v3 = v3 + m4 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 8) | v14 >>> 8; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 7) | v4 >>> 7; - v1 = v1 + m6 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 8) | v12 >>> 8; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 7) | v6 >>> 7; - v0 = v0 + m14 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 8) | v15 >>> 8; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 7) | v5 >>> 7; + let v0 = this.h[0], + v1 = this.h[1], + v2 = this.h[2], + v3 = this.h[3], + v4 = this.h[4], + v5 = this.h[5], + v6 = this.h[6], + v7 = this.h[7], + v8 = IV[0], + v9 = IV[1], + v10 = IV[2], + v11 = IV[3], + v12 = IV[4] ^ this.t0, + v13 = IV[5] ^ this.t1, + v14 = IV[6] ^ this.f0, + v15 = IV[7] ^ this.f1; - // Round 4. - v0 = v0 + m7 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 16) | v12 >>> 16; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 12) | v4 >>> 12; - v1 = v1 + m3 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 16) | v13 >>> 16; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 12) | v5 >>> 12; - v2 = v2 + m13 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 16) | v14 >>> 16; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 12) | v6 >>> 12; - v3 = v3 + m11 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 16) | v15 >>> 16; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 12) | v7 >>> 12; - v2 = v2 + m12 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 8) | v14 >>> 8; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 7) | v6 >>> 7; - v3 = v3 + m14 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 8) | v15 >>> 8; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 7) | v7 >>> 7; - v1 = v1 + m1 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 8) | v13 >>> 8; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 7) | v5 >>> 7; - v0 = v0 + m9 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 8) | v12 >>> 8; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 7) | v4 >>> 7; - v0 = v0 + m2 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 16) | v15 >>> 16; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 12) | v5 >>> 12; - v1 = v1 + m5 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 16) | v12 >>> 16; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 12) | v6 >>> 12; - v2 = v2 + m4 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 16) | v13 >>> 16; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 12) | v7 >>> 12; - v3 = v3 + m15 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 16) | v14 >>> 16; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 12) | v4 >>> 12; - v2 = v2 + m0 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 8) | v13 >>> 8; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 7) | v7 >>> 7; - v3 = v3 + m8 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 8) | v14 >>> 8; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 7) | v4 >>> 7; - v1 = v1 + m10 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 8) | v12 >>> 8; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 7) | v6 >>> 7; - v0 = v0 + m6 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 8) | v15 >>> 8; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 7) | v5 >>> 7; + let x = this.x; + let m0 = x[ 0] & 0xff | (x[ 1] & 0xff) << 8 | (x[ 2] & 0xff) << 16 | (x[ 3] & 0xff) << 24, + m1 = x[ 4] & 0xff | (x[ 5] & 0xff) << 8 | (x[ 6] & 0xff) << 16 | (x[ 7] & 0xff) << 24, + m2 = x[ 8] & 0xff | (x[ 9] & 0xff) << 8 | (x[10] & 0xff) << 16 | (x[11] & 0xff) << 24, + m3 = x[12] & 0xff | (x[13] & 0xff) << 8 | (x[14] & 0xff) << 16 | (x[15] & 0xff) << 24, + m4 = x[16] & 0xff | (x[17] & 0xff) << 8 | (x[18] & 0xff) << 16 | (x[19] & 0xff) << 24, + m5 = x[20] & 0xff | (x[21] & 0xff) << 8 | (x[22] & 0xff) << 16 | (x[23] & 0xff) << 24, + m6 = x[24] & 0xff | (x[25] & 0xff) << 8 | (x[26] & 0xff) << 16 | (x[27] & 0xff) << 24, + m7 = x[28] & 0xff | (x[29] & 0xff) << 8 | (x[30] & 0xff) << 16 | (x[31] & 0xff) << 24, + m8 = x[32] & 0xff | (x[33] & 0xff) << 8 | (x[34] & 0xff) << 16 | (x[35] & 0xff) << 24, + m9 = x[36] & 0xff | (x[37] & 0xff) << 8 | (x[38] & 0xff) << 16 | (x[39] & 0xff) << 24, + m10 = x[40] & 0xff | (x[41] & 0xff) << 8 | (x[42] & 0xff) << 16 | (x[43] & 0xff) << 24, + m11 = x[44] & 0xff | (x[45] & 0xff) << 8 | (x[46] & 0xff) << 16 | (x[47] & 0xff) << 24, + m12 = x[48] & 0xff | (x[49] & 0xff) << 8 | (x[50] & 0xff) << 16 | (x[51] & 0xff) << 24, + m13 = x[52] & 0xff | (x[53] & 0xff) << 8 | (x[54] & 0xff) << 16 | (x[55] & 0xff) << 24, + m14 = x[56] & 0xff | (x[57] & 0xff) << 8 | (x[58] & 0xff) << 16 | (x[59] & 0xff) << 24, + m15 = x[60] & 0xff | (x[61] & 0xff) << 8 | (x[62] & 0xff) << 16 | (x[63] & 0xff) << 24; - // Round 5. - v0 = v0 + m9 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 16) | v12 >>> 16; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 12) | v4 >>> 12; - v1 = v1 + m5 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 16) | v13 >>> 16; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 12) | v5 >>> 12; - v2 = v2 + m2 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 16) | v14 >>> 16; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 12) | v6 >>> 12; - v3 = v3 + m10 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 16) | v15 >>> 16; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 12) | v7 >>> 12; - v2 = v2 + m4 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 8) | v14 >>> 8; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 7) | v6 >>> 7; - v3 = v3 + m15 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 8) | v15 >>> 8; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 7) | v7 >>> 7; - v1 = v1 + m7 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 8) | v13 >>> 8; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 7) | v5 >>> 7; - v0 = v0 + m0 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 8) | v12 >>> 8; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 7) | v4 >>> 7; - v0 = v0 + m14 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 16) | v15 >>> 16; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 12) | v5 >>> 12; - v1 = v1 + m11 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 16) | v12 >>> 16; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 12) | v6 >>> 12; - v2 = v2 + m6 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 16) | v13 >>> 16; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 12) | v7 >>> 12; - v3 = v3 + m3 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 16) | v14 >>> 16; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 12) | v4 >>> 12; - v2 = v2 + m8 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 8) | v13 >>> 8; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 7) | v7 >>> 7; - v3 = v3 + m13 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 8) | v14 >>> 8; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 7) | v4 >>> 7; - v1 = v1 + m12 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 8) | v12 >>> 8; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 7) | v6 >>> 7; - v0 = v0 + m1 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 8) | v15 >>> 8; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 7) | v5 >>> 7; + // Round 1. + v0 = v0 + m0 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 16) | v12 >>> 16; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 12) | v4 >>> 12; + v1 = v1 + m2 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 16) | v13 >>> 16; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 12) | v5 >>> 12; + v2 = v2 + m4 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 16) | v14 >>> 16; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 12) | v6 >>> 12; + v3 = v3 + m6 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 16) | v15 >>> 16; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 12) | v7 >>> 12; + v2 = v2 + m5 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 8) | v14 >>> 8; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 7) | v6 >>> 7; + v3 = v3 + m7 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 8) | v15 >>> 8; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 7) | v7 >>> 7; + v1 = v1 + m3 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 8) | v13 >>> 8; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 7) | v5 >>> 7; + v0 = v0 + m1 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 8) | v12 >>> 8; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 7) | v4 >>> 7; + v0 = v0 + m8 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 16) | v15 >>> 16; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 12) | v5 >>> 12; + v1 = v1 + m10 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 16) | v12 >>> 16; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 12) | v6 >>> 12; + v2 = v2 + m12 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 16) | v13 >>> 16; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 12) | v7 >>> 12; + v3 = v3 + m14 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 16) | v14 >>> 16; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 12) | v4 >>> 12; + v2 = v2 + m13 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 8) | v13 >>> 8; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 7) | v7 >>> 7; + v3 = v3 + m15 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 8) | v14 >>> 8; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 7) | v4 >>> 7; + v1 = v1 + m11 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 8) | v12 >>> 8; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 7) | v6 >>> 7; + v0 = v0 + m9 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 8) | v15 >>> 8; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 7) | v5 >>> 7; - // Round 6. - v0 = v0 + m2 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 16) | v12 >>> 16; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 12) | v4 >>> 12; - v1 = v1 + m6 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 16) | v13 >>> 16; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 12) | v5 >>> 12; - v2 = v2 + m0 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 16) | v14 >>> 16; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 12) | v6 >>> 12; - v3 = v3 + m8 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 16) | v15 >>> 16; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 12) | v7 >>> 12; - v2 = v2 + m11 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 8) | v14 >>> 8; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 7) | v6 >>> 7; - v3 = v3 + m3 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 8) | v15 >>> 8; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 7) | v7 >>> 7; - v1 = v1 + m10 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 8) | v13 >>> 8; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 7) | v5 >>> 7; - v0 = v0 + m12 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 8) | v12 >>> 8; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 7) | v4 >>> 7; - v0 = v0 + m4 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 16) | v15 >>> 16; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 12) | v5 >>> 12; - v1 = v1 + m7 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 16) | v12 >>> 16; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 12) | v6 >>> 12; - v2 = v2 + m15 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 16) | v13 >>> 16; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 12) | v7 >>> 12; - v3 = v3 + m1 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 16) | v14 >>> 16; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 12) | v4 >>> 12; - v2 = v2 + m14 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 8) | v13 >>> 8; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 7) | v7 >>> 7; - v3 = v3 + m9 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 8) | v14 >>> 8; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 7) | v4 >>> 7; - v1 = v1 + m5 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 8) | v12 >>> 8; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 7) | v6 >>> 7; - v0 = v0 + m13 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 8) | v15 >>> 8; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 7) | v5 >>> 7; + // Round 2. + v0 = v0 + m14 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 16) | v12 >>> 16; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 12) | v4 >>> 12; + v1 = v1 + m4 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 16) | v13 >>> 16; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 12) | v5 >>> 12; + v2 = v2 + m9 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 16) | v14 >>> 16; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 12) | v6 >>> 12; + v3 = v3 + m13 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 16) | v15 >>> 16; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 12) | v7 >>> 12; + v2 = v2 + m15 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 8) | v14 >>> 8; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 7) | v6 >>> 7; + v3 = v3 + m6 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 8) | v15 >>> 8; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 7) | v7 >>> 7; + v1 = v1 + m8 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 8) | v13 >>> 8; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 7) | v5 >>> 7; + v0 = v0 + m10 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 8) | v12 >>> 8; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 7) | v4 >>> 7; + v0 = v0 + m1 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 16) | v15 >>> 16; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 12) | v5 >>> 12; + v1 = v1 + m0 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 16) | v12 >>> 16; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 12) | v6 >>> 12; + v2 = v2 + m11 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 16) | v13 >>> 16; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 12) | v7 >>> 12; + v3 = v3 + m5 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 16) | v14 >>> 16; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 12) | v4 >>> 12; + v2 = v2 + m7 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 8) | v13 >>> 8; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 7) | v7 >>> 7; + v3 = v3 + m3 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 8) | v14 >>> 8; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 7) | v4 >>> 7; + v1 = v1 + m2 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 8) | v12 >>> 8; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 7) | v6 >>> 7; + v0 = v0 + m12 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 8) | v15 >>> 8; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 7) | v5 >>> 7; - // Round 7. - v0 = v0 + m12 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 16) | v12 >>> 16; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 12) | v4 >>> 12; - v1 = v1 + m1 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 16) | v13 >>> 16; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 12) | v5 >>> 12; - v2 = v2 + m14 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 16) | v14 >>> 16; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 12) | v6 >>> 12; - v3 = v3 + m4 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 16) | v15 >>> 16; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 12) | v7 >>> 12; - v2 = v2 + m13 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 8) | v14 >>> 8; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 7) | v6 >>> 7; - v3 = v3 + m10 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 8) | v15 >>> 8; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 7) | v7 >>> 7; - v1 = v1 + m15 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 8) | v13 >>> 8; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 7) | v5 >>> 7; - v0 = v0 + m5 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 8) | v12 >>> 8; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 7) | v4 >>> 7; - v0 = v0 + m0 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 16) | v15 >>> 16; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 12) | v5 >>> 12; - v1 = v1 + m6 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 16) | v12 >>> 16; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 12) | v6 >>> 12; - v2 = v2 + m9 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 16) | v13 >>> 16; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 12) | v7 >>> 12; - v3 = v3 + m8 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 16) | v14 >>> 16; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 12) | v4 >>> 12; - v2 = v2 + m2 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 8) | v13 >>> 8; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 7) | v7 >>> 7; - v3 = v3 + m11 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 8) | v14 >>> 8; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 7) | v4 >>> 7; - v1 = v1 + m3 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 8) | v12 >>> 8; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 7) | v6 >>> 7; - v0 = v0 + m7 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 8) | v15 >>> 8; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 7) | v5 >>> 7; + // Round 3. + v0 = v0 + m11 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 16) | v12 >>> 16; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 12) | v4 >>> 12; + v1 = v1 + m12 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 16) | v13 >>> 16; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 12) | v5 >>> 12; + v2 = v2 + m5 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 16) | v14 >>> 16; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 12) | v6 >>> 12; + v3 = v3 + m15 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 16) | v15 >>> 16; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 12) | v7 >>> 12; + v2 = v2 + m2 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 8) | v14 >>> 8; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 7) | v6 >>> 7; + v3 = v3 + m13 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 8) | v15 >>> 8; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 7) | v7 >>> 7; + v1 = v1 + m0 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 8) | v13 >>> 8; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 7) | v5 >>> 7; + v0 = v0 + m8 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 8) | v12 >>> 8; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 7) | v4 >>> 7; + v0 = v0 + m10 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 16) | v15 >>> 16; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 12) | v5 >>> 12; + v1 = v1 + m3 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 16) | v12 >>> 16; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 12) | v6 >>> 12; + v2 = v2 + m7 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 16) | v13 >>> 16; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 12) | v7 >>> 12; + v3 = v3 + m9 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 16) | v14 >>> 16; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 12) | v4 >>> 12; + v2 = v2 + m1 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 8) | v13 >>> 8; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 7) | v7 >>> 7; + v3 = v3 + m4 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 8) | v14 >>> 8; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 7) | v4 >>> 7; + v1 = v1 + m6 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 8) | v12 >>> 8; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 7) | v6 >>> 7; + v0 = v0 + m14 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 8) | v15 >>> 8; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 7) | v5 >>> 7; - // Round 8. - v0 = v0 + m13 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 16) | v12 >>> 16; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 12) | v4 >>> 12; - v1 = v1 + m7 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 16) | v13 >>> 16; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 12) | v5 >>> 12; - v2 = v2 + m12 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 16) | v14 >>> 16; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 12) | v6 >>> 12; - v3 = v3 + m3 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 16) | v15 >>> 16; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 12) | v7 >>> 12; - v2 = v2 + m1 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 8) | v14 >>> 8; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 7) | v6 >>> 7; - v3 = v3 + m9 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 8) | v15 >>> 8; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 7) | v7 >>> 7; - v1 = v1 + m14 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 8) | v13 >>> 8; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 7) | v5 >>> 7; - v0 = v0 + m11 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 8) | v12 >>> 8; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 7) | v4 >>> 7; - v0 = v0 + m5 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 16) | v15 >>> 16; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 12) | v5 >>> 12; - v1 = v1 + m15 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 16) | v12 >>> 16; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 12) | v6 >>> 12; - v2 = v2 + m8 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 16) | v13 >>> 16; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 12) | v7 >>> 12; - v3 = v3 + m2 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 16) | v14 >>> 16; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 12) | v4 >>> 12; - v2 = v2 + m6 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 8) | v13 >>> 8; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 7) | v7 >>> 7; - v3 = v3 + m10 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 8) | v14 >>> 8; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 7) | v4 >>> 7; - v1 = v1 + m4 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 8) | v12 >>> 8; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 7) | v6 >>> 7; - v0 = v0 + m0 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 8) | v15 >>> 8; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 7) | v5 >>> 7; + // Round 4. + v0 = v0 + m7 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 16) | v12 >>> 16; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 12) | v4 >>> 12; + v1 = v1 + m3 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 16) | v13 >>> 16; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 12) | v5 >>> 12; + v2 = v2 + m13 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 16) | v14 >>> 16; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 12) | v6 >>> 12; + v3 = v3 + m11 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 16) | v15 >>> 16; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 12) | v7 >>> 12; + v2 = v2 + m12 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 8) | v14 >>> 8; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 7) | v6 >>> 7; + v3 = v3 + m14 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 8) | v15 >>> 8; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 7) | v7 >>> 7; + v1 = v1 + m1 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 8) | v13 >>> 8; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 7) | v5 >>> 7; + v0 = v0 + m9 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 8) | v12 >>> 8; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 7) | v4 >>> 7; + v0 = v0 + m2 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 16) | v15 >>> 16; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 12) | v5 >>> 12; + v1 = v1 + m5 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 16) | v12 >>> 16; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 12) | v6 >>> 12; + v2 = v2 + m4 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 16) | v13 >>> 16; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 12) | v7 >>> 12; + v3 = v3 + m15 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 16) | v14 >>> 16; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 12) | v4 >>> 12; + v2 = v2 + m0 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 8) | v13 >>> 8; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 7) | v7 >>> 7; + v3 = v3 + m8 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 8) | v14 >>> 8; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 7) | v4 >>> 7; + v1 = v1 + m10 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 8) | v12 >>> 8; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 7) | v6 >>> 7; + v0 = v0 + m6 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 8) | v15 >>> 8; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 7) | v5 >>> 7; - // Round 9. - v0 = v0 + m6 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 16) | v12 >>> 16; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 12) | v4 >>> 12; - v1 = v1 + m14 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 16) | v13 >>> 16; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 12) | v5 >>> 12; - v2 = v2 + m11 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 16) | v14 >>> 16; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 12) | v6 >>> 12; - v3 = v3 + m0 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 16) | v15 >>> 16; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 12) | v7 >>> 12; - v2 = v2 + m3 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 8) | v14 >>> 8; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 7) | v6 >>> 7; - v3 = v3 + m8 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 8) | v15 >>> 8; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 7) | v7 >>> 7; - v1 = v1 + m9 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 8) | v13 >>> 8; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 7) | v5 >>> 7; - v0 = v0 + m15 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 8) | v12 >>> 8; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 7) | v4 >>> 7; - v0 = v0 + m12 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 16) | v15 >>> 16; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 12) | v5 >>> 12; - v1 = v1 + m13 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 16) | v12 >>> 16; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 12) | v6 >>> 12; - v2 = v2 + m1 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 16) | v13 >>> 16; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 12) | v7 >>> 12; - v3 = v3 + m10 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 16) | v14 >>> 16; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 12) | v4 >>> 12; - v2 = v2 + m4 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 8) | v13 >>> 8; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 7) | v7 >>> 7; - v3 = v3 + m5 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 8) | v14 >>> 8; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 7) | v4 >>> 7; - v1 = v1 + m7 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 8) | v12 >>> 8; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 7) | v6 >>> 7; - v0 = v0 + m2 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 8) | v15 >>> 8; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 7) | v5 >>> 7; + // Round 5. + v0 = v0 + m9 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 16) | v12 >>> 16; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 12) | v4 >>> 12; + v1 = v1 + m5 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 16) | v13 >>> 16; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 12) | v5 >>> 12; + v2 = v2 + m2 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 16) | v14 >>> 16; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 12) | v6 >>> 12; + v3 = v3 + m10 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 16) | v15 >>> 16; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 12) | v7 >>> 12; + v2 = v2 + m4 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 8) | v14 >>> 8; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 7) | v6 >>> 7; + v3 = v3 + m15 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 8) | v15 >>> 8; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 7) | v7 >>> 7; + v1 = v1 + m7 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 8) | v13 >>> 8; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 7) | v5 >>> 7; + v0 = v0 + m0 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 8) | v12 >>> 8; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 7) | v4 >>> 7; + v0 = v0 + m14 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 16) | v15 >>> 16; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 12) | v5 >>> 12; + v1 = v1 + m11 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 16) | v12 >>> 16; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 12) | v6 >>> 12; + v2 = v2 + m6 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 16) | v13 >>> 16; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 12) | v7 >>> 12; + v3 = v3 + m3 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 16) | v14 >>> 16; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 12) | v4 >>> 12; + v2 = v2 + m8 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 8) | v13 >>> 8; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 7) | v7 >>> 7; + v3 = v3 + m13 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 8) | v14 >>> 8; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 7) | v4 >>> 7; + v1 = v1 + m12 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 8) | v12 >>> 8; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 7) | v6 >>> 7; + v0 = v0 + m1 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 8) | v15 >>> 8; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 7) | v5 >>> 7; - // Round 10. - v0 = v0 + m10 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 16) | v12 >>> 16; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 12) | v4 >>> 12; - v1 = v1 + m8 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 16) | v13 >>> 16; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 12) | v5 >>> 12; - v2 = v2 + m7 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 16) | v14 >>> 16; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 12) | v6 >>> 12; - v3 = v3 + m1 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 16) | v15 >>> 16; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 12) | v7 >>> 12; - v2 = v2 + m6 | 0; - v2 = v2 + v6 | 0; - v14 ^= v2; - v14 = v14 << (32 - 8) | v14 >>> 8; - v10 = v10 + v14 | 0; - v6 ^= v10; - v6 = v6 << (32 - 7) | v6 >>> 7; - v3 = v3 + m5 | 0; - v3 = v3 + v7 | 0; - v15 ^= v3; - v15 = v15 << (32 - 8) | v15 >>> 8; - v11 = v11 + v15 | 0; - v7 ^= v11; - v7 = v7 << (32 - 7) | v7 >>> 7; - v1 = v1 + m4 | 0; - v1 = v1 + v5 | 0; - v13 ^= v1; - v13 = v13 << (32 - 8) | v13 >>> 8; - v9 = v9 + v13 | 0; - v5 ^= v9; - v5 = v5 << (32 - 7) | v5 >>> 7; - v0 = v0 + m2 | 0; - v0 = v0 + v4 | 0; - v12 ^= v0; - v12 = v12 << (32 - 8) | v12 >>> 8; - v8 = v8 + v12 | 0; - v4 ^= v8; - v4 = v4 << (32 - 7) | v4 >>> 7; - v0 = v0 + m15 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 16) | v15 >>> 16; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 12) | v5 >>> 12; - v1 = v1 + m9 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 16) | v12 >>> 16; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 12) | v6 >>> 12; - v2 = v2 + m3 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 16) | v13 >>> 16; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 12) | v7 >>> 12; - v3 = v3 + m13 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 16) | v14 >>> 16; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 12) | v4 >>> 12; - v2 = v2 + m12 | 0; - v2 = v2 + v7 | 0; - v13 ^= v2; - v13 = v13 << (32 - 8) | v13 >>> 8; - v8 = v8 + v13 | 0; - v7 ^= v8; - v7 = v7 << (32 - 7) | v7 >>> 7; - v3 = v3 + m0 | 0; - v3 = v3 + v4 | 0; - v14 ^= v3; - v14 = v14 << (32 - 8) | v14 >>> 8; - v9 = v9 + v14 | 0; - v4 ^= v9; - v4 = v4 << (32 - 7) | v4 >>> 7; - v1 = v1 + m14 | 0; - v1 = v1 + v6 | 0; - v12 ^= v1; - v12 = v12 << (32 - 8) | v12 >>> 8; - v11 = v11 + v12 | 0; - v6 ^= v11; - v6 = v6 << (32 - 7) | v6 >>> 7; - v0 = v0 + m11 | 0; - v0 = v0 + v5 | 0; - v15 ^= v0; - v15 = v15 << (32 - 8) | v15 >>> 8; - v10 = v10 + v15 | 0; - v5 ^= v10; - v5 = v5 << (32 - 7) | v5 >>> 7; + // Round 6. + v0 = v0 + m2 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 16) | v12 >>> 16; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 12) | v4 >>> 12; + v1 = v1 + m6 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 16) | v13 >>> 16; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 12) | v5 >>> 12; + v2 = v2 + m0 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 16) | v14 >>> 16; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 12) | v6 >>> 12; + v3 = v3 + m8 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 16) | v15 >>> 16; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 12) | v7 >>> 12; + v2 = v2 + m11 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 8) | v14 >>> 8; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 7) | v6 >>> 7; + v3 = v3 + m3 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 8) | v15 >>> 8; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 7) | v7 >>> 7; + v1 = v1 + m10 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 8) | v13 >>> 8; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 7) | v5 >>> 7; + v0 = v0 + m12 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 8) | v12 >>> 8; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 7) | v4 >>> 7; + v0 = v0 + m4 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 16) | v15 >>> 16; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 12) | v5 >>> 12; + v1 = v1 + m7 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 16) | v12 >>> 16; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 12) | v6 >>> 12; + v2 = v2 + m15 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 16) | v13 >>> 16; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 12) | v7 >>> 12; + v3 = v3 + m1 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 16) | v14 >>> 16; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 12) | v4 >>> 12; + v2 = v2 + m14 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 8) | v13 >>> 8; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 7) | v7 >>> 7; + v3 = v3 + m9 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 8) | v14 >>> 8; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 7) | v4 >>> 7; + v1 = v1 + m5 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 8) | v12 >>> 8; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 7) | v6 >>> 7; + v0 = v0 + m13 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 8) | v15 >>> 8; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 7) | v5 >>> 7; - this.h[0] ^= v0 ^ v8; - this.h[1] ^= v1 ^ v9; - this.h[2] ^= v2 ^ v10; - this.h[3] ^= v3 ^ v11; - this.h[4] ^= v4 ^ v12; - this.h[5] ^= v5 ^ v13; - this.h[6] ^= v6 ^ v14; - this.h[7] ^= v7 ^ v15; - }; + // Round 7. + v0 = v0 + m12 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 16) | v12 >>> 16; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 12) | v4 >>> 12; + v1 = v1 + m1 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 16) | v13 >>> 16; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 12) | v5 >>> 12; + v2 = v2 + m14 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 16) | v14 >>> 16; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 12) | v6 >>> 12; + v3 = v3 + m4 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 16) | v15 >>> 16; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 12) | v7 >>> 12; + v2 = v2 + m13 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 8) | v14 >>> 8; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 7) | v6 >>> 7; + v3 = v3 + m10 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 8) | v15 >>> 8; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 7) | v7 >>> 7; + v1 = v1 + m15 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 8) | v13 >>> 8; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 7) | v5 >>> 7; + v0 = v0 + m5 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 8) | v12 >>> 8; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 7) | v4 >>> 7; + v0 = v0 + m0 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 16) | v15 >>> 16; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 12) | v5 >>> 12; + v1 = v1 + m6 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 16) | v12 >>> 16; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 12) | v6 >>> 12; + v2 = v2 + m9 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 16) | v13 >>> 16; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 12) | v7 >>> 12; + v3 = v3 + m8 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 16) | v14 >>> 16; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 12) | v4 >>> 12; + v2 = v2 + m2 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 8) | v13 >>> 8; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 7) | v7 >>> 7; + v3 = v3 + m11 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 8) | v14 >>> 8; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 7) | v4 >>> 7; + v1 = v1 + m3 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 8) | v12 >>> 8; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 7) | v6 >>> 7; + v0 = v0 + m7 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 8) | v15 >>> 8; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 7) | v5 >>> 7; - BLAKE2s.prototype.update = function(p, offset, length) { - if (typeof p === 'string') - throw new TypeError('update() accepts Uint8Array or an Array of bytes'); - if (this.isFinished) - throw new Error('update() after calling digest()'); + // Round 8. + v0 = v0 + m13 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 16) | v12 >>> 16; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 12) | v4 >>> 12; + v1 = v1 + m7 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 16) | v13 >>> 16; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 12) | v5 >>> 12; + v2 = v2 + m12 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 16) | v14 >>> 16; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 12) | v6 >>> 12; + v3 = v3 + m3 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 16) | v15 >>> 16; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 12) | v7 >>> 12; + v2 = v2 + m1 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 8) | v14 >>> 8; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 7) | v6 >>> 7; + v3 = v3 + m9 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 8) | v15 >>> 8; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 7) | v7 >>> 7; + v1 = v1 + m14 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 8) | v13 >>> 8; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 7) | v5 >>> 7; + v0 = v0 + m11 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 8) | v12 >>> 8; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 7) | v4 >>> 7; + v0 = v0 + m5 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 16) | v15 >>> 16; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 12) | v5 >>> 12; + v1 = v1 + m15 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 16) | v12 >>> 16; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 12) | v6 >>> 12; + v2 = v2 + m8 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 16) | v13 >>> 16; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 12) | v7 >>> 12; + v3 = v3 + m2 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 16) | v14 >>> 16; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 12) | v4 >>> 12; + v2 = v2 + m6 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 8) | v13 >>> 8; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 7) | v7 >>> 7; + v3 = v3 + m10 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 8) | v14 >>> 8; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 7) | v4 >>> 7; + v1 = v1 + m4 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 8) | v12 >>> 8; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 7) | v6 >>> 7; + v0 = v0 + m0 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 8) | v15 >>> 8; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 7) | v5 >>> 7; - if (typeof offset === 'undefined') { offset = 0; } - if (typeof length === 'undefined') { length = p.length - offset; } + // Round 9. + v0 = v0 + m6 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 16) | v12 >>> 16; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 12) | v4 >>> 12; + v1 = v1 + m14 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 16) | v13 >>> 16; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 12) | v5 >>> 12; + v2 = v2 + m11 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 16) | v14 >>> 16; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 12) | v6 >>> 12; + v3 = v3 + m0 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 16) | v15 >>> 16; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 12) | v7 >>> 12; + v2 = v2 + m3 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 8) | v14 >>> 8; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 7) | v6 >>> 7; + v3 = v3 + m8 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 8) | v15 >>> 8; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 7) | v7 >>> 7; + v1 = v1 + m9 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 8) | v13 >>> 8; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 7) | v5 >>> 7; + v0 = v0 + m15 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 8) | v12 >>> 8; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 7) | v4 >>> 7; + v0 = v0 + m12 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 16) | v15 >>> 16; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 12) | v5 >>> 12; + v1 = v1 + m13 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 16) | v12 >>> 16; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 12) | v6 >>> 12; + v2 = v2 + m1 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 16) | v13 >>> 16; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 12) | v7 >>> 12; + v3 = v3 + m10 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 16) | v14 >>> 16; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 12) | v4 >>> 12; + v2 = v2 + m4 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 8) | v13 >>> 8; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 7) | v7 >>> 7; + v3 = v3 + m5 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 8) | v14 >>> 8; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 7) | v4 >>> 7; + v1 = v1 + m7 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 8) | v12 >>> 8; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 7) | v6 >>> 7; + v0 = v0 + m2 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 8) | v15 >>> 8; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 7) | v5 >>> 7; - if (length === 0) return this; + // Round 10. + v0 = v0 + m10 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 16) | v12 >>> 16; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 12) | v4 >>> 12; + v1 = v1 + m8 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 16) | v13 >>> 16; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 12) | v5 >>> 12; + v2 = v2 + m7 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 16) | v14 >>> 16; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 12) | v6 >>> 12; + v3 = v3 + m1 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 16) | v15 >>> 16; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 12) | v7 >>> 12; + v2 = v2 + m6 | 0; + v2 = v2 + v6 | 0; + v14 ^= v2; + v14 = v14 << (32 - 8) | v14 >>> 8; + v10 = v10 + v14 | 0; + v6 ^= v10; + v6 = v6 << (32 - 7) | v6 >>> 7; + v3 = v3 + m5 | 0; + v3 = v3 + v7 | 0; + v15 ^= v3; + v15 = v15 << (32 - 8) | v15 >>> 8; + v11 = v11 + v15 | 0; + v7 ^= v11; + v7 = v7 << (32 - 7) | v7 >>> 7; + v1 = v1 + m4 | 0; + v1 = v1 + v5 | 0; + v13 ^= v1; + v13 = v13 << (32 - 8) | v13 >>> 8; + v9 = v9 + v13 | 0; + v5 ^= v9; + v5 = v5 << (32 - 7) | v5 >>> 7; + v0 = v0 + m2 | 0; + v0 = v0 + v4 | 0; + v12 ^= v0; + v12 = v12 << (32 - 8) | v12 >>> 8; + v8 = v8 + v12 | 0; + v4 ^= v8; + v4 = v4 << (32 - 7) | v4 >>> 7; + v0 = v0 + m15 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 16) | v15 >>> 16; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 12) | v5 >>> 12; + v1 = v1 + m9 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 16) | v12 >>> 16; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 12) | v6 >>> 12; + v2 = v2 + m3 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 16) | v13 >>> 16; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 12) | v7 >>> 12; + v3 = v3 + m13 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 16) | v14 >>> 16; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 12) | v4 >>> 12; + v2 = v2 + m12 | 0; + v2 = v2 + v7 | 0; + v13 ^= v2; + v13 = v13 << (32 - 8) | v13 >>> 8; + v8 = v8 + v13 | 0; + v7 ^= v8; + v7 = v7 << (32 - 7) | v7 >>> 7; + v3 = v3 + m0 | 0; + v3 = v3 + v4 | 0; + v14 ^= v3; + v14 = v14 << (32 - 8) | v14 >>> 8; + v9 = v9 + v14 | 0; + v4 ^= v9; + v4 = v4 << (32 - 7) | v4 >>> 7; + v1 = v1 + m14 | 0; + v1 = v1 + v6 | 0; + v12 ^= v1; + v12 = v12 << (32 - 8) | v12 >>> 8; + v11 = v11 + v12 | 0; + v6 ^= v11; + v6 = v6 << (32 - 7) | v6 >>> 7; + v0 = v0 + m11 | 0; + v0 = v0 + v5 | 0; + v15 ^= v0; + v15 = v15 << (32 - 8) | v15 >>> 8; + v10 = v10 + v15 | 0; + v5 ^= v10; + v5 = v5 << (32 - 7) | v5 >>> 7; + this.h[0] ^= v0 ^ v8; + this.h[1] ^= v1 ^ v9; + this.h[2] ^= v2 ^ v10; + this.h[3] ^= v3 ^ v11; + this.h[4] ^= v4 ^ v12; + this.h[5] ^= v5 ^ v13; + this.h[6] ^= v6 ^ v14; + this.h[7] ^= v7 ^ v15; +}; - var i, left = 64 - this.nx; +BLAKE2s.prototype.update = function(p, offset = 0, length = p.length - offset) { + if (typeof p === 'string') + throw new TypeError('update() accepts Uint8Array or an Array of bytes'); + if (this.isFinished) + throw new Error('update() after calling digest()'); - // Finish buffer. - if (length > left) { - for (i = 0; i < left; i++) { - this.x[this.nx + i] = p[offset + i]; - } - this.processBlock(64); - offset += left; - length -= left; - this.nx = 0; - } + if (length === 0) return this; - // Process message blocks. - while (length > 64) { - for (i = 0; i < 64; i++) { - this.x[i] = p[offset + i]; - } - this.processBlock(64); - offset += 64; - length -= 64; - this.nx = 0; - } + let i, left = 64 - this.nx; - // Copy leftovers to buffer. - for (i = 0; i < length; i++) { + // Finish buffer. + if (length > left) { + for (i = 0; i < left; i++) { this.x[this.nx + i] = p[offset + i]; } - this.nx += length; - - return this; - }; - - BLAKE2s.prototype.digest = function() { - var i; + this.processBlock(64); + offset += left; + length -= left; + this.nx = 0; + } - if (this.isFinished) return this.result; + // Process message blocks. + while (length > 64) { + for (i = 0; i < 64; i++) { + this.x[i] = p[offset + i]; + } + this.processBlock(64); + offset += 64; + length -= 64; + this.nx = 0; + } - for (i = this.nx; i < 64; i++) this.x[i] = 0; + // Copy leftovers to buffer. + for (i = 0; i < length; i++) { + this.x[this.nx + i] = p[offset + i]; + } + this.nx += length; - // Set last block flag. - this.f0 = 0xffffffff; + return this; +}; - //TODO in tree mode, set f1 to 0xffffffff. - this.processBlock(this.nx); +BLAKE2s.prototype.digest = function() { + if (this.isFinished) throw new Error("consumed") - var d = Buffer.alloc(32); - for (i = 0; i < 8; i++) { - var h = this.h[i]; - d[i * 4 + 0] = (h >>> 0) & 0xff; - d[i * 4 + 1] = (h >>> 8) & 0xff; - d[i * 4 + 2] = (h >>> 16) & 0xff; - d[i * 4 + 3] = (h >>> 24) & 0xff; - } - this.result = Buffer.from(d.slice(0, this.digestLength)); - this.isFinished = true; - return this.result; - }; + for (let i = this.nx; i < 64; i++) this.x[i] = 0; - BLAKE2s.prototype.hexDigest = function() { - var hex = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']; - var out = []; - var d = this.digest(); - for (var i = 0; i < d.length; i++) { - out.push(hex[(d[i] >> 4) & 0xf]); - out.push(hex[d[i] & 0xf]); - } - return out.join(''); - }; + // Set last block flag. + this.f0 = 0xffffffff; - BLAKE2s.digestLength = MAX_DIGEST_LENGTH; - BLAKE2s.blockLength = BLOCK_LENGTH; - BLAKE2s.keyLength = MAX_KEY_LENGTH; - BLAKE2s.saltLength = SALT_LENGTH; - BLAKE2s.personalizationLength = PERSONALIZATION_LENGTH; + //TODO in tree mode, set f1 to 0xffffffff. + this.processBlock(this.nx); - return BLAKE2s; + const d = Buffer.alloc(32); + for (let i = 0; i < 8; i++) { + const h = this.h[i]; + d[i * 4 + 0] = (h >>> 0) & 0xff; + d[i * 4 + 1] = (h >>> 8) & 0xff; + d[i * 4 + 2] = (h >>> 16) & 0xff; + d[i * 4 + 3] = (h >>> 24) & 0xff; + } + this.isFinished = true; + return d.slice(0, this.digestLength); +}; -})(); +BLAKE2s.digestLength = MAX_DIGEST_LENGTH; +BLAKE2s.blockLength = BLOCK_LENGTH; +BLAKE2s.keyLength = MAX_KEY_LENGTH; +BLAKE2s.saltLength = SALT_LENGTH; +BLAKE2s.personalizationLength = PERSONALIZATION_LENGTH; -if (typeof module !== 'undefined' && module.exports) module.exports = BLAKE2s; \ No newline at end of file +module.exports = BLAKE2s \ No newline at end of file diff --git a/packages/app-package-builder/package.json b/packages/app-package-builder/package.json index 48eb321b84c..6e34aeb2b8d 100644 --- a/packages/app-package-builder/package.json +++ b/packages/app-package-builder/package.json @@ -11,7 +11,7 @@ "out", "blake2s.min.js" ], "dependencies": { - "bluebird-lst": "^1.0.4", + "bluebird-lst": "^1.0.5", "fs-extra-p": "^4.4.4", "int64-buffer": "^0.1.9", "builder-util-runtime": "^0.0.0-semantic-release", diff --git a/packages/app-package-builder/src/ContentDefinedChunker.ts b/packages/app-package-builder/src/ContentDefinedChunker.ts index c0163f86862..c3c2e765a99 100644 --- a/packages/app-package-builder/src/ContentDefinedChunker.ts +++ b/packages/app-package-builder/src/ContentDefinedChunker.ts @@ -39,7 +39,7 @@ export class ContentDefinedChunker { chunkEnd -= tailBufferData.length tailBufferData = null } - hash.update(dataBuffer.slice(chunkStart, chunkEnd)) + hash.update(dataBuffer, chunkStart, size) checksums.push(digest(hash)) chunkStart = chunkEnd } diff --git a/packages/asar-integrity/package.json b/packages/asar-integrity/package.json index 3bc9c10a22b..0b5b2991009 100644 --- a/packages/asar-integrity/package.json +++ b/packages/asar-integrity/package.json @@ -11,7 +11,7 @@ "out" ], "dependencies": { - "bluebird-lst": "^1.0.4", + "bluebird-lst": "^1.0.5", "fs-extra-p": "^4.4.4" }, "typings": "./out/main.d.ts" diff --git a/packages/builder-util-runtime/package.json b/packages/builder-util-runtime/package.json index 58be8a0137c..c2111acd17f 100644 --- a/packages/builder-util-runtime/package.json +++ b/packages/builder-util-runtime/package.json @@ -16,7 +16,7 @@ "dependencies": { "debug": "^3.1.0", "fs-extra-p": "^4.4.4", - "bluebird-lst": "^1.0.4", + "bluebird-lst": "^1.0.5", "sax": "^1.2.4" }, "types": "./out/index.d.ts" diff --git a/packages/builder-util/package.json b/packages/builder-util/package.json index e9d613dc4e1..86ad86f710a 100644 --- a/packages/builder-util/package.json +++ b/packages/builder-util/package.json @@ -15,8 +15,8 @@ "fs-extra-p": "^4.4.4", "is-ci": "^1.0.10", "stat-mode": "^0.2.2", - "bluebird-lst": "^1.0.4", - "chalk": "^2.1.0", + "bluebird-lst": "^1.0.5", + "chalk": "2.1.0", "debug": "^3.1.0", "node-emoji": "^1.8.1", "builder-util-runtime": "^0.0.0-semantic-release", diff --git a/packages/dmg-builder/package.json b/packages/dmg-builder/package.json index 3afcc87b327..fa42118c7b3 100644 --- a/packages/dmg-builder/package.json +++ b/packages/dmg-builder/package.json @@ -14,7 +14,7 @@ ], "dependencies": { "fs-extra-p": "^4.4.4", - "bluebird-lst": "^1.0.4", + "bluebird-lst": "^1.0.5", "parse-color": "^1.0.0", "builder-util": "^0.0.0-semantic-release", "debug": "^3.1.0", diff --git a/packages/electron-builder-squirrel-windows/package.json b/packages/electron-builder-squirrel-windows/package.json index fb20a31a3f5..480c1e9f074 100644 --- a/packages/electron-builder-squirrel-windows/package.json +++ b/packages/electron-builder-squirrel-windows/package.json @@ -12,7 +12,7 @@ ], "dependencies": { "builder-util": "^0.0.0-semantic-release", - "bluebird-lst": "^1.0.4", + "bluebird-lst": "^1.0.5", "fs-extra-p": "^4.4.4", "archiver": "^2.1.0", "sanitize-filename": "^1.6.1" diff --git a/packages/electron-builder/package.json b/packages/electron-builder/package.json index 5bd1ef64f7f..76cc7e2456e 100644 --- a/packages/electron-builder/package.json +++ b/packages/electron-builder/package.json @@ -18,7 +18,7 @@ }, "repository": "electron-userland/electron-builder", "engines": { - "node": ">=6.0.0" + "node": ">=6.11.4" }, "keywords": [ "electron", @@ -53,8 +53,8 @@ "dependencies": { "7zip-bin": "^2.2.7", "async-exit-hook": "^2.0.1", - "bluebird-lst": "^1.0.4", - "chalk": "^2.1.0", + "bluebird-lst": "^1.0.5", + "chalk": "2.1.0", "chromium-pickle-js": "^0.2.0", "cuint": "^0.2.2", "app-package-builder": "0.0.0-semantic-release", diff --git a/packages/electron-builder/src/asar/asarUtil.ts b/packages/electron-builder/src/asar/asarUtil.ts index 7c34743c827..a19535757f6 100644 --- a/packages/electron-builder/src/asar/asarUtil.ts +++ b/packages/electron-builder/src/asar/asarUtil.ts @@ -74,54 +74,59 @@ export class AsarPackager { for (let i = 0, n = fileSet.files.length; i < n; i++) { const file = fileSet.files[i] const stat = metadata.get(file) + if (stat == null) { + continue + } + const pathInArchive = path.relative(rootForAppFilesWithoutAsar, getDestinationPath(file, fileSet)) - if (stat != null && stat.isFile()) { - let fileParent = path.dirname(pathInArchive) - if (fileParent === ".") { - fileParent = "" - } - if (currentDirPath !== fileParent) { - if (fileParent.startsWith("..")) { - throw new Error("Internal error") - } + if (stat.isSymbolicLink()) { + this.fs.getOrCreateNode(pathInArchive).link = (stat as any).relativeLink + continue + } - currentDirPath = fileParent - currentDirNode = this.fs.getOrCreateNode(fileParent) - // do not check for root - if (fileParent !== "" && !currentDirNode.unpacked) { - if (unpackedDirs.has(fileParent)) { - currentDirNode.unpacked = true - } - else { - await correctDirNodeUnpackedFlag(fileParent, currentDirNode) - } - } + let fileParent = path.dirname(pathInArchive) + if (fileParent === ".") { + fileParent = "" + } + + if (currentDirPath !== fileParent) { + if (fileParent.startsWith("..")) { + throw new Error(`Internal error: path must not start with "..": ${fileParent}`) } - const dirNode = currentDirNode! - const newData = transformedFiles == null ? null : transformedFiles.get(i) - const isUnpacked = dirNode.unpacked || (this.unpackPattern != null && this.unpackPattern(file, stat)) - this.fs.addFileNode(file, dirNode, newData == null ? stat.size : Buffer.byteLength(newData), isUnpacked, stat) - if (isUnpacked) { - if (!dirNode.unpacked && !dirToCreateForUnpackedFiles.has(fileParent)) { - dirToCreateForUnpackedFiles.add(fileParent) - await ensureDir(path.join(unpackedDest, fileParent)) + currentDirPath = fileParent + currentDirNode = this.fs.getOrCreateNode(fileParent) + // do not check for root + if (fileParent !== "" && !currentDirNode.unpacked) { + if (unpackedDirs.has(fileParent)) { + currentDirNode.unpacked = true } - - const unpackedFile = path.join(unpackedDest, pathInArchive) - taskManager.addTask(copyFileOrData(fileCopier, newData, file, unpackedFile, stat)) - if (taskManager.tasks.length > MAX_FILE_REQUESTS) { - await taskManager.awaitTasks() + else { + await correctDirNodeUnpackedFlag(fileParent, currentDirNode) } - - unpackedFileIndexSet.add(i) } } - else if (stat != null && stat.isSymbolicLink()) { - this.fs.getOrCreateNode(pathInArchive).link = (stat as any).relativeLink + + const dirNode = currentDirNode! + const newData = transformedFiles == null ? null : transformedFiles.get(i) + const isUnpacked = dirNode.unpacked || (this.unpackPattern != null && this.unpackPattern(file, stat)) + this.fs.addFileNode(file, dirNode, newData == null ? stat.size : Buffer.byteLength(newData), isUnpacked, stat) + if (isUnpacked) { + if (!dirNode.unpacked && !dirToCreateForUnpackedFiles.has(fileParent)) { + dirToCreateForUnpackedFiles.add(fileParent) + await ensureDir(path.join(unpackedDest, fileParent)) + } + + const unpackedFile = path.join(unpackedDest, pathInArchive) + taskManager.addTask(copyFileOrData(fileCopier, newData, file, unpackedFile, stat)) + if (taskManager.tasks.length > MAX_FILE_REQUESTS) { + await taskManager.awaitTasks() + } + + unpackedFileIndexSet.add(i) } - } + } if (taskManager.tasks.length > 0) { await taskManager.awaitTasks() diff --git a/packages/electron-builder/src/fileMatcher.ts b/packages/electron-builder/src/fileMatcher.ts index 2dc1ff48dad..41d4d0dcded 100644 --- a/packages/electron-builder/src/fileMatcher.ts +++ b/packages/electron-builder/src/fileMatcher.ts @@ -12,6 +12,13 @@ import { createFilter, hasMagic } from "./util/filter" // https://github.com/electron-userland/electron-builder/issues/733 const minimatchOptions = {dot: true} +// noinspection SpellCheckingInspection +export const excludedNames = ".git,.hg,.svn,CVS,RCS,SCCS," + + "__pycache__,.DS_Store,thumbs.db,.gitignore,.gitkeep,.gitattributes,.npmignore," + + ".idea,.vs,.flowconfig,.jshintrc,.eslintrc,.circleci," + + ".yarn-integrity,.yarn-metadata.json,yarn-error.log,yarn.lock,package-lock.json,npm-debug.log," + + "appveyor.yml,.travis.yml,circle.yml,.nyc_output" + /** @internal */ export class FileMatcher { readonly from: string @@ -23,7 +30,7 @@ export class FileMatcher { readonly isSpecifiedAsEmptyArray: boolean - constructor(from: string, to: string, private readonly macroExpander: (pattern: string) => string, patterns?: Array | string | null | undefined) { + constructor(from: string, to: string, readonly macroExpander: (pattern: string) => string, patterns?: Array | string | null | undefined) { this.from = macroExpander(from) this.to = macroExpander(to) this.patterns = asArray(patterns).map(it => this.normalizePattern(it)) @@ -149,16 +156,11 @@ export function getMainFileMatchers(appDir: string, destination: string, macroEx patterns.push("!**/node_modules/**/*.{dll,exe}") } - patterns.push("!**/node_modules/*/{README.md,karma.conf.js,.coveralls.yml,readme.markdown,README,readme.md,readme,test,__tests__,tests,powered-test,example,examples}") patterns.push(`!**/*.{iml,hprof,orig,pyc,pyo,rbc,swp,csproj,sln,suo,xproj,cc,pdb}`) patterns.push("!**/._*") patterns.push("!**/electron-builder.{yaml,yml,json,json5,toml}") //noinspection SpellCheckingInspection - patterns.push("!**/{.git,.hg,.svn,CVS,RCS,SCCS," + - "__pycache__,.DS_Store,thumbs.db,.gitignore,.gitkeep,.gitattributes,.npmignore," + - ".idea,.vs,.flowconfig,.jshintrc,.eslintrc,.circleci," + - ".yarn-integrity,.yarn-metadata.json,yarn-error.log,yarn.lock,package-lock.json,npm-debug.log," + - "appveyor.yml,.travis.yml,circle.yml,.nyc_output}") + patterns.push(`!**/{${excludedNames}}`) if (isElectronCompile) { patterns.push("!.cache{,/**/*}") diff --git a/packages/electron-builder/src/platformPackager.ts b/packages/electron-builder/src/platformPackager.ts index 4c016c1cd31..7cc3b65552e 100644 --- a/packages/electron-builder/src/platformPackager.ts +++ b/packages/electron-builder/src/platformPackager.ts @@ -228,6 +228,7 @@ export abstract class PlatformPackager } : config.extraMetadata) const _computeFileSets = (matchers: Array) => { return computeFileSets(matchers, transformer, this.info, isElectronCompile) + .then(it => it.filter(it => it.files.length > 0)) } if (this.info.isPrepackedAppAsar) { diff --git a/packages/electron-builder/src/util/AppFileCopierHelper.ts b/packages/electron-builder/src/util/AppFileCopierHelper.ts index 8c065c4290a..0ca11f5aebd 100644 --- a/packages/electron-builder/src/util/AppFileCopierHelper.ts +++ b/packages/electron-builder/src/util/AppFileCopierHelper.ts @@ -7,6 +7,8 @@ import { FileMatcher } from "../fileMatcher" import { createElectronCompilerHost } from "../fileTransformer" import { Packager } from "../packager" import { AppFileWalker } from "./AppFileWalker" +import { NodeModuleCopyHelper } from "./NodeModuleCopyHelper" +import { Dependency } from "./packageDependencies" /** @internal */ export const NODE_MODULES_PATTERN = `${path.sep}node_modules${path.sep}` @@ -23,18 +25,35 @@ export interface ResolvedFileSet { export async function computeFileSets(matchers: Array, transformer: FileTransformer, packager: Packager, isElectronCompile: boolean): Promise> { const fileSets: Array = [] + let hoistedNodeModuleFileSets: Array | null = null + let isHoistedNodeModuleChecked = false for (const matcher of matchers) { const fileWalker = new AppFileWalker(matcher, packager) - const fromStat = await statOrNull(fileWalker.matcher.from) + const fromStat = await statOrNull(matcher.from) if (fromStat == null) { - debug(`Directory ${fileWalker.matcher.from} doesn't exists, skip file copying`) + debug(`Directory ${matcher.from} doesn't exists, skip file copying`) continue } - const files = await walk(fileWalker.matcher.from, fileWalker.filter, fileWalker) + const files = await walk(matcher.from, fileWalker.filter, fileWalker) const metadata = fileWalker.metadata + // https://github.com/electron-userland/electron-builder/issues/2205 Support for hoisted node_modules (lerna + yarn workspaces) + // if no node_modules in the app dir, it means that probably dependencies are hoisted + // check that main node_modules doesn't exist in addition to isNodeModulesHandled because isNodeModulesHandled will be false if node_modules dir is ignored by filter + // here isNodeModulesHandled is required only because of performance reasons (avoid stat call) + if (!isHoistedNodeModuleChecked && matcher.from === packager.appDir && !fileWalker.isNodeModulesHandled) { + isHoistedNodeModuleChecked = true + if ((await statOrNull(path.join(packager.appDir, "node_modules"))) == null) { + // in the prepacked mode no package.json + const packageJsonStat = await statOrNull(path.join(packager.appDir, "package.json")) + if (packageJsonStat != null && packageJsonStat.isFile()) { + hoistedNodeModuleFileSets = await copyHoistedNodeModules(packager, matcher) + } + } + } + const transformedFiles = new Map() await BluebirdPromise.filter(files, (it, index) => { const fileStat = metadata.get(it) @@ -60,17 +79,42 @@ export async function computeFileSets(matchers: Array, transformer: return false }, CONCURRENCY) - fileSets.push({src: fileWalker.matcher.from, files, metadata: fileWalker.metadata, transformedFiles, destination: fileWalker.matcher.to}) + fileSets.push({src: matcher.from, files, metadata, transformedFiles, destination: matcher.to}) } - const mainFileSet = fileSets[0] if (isElectronCompile) { // cache files should be first (better IO) - fileSets.unshift(await compileUsingElectronCompile(mainFileSet, packager)) + fileSets.unshift(await compileUsingElectronCompile(fileSets[0], packager)) + } + if (hoistedNodeModuleFileSets != null) { + return fileSets.concat(hoistedNodeModuleFileSets) } return fileSets } +async function copyHoistedNodeModules(packager: Packager, mainMatcher: FileMatcher): Promise> { + const productionDeps = await packager.productionDeps.value + const rootPathToCopier = new Map>() + for (const dep of productionDeps) { + const root = dep.path.substring(0, dep.path.indexOf(NODE_MODULES_PATTERN)) + let list = rootPathToCopier.get(root) + if (list == null) { + list = [] + rootPathToCopier.set(root, list) + } + list.push(dep) + } + + // mapSeries instead of map because copyNodeModules is concurrent and so, no need to increase queue/pressure + return await BluebirdPromise.mapSeries(rootPathToCopier.keys(), async source => { + // use main matcher patterns, so, user can exclude some files in such hoisted node modules + const matcher = new FileMatcher(source, mainMatcher.to, mainMatcher.macroExpander, mainMatcher.patterns) + const copier = new NodeModuleCopyHelper(matcher, packager) + const files = await copier.collectNodeModules(rootPathToCopier.get(source)!!) + return {src: matcher.from, destination: matcher.to, files, metadata: copier.metadata} + }) +} + const BOWER_COMPONENTS_PATTERN = `${path.sep}bower_components${path.sep}` /** @internal */ export const ELECTRON_COMPILE_SHIM_FILENAME = "__shim.js" diff --git a/packages/electron-builder/src/util/AppFileWalker.ts b/packages/electron-builder/src/util/AppFileWalker.ts index 32c978b5590..2dc14ce5b7c 100644 --- a/packages/electron-builder/src/util/AppFileWalker.ts +++ b/packages/electron-builder/src/util/AppFileWalker.ts @@ -1,24 +1,26 @@ -import BluebirdPromise from "bluebird-lst" -import { CONCURRENCY, FileConsumer, Filter } from "builder-util/out/fs" -import { lstat, readdir, readlink, stat, Stats } from "fs-extra-p" +import { FileConsumer } from "builder-util/out/fs" +import { Stats } from "fs-extra-p" import * as path from "path" import { FileMatcher } from "../fileMatcher" import { Packager } from "../packager" -import { Dependency, getProductionDependencies } from "./packageDependencies" +import { NodeModuleCopyHelper } from "./NodeModuleCopyHelper" +import { getProductionDependencies } from "./packageDependencies" const nodeModulesSystemDependentSuffix = `${path.sep}node_modules` -const excludedFiles = new Set([".DS_Store", "node_modules" /* already in the queue */, "CHANGELOG.md", "ChangeLog", "changelog.md", "binding.gyp"]) + +function addAllPatternIfNeed(matcher: FileMatcher) { + if (!matcher.isSpecifiedAsEmptyArray && (matcher.isEmpty() || matcher.containsOnlyIgnore())) { + matcher.prependPattern("**/*") + } + return matcher +} /** @internal */ -export class AppFileWalker implements FileConsumer { - readonly metadata = new Map() - readonly filter: Filter +export class AppFileWalker extends NodeModuleCopyHelper implements FileConsumer { + isNodeModulesHandled = false - constructor(readonly matcher: FileMatcher, readonly packager: Packager) { - if (!matcher.isSpecifiedAsEmptyArray && (matcher.isEmpty() || matcher.containsOnlyIgnore())) { - matcher.prependPattern("**/*") - } - this.filter = matcher.createFilter() + constructor(matcher: FileMatcher, packager: Packager) { + super(addAllPatternIfNeed(matcher), packager) } // noinspection JSUnusedGlobalSymbols @@ -40,135 +42,16 @@ export class AppFileWalker implements FileConsumer { private handleNodeModulesDir(nodeModulesDir: string, parent: string) { const packager = this.packager - return (parent === packager.appDir ? packager.productionDeps.value : getProductionDependencies(parent)) + const isMainNodeModules = parent === packager.appDir + if (isMainNodeModules) { + this.isNodeModulesHandled = true + } + return (isMainNodeModules ? packager.productionDeps.value : getProductionDependencies(parent)) .then(it => { if (packager.debugLogger.enabled) { packager.debugLogger.add(`productionDependencies.${parent}`, it.filter(it => it.path.startsWith(nodeModulesDir)).map(it => path.relative(nodeModulesDir, it.path))) } - - return this.copyNodeModules(it, this.filter, (file, fileStat) => { - this.metadata.set(file, fileStat) - return this.handleFile(file, fileStat) - }) - }) - } - - private handleFile(file: string, fileStat: Stats) { - if (!fileStat.isSymbolicLink()) { - return null - } - - return readlink(file) - .then((linkTarget): any => { - // http://unix.stackexchange.com/questions/105637/is-symlinks-target-relative-to-the-destinations-parent-directory-and-if-so-wh - return this.handleSymlink(fileStat, file, path.resolve(path.dirname(file), linkTarget)) + return this.collectNodeModules(it) }) } - - private handleSymlink(fileStat: Stats, file: string, linkTarget: string) { - const link = path.relative(this.matcher.from, linkTarget) - if (link.startsWith("..")) { - // outside of project, linked module (https://github.com/electron-userland/electron-builder/issues/675) - return stat(linkTarget) - .then(targetFileStat => { - this.metadata.set(file, targetFileStat) - return targetFileStat - }) - } - else { - (fileStat as any).relativeLink = link - } - return null - } - - private async copyNodeModules(list: Array, filter: Filter | null | undefined, consumer: (file: string, stat: Stats, parent: string, siblingNames: Array) => any): Promise> { - const result: Array = [] - const queue: Array = [] - for (const dep of list) { - queue.length = 1 - queue[0] = dep.path - - if (dep.link != null) { - this.metadata.set(dep.path, dep.stat!) - const r = this.handleSymlink(dep.stat!, dep.path, dep.link!) - if (r != null) { - await r - } - } - - while (queue.length > 0) { - const dirPath = queue.pop()! - - const childNames = await readdir(dirPath) - childNames.sort() - - const dirs: Array = [] - // our handler is async, but we should add sorted files, so, we add file to result not in the mapper, but after map - const sortedFilePaths = await BluebirdPromise.map(childNames, name => { - if (excludedFiles.has(name) || name.endsWith(".h") || name.endsWith(".o") || name.endsWith(".obj") || name.endsWith(".cc") || name.endsWith(".pdb") || name.endsWith(".d.ts") || name.endsWith(".suo") || name.endsWith(".npmignore") || name.endsWith(".sln")) { - return null - } - - if (dirPath.endsWith("build")) { - if (name === "gyp-mac-tool" || name === "Makefile" || name.endsWith(".mk") || name.endsWith(".gypi") || name.endsWith(".Makefile")) { - return null - } - } - else if (dirPath.endsWith("Release") && (name === ".deps" || name === "obj.target")) { - return null - } - else if (name === "src" && (dirPath.endsWith("keytar") || dirPath.endsWith("keytar-prebuild"))) { - return null - } - else if (dirPath.endsWith("lzma-native") && (name === "build" || name === "deps")) { - return null - } - - const filePath = dirPath + path.sep + name - return lstat(filePath) - .then(stat => { - if (filter != null && !filter(filePath, stat)) { - return null - } - - const consumerResult = consumer(filePath, stat, dirPath, childNames) - if (consumerResult == null || !("then" in consumerResult)) { - if (stat.isDirectory()) { - dirs.push(name) - return null - } - else { - return filePath - } - } - else { - return (consumerResult as Promise) - .then(it => { - // asarUtil can return modified stat (symlink handling) - if ((it != null && "isDirectory" in it ? (it as Stats) : stat).isDirectory()) { - dirs.push(name) - return null - } - else { - return filePath - } - }) - } - }) - }, CONCURRENCY) - - for (const child of sortedFilePaths) { - if (child != null) { - result.push(child) - } - } - - dirs.sort() - for (const child of dirs) { - queue.push(dirPath + path.sep + child) - } - } - } - return result - } } \ No newline at end of file diff --git a/packages/electron-builder/src/util/NodeModuleCopyHelper.ts b/packages/electron-builder/src/util/NodeModuleCopyHelper.ts new file mode 100644 index 00000000000..d4f79953695 --- /dev/null +++ b/packages/electron-builder/src/util/NodeModuleCopyHelper.ts @@ -0,0 +1,149 @@ +import BluebirdPromise from "bluebird-lst" +import { CONCURRENCY, Filter } from "builder-util/out/fs" +import { lstat, readdir, readlink, stat, Stats } from "fs-extra-p" +import * as path from "path" +import { excludedNames, FileMatcher } from "../fileMatcher" +import { Packager } from "../packager" +import { Dependency } from "./packageDependencies" + +const excludedFiles = new Set([".DS_Store", "node_modules" /* already in the queue */, "CHANGELOG.md", "ChangeLog", "changelog.md", "binding.gyp"].concat(excludedNames.split(","))) +const topLevelExcludedFiles = new Set(["karma.conf.js", ".coveralls.yml", "README.md", "readme.markdown", "README", "readme.md", "readme", "test", "__tests__", "tests", "powered-test", "example", "examples"]) + +/** @internal */ +export class NodeModuleCopyHelper { + readonly metadata = new Map() + readonly filter: Filter + + constructor(private readonly matcher: FileMatcher, protected readonly packager: Packager) { + this.filter = matcher.createFilter() + } + + protected handleFile(file: string, fileStat: Stats) { + if (!fileStat.isSymbolicLink()) { + return null + } + + return readlink(file) + .then((linkTarget): any => { + // http://unix.stackexchange.com/questions/105637/is-symlinks-target-relative-to-the-destinations-parent-directory-and-if-so-wh + return this.handleSymlink(fileStat, file, path.resolve(path.dirname(file), linkTarget)) + }) + } + + protected handleSymlink(fileStat: Stats, file: string, linkTarget: string) { + const link = path.relative(this.matcher.from, linkTarget) + if (link.startsWith("..")) { + // outside of project, linked module (https://github.com/electron-userland/electron-builder/issues/675) + return stat(linkTarget) + .then(targetFileStat => { + this.metadata.set(file, targetFileStat) + return targetFileStat + }) + } + else { + (fileStat as any).relativeLink = link + } + return null + } + + async collectNodeModules(list: Array): Promise> { + const filter = this.filter + const metadata = this.metadata + + const result: Array = [] + const queue: Array = [] + for (const dep of list) { + queue.length = 1 + queue[0] = dep.path + + if (dep.link != null) { + this.metadata.set(dep.path, dep.stat!) + const r = this.handleSymlink(dep.stat!, dep.path, dep.link!) + if (r != null) { + await r + } + } + + while (queue.length > 0) { + const dirPath = queue.pop()! + + const childNames = await readdir(dirPath) + childNames.sort() + + const isTopLevel = !dirPath.includes(path.sep, dep.path.length + 1) + + const dirs: Array = [] + // our handler is async, but we should add sorted files, so, we add file to result not in the mapper, but after map + const sortedFilePaths = await BluebirdPromise.map(childNames, name => { + if (excludedFiles.has(name) || name.endsWith(".h") || name.endsWith(".o") || name.endsWith(".obj") || name.endsWith(".cc") || name.endsWith(".pdb") || name.endsWith(".d.ts") || name.endsWith(".suo") || name.endsWith(".npmignore") || name.endsWith(".sln")) { + return null + } + + if (isTopLevel && topLevelExcludedFiles.has(name)) { + return null + } + + if (dirPath.endsWith("build")) { + if (name === "gyp-mac-tool" || name === "Makefile" || name.endsWith(".mk") || name.endsWith(".gypi") || name.endsWith(".Makefile")) { + return null + } + } + else if (dirPath.endsWith("Release") && (name === ".deps" || name === "obj.target")) { + return null + } + else if (name === "src" && (dirPath.endsWith("keytar") || dirPath.endsWith("keytar-prebuild"))) { + return null + } + else if (dirPath.endsWith("lzma-native") && (name === "build" || name === "deps")) { + return null + } + + const filePath = dirPath + path.sep + name + return lstat(filePath) + .then(stat => { + if (filter != null && !filter(filePath, stat)) { + return null + } + + metadata.set(filePath, stat) + const consumerResult = this.handleFile(filePath, stat) + if (consumerResult == null || !("then" in consumerResult)) { + if (stat.isDirectory()) { + dirs.push(name) + return null + } + else { + return filePath + } + } + else { + return (consumerResult as Promise) + .then(it => { + // asarUtil can return modified stat (symlink handling) + if ((it != null && "isDirectory" in it ? (it as Stats) : stat).isDirectory()) { + dirs.push(name) + return null + } + else { + return filePath + } + }) + } + }) + }, CONCURRENCY) + + for (const child of sortedFilePaths) { + if (child != null) { + result.push(child) + } + } + + dirs.sort() + for (const child of dirs) { + queue.push(dirPath + path.sep + child) + } + } + } + return result + } +} \ No newline at end of file diff --git a/packages/electron-builder/src/util/appFileCopier.ts b/packages/electron-builder/src/util/appFileCopier.ts index fee4cf80fbf..336c194d432 100644 --- a/packages/electron-builder/src/util/appFileCopier.ts +++ b/packages/electron-builder/src/util/appFileCopier.ts @@ -5,10 +5,27 @@ import { ensureDir, readlink, symlink } from "fs-extra-p" import * as path from "path" import { copyFileOrData } from "../asar/asarUtil" import { Packager } from "../packager" -import { ensureEndSlash, ResolvedFileSet } from "./AppFileCopierHelper" +import { ensureEndSlash, NODE_MODULES_PATTERN, ResolvedFileSet } from "./AppFileCopierHelper" export function getDestinationPath(file: string, fileSet: ResolvedFileSet) { - return file === fileSet.src ? fileSet.destination : file.replace(ensureEndSlash(fileSet.src), ensureEndSlash(fileSet.destination)) + if (file === fileSet.src) { + return fileSet.destination + } + else { + const src = ensureEndSlash(fileSet.src) + const dest = ensureEndSlash(fileSet.destination) + if (file.startsWith(src)) { + return dest + file.substring(src.length) + } + else { + // hoisted node_modules + const index = file.lastIndexOf(NODE_MODULES_PATTERN) + if (index < 0) { + throw new Error(`File "${file}" not under the source directory "${fileSet.src}"`) + } + return dest + file.substring(index + 1 /* leading slash */) + } + } } export async function copyAppFiles(fileSet: ResolvedFileSet, packager: Packager) { diff --git a/packages/electron-builder/src/util/packageDependencies.ts b/packages/electron-builder/src/util/packageDependencies.ts index a3040eb416d..176d2dc5fea 100644 --- a/packages/electron-builder/src/util/packageDependencies.ts +++ b/packages/electron-builder/src/util/packageDependencies.ts @@ -1,6 +1,6 @@ import BluebirdPromise from "bluebird-lst" -import { debug } from "builder-util" -import { CONCURRENCY } from "builder-util/out/fs" +import { debug, isEnvTrue, warn } from "builder-util" +import { CONCURRENCY, statOrNull } from "builder-util/out/fs" import { orNullIfFileNotExist } from "builder-util/out/promise" import { lstat, readdir, readFile, realpath, Stats } from "fs-extra-p" import { Lazy } from "lazy-val" @@ -14,7 +14,8 @@ export interface Dependency { optional: boolean dependencies: Map | null - directDependencyNames: { [key: string]: any } | null + directDependencyNames: Array | null + peerDependencies: { [key: string]: any } | null optionalDependencies: { [key: string]: any } | null realName: string @@ -32,15 +33,9 @@ const knownAlwaysIgnoredDevDeps = new Set([ "jest", "jest-cli", "prebuild-install", "nan", "electron-webpack", "electron-webpack-ts", "electron-webpack-vue", "react-scripts", + "@types", ]) -if (process.env.ALLOW_ELECTRON_BUILDER_AS_PRODUCTION_DEPENDENCY !== "true") { - knownAlwaysIgnoredDevDeps.add("electron-builder") - knownAlwaysIgnoredDevDeps.add("builder-util") - knownAlwaysIgnoredDevDeps.add("electron-publish") - knownAlwaysIgnoredDevDeps.add("electron-download-tf") -} - export function createLazyProductionDeps(projectDir: string) { return new Lazy(() => getProductionDependencies(projectDir)) } @@ -52,17 +47,15 @@ export async function getProductionDependencies(folder: string): Promise { - const pathToDep = new Map() - const obj = await readJson(path.join(folder, "package.json")) - await _readInstalled(folder, obj, null, null, 0, pathToDep) - unmarkExtraneous(obj, false, true) - return obj +function computeDependencies(folder: string): Promise { + return new Collector().collect(folder) } +const ignoredProperties = new Set(["description", "author", "bugs", "engines", "repository", "build", "main", "license", "homepage", "scripts", "maintainers", "contributors", "keywords", "devDependencies", "files", "typings", "types"]) + function readJson(file: string) { return readFile(file, "utf-8") - .then(it => JSON.parse(it, (key, value) => key === "description" || key === "author" || key === "scripts" || key === "maintainers" || key === "keywords" || key === "devDependencies" ? undefined : value)) + .then(it => JSON.parse(it, (key, value) => ignoredProperties.has(key) ? undefined : value)) } function computeSortedPaths(parent: Dependency, result: Array, isExtraneous: boolean) { @@ -79,142 +72,216 @@ function computeSortedPaths(parent: Dependency, result: Array, isExt } } -async function _readInstalled(dir: string, obj: Dependency, parent: any | null, name: string | null, depth: number, pathToMetadata: Map): Promise { - obj.realName = name || obj.name - obj.directDependencyNames = obj.dependencies == null ? null : Object.keys(obj.dependencies) +class Collector { + readonly pathToMetadata = new Map() + private unresolved = new Set() - // Mark as extraneous at this point. - // This will be un-marked in unmarkExtraneous, where we mark as not-extraneous everything that is required in some way from the root object. - obj.extraneous = true - obj.optional = true + async collect(dir: string) { + const rootDependency: Dependency = await readJson(path.join(dir, "package.json")) + await this.readInstalled(path.join(dir, "node_modules"), rootDependency, rootDependency.name) + this.unmarkExtraneous(rootDependency) - if (parent != null) { - if (obj.link == null) { - obj.parent = parent + if (this.unresolved.size > 0) { + if (debug.enabled) { + debug(`Unresolved dependencies after first round: ${Array.from(this.unresolved).join(", ")}`) + } + await this.resolveUnresolvedHoisted(rootDependency, dir) } - - // do not add root project to result - pathToMetadata.set(dir, obj) + return rootDependency } - if (obj.dependencies == null && obj.optionalDependencies == null) { - // package has only dev or peer dependencies - no need to check child node_module - obj.dependencies = null - return - } + private async resolveUnresolvedHoisted(rootDependency: Dependency, dir: string) { + let nameToMetadata = rootDependency.dependencies + if (nameToMetadata == null) { + rootDependency.dependencies = new Map() + nameToMetadata = rootDependency.dependencies + } - const childModules = await readScopedDir(path.join(dir, "node_modules")) - if (childModules == null) { - obj.dependencies = null - return - } + let parentDir = dir + do { + parentDir = path.dirname(parentDir) + if (parentDir === "" || parentDir.endsWith("/") || parentDir.endsWith("\\")) { + const message = `Unresolved node modules: ${Array.from(this.unresolved).join(", ")}` + if (isEnvTrue(process.env.ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES)) { + warn(message) + } + else { + throw new Error(message) + } + break + } - const deps = await BluebirdPromise.map(childModules, it => readChildPackage(it, dir, obj, depth, pathToMetadata), CONCURRENCY) - if (deps.length === 0) { - obj.dependencies = null - return + const parentNodeModulesDir = parentDir + path.sep + "node_modules" + const dirStat = await statOrNull(parentNodeModulesDir) + if (dirStat == null || !dirStat.isDirectory()) { + continue + } + + const unresolved = Array.from(this.unresolved) + this.unresolved.clear() + + const resolved = await BluebirdPromise.map(unresolved, it => { + return this.readChildPackage(it, parentNodeModulesDir, rootDependency) + .catch(e => { + if ((e as any).code === "ENOENT") { + return null + } + else { + throw e + } + }) + }, CONCURRENCY) + for (const dep of resolved) { + if (dep != null) { + nameToMetadata.set(dep.realName, dep) + } + } + + this.unmarkExtraneous(rootDependency) + } + while (this.unresolved.size > 0) } - const nameToMetadata = new Map() - for (const dep of deps) { - if (dep != null) { - nameToMetadata.set(dep.realName, dep) + private async readInstalled(nodeModulesDir: string, dependency: Dependency, name: string): Promise { + dependency.realName = name + dependency.directDependencyNames = dependency.dependencies == null ? null : Object.keys(dependency.dependencies) + + // mark as extraneous at this point. + // this will be un-marked in unmarkExtraneous, where we mark as not-extraneous everything that is required in some way from the root object. + dependency.extraneous = true + dependency.optional = true + + if (dependency.dependencies == null && dependency.optionalDependencies == null) { + // package has only dev or peer dependencies - no need to check child node_module + dependency.dependencies = null + return + } + + const childModules = await readNodeModulesDir(nodeModulesDir) + if (childModules == null) { + dependency.dependencies = null + return } + + const deps = await BluebirdPromise.map(childModules, it => this.readChildPackage(it, nodeModulesDir, dependency), CONCURRENCY) + if (deps.length === 0) { + dependency.dependencies = null + return + } + + const nameToMetadata = new Map() + for (const dep of deps) { + if (dep != null) { + nameToMetadata.set(dep.realName, dep) + } + } + dependency.dependencies = nameToMetadata } - obj.dependencies = nameToMetadata -} -async function readChildPackage(name: string, parentDir: string, parent: any, parentDepth: number, pathToMetadata: Map): Promise { - const rawDir = path.join(parentDir, "node_modules", name) - let dir: string | null = rawDir - const stat = await lstat(dir) - const isSymbolicLink = stat.isSymbolicLink() - if (isSymbolicLink) { - dir = await orNullIfFileNotExist(realpath(dir)) - if (dir == null) { - debug(`Broken symlink ${rawDir}`) + private async readChildPackage(name: string, nodeModulesDir: string, parent: Dependency): Promise { + const rawDir = path.join(nodeModulesDir, name) + let dir: string | null = rawDir + const stat = await lstat(dir) + const isSymbolicLink = stat.isSymbolicLink() + if (isSymbolicLink) { + dir = await orNullIfFileNotExist(realpath(dir)) + if (dir == null) { + debug(`Broken symlink ${rawDir}`) + return null + } + } + + const processed = this.pathToMetadata.get(dir) + if (processed != null) { + return processed + } + + const metadata: Dependency = await orNullIfFileNotExist(readJson(path.join(dir, "package.json"))) + if (metadata == null) { return null } - } - const processed = pathToMetadata.get(dir) - if (processed != null) { - return processed - } + if (isSymbolicLink) { + metadata.link = dir + metadata.stat = stat + } + else { + metadata.parent = parent + } - const metadata: Dependency = await orNullIfFileNotExist(readJson(path.join(dir, "package.json"))) - if (metadata == null) { - return null - } + metadata.path = rawDir + + // do not add root project to result + this.pathToMetadata.set(dir, metadata) - if (isSymbolicLink) { - metadata.link = dir - metadata.stat = stat + await this.readInstalled(dir + path.sep + "node_modules", metadata, name) + return metadata } - metadata.path = rawDir - await _readInstalled(dir, metadata, parent, name, parentDepth + 1, pathToMetadata) - return metadata -} -function unmark(deps: Iterable, obj: Dependency, dev: boolean, unsetOptional: boolean) { - for (const name of deps) { - const dep = findDep(obj, name) - if (dep != null) { - if (unsetOptional) { - dep.optional = false - } - if (dep.extraneous) { - unmarkExtraneous(dep, dev, false) + private unmark(deps: Iterable, obj: Dependency, unsetOptional: boolean) { + for (const name of deps) { + const dep = this.findDep(obj, name) + if (dep != null) { + if (unsetOptional) { + dep.optional = false + } + if (dep.extraneous) { + this.unmarkExtraneous(dep) + } } } } -} -function unmarkExtraneous(obj: any, isDev: boolean, isRoot: boolean) { - // Mark all non-required deps as extraneous. - // start from the root object and mark as non-extraneous all modules - // that haven't been previously flagged as extraneous then propagate to all their dependencies + private unmarkExtraneous(obj: Dependency) { + // Mark all non-required deps as extraneous. + // start from the root object and mark as non-extraneous all modules + // that haven't been previously flagged as extraneous then propagate to all their dependencies - obj.extraneous = false + obj.extraneous = false - if (obj.directDependencyNames != null) { - unmark(obj.directDependencyNames, obj, isDev, true) - } + if (obj.directDependencyNames != null) { + this.unmark(obj.directDependencyNames, obj, true) + } - if (isDev && obj.devDependencies != null && (isRoot || obj.link)) { - unmark(Object.keys(obj.devDependencies), obj, isDev, true) - } + if (obj.peerDependencies != null) { + this.unmark(Object.keys(obj.peerDependencies), obj, true) + } - if (obj.peerDependencies != null) { - unmark(Object.keys(obj.peerDependencies), obj, isDev, true) + if (obj.optionalDependencies != null) { + this.unmark(Object.keys(obj.optionalDependencies), obj, false) + } } - if (obj.optionalDependencies != null) { - unmark(Object.keys(obj.optionalDependencies), obj, isDev, false) - } -} + // find the one that will actually be loaded by require() so we can make sure it's valid + private findDep(obj: Dependency, name: string) { + if (isIgnoredDep(name)) { + return null + } -// find the one that will actually be loaded by require() so we can make sure it's valid -function findDep(obj: Dependency, name: string) { - if (knownAlwaysIgnoredDevDeps.has(name)) { - return null - } + let r: Dependency | null | undefined = obj + let found = null + while (r != null && found == null) { + // if r is a valid choice, then use that. + // kinda weird if a pkg depends on itself, but after the first iteration of this loop, it indicates a dep cycle. + found = r.dependencies == null ? null : r.dependencies.get(name) + if (found == null && r.realName === name) { + found = r + } + r = r.link == null ? r.parent : null + } - let r: Dependency | null | undefined = obj - let found = null - while (r != null && found == null) { - // if r is a valid choice, then use that. - // kinda weird if a pkg depends on itself, but after the first iteration of this loop, it indicates a dep cycle. - found = r.dependencies == null ? null : r.dependencies.get(name) - if (found == null && r.realName === name) { - found = r + if (found == null) { + this.unresolved.add(name) } - r = r.link == null ? r.parent : null + return found } - return found } -async function readScopedDir(dir: string): Promise | null> { +function isIgnoredDep(name: string) { + return knownAlwaysIgnoredDevDeps.has(name) || name.startsWith("@types/") +} + +async function readNodeModulesDir(dir: string): Promise | null> { let files: Array try { files = (await readdir(dir)).filter(it => !it.startsWith(".") && !knownAlwaysIgnoredDevDeps.has(it)) @@ -226,7 +293,7 @@ async function readScopedDir(dir: string): Promise | null> { files.sort() - const scopes = files.filter(it => it.startsWith("@") && it !== "@types") + const scopes = files.filter(it => it.startsWith("@")) if (scopes.length === 0) { return files } diff --git a/packages/electron-publish/package.json b/packages/electron-publish/package.json index d35b1f69456..3c1000ef78d 100644 --- a/packages/electron-publish/package.json +++ b/packages/electron-publish/package.json @@ -13,10 +13,10 @@ "dependencies": { "fs-extra-p": "^4.4.4", "mime": "^2.0.3", - "bluebird-lst": "^1.0.4", + "bluebird-lst": "^1.0.5", "builder-util-runtime": "^0.0.0-semantic-release", "builder-util": "^0.0.0-semantic-release", - "chalk": "^2.1.0" + "chalk": "2.1.0" }, "typings": "./out/publisher.d.ts" } diff --git a/packages/electron-publisher-s3/package.json b/packages/electron-publisher-s3/package.json index 3d6fbed71b2..b7bffcb9145 100644 --- a/packages/electron-publisher-s3/package.json +++ b/packages/electron-publisher-s3/package.json @@ -12,7 +12,7 @@ ], "dependencies": { "fs-extra-p": "^4.4.4", - "aws-sdk": "^2.134.0", + "aws-sdk": "^2.135.0", "mime": "^2.0.3", "electron-publish": "~0.0.0-semantic-release", "builder-util": "^0.0.0-semantic-release", diff --git a/packages/electron-updater/package.json b/packages/electron-updater/package.json index 0f7aef861d2..11a309b9520 100644 --- a/packages/electron-updater/package.json +++ b/packages/electron-updater/package.json @@ -13,7 +13,7 @@ ], "dependencies": { "lazy-val": "^1.0.2", - "bluebird-lst": "^1.0.4", + "bluebird-lst": "^1.0.5", "fs-extra-p": "^4.4.4", "js-yaml": "^3.10.0", "semver": "^5.4.1", diff --git a/test/.babelrc b/test/.babelrc deleted file mode 100644 index 7b11b6dad2a..00000000000 --- a/test/.babelrc +++ /dev/null @@ -1,17 +0,0 @@ -{ - plugins: [ - [ - "transform-async-to-module-method", - { - module: "bluebird-lst", - method: "coroutine" - } - ], - [ - "transform-inline-imports-commonjs", - { - excludeModules: ["path", "debug", "http", "https"] - } - ], - ] -} \ No newline at end of file diff --git a/test/babel-jest.js b/test/babel-jest.js index 84413571121..11a2f2be09c 100644 --- a/test/babel-jest.js +++ b/test/babel-jest.js @@ -4,33 +4,14 @@ let babel const crypto = require("crypto") const fs = require("fs") const jestPreset = require("babel-preset-jest") -const path = require("path") - -let babelRc; - -function getBabelRcDigest() { - if (babelRc == null) { - let configFile - try { - configFile = fs.readFileSync(path.join(__dirname, ".babelrc")) - } - catch (e) { - configFile = fs.readFileSync(path.join(__dirname, "..", ".babelrc")) - } - - babelRc = crypto - .createHash("md5") - .update(configFile) - .digest() - } - return babelRc -} // compiled by ts-babel - do not transform function isFullyCompiled(fileData) { return fileData.startsWith(`"use strict";`) && fileData.includes("var _") } +const BABEL_CONFIG_VERSION = Buffer.from([1]) + function createTransformer(options) { options = Object.assign({}, options, { presets: (options && options.presets || []).concat([jestPreset]), @@ -45,7 +26,7 @@ function createTransformer(options) { .update(fileData) .update(isFullyCompiled(fileData) ? "f": "p") .update(configString) - .update(getBabelRcDigest()) + .update(BABEL_CONFIG_VERSION) .update(_ref2.instrument ? "instrument" : "") .digest("hex") }, diff --git a/test/fixtures/.gitignore b/test/fixtures/.gitignore new file mode 100644 index 00000000000..9bfb325f109 --- /dev/null +++ b/test/fixtures/.gitignore @@ -0,0 +1 @@ +!node_modules/ \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/.yarn-integrity b/test/fixtures/test-app-yarn-several-workspace/node_modules/.yarn-integrity new file mode 100644 index 00000000000..d4af20d9ae5 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/.yarn-integrity @@ -0,0 +1,33 @@ +{ + "modulesFolders": [ + "node_modules", + "node_modules", + "packages/test-app/node_modules" + ], + "flags": [], + "linkedModules": [ + "dmd", + "dmd-tf", + "docdash", + "electron-auto-updater", + "electron-download-tf", + "electron-vue-scripts", + "electron-webpack", + "jest-cli" + ], + "topLevelPatterns": [ + "electron-log@2.2.8", + "electron-log@2.2.9", + "foo@1.0.0", + "ms@2.0.0", + "ms@2.0.0", + "test-app@1.1.0" + ], + "lockfileEntries": { + "electron-log@2.2.8": "https://registry.yarnpkg.com/electron-log/-/electron-log-2.2.8.tgz#2296cccd8da046268a199c1a302dcb8cb16f2b72", + "electron-log@2.2.9": "https://registry.yarnpkg.com/electron-log/-/electron-log-2.2.9.tgz#e0484cb1a8a84593095e3b69f47361ae15d73bdf", + "ms@2.0.0": "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + }, + "files": [], + "artifacts": {} +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/LICENSE b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/LICENSE new file mode 100644 index 00000000000..1f7f7e1438c --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Alexey Prokhorov + +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. \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/README.md b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/README.md new file mode 100644 index 00000000000..a1ab28fa943 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/README.md @@ -0,0 +1,163 @@ +# electron-log +[![Build Status](https://travis-ci.org/megahertz/electron-log.svg?branch=master)](https://travis-ci.org/megahertz/electron-log) +[![NPM version](https://badge.fury.io/js/electron-log.svg)](https://badge.fury.io/js/electron-log) +[![Dependencies status](https://david-dm.org/megahertz/electron-log/status.svg)](https://david-dm.org/megahertz/electron-log) + +## Description + +Just a simple logging module for your Electron or NW.js application. +No dependencies. No complicated configuration. Just require and use. +It can be used without Electron. + +By default it writes logs to the following locations: + + * **on Linux:** `~/.config//log.log` + * **on OS X:** `~/Library/Logs//log.log` + * **on Windows:** `%USERPROFILE%\AppData\Roaming\\log.log` + +## Installation + +Install with [npm](https://npmjs.org/package/electron-log): + + npm install electron-log + +## Usage + +```js +var log = require('electron-log'); + +log.info('Hello, log'); +``` +### Log levels + +electron-log supports the following log levels: + + error, warn, info, verbose, debug, silly + +### Transport + +Transport is a simple function which requires an object which describes +a message. By default, two transports are active: console and file. +Please be aware that the file log level is 'warn' by default, so info +and debug messages will be filtered. The file path is dependent on the +current platform. + + + +#### Disable default transport: + +```js +log.transports.file.level = false; +log.transports.console.level = false; +``` + +#### Override transport: + +```js +var format = require('util'); + +log.transports.console = function(msg) { + var text = util.format.apply(util, msg.data); + console.log(`[${msg.date.toLocaleTimeString()} ${msg.level}] ${text}`); +}; +``` +Please be aware that if you override a transport function the default +transport options (like level or format) will be undefined. + +#### Console Transport + +```js +// Log level +log.transports.console.level = 'warn'; + +/** + * Set output format template. Available variables: + * Main: {level}, {text} + * Date: {y},{m},{d},{h},{i},{s},{ms} + */ +log.transports.console.format = '{h}:{i}:{s}:{ms} {text}'; + +// Set a function which formats output +log.transports.console.format = (msg) => util.format.apply(util, msg.data); +``` + +#### Renderer Console transport +Show logs in Chromium DevTools Console. It has the same options as +console transport. + +#### File transport + +```js +// Same as for console transport +log.transports.file.level = 'warn'; +log.transports.file.format = '{h}:{i}:{s}:{ms} {text}'; + +// Set approximate maximum log size in bytes. When it exceeds, +// the archived log will be saved as the log.old.log file +log.transports.file.maxSize = 5 * 1024 * 1024; + +// Write to this file, must be set before first logging +log.transports.file.file = __dirname + '/log.txt'; + +// fs.createWriteStream options, must be set before first logging +log.transports.file.streamConfig = { flags: 'w' }; + +// set existed file stream +log.transports.file.stream = fs.createWriteStream('log.txt'); +``` + +By default, file transport reads a productName or name property from +package.json to determine a log path like +`~/.config//log.log`. If you have no package.json or you want +to specify another path, just set the appName property: + +```js +log.transports.file.appName = 'test'; +``` +This value should be set before the first log method call. + +## Renderer process + +Since version 2.0.0 this package works differently in main and renderer +processes. When it's included in a renderer process it sends logs to +the main process through IPC. There are no API changes, you can still +require the package by the same way both in main and renderer processes, +but please be aware that transport configuration is available only +inside the main process. + +## Change Log + +**2.1.0** + - Add Renderer Console transport + +**2.0.0** + - Move log.appName property to log.transports.file.appName. + - Change a log message object. See updated + [Override transport section](#override-transport) if you use a custom + transport. + - Now it's not possible to configure transports from a renderer + process, only from the main. + - To disable a transport set its level to false. + - Fix problems when this package is used from a renderer process. + - Add Typescript definitions. + - Add [log-s](https://github.com/megahertz/log-s) transport + (experimental). + - Fix file transport appName detection when an application is run + in dev environment (through `electron .` or similar way) + +**1.3.0** + +- #18 Rename 'warning' log level to 'warn' + +**1.2.0** + + - #14 Use native console levels instead of console.log + +**1.0.16** + + - Prefer to use package.json:productName instead of package.json:name + to determine a log path. + +## License + +Licensed under MIT. diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/electron-log.d.ts b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/electron-log.d.ts new file mode 100644 index 00000000000..af2527a1086 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/electron-log.d.ts @@ -0,0 +1,60 @@ +export type LogLevel = "error" | "warn" | "info" | "verbose" | "debug" | "silly"; +export type LevelOption = LogLevel | false; + +export type IFormat = (msg: ILogMessage) => void; + +export interface ILogMessage { + data: any[]; + date: Date; + level: LogLevel; +} + +export interface IConsoleTransport { + (msg: ILogMessage): void; + level: LevelOption; + format: IFormat | string; +} + +export interface IFileTransport { + (msg: ILogMessage): void; + appName?: string; + file?: string; + format: IFormat | string; + level: LevelOption; + maxSize: number; + streamConfig?: object; + findLogPath(appName: string): string; +} + +export interface ILogSTransport { + (msg: ILogMessage): void; + client: object; + depth: number; + level: LevelOption; + url?: string; +} + +export declare function error(...params: any[]): void; +export declare function warn(...params: any[]): void; +export declare function info(...params: any[]): void; +export declare function verbose(...params: any[]): void; +export declare function debug(...params: any[]): void; +export declare function silly(...params: any[]): void; + +export declare const transports: { + console: IConsoleTransport; + file: IFileTransport; + logS: ILogSTransport; + rendererConsole: IConsoleTransport; +}; + +// tslint:disable object-literal-sort-keys +export default { + error, + warn, + info, + verbose, + debug, + silly, + transports, +}; diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/index.js b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/index.js new file mode 100644 index 00000000000..ece47214b63 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/index.js @@ -0,0 +1,7 @@ +'use strict'; + +if (process.type === 'renderer') { + module.exports = require('./renderer'); +} else { + module.exports = require('./main'); +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/format.js b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/format.js new file mode 100644 index 00000000000..fa96c0144b9 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/format.js @@ -0,0 +1,41 @@ +'use strict'; + +var util = require('util'); +var EOL = require('os').EOL; + +module.exports = { + format: format, + pad: pad, + stringifyArray: stringifyArray +}; + +function format(msg, formatter) { + if (typeof formatter === 'function') { + return formatter(msg); + } + + var date = msg.date; + + return formatter + .replace('{level}', msg.level) + .replace('{text}', stringifyArray(msg.data)) + .replace('{y}', date.getFullYear()) + .replace('{m}', pad(date.getMonth() + 1)) + .replace('{d}', pad(date.getDate())) + .replace('{h}', pad(date.getHours())) + .replace('{i}', pad(date.getMinutes())) + .replace('{s}', pad(date.getSeconds())) + .replace('{ms}', pad(date.getMilliseconds(), 3)); +} + +function stringifyArray(data) { + data = data.map(function formatErrors(arg) { + return arg instanceof Error ? arg.stack + EOL : arg; + }); + return util.format.apply(util, data); +} + +function pad(number, zeros) { + zeros = zeros || 2; + return (new Array(zeros + 1).join('0') + number).substr(-zeros, zeros); +} diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/log.js b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/log.js new file mode 100644 index 00000000000..9be83d6ed72 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/log.js @@ -0,0 +1,42 @@ +// jshint -W040 +'use strict'; + +var LEVELS = ['error', 'warn', 'info', 'verbose', 'debug', 'silly']; + +module.exports = log; + +function log(transports, level, text) { + var data = Array.prototype.slice.call(arguments, 2); + + var msg = { + data: data, + date: new Date(), + level: level + }; + + for (var i in transports) { + // jshint -W089 + if (!transports.hasOwnProperty(i) || typeof transports[i] !== 'function') { + continue; + } + + var transport = transports[i]; + + if (transport === false || !compareLevels(transport.level, level)) { + continue; + } + + if (transport.level === false) continue; + + transport.call(null, msg); + } +} + +function compareLevels(passLevel, checkLevel) { + var pass = LEVELS.indexOf(passLevel); + var check = LEVELS.indexOf(checkLevel); + if (check === -1 || pass === -1) { + return true; + } + return check <= pass; +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/console.js b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/console.js new file mode 100644 index 00000000000..631d6e0bea8 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/console.js @@ -0,0 +1,28 @@ +'use strict'; + +var format = require('../format'); + +transport.level = 'silly'; +transport.format = formatFn; + +module.exports = transport; + +function transport(msg) { + var text = format.format(msg, transport.format); + if (console[msg.level]) { + console[msg.level](text); + } else { + console.log(text); + } +} + +function formatFn(msg) { + var time = + format.pad(msg.date.getHours()) + ':' + + format.pad(msg.date.getMinutes()) + ':' + + format.pad(msg.date.getSeconds()) + ':' + + format.pad(msg.date.getMilliseconds(), 4); + + return '[' + time + '] [' + msg.level + '] ' + + format.stringifyArray(msg.data); +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/file/find-log-path.js b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/file/find-log-path.js new file mode 100644 index 00000000000..7eba2300fb3 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/file/find-log-path.js @@ -0,0 +1,96 @@ +'use strict'; + +var fs = require('fs'); +var path = require('path'); +var os = require('os'); +var getAppName = require('./get-app-name'); + +module.exports = findLogPath; + +/** + * Try to determine a platform-specific path where can write logs + * @param {string} [appName] Used to determine the last part of a log path + * @return {string|boolean} + */ +function findLogPath(appName) { + appName = appName || getAppName(); + if (!appName) { + return false; + } + + var homeDir = os.homedir ? os.homedir() : process.env['HOME']; + + var dir; + switch (process.platform) { + case 'linux': { + dir = prepareDir(process.env['XDG_CONFIG_HOME'], appName) + .or(homeDir, '.config', appName) + .or(process.env['XDG_DATA_HOME'], appName) + .or(homeDir, '.local', 'share', appName) + .result; + break; + } + + case 'darwin': { + dir = prepareDir(homeDir, 'Library', 'Logs', appName) + .or(homeDir, 'Library', 'Application Support', appName) + .result; + break; + } + + case 'win32': { + dir = prepareDir(process.env['APPDATA'], appName) + .or(homeDir, 'AppData', 'Roaming', appName) + .result; + break; + } + } + + if (dir) { + return path.join(dir, 'log.log'); + } else { + return false; + } +} + + + +function prepareDir(dirPath) { + // jshint -W040 + if (!this || this.or !== prepareDir || !this.result) { + if (!dirPath) { + return { or: prepareDir }; + } + + //noinspection JSCheckFunctionSignatures + dirPath = path.join.apply(path, arguments); + mkDir(dirPath); + + try { + fs.accessSync(dirPath, fs.W_OK); + } catch (e) { + return { or: prepareDir }; + } + } + + return { + or: prepareDir, + result: (this ? this.result : false) || dirPath + }; +} + +function mkDir(dirPath, root) { + var dirs = dirPath.split(path.sep); + var dir = dirs.shift(); + root = (root || '') + dir + path.sep; + + try { + fs.mkdirSync(root); + } catch (e) { + if (!fs.statSync(root).isDirectory()) { + throw new Error(e); + } + } + + return !dirs.length || mkDir(dirs.join(path.sep), root); +} diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/file/get-app-name.js b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/file/get-app-name.js new file mode 100644 index 00000000000..213ae49bcf8 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/file/get-app-name.js @@ -0,0 +1,91 @@ +// jshint -W074 +'use strict'; + +/** @name process.resourcesPath */ + +var fs = require('fs'); +var path = require('path'); +var consoleTransport = require('../console'); + +module.exports = getAppName; + +function getAppName() { + try { + var name = loadPackageName(); + if (name) { + return name; + } + return warn('electron-log: unable to load the app name from package.json'); + } catch (e) { + return warn('electron-log: ' + e.message); + } +} + +/** + * Try to load main app package + * @throws {Error} + * @return {Object|null} + */ +function loadPackageName() { + var packageFile; + + try { + if (require.main.filename) { + packageFile = find(path.dirname(require.main.filename)); + } + } catch (e) {} + + if (!packageFile && process.resourcesPath) { + packageFile = find(path.join(process.resourcesPath, 'app.asar')); + var electronModule = path.join('node_modules', 'electron', 'package.json'); + if (packageFile && packageFile.indexOf(electronModule) !== -1) { + packageFile = null; + } + } + + if (!packageFile) { + packageFile = find(process.cwd()); + } + + if (!packageFile) { + return null; + } + + var content = fs.readFileSync(packageFile, 'utf-8'); + var packageData = JSON.parse(content); + + //noinspection JSUnresolvedVariable + return packageData ? packageData.productName || packageData.name : false; +} + +function find(root) { + var file; + + while (!file) { + var parent; + file = path.join(root, 'package.json'); + + try { + fs.statSync(file); + } catch (e) { + parent = path.resolve(root, '..'); + file = null; + } + + if (root === parent) { + break; + } + + root = parent; + } + + return file; +} + +function warn(message) { + consoleTransport({ + data: [message], + date: new Date(), + level: 'warn' + }); +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/file/index.js b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/file/index.js new file mode 100644 index 00000000000..49080fd86ba --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/file/index.js @@ -0,0 +1,110 @@ +'use strict'; + +var fs = require('fs'); +var EOL = require('os').EOL; +var format = require('../../format'); +var consoleTransport = require('../console'); +var findLogPath = require('./find-log-path'); + +transport.findLogPath = findLogPath; +transport.format = formatFn; +transport.level = 'warn'; +transport.maxSize = 1024 * 1024; +transport.streamConfig = undefined; + +module.exports = transport; + +function transport(msg) { + var text = format.format(msg, transport.format) + EOL; + + if (transport.stream === undefined) { + initSteamConfig(); + openStream(); + } + + if (transport.level === false) { + return; + } + + var needLogRotation = transport.maxSize > 0 && + getStreamSize(transport.stream) > transport.maxSize; + + if (needLogRotation) { + archiveLog(transport.stream); + openStream(); + } + + transport.stream.write(text); +} + +function initSteamConfig() { + transport.file = transport.file || findLogPath(transport.appName); + + if (!transport.file) { + transport.level = false; + logConsole('Could not set a log file'); + } +} + +function openStream() { + if (transport.level === false) { + return; + } + + transport.stream = fs.createWriteStream( + transport.file, + transport.streamConfig || { flags: 'a' } + ); +} + +function getStreamSize(stream) { + if (!stream) { + return 0; + } + + if (stream.logSizeAtStart === undefined) { + try { + stream.logSizeAtStart = fs.statSync(stream.path).size; + } catch (e) { + stream.logSizeAtStart = 0; + } + } + + return stream.logSizeAtStart + stream.bytesWritten; +} + +function archiveLog(stream) { + if (stream.end) { + stream.end(); + } + + try { + fs.renameSync(stream.path, stream.path.replace(/log$/, 'old.log')); + } catch (e) { + logConsole('Could not rotate log', e); + } +} + +function formatFn(msg) { + var date = + msg.date.getFullYear() + '-' + + format.pad(msg.date.getMonth() + 1) + '-' + + format.pad(msg.date.getDate()) + ' ' + + format.pad(msg.date.getHours()) + ':' + + format.pad(msg.date.getMinutes()) + ':' + + format.pad(msg.date.getSeconds()) + ':' + + format.pad(msg.date.getMilliseconds(), 4); + + return '[' + date + '] [' + msg.level + '] ' + + format.stringifyArray(msg.data); +} + +function logConsole(message, error) { + var data = ['electron-log.transports.file: ' + message]; + + if (error) { + data.push(error); + } + + consoleTransport({ data: data, date: new Date(), level: 'warn' }); +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/log-s.js b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/log-s.js new file mode 100644 index 00000000000..e7b1d49dd5f --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/log-s.js @@ -0,0 +1,86 @@ +// jshint -W074, -W089 +'use strict'; + +var http = require('http'); +var https = require('https'); +var url = require('url'); + +transport.client = { name: 'electron-application' }; +transport.depth = 6; +transport.level = false; +transport.url = null; + +module.exports = transport; + +function transport(msg) { + if (!transport.url) return; + + var data = jsonDepth({ + client: transport.client, + data: msg.data, + date: msg.date.getTime(), + level: msg.level + }, transport.depth + 1); + + post(transport.url, data); +} + +function post(serverUrl, data) { + var urlObject = url.parse(serverUrl); + var transport = urlObject.protocol === 'https:' ? https : http; + + var body = JSON.stringify(data); + + var options = { + hostname: urlObject.hostname, + port: urlObject.port, + path: urlObject.path, + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Content-Length': body.length + } + }; + + var request = transport.request(options); + request.write(body); + request.end(); +} + +function jsonDepth(json, depth) { + if (depth < 1) { + if (Array.isArray(json)) return '[array]'; + if (typeof json === 'object') return '[object]'; + return json; + } + + if (Array.isArray(json)) { + return json.map(function(child) { + return jsonDepth(child, depth - 1); + }); + } + + if (json && typeof json.getMonth === 'function') { + return json; + } + + if (json === null) { + return null; + } + + if (typeof json === 'object') { + if (typeof json.toJSON === 'function') { + json = json.toJSON(); + } + + var newJson = {}; + for (var i in json) { + //noinspection JSUnfilteredForInLoop + newJson[i] = jsonDepth(json[i], depth - 1); + } + + return newJson; + } + + return json; +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/renderer-console.js b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/renderer-console.js new file mode 100644 index 00000000000..fa7326221d2 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/lib/transports/renderer-console.js @@ -0,0 +1,34 @@ +'use strict'; + +var BrowserWindow; +try { + BrowserWindow = require('electron').BrowserWindow; +} catch (e) { + BrowserWindow = null; +} + +var format = require('../format'); + +transport.level = BrowserWindow ? 'silly' : false; +transport.format = formatFn; + +module.exports = transport; + +function transport(msg) { + if (!BrowserWindow) return; + + var text = format.format(msg, transport.format); + BrowserWindow.getAllWindows().forEach(function(wnd) { + wnd.webContents.send('__ELECTRON_LOG_RENDERER__', msg.level, text); + }); +} + +function formatFn(msg) { + var time = + format.pad(msg.date.getHours()) + ':' + + format.pad(msg.date.getMinutes()) + ':' + + format.pad(msg.date.getSeconds()) + ':' + + format.pad(msg.date.getMilliseconds(), 4); + + return '[' + time + '] ' + format.stringifyArray(msg.data); +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/main.js b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/main.js new file mode 100644 index 00000000000..bf4181d59d4 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/main.js @@ -0,0 +1,50 @@ +'use strict'; + +var electron; +try { + electron = require('electron'); +} catch (e) { + electron = null; +} + +var log = require('./lib/log'); +var transportConsole = require('./lib/transports/console'); +var transportFile = require('./lib/transports/file'); +var transportLogS = require('./lib/transports/log-s'); +var transportRendererConsole = require('./lib/transports/renderer-console'); + +var transports = { + console: transportConsole, + file: transportFile, + logS: transportLogS, + rendererConsole: transportRendererConsole +}; + +module.exports = { + transports: transports, + + error: log.bind(null, transports, 'error'), + warn: log.bind(null, transports, 'warn'), + info: log.bind(null, transports, 'info'), + verbose: log.bind(null, transports, 'verbose'), + debug: log.bind(null, transports, 'debug'), + silly: log.bind(null, transports, 'silly'), + log: log.bind(null, transports, 'info') +}; + +module.exports.default = module.exports; + +if (electron && electron.ipcMain) { + electron.ipcMain.on('__ELECTRON_LOG__', onRendererLog); + var appName = electron.app.getName(); + if (appName !== 'Electron') { + transportFile.appName = appName; + } +} + +function onRendererLog(event, data) { + if (Array.isArray(data)) { + data.unshift(transports); + log.apply(null, data); + } +} diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/package.json b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/package.json new file mode 100644 index 00000000000..dc9f1f64f44 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/package.json @@ -0,0 +1,56 @@ +{ + "name": "electron-log", + "version": "2.2.8", + "description": "Just a very simple logging module for your Electron application", + "main": "./index.js", + "scripts": { + "test": "npm run jshint && npm run jscs && npm run tslint && npm run mocha && npm run test-projects", + "mocha": "mocha index.spec.js lib/{,**/}{,**/}*.spec.js", + "test-projects": "mocha test-projects/**/*.spec.js", + "test-projects-install": "node test-projects/install.js", + "jscs": "jscs .", + "jshint": "jshint --exclude ./node_modules,./test-projects . --verbose", + "tslint": "tslint electron-log.d.ts" + }, + "typings": "./electron-log.d.ts", + "repository": { + "type": "git", + "url": "git+https://github.com/megahertz/electron-log.git" + }, + "files": [ + "index.js", + "main.js", + "renderer.js", + "lib/**/*.js", + "!lib/**/*.spec.js", + "electron-log.d.ts" + ], + "keywords": [ + "electron", + "atom", + "log", + "logger", + "logging", + "windows", + "mac", + "osx", + "linux", + "desktop" + ], + "author": "Alexey Prokhorov", + "license": "MIT", + "bugs": { + "url": "https://github.com/megahertz/electron-log/issues" + }, + "homepage": "https://github.com/megahertz/electron-log#readme", + "devDependencies": { + "chai": "*", + "jscs": "*", + "jshint": "*", + "jshint-reporter-jscs": "*", + "mocha": "*", + "rewire": "*", + "tslint": "*", + "typescript": "*" + } +} diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/renderer.js b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/renderer.js new file mode 100644 index 00000000000..12f55f4378b --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/electron-log/renderer.js @@ -0,0 +1,48 @@ +'use strict'; + +module.exports = null; + +var ipcRenderer; +try { + ipcRenderer = require('electron').ipcRenderer; +} catch (e) { + ipcRenderer = null; +} + +if (ipcRenderer) { + module.exports = { + error: log.bind(null, 'error'), + warn: log.bind(null, 'warn'), + info: log.bind(null, 'info'), + verbose: log.bind(null, 'verbose'), + debug: log.bind(null, 'debug'), + silly: log.bind(null, 'silly'), + log: log.bind(null, 'info') + }; + + module.exports.default = module.exports; + + ipcRenderer.on('__ELECTRON_LOG_RENDERER__', function(event, level, text) { + if (level === 'verbose') { + level = 'log'; + } else if (level === 'silly') { + level = 'debug'; + } + + console[level](text); + }); +} + +function log() { + var data = Array.prototype.slice.call(arguments); + + data = data.map(function(obj) { + if (obj instanceof Error) { + obj = obj.stack || obj; + } + + return obj; + }); + + ipcRenderer.send('__ELECTRON_LOG__', data); +} diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/foo b/test/fixtures/test-app-yarn-several-workspace/node_modules/foo new file mode 120000 index 00000000000..61d898a3a60 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/foo @@ -0,0 +1 @@ +../packages/foo \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/ms/index.js b/test/fixtures/test-app-yarn-several-workspace/node_modules/ms/index.js new file mode 100644 index 00000000000..6a522b16b3a --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/ms/index.js @@ -0,0 +1,152 @@ +/** + * Helpers. + */ + +var s = 1000; +var m = s * 60; +var h = m * 60; +var d = h * 24; +var y = d * 365.25; + +/** + * Parse or format the given `val`. + * + * Options: + * + * - `long` verbose formatting [false] + * + * @param {String|Number} val + * @param {Object} [options] + * @throws {Error} throw an error if val is not a non-empty string or a number + * @return {String|Number} + * @api public + */ + +module.exports = function(val, options) { + options = options || {}; + var type = typeof val; + if (type === 'string' && val.length > 0) { + return parse(val); + } else if (type === 'number' && isNaN(val) === false) { + return options.long ? fmtLong(val) : fmtShort(val); + } + throw new Error( + 'val is not a non-empty string or a valid number. val=' + + JSON.stringify(val) + ); +}; + +/** + * Parse the given `str` and return milliseconds. + * + * @param {String} str + * @return {Number} + * @api private + */ + +function parse(str) { + str = String(str); + if (str.length > 100) { + return; + } + var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec( + str + ); + if (!match) { + return; + } + var n = parseFloat(match[1]); + var type = (match[2] || 'ms').toLowerCase(); + switch (type) { + case 'years': + case 'year': + case 'yrs': + case 'yr': + case 'y': + return n * y; + case 'days': + case 'day': + case 'd': + return n * d; + case 'hours': + case 'hour': + case 'hrs': + case 'hr': + case 'h': + return n * h; + case 'minutes': + case 'minute': + case 'mins': + case 'min': + case 'm': + return n * m; + case 'seconds': + case 'second': + case 'secs': + case 'sec': + case 's': + return n * s; + case 'milliseconds': + case 'millisecond': + case 'msecs': + case 'msec': + case 'ms': + return n; + default: + return undefined; + } +} + +/** + * Short format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtShort(ms) { + if (ms >= d) { + return Math.round(ms / d) + 'd'; + } + if (ms >= h) { + return Math.round(ms / h) + 'h'; + } + if (ms >= m) { + return Math.round(ms / m) + 'm'; + } + if (ms >= s) { + return Math.round(ms / s) + 's'; + } + return ms + 'ms'; +} + +/** + * Long format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtLong(ms) { + return plural(ms, d, 'day') || + plural(ms, h, 'hour') || + plural(ms, m, 'minute') || + plural(ms, s, 'second') || + ms + ' ms'; +} + +/** + * Pluralization helper. + */ + +function plural(ms, n, name) { + if (ms < n) { + return; + } + if (ms < n * 1.5) { + return Math.floor(ms / n) + ' ' + name; + } + return Math.ceil(ms / n) + ' ' + name + 's'; +} diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/ms/license.md b/test/fixtures/test-app-yarn-several-workspace/node_modules/ms/license.md new file mode 100644 index 00000000000..69b61253a38 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/ms/license.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Zeit, Inc. + +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. diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/ms/package.json b/test/fixtures/test-app-yarn-several-workspace/node_modules/ms/package.json new file mode 100644 index 00000000000..6a31c81fac4 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/ms/package.json @@ -0,0 +1,37 @@ +{ + "name": "ms", + "version": "2.0.0", + "description": "Tiny milisecond conversion utility", + "repository": "zeit/ms", + "main": "./index", + "files": [ + "index.js" + ], + "scripts": { + "precommit": "lint-staged", + "lint": "eslint lib/* bin/*", + "test": "mocha tests.js" + }, + "eslintConfig": { + "extends": "eslint:recommended", + "env": { + "node": true, + "es6": true + } + }, + "lint-staged": { + "*.js": [ + "npm run lint", + "prettier --single-quote --write", + "git add" + ] + }, + "license": "MIT", + "devDependencies": { + "eslint": "3.19.0", + "expect.js": "0.3.1", + "husky": "0.13.3", + "lint-staged": "3.4.1", + "mocha": "3.4.1" + } +} diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/ms/readme.md b/test/fixtures/test-app-yarn-several-workspace/node_modules/ms/readme.md new file mode 100644 index 00000000000..84a9974cccd --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/ms/readme.md @@ -0,0 +1,51 @@ +# ms + +[![Build Status](https://travis-ci.org/zeit/ms.svg?branch=master)](https://travis-ci.org/zeit/ms) +[![Slack Channel](http://zeit-slackin.now.sh/badge.svg)](https://zeit.chat/) + +Use this package to easily convert various time formats to milliseconds. + +## Examples + +```js +ms('2 days') // 172800000 +ms('1d') // 86400000 +ms('10h') // 36000000 +ms('2.5 hrs') // 9000000 +ms('2h') // 7200000 +ms('1m') // 60000 +ms('5s') // 5000 +ms('1y') // 31557600000 +ms('100') // 100 +``` + +### Convert from milliseconds + +```js +ms(60000) // "1m" +ms(2 * 60000) // "2m" +ms(ms('10 hours')) // "10h" +``` + +### Time format written-out + +```js +ms(60000, { long: true }) // "1 minute" +ms(2 * 60000, { long: true }) // "2 minutes" +ms(ms('10 hours'), { long: true }) // "10 hours" +``` + +## Features + +- Works both in [node](https://nodejs.org) and in the browser. +- If a number is supplied to `ms`, a string with a unit is returned. +- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`). +- If you pass a string with a number and a valid unit, the number of equivalent ms is returned. + +## Caught a bug? + +1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device +2. Link the package to the global module directory: `npm link` +3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, node will now use your clone of ms! + +As always, you can run the tests using: `npm test` diff --git a/test/fixtures/test-app-yarn-several-workspace/node_modules/test-app b/test/fixtures/test-app-yarn-several-workspace/node_modules/test-app new file mode 120000 index 00000000000..6d4c4c138ca --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/node_modules/test-app @@ -0,0 +1 @@ +../packages/test-app \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/package.json b/test/fixtures/test-app-yarn-several-workspace/package.json new file mode 100644 index 00000000000..8de1b8ebd98 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "workspaces": [ + "packages/*" + ] +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/foo/package.json b/test/fixtures/test-app-yarn-several-workspace/packages/foo/package.json new file mode 100644 index 00000000000..28a5b85beef --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/foo/package.json @@ -0,0 +1,10 @@ +{ + "name": "foo", + "version": "1.0.0", + "main": "index.js", + "license": "MIT", + "dependencies": { + "ms": "2.0.0", + "electron-log": "2.2.8" + } +} diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/index.html b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/index.html new file mode 100644 index 00000000000..a25b3367d5e --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/index.html @@ -0,0 +1,25 @@ + + + + + Hello World! + + + +

Hello World!

+ We are using node , + Chrome , + and Electron . + + Args: . + + Env: . + + + + diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/index.js b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/index.js new file mode 100644 index 00000000000..c3f858036c9 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/index.js @@ -0,0 +1,144 @@ +'use strict' + +const { app, ipcMain, BrowserWindow, Menu, Tray } = require("electron") +const fs = require("fs") +const path = require("path") + +// this should be placed at top of main.js to handle setup events quickly +if (handleSquirrelEvent()) { + // squirrel event handled and app will exit in 1000ms, so don't do anything else + return; +} + +function handleSquirrelEvent() { + if (process.argv.length === 1) { + return false; + } + + const ChildProcess = require('child_process'); + + const appFolder = path.resolve(process.execPath, '..'); + const rootAtomFolder = path.resolve(appFolder, '..'); + const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe')); + const exeName = path.basename(process.execPath); + + const spawn = function(command, args) { + let spawnedProcess, error; + + try { + spawnedProcess = ChildProcess.spawn(command, args, {detached: true}); + } catch (error) {} + + return spawnedProcess; + }; + + const spawnUpdate = function(args) { + return spawn(updateDotExe, args); + }; + + const squirrelEvent = process.argv[1]; + switch (squirrelEvent) { + case '--squirrel-install': + case '--squirrel-updated': + // Optionally do things such as: + // - Add your .exe to the PATH + // - Write to the registry for things like file associations and + // explorer context menus + + // Install desktop and start menu shortcuts + spawnUpdate(['--createShortcut', exeName]); + + setTimeout(app.quit, 1000); + return true; + + case '--squirrel-uninstall': + // Undo anything you did in the --squirrel-install and + // --squirrel-updated handlers + + // Remove desktop and start menu shortcuts + spawnUpdate(['--removeShortcut', exeName]); + + setTimeout(app.quit, 1000); + return true; + + case '--squirrel-obsolete': + // This is called on the outgoing version of your app before + // we update to the new version - it's the opposite of + // --squirrel-updated + + app.quit(); + return true; + } +} + +// Module to control application life. +// Module to create native browser window. + +// Keep a global reference of the window object, if you don't, the window will +// be closed automatically when the JavaScript object is garbage collected. +let mainWindow; + +let tray = null + +function createWindow () { + if (process.platform === "linux" && process.env.APPDIR != null) { + tray = new Tray(path.join(process.env.APPDIR, "testapp.png")) + const contextMenu = Menu.buildFromTemplate([ + {label: 'Item1', type: 'radio'}, + {label: 'Item2', type: 'radio'}, + {label: 'Item3', type: 'radio', checked: true}, + {label: 'Item4', type: 'radio'} + ]) + tray.setToolTip('This is my application.') + tray.setContextMenu(contextMenu) + } + + // Create the browser window. + mainWindow = new BrowserWindow({width: 800, height: 600}); + + // and load the index.html of the app. + mainWindow.loadURL('file://' + __dirname + '/index.html'); + + // Open the DevTools. + mainWindow.webContents.openDevTools(); + + mainWindow.webContents.executeJavaScript(`console.log("appData: ${app.getPath("appData").replace(/\\/g, "\\\\")}")`) + mainWindow.webContents.executeJavaScript(`console.log("userData: ${app.getPath("userData").replace(/\\/g, "\\\\")}")`) + + // Emitted when the window is closed. + mainWindow.on('closed', function() { + // Dereference the window object, usually you would store windows + // in an array if your app supports multi windows, this is the time + // when you should delete the corresponding element. + mainWindow = null; + }); +} + +// This method will be called when Electron has finished +// initialization and is ready to create browser windows. +app.on('ready', createWindow); + +// Quit when all windows are closed. +app.on('window-all-closed', function () { + // On MacOS it is common for applications and their menu bar + // to stay active until the user quits explicitly with Cmd + Q + if (process.platform !== 'darwin') { + app.quit(); + } +}); + +app.on("activate", function () { + if (mainWindow === null) { + createWindow() + } +}) + +ipcMain.on("saveAppData", () => { + try { + // electron doesn't escape / in the product name + fs.writeFileSync(path.join(app.getPath("appData"), "Test App ßW", "testFile"), "test") + } + catch (e) { + mainWindow.webContents.executeJavaScript(`console.log(\`userData: ${e}\`)`) + } +}) \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/LICENSE b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/LICENSE new file mode 100644 index 00000000000..1f7f7e1438c --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Alexey Prokhorov + +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. \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/README.md b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/README.md new file mode 100644 index 00000000000..a1ab28fa943 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/README.md @@ -0,0 +1,163 @@ +# electron-log +[![Build Status](https://travis-ci.org/megahertz/electron-log.svg?branch=master)](https://travis-ci.org/megahertz/electron-log) +[![NPM version](https://badge.fury.io/js/electron-log.svg)](https://badge.fury.io/js/electron-log) +[![Dependencies status](https://david-dm.org/megahertz/electron-log/status.svg)](https://david-dm.org/megahertz/electron-log) + +## Description + +Just a simple logging module for your Electron or NW.js application. +No dependencies. No complicated configuration. Just require and use. +It can be used without Electron. + +By default it writes logs to the following locations: + + * **on Linux:** `~/.config//log.log` + * **on OS X:** `~/Library/Logs//log.log` + * **on Windows:** `%USERPROFILE%\AppData\Roaming\\log.log` + +## Installation + +Install with [npm](https://npmjs.org/package/electron-log): + + npm install electron-log + +## Usage + +```js +var log = require('electron-log'); + +log.info('Hello, log'); +``` +### Log levels + +electron-log supports the following log levels: + + error, warn, info, verbose, debug, silly + +### Transport + +Transport is a simple function which requires an object which describes +a message. By default, two transports are active: console and file. +Please be aware that the file log level is 'warn' by default, so info +and debug messages will be filtered. The file path is dependent on the +current platform. + + + +#### Disable default transport: + +```js +log.transports.file.level = false; +log.transports.console.level = false; +``` + +#### Override transport: + +```js +var format = require('util'); + +log.transports.console = function(msg) { + var text = util.format.apply(util, msg.data); + console.log(`[${msg.date.toLocaleTimeString()} ${msg.level}] ${text}`); +}; +``` +Please be aware that if you override a transport function the default +transport options (like level or format) will be undefined. + +#### Console Transport + +```js +// Log level +log.transports.console.level = 'warn'; + +/** + * Set output format template. Available variables: + * Main: {level}, {text} + * Date: {y},{m},{d},{h},{i},{s},{ms} + */ +log.transports.console.format = '{h}:{i}:{s}:{ms} {text}'; + +// Set a function which formats output +log.transports.console.format = (msg) => util.format.apply(util, msg.data); +``` + +#### Renderer Console transport +Show logs in Chromium DevTools Console. It has the same options as +console transport. + +#### File transport + +```js +// Same as for console transport +log.transports.file.level = 'warn'; +log.transports.file.format = '{h}:{i}:{s}:{ms} {text}'; + +// Set approximate maximum log size in bytes. When it exceeds, +// the archived log will be saved as the log.old.log file +log.transports.file.maxSize = 5 * 1024 * 1024; + +// Write to this file, must be set before first logging +log.transports.file.file = __dirname + '/log.txt'; + +// fs.createWriteStream options, must be set before first logging +log.transports.file.streamConfig = { flags: 'w' }; + +// set existed file stream +log.transports.file.stream = fs.createWriteStream('log.txt'); +``` + +By default, file transport reads a productName or name property from +package.json to determine a log path like +`~/.config//log.log`. If you have no package.json or you want +to specify another path, just set the appName property: + +```js +log.transports.file.appName = 'test'; +``` +This value should be set before the first log method call. + +## Renderer process + +Since version 2.0.0 this package works differently in main and renderer +processes. When it's included in a renderer process it sends logs to +the main process through IPC. There are no API changes, you can still +require the package by the same way both in main and renderer processes, +but please be aware that transport configuration is available only +inside the main process. + +## Change Log + +**2.1.0** + - Add Renderer Console transport + +**2.0.0** + - Move log.appName property to log.transports.file.appName. + - Change a log message object. See updated + [Override transport section](#override-transport) if you use a custom + transport. + - Now it's not possible to configure transports from a renderer + process, only from the main. + - To disable a transport set its level to false. + - Fix problems when this package is used from a renderer process. + - Add Typescript definitions. + - Add [log-s](https://github.com/megahertz/log-s) transport + (experimental). + - Fix file transport appName detection when an application is run + in dev environment (through `electron .` or similar way) + +**1.3.0** + +- #18 Rename 'warning' log level to 'warn' + +**1.2.0** + + - #14 Use native console levels instead of console.log + +**1.0.16** + + - Prefer to use package.json:productName instead of package.json:name + to determine a log path. + +## License + +Licensed under MIT. diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/electron-log.d.ts b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/electron-log.d.ts new file mode 100644 index 00000000000..af2527a1086 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/electron-log.d.ts @@ -0,0 +1,60 @@ +export type LogLevel = "error" | "warn" | "info" | "verbose" | "debug" | "silly"; +export type LevelOption = LogLevel | false; + +export type IFormat = (msg: ILogMessage) => void; + +export interface ILogMessage { + data: any[]; + date: Date; + level: LogLevel; +} + +export interface IConsoleTransport { + (msg: ILogMessage): void; + level: LevelOption; + format: IFormat | string; +} + +export interface IFileTransport { + (msg: ILogMessage): void; + appName?: string; + file?: string; + format: IFormat | string; + level: LevelOption; + maxSize: number; + streamConfig?: object; + findLogPath(appName: string): string; +} + +export interface ILogSTransport { + (msg: ILogMessage): void; + client: object; + depth: number; + level: LevelOption; + url?: string; +} + +export declare function error(...params: any[]): void; +export declare function warn(...params: any[]): void; +export declare function info(...params: any[]): void; +export declare function verbose(...params: any[]): void; +export declare function debug(...params: any[]): void; +export declare function silly(...params: any[]): void; + +export declare const transports: { + console: IConsoleTransport; + file: IFileTransport; + logS: ILogSTransport; + rendererConsole: IConsoleTransport; +}; + +// tslint:disable object-literal-sort-keys +export default { + error, + warn, + info, + verbose, + debug, + silly, + transports, +}; diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/index.js b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/index.js new file mode 100644 index 00000000000..ece47214b63 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/index.js @@ -0,0 +1,7 @@ +'use strict'; + +if (process.type === 'renderer') { + module.exports = require('./renderer'); +} else { + module.exports = require('./main'); +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/format.js b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/format.js new file mode 100644 index 00000000000..fa96c0144b9 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/format.js @@ -0,0 +1,41 @@ +'use strict'; + +var util = require('util'); +var EOL = require('os').EOL; + +module.exports = { + format: format, + pad: pad, + stringifyArray: stringifyArray +}; + +function format(msg, formatter) { + if (typeof formatter === 'function') { + return formatter(msg); + } + + var date = msg.date; + + return formatter + .replace('{level}', msg.level) + .replace('{text}', stringifyArray(msg.data)) + .replace('{y}', date.getFullYear()) + .replace('{m}', pad(date.getMonth() + 1)) + .replace('{d}', pad(date.getDate())) + .replace('{h}', pad(date.getHours())) + .replace('{i}', pad(date.getMinutes())) + .replace('{s}', pad(date.getSeconds())) + .replace('{ms}', pad(date.getMilliseconds(), 3)); +} + +function stringifyArray(data) { + data = data.map(function formatErrors(arg) { + return arg instanceof Error ? arg.stack + EOL : arg; + }); + return util.format.apply(util, data); +} + +function pad(number, zeros) { + zeros = zeros || 2; + return (new Array(zeros + 1).join('0') + number).substr(-zeros, zeros); +} diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/log.js b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/log.js new file mode 100644 index 00000000000..9be83d6ed72 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/log.js @@ -0,0 +1,42 @@ +// jshint -W040 +'use strict'; + +var LEVELS = ['error', 'warn', 'info', 'verbose', 'debug', 'silly']; + +module.exports = log; + +function log(transports, level, text) { + var data = Array.prototype.slice.call(arguments, 2); + + var msg = { + data: data, + date: new Date(), + level: level + }; + + for (var i in transports) { + // jshint -W089 + if (!transports.hasOwnProperty(i) || typeof transports[i] !== 'function') { + continue; + } + + var transport = transports[i]; + + if (transport === false || !compareLevels(transport.level, level)) { + continue; + } + + if (transport.level === false) continue; + + transport.call(null, msg); + } +} + +function compareLevels(passLevel, checkLevel) { + var pass = LEVELS.indexOf(passLevel); + var check = LEVELS.indexOf(checkLevel); + if (check === -1 || pass === -1) { + return true; + } + return check <= pass; +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/console.js b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/console.js new file mode 100644 index 00000000000..880d44c55e2 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/console.js @@ -0,0 +1,18 @@ +'use strict'; + +var format = require('../format'); + +transport.level = 'silly'; +transport.format = '[{h}:{i}:{s}.{ms}] [{level}] {text}'; + +module.exports = transport; + +function transport(msg) { + var text = format.format(msg, transport.format); + if (console[msg.level]) { + console[msg.level](text); + } else { + console.log(text); + } +} + diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/file/find-log-path.js b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/file/find-log-path.js new file mode 100644 index 00000000000..7eba2300fb3 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/file/find-log-path.js @@ -0,0 +1,96 @@ +'use strict'; + +var fs = require('fs'); +var path = require('path'); +var os = require('os'); +var getAppName = require('./get-app-name'); + +module.exports = findLogPath; + +/** + * Try to determine a platform-specific path where can write logs + * @param {string} [appName] Used to determine the last part of a log path + * @return {string|boolean} + */ +function findLogPath(appName) { + appName = appName || getAppName(); + if (!appName) { + return false; + } + + var homeDir = os.homedir ? os.homedir() : process.env['HOME']; + + var dir; + switch (process.platform) { + case 'linux': { + dir = prepareDir(process.env['XDG_CONFIG_HOME'], appName) + .or(homeDir, '.config', appName) + .or(process.env['XDG_DATA_HOME'], appName) + .or(homeDir, '.local', 'share', appName) + .result; + break; + } + + case 'darwin': { + dir = prepareDir(homeDir, 'Library', 'Logs', appName) + .or(homeDir, 'Library', 'Application Support', appName) + .result; + break; + } + + case 'win32': { + dir = prepareDir(process.env['APPDATA'], appName) + .or(homeDir, 'AppData', 'Roaming', appName) + .result; + break; + } + } + + if (dir) { + return path.join(dir, 'log.log'); + } else { + return false; + } +} + + + +function prepareDir(dirPath) { + // jshint -W040 + if (!this || this.or !== prepareDir || !this.result) { + if (!dirPath) { + return { or: prepareDir }; + } + + //noinspection JSCheckFunctionSignatures + dirPath = path.join.apply(path, arguments); + mkDir(dirPath); + + try { + fs.accessSync(dirPath, fs.W_OK); + } catch (e) { + return { or: prepareDir }; + } + } + + return { + or: prepareDir, + result: (this ? this.result : false) || dirPath + }; +} + +function mkDir(dirPath, root) { + var dirs = dirPath.split(path.sep); + var dir = dirs.shift(); + root = (root || '') + dir + path.sep; + + try { + fs.mkdirSync(root); + } catch (e) { + if (!fs.statSync(root).isDirectory()) { + throw new Error(e); + } + } + + return !dirs.length || mkDir(dirs.join(path.sep), root); +} diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/file/get-app-name.js b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/file/get-app-name.js new file mode 100644 index 00000000000..213ae49bcf8 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/file/get-app-name.js @@ -0,0 +1,91 @@ +// jshint -W074 +'use strict'; + +/** @name process.resourcesPath */ + +var fs = require('fs'); +var path = require('path'); +var consoleTransport = require('../console'); + +module.exports = getAppName; + +function getAppName() { + try { + var name = loadPackageName(); + if (name) { + return name; + } + return warn('electron-log: unable to load the app name from package.json'); + } catch (e) { + return warn('electron-log: ' + e.message); + } +} + +/** + * Try to load main app package + * @throws {Error} + * @return {Object|null} + */ +function loadPackageName() { + var packageFile; + + try { + if (require.main.filename) { + packageFile = find(path.dirname(require.main.filename)); + } + } catch (e) {} + + if (!packageFile && process.resourcesPath) { + packageFile = find(path.join(process.resourcesPath, 'app.asar')); + var electronModule = path.join('node_modules', 'electron', 'package.json'); + if (packageFile && packageFile.indexOf(electronModule) !== -1) { + packageFile = null; + } + } + + if (!packageFile) { + packageFile = find(process.cwd()); + } + + if (!packageFile) { + return null; + } + + var content = fs.readFileSync(packageFile, 'utf-8'); + var packageData = JSON.parse(content); + + //noinspection JSUnresolvedVariable + return packageData ? packageData.productName || packageData.name : false; +} + +function find(root) { + var file; + + while (!file) { + var parent; + file = path.join(root, 'package.json'); + + try { + fs.statSync(file); + } catch (e) { + parent = path.resolve(root, '..'); + file = null; + } + + if (root === parent) { + break; + } + + root = parent; + } + + return file; +} + +function warn(message) { + consoleTransport({ + data: [message], + date: new Date(), + level: 'warn' + }); +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/file/index.js b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/file/index.js new file mode 100644 index 00000000000..94fa9f88219 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/file/index.js @@ -0,0 +1,96 @@ +'use strict'; + +var fs = require('fs'); +var EOL = require('os').EOL; +var format = require('../../format'); +var consoleTransport = require('../console'); +var findLogPath = require('./find-log-path'); + +transport.findLogPath = findLogPath; +transport.format = '[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}] {text}'; +transport.level = 'warn'; +transport.maxSize = 1024 * 1024; +transport.streamConfig = undefined; + +module.exports = transport; + +function transport(msg) { + var text = format.format(msg, transport.format) + EOL; + + if (transport.stream === undefined) { + initSteamConfig(); + openStream(); + } + + if (transport.level === false) { + return; + } + + var needLogRotation = transport.maxSize > 0 && + getStreamSize(transport.stream) > transport.maxSize; + + if (needLogRotation) { + archiveLog(transport.stream); + openStream(); + } + + transport.stream.write(text); +} + +function initSteamConfig() { + transport.file = transport.file || findLogPath(transport.appName); + + if (!transport.file) { + transport.level = false; + logConsole('Could not set a log file'); + } +} + +function openStream() { + if (transport.level === false) { + return; + } + + transport.stream = fs.createWriteStream( + transport.file, + transport.streamConfig || { flags: 'a' } + ); +} + +function getStreamSize(stream) { + if (!stream) { + return 0; + } + + if (stream.logSizeAtStart === undefined) { + try { + stream.logSizeAtStart = fs.statSync(stream.path).size; + } catch (e) { + stream.logSizeAtStart = 0; + } + } + + return stream.logSizeAtStart + stream.bytesWritten; +} + +function archiveLog(stream) { + if (stream.end) { + stream.end(); + } + + try { + fs.renameSync(stream.path, stream.path.replace(/log$/, 'old.log')); + } catch (e) { + logConsole('Could not rotate log', e); + } +} + +function logConsole(message, error) { + var data = ['electron-log.transports.file: ' + message]; + + if (error) { + data.push(error); + } + + consoleTransport({ data: data, date: new Date(), level: 'warn' }); +} diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/log-s.js b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/log-s.js new file mode 100644 index 00000000000..e7b1d49dd5f --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/log-s.js @@ -0,0 +1,86 @@ +// jshint -W074, -W089 +'use strict'; + +var http = require('http'); +var https = require('https'); +var url = require('url'); + +transport.client = { name: 'electron-application' }; +transport.depth = 6; +transport.level = false; +transport.url = null; + +module.exports = transport; + +function transport(msg) { + if (!transport.url) return; + + var data = jsonDepth({ + client: transport.client, + data: msg.data, + date: msg.date.getTime(), + level: msg.level + }, transport.depth + 1); + + post(transport.url, data); +} + +function post(serverUrl, data) { + var urlObject = url.parse(serverUrl); + var transport = urlObject.protocol === 'https:' ? https : http; + + var body = JSON.stringify(data); + + var options = { + hostname: urlObject.hostname, + port: urlObject.port, + path: urlObject.path, + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Content-Length': body.length + } + }; + + var request = transport.request(options); + request.write(body); + request.end(); +} + +function jsonDepth(json, depth) { + if (depth < 1) { + if (Array.isArray(json)) return '[array]'; + if (typeof json === 'object') return '[object]'; + return json; + } + + if (Array.isArray(json)) { + return json.map(function(child) { + return jsonDepth(child, depth - 1); + }); + } + + if (json && typeof json.getMonth === 'function') { + return json; + } + + if (json === null) { + return null; + } + + if (typeof json === 'object') { + if (typeof json.toJSON === 'function') { + json = json.toJSON(); + } + + var newJson = {}; + for (var i in json) { + //noinspection JSUnfilteredForInLoop + newJson[i] = jsonDepth(json[i], depth - 1); + } + + return newJson; + } + + return json; +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/renderer-console.js b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/renderer-console.js new file mode 100644 index 00000000000..a50f09990fa --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/lib/transports/renderer-console.js @@ -0,0 +1,24 @@ +'use strict'; + +var BrowserWindow; +try { + BrowserWindow = require('electron').BrowserWindow; +} catch (e) { + BrowserWindow = null; +} + +var format = require('../format'); + +transport.level = BrowserWindow ? 'silly' : false; +transport.format = '[{h}:{i}:{s}.{ms}] {text}'; + +module.exports = transport; + +function transport(msg) { + if (!BrowserWindow) return; + + var text = format.format(msg, transport.format); + BrowserWindow.getAllWindows().forEach(function(wnd) { + wnd.webContents.send('__ELECTRON_LOG_RENDERER__', msg.level, text); + }); +} diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/main.js b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/main.js new file mode 100644 index 00000000000..bf4181d59d4 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/main.js @@ -0,0 +1,50 @@ +'use strict'; + +var electron; +try { + electron = require('electron'); +} catch (e) { + electron = null; +} + +var log = require('./lib/log'); +var transportConsole = require('./lib/transports/console'); +var transportFile = require('./lib/transports/file'); +var transportLogS = require('./lib/transports/log-s'); +var transportRendererConsole = require('./lib/transports/renderer-console'); + +var transports = { + console: transportConsole, + file: transportFile, + logS: transportLogS, + rendererConsole: transportRendererConsole +}; + +module.exports = { + transports: transports, + + error: log.bind(null, transports, 'error'), + warn: log.bind(null, transports, 'warn'), + info: log.bind(null, transports, 'info'), + verbose: log.bind(null, transports, 'verbose'), + debug: log.bind(null, transports, 'debug'), + silly: log.bind(null, transports, 'silly'), + log: log.bind(null, transports, 'info') +}; + +module.exports.default = module.exports; + +if (electron && electron.ipcMain) { + electron.ipcMain.on('__ELECTRON_LOG__', onRendererLog); + var appName = electron.app.getName(); + if (appName !== 'Electron') { + transportFile.appName = appName; + } +} + +function onRendererLog(event, data) { + if (Array.isArray(data)) { + data.unshift(transports); + log.apply(null, data); + } +} diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/package.json b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/package.json new file mode 100644 index 00000000000..6d62dde372b --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/package.json @@ -0,0 +1,56 @@ +{ + "name": "electron-log", + "version": "2.2.9", + "description": "Just a very simple logging module for your Electron application", + "main": "./index.js", + "scripts": { + "test": "npm run jshint && npm run jscs && npm run tslint && npm run mocha && npm run test-projects", + "mocha": "mocha index.spec.js lib/{,**/}{,**/}*.spec.js", + "test-projects": "mocha test-projects/**/*.spec.js", + "test-projects-install": "node test-projects/install.js", + "jscs": "jscs .", + "jshint": "jshint --exclude ./node_modules,./test-projects . --verbose", + "tslint": "tslint electron-log.d.ts" + }, + "typings": "./electron-log.d.ts", + "repository": { + "type": "git", + "url": "git+https://github.com/megahertz/electron-log.git" + }, + "files": [ + "index.js", + "main.js", + "renderer.js", + "lib/**/*.js", + "!lib/**/*.spec.js", + "electron-log.d.ts" + ], + "keywords": [ + "electron", + "atom", + "log", + "logger", + "logging", + "windows", + "mac", + "osx", + "linux", + "desktop" + ], + "author": "Alexey Prokhorov", + "license": "MIT", + "bugs": { + "url": "https://github.com/megahertz/electron-log/issues" + }, + "homepage": "https://github.com/megahertz/electron-log#readme", + "devDependencies": { + "chai": "*", + "jscs": "*", + "jshint": "*", + "jshint-reporter-jscs": "*", + "mocha": "*", + "rewire": "*", + "tslint": "*", + "typescript": "*" + } +} diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/renderer.js b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/renderer.js new file mode 100644 index 00000000000..12f55f4378b --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/node_modules/electron-log/renderer.js @@ -0,0 +1,48 @@ +'use strict'; + +module.exports = null; + +var ipcRenderer; +try { + ipcRenderer = require('electron').ipcRenderer; +} catch (e) { + ipcRenderer = null; +} + +if (ipcRenderer) { + module.exports = { + error: log.bind(null, 'error'), + warn: log.bind(null, 'warn'), + info: log.bind(null, 'info'), + verbose: log.bind(null, 'verbose'), + debug: log.bind(null, 'debug'), + silly: log.bind(null, 'silly'), + log: log.bind(null, 'info') + }; + + module.exports.default = module.exports; + + ipcRenderer.on('__ELECTRON_LOG_RENDERER__', function(event, level, text) { + if (level === 'verbose') { + level = 'log'; + } else if (level === 'silly') { + level = 'debug'; + } + + console[level](text); + }); +} + +function log() { + var data = Array.prototype.slice.call(arguments); + + data = data.map(function(obj) { + if (obj instanceof Error) { + obj = obj.stack || obj; + } + + return obj; + }); + + ipcRenderer.send('__ELECTRON_LOG__', data); +} diff --git a/test/fixtures/test-app-yarn-several-workspace/packages/test-app/package.json b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/package.json new file mode 100644 index 00000000000..270c1bb1fad --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/packages/test-app/package.json @@ -0,0 +1,25 @@ +{ + "name": "test-app", + "productName": "Test App ßW", + "version": "1.1.0", + "homepage": "http://foo.example.com", + "description": "Test Application (test quite \" #378)", + "author": "Foo Bar ", + "license": "MIT", + "build": { + "electronVersion": "1.7.8", + "appId": "org.electron-builder.testApp", + "compression": "store", + "npmRebuild": false, + "mac": { + "category": "your.app.category.type" + }, + "linux": { + "category": "Development" + } + }, + "dependencies": { + "ms": "2.0.0", + "electron-log": "2.2.9" + } +} diff --git a/test/fixtures/test-app-yarn-several-workspace/yarn.lock b/test/fixtures/test-app-yarn-several-workspace/yarn.lock new file mode 100644 index 00000000000..7732df68af9 --- /dev/null +++ b/test/fixtures/test-app-yarn-several-workspace/yarn.lock @@ -0,0 +1,15 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +electron-log@2.2.8: + version "2.2.8" + resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-2.2.8.tgz#2296cccd8da046268a199c1a302dcb8cb16f2b72" + +electron-log@2.2.9: + version "2.2.9" + resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-2.2.9.tgz#e0484cb1a8a84593095e3b69f47361ae15d73bdf" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/.yarn-integrity b/test/fixtures/test-app-yarn-workspace/node_modules/.yarn-integrity new file mode 100644 index 00000000000..1558c9ea155 --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/.yarn-integrity @@ -0,0 +1,26 @@ +{ + "modulesFolders": [ + "node_modules", + "node_modules" + ], + "flags": [], + "linkedModules": [ + "dmd", + "dmd-tf", + "docdash", + "electron-auto-updater", + "electron-download-tf", + "electron-vue-scripts", + "electron-webpack", + "jest-cli" + ], + "topLevelPatterns": [ + "electron-log@2.2.9", + "test-app@1.1.0" + ], + "lockfileEntries": { + "electron-log@2.2.9": "https://registry.yarnpkg.com/electron-log/-/electron-log-2.2.9.tgz#e0484cb1a8a84593095e3b69f47361ae15d73bdf" + }, + "files": [], + "artifacts": {} +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/LICENSE b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/LICENSE new file mode 100644 index 00000000000..1f7f7e1438c --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Alexey Prokhorov + +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. \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/README.md b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/README.md new file mode 100644 index 00000000000..a1ab28fa943 --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/README.md @@ -0,0 +1,163 @@ +# electron-log +[![Build Status](https://travis-ci.org/megahertz/electron-log.svg?branch=master)](https://travis-ci.org/megahertz/electron-log) +[![NPM version](https://badge.fury.io/js/electron-log.svg)](https://badge.fury.io/js/electron-log) +[![Dependencies status](https://david-dm.org/megahertz/electron-log/status.svg)](https://david-dm.org/megahertz/electron-log) + +## Description + +Just a simple logging module for your Electron or NW.js application. +No dependencies. No complicated configuration. Just require and use. +It can be used without Electron. + +By default it writes logs to the following locations: + + * **on Linux:** `~/.config//log.log` + * **on OS X:** `~/Library/Logs//log.log` + * **on Windows:** `%USERPROFILE%\AppData\Roaming\\log.log` + +## Installation + +Install with [npm](https://npmjs.org/package/electron-log): + + npm install electron-log + +## Usage + +```js +var log = require('electron-log'); + +log.info('Hello, log'); +``` +### Log levels + +electron-log supports the following log levels: + + error, warn, info, verbose, debug, silly + +### Transport + +Transport is a simple function which requires an object which describes +a message. By default, two transports are active: console and file. +Please be aware that the file log level is 'warn' by default, so info +and debug messages will be filtered. The file path is dependent on the +current platform. + + + +#### Disable default transport: + +```js +log.transports.file.level = false; +log.transports.console.level = false; +``` + +#### Override transport: + +```js +var format = require('util'); + +log.transports.console = function(msg) { + var text = util.format.apply(util, msg.data); + console.log(`[${msg.date.toLocaleTimeString()} ${msg.level}] ${text}`); +}; +``` +Please be aware that if you override a transport function the default +transport options (like level or format) will be undefined. + +#### Console Transport + +```js +// Log level +log.transports.console.level = 'warn'; + +/** + * Set output format template. Available variables: + * Main: {level}, {text} + * Date: {y},{m},{d},{h},{i},{s},{ms} + */ +log.transports.console.format = '{h}:{i}:{s}:{ms} {text}'; + +// Set a function which formats output +log.transports.console.format = (msg) => util.format.apply(util, msg.data); +``` + +#### Renderer Console transport +Show logs in Chromium DevTools Console. It has the same options as +console transport. + +#### File transport + +```js +// Same as for console transport +log.transports.file.level = 'warn'; +log.transports.file.format = '{h}:{i}:{s}:{ms} {text}'; + +// Set approximate maximum log size in bytes. When it exceeds, +// the archived log will be saved as the log.old.log file +log.transports.file.maxSize = 5 * 1024 * 1024; + +// Write to this file, must be set before first logging +log.transports.file.file = __dirname + '/log.txt'; + +// fs.createWriteStream options, must be set before first logging +log.transports.file.streamConfig = { flags: 'w' }; + +// set existed file stream +log.transports.file.stream = fs.createWriteStream('log.txt'); +``` + +By default, file transport reads a productName or name property from +package.json to determine a log path like +`~/.config//log.log`. If you have no package.json or you want +to specify another path, just set the appName property: + +```js +log.transports.file.appName = 'test'; +``` +This value should be set before the first log method call. + +## Renderer process + +Since version 2.0.0 this package works differently in main and renderer +processes. When it's included in a renderer process it sends logs to +the main process through IPC. There are no API changes, you can still +require the package by the same way both in main and renderer processes, +but please be aware that transport configuration is available only +inside the main process. + +## Change Log + +**2.1.0** + - Add Renderer Console transport + +**2.0.0** + - Move log.appName property to log.transports.file.appName. + - Change a log message object. See updated + [Override transport section](#override-transport) if you use a custom + transport. + - Now it's not possible to configure transports from a renderer + process, only from the main. + - To disable a transport set its level to false. + - Fix problems when this package is used from a renderer process. + - Add Typescript definitions. + - Add [log-s](https://github.com/megahertz/log-s) transport + (experimental). + - Fix file transport appName detection when an application is run + in dev environment (through `electron .` or similar way) + +**1.3.0** + +- #18 Rename 'warning' log level to 'warn' + +**1.2.0** + + - #14 Use native console levels instead of console.log + +**1.0.16** + + - Prefer to use package.json:productName instead of package.json:name + to determine a log path. + +## License + +Licensed under MIT. diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/electron-log.d.ts b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/electron-log.d.ts new file mode 100644 index 00000000000..af2527a1086 --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/electron-log.d.ts @@ -0,0 +1,60 @@ +export type LogLevel = "error" | "warn" | "info" | "verbose" | "debug" | "silly"; +export type LevelOption = LogLevel | false; + +export type IFormat = (msg: ILogMessage) => void; + +export interface ILogMessage { + data: any[]; + date: Date; + level: LogLevel; +} + +export interface IConsoleTransport { + (msg: ILogMessage): void; + level: LevelOption; + format: IFormat | string; +} + +export interface IFileTransport { + (msg: ILogMessage): void; + appName?: string; + file?: string; + format: IFormat | string; + level: LevelOption; + maxSize: number; + streamConfig?: object; + findLogPath(appName: string): string; +} + +export interface ILogSTransport { + (msg: ILogMessage): void; + client: object; + depth: number; + level: LevelOption; + url?: string; +} + +export declare function error(...params: any[]): void; +export declare function warn(...params: any[]): void; +export declare function info(...params: any[]): void; +export declare function verbose(...params: any[]): void; +export declare function debug(...params: any[]): void; +export declare function silly(...params: any[]): void; + +export declare const transports: { + console: IConsoleTransport; + file: IFileTransport; + logS: ILogSTransport; + rendererConsole: IConsoleTransport; +}; + +// tslint:disable object-literal-sort-keys +export default { + error, + warn, + info, + verbose, + debug, + silly, + transports, +}; diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/index.js b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/index.js new file mode 100644 index 00000000000..ece47214b63 --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/index.js @@ -0,0 +1,7 @@ +'use strict'; + +if (process.type === 'renderer') { + module.exports = require('./renderer'); +} else { + module.exports = require('./main'); +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/format.js b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/format.js new file mode 100644 index 00000000000..fa96c0144b9 --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/format.js @@ -0,0 +1,41 @@ +'use strict'; + +var util = require('util'); +var EOL = require('os').EOL; + +module.exports = { + format: format, + pad: pad, + stringifyArray: stringifyArray +}; + +function format(msg, formatter) { + if (typeof formatter === 'function') { + return formatter(msg); + } + + var date = msg.date; + + return formatter + .replace('{level}', msg.level) + .replace('{text}', stringifyArray(msg.data)) + .replace('{y}', date.getFullYear()) + .replace('{m}', pad(date.getMonth() + 1)) + .replace('{d}', pad(date.getDate())) + .replace('{h}', pad(date.getHours())) + .replace('{i}', pad(date.getMinutes())) + .replace('{s}', pad(date.getSeconds())) + .replace('{ms}', pad(date.getMilliseconds(), 3)); +} + +function stringifyArray(data) { + data = data.map(function formatErrors(arg) { + return arg instanceof Error ? arg.stack + EOL : arg; + }); + return util.format.apply(util, data); +} + +function pad(number, zeros) { + zeros = zeros || 2; + return (new Array(zeros + 1).join('0') + number).substr(-zeros, zeros); +} diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/log.js b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/log.js new file mode 100644 index 00000000000..9be83d6ed72 --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/log.js @@ -0,0 +1,42 @@ +// jshint -W040 +'use strict'; + +var LEVELS = ['error', 'warn', 'info', 'verbose', 'debug', 'silly']; + +module.exports = log; + +function log(transports, level, text) { + var data = Array.prototype.slice.call(arguments, 2); + + var msg = { + data: data, + date: new Date(), + level: level + }; + + for (var i in transports) { + // jshint -W089 + if (!transports.hasOwnProperty(i) || typeof transports[i] !== 'function') { + continue; + } + + var transport = transports[i]; + + if (transport === false || !compareLevels(transport.level, level)) { + continue; + } + + if (transport.level === false) continue; + + transport.call(null, msg); + } +} + +function compareLevels(passLevel, checkLevel) { + var pass = LEVELS.indexOf(passLevel); + var check = LEVELS.indexOf(checkLevel); + if (check === -1 || pass === -1) { + return true; + } + return check <= pass; +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/console.js b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/console.js new file mode 100644 index 00000000000..880d44c55e2 --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/console.js @@ -0,0 +1,18 @@ +'use strict'; + +var format = require('../format'); + +transport.level = 'silly'; +transport.format = '[{h}:{i}:{s}.{ms}] [{level}] {text}'; + +module.exports = transport; + +function transport(msg) { + var text = format.format(msg, transport.format); + if (console[msg.level]) { + console[msg.level](text); + } else { + console.log(text); + } +} + diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/file/find-log-path.js b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/file/find-log-path.js new file mode 100644 index 00000000000..7eba2300fb3 --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/file/find-log-path.js @@ -0,0 +1,96 @@ +'use strict'; + +var fs = require('fs'); +var path = require('path'); +var os = require('os'); +var getAppName = require('./get-app-name'); + +module.exports = findLogPath; + +/** + * Try to determine a platform-specific path where can write logs + * @param {string} [appName] Used to determine the last part of a log path + * @return {string|boolean} + */ +function findLogPath(appName) { + appName = appName || getAppName(); + if (!appName) { + return false; + } + + var homeDir = os.homedir ? os.homedir() : process.env['HOME']; + + var dir; + switch (process.platform) { + case 'linux': { + dir = prepareDir(process.env['XDG_CONFIG_HOME'], appName) + .or(homeDir, '.config', appName) + .or(process.env['XDG_DATA_HOME'], appName) + .or(homeDir, '.local', 'share', appName) + .result; + break; + } + + case 'darwin': { + dir = prepareDir(homeDir, 'Library', 'Logs', appName) + .or(homeDir, 'Library', 'Application Support', appName) + .result; + break; + } + + case 'win32': { + dir = prepareDir(process.env['APPDATA'], appName) + .or(homeDir, 'AppData', 'Roaming', appName) + .result; + break; + } + } + + if (dir) { + return path.join(dir, 'log.log'); + } else { + return false; + } +} + + + +function prepareDir(dirPath) { + // jshint -W040 + if (!this || this.or !== prepareDir || !this.result) { + if (!dirPath) { + return { or: prepareDir }; + } + + //noinspection JSCheckFunctionSignatures + dirPath = path.join.apply(path, arguments); + mkDir(dirPath); + + try { + fs.accessSync(dirPath, fs.W_OK); + } catch (e) { + return { or: prepareDir }; + } + } + + return { + or: prepareDir, + result: (this ? this.result : false) || dirPath + }; +} + +function mkDir(dirPath, root) { + var dirs = dirPath.split(path.sep); + var dir = dirs.shift(); + root = (root || '') + dir + path.sep; + + try { + fs.mkdirSync(root); + } catch (e) { + if (!fs.statSync(root).isDirectory()) { + throw new Error(e); + } + } + + return !dirs.length || mkDir(dirs.join(path.sep), root); +} diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/file/get-app-name.js b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/file/get-app-name.js new file mode 100644 index 00000000000..213ae49bcf8 --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/file/get-app-name.js @@ -0,0 +1,91 @@ +// jshint -W074 +'use strict'; + +/** @name process.resourcesPath */ + +var fs = require('fs'); +var path = require('path'); +var consoleTransport = require('../console'); + +module.exports = getAppName; + +function getAppName() { + try { + var name = loadPackageName(); + if (name) { + return name; + } + return warn('electron-log: unable to load the app name from package.json'); + } catch (e) { + return warn('electron-log: ' + e.message); + } +} + +/** + * Try to load main app package + * @throws {Error} + * @return {Object|null} + */ +function loadPackageName() { + var packageFile; + + try { + if (require.main.filename) { + packageFile = find(path.dirname(require.main.filename)); + } + } catch (e) {} + + if (!packageFile && process.resourcesPath) { + packageFile = find(path.join(process.resourcesPath, 'app.asar')); + var electronModule = path.join('node_modules', 'electron', 'package.json'); + if (packageFile && packageFile.indexOf(electronModule) !== -1) { + packageFile = null; + } + } + + if (!packageFile) { + packageFile = find(process.cwd()); + } + + if (!packageFile) { + return null; + } + + var content = fs.readFileSync(packageFile, 'utf-8'); + var packageData = JSON.parse(content); + + //noinspection JSUnresolvedVariable + return packageData ? packageData.productName || packageData.name : false; +} + +function find(root) { + var file; + + while (!file) { + var parent; + file = path.join(root, 'package.json'); + + try { + fs.statSync(file); + } catch (e) { + parent = path.resolve(root, '..'); + file = null; + } + + if (root === parent) { + break; + } + + root = parent; + } + + return file; +} + +function warn(message) { + consoleTransport({ + data: [message], + date: new Date(), + level: 'warn' + }); +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/file/index.js b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/file/index.js new file mode 100644 index 00000000000..94fa9f88219 --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/file/index.js @@ -0,0 +1,96 @@ +'use strict'; + +var fs = require('fs'); +var EOL = require('os').EOL; +var format = require('../../format'); +var consoleTransport = require('../console'); +var findLogPath = require('./find-log-path'); + +transport.findLogPath = findLogPath; +transport.format = '[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}] {text}'; +transport.level = 'warn'; +transport.maxSize = 1024 * 1024; +transport.streamConfig = undefined; + +module.exports = transport; + +function transport(msg) { + var text = format.format(msg, transport.format) + EOL; + + if (transport.stream === undefined) { + initSteamConfig(); + openStream(); + } + + if (transport.level === false) { + return; + } + + var needLogRotation = transport.maxSize > 0 && + getStreamSize(transport.stream) > transport.maxSize; + + if (needLogRotation) { + archiveLog(transport.stream); + openStream(); + } + + transport.stream.write(text); +} + +function initSteamConfig() { + transport.file = transport.file || findLogPath(transport.appName); + + if (!transport.file) { + transport.level = false; + logConsole('Could not set a log file'); + } +} + +function openStream() { + if (transport.level === false) { + return; + } + + transport.stream = fs.createWriteStream( + transport.file, + transport.streamConfig || { flags: 'a' } + ); +} + +function getStreamSize(stream) { + if (!stream) { + return 0; + } + + if (stream.logSizeAtStart === undefined) { + try { + stream.logSizeAtStart = fs.statSync(stream.path).size; + } catch (e) { + stream.logSizeAtStart = 0; + } + } + + return stream.logSizeAtStart + stream.bytesWritten; +} + +function archiveLog(stream) { + if (stream.end) { + stream.end(); + } + + try { + fs.renameSync(stream.path, stream.path.replace(/log$/, 'old.log')); + } catch (e) { + logConsole('Could not rotate log', e); + } +} + +function logConsole(message, error) { + var data = ['electron-log.transports.file: ' + message]; + + if (error) { + data.push(error); + } + + consoleTransport({ data: data, date: new Date(), level: 'warn' }); +} diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/log-s.js b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/log-s.js new file mode 100644 index 00000000000..e7b1d49dd5f --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/log-s.js @@ -0,0 +1,86 @@ +// jshint -W074, -W089 +'use strict'; + +var http = require('http'); +var https = require('https'); +var url = require('url'); + +transport.client = { name: 'electron-application' }; +transport.depth = 6; +transport.level = false; +transport.url = null; + +module.exports = transport; + +function transport(msg) { + if (!transport.url) return; + + var data = jsonDepth({ + client: transport.client, + data: msg.data, + date: msg.date.getTime(), + level: msg.level + }, transport.depth + 1); + + post(transport.url, data); +} + +function post(serverUrl, data) { + var urlObject = url.parse(serverUrl); + var transport = urlObject.protocol === 'https:' ? https : http; + + var body = JSON.stringify(data); + + var options = { + hostname: urlObject.hostname, + port: urlObject.port, + path: urlObject.path, + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Content-Length': body.length + } + }; + + var request = transport.request(options); + request.write(body); + request.end(); +} + +function jsonDepth(json, depth) { + if (depth < 1) { + if (Array.isArray(json)) return '[array]'; + if (typeof json === 'object') return '[object]'; + return json; + } + + if (Array.isArray(json)) { + return json.map(function(child) { + return jsonDepth(child, depth - 1); + }); + } + + if (json && typeof json.getMonth === 'function') { + return json; + } + + if (json === null) { + return null; + } + + if (typeof json === 'object') { + if (typeof json.toJSON === 'function') { + json = json.toJSON(); + } + + var newJson = {}; + for (var i in json) { + //noinspection JSUnfilteredForInLoop + newJson[i] = jsonDepth(json[i], depth - 1); + } + + return newJson; + } + + return json; +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/renderer-console.js b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/renderer-console.js new file mode 100644 index 00000000000..a50f09990fa --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/lib/transports/renderer-console.js @@ -0,0 +1,24 @@ +'use strict'; + +var BrowserWindow; +try { + BrowserWindow = require('electron').BrowserWindow; +} catch (e) { + BrowserWindow = null; +} + +var format = require('../format'); + +transport.level = BrowserWindow ? 'silly' : false; +transport.format = '[{h}:{i}:{s}.{ms}] {text}'; + +module.exports = transport; + +function transport(msg) { + if (!BrowserWindow) return; + + var text = format.format(msg, transport.format); + BrowserWindow.getAllWindows().forEach(function(wnd) { + wnd.webContents.send('__ELECTRON_LOG_RENDERER__', msg.level, text); + }); +} diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/main.js b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/main.js new file mode 100644 index 00000000000..bf4181d59d4 --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/main.js @@ -0,0 +1,50 @@ +'use strict'; + +var electron; +try { + electron = require('electron'); +} catch (e) { + electron = null; +} + +var log = require('./lib/log'); +var transportConsole = require('./lib/transports/console'); +var transportFile = require('./lib/transports/file'); +var transportLogS = require('./lib/transports/log-s'); +var transportRendererConsole = require('./lib/transports/renderer-console'); + +var transports = { + console: transportConsole, + file: transportFile, + logS: transportLogS, + rendererConsole: transportRendererConsole +}; + +module.exports = { + transports: transports, + + error: log.bind(null, transports, 'error'), + warn: log.bind(null, transports, 'warn'), + info: log.bind(null, transports, 'info'), + verbose: log.bind(null, transports, 'verbose'), + debug: log.bind(null, transports, 'debug'), + silly: log.bind(null, transports, 'silly'), + log: log.bind(null, transports, 'info') +}; + +module.exports.default = module.exports; + +if (electron && electron.ipcMain) { + electron.ipcMain.on('__ELECTRON_LOG__', onRendererLog); + var appName = electron.app.getName(); + if (appName !== 'Electron') { + transportFile.appName = appName; + } +} + +function onRendererLog(event, data) { + if (Array.isArray(data)) { + data.unshift(transports); + log.apply(null, data); + } +} diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/package.json b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/package.json new file mode 100644 index 00000000000..6d62dde372b --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/package.json @@ -0,0 +1,56 @@ +{ + "name": "electron-log", + "version": "2.2.9", + "description": "Just a very simple logging module for your Electron application", + "main": "./index.js", + "scripts": { + "test": "npm run jshint && npm run jscs && npm run tslint && npm run mocha && npm run test-projects", + "mocha": "mocha index.spec.js lib/{,**/}{,**/}*.spec.js", + "test-projects": "mocha test-projects/**/*.spec.js", + "test-projects-install": "node test-projects/install.js", + "jscs": "jscs .", + "jshint": "jshint --exclude ./node_modules,./test-projects . --verbose", + "tslint": "tslint electron-log.d.ts" + }, + "typings": "./electron-log.d.ts", + "repository": { + "type": "git", + "url": "git+https://github.com/megahertz/electron-log.git" + }, + "files": [ + "index.js", + "main.js", + "renderer.js", + "lib/**/*.js", + "!lib/**/*.spec.js", + "electron-log.d.ts" + ], + "keywords": [ + "electron", + "atom", + "log", + "logger", + "logging", + "windows", + "mac", + "osx", + "linux", + "desktop" + ], + "author": "Alexey Prokhorov", + "license": "MIT", + "bugs": { + "url": "https://github.com/megahertz/electron-log/issues" + }, + "homepage": "https://github.com/megahertz/electron-log#readme", + "devDependencies": { + "chai": "*", + "jscs": "*", + "jshint": "*", + "jshint-reporter-jscs": "*", + "mocha": "*", + "rewire": "*", + "tslint": "*", + "typescript": "*" + } +} diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/renderer.js b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/renderer.js new file mode 100644 index 00000000000..12f55f4378b --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/electron-log/renderer.js @@ -0,0 +1,48 @@ +'use strict'; + +module.exports = null; + +var ipcRenderer; +try { + ipcRenderer = require('electron').ipcRenderer; +} catch (e) { + ipcRenderer = null; +} + +if (ipcRenderer) { + module.exports = { + error: log.bind(null, 'error'), + warn: log.bind(null, 'warn'), + info: log.bind(null, 'info'), + verbose: log.bind(null, 'verbose'), + debug: log.bind(null, 'debug'), + silly: log.bind(null, 'silly'), + log: log.bind(null, 'info') + }; + + module.exports.default = module.exports; + + ipcRenderer.on('__ELECTRON_LOG_RENDERER__', function(event, level, text) { + if (level === 'verbose') { + level = 'log'; + } else if (level === 'silly') { + level = 'debug'; + } + + console[level](text); + }); +} + +function log() { + var data = Array.prototype.slice.call(arguments); + + data = data.map(function(obj) { + if (obj instanceof Error) { + obj = obj.stack || obj; + } + + return obj; + }); + + ipcRenderer.send('__ELECTRON_LOG__', data); +} diff --git a/test/fixtures/test-app-yarn-workspace/node_modules/test-app b/test/fixtures/test-app-yarn-workspace/node_modules/test-app new file mode 120000 index 00000000000..6d4c4c138ca --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/node_modules/test-app @@ -0,0 +1 @@ +../packages/test-app \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-workspace/package.json b/test/fixtures/test-app-yarn-workspace/package.json new file mode 100644 index 00000000000..8de1b8ebd98 --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "workspaces": [ + "packages/*" + ] +} \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-workspace/packages/test-app/index.html b/test/fixtures/test-app-yarn-workspace/packages/test-app/index.html new file mode 100644 index 00000000000..a25b3367d5e --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/packages/test-app/index.html @@ -0,0 +1,25 @@ + + + + + Hello World! + + + +

Hello World!

+ We are using node , + Chrome , + and Electron . + + Args: . + + Env: . + + + + diff --git a/test/fixtures/test-app-yarn-workspace/packages/test-app/index.js b/test/fixtures/test-app-yarn-workspace/packages/test-app/index.js new file mode 100644 index 00000000000..c3f858036c9 --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/packages/test-app/index.js @@ -0,0 +1,144 @@ +'use strict' + +const { app, ipcMain, BrowserWindow, Menu, Tray } = require("electron") +const fs = require("fs") +const path = require("path") + +// this should be placed at top of main.js to handle setup events quickly +if (handleSquirrelEvent()) { + // squirrel event handled and app will exit in 1000ms, so don't do anything else + return; +} + +function handleSquirrelEvent() { + if (process.argv.length === 1) { + return false; + } + + const ChildProcess = require('child_process'); + + const appFolder = path.resolve(process.execPath, '..'); + const rootAtomFolder = path.resolve(appFolder, '..'); + const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe')); + const exeName = path.basename(process.execPath); + + const spawn = function(command, args) { + let spawnedProcess, error; + + try { + spawnedProcess = ChildProcess.spawn(command, args, {detached: true}); + } catch (error) {} + + return spawnedProcess; + }; + + const spawnUpdate = function(args) { + return spawn(updateDotExe, args); + }; + + const squirrelEvent = process.argv[1]; + switch (squirrelEvent) { + case '--squirrel-install': + case '--squirrel-updated': + // Optionally do things such as: + // - Add your .exe to the PATH + // - Write to the registry for things like file associations and + // explorer context menus + + // Install desktop and start menu shortcuts + spawnUpdate(['--createShortcut', exeName]); + + setTimeout(app.quit, 1000); + return true; + + case '--squirrel-uninstall': + // Undo anything you did in the --squirrel-install and + // --squirrel-updated handlers + + // Remove desktop and start menu shortcuts + spawnUpdate(['--removeShortcut', exeName]); + + setTimeout(app.quit, 1000); + return true; + + case '--squirrel-obsolete': + // This is called on the outgoing version of your app before + // we update to the new version - it's the opposite of + // --squirrel-updated + + app.quit(); + return true; + } +} + +// Module to control application life. +// Module to create native browser window. + +// Keep a global reference of the window object, if you don't, the window will +// be closed automatically when the JavaScript object is garbage collected. +let mainWindow; + +let tray = null + +function createWindow () { + if (process.platform === "linux" && process.env.APPDIR != null) { + tray = new Tray(path.join(process.env.APPDIR, "testapp.png")) + const contextMenu = Menu.buildFromTemplate([ + {label: 'Item1', type: 'radio'}, + {label: 'Item2', type: 'radio'}, + {label: 'Item3', type: 'radio', checked: true}, + {label: 'Item4', type: 'radio'} + ]) + tray.setToolTip('This is my application.') + tray.setContextMenu(contextMenu) + } + + // Create the browser window. + mainWindow = new BrowserWindow({width: 800, height: 600}); + + // and load the index.html of the app. + mainWindow.loadURL('file://' + __dirname + '/index.html'); + + // Open the DevTools. + mainWindow.webContents.openDevTools(); + + mainWindow.webContents.executeJavaScript(`console.log("appData: ${app.getPath("appData").replace(/\\/g, "\\\\")}")`) + mainWindow.webContents.executeJavaScript(`console.log("userData: ${app.getPath("userData").replace(/\\/g, "\\\\")}")`) + + // Emitted when the window is closed. + mainWindow.on('closed', function() { + // Dereference the window object, usually you would store windows + // in an array if your app supports multi windows, this is the time + // when you should delete the corresponding element. + mainWindow = null; + }); +} + +// This method will be called when Electron has finished +// initialization and is ready to create browser windows. +app.on('ready', createWindow); + +// Quit when all windows are closed. +app.on('window-all-closed', function () { + // On MacOS it is common for applications and their menu bar + // to stay active until the user quits explicitly with Cmd + Q + if (process.platform !== 'darwin') { + app.quit(); + } +}); + +app.on("activate", function () { + if (mainWindow === null) { + createWindow() + } +}) + +ipcMain.on("saveAppData", () => { + try { + // electron doesn't escape / in the product name + fs.writeFileSync(path.join(app.getPath("appData"), "Test App ßW", "testFile"), "test") + } + catch (e) { + mainWindow.webContents.executeJavaScript(`console.log(\`userData: ${e}\`)`) + } +}) \ No newline at end of file diff --git a/test/fixtures/test-app-yarn-workspace/packages/test-app/package.json b/test/fixtures/test-app-yarn-workspace/packages/test-app/package.json new file mode 100644 index 00000000000..a996ad8294f --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/packages/test-app/package.json @@ -0,0 +1,24 @@ +{ + "name": "test-app", + "productName": "Test App ßW", + "version": "1.1.0", + "homepage": "http://foo.example.com", + "description": "Test Application (test quite \" #378)", + "author": "Foo Bar ", + "license": "MIT", + "build": { + "electronVersion": "1.7.8", + "appId": "org.electron-builder.testApp", + "compression": "store", + "npmRebuild": false, + "mac": { + "category": "your.app.category.type" + }, + "linux": { + "category": "Development" + } + }, + "dependencies": { + "electron-log": "2.2.9" + } +} diff --git a/test/fixtures/test-app-yarn-workspace/yarn.lock b/test/fixtures/test-app-yarn-workspace/yarn.lock new file mode 100644 index 00000000000..da02db2c2cf --- /dev/null +++ b/test/fixtures/test-app-yarn-workspace/yarn.lock @@ -0,0 +1,7 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +electron-log@2.2.9: + version "2.2.9" + resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-2.2.9.tgz#e0484cb1a8a84593095e3b69f47361ae15d73bdf" diff --git a/test/out/__snapshots__/HoistedNodeModuleTest.js.snap b/test/out/__snapshots__/HoistedNodeModuleTest.js.snap new file mode 100644 index 00000000000..febc782df9e --- /dev/null +++ b/test/out/__snapshots__/HoistedNodeModuleTest.js.snap @@ -0,0 +1,211 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`yarn several workspaces 1`] = ` +Object { + "linux": Array [], +} +`; + +exports[`yarn several workspaces 2`] = ` +Object { + "files": Object { + "index.html": Object { + "offset": "0", + "size": 841, + }, + "index.js": Object { + "offset": "841", + "size": 4371, + }, + "node_modules": Object { + "files": Object { + "electron-log": Object { + "files": Object { + "LICENSE": Object { + "offset": "5522", + "size": 1082, + }, + "index.js": Object { + "offset": "6604", + "size": 140, + }, + "lib": Object { + "files": Object { + "format.js": Object { + "offset": "9889", + "size": 1021, + }, + "log.js": Object { + "offset": "10910", + "size": 877, + }, + "transports": Object { + "files": Object { + "console.js": Object { + "offset": "11787", + "size": 343, + }, + "file": Object { + "files": Object { + "find-log-path.js": Object { + "offset": "14425", + "size": 2078, + }, + "get-app-name.js": Object { + "offset": "16503", + "size": 1780, + }, + "index.js": Object { + "offset": "18283", + "size": 2068, + }, + }, + }, + "log-s.js": Object { + "offset": "12130", + "size": 1751, + }, + "renderer-console.js": Object { + "offset": "13881", + "size": 544, + }, + }, + }, + }, + }, + "main.js": Object { + "offset": "6744", + "size": 1343, + }, + "package.json": Object { + "offset": "8087", + "size": 824, + }, + "renderer.js": Object { + "offset": "8911", + "size": 978, + }, + }, + }, + "ms": Object { + "files": Object { + "index.js": Object { + "offset": "20351", + "size": 2764, + }, + "license.md": Object { + "offset": "23115", + "size": 1077, + }, + "package.json": Object { + "offset": "24192", + "size": 469, + }, + }, + }, + }, + }, + "package.json": Object { + "offset": "5212", + "size": 310, + }, + }, +} +`; + +exports[`yarn workspace 1`] = ` +Object { + "linux": Array [], +} +`; + +exports[`yarn workspace 2`] = ` +Object { + "files": Object { + "index.html": Object { + "offset": "0", + "size": 841, + }, + "index.js": Object { + "offset": "841", + "size": 4371, + }, + "node_modules": Object { + "files": Object { + "electron-log": Object { + "files": Object { + "LICENSE": Object { + "offset": "5503", + "size": 1082, + }, + "index.js": Object { + "offset": "6585", + "size": 140, + }, + "lib": Object { + "files": Object { + "format.js": Object { + "offset": "10471", + "size": 1021, + }, + "log.js": Object { + "offset": "11492", + "size": 877, + }, + "transports": Object { + "files": Object { + "console.js": Object { + "offset": "12369", + "size": 343, + }, + "file": Object { + "files": Object { + "find-log-path.js": Object { + "offset": "15007", + "size": 2078, + }, + "get-app-name.js": Object { + "offset": "17085", + "size": 1780, + }, + "index.js": Object { + "offset": "18865", + "size": 2068, + }, + }, + }, + "log-s.js": Object { + "offset": "12712", + "size": 1751, + }, + "renderer-console.js": Object { + "offset": "14463", + "size": 544, + }, + }, + }, + }, + }, + "main.js": Object { + "offset": "6725", + "size": 1343, + }, + "package.json": Object { + "offset": "8068", + "size": 1425, + }, + "renderer.js": Object { + "offset": "9493", + "size": 978, + }, + }, + }, + }, + }, + "package.json": Object { + "offset": "5212", + "size": 291, + }, + }, +} +`; diff --git a/test/src/BuildTest.ts b/test/src/BuildTest.ts index 45e4cccd187..cb019e955a5 100644 --- a/test/src/BuildTest.ts +++ b/test/src/BuildTest.ts @@ -5,11 +5,9 @@ import { Arch, createTargets, DIR_TARGET, Platform } from "electron-builder" import { readAsar } from "electron-builder/out/asar/asar" import { move, outputJson, readJson } from "fs-extra-p" import * as path from "path" -import { app, appTwo, appTwoThrows, assertPack, modifyPackageJson, packageJson } from "./helpers/packTester" +import { app, appTwo, appTwoThrows, assertPack, linuxDirTarget, modifyPackageJson, packageJson } from "./helpers/packTester" import { ELECTRON_VERSION } from "./helpers/testConfig" -const linuxDirTarget = Platform.LINUX.createTarget(DIR_TARGET) - test("cli", async () => { // because these methods are internal const { configureBuildCommand, normalizeOptions } = require("electron-builder/out/builder") diff --git a/test/src/ExtraBuildTest.ts b/test/src/ExtraBuildTest.ts index 23d7ec2e062..2e10917c86d 100644 --- a/test/src/ExtraBuildTest.ts +++ b/test/src/ExtraBuildTest.ts @@ -3,7 +3,7 @@ import { move, readFile } from "fs-extra-p" import { safeLoad } from "js-yaml" import * as path from "path" import { assertThat } from "./helpers/fileAssert" -import { app, assertPack, modifyPackageJson } from "./helpers/packTester" +import { app, assertPack, linuxDirTarget, modifyPackageJson } from "./helpers/packTester" import { expectUpdateMetadata } from "./helpers/winHelper" function createBuildResourcesTest(platform: Platform) { @@ -26,8 +26,6 @@ function createBuildResourcesTest(platform: Platform) { }) } -const linuxDirTarget = Platform.LINUX.createTarget(DIR_TARGET) - test.ifAll.ifNotWindows("custom buildResources and output dirs: mac", createBuildResourcesTest(Platform.MAC)) test.ifAll.ifNotCiMac("custom buildResources and output dirs: win", createBuildResourcesTest(Platform.WINDOWS)) test.ifAll.ifNotWindows("custom buildResources and output dirs: linux", createBuildResourcesTest(Platform.LINUX)) diff --git a/test/src/HoistedNodeModuleTest.ts b/test/src/HoistedNodeModuleTest.ts new file mode 100644 index 00000000000..750b2432414 --- /dev/null +++ b/test/src/HoistedNodeModuleTest.ts @@ -0,0 +1,23 @@ +import { readAsar } from "electron-builder/out/asar/asar" +import { assertPack, linuxDirTarget } from "./helpers/packTester" +import { Platform } from "electron-builder" +import * as path from "path" + +test.ifAll("yarn workspace", () => assertPack("test-app-yarn-workspace", { + targets: linuxDirTarget, + projectDir: "packages/test-app" +}, { + packed: context => verifyAsarFileTree(context.getResources(Platform.LINUX)), +})) + +test("yarn several workspaces", () => assertPack("test-app-yarn-several-workspace", { + targets: linuxDirTarget, + projectDir: "packages/test-app" +}, { + packed: context => verifyAsarFileTree(context.getResources(Platform.LINUX)), +})) + +async function verifyAsarFileTree(resourceDir: string) { + const fs = await readAsar(path.join(resourceDir, "app.asar")) + expect(fs.header).toMatchSnapshot() +} \ No newline at end of file diff --git a/test/src/configurationValidationTest.ts b/test/src/configurationValidationTest.ts index 465bda3b3de..3711ccfb5ac 100644 --- a/test/src/configurationValidationTest.ts +++ b/test/src/configurationValidationTest.ts @@ -1,7 +1,5 @@ -import { DIR_TARGET, Platform } from "electron-builder" -import { app, appThrows } from "./helpers/packTester" - -const linuxDirTarget = Platform.LINUX.createTarget(DIR_TARGET) +import { Platform } from "electron-builder" +import { app, appThrows, linuxDirTarget } from "./helpers/packTester" test.ifAll.ifDevOrLinuxCi("validation", appThrows({ targets: linuxDirTarget, diff --git a/test/src/filesTest.ts b/test/src/filesTest.ts index f9c20104f2f..07c43bc6d8b 100644 --- a/test/src/filesTest.ts +++ b/test/src/filesTest.ts @@ -6,9 +6,7 @@ import { outputFile, readFile, move, stat, symlink } from "fs-extra-p" import * as path from "path" import Mode, { Permissions } from "stat-mode" import { assertThat } from "./helpers/fileAssert" -import { app, appThrows, assertPack, checkDirContents, modifyPackageJson } from "./helpers/packTester" - -const linuxDirTarget = Platform.LINUX.createTarget(DIR_TARGET) +import { app, appThrows, assertPack, checkDirContents, linuxDirTarget, modifyPackageJson } from "./helpers/packTester" test.ifDevOrLinuxCi("expand not defined env", appThrows({ targets: linuxDirTarget, diff --git a/test/src/helpers/packTester.ts b/test/src/helpers/packTester.ts index 11e6a1eeb7c..e4545902137 100644 --- a/test/src/helpers/packTester.ts +++ b/test/src/helpers/packTester.ts @@ -6,7 +6,7 @@ import { getLinuxToolsPath } from "builder-util/out/bundledTool" import { copyDir, FileCopier, walk } from "builder-util/out/fs" import { executeFinally } from "builder-util/out/promise" import DecompressZip from "decompress-zip" -import { Arch, ArtifactCreated, DIR_TARGET, getArchSuffix, MacOsTargetName, Packager, PackagerOptions, Platform, Target, Configuration } from "electron-builder" +import { Arch, ArtifactCreated, Configuration, DIR_TARGET, getArchSuffix, MacOsTargetName, Packager, PackagerOptions, Platform, Target } from "electron-builder" import { convertVersion } from "electron-builder-squirrel-windows/out/squirrelPack" import { PublishManager } from "electron-builder/out/publish/PublishManager" import { computeArchToTargetNamesMap } from "electron-builder/out/targets/targetFactory" @@ -27,6 +27,8 @@ if (process.env.TRAVIS !== "true") { const OUT_DIR_NAME = "dist" +export const linuxDirTarget = Platform.LINUX.createTarget(DIR_TARGET) + interface AssertPackOptions { readonly projectDirCreated?: (projectDir: string, tmpDir: TmpDir) => Promise readonly packed?: (context: PackedContext) => Promise @@ -98,7 +100,8 @@ export async function assertPack(fixtureName: string, packagerOptions: PackagerO await copyDir(projectDir, dir, { filter: it => { const basename = path.basename(it) - return basename !== OUT_DIR_NAME && basename !== "node_modules" && !basename.startsWith(".") + // if custom project dir specified, copy node_modules (i.e. do not ignore it) + return basename !== OUT_DIR_NAME && (packagerOptions.projectDir != null || basename !== "node_modules") && !basename.startsWith(".") }, isUseHardLink: it => path.basename(it) !== "package.json", }) @@ -115,7 +118,14 @@ export async function assertPack(fixtureName: string, packagerOptions: PackagerO } } - const {packager, outDir} = await packAndCheck({projectDir, ...packagerOptions}, checkOptions) + if (packagerOptions.projectDir != null) { + packagerOptions.projectDir = path.resolve(projectDir, packagerOptions.projectDir) + } + + const {packager, outDir} = await packAndCheck({ + projectDir, + ...packagerOptions + }, checkOptions) if (checkOptions.packed != null) { function base(platform: Platform, arch?: Arch): string { diff --git a/test/src/helpers/runTests.ts b/test/src/helpers/runTests.ts index 56362771f95..dfebbf6adf9 100644 --- a/test/src/helpers/runTests.ts +++ b/test/src/helpers/runTests.ts @@ -50,6 +50,7 @@ async function runTests() { args.push("nsisUpdaterTest") args.push("macArchiveTest") args.push("macCodeSignTest") + args.push("HoistedNodeModuleTest") } else if (circleNodeIndex === 1) { args.push("oneClickInstallerTest") diff --git a/yarn.lock b/yarn.lock index 1f03c4cc00e..2600645bb0d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -101,9 +101,9 @@ version "1.3.29" resolved "https://registry.yarnpkg.com/@types/ini/-/ini-1.3.29.tgz#1325e981e047d40d13ce0359b821475b97741d2f" -"@types/jest@^21.1.3": - version "21.1.3" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-21.1.3.tgz#158d13cc3fa6b2f34d78118677af77754fe5b3fe" +"@types/jest@^21.1.4": + version "21.1.4" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-21.1.4.tgz#83c5c474dd6dee5bef9d014ff36787edfd4ab5a7" "@types/js-yaml@^3.9.1": version "3.9.1" @@ -124,8 +124,8 @@ resolved "https://registry.yarnpkg.com/@types/node-emoji/-/node-emoji-1.4.0.tgz#34068c35b74ee5c9d73eb9b84c60b2c06a169412" "@types/node@*": - version "8.0.41" - resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.41.tgz#b88d23b454fdbcfd170f61de88a33ec9cd98960a" + version "8.0.44" + resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.44.tgz#5c39800fda4b76dab39a5f28fda676fc500015ac" "@types/sanitize-filename@^1.1.28": version "1.1.28" @@ -443,9 +443,9 @@ asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" -aws-sdk@^2.134.0: - version "2.134.0" - resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.134.0.tgz#acc0c989900cae632a0a4cfc3609b0a406169da9" +aws-sdk@^2.135.0: + version "2.135.0" + resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.135.0.tgz#81f4a47b99212f2f236bf5b11b0b3a3a02086db4" dependencies: buffer "4.9.1" crypto-browserify "1.0.9" @@ -515,15 +515,6 @@ babel-generator@^6.18.0, babel-generator@^6.26.0: source-map "^0.5.6" trim-right "^1.0.1" -babel-helper-call-delegate@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz#ece6aacddc76e41c3461f88bfc575bd0daa2df8d" - dependencies: - babel-helper-hoist-variables "^6.24.1" - babel-runtime "^6.22.0" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - babel-helper-function-name@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" @@ -541,13 +532,6 @@ babel-helper-get-function-arity@^6.24.1: babel-runtime "^6.22.0" babel-types "^6.24.1" -babel-helper-hoist-variables@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz#1ecb27689c9d25513eadbc9914a73f5408be7a76" - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - babel-helper-remap-async-to-generator@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz#5ec581827ad723fecdd381f1c928390676e4551b" @@ -578,10 +562,6 @@ babel-messages@^6.23.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-array-includes@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/babel-plugin-array-includes/-/babel-plugin-array-includes-2.0.3.tgz#cf5452e81c7b803fb7959f1045ac88e2ec28ff76" - babel-plugin-istanbul@^4.0.0: version "4.1.5" resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.5.tgz#6760cdd977f411d3e175bb064f2bc327d99b2b6e" @@ -611,29 +591,6 @@ babel-plugin-transform-async-to-module-method@^6.24.1: babel-runtime "^6.22.0" babel-types "^6.24.1" -babel-plugin-transform-es2015-destructuring@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz#997bb1f1ab967f682d2b0876fe358d60e765c56d" - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-parameters@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz#57ac351ab49caf14a97cd13b09f66fdf0a625f2b" - dependencies: - babel-helper-call-delegate "^6.24.1" - babel-helper-get-function-arity "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-spread@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz#d6d68a99f89aedc4536c81a542e8dd9f1746f8d1" - dependencies: - babel-runtime "^6.22.0" - babel-plugin-transform-inline-imports-commonjs@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-inline-imports-commonjs/-/babel-plugin-transform-inline-imports-commonjs-1.2.0.tgz#20c7d192bafc54c8727386e3387d8ee4ef19e6a5" @@ -655,15 +612,11 @@ babel-preset-jest@^21.2.0: babel-plugin-jest-hoist "^21.2.0" babel-plugin-syntax-object-rest-spread "^6.13.0" -babel-preset-ts-node4-bluebird@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/babel-preset-ts-node4-bluebird/-/babel-preset-ts-node4-bluebird-0.1.1.tgz#72a3bb93b4ff026308844ca8d1d1ba587e30e7fd" +babel-preset-ts-node6-bluebird@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/babel-preset-ts-node6-bluebird/-/babel-preset-ts-node6-bluebird-1.0.1.tgz#5d3967d9fe9a6534990f0ec7a45af42ffa6216c5" dependencies: - babel-plugin-array-includes "^2.0.3" babel-plugin-transform-async-to-module-method "^6.24.1" - babel-plugin-transform-es2015-destructuring "^6.23.0" - babel-plugin-transform-es2015-parameters "^6.24.1" - babel-plugin-transform-es2015-spread "^6.22.0" babel-plugin-transform-inline-imports-commonjs "^1.2.0" babel-register@^6.26.0: @@ -775,9 +728,9 @@ block-stream@*: dependencies: inherits "~2.0.0" -bluebird-lst@^1.0.3, bluebird-lst@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/bluebird-lst/-/bluebird-lst-1.0.4.tgz#7fa1e4daaaf9e4e52f6dd0ec5b32e7ed4ca8cd6d" +bluebird-lst@^1.0.3, bluebird-lst@^1.0.4, bluebird-lst@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/bluebird-lst/-/bluebird-lst-1.0.5.tgz#bebc83026b7e92a72871a3dc599e219cbfb002a9" dependencies: bluebird "^3.5.1" @@ -827,8 +780,8 @@ boom@5.x.x: hoek "4.x.x" boxen@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.2.1.tgz#0f11e7fe344edb9397977fc13ede7f64d956481d" + version "1.2.2" + resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.2.2.tgz#3f1d4032c30ffea9d4b02c322eaf2ea741dcbce5" dependencies: ansi-align "^2.0.0" camelcase "^4.0.0" @@ -951,6 +904,14 @@ chainsaw@~0.1.0: dependencies: traverse ">=0.3.0 <0.4" +chalk@2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e" + dependencies: + ansi-styles "^3.1.0" + escape-string-regexp "^1.0.5" + supports-color "^4.0.0" + chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" @@ -962,8 +923,8 @@ chalk@^1.1.3: supports-color "^2.0.0" chalk@^2.0.1, chalk@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e" + version "2.2.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.2.0.tgz#477b3bf2f9b8fd5ca9e429747e37f724ee7af240" dependencies: ansi-styles "^3.1.0" escape-string-regexp "^1.0.5" @@ -1634,7 +1595,7 @@ error@7.0.2: string-template "~0.2.1" xtend "~4.0.0" -es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.11, es5-ext@~0.10.14, es5-ext@~0.10.2, es5-ext@~0.10.5, es5-ext@~0.10.6: +es5-ext@^0.10.35, es5-ext@^0.10.9, es5-ext@~0.10.11, es5-ext@~0.10.14, es5-ext@~0.10.2, es5-ext@~0.10.5, es5-ext@~0.10.6: version "0.10.35" resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.35.tgz#18ee858ce6a3c45c7d79e91c15fcca9ec568494f" dependencies: @@ -1650,14 +1611,14 @@ es6-iterator@~0.1.3: es6-symbol "~2.0.1" es6-iterator@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.1.tgz#8e319c9f0453bf575d374940a655920e59ca5512" + version "2.0.3" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" dependencies: d "1" - es5-ext "^0.10.14" - es6-symbol "^3.1" + es5-ext "^0.10.35" + es6-symbol "^3.1.1" -es6-symbol@^3.1, es6-symbol@~3.1.1: +es6-symbol@^3.1.1, es6-symbol@~3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" dependencies: @@ -1937,7 +1898,7 @@ front-matter@^2.1.0: dependencies: js-yaml "^3.4.6" -fs-extra-p@^4.4.0, fs-extra-p@^4.4.3, fs-extra-p@^4.4.4: +fs-extra-p@^4.4.0, fs-extra-p@^4.4.4: version "4.4.4" resolved "https://registry.yarnpkg.com/fs-extra-p/-/fs-extra-p-4.4.4.tgz#396ad6f914eb2954e1700fd0e18288301ed45f04" dependencies: @@ -2192,8 +2153,8 @@ handlebars@3.0.3: uglify-js "~2.3" handlebars@^4.0.3: - version "4.0.10" - resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.10.tgz#3d30c718b09a3d96f23ea4cc1f403c4d3ba9ff4f" + version "4.0.11" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc" dependencies: async "^1.4.0" optimist "^0.6.1" @@ -4827,13 +4788,13 @@ truncate-utf8-bytes@^1.0.0: dependencies: utf8-byte-length "^1.0.1" -ts-babel@^4.1.6: - version "4.1.6" - resolved "https://registry.yarnpkg.com/ts-babel/-/ts-babel-4.1.6.tgz#e00d497d4ff7c950c7bc8ace58489cabdb7d6967" +ts-babel@^4.1.7: + version "4.1.7" + resolved "https://registry.yarnpkg.com/ts-babel/-/ts-babel-4.1.7.tgz#b95fe9bbafa43ea18c494777a3011270ebd9f8a3" dependencies: babel-core "^6.26.0" bluebird-lst "^1.0.4" - fs-extra-p "^4.4.3" + fs-extra-p "^4.4.4" source-map-support "^0.5.0" v8-compile-cache "^1.1.0"