Unverified Commit 15236a2c authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #1830 from hypothesis/remove-sourcemap-upload

Remove unused sourcemap upload scripts
parents a78b8642 1e91cac1
...@@ -40,13 +40,6 @@ function parseCommandLine() { ...@@ -40,13 +40,6 @@ function parseCommandLine() {
const taskArgs = parseCommandLine(); const taskArgs = parseCommandLine();
function getEnv(key) {
if (!process.env.hasOwnProperty(key)) {
throw new Error(`Environment variable ${key} is not set`);
}
return process.env[key];
}
/** A list of all modules included in vendor bundles. */ /** A list of all modules included in vendor bundles. */
const vendorModules = Object.keys(vendorBundles.bundles).reduce(function( const vendorModules = Object.keys(vendorBundles.bundles).reduce(function(
deps, deps,
...@@ -355,21 +348,3 @@ gulp.task( ...@@ -355,21 +348,3 @@ gulp.task(
'test-watch', 'test-watch',
gulp.series('build-css', done => runKarma({ singleRun: false }, done)) gulp.series('build-css', done => runKarma({ singleRun: false }, done))
); );
gulp.task(
'upload-sourcemaps',
gulp.series('build-js', function() {
const uploadToSentry = require('./scripts/gulp/upload-to-sentry');
const opts = {
key: getEnv('SENTRY_API_KEY'),
organization: getEnv('SENTRY_ORGANIZATION'),
};
const projects = getEnv('SENTRY_PROJECTS').split(',');
const release = getEnv('SENTRY_RELEASE_VERSION');
return gulp
.src(['build/scripts/*.js', 'build/scripts/*.map'])
.pipe(uploadToSentry(opts, projects, release));
})
);
...@@ -91,7 +91,6 @@ ...@@ -91,7 +91,6 @@
"raf": "^3.1.0", "raf": "^3.1.0",
"redux": "^4.0.1", "redux": "^4.0.1",
"redux-thunk": "^2.1.0", "redux-thunk": "^2.1.0",
"request": "^2.76.0",
"reselect": "^4.0.0", "reselect": "^4.0.0",
"retry": "^0.12.0", "retry": "^0.12.0",
"sass": "^1.23.0", "sass": "^1.23.0",
......
'use strict';
const fs = require('fs');
const path = require('path');
const log = require('fancy-log');
const request = require('request');
const through = require('through2');
const SENTRY_API_ROOT = 'https://app.getsentry.com/api/0';
/**
* interface SentryOptions {
* /// The Sentry API key
* key: string;
* /// The Sentry organisation to upload the release to
* organization: string;
* }
*/
/** Wrapper around request() that returns a Promise. */
function httpRequest(opts) {
return new Promise(function(resolve, reject) {
request(opts, function(err, response, body) {
if (err) {
reject(err);
} else {
resolve({
response: response,
body: body,
});
}
});
});
}
/** Create a release in Sentry. Returns a Promise. */
function createRelease(opts, project, release) {
return httpRequest({
uri: `${SENTRY_API_ROOT}/projects/${opts.organization}/${project}/releases/`,
method: 'POST',
auth: {
user: opts.key,
password: '',
},
body: {
version: release,
},
json: true,
}).then(function(result) {
const success = result.response.statusCode === 201;
const alreadyCreated =
result.response.statusCode === 400 &&
result.body.detail.match(/already exists/);
if (success || alreadyCreated) {
return;
}
throw new Error(
`unable to create release '${release}' in project '${project}'`
);
});
}
/** Upload a named file to a release in Sentry. Returns a Promise. */
function uploadReleaseFile(opts, project, release, file) {
return httpRequest({
uri: `${SENTRY_API_ROOT}/projects/${opts.organization}/${project}/releases/${release}/files/`,
method: 'POST',
auth: {
user: opts.key,
password: '',
},
formData: {
file: fs.createReadStream(file.path),
name: path.basename(file.path),
},
}).then(function(result) {
if (result.response.statusCode === 201) {
return;
}
throw new Error(
`Uploading file failed: ${result.response.statusCode}: ${result.body}`
);
});
}
/**
* Upload a stream of Vinyl files as a Sentry release.
*
* This creates a new release in Sentry using the organization, project
* and release settings in `opts` and uploads the input stream of Vinyl
* files as artefacts for the release.
*
* @param {SentryOptions} opts
* @param {Array[String]} projects - A list of projects to which to upload
* files.
* @param {String} release - The name of the release.
* @return {NodeJS.ReadWriteStream} - A stream into which Vinyl files from
* gulp.src() etc. can be piped.
*/
module.exports = function uploadToSentry(opts, projects, release) {
// Create releases in every project
const releases = projects.map(function(project) {
log(`Creating release '${release}' in project '${project}'`);
return createRelease(opts, project, release);
});
return through.obj(function(file, enc, callback) {
Promise.all(releases)
.then(function() {
log(`Uploading ${path.basename(file.path)}`);
const uploads = projects.map(function(project) {
return uploadReleaseFile(opts, project, release, file);
});
return Promise.all(uploads);
})
.then(function() {
callback();
})
.catch(function(err) {
log('Sentry upload failed: ', err);
callback(err);
});
});
};
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment