@@ -11,19 +11,18 @@ import { get } from "https";
11
11
import { join } from "path" ;
12
12
import { logAsyncOperation } from "../async/logAsyncOperation" ;
13
13
import { metadataPath , runtimeMetadata } from "./config" ;
14
- import { getLatestRelease } from "./getLatestReleases" ;
15
14
import { MetadataJSON } from "./types" ;
16
15
17
16
const MAX_DOWNLOAD_ATTEMPTS = 5 ;
18
17
19
- type Result = {
18
+ type ReleaseSpec = {
20
19
buildId : string ;
21
20
forkedVersion : string | null ;
22
21
} ;
23
22
24
- export const installLatestRelease = createAsyncFunctionWithTracking (
25
- async function installLatestRelease ( ) : Promise < Result | undefined > {
26
- logInfo ( "InstallLatestRelease :Start" ) ;
23
+ export const installRelease = createAsyncFunctionWithTracking (
24
+ async function installRelease ( releaseSpec : ReleaseSpec ) : Promise < ReleaseSpec | undefined > {
25
+ logInfo ( "InstallRelease :Start" ) ;
27
26
const runtimeBaseDir = getReplayPath ( "runtimes" ) ;
28
27
const runtimePath = getReplayPath ( "runtimes" , runtimeMetadata . destinationName ) ;
29
28
const downloadFilePath = getReplayPath ( "runtimes" , runtimeMetadata . downloadFileName ) ;
@@ -39,17 +38,17 @@ export const installLatestRelease = createAsyncFunctionWithTracking(
39
38
40
39
progress . setPending ( "Processing downloaded browser archive" ) ;
41
40
42
- logInfo ( "InstallLatestRelease :RemovingPreviousInstallation" , { runtimePath } ) ;
41
+ logInfo ( "InstallRelease :RemovingPreviousInstallation" , { runtimePath } ) ;
43
42
rmSync ( runtimePath , { force : true , recursive : true } ) ;
44
43
45
44
ensureDirSync ( runtimeBaseDir ) ;
46
45
47
- logInfo ( "InstallLatestRelease :WritingDownloadFile" , { downloadFilePath } ) ;
46
+ logInfo ( "InstallRelease :WritingDownloadFile" , { downloadFilePath } ) ;
48
47
writeFileSync ( downloadFilePath , buffers ) ;
49
48
50
49
extractBrowserArchive ( runtimeBaseDir , runtimePath ) ;
51
50
52
- logInfo ( "InstallLatestRelease :DeletingDownloadedFile" , { downloadFilePath } ) ;
51
+ logInfo ( "InstallRelease :DeletingDownloadedFile" , { downloadFilePath } ) ;
53
52
unlinkSync ( downloadFilePath ) ;
54
53
55
54
// This seems unnecessary, but we've always done it (and changing it would break legacy CLI compat)
@@ -62,28 +61,24 @@ export const installLatestRelease = createAsyncFunctionWithTracking(
62
61
) ;
63
62
}
64
63
65
- const latestRelease = await getLatestRelease ( ) ;
66
- const latestBuildId = latestRelease . buildId ;
67
- const latestVersion = latestRelease . version ;
68
-
69
64
// Write version metadata to disk so we can compare against the latest release and prompt to update
70
- logInfo ( "InstallLatestRelease :SavingMetadata" , { metadataPath } ) ;
65
+ logInfo ( "InstallRelease :SavingMetadata" , { metadataPath } ) ;
71
66
writeToCache < MetadataJSON > ( metadataPath , {
72
67
chromium : {
73
- buildId : latestBuildId ,
74
- forkedVersion : latestVersion ,
68
+ buildId : releaseSpec . buildId ,
69
+ forkedVersion : releaseSpec . forkedVersion ,
75
70
installDate : new Date ( ) . toISOString ( ) ,
76
71
} ,
77
72
} ) ;
78
73
79
74
progress . setSuccess ( "Replay browser has been updated." ) ;
80
75
81
76
return {
82
- buildId : latestBuildId ,
83
- forkedVersion : latestVersion ,
77
+ buildId : releaseSpec . buildId ,
78
+ forkedVersion : releaseSpec . forkedVersion ,
84
79
} ;
85
80
} catch ( error ) {
86
- logError ( "InstallLatestRelease :Failed" , { error } ) ;
81
+ logError ( "InstallRelease :Failed" , { error } ) ;
87
82
88
83
progress . setFailed ( "Something went wrong installing the Replay browser." ) ;
89
84
throw error ;
0 commit comments