-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathgenerateMarkdownOutput.mjs
62 lines (51 loc) · 2.12 KB
/
generateMarkdownOutput.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2021, University of Colorado Boulder
import fs from 'fs';
/**
* List repos per developer
*
* Usage:
* cd root
* sage run phet-info/sim-info/generateMarkdownOutput.mjs
*
* @author Michael Kauzmann (PhET Interactive Simulations)
*/
const responsibleDevObject = JSON.parse( fs.readFileSync( './phet-info/sim-info/responsible_dev.json', 'utf8' ) );
const repos = Object.keys( responsibleDevObject );
let responsibleTableString = `
## HTML5 Sim and Common Code Repos - Developer/Designer Responsibility List
NOTE: This file is generated, do not edit directly. It is created from \`responsible_dev.json\`, see \`./generateMarkdownOutput.mjs\`.
| Simulation | Developer | Designer | Features |
| :---------- | :------------- | :------------- | :------------- |
`;
// look at the repo's package.json in phet.simFeatures and note selected features for the sim.
const getFeatures = repo => {
const features = [];
try {
const packageJSON = JSON.parse( fs.readFileSync( `./${repo}/package.json` ).toString() );
if ( packageJSON.phet && packageJSON.phet.simFeatures ) {
if ( packageJSON.phet.simFeatures.supportsSound ) {
features.push( 'Sound' );
}
if ( packageJSON.phet.simFeatures.supportsInteractiveDescription ) {
features.push( 'Interactive Description' );
}
if ( packageJSON.phet.simFeatures.supportsVoicing ) {
features.push( 'Voicing' );
}
if ( packageJSON.phet.simFeatures.supportsInteractiveHighlights ) {
features.push( 'Interactive Highlights' );
}
}
}
catch( e ) {
// some repos don't have package.json, and that's okay.
}
return features;
};
repos.forEach( repoName => {
const responsibleDeveloper = responsibleDevObject[ repoName ].responsibleDevs.join( ',' );
const responsibleDesigner = responsibleDevObject[ repoName ].responsibleDesigners.join( ',' );
const features = getFeatures( repoName ).join( '<br/>' );
responsibleTableString += `| ${repoName} | ${responsibleDeveloper} | ${responsibleDesigner} | ${features} | \n`;
} );
fs.writeFileSync( './phet-info/sim-info/responsible_dev.md', responsibleTableString );