Skip to content

Conversation

gbockus-sf
Copy link
Contributor

What does this PR do?

Implements the readFileSync function in ZipTreeContainer.
I attempted to get this done without bringing in a third party module without success. Basically if TS/js wants to be sync/async there's no magic formula for getting around it. Also the zip module we are using unzipper has no support for reading a file synchronously.

This PR brings in the deasync module that gets around this problem by providing a non-js solution for making an async flow synchronous.

What issues does this PR fix or reference?

Required for fixing @W-10120433@

Functionality Before

readFileSync was not implemented for ZipTreeContainer

Functionality After

readFileSync is implemented for ZipTreeContainer. Have verified that it fixes the issues found in https://github.com/forcedotcom/salesforcedx-vscode by linking the updated module locally.

@gbockus-sf gbockus-sf requested review from a team as code owners February 28, 2022 20:40
@gbockus-sf gbockus-sf requested a review from randi274 February 28, 2022 20:40
v55 introduces the following new types. Here's their current level of support

|Metadata Type|Support|Notes|
|:---|:---|:---|
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure how this magic happens. commit flow I assume. Lemme know if I need to fix up something here.

"@salesforce/core": "^2.35.0",
"@salesforce/kit": "^1.5.32",
"@salesforce/ts-types": "^1.4.2",
"archiver": "^5.3.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the third party dependency that got the deal done. https://www.npmjs.com/package/deasync. MIT licensed and around 1M downloads a week so seemed a safe choice. I'm following up on what I need to do for 3PP land.

done = true;
throw error;
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This module covers doing exactly the ask here. Do something async but treat the current flow and synchronous.

@gbockus-sf gbockus-sf requested review from floralan and jag-j February 28, 2022 20:44
@gbockus-sf gbockus-sf merged commit da9c7ef into main Mar 2, 2022
@gbockus-sf gbockus-sf deleted the gbockus/implementReadFileSync branch March 2, 2022 21:27
gbockus-sf added a commit that referenced this pull request Mar 11, 2022
gbockus-sf added a commit that referenced this pull request Mar 11, 2022
* Revert "Implement readFileSync for ZipTreeContainer (#583)"

This reverts commit da9c7ef.

* chore: adding types for SDR
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