diff --git a/lib/packageModules.js b/lib/packageModules.js index 4d6eac5f2..040cd955b 100644 --- a/lib/packageModules.js +++ b/lib/packageModules.js @@ -3,10 +3,10 @@ const BbPromise = require('bluebird'); const _ = require('lodash'); const path = require('path'); -const archiver = require('archiver'); -const fs = require('fs'); +const bestzip = require('bestzip'); const glob = require('glob'); const semver = require('semver'); +const fs = require('fs'); function setArtifactPath(funcName, func, artifactPath) { const version = this.serverless.getVersion(); @@ -26,14 +26,7 @@ function setArtifactPath(funcName, func, artifactPath) { } function zip(directory, name) { - const zip = archiver.create('zip'); - // Create artifact in temp path and move it to the package path (if any) later - // This allows us to persist the webpackOutputPath and re-use the compiled output - const artifactFilePath = path.join(this.webpackOutputPath, name); - this.serverless.utils.writeFileDir(artifactFilePath); - - const output = fs.createWriteStream(artifactFilePath); - + // Check that files exist to be zipped let files = glob.sync('**', { cwd: directory, dot: true, @@ -50,29 +43,28 @@ function zip(directory, name) { return BbPromise.reject(error); } - output.on('open', () => { - zip.pipe(output); - - _.forEach(files, filePath => { - const fullPath = path.resolve(directory, filePath); - - const stats = fs.statSync(fullPath); - - if (!stats.isDirectory(fullPath)) { - zip.append(fs.readFileSync(fullPath), { - name: filePath, - mode: stats.mode, - date: new Date(0) // necessary to get the same hash when zipping the same content - }); - } - }); - - zip.finalize(); - }); + // Create artifact in temp path and move it to the package path (if any) later + // This allows us to persist the webpackOutputPath and re-use the compiled output + const artifactFilePath = path.join(this.webpackOutputPath, name); + this.serverless.utils.writeFileDir(artifactFilePath); + const cwd = directory; + const source = '*'; + const destination = path.relative(cwd, artifactFilePath); + const zipArgs = { + source, + cwd, + destination + }; return new BbPromise((resolve, reject) => { - output.on('close', () => resolve(artifactFilePath)); - zip.on('error', err => reject(err)); + bestzip(zipArgs) + .then(() => { + resolve(artifactFilePath); + return null; + }) + .catch(err => { + reject(err); + }); }); } diff --git a/lib/packagers/yarn.test.js b/lib/packagers/yarn.test.js index 8ec580988..676aa3d3e 100644 --- a/lib/packagers/yarn.test.js +++ b/lib/packagers/yarn.test.js @@ -63,14 +63,14 @@ describe('yarn', () => { it('should transform yarn trees to npm dependencies', () => { const testYarnResult = '{"type":"activityStart","data":{"id":0}}\n' + - '{"type":"activityTick","data":{"id":0,"name":"archiver@^2.1.1"}}\n' + + '{"type":"activityTick","data":{"id":0,"name":"bestzip@^2.1.5"}}\n' + '{"type":"activityTick","data":{"id":0,"name":"bluebird@^3.5.1"}}\n' + '{"type":"activityTick","data":{"id":0,"name":"fs-extra@^4.0.3"}}\n' + '{"type":"activityTick","data":{"id":0,"name":"mkdirp@^0.5.1"}}\n' + '{"type":"activityTick","data":{"id":0,"name":"minimist@^0.0.8"}}\n' + '{"type":"activityTick","data":{"id":0,"name":"@sls/webpack@^1.0.0"}}\n' + '{"type":"tree","data":{"type":"list","trees":[' + - '{"name":"archiver@2.1.1","children":[],"hint":null,"color":"bold",' + + '{"name":"bestzip@2.1.5","children":[],"hint":null,"color":"bold",' + '"depth":0},{"name":"bluebird@3.5.1","children":[],"hint":null,"color":' + '"bold","depth":0},{"name":"fs-extra@4.0.3","children":[],"hint":null,' + '"color":"bold","depth":0},{"name":"mkdirp@0.5.1","children":[{"name":' + @@ -80,8 +80,8 @@ describe('yarn', () => { const expectedResult = { problems: [], dependencies: { - archiver: { - version: '2.1.1', + bestzip: { + version: '2.1.5', dependencies: {} }, bluebird: { diff --git a/package-lock.json b/package-lock.json index 6bfb8e28a..e9ffc4224 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1377,7 +1377,6 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, "requires": { "color-convert": "^1.9.0" } @@ -1419,17 +1418,17 @@ } }, "archiver": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/archiver/-/archiver-5.0.2.tgz", - "integrity": "sha512-Tq3yV/T4wxBsD2Wign8W9VQKhaUxzzRmjEiSoOK0SLqPgDP/N1TKdYyBeIEu56T4I9iO4fKTTR0mN9NWkBA0sg==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/archiver/-/archiver-4.0.2.tgz", + "integrity": "sha512-B9IZjlGwaxF33UN4oPbfBkyA4V1SxNLeIhR1qY8sRXSsbdUkEHrrOvwlYFPx+8uQeCe9M+FG6KgO+imDmQ79CQ==", "requires": { "archiver-utils": "^2.1.0", "async": "^3.2.0", "buffer-crc32": "^0.2.1", + "glob": "^7.1.6", "readable-stream": "^3.6.0", - "readdir-glob": "^1.0.0", - "tar-stream": "^2.1.4", - "zip-stream": "^4.0.0" + "tar-stream": "^2.1.2", + "zip-stream": "^3.0.1" } }, "archiver-utils": { @@ -1961,6 +1960,118 @@ "tweetnacl": "^0.14.3" } }, + "bestzip": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/bestzip/-/bestzip-2.1.7.tgz", + "integrity": "sha512-Eg5ZP0Viw1beJydZLbW246oCUnvtKGi7DhcB6IlKxP03NaxKCGVhKJD/jY4MLFRINhepfVEhAhnlc/uIxc9dHA==", + "requires": { + "archiver": "^4.0.2", + "async": "^3.2.0", + "glob": "^7.1.3", + "which": "^1.3.1", + "yargs": "^13.2.4" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" + }, + "cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "requires": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + } + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "requires": { + "locate-path": "^3.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + } + }, + "yargs": { + "version": "13.3.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", + "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", + "requires": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.2" + } + } + } + }, "better-assert": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", @@ -2225,8 +2336,7 @@ "camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "dev": true + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" }, "camelcase-keys": { "version": "6.0.0", @@ -2586,7 +2696,6 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, "requires": { "color-name": "1.1.3" } @@ -2594,8 +2703,7 @@ "color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, "color-string": { "version": "1.5.3", @@ -2681,14 +2789,30 @@ "dev": true }, "compress-commons": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/compress-commons/-/compress-commons-4.0.1.tgz", - "integrity": "sha512-xZm9o6iikekkI0GnXCmAl3LQGZj5TBDj0zLowsqi7tJtEa3FMGSEcHcqrSJIrOAk1UG/NBbDn/F1q+MG/p/EsA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/compress-commons/-/compress-commons-3.0.0.tgz", + "integrity": "sha512-FyDqr8TKX5/X0qo+aVfaZ+PVmNJHJeckFBlq8jZGSJOgnynhfifoyl24qaqdUdDIBe0EVTHByN6NAkqYvE/2Xg==", "requires": { "buffer-crc32": "^0.2.13", - "crc32-stream": "^4.0.0", + "crc32-stream": "^3.0.1", "normalize-path": "^3.0.0", - "readable-stream": "^3.6.0" + "readable-stream": "^2.3.7" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + } } }, "concat-map": { @@ -2808,9 +2932,9 @@ } }, "crc32-stream": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-4.0.0.tgz", - "integrity": "sha512-tyMw2IeUX6t9jhgXI6um0eKfWq4EIDpfv5m7GX4Jzp7eVelQ360xd8EPXJhp2mHwLQIkqlnMLjzqSZI3a+0wRw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-3.0.1.tgz", + "integrity": "sha512-mctvpXlbzsvK+6z8kJwSJ5crm7yBwrQMTybJzMw1O4lLGJqjlDCXY2Zw7KheiA6XBEcBmfLx1D88mjRGVJtY9w==", "requires": { "crc": "^3.4.4", "readable-stream": "^3.4.0" @@ -2882,8 +3006,7 @@ "decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" }, "decode-uri-component": { "version": "0.2.0", @@ -3421,8 +3544,7 @@ "emoji-regex": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", - "dev": true + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==" }, "enabled": { "version": "1.0.2", @@ -5020,8 +5142,7 @@ "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" }, "get-func-name": { "version": "2.0.0", @@ -6100,8 +6221,7 @@ "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" }, "is-glob": { "version": "4.0.1", @@ -6256,8 +6376,7 @@ "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, "iso8601-duration": { "version": "1.2.0", @@ -8513,8 +8632,7 @@ "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" }, "path-is-absolute": { "version": "1.0.1", @@ -9455,14 +9573,6 @@ "util-deprecate": "^1.0.1" } }, - "readdir-glob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/readdir-glob/-/readdir-glob-1.0.0.tgz", - "integrity": "sha512-km0DIcwQVZ1ZUhXhMWpF74/Wm5aFEd5/jDiVWF1Hkw2myPQovG8vCQ8+FQO2KXE9npQQvCnAMZhhWuUee4WcCQ==", - "requires": { - "minimatch": "^3.0.4" - } - }, "readdirp": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.4.0.tgz", @@ -9598,14 +9708,12 @@ "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "dev": true + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" }, "require-main-filename": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", - "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", - "dev": true + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==" }, "require-relative": { "version": "0.8.7", @@ -10078,8 +10186,7 @@ "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "dev": true + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" }, "set-immediate-shim": { "version": "1.0.1", @@ -11524,7 +11631,6 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "dev": true, "requires": { "isexe": "^2.0.0" } @@ -11532,8 +11638,7 @@ "which-module": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", - "dev": true + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" }, "which-pm-runs": { "version": "1.0.0", @@ -11764,8 +11869,7 @@ "y18n": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", - "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", - "dev": true + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==" }, "yallist": { "version": "2.1.2", @@ -11917,7 +12021,6 @@ "version": "13.1.2", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", - "dev": true, "requires": { "camelcase": "^5.0.0", "decamelize": "^1.2.0" @@ -12081,12 +12184,12 @@ "optional": true }, "zip-stream": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-4.0.2.tgz", - "integrity": "sha512-TGxB2g+1ur6MHkvM644DuZr8Uzyz0k0OYWtS3YlpfWBEmK4woaC2t3+pozEL3dBfIPmpgmClR5B2QRcMgGt22g==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-3.0.1.tgz", + "integrity": "sha512-r+JdDipt93ttDjsOVPU5zaq5bAyY+3H19bDrThkvuVxC0xMQzU1PJcS6D+KrP3u96gH9XLomcHPb+2skoDjulQ==", "requires": { "archiver-utils": "^2.1.0", - "compress-commons": "^4.0.0", + "compress-commons": "^3.0.0", "readable-stream": "^3.6.0" } } diff --git a/package.json b/package.json index e5d33f7ed..df91642f6 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "report-dir": "./coverage" }, "dependencies": { - "archiver": "^5.0.2", + "bestzip": "^2.1.7", "bluebird": "^3.7.2", "fs-extra": "^9.0.1", "glob": "^7.1.6", diff --git a/tests/mocks/archiver.mock.js b/tests/mocks/archiver.mock.js deleted file mode 100644 index 1726b01e9..000000000 --- a/tests/mocks/archiver.mock.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -/** - * Mock object for glob - */ - -const sinon = require('sinon'); - -const ZipMock = sandbox => ({ - pipe: sandbox.stub(), - append: sandbox.stub(), - finalize: sandbox.stub(), - on: sandbox.stub() -}); - -module.exports.create = sandbox => { - const zipMock = ZipMock(sandbox); - const mock = { - create: sinon.stub().returns(zipMock), - _zipMock: zipMock - }; - return mock; -}; diff --git a/tests/mocks/bestzip.mock.js b/tests/mocks/bestzip.mock.js new file mode 100644 index 000000000..99b9886df --- /dev/null +++ b/tests/mocks/bestzip.mock.js @@ -0,0 +1,15 @@ +'use strict'; + +/** + * Mock object for bestzip + */ + +const sinon = require('sinon'); + +const BestZipMock = sandbox => sandbox.stub(); + +module.exports.create = sandbox => { + const bestzipMock = BestZipMock(sandbox); + const mock = sinon.stub().resolves(bestzipMock); + return mock; +}; diff --git a/tests/mocks/package.mock.json b/tests/mocks/package.mock.json index 11835da82..27a50f9db 100644 --- a/tests/mocks/package.mock.json +++ b/tests/mocks/package.mock.json @@ -1,6 +1,6 @@ { "dependencies": { - "archiver": "^2.0.0", + "bestzip": "^2.1.5", "bluebird": "^3.4.0", "fs-extra": "^0.26.7", "glob": "^7.1.2", diff --git a/tests/mocks/packageIgnoredDevDeps.mock.json b/tests/mocks/packageIgnoredDevDeps.mock.json index fa6ef536a..304b3c3f1 100644 --- a/tests/mocks/packageIgnoredDevDeps.mock.json +++ b/tests/mocks/packageIgnoredDevDeps.mock.json @@ -1,6 +1,6 @@ { "dependencies": { - "archiver": "^2.0.0", + "bestzip": "^2.1.5", "bluebird": "^3.4.0", "fs-extra": "^0.26.7", "glob": "^7.1.2", diff --git a/tests/mocks/packageLocalRef.mock.json b/tests/mocks/packageLocalRef.mock.json index ea120d91f..cbc30f301 100644 --- a/tests/mocks/packageLocalRef.mock.json +++ b/tests/mocks/packageLocalRef.mock.json @@ -1,6 +1,6 @@ { "dependencies": { - "archiver": "^2.0.0", + "bestzip": "^2.1.5", "bluebird": "^3.4.0", "fs-extra": "^0.26.7", "glob": "^7.1.2", diff --git a/tests/packageModules.test.js b/tests/packageModules.test.js index 675b51cb6..d62353453 100644 --- a/tests/packageModules.test.js +++ b/tests/packageModules.test.js @@ -12,7 +12,7 @@ const Configuration = require('../lib/Configuration'); // Mocks const fsMockFactory = require('./mocks/fs.mock'); const globMockFactory = require('./mocks/glob.mock'); -const archiverMockFactory = require('./mocks/archiver.mock'); +const bestzipMockFactory = require('./mocks/bestzip.mock'); chai.use(require('chai-as-promised')); chai.use(require('sinon-chai')); @@ -28,7 +28,7 @@ describe('packageModules', () => { // Mocks let fsMock; let globMock; - let archiverMock; + let bestzipMock; // Serverless stubs let writeFileDirStub; let getAllFunctionsStub; @@ -41,11 +41,11 @@ describe('packageModules', () => { sandbox.usingPromise(BbPromise); fsMock = fsMockFactory.create(sandbox); - archiverMock = archiverMockFactory.create(sandbox); + bestzipMock = bestzipMockFactory.create(sandbox); globMock = globMockFactory.create(sandbox); mockery.enable({ warnOnUnregistered: false }); - mockery.registerMock('archiver', archiverMock); + mockery.registerMock('bestzip', bestzipMock); mockery.registerMock('fs', fsMock); mockery.registerMock('glob', globMock); baseModule = require('../lib/packageModules'); @@ -92,7 +92,7 @@ describe('packageModules', () => { module.compileStats = { stats: [] }; return expect(module.packageModules()).to.be.fulfilled.then(() => BbPromise.all([ - expect(archiverMock.create).to.not.have.been.called, + expect(bestzipMock).to.not.have.been.called, expect(writeFileDirStub).to.not.have.been.called, expect(fsMock.createWriteStream).to.not.have.been.called, expect(globMock.sync).to.not.have.been.called @@ -104,7 +104,7 @@ describe('packageModules', () => { module.skipCompile = true; return expect(module.packageModules()).to.be.fulfilled.then(() => BbPromise.all([ - expect(archiverMock.create).to.not.have.been.called, + expect(bestzipMock).to.not.have.been.called, expect(writeFileDirStub).to.not.have.been.called, expect(fsMock.createWriteStream).to.not.have.been.called, expect(globMock.sync).to.not.have.been.called