Remove Local Build Universal Maker hack#10539
Conversation
…ner and easier to read.
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension. |
There was a problem hiding this comment.
Code Review
This pull request updates the build output directory to .apphosting and removes redundant file-moving logic that was previously used to handle output safely. Additionally, the toProcessEnv function has been refactored to improve readability and type safety, aligning with the repository's style guide by reducing nesting and streamlining the environment variable resolution process.
| async function toProcessEnv(projectId: string, env: EnvMap): Promise<Record<string, string>> { | ||
| const buildVars = Object.entries(env).filter(([, value]) => { | ||
| return !value.availability || value.availability.includes("BUILD"); | ||
| }); | ||
|
|
||
| if (value.secret) { | ||
| const resolvedValue = await loadSecret(projectId, value.secret); | ||
| return [key, resolvedValue]; | ||
| } else { | ||
| return [key, value.value || ""]; | ||
| } | ||
| const resolvedEntries = await Promise.all( | ||
| buildVars.map(async ([key, value]) => { | ||
| const resolvedValue = value.secret | ||
| ? await loadSecret(projectId, value.secret) | ||
| : value.value || ""; | ||
| return [key, resolvedValue]; | ||
| }), | ||
| ); | ||
|
|
||
| const filteredEntries = entries.filter((entry): entry is [string, string] => entry !== null); | ||
| return Object.fromEntries(filteredEntries) as NodeJS.ProcessEnv; | ||
| return Object.fromEntries(resolvedEntries) as Record<string, string>; | ||
| } |
There was a problem hiding this comment.
The refactoring of toProcessEnv significantly improves readability and adheres to the repository's best practice of reducing nesting. By filtering the environment variables before mapping them to asynchronous secret resolution, the code is more efficient and easier to follow. Additionally, changing the return type to Record<string, string> provides better type safety and aligns with the expectations of runUniversalMaker.
References
- Reduce nesting as much as possible. Code should avoid unnecessarily deep nesting or long periods of nesting. Handle edge cases early and exit or fold them into the general case.
Description
This is no longer required because Universal Maker fixed their bug related to copying files on top of each other.
Also, this cleans up the code for toProcessEnv
Scenarios Tested
Sample Commands