Explorar el Código

Upload downloadable zip archive of releases to CDN (#2052)

* Fix jsdoc warnings

* Upload downloadable zip archive of releases to CDN

* var -> const

* Only upload .zip for the main uppy package

* Implement @goto-bus-stop's feedback
Kevin van Zonneveld hace 5 años
padre
commit
b7bdce7363
Se han modificado 2 ficheros con 16 adiciones y 4 borrados
  1. 15 4
      bin/upload-to-cdn.js
  2. 1 0
      package.json

+ 15 - 4
bin/upload-to-cdn.js

@@ -30,6 +30,7 @@ const mime = require('mime-types')
 const { promisify } = require('util')
 const readFile = promisify(require('fs').readFile)
 const finished = promisify(require('stream').finished)
+const AdmZip = require('adm-zip')
 
 function delay (ms) {
   return new Promise(resolve => setTimeout(resolve, ms))
@@ -41,10 +42,10 @@ const AWS_DIRECTORY = '756b8efaed084669b02cb99d4540d81f/default'
 
 /**
  * Get remote dist/ files by fetching the tarball for the given version
- * from npm and filtering it down to package/dist/ files.
+from npm and filtering it down to package/dist/ files.
  *
- * @param {string} Package name, eg. @uppy/robodog
- * @param {string} Package version, eg. "1.2.0"
+ * @param {string} packageName eg. @uppy/robodog
+ * @param {string} version eg. 1.8.0
  * @returns a Map<string, Buffer>, filename → content
  */
 async function getRemoteDistFiles (packageName, version) {
@@ -74,7 +75,7 @@ async function getRemoteDistFiles (packageName, version) {
  * Get local dist/ files by asking npm-packlist what files would be added
  * to an npm package during publish, and filtering those down to just dist/ files.
  *
- * @param {string} Base file path of the package, eg. ./packages/@uppy/locales
+ * @param {string} packagePath Base file path of the package, eg. ./packages/@uppy/locales
  * @returns a Map<string, Buffer>, filename → content
  */
 async function getLocalDistFiles (packagePath) {
@@ -160,6 +161,16 @@ async function main (packageName, version) {
     ? await getRemoteDistFiles(packageName, version)
     : await getLocalDistFiles(packagePath)
 
+  if (packageName === 'uppy') {
+    // Create downloadable zip archive
+    const zip = new AdmZip()
+    for (const [filename, buffer] of files.entries()) {
+      zip.addFile(filename, buffer)
+    }
+
+    files.set(`uppy-v${version}.zip`, zip.toBuffer())
+  }
+
   for (const [filename, buffer] of files.entries()) {
     const key = path.posix.join(AWS_DIRECTORY, outputPath, filename)
     console.log(`pushing s3://${AWS_BUCKET}/${key}`)

+ 1 - 0
package.json

@@ -103,6 +103,7 @@
     "@wdio/local-runner": "^5.16.15",
     "@wdio/mocha-framework": "^5.16.15",
     "@wdio/sauce-service": "^5.16.10",
+    "adm-zip": "0.4.13",
     "aliasify": "^2.1.0",
     "autoprefixer": "^9.7.3",
     "babel-eslint": "^10.0.3",