@@ -995,6 +995,21 @@ export class Registry {
995
995
return await validateDependenciesWindows ( sdkLanguage , windowsExeAndDllDirectories . map ( d => path . join ( browserDirectory , d ) ) ) ;
996
996
}
997
997
998
+ private async _validateMarkerFile ( descriptor : BrowsersJSONDescriptor ) {
999
+ const { revision, dir, name } = descriptor ;
1000
+
1001
+ const browserRevision = parseInt ( revision , 10 ) ;
1002
+ // Old browser installations don't have marker file.
1003
+ // We switched chromium from 999999 to 1000, 300000 is the new Y2K.
1004
+ const shouldHaveMarkerFile = ( name === 'chromium' && ( browserRevision >= 786218 || browserRevision < 300000 ) ) ||
1005
+ ( name === 'firefox' && browserRevision >= 1128 ) ||
1006
+ ( name === 'webkit' && browserRevision >= 1307 ) ||
1007
+ // All new applications have a marker file right away.
1008
+ ( name !== 'firefox' && name !== 'chromium' && name !== 'webkit' ) ;
1009
+
1010
+ return ! shouldHaveMarkerFile || ( await existsAsync ( browserDirectoryToMarkerFilePath ( dir ) ) ) ;
1011
+ }
1012
+
998
1013
async installDeps ( executablesToInstallDeps : Executable [ ] , dryRun : boolean ) {
999
1014
const executables = this . _dedupe ( executablesToInstallDeps ) ;
1000
1015
const targets = new Set < DependencyGroup > ( ) ;
@@ -1009,6 +1024,51 @@ export class Registry {
1009
1024
return await installDependenciesLinux ( targets , dryRun ) ;
1010
1025
}
1011
1026
1027
+ async list ( all ?: boolean ) {
1028
+ const linksDir = path . join ( registryDirectory , '.links' ) ;
1029
+ const links = new Set < string > ( ) ;
1030
+ links . add ( calculateSha1 ( PACKAGE_PATH ) ) ;
1031
+
1032
+ if ( all )
1033
+ ( await fs . promises . readdir ( linksDir ) ) . forEach ( link => links . add ( link ) ) ;
1034
+
1035
+ const browsersInfo : { target : string ; currentInstance : boolean ; browsers : { name : string ; version : string ; dir : string ; installationCompleted : boolean } [ ] } [ ] = [ ] ;
1036
+
1037
+ for ( const link of links ) {
1038
+ try {
1039
+ const linkTarget = ( await fs . promises . readFile ( path . join ( linksDir , link ) ) ) . toString ( ) ;
1040
+ const browsersJSON = require ( path . join ( linkTarget , 'browsers.json' ) ) ;
1041
+ const descriptors = readDescriptors ( browsersJSON ) ;
1042
+ const currentTargetBrowsers = [ ] ;
1043
+
1044
+ for ( const descriptor of descriptors ) {
1045
+ const { name, browserVersion, dir } = descriptor ;
1046
+ if ( ! isBrowserDirectory ( dir ) )
1047
+ continue ;
1048
+
1049
+ const doesExist = await existsAsync ( dir ) ;
1050
+ if ( ! doesExist )
1051
+ continue ;
1052
+
1053
+ currentTargetBrowsers . push ( {
1054
+ name,
1055
+ version : browserVersion || '' ,
1056
+ dir,
1057
+ installationCompleted : await this . _validateMarkerFile ( descriptor )
1058
+ } ) ;
1059
+ }
1060
+ browsersInfo . push ( {
1061
+ target : linkTarget ,
1062
+ browsers : currentTargetBrowsers ,
1063
+ currentInstance : linkTarget === PACKAGE_PATH ,
1064
+ } ) ;
1065
+
1066
+ } catch ( e ) { }
1067
+ }
1068
+
1069
+ return browsersInfo ;
1070
+ }
1071
+
1012
1072
async install ( executablesToInstall : Executable [ ] , forceReinstall : boolean ) {
1013
1073
const executables = this . _dedupe ( executablesToInstall ) ;
1014
1074
await fs . promises . mkdir ( registryDirectory , { recursive : true } ) ;
@@ -1257,15 +1317,8 @@ export class Registry {
1257
1317
if ( ! descriptor )
1258
1318
continue ;
1259
1319
const usedBrowserPath = descriptor . dir ;
1260
- const browserRevision = parseInt ( descriptor . revision , 10 ) ;
1261
- // Old browser installations don't have marker file.
1262
- // We switched chromium from 999999 to 1000, 300000 is the new Y2K.
1263
- const shouldHaveMarkerFile = ( browserName === 'chromium' && ( browserRevision >= 786218 || browserRevision < 300000 ) ) ||
1264
- ( browserName === 'firefox' && browserRevision >= 1128 ) ||
1265
- ( browserName === 'webkit' && browserRevision >= 1307 ) ||
1266
- // All new applications have a marker file right away.
1267
- ( browserName !== 'firefox' && browserName !== 'chromium' && browserName !== 'webkit' ) ;
1268
- if ( ! shouldHaveMarkerFile || ( await existsAsync ( browserDirectoryToMarkerFilePath ( usedBrowserPath ) ) ) )
1320
+
1321
+ if ( await this . _validateMarkerFile ( descriptor ) )
1269
1322
usedBrowserPaths . add ( usedBrowserPath ) ;
1270
1323
}
1271
1324
} catch ( e ) {
0 commit comments