Skip to content

Commit a072078

Browse files
committed
fix: #26 correctly upload gzipped files
1 parent f44e1dc commit a072078

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,18 @@ Enable adding a meta tag with the current revisionKey into the head of your `ind
148148

149149
### replaceFiles
150150

151-
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.
151+
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.
152152

153153
*Default* true
154154

155+
### gzippedFiles
156+
157+
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].
158+
159+
This option will be used to determine which files in `distDir`, that match `filePattern`, require the gzip content encoding when uploading.
160+
161+
*Default:* `context.gzippedFiles`
162+
155163
## Prerequisites
156164

157165
The following properties are expected to be present on the deployment `context` object:
@@ -205,3 +213,4 @@ It works. We use it in production at [Hatchet](https://hatchet.is).
205213
[10]: http://ember-cli.github.io/ember-cli-deploy/plugins "Plugin Documentation"
206214
[11]: https://github.com/zapnito/ember-cli-deploy-build "ember-cli-deploy-build"
207215
[12]: https://github.com/zapnito/ember-cli-deploy-revision-data "ember-cli-deploy-revision-data"
216+
[13]: https://github.com/ember-cli-deploy/ember-cli-deploy-gzip "ember-cli-deploy-gzip"

index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ module.exports = {
3333
return context.revisionData && context.revisionData.revisionKey;
3434
},
3535
enableRevisionTagging: true,
36+
37+
gzippedFiles: function(context) {
38+
return context.gzippedFiles || []; // e.g. from ember-cli-deploy-gzip
39+
},
40+
3641
replaceFiles: true
3742
},
3843
requiredConfig: ['publicUrl', 'sentryUrl', 'sentryOrganizationSlug', 'sentryProjectSlug', 'sentryApiKey', 'revisionKey'],
@@ -135,6 +140,11 @@ module.exports = {
135140
throw new SilentError('Creating release failed');
136141
});
137142
},
143+
_isFileGzipped(filePath) {
144+
var gzippedFiles = this.readConfig('gzippedFiles') || [];
145+
var isGzipped = gzippedFiles.indexOf(filePath) >= 0;
146+
return isGzipped;
147+
},
138148
_doUpload: function doUpload() {
139149
return this._getFilesToUpload()
140150
.then(this._uploadFileList.bind(this));
@@ -173,6 +183,10 @@ module.exports = {
173183
file: fs.createReadStream(fileName),
174184
};
175185

186+
if (this._isFileGzipped(filePath)) {
187+
formData.header = 'content-encoding:gzip';
188+
}
189+
176190
return request({
177191
uri: urljoin(this.releaseUrl, 'files/'),
178192
method: 'POST',

0 commit comments

Comments
 (0)