Skip to content

Conversation

@lashower
Copy link
Contributor

@lashower lashower commented Dec 6, 2025

  1. 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)

    • Yes
    • [ X ] No

    If Yes, briefly describe what is impacted.

  2. Do these changes impact documentation? (e.g., a tutorial on https://learn.microsoft.com/en-us/office/dev/add-ins/overview/office-add-ins)

    • Yes
    • [ X ] No

    If Yes, briefly describe what is impacted.

  3. 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.

  1. Platforms tested:

    • [ X ] Windows
    • Mac

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:

  • start was not functional, so I fixed that.
  • Moved rimraf into its own clean command and updated references
  • Updated test so you can add default environment variables and removed useless ts-node/register

Updated the helperMethods.ts with

  • Log entries for downloadProjectTemplateZipFile
  • Added GENERATOR_OFFICE_USE_PROXY environment variable that will use the proxy server by default.
  • Added interceptor method call.
  • Switched axios function call with axios.create to have a unique instance.

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.

@lashower lashower requested a review from a team as a code owner December 6, 2025 02:07
@lashower
Copy link
Contributor Author

lashower commented Dec 6, 2025

@microsoft-github-policy-service agree

Copy link
Contributor

@millerds millerds left a 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.

import { AttemptAwareConfig, hasProxy, addProxy, addLogger, addInterceptor } from "./requestHelpers.js";

const zipFile = 'project.zip';
const log = debug("genOffice").extend("helper")
Copy link
Contributor

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.

const useProxyFirst = process.env.GENERATOR_OFFICE_USE_PROXY === "true";
const projectTemplateZipFile = `${projectRepo}/archive/${projectBranch}.zip`;
return axios({
log("Setting up config for %s",projectTemplateZipFile)
Copy link
Contributor

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.

@millerds
Copy link
Contributor

millerds commented Dec 8, 2025

/azurepipelines run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@millerds
Copy link
Contributor

millerds commented Dec 8, 2025

/azurepipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@millerds
Copy link
Contributor

millerds commented Dec 9, 2025

You will also need to pull a change I just added to master in order for the tests to pass.

@lashower
Copy link
Contributor Author

/azurepipelines run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 874 in repo OfficeDev/generator-office

@millerds
Copy link
Contributor

/azurepipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@millerds millerds merged commit cb440dc into OfficeDev:master Dec 10, 2025
5 checks passed
@millerds
Copy link
Contributor

Thanks again for the submission and work you did!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants