Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Proxy config when available #124

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions packages/sitevision-scripts/scripts/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,29 @@ import chalk from 'chalk';
filename: fileName,
contentType: 'application/octet-stream',
});
var options = {
method: 'POST',
body: formData,
headers: formData.getHeaders({
Authorization: `Basic ${Buffer.from(
answers.username + ':' + answers.password,
).toString('base64')}`,
}),
};

if (process.env.HTTPS_PROXY) {
console.log(`using ${process.env.HTTPS_PROXY} as HTTPS_PROXY`);
const HttpsProxyAgent = require('https-proxy-agent');
const proxyAgent = new HttpsProxyAgent(process.env.HTTPS_PROXY);
options.agent = proxyAgent;
}
try {
const response = await fetch(url, {
method: 'POST',
body: formData,
headers: formData.getHeaders({
Authorization: `Basic ${Buffer.from(
answers.username + ':' + answers.password
).toString('base64')}`,
}),
});
const response = await fetch(url, options);

if (response.ok) {
const signedFileNameAndPath = path.join(
properties.DIST_DIR_PATH,
`${manifest.id}-signed.zip`
`${manifest.id}-signed.zip`,
);

const writer = fs.createWriteStream(signedFileNameAndPath, {
Expand All @@ -76,16 +83,16 @@ import chalk from 'chalk';

return console.log(
`${chalk.green(
'Signing successful, created:'
)} ${signedFileNameAndPath}`
'Signing successful, created:',
)} ${signedFileNameAndPath}`,
);
}

if (response.status === 401) {
console.log(
`${chalk.red(
'Signing failed:'
)} Unauthorized, check username and password`
'Signing failed:',
)} Unauthorized, check username and password`,
);
}
} catch (err) {
Expand Down