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 2 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
23 changes: 14 additions & 9 deletions packages/sitevision-scripts/scripts/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import chalk from 'chalk';
const manifest = properties.getManifest();
const fileName = manifest.id + '.zip';
const zipPath = properties.DIST_DIR_PATH + '/' + fileName;

if (!fs.existsSync(zipPath)) {
console.log('You have to run "npm run build" before running this script');
return;
Expand All @@ -51,17 +51,22 @@ import chalk from 'chalk';
filename: fileName,
contentType: 'application/octet-stream',
});

try {
const response = await fetch(url, {
method: 'POST',
body: formData,
headers: formData.getHeaders({
var options = {
method: 'POST',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code formatting is a bit off from the rest of the file. We use Prettier it's a simple tool that formats the files automatically and let you focus on more important stuff. :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jag måste tyvärr använda mig av online redigeringen så är lite begränsad till vad jag kan göra. Får titta mer på om jag kan ha någon vettigt dev miljö för detta.

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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest we add this as an explicit dependency now that it is used directly. Makes it more obvious that we actually use it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vi la den där pga lazy loading, men du har rätt.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Det är helt ok med lazy-loading. Det jag tänkte på var att den bör specificeras i package.json, nu är det med som ett transient beroende.

const proxyAgent = new HttpsProxyAgent(process.env.HTTPS_PROXY);
options.agent = proxyAgent
}
try {
const response = await fetch(url, options);

if (response.ok) {
const signedFileNameAndPath = path.join(
Expand Down