[Refactor] Modernize archiver utilities with async/await#7993
[Refactor] Modernize archiver utilities with async/await#7993gonzaloriestra wants to merge 1 commit into
Conversation
Refactored `zip` and `brotliCompress` in `packages/cli-kit` to use `async/await` syntax instead of manual `Promise` constructor wrappers and `.then()`/`.catch()` chains. This improves readability and maintainability while preserving the existing behavior of awaiting both the archive finalization and the output stream closure. - Replaced `.then()` chains with `await` in `zip` and `brotliCompress`. - Used a dedicated promise to bridge stream 'close'/'error' events with the async flow. - Added missing `@returns` JSDoc to `zip` to satisfy linting rules. - Removed unnecessary `eslint-disable` comments for floating promises.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationsWe found no new type declarations in this PR Existing type declarationspackages/cli-kit/dist/public/node/archiver.d.ts@@ -18,6 +18,7 @@ interface ZipOptions {
* Windows.
*
* @param options - ZipOptions.
+ * @returns A promise that resolves when the directory has been zipped.
*/
export declare function zip(options: ZipOptions): Promise<void>;
export interface BrotliOptions {
|
This PR refactors the archiving utilities in
@shopify/cli-kitto follow modern asynchronous patterns.Why:
The previous implementation used manual
Promisewrappers and.then()chains which were more verbose and harder to reason about. Moving toasync/awaitmakes the control flow clearer, especially when coordinating multiple asynchronous operations like globbing, file reading, and stream finalization.Changes:
zip: Now usesasync/awaitfor globbing and file addition. It waits forarchive.finalize()and the output stream'scloseevent before resolving.brotliCompress: Similarly modernized to useasync/awaitfor the internal tar archive creation step.@returnstozipJSDoc.How to test your changes?
CI. (Integration tests in
packages/cli-kit/src/public/node/archiver.integration.test.tscover these changes).PR created automatically by Jules for task 2020363541973881611 started by @gonzaloriestra