build: convert all release scripts to typescript (#44059)

* build: convert all release scripts to typescript (#44035)

* build: convert all release scripts to typescript

* fix test imports

* build: fix version bumper export

* refactor: use as const

* spec: fix bad type spec

* build: use ts-node to spawn the version-bumper (#44057)

Missed this in the tsification, we should probably call this via API instead of spawning a sub-proc?

* build: still colors
This commit is contained in:
Samuel Attard 2024-10-01 03:04:22 -07:00 committed by GitHub
parent 52a8d133cd
commit fc9cda72d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 1164 additions and 772 deletions

View file

@ -1,42 +0,0 @@
const got = require('got');
const url = require('node:url');
module.exports = async function getUrlHash (targetUrl, algorithm = 'sha256', attempts = 3) {
const options = {
code: process.env.ELECTRON_ARTIFACT_HASHER_FUNCTION_KEY,
targetUrl,
algorithm
};
const search = new url.URLSearchParams(options);
const functionUrl = url.format({
protocol: 'https:',
hostname: 'electron-artifact-hasher.azurewebsites.net',
pathname: '/api/HashArtifact',
search: search.toString()
});
try {
const resp = await got(functionUrl, {
throwHttpErrors: false
});
if (resp.statusCode !== 200) {
console.error('bad hasher function response:', resp.body.trim());
throw new Error('non-200 status code received from hasher function');
}
if (!resp.body) throw new Error('Successful lambda call but failed to get valid hash');
return resp.body.trim();
} catch (err) {
if (attempts > 1) {
if (err.response?.body) {
console.error(`Failed to get URL hash for ${targetUrl} - we will retry`, {
statusCode: err.response.statusCode,
body: JSON.parse(err.response.body)
});
} else {
console.error(`Failed to get URL hash for ${targetUrl} - we will retry`, err);
}
return getUrlHash(targetUrl, algorithm, attempts - 1);
}
throw err;
}
};