release.js
/**
 * @return {!Map<string, string>} entrypoints that should be generated for prod
 */
@return {!Map} entrypoints that should be generated for prod
@return { !Map } entrypoints that should be generated for prod
async function findProdPages() {
  const raw = await fsp.readFile('./static/src/strings/scenes.js', 'utf-8');
  const dictMatch = raw.match(/^export default (\{[^]*\})/m);
  if (!dictMatch) {
    throw new TypeError(`expected ./static/src/strings/scenes.js to contain "export default { ... }`);
  }
  const validInput = dictMatch[1].replace(/_msg`(\w+)`/g, (_, arg) => `'${arg}'`);
  const pages = JSON5.parse(validInput);
  if (!('index' in pages)) {
    pages['index'] = pages[''] || '';
  }
  for (const key of Object.keys(pages)) {
    if (key.startsWith('@')) {
      delete pages[key];
    } else if (DISABLED_SCENES.includes(key)) {
      delete pages[key];
    }
  }
  delete pages[''];  
  const diskScenes = (await fsp.readdir('./static/scenes')).filter((cand) => cand.match(/^[a-z  ]+/));
  for (const page of diskScenes) {
    if (!(page in pages)) {
      pages[page] = '';
    }
  }
  return pages;
}
async function findProdPages ( ) { const raw = await fsp . readFile ( './static/src/strings/scenes.js' , 'utf-8' ) ; const dictMatch = raw . match ( / ^export default (\{[^]*\}) / m ) ; if ( ! dictMatch ) { throw new TypeError ( ` ` ) ; } const validInput = dictMatch [ 1 ] . replace ( / _msg`(\w+)` / g , ( _ , arg ) => ` ${ arg } ` ) ; const pages = JSON5 . parse ( validInput ) ; if ( ! ( 'index' in pages ) ) { pages [ 'index' ] = pages [ '' ] || '' ; } for ( const key of Object . keys ( pages ) ) { if ( key . startsWith ( '@' ) ) { delete pages [ key ] ; } else if ( DISABLED_SCENES . includes ( key ) ) { delete pages [ key ] ; } } delete pages [ '' ] ; const diskScenes = ( await fsp . readdir ( './static/scenes' ) ) . filter ( ( cand ) => cand . match ( / ^[a-z  ]+ / ) ) ; for ( const page of diskScenes ) { if ( ! ( page in pages ) ) { pages [ page ] = '' ; } } return pages ; }
@return {!Map<string, string>} entrypoints that should be generated for prod
@return { !Map<string string > } entrypoints that should be generated for prod
// This is a bit gross but relies on this file to have an expected format. // nb. [^] matches anything _including_ newlines // Remove Android-only scenes. // don't explicitly generate blank top-level page // Find any pages we might be missing.