Skip to content

Commit

Permalink
fix: dschmidt#26 correctly upload gzipped files
Browse files Browse the repository at this point in the history
  • Loading branch information
urbany committed Dec 15, 2016
1 parent 31d8e5c commit a284653
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,18 @@ Enable adding a meta tag with the current revisionKey into the head of your `ind

### replaceFiles

At deploy-time, the plugin will check your Sentry instance for an existing release under the current `revisionKey`. If a release is found and this is set to `true`, all existing files for the matching release will be deleted before the current build's files are uploaded to Sentry. If this is set to `false`, the files on Sentry will remain untouched and the just-built files will not be uploaded.
At deploy-time, the plugin will check your Sentry instance for an existing release under the current `revisionKey`. If a release is found and this is set to `true`, all existing files for the matching release will be deleted before the current build's files are uploaded to Sentry. If this is set to `false`, the files on Sentry will remain untouched and the just-built files will not be uploaded.

*Default* true

### gzippedFiles

The list of files that have been gziped. This option should be relative to `distDir`. By default, this option will use the `gzippedFiles` property of the deployment context, provided by [ember-cli-deploy-gzip][13].

This option will be used to determine which files in `distDir`, that match `filePattern`, require the gzip content encoding when uploading.

*Default:* `context.gzippedFiles`

## Prerequisites

The following properties are expected to be present on the deployment `context` object:
Expand Down Expand Up @@ -225,3 +233,4 @@ It works. We use it in production at [Hatchet](https://hatchet.is).
[10]: http://ember-cli.github.io/ember-cli-deploy/plugins "Plugin Documentation"
[11]: https://github.com/zapnito/ember-cli-deploy-build "ember-cli-deploy-build"
[12]: https://github.com/zapnito/ember-cli-deploy-revision-data "ember-cli-deploy-revision-data"
[13]: https://github.com/lukemelia/ember-cli-deploy-gzip "ember-cli-deploy-gzip"
15 changes: 14 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ module.exports = {
+ this.readConfig('revisionKey')
+ '/';
},
replaceFiles: true
replaceFiles: true,

gzippedFiles: function(context) {
return context.gzippedFiles || []; // e.g. from ember-cli-deploy-gzip
}
},
requiredConfig: ['publicUrl', 'sentryUrl', 'sentryOrganizationSlug', 'sentryProjectSlug', 'sentryApiKey', 'revisionKey'],

Expand Down Expand Up @@ -147,6 +151,11 @@ module.exports = {
throw new SilentError('Creating release failed');
});
},
_isFileGzipped(filePath) {
var gzippedFiles = this.readConfig('gzippedFiles') || [];
var isGzipped = gzippedFiles.indexOf(filePath) >= 0;
return isGzipped;
},
_doUpload: function doUpload() {
return this._getFilesToUpload()
.then(this._uploadFileList.bind(this));
Expand Down Expand Up @@ -185,6 +194,10 @@ module.exports = {
file: fs.createReadStream(fileName),
};

if (this._isFileGzipped(filePath)) {
formData.header = 'content-encoding:gzip';
}

return request({
uri: urljoin(this.releaseUrl, 'files/'),
method: 'POST',
Expand Down

0 comments on commit a284653

Please sign in to comment.