Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

feat: Retrieving translations from scanner and CLI #129

Closed
wants to merge 2 commits into from

Conversation

fabnguess
Copy link
Contributor

I'm doing this to get your feedback and also share a problem I encountered during implementation.

The issue suggests using the GitHub package to retrieve the target projects. The problem is that when I use downloadAndExtract to retrieve the scanner and cli packages, an error appears. I tested on quite a few of our packages and the problem recurred on some.

To be able to continue working, I used some packages where there were no problems, including utils and ossf-scorecard-sdk.

@PierreDemailly
Copy link
Member

PierreDemailly commented Mar 2, 2024

@fabnguess I bet your error is due to default branch.
Both cli & scanner have master as default while @nodesecure/github use main: const kDefaultBranch = "main";.

You need to add dlOptions (which are the github.downloadAndExtract options).
So we can use the master branch:

await fetchTranslations(["cli"], { branch: "master" });

Edit:
So we'll need to take care of the api because we wanna be allowing to pass the branch for any repo, i see 2 options:

await fetchTranslations([{ repo: "cli", branch: "master" }, { repo: "scanner", branch: "master" }]);

Or the chaining API as we discussed already

await i18n
  .repository("cli", { branch: "master" })
  .repository("scanner", { branch: "master" })
  .fetch()

@PierreDemailly
Copy link
Member

PierreDemailly commented Mar 2, 2024

@fraxken FYI when we pass the wrong branch the error is weird
image
It's because we keep doing createWriteStream even if the request fails, since the file is xx.tar.gz, it throws this error because he's waiting for gzip format
I'm not sure what we can do to prevent this

@fabnguess
Copy link
Contributor Author

@PierreDemailly, Indeed, the problem was due to the branch

@fabnguess fabnguess force-pushed the fetch_local_i18n_translations branch from be5f836 to 1b1b542 Compare March 2, 2024 21:06
@fraxken
Copy link
Member

fraxken commented Mar 2, 2024

This code is not intended to be shipped in the package. Everything is devDep and must be run as separated script.

index.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
scripts/fetchi18n.js Outdated Show resolved Hide resolved
scripts/fetchi18n.js Outdated Show resolved Hide resolved
scripts/fetchi18n.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
@fraxken
Copy link
Member

fraxken commented Mar 19, 2024

@fabnguess think to handle my review (you resolved some threads but the code didn't change, did you forget to push?)

@fabnguess
Copy link
Contributor Author

I'll do it by tonight

@fabnguess
Copy link
Contributor Author

Hi @fraxken ,
In our discussion with @PierreDemailly , we agreed to merge the contents of the language files from the target packages into the local language files rather than using the extendFromSystemPath API. I'm currently working on this aspect, but I can already submit my changes for your consideration.

@fabnguess fabnguess requested a review from fraxken March 19, 2024 18:17
@fabnguess fabnguess force-pushed the fetch_local_i18n_translations branch 2 times, most recently from 8d78384 to b59570f Compare July 16, 2024 16:03
index.js Outdated Show resolved Hide resolved
@fabnguess fabnguess force-pushed the fetch_local_i18n_translations branch 2 times, most recently from 4c61c5b to 5ebcd9d Compare July 16, 2024 19:12
@fraxken fraxken closed this Aug 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants