Skip to content

Commit

Permalink
Move to tasks/, see #1459
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Sep 12, 2024
1 parent 022702a commit 96a28c1
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 48 deletions.
71 changes: 23 additions & 48 deletions js/grunt/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Minify-specific options:
'Generates top-level SIM-a11y-view.html file used for visualizing accessible content. Usually you should ' +
'set the "phet.simFeatures.supportsInteractiveDescription":true flag in the sim package.json and run `grunt update` ' +
'instead of manually generating this.',
wrapExecSync( `node ../chipper/js/grunt/tasks/generateA11yViewHTML.js --repo ${repo}` )
wrapExecSync( `node ../chipper/js/grunt/tasks/generate-a11y-view.js --repo ${repo}` )
);

grunt.registerTask( 'update', `
Expand All @@ -231,77 +231,49 @@ Updates the normal automatically-generated files for this repository. Includes:
'To support locales=* in unbuilt mode, generate a conglomerate JSON file for each repo with translations in babel. Run on all repos via:\n' +
'* for-each.sh perennial-alias/data/active-repos npm install\n' +
'* for-each.sh perennial-alias/data/active-repos grunt generate-development-strings',
wrapTask( async () => {
const generateDevelopmentStrings = require( '../scripts/generateDevelopmentStrings' );
const fs = require( 'fs' );

if ( fs.existsSync( `../${repo}/${repo}-strings_en.json` ) ) {
generateDevelopmentStrings( repo );
}
} )
wrapExecSync( `node ../chipper/js/grunt/tasks/generate-development-strings.js --repo ${repo}` )
);

grunt.registerTask( 'published-README',
'Generates README.md file for a published simulation.',
wrapTask( async () => {
const generateREADME = require( './generateREADME' ); // used by multiple tasks
await generateREADME( repo, true /* published */ );
} ) );
wrapExecSync( `node ../chipper/js/grunt/tasks/published-README.js --repo ${repo}` )
);

grunt.registerTask( 'unpublished-README',
'Generates README.md file for an unpublished simulation.',
wrapTask( async () => {
const generateREADME = require( './generateREADME' ); // used by multiple tasks
await generateREADME( repo, false /* published */ );
} ) );

grunt.registerTask( 'sort-imports', 'Sort the import statements for a single file (if --file={{FILE}} is provided), or does so for all JS files if not specified', wrapTask( async () => {
const sortImports = require( './sortImports' );

const file = grunt.option( 'file' );
wrapExecSync( `node ../chipper/js/grunt/tasks/unpublished-README.js --repo ${repo}` )
);

if ( file ) {
sortImports( file );
}
else {
grunt.file.recurse( `../${repo}/js`, absfile => sortImports( absfile ) );
}
} ) );
// TODO: https://github.com/phetsims/chipper/issues/1459 probably does not need to be here in grunt
grunt.registerTask( 'sort-imports', 'Sort the import statements for a single file (if --file={{FILE}} is provided), or does so for all JS files if not specified',
wrapExecSync( `node ../chipper/js/grunt/tasks/sort-imports.js --repo ${repo} ${process.argv.slice( 2 ).join( ' ' )}` )
);

// TODO: https://github.com/phetsims/chipper/issues/1459 probably does not need to be here in grunt
grunt.registerTask( 'commits-since',
'Shows commits since a specified date. Use --date=<date> to specify the date.',
wrapTask( async () => {
const dateString = grunt.option( 'date' );
assert( dateString, 'missing required option: --date={{DATE}}' );

const commitsSince = require( './commitsSince' );

await commitsSince( repo, dateString );
} ) );
wrapExecSync( `node ../chipper/js/grunt/tasks/commits-since.js --repo ${repo} ${process.argv.slice( 2 ).join( ' ' )}` ) // TODO: Just need date, or take everything? See https://github.com/phetsims/chipper/issues/1459
);

// See reportMedia.js
// TODO: https://github.com/phetsims/chipper/issues/1459 probably does not need to be here in grunt
grunt.registerTask( 'report-media',
'(project-wide) Report on license.json files throughout all working copies. ' +
'Reports any media (such as images or sound) files that have any of the following problems:\n' +
'(1) incompatible-license (resource license not approved)\n' +
'(2) not-annotated (license.json missing or entry missing from license.json)\n' +
'(3) missing-file (entry in the license.json but not on the file system)',
wrapTask( async () => {
const reportMedia = require( './reportMedia' );

await reportMedia( repo );
} ) );
wrapExecSync( `node ../chipper/js/grunt/tasks/report-media.js --repo ${repo}` )
);

// see reportThirdParty.js
// TODO: https://github.com/phetsims/chipper/issues/1459 probably does not need to be here in grunt
grunt.registerTask( 'report-third-party',
'Creates a report of third-party resources (code, images, sound, etc) used in the published PhET simulations by ' +
'reading the license information in published HTML files on the PhET website. This task must be run from main. ' +
'After running this task, you must push sherpa/third-party-licenses.md.',
wrapTask( async () => {
const reportThirdParty = require( './reportThirdParty' );

await reportThirdParty();
} ) );
wrapExecSync( `node ../chipper/js/grunt/tasks/report-third-party.js --repo ${repo}` )
);

grunt.registerTask( 'modulify', 'Creates *.js modules for all images/strings/audio/etc in a repo', wrapTask( async () => {
const modulify = require( './modulify' );
Expand Down Expand Up @@ -385,7 +357,9 @@ Updates the normal automatically-generated files for this repository. Includes:

// Notify about long transpile times, in case more people need to skip
if ( transpileTimeMS >= 5000 ) {
grunt.log.writeln( `generate-phet-io-api transpilation took ${transpileTimeMS} ms` );
grunt.log.writeln(
`generate-phet-io-api transpilation took ${transpileTimeMS} ms`
);
}
}
else {
Expand Down Expand Up @@ -460,6 +434,7 @@ Updates the normal automatically-generated files for this repository. Includes:
} )
);

// TODO: https://github.com/phetsims/chipper/issues/1459 probably does not need to be here in grunt
grunt.registerTask(
'profile-file-size',
'Profiles the file size of the built JS file for a given repo',
Expand Down
17 changes: 17 additions & 0 deletions js/grunt/tasks/commits-since.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2024, University of Colorado Boulder

const getRequiredArg = require( './getRequiredArg' );

/**
* @author Sam Reid (PhET Interactive Simulations)
*/
const grunt = require( 'grunt' );
const repo = getRequiredArg( '--repo' );

const dateString = grunt.option( 'date' );
assert( dateString, 'missing required option: --date={{DATE}}' );

const commitsSince = require( '../commitsSince' );
const assert = require( 'assert' );

await commitsSince( repo, dateString );
15 changes: 15 additions & 0 deletions js/grunt/tasks/generate-development-strings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2024, University of Colorado Boulder

const getRequiredArg = require( './getRequiredArg' );

/**
* @author Sam Reid (PhET Interactive Simulations)
*/
const repo = getRequiredArg( '--repo' );

const generateDevelopmentStrings = require( '../../scripts/generateDevelopmentStrings' );
const fs = require( 'fs' );

if ( fs.existsSync( `../${repo}/${repo}-strings_en.json` ) ) {
generateDevelopmentStrings( repo );
}
13 changes: 13 additions & 0 deletions js/grunt/tasks/published-README.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2024, University of Colorado Boulder

const getRequiredArg = require( './getRequiredArg' );

/**
* @author Sam Reid (PhET Interactive Simulations)
*/
const repo = getRequiredArg( '--repo' );

const generateREADME = require( './generateREADME' ); // used by multiple tasks
( async () => {
await generateREADME( repo, true /* published */ );
} )();
14 changes: 14 additions & 0 deletions js/grunt/tasks/report-media.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2024, University of Colorado Boulder

const getRequiredArg = require( './getRequiredArg' );

/**
* @author Sam Reid (PhET Interactive Simulations)
*/
const repo = getRequiredArg( '--repo' );

const reportMedia = require( './reportMedia' );

( () => {
await reportMedia( repo );
} )();
10 changes: 10 additions & 0 deletions js/grunt/tasks/report-third-party.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright 2024, University of Colorado Boulder

/**
* @author Sam Reid (PhET Interactive Simulations)
*/
( () => {
const reportThirdParty = require( '../reportThirdParty' );

await reportThirdParty();
} )();
20 changes: 20 additions & 0 deletions js/grunt/tasks/sort-imports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2024, University of Colorado Boulder

const getRequiredArg = require( './getRequiredArg' );

/**
* @author Sam Reid (PhET Interactive Simulations)
*/
const grunt = require( 'grunt' );
const repo = getRequiredArg( '--repo' );

const sortImports = require( './sortImports' );

const file = grunt.option( 'file' );

if ( file ) {
sortImports( file );
}
else {
grunt.file.recurse( `../${repo}/js`, absfile => sortImports( absfile ) );
}
13 changes: 13 additions & 0 deletions js/grunt/tasks/unpublished-README.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2024, University of Colorado Boulder

const getRequiredArg = require( './getRequiredArg' );

/**
* @author Sam Reid (PhET Interactive Simulations)
*/
const repo = getRequiredArg( '--repo' );

const generateREADME = require( './generateREADME' ); // used by multiple tasks
( async () => {
await generateREADME( repo, false /* published */ );
} )();

0 comments on commit 96a28c1

Please sign in to comment.