66 * found in the LICENSE file at https://angular.io/license
77 */
88
9- import { resolveBuildId , Browser , BrowserPlatform } from " @puppeteer/browsers" ;
10- import { mkdtemp } from " node:fs/promises" ;
11- import os from " node:os" ;
12- import path from " node:path" ;
13- import { downloadAndHashBinariesForBrowser } from " ./download.mjs" ;
9+ import { resolveBuildId , Browser , BrowserPlatform } from ' @puppeteer/browsers' ;
10+ import { mkdtemp } from ' node:fs/promises' ;
11+ import os from ' node:os' ;
12+ import path from ' node:path' ;
13+ import { downloadAndHashBinariesForBrowser } from ' ./download.mjs' ;
1414import {
1515 generateRepoInfo ,
1616 generateVersionsBzlFile ,
1717 Versions ,
18- } from " ./generation.mjs" ;
19- import fs from " node:fs/promises" ;
20- import { getChromeMilestones , getFirefoxMilestones } from " ./versions.mjs" ;
18+ } from ' ./generation.mjs' ;
19+ import fs from ' node:fs/promises' ;
20+ import { getChromeMilestones , getFirefoxMilestones } from ' ./versions.mjs' ;
2121
2222main ( ) . catch ( ( e ) => {
2323 console . error ( e ) ;
@@ -36,7 +36,7 @@ interface WriteVersionsOptions {
3636// We treat chrome-headless-shell as Chromium in the module. This function
3737// ensures browser name is written to files as expected.
3838function getReadableBrowserName ( browser : Browser ) : string {
39- return browser === Browser . CHROMEHEADLESSSHELL ? " chromium" : browser ;
39+ return browser === Browser . CHROMEHEADLESSSHELL ? ' chromium' : browser ;
4040}
4141
4242async function downloadMilestonesAndWriteVersionsFiles ( {
@@ -50,20 +50,20 @@ async function downloadMilestonesAndWriteVersionsFiles({
5050 buildIdToVersion = buildIdToVersion ?? ( ( buildId ) => buildId ) ;
5151
5252 const buildIds = await Promise . all (
53- milestones . map ( ( milestone ) => resolveBuildId ( browser , null ! , milestone ) )
53+ milestones . map ( ( milestone ) => resolveBuildId ( browser , null ! , milestone ) ) ,
5454 ) ;
5555
5656 const fileBasePath = path . join (
5757 workspaceRoot ,
58- " browsers/private/versions" ,
59- getReadableBrowserName ( browser )
58+ ' browsers/private/versions' ,
59+ getReadableBrowserName ( browser ) ,
6060 ) ;
6161 // We keep a JSON file around that only holds the versions without any of the
6262 // additional content in the `.bzl` file. This enables merging of existing
6363 // versions with newly fetched one's without having to do string gymnastics on
6464 // the `.bzl` file.
65- const jsonFilePath = fileBasePath + " .json" ;
66- const bzlFilePath = fileBasePath + " .bzl" ;
65+ const jsonFilePath = fileBasePath + ' .json' ;
66+ const bzlFilePath = fileBasePath + ' .bzl' ;
6767
6868 let versions : Versions = { } ;
6969
@@ -72,19 +72,19 @@ async function downloadMilestonesAndWriteVersionsFiles({
7272 // same milestone. If the new version has a different build ID, we will
7373 // provide both versions. Otherwise the old version will remain.
7474 try {
75- const currentVersionsRaw = await fs . readFile ( jsonFilePath , " utf8" ) ;
75+ const currentVersionsRaw = await fs . readFile ( jsonFilePath , ' utf8' ) ;
7676 const currentVersions = JSON . parse ( currentVersionsRaw ) as Versions ;
7777 versions = currentVersions ;
7878 } catch ( err : unknown ) {
79- console . warn ( " Failed to read versions JSON file:" , ( err as Error ) . message ) ;
79+ console . warn ( ' Failed to read versions JSON file:' , ( err as Error ) . message ) ;
8080 }
8181
8282 // Don't download versions we downloaded previously again. This would not
8383 // catch cases where the binaries under an existing build ID changes, although
8484 // this should ideally never happen (at least for Chrome).
8585 const existingVersions = new Set ( Object . keys ( versions ) ) ;
8686 const filteredNewBuildIds = buildIds . filter (
87- ( buildId ) => ! existingVersions . has ( buildIdToVersion ( buildId ) )
87+ ( buildId ) => ! existingVersions . has ( buildIdToVersion ( buildId ) ) ,
8888 ) ;
8989
9090 // Fetch the binaries for each build ID. The only reason we do this is to
@@ -96,9 +96,9 @@ async function downloadMilestonesAndWriteVersionsFiles({
9696 browser ,
9797 buildId ,
9898 { } ,
99- excludeFilesForPerformance
100- )
101- )
99+ excludeFilesForPerformance ,
100+ ) ,
101+ ) ,
102102 ) ;
103103
104104 for ( const binariesForBuild of binariesForBuilds ) {
@@ -118,14 +118,14 @@ async function downloadMilestonesAndWriteVersionsFiles({
118118 generateVersionsBzlFile (
119119 getReadableBrowserName ( browser ) ,
120120 defaultVersion ,
121- versions
122- )
121+ versions ,
122+ ) ,
123123 ) ;
124124}
125125
126126async function main ( ) {
127- const tmpDir = await mkdtemp ( path . join ( os . tmpdir ( ) , " rules_browsers_tmp-" ) ) ;
128- const workspaceRoot = process . env [ " BUILD_WORKING_DIRECTORY" ] ! ;
127+ const tmpDir = await mkdtemp ( path . join ( os . tmpdir ( ) , ' rules_browsers_tmp-' ) ) ;
128+ const workspaceRoot = process . env [ ' BUILD_WORKING_DIRECTORY' ] ! ;
129129
130130 // Fetch the last 15 milestones for each browser. This is mostly relevant when
131131 // browsers haven't been updated in a long time and we want to backfill. All
@@ -143,10 +143,10 @@ async function main() {
143143 workspaceRoot,
144144 excludeFilesForPerformance : {
145145 // Exclude log files that Chrome might write to— causing remote cache misses.
146- [ BrowserPlatform . LINUX ] : [ " **/*.log" ] ,
147- [ BrowserPlatform . MAC ] : [ " **/*.log" ] ,
148- [ BrowserPlatform . MAC_ARM ] : [ " **/*.log" ] ,
149- [ BrowserPlatform . WIN64 ] : [ " **/*.log" ] ,
146+ [ BrowserPlatform . LINUX ] : [ ' **/*.log' ] ,
147+ [ BrowserPlatform . MAC ] : [ ' **/*.log' ] ,
148+ [ BrowserPlatform . MAC_ARM ] : [ ' **/*.log' ] ,
149+ [ BrowserPlatform . WIN64 ] : [ ' **/*.log' ] ,
150150 } ,
151151 } ) ,
152152 downloadMilestonesAndWriteVersionsFiles ( {
@@ -162,9 +162,9 @@ async function main() {
162162 workspaceRoot,
163163 // We want Firefox to be addressable with "120.0" instead of
164164 // "stable_120.0", so we rewrite the build ID.
165- buildIdToVersion : ( buildId : string ) => buildId . replace ( / ^ s t a b l e _ / , "" ) ,
165+ buildIdToVersion : ( buildId : string ) => buildId . replace ( / ^ s t a b l e _ / , '' ) ,
166166 } ) ,
167167 ] ) ;
168168
169- await fs . rm ( tmpDir , { recursive : true , maxRetries : 2 } ) ;
169+ await fs . rm ( tmpDir , { recursive : true , maxRetries : 2 } ) ;
170170}
0 commit comments