-
Notifications
You must be signed in to change notification settings - Fork 217
Fix for Corporate Proxies #874
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
Conversation
|
@microsoft-github-policy-service agree |
millerds
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this!
It's probably fine that it's all together. Some formatting things that should be corrected and someone else will have to take a look at it too.
src/app/helpers/helperMethods.ts
Outdated
| import { AttemptAwareConfig, hasProxy, addProxy, addLogger, addInterceptor } from "./requestHelpers.js"; | ||
|
|
||
| const zipFile = 'project.zip'; | ||
| const log = debug("genOffice").extend("helper") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Please add semicolon to end of the statement. This should be done in other places as well.
src/app/helpers/helperMethods.ts
Outdated
| const useProxyFirst = process.env.GENERATOR_OFFICE_USE_PROXY === "true"; | ||
| const projectTemplateZipFile = `${projectRepo}/archive/${projectBranch}.zip`; | ||
| return axios({ | ||
| log("Setting up config for %s",projectTemplateZipFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: please a space between the ',' and next argument. Should be done in other statements as well.
|
/azurepipelines run |
|
No pipelines are associated with this pull request. |
|
/azurepipelines run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
You will also need to pull a change I just added to master in order for the tests to pass. |
Merging updates to master
Nit updates for spacing
|
/azurepipelines run |
|
Commenter does not have sufficient privileges for PR 874 in repo OfficeDev/generator-office |
|
/azurepipelines run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Thanks again for the submission and work you did! |
Do these changes impact User Experience? (e.g., how the user interacts with Yo Office and/or the files and folders the user sees in the project that Yo Office creates)
If Yes, briefly describe what is impacted.
Do these changes impact documentation? (e.g., a tutorial on https://learn.microsoft.com/en-us/office/dev/add-ins/overview/office-add-ins)
If Yes, briefly describe what is impacted.
Validation/testing performed:
Ran all tests in convert-to-single-host on both a computer requiring a proxy and a comnputer without a proxy. I also added tests to validate all my code with a fake proxy.
After test cases passed, I validated it worked with yo directly on both the proxied and non-proxied computers.
Platforms tested:
Overview
With the use of the requestHelpers.ts, I give the project the ability to identify and switch to a proxy server in the event of download failure. This update should resolve issue #872.
Why changes were made?
While axios could attempt to resolve the error, they have provided acceptable solutions for others to resolve on their own, as seen in the addInterceptor function in requestHelpers.ts. Axios updates alone were not enough because I was able to get all the tests to pass, but when run through the yo command line, it still failed because the default http agent was being overwritten as a BoundHttpsProxyAgent instead of a regular HttpsProxyAgent. I believe a yo dependency is modifying the Agent somehow, which might be the Microsoft usage tracker. Adding global-proxy allows you to bypass the BoundHttpsProxyAgent and switch to the proxy when necessary.
Changes breakdown
I updated the npm run scripts:
Updated the helperMethods.ts with
In index.ts, I ran into multiple issues where the files would download, but failed to properly filter and copy files (randomly in tests), so I added more logging and changed the order of operations. This may cause issues if run on machines with limited disk space.
In convert-to-single-host tests, I added a specific test for my proxy changes, replaced deprecated withPrompts with withAnswers, and added logging to all of the tests so you can see the performance changes that conveniently come with debug.
My apologies for not making these changes bite-sized. I am open to any suggestions and am willing to break this into multiple branches/pull requests.