From 59884369b6662e710459a5d7ca74376345d5aa2e Mon Sep 17 00:00:00 2001 From: Liron Kopinsky Date: Thu, 25 Jun 2020 09:33:05 +0300 Subject: [PATCH 01/15] Add some logging for testing zip performance. --- lib/packageModules.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/packageModules.js b/lib/packageModules.js index 4d6eac5f2..919ff12f1 100644 --- a/lib/packageModules.js +++ b/lib/packageModules.js @@ -51,9 +51,16 @@ function zip(directory, name) { } output.on('open', () => { + + this.options.verbose && + this.serverless.cli.log( + `${new Date().toUTCString()} Zip ${directory} open - ${files.length} files` + ) zip.pipe(output); + const fileDurations = {} _.forEach(files, filePath => { + const startFile = _.now() const fullPath = path.resolve(directory, filePath); const stats = fs.statSync(fullPath); @@ -65,9 +72,18 @@ function zip(directory, name) { date: new Date(0) // necessary to get the same hash when zipping the same content }); } + const duration = _.now() - startFile + fileDurations[fullPath] = duration }); zip.finalize(); + + if (this.options.verbose) { + this.serverless.cli.log( + `${new Date().toUTCString()} Zip ${directory} finalized` + ) + this.serverless.cli.log(fileDurations) + } }); return new BbPromise((resolve, reject) => { @@ -119,6 +135,10 @@ module.exports = { const filename = getArtifactName.call(this, entryFunction); const modulePath = compileStats.compilation.compiler.outputPath; + this.options.verbose && + this.serverless.cli.log( + `${new Date().toUTCString()} Zip ${_.isEmpty(entryFunction) ? 'service' : 'function'}: ${modulePath} start` + ) const startZip = _.now(); return zip .call(this, modulePath, filename) @@ -126,7 +146,7 @@ module.exports = { () => this.options.verbose && this.serverless.cli.log( - `Zip ${_.isEmpty(entryFunction) ? 'service' : 'function'}: ${modulePath} [${_.now() - startZip} ms]` + `${new Date().toUTCString()} Zip ${_.isEmpty(entryFunction) ? 'service' : 'function'}: ${modulePath} [${_.now() - startZip} ms]` ) ); }); From 82015468997277edda42bd6fe66f5857a3a971fa Mon Sep 17 00:00:00 2001 From: Liron Kopinsky Date: Thu, 25 Jun 2020 10:22:25 +0300 Subject: [PATCH 02/15] Better formatting on file durations logging. --- lib/packageModules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/packageModules.js b/lib/packageModules.js index 919ff12f1..7334becbd 100644 --- a/lib/packageModules.js +++ b/lib/packageModules.js @@ -82,7 +82,7 @@ function zip(directory, name) { this.serverless.cli.log( `${new Date().toUTCString()} Zip ${directory} finalized` ) - this.serverless.cli.log(fileDurations) + this.serverless.cli.log(JSON.stringify(fileDurations)) } }); From eb43b7dbb41ac6df420e430c4019008b03bb1514 Mon Sep 17 00:00:00 2001 From: Liron Kopinsky Date: Thu, 25 Jun 2020 10:47:10 +0300 Subject: [PATCH 03/15] Attempt better logging for zip writing performance. --- lib/packageModules.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/packageModules.js b/lib/packageModules.js index 7334becbd..39b325ea7 100644 --- a/lib/packageModules.js +++ b/lib/packageModules.js @@ -50,15 +50,14 @@ function zip(directory, name) { return BbPromise.reject(error); } + const fileDurations = {} output.on('open', () => { - this.options.verbose && this.serverless.cli.log( - `${new Date().toUTCString()} Zip ${directory} open - ${files.length} files` + `${new Date().toUTCString()} Zip ${artifactFilePath} open - ${files.length} files` ) zip.pipe(output); - const fileDurations = {} _.forEach(files, filePath => { const startFile = _.now() const fullPath = path.resolve(directory, filePath); @@ -66,14 +65,19 @@ function zip(directory, name) { const stats = fs.statSync(fullPath); if (!stats.isDirectory(fullPath)) { - zip.append(fs.readFileSync(fullPath), { + const readStream = fs.readFileSync(fullPath) + readStream.on('close', () => { + const duration = _.now() - startFile + if (duration >= 1) { + fileDurations[fullPath] = duration + } + }) + zip.append(readStream, { name: filePath, mode: stats.mode, date: new Date(0) // necessary to get the same hash when zipping the same content }); } - const duration = _.now() - startFile - fileDurations[fullPath] = duration }); zip.finalize(); @@ -82,12 +86,19 @@ function zip(directory, name) { this.serverless.cli.log( `${new Date().toUTCString()} Zip ${directory} finalized` ) - this.serverless.cli.log(JSON.stringify(fileDurations)) } }); return new BbPromise((resolve, reject) => { - output.on('close', () => resolve(artifactFilePath)); + output.on('close', () => { + if (this.options.verbose) { + this.serverless.cli.log( + `${new Date().toUTCString()} Zip ${artifactFilePath} closed` + ) + this.serverless.cli.log(JSON.stringify(fileDurations)) + } + resolve(artifactFilePath) + }); zip.on('error', err => reject(err)); }); } From 9b3c7253851b36c0ea43a02ca64c8a0b845866d1 Mon Sep 17 00:00:00 2001 From: Liron Kopinsky Date: Thu, 25 Jun 2020 11:00:27 +0300 Subject: [PATCH 04/15] Remove bad code. --- lib/packageModules.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/packageModules.js b/lib/packageModules.js index 39b325ea7..e9a8d0e54 100644 --- a/lib/packageModules.js +++ b/lib/packageModules.js @@ -59,19 +59,12 @@ function zip(directory, name) { zip.pipe(output); _.forEach(files, filePath => { - const startFile = _.now() const fullPath = path.resolve(directory, filePath); const stats = fs.statSync(fullPath); if (!stats.isDirectory(fullPath)) { const readStream = fs.readFileSync(fullPath) - readStream.on('close', () => { - const duration = _.now() - startFile - if (duration >= 1) { - fileDurations[fullPath] = duration - } - }) zip.append(readStream, { name: filePath, mode: stats.mode, From de20ff5c6df4fade8f2f1ba29871122702e4a9de Mon Sep 17 00:00:00 2001 From: Liron Kopinsky Date: Thu, 25 Jun 2020 13:02:04 +0300 Subject: [PATCH 05/15] Attempt to use bestzip instead of archiver. Unit tests not passing. --- lib/packageModules.js | 91 +++++++---------- package-lock.json | 231 ++++++++++++++++++++++++++++++++++++------ package.json | 1 + 3 files changed, 238 insertions(+), 85 deletions(-) diff --git a/lib/packageModules.js b/lib/packageModules.js index e9a8d0e54..2526092de 100644 --- a/lib/packageModules.js +++ b/lib/packageModules.js @@ -3,8 +3,7 @@ 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'); @@ -26,14 +25,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, @@ -49,50 +41,35 @@ function zip(directory, name) { const error = new this.serverless.classes.Error('Packaging: No files found'); return BbPromise.reject(error); } + const artifactFilePath = path.join(this.serverless.config.servicePath, '.serverless', name); + this.serverless.utils.writeFileDir(artifactFilePath); - const fileDurations = {} - output.on('open', () => { - this.options.verbose && - this.serverless.cli.log( - `${new Date().toUTCString()} Zip ${artifactFilePath} open - ${files.length} files` - ) - zip.pipe(output); - - _.forEach(files, filePath => { - const fullPath = path.resolve(directory, filePath); - - const stats = fs.statSync(fullPath); - - if (!stats.isDirectory(fullPath)) { - const readStream = fs.readFileSync(fullPath) - zip.append(readStream, { - name: filePath, - mode: stats.mode, - date: new Date(0) // necessary to get the same hash when zipping the same content - }); - } - }); - - zip.finalize(); - - if (this.options.verbose) { - this.serverless.cli.log( - `${new Date().toUTCString()} Zip ${directory} finalized` - ) - } - }); - + this.options.verbose && + this.serverless.cli.log(`${new Date().toUTCString()} Zip ${directory} into ${artifactFilePath} - start`); + const startTime = _.now(); + let source = directory; + if (!_.endsWith(directory, '/')) { + source += '/'; + } + const zipArgs = { + source, + destination: artifactFilePath + }; + this.options.verbose && this.serverless.cli.log(`Zip Args: ${JSON.stringify(zipArgs)}`); return new BbPromise((resolve, reject) => { - output.on('close', () => { - if (this.options.verbose) { - this.serverless.cli.log( - `${new Date().toUTCString()} Zip ${artifactFilePath} closed` - ) - this.serverless.cli.log(JSON.stringify(fileDurations)) - } - resolve(artifactFilePath) - }); - zip.on('error', err => reject(err)); + bestzip(zipArgs) + .then(result => { + const duration = _.now() - startTime; + this.options.verbose && + this.serverless.cli.log( + `${new Date().toUTCString()} Zip ${directory} into ${artifactFilePath} - finished [${duration} ms]` + ); + resolve(result); + return null; + }) + .catch(err => { + reject(err); + }); }); } @@ -140,9 +117,9 @@ module.exports = { const modulePath = compileStats.compilation.compiler.outputPath; this.options.verbose && - this.serverless.cli.log( - `${new Date().toUTCString()} Zip ${_.isEmpty(entryFunction) ? 'service' : 'function'}: ${modulePath} start` - ) + this.serverless.cli.log( + `${new Date().toUTCString()} Zip ${_.isEmpty(entryFunction) ? 'service' : 'function'}: ${modulePath} start` + ); const startZip = _.now(); return zip .call(this, modulePath, filename) @@ -150,7 +127,9 @@ module.exports = { () => this.options.verbose && this.serverless.cli.log( - `${new Date().toUTCString()} Zip ${_.isEmpty(entryFunction) ? 'service' : 'function'}: ${modulePath} [${_.now() - startZip} ms]` + `${new Date().toUTCString()} Zip ${ + _.isEmpty(entryFunction) ? 'service' : 'function' + }: ${modulePath} [${_.now() - startZip} ms]` ) ); }); diff --git a/package-lock.json b/package-lock.json index 6bfb8e28a..2c786c266 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" } @@ -1961,6 +1960,195 @@ "tweetnacl": "^0.14.3" } }, + "bestzip": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/bestzip/-/bestzip-2.1.5.tgz", + "integrity": "sha512-ieNnkUNC4iF3eC8L+00Gd/niBqyjqZ28UnKYOSozWDBluqht3NMlQXLJVi47mehwgSsvGq+GqvEmVWZHQy2nrQ==", + "requires": { + "archiver": "^3.0.0", + "async": "^2.6.1", + "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==" + }, + "archiver": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/archiver/-/archiver-3.1.1.tgz", + "integrity": "sha512-5Hxxcig7gw5Jod/8Gq0OneVgLYET+oNHcxgWItq4TbhOzRLKNAFUb9edAftiMKXvXfCB0vbGrJdZDNq0dWMsxg==", + "requires": { + "archiver-utils": "^2.1.0", + "async": "^2.6.3", + "buffer-crc32": "^0.2.1", + "glob": "^7.1.4", + "readable-stream": "^3.4.0", + "tar-stream": "^2.1.0", + "zip-stream": "^2.1.2" + } + }, + "async": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", + "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "requires": { + "lodash": "^4.17.14" + } + }, + "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" + } + }, + "compress-commons": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/compress-commons/-/compress-commons-2.1.1.tgz", + "integrity": "sha512-eVw6n7CnEMFzc3duyFVrQEuY1BlHR3rYsSztyG32ibGMW722i3C6IizEGMFmfMU+A+fALvBIwxN3czffTcdA+Q==", + "requires": { + "buffer-crc32": "^0.2.13", + "crc32-stream": "^3.0.1", + "normalize-path": "^3.0.0", + "readable-stream": "^2.3.6" + }, + "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" + } + } + } + }, + "crc32-stream": { + "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" + } + }, + "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" + } + }, + "yargs-parser": { + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "zip-stream": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-2.1.3.tgz", + "integrity": "sha512-EkXc2JGcKhO5N5aZ7TmuNo45budRaFGHOmz24wtJR7znbNqDPmdZtUauKX6et8KAVseAMBOyWJqEpXcHTBsh7Q==", + "requires": { + "archiver-utils": "^2.1.0", + "compress-commons": "^2.1.1", + "readable-stream": "^3.4.0" + } + } + } + }, "better-assert": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", @@ -2225,8 +2413,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 +2773,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 +2780,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", @@ -2882,8 +3067,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 +3605,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 +5203,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 +6282,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 +6437,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 +8693,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", @@ -9598,14 +9777,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 +10255,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 +11700,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 +11707,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 +11938,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", diff --git a/package.json b/package.json index e5d33f7ed..c9c860ee3 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ }, "dependencies": { "archiver": "^5.0.2", + "bestzip": "^2.1.5", "bluebird": "^3.7.2", "fs-extra": "^9.0.1", "glob": "^7.1.6", From f99645e8657d895a3bc608789e45e8d01f2e1b1e Mon Sep 17 00:00:00 2001 From: Liron Kopinsky Date: Thu, 25 Jun 2020 13:13:17 +0300 Subject: [PATCH 06/15] Fix bug in previous attempt. Also attempt to add bestzip mock, which isn't working yet. --- lib/packageModules.js | 4 ++-- tests/mocks/bestzip.mock.js | 21 +++++++++++++++++++++ tests/packageModules.test.js | 5 +++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/mocks/bestzip.mock.js diff --git a/lib/packageModules.js b/lib/packageModules.js index 2526092de..06b4aaac9 100644 --- a/lib/packageModules.js +++ b/lib/packageModules.js @@ -58,13 +58,13 @@ function zip(directory, name) { this.options.verbose && this.serverless.cli.log(`Zip Args: ${JSON.stringify(zipArgs)}`); return new BbPromise((resolve, reject) => { bestzip(zipArgs) - .then(result => { + .then(() => { const duration = _.now() - startTime; this.options.verbose && this.serverless.cli.log( `${new Date().toUTCString()} Zip ${directory} into ${artifactFilePath} - finished [${duration} ms]` ); - resolve(result); + resolve(artifactFilePath); return null; }) .catch(err => { diff --git a/tests/mocks/bestzip.mock.js b/tests/mocks/bestzip.mock.js new file mode 100644 index 000000000..25eaf0b27 --- /dev/null +++ b/tests/mocks/bestzip.mock.js @@ -0,0 +1,21 @@ +'use strict'; + +/** + * Mock object for bestzip + */ + +const sinon = require('sinon'); + +// const BestZipMock = sandbox => ({ +// bestzip: sandbox.stub() +// }); +const BestZipMock = sandbox => sandbox.stub(); + +module.exports.create = sandbox => { + const bestzipMock = BestZipMock(sandbox); + const mock = { + create: sinon.stub().returns(bestzipMock), + _bestzipMock: bestzipMock + }; + return mock; +}; diff --git a/tests/packageModules.test.js b/tests/packageModules.test.js index 675b51cb6..35ca042d9 100644 --- a/tests/packageModules.test.js +++ b/tests/packageModules.test.js @@ -13,6 +13,7 @@ const Configuration = require('../lib/Configuration'); 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')); @@ -29,6 +30,7 @@ describe('packageModules', () => { let fsMock; let globMock; let archiverMock; + let bestzipMock; // Serverless stubs let writeFileDirStub; let getAllFunctionsStub; @@ -42,10 +44,12 @@ describe('packageModules', () => { 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'); @@ -93,6 +97,7 @@ describe('packageModules', () => { 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 From 48c49cf57d715ef9562fab56a2e696bd07586260 Mon Sep 17 00:00:00 2001 From: Liron Kopinsky Date: Thu, 25 Jun 2020 16:52:38 +0300 Subject: [PATCH 07/15] Get unit tests to pass and attempt to fix zip file paths. --- lib/packageModules.js | 15 ++++++++------- tests/mocks/bestzip.mock.js | 8 +------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/packageModules.js b/lib/packageModules.js index 06b4aaac9..df88a2346 100644 --- a/lib/packageModules.js +++ b/lib/packageModules.js @@ -41,19 +41,20 @@ function zip(directory, name) { const error = new this.serverless.classes.Error('Packaging: No files found'); return BbPromise.reject(error); } - const artifactFilePath = path.join(this.serverless.config.servicePath, '.serverless', name); + const artifactRootPath = path.join(this.serverless.config.servicePath, '.serverless'); + const artifactFilePath = path.join(artifactRootPath, name); this.serverless.utils.writeFileDir(artifactFilePath); this.options.verbose && this.serverless.cli.log(`${new Date().toUTCString()} Zip ${directory} into ${artifactFilePath} - start`); const startTime = _.now(); - let source = directory; - if (!_.endsWith(directory, '/')) { - source += '/'; - } + + const directoryPath = path.parse(directory); + const cwd = directoryPath.dir; const zipArgs = { - source, - destination: artifactFilePath + source: directoryPath.name, + cwd, + destination: path.relative(cwd, artifactFilePath) }; this.options.verbose && this.serverless.cli.log(`Zip Args: ${JSON.stringify(zipArgs)}`); return new BbPromise((resolve, reject) => { diff --git a/tests/mocks/bestzip.mock.js b/tests/mocks/bestzip.mock.js index 25eaf0b27..99b9886df 100644 --- a/tests/mocks/bestzip.mock.js +++ b/tests/mocks/bestzip.mock.js @@ -6,16 +6,10 @@ const sinon = require('sinon'); -// const BestZipMock = sandbox => ({ -// bestzip: sandbox.stub() -// }); const BestZipMock = sandbox => sandbox.stub(); module.exports.create = sandbox => { const bestzipMock = BestZipMock(sandbox); - const mock = { - create: sinon.stub().returns(bestzipMock), - _bestzipMock: bestzipMock - }; + const mock = sinon.stub().resolves(bestzipMock); return mock; }; From 0bcecf8f0cb562797bc4524c0b143b185e7f21b1 Mon Sep 17 00:00:00 2001 From: Liron Kopinsky Date: Thu, 25 Jun 2020 17:25:59 +0300 Subject: [PATCH 08/15] Some code cleanup. --- lib/packageModules.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/packageModules.js b/lib/packageModules.js index df88a2346..44320a69e 100644 --- a/lib/packageModules.js +++ b/lib/packageModules.js @@ -51,10 +51,12 @@ function zip(directory, name) { const directoryPath = path.parse(directory); const cwd = directoryPath.dir; + const source = directoryPath.name; + const destination = path.relative(cwd, artifactFilePath); const zipArgs = { - source: directoryPath.name, + source, cwd, - destination: path.relative(cwd, artifactFilePath) + destination }; this.options.verbose && this.serverless.cli.log(`Zip Args: ${JSON.stringify(zipArgs)}`); return new BbPromise((resolve, reject) => { From e3641fbbcc7ef5874399beeacb9df2a23a19ec98 Mon Sep 17 00:00:00 2001 From: Liron Kopinsky Date: Thu, 25 Jun 2020 19:07:56 +0300 Subject: [PATCH 09/15] Attempt to adjust the cwd to use the full directory and not the parent directory. --- lib/packageModules.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/packageModules.js b/lib/packageModules.js index 44320a69e..0fb11907f 100644 --- a/lib/packageModules.js +++ b/lib/packageModules.js @@ -49,9 +49,8 @@ function zip(directory, name) { this.serverless.cli.log(`${new Date().toUTCString()} Zip ${directory} into ${artifactFilePath} - start`); const startTime = _.now(); - const directoryPath = path.parse(directory); - const cwd = directoryPath.dir; - const source = directoryPath.name; + const cwd = directory; + const source = '*'; const destination = path.relative(cwd, artifactFilePath); const zipArgs = { source, From 7ca2836296ade3c8a871c5543256013404be0903 Mon Sep 17 00:00:00 2001 From: Liron Kopinsky Date: Thu, 25 Jun 2020 19:34:21 +0300 Subject: [PATCH 10/15] Remove unneeded logs. --- lib/packageModules.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/lib/packageModules.js b/lib/packageModules.js index 0fb11907f..97af77c02 100644 --- a/lib/packageModules.js +++ b/lib/packageModules.js @@ -45,10 +45,6 @@ function zip(directory, name) { const artifactFilePath = path.join(artifactRootPath, name); this.serverless.utils.writeFileDir(artifactFilePath); - this.options.verbose && - this.serverless.cli.log(`${new Date().toUTCString()} Zip ${directory} into ${artifactFilePath} - start`); - const startTime = _.now(); - const cwd = directory; const source = '*'; const destination = path.relative(cwd, artifactFilePath); @@ -57,15 +53,9 @@ function zip(directory, name) { cwd, destination }; - this.options.verbose && this.serverless.cli.log(`Zip Args: ${JSON.stringify(zipArgs)}`); return new BbPromise((resolve, reject) => { bestzip(zipArgs) .then(() => { - const duration = _.now() - startTime; - this.options.verbose && - this.serverless.cli.log( - `${new Date().toUTCString()} Zip ${directory} into ${artifactFilePath} - finished [${duration} ms]` - ); resolve(artifactFilePath); return null; }) @@ -118,10 +108,6 @@ module.exports = { const filename = getArtifactName.call(this, entryFunction); const modulePath = compileStats.compilation.compiler.outputPath; - this.options.verbose && - this.serverless.cli.log( - `${new Date().toUTCString()} Zip ${_.isEmpty(entryFunction) ? 'service' : 'function'}: ${modulePath} start` - ); const startZip = _.now(); return zip .call(this, modulePath, filename) From d077fba690fb2866d511010af713472dbe8fcb8f Mon Sep 17 00:00:00 2001 From: Liron Kopinsky Date: Sun, 28 Jun 2020 09:52:18 +0300 Subject: [PATCH 11/15] Revert one logging change to remove the timestamp. --- lib/packageModules.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/packageModules.js b/lib/packageModules.js index 97af77c02..f2a7c976d 100644 --- a/lib/packageModules.js +++ b/lib/packageModules.js @@ -115,9 +115,7 @@ module.exports = { () => this.options.verbose && this.serverless.cli.log( - `${new Date().toUTCString()} Zip ${ - _.isEmpty(entryFunction) ? 'service' : 'function' - }: ${modulePath} [${_.now() - startZip} ms]` + `Zip ${_.isEmpty(entryFunction) ? 'service' : 'function'}: ${modulePath} [${_.now() - startZip} ms]` ) ); }); From a1846783cb1d26998a945aeeb57aefa7cfc6cb31 Mon Sep 17 00:00:00 2001 From: Liron Kopinsky Date: Wed, 22 Jul 2020 17:31:40 +0300 Subject: [PATCH 12/15] Fix missing require after merge. --- lib/packageModules.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/packageModules.js b/lib/packageModules.js index f2a7c976d..54cfb2a12 100644 --- a/lib/packageModules.js +++ b/lib/packageModules.js @@ -6,6 +6,7 @@ const path = require('path'); 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(); From dc9c136c685212f3efa4c93162ee84ece5bdd8b5 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 29 Jul 2020 10:54:24 +0200 Subject: [PATCH 13/15] Cleanup archiver --- lib/packagers/yarn.test.js | 8 +++---- package.json | 1 - tests/mocks/archiver.mock.js | 23 --------------------- tests/mocks/package.mock.json | 2 +- tests/mocks/packageIgnoredDevDeps.mock.json | 2 +- tests/mocks/packageLocalRef.mock.json | 2 +- tests/packageModules.test.js | 7 +------ 7 files changed, 8 insertions(+), 37 deletions(-) delete mode 100644 tests/mocks/archiver.mock.js 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.json b/package.json index c9c860ee3..ebb90d789 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,6 @@ "report-dir": "./coverage" }, "dependencies": { - "archiver": "^5.0.2", "bestzip": "^2.1.5", "bluebird": "^3.7.2", "fs-extra": "^9.0.1", 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/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 35ca042d9..d62353453 100644 --- a/tests/packageModules.test.js +++ b/tests/packageModules.test.js @@ -12,7 +12,6 @@ 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')); @@ -29,7 +28,6 @@ describe('packageModules', () => { // Mocks let fsMock; let globMock; - let archiverMock; let bestzipMock; // Serverless stubs let writeFileDirStub; @@ -43,12 +41,10 @@ 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); @@ -96,7 +92,6 @@ 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, @@ -109,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 From 2aef3a94833de4cf52b8e077576dc4f6edeb7961 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 29 Jul 2020 11:49:29 +0200 Subject: [PATCH 14/15] Keep using `.webpack` instead of switching to `.serverless` folder --- lib/packageModules.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/packageModules.js b/lib/packageModules.js index 54cfb2a12..040cd955b 100644 --- a/lib/packageModules.js +++ b/lib/packageModules.js @@ -42,8 +42,10 @@ function zip(directory, name) { const error = new this.serverless.classes.Error('Packaging: No files found'); return BbPromise.reject(error); } - const artifactRootPath = path.join(this.serverless.config.servicePath, '.serverless'); - const artifactFilePath = path.join(artifactRootPath, name); + + // 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; From 0136d7e8cbd734170cb2d8c0270da00b0a1c5f3f Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 20 Nov 2020 15:35:23 +0100 Subject: [PATCH 15/15] Update bestzip --- package-lock.json | 148 ++++++++++++---------------------------------- package.json | 2 +- 2 files changed, 40 insertions(+), 110 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2c786c266..e9ffc4224 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1418,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,12 +1961,12 @@ } }, "bestzip": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/bestzip/-/bestzip-2.1.5.tgz", - "integrity": "sha512-ieNnkUNC4iF3eC8L+00Gd/niBqyjqZ28UnKYOSozWDBluqht3NMlQXLJVi47mehwgSsvGq+GqvEmVWZHQy2nrQ==", + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/bestzip/-/bestzip-2.1.7.tgz", + "integrity": "sha512-Eg5ZP0Viw1beJydZLbW246oCUnvtKGi7DhcB6IlKxP03NaxKCGVhKJD/jY4MLFRINhepfVEhAhnlc/uIxc9dHA==", "requires": { - "archiver": "^3.0.0", - "async": "^2.6.1", + "archiver": "^4.0.2", + "async": "^3.2.0", "glob": "^7.1.3", "which": "^1.3.1", "yargs": "^13.2.4" @@ -1977,28 +1977,6 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" }, - "archiver": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/archiver/-/archiver-3.1.1.tgz", - "integrity": "sha512-5Hxxcig7gw5Jod/8Gq0OneVgLYET+oNHcxgWItq4TbhOzRLKNAFUb9edAftiMKXvXfCB0vbGrJdZDNq0dWMsxg==", - "requires": { - "archiver-utils": "^2.1.0", - "async": "^2.6.3", - "buffer-crc32": "^0.2.1", - "glob": "^7.1.4", - "readable-stream": "^3.4.0", - "tar-stream": "^2.1.0", - "zip-stream": "^2.1.2" - } - }, - "async": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", - "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", - "requires": { - "lodash": "^4.17.14" - } - }, "cliui": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", @@ -2009,42 +1987,6 @@ "wrap-ansi": "^5.1.0" } }, - "compress-commons": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/compress-commons/-/compress-commons-2.1.1.tgz", - "integrity": "sha512-eVw6n7CnEMFzc3duyFVrQEuY1BlHR3rYsSztyG32ibGMW722i3C6IizEGMFmfMU+A+fALvBIwxN3czffTcdA+Q==", - "requires": { - "buffer-crc32": "^0.2.13", - "crc32-stream": "^3.0.1", - "normalize-path": "^3.0.0", - "readable-stream": "^2.3.6" - }, - "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" - } - } - } - }, - "crc32-stream": { - "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" - } - }, "find-up": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", @@ -2127,25 +2069,6 @@ "y18n": "^4.0.0", "yargs-parser": "^13.1.2" } - }, - "yargs-parser": { - "version": "13.1.2", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", - "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - } - }, - "zip-stream": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-2.1.3.tgz", - "integrity": "sha512-EkXc2JGcKhO5N5aZ7TmuNo45budRaFGHOmz24wtJR7znbNqDPmdZtUauKX6et8KAVseAMBOyWJqEpXcHTBsh7Q==", - "requires": { - "archiver-utils": "^2.1.0", - "compress-commons": "^2.1.1", - "readable-stream": "^3.4.0" - } } } }, @@ -2866,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": { @@ -2993,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" @@ -9634,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", @@ -12090,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" @@ -12254,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 ebb90d789..df91642f6 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "report-dir": "./coverage" }, "dependencies": { - "bestzip": "^2.1.5", + "bestzip": "^2.1.7", "bluebird": "^3.7.2", "fs-extra": "^9.0.1", "glob": "^7.1.6",