-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding locale-sim-list, see phetsims/qa#1036
- Loading branch information
1 parent
bddc5b4
commit aa27ac6
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <jonathan.olson@colorado.edu> | ||
*/ | ||
|
||
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( '' ); | ||
} | ||
} )(); |