From aa27ac65c50e88c070f3d5508d2cbf6a38a7c8da Mon Sep 17 00:00:00 2001 From: Jonathan Olson Date: Wed, 7 Feb 2024 17:22:21 -0700 Subject: [PATCH] Adding locale-sim-list, see https://github.com/phetsims/qa/issues/1036 --- js/scripts/locale-sim-list.js | 69 +++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 js/scripts/locale-sim-list.js diff --git a/js/scripts/locale-sim-list.js b/js/scripts/locale-sim-list.js new file mode 100644 index 00000000..2fd17ae9 --- /dev/null +++ b/js/scripts/locale-sim-list.js @@ -0,0 +1,69 @@ +// Copyright 2024, University of Colorado Boulder + +/** + * Prints out a report (with links) for active sims/translation for each locale + * + * @author Jonathan Olson + */ + +const localeInfo = require( '../../../chipper/js/data/localeInfo' ); +const simMetadata = require( '../common/simMetadata' ); +const winston = require( 'winston' ); + +winston.default.transports.console.level = 'error'; + +const production = process.argv.includes( '--production' ); +const phettest = process.argv.includes( '--phettest' ); +const local = process.argv.includes( '--local' ); + +const limitString = process.argv.find( arg => arg.startsWith( '--limit=' ) ); +const limit = limitString ? Number( limitString.substring( '--limit='.length ) ) : Number.POSITIVE_INFINITY; + +( async () => { + + const metadata = await simMetadata(); + + const simNamesByLocale = {}; + + metadata.projects.forEach( project => { + const simulations = project.simulations; + if ( simulations.length !== 1 ) { + throw new Error( 'Expected exactly one simulation per project in metadata' ); + } + + const simulation = simulations[ 0 ]; + const name = simulation.name; + const locales = Object.keys( simulation.localizedSimulations ); + + locales.forEach( locale => { + if ( !simNamesByLocale[ locale ] ) { + simNamesByLocale[ locale ] = []; + } + simNamesByLocale[ locale ].push( name ); + } ); + } ); + + // https://bayes.colorado.edu/dev/phettest/acid-base-solutions/acid-base-solutions_en.html?ea&brand=phet + + const locales = Object.keys( simNamesByLocale ).sort(); + + for ( const locale of locales ) { + + console.log( `## ${locale} (${localeInfo[ locale ].name})` ); + console.log( '' ); + simNamesByLocale[ locale ].slice( 0, Math.min( limit, simNamesByLocale[ locale ].length ) ).forEach( simName => { + const links = []; + if ( production ) { + links.push( `[production](https://phet.colorado.edu/sims/html/${simName}/latest/${simName}_all.html?locale=${locale})` ); + } + if ( phettest ) { + links.push( `[phettest](https://bayes.colorado.edu/dev/phettest/${simName}/${simName}_en.html?ea&brand=phet&locale=${locale})` ); + } + if ( local ) { + links.push( `[local](http://localhost/${simName}/${simName}_en.html?brand=phet&ea&debugger&locale=${locale})` ); + } + console.log( `- ${simName} ${links.join( ' ' )}` ); + } ); + console.log( '' ); + } +} )();