diff --git a/js/grunt/Gruntfile.js b/js/grunt/Gruntfile.js index 3e1bb797..c0fdf4e1 100644 --- a/js/grunt/Gruntfile.js +++ b/js/grunt/Gruntfile.js @@ -12,11 +12,10 @@ const assert = require( 'assert' ); require( './checkNodeVersion' ); const { spawn } = require( 'child_process' ); // eslint-disable-line require-statement-match -const getPhetLibs = require( './getPhetLibs' ); // TODO: Will ctrl-c correctly kill spawned tasks? https://github.com/phetsims/chipper/issues/1459 -// Allow other Gruntfiles to potentially handle exiting and errors differently` +// Allow other Gruntfiles to potentially handle exiting and errors differently if ( !global.processEventOptOut ) { // See https://medium.com/@dtinth/making-unhandled-promise-rejections-crash-the-node-js-process-ffc27cfcc9dd for how @@ -38,30 +37,23 @@ module.exports = function( grunt ) { assert( typeof repo === 'string' && /^[a-z]+(-[a-z]+)*$/u.test( repo ), 'repo name should be composed of lower-case characters, optionally with dashes used as separators' ); // TODO: This is working well but should we use execute? Let's chat: https://github.com/phetsims/chipper/issues/1459 - function wrapExecSync( line ) { + function execTask( taskFilename ) { - const command = line.split( ' ' )[ 0 ]; - const args = line.split( ' ' ).slice( 1 ); + // TODO switch to npx tsx, see https://github.com/phetsims/chipper/issues/1459 via npx ../chipper/node_modules/tsx + // TODO: test on windows, see https://github.com/phetsims/chipper/issues/1459 + const command = 'node'; return () => { const done = grunt.task.current.async(); try { - const child = spawn( command, args, { stdio: [ 'inherit', 'pipe', 'pipe' ] } ); + const child = spawn( command, [ `../chipper/js/grunt/tasks/${taskFilename}`, ...process.argv.slice( 2 ) ], { stdio: [ 'inherit', 'pipe', 'pipe' ] } ); - // Stream stdout - child.stdout.on( 'data', data => { - process.stdout.write( data.toString() ); - } ); - - // Stream stderr - child.stderr.on( 'data', data => { - process.stderr.write( data.toString() ); - } ); + child.stdout.on( 'data', data => process.stdout.write( data.toString() ) ); + child.stderr.on( 'data', data => process.stderr.write( data.toString() ) ); // Listen for the close event when the command finishes child.on( 'close', code => { - done(); if ( code !== 0 ) { grunt.fail.fatal( `Command failed with exit code ${code}` ); @@ -84,22 +76,22 @@ module.exports = function( grunt ) { // TODO: https://github.com/phetsims/chipper/issues/1459 running grunt requires that we register tasks, otherwise it fails out. Is that ok? grunt.registerTask( 'clean', 'Erases the build/ directory and all its contents, and recreates the build/ directory', - wrapExecSync( `node ../chipper/js/grunt/tasks/clean.js --repo ${repo}` ) + execTask( 'clean.js' ) ); grunt.registerTask( 'build-images', 'Build images only', - wrapExecSync( `node ../chipper/js/grunt/tasks/build-images.js --repo ${repo}` ) + execTask( 'build-images.js' ) ); grunt.registerTask( 'output-js', 'Outputs JS just for the specified repo', - wrapExecSync( `node ../chipper/js/grunt/tasks/output-js.js --repo ${repo}` ) + execTask( 'output-js.js' ) ); grunt.registerTask( 'output-js-project', 'Outputs JS for the specified repo and its dependencies', - wrapExecSync( `node ../chipper/js/grunt/tasks/output-js-project.js --repos ${getPhetLibs( repo ).join( ',' )}` ) + execTask( 'output-js-project.js' ) ); grunt.registerTask( 'output-js-all', 'Outputs JS for all repos', - wrapExecSync( 'node ../chipper/js/grunt/tasks/output-js-all.js' ) + execTask( '-js-all.js' ) ); grunt.registerTask( 'build', @@ -121,14 +113,13 @@ Minify-specific options: --minify.mangle=false - During uglification, it will not "mangle" variable names (where they get renamed to short constants to reduce file size.) --minify.beautify=true - After uglification, the source code will be syntax formatted nicely --minify.stripAssertions=false - During uglification, it will strip assertions. - --minify.stripLogging=false - During uglification, it will not strip logging statements. - `, - wrapExecSync( `node ../chipper/js/grunt/tasks/build.js --repo ${repo} ${process.argv.slice( 2 ).join( ' ' )}` ) + --minify.stripLogging=false - During uglification, it will not strip logging statements.`, + execTask( 'build.js' ) ); grunt.registerTask( 'generate-used-strings-file', 'Writes used strings to phet-io-sim-specific/ so that PhET-iO sims only output relevant strings to the API in unbuilt mode', - wrapExecSync( `node ../chipper/js/grunt/tasks/generate-used-strings-file.js --repo ${repo}` ) + execTask( 'generate-used-strings-file.js' ) ); grunt.registerTask( 'build-for-server', 'meant for use by build-server only', @@ -141,30 +132,30 @@ Minify-specific options: --fix: autofixable changes will be written to disk --chip-away: output a list of responsible devs for each repo with lint problems --repos: comma separated list of repos to lint in addition to the repo from running`, - wrapExecSync( `node ../chipper/js/grunt/tasks/lint.js --repo ${repo} ${process.argv.slice( 2 ).join( ' ' )}` ) + execTask( 'lint.js' ) ); grunt.registerTask( 'lint-all', 'lint all js files that are required to build this repository (for the specified brands)', - wrapExecSync( `node ../chipper/js/grunt/tasks/lint-all.js --repo ${repo} ${process.argv.slice( 2 ).join( ' ' )}` ) + execTask( 'lint-all.js' ) ); grunt.registerTask( 'generate-development-html', 'Generates top-level SIM_en.html file based on the preloads in package.json.', - wrapExecSync( `node ../chipper/js/grunt/tasks/generate-development-html.js --repo ${repo}` ) + execTask( 'generate-development-html.js' ) ); grunt.registerTask( 'generate-test-html', 'Generates top-level SIM-tests.html file based on the preloads in package.json. See https://github.com/phetsims/aqua/blob/main/doc/adding-unit-tests.md ' + 'for more information on automated testing. Usually you should ' + 'set the "generatedUnitTests":true flag in the sim package.json and run `grunt update` instead of manually generating this.', - wrapExecSync( `node ../chipper/js/grunt/tasks/generate-test-html.js --repo ${repo}` ) + execTask( 'generate-test-html.js' ) ); grunt.registerTask( 'generate-a11y-view-html', '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/generate-a11y-view.js --repo ${repo}` ) + execTask( 'generate-a11y-view.js' ) ); grunt.registerTask( 'update', ` @@ -175,7 +166,7 @@ Updates the normal automatically-generated files for this repository. Includes: * simulations: generateREADME() * phet-io simulations: generate overrides file if needed * create the conglomerate string files for unbuilt mode, for this repo and its dependencies`, - wrapExecSync( `node ../chipper/js/grunt/tasks/update.js --repo ${repo}` ) + execTask( 'update.js' ) ); // This is not run in grunt update because it affects dependencies and outputs files outside of the repo. @@ -183,28 +174,27 @@ 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', - wrapExecSync( `node ../chipper/js/grunt/tasks/generate-development-strings.js --repo ${repo}` ) + execTask( 'generate-development-strings.js' ) ); grunt.registerTask( 'published-README', 'Generates README.md file for a published simulation.', - wrapExecSync( `node ../chipper/js/grunt/tasks/published-README.js --repo ${repo}` ) + execTask( 'published-README.js' ) ); grunt.registerTask( 'unpublished-README', 'Generates README.md file for an unpublished simulation.', - wrapExecSync( `node ../chipper/js/grunt/tasks/unpublished-README.js --repo ${repo}` ) + execTask( 'unpublished-README.js' ) ); // 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( ' ' )}` ) + execTask( 'sort-imports.js' ) ); // 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= to specify the date.', - 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 + grunt.registerTask( 'commits-since', 'Shows commits since a specified date. Use --date= to specify the date.', + execTask( 'commits-since.js' ) ); // See reportMedia.js @@ -215,7 +205,7 @@ Updates the normal automatically-generated files for this repository. Includes: '(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)', - wrapExecSync( `node ../chipper/js/grunt/tasks/report-media.js --repo ${repo}` ) + execTask( 'report-media.js' ) ); // see reportThirdParty.js @@ -224,19 +214,17 @@ Updates the normal automatically-generated files for this repository. Includes: '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.', - wrapExecSync( `node ../chipper/js/grunt/tasks/report-third-party.js --repo ${repo}` ) + execTask( 'report-third-party.js' ) ); grunt.registerTask( 'modulify', 'Creates *.js modules for all images/strings/audio/etc in a repo', - wrapExecSync( `node ../chipper/js/grunt/tasks/modulify.js --repo ${repo}` ) + execTask( 'modulify.js' ) ); // Grunt task that determines created and last modified dates from git, and // updates copyright statements accordingly, see #403 - grunt.registerTask( - 'update-copyright-dates', - 'Update the copyright dates in JS source files based on Github dates', - wrapExecSync( `node ../chipper/js/grunt/tasks/update-copyright-dates.js --repo ${repo}` ) + grunt.registerTask( 'update-copyright-dates', 'Update the copyright dates in JS source files based on Github dates', + execTask( 'update-copyright-dates.js' ) ); // TODO: https://github.com/phetsims/chipper/issues/1459 probably does not need to be here in grunt @@ -277,7 +265,7 @@ Updates the normal automatically-generated files for this repository. Includes: '--stable - regenerate for all "stable sims" (see perennial/data/phet-io-api-stable/)\n' + '--temporary - outputs to the temporary directory\n' + '--transpile=false - skips the transpilation step. You can skip transpilation if a watch process is handling it.', - wrapExecSync( `node ../chipper/js/grunt/tasks/generate-phet-io-api.js --repo ${repo} ${process.argv.slice( 2 ).join( ' ' )}` ) + execTask( 'generate-phet-io-api.js' ) ); grunt.registerTask( @@ -290,12 +278,12 @@ Updates the normal automatically-generated files for this repository. Includes: '--delta, by default a breaking-compatibility comparison is done, but --delta shows all changes\n' + '--temporary, compares API files in the temporary directory (otherwise compares to freshly generated APIs)\n' + '--compareBreakingAPIChanges - add this flag to compare breaking changes in addition to designed changes', - wrapExecSync( `node ../chipper/js/grunt/tasks/compare-phet-io-api.js --repo ${repo} ${process.argv.slice( 2 ).join( ' ' )}` ) + execTask( 'compare-phet-io-api.js' ) ); // 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', - wrapExecSync( `node ../chipper/js/grunt/tasks/profile-file-size.js --repo ${repo}` ) + execTask( 'profile-file-size.js' ) ); /** diff --git a/js/grunt/tasks/build-images.js b/js/grunt/tasks/build-images.js index 6c06a55c..8a46709a 100644 --- a/js/grunt/tasks/build-images.js +++ b/js/grunt/tasks/build-images.js @@ -4,7 +4,7 @@ * @author Sam Reid (PhET Interactive Simulations) */ const grunt = require( 'grunt' ); -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); const jimp = require( 'jimp' ); const generateThumbnails = require( '../generateThumbnails' ); @@ -12,7 +12,7 @@ const generateTwitterCard = require( '../generateTwitterCard' ); const brand = 'phet'; -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); ( async () => { const buildDir = `../${repo}/build/${brand}`; diff --git a/js/grunt/tasks/build.js b/js/grunt/tasks/build.js index 10975ba5..d57a69a8 100644 --- a/js/grunt/tasks/build.js +++ b/js/grunt/tasks/build.js @@ -15,13 +15,13 @@ const getPhetLibs = require( '../getPhetLibs' ); const phetTimingLog = require( '../../../../perennial-alias/js/common/phetTimingLog' ); const grunt = require( 'grunt' ); -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); const assert = require( 'assert' ); const Transpiler = require( '../../common/Transpiler' ); const getBrands = require( './getBrands' ); const parseGruntOptions = require( './parseGruntOptions' ); -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); // Initialize Grunt options with parsed arguments // Call this before getBrands diff --git a/js/grunt/tasks/clean.js b/js/grunt/tasks/clean.js index f99cfe2c..b06cefd8 100644 --- a/js/grunt/tasks/clean.js +++ b/js/grunt/tasks/clean.js @@ -1,12 +1,12 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ const grunt = require( 'grunt' ); -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const buildDirectory = `../${repo}/build`; diff --git a/js/grunt/tasks/commits-since.js b/js/grunt/tasks/commits-since.js index 2475d239..f58abdc5 100644 --- a/js/grunt/tasks/commits-since.js +++ b/js/grunt/tasks/commits-since.js @@ -1,12 +1,12 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ const grunt = require( 'grunt' ); -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const parseGruntOptions = require( './parseGruntOptions' ); // Initialize Grunt options with parsed arguments diff --git a/js/grunt/tasks/compare-phet-io-api.js b/js/grunt/tasks/compare-phet-io-api.js index 330fdac5..a99107f8 100644 --- a/js/grunt/tasks/compare-phet-io-api.js +++ b/js/grunt/tasks/compare-phet-io-api.js @@ -1,12 +1,12 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ const grunt = require( 'grunt' ); -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const parseGruntOptions = require( './parseGruntOptions' ); diff --git a/js/grunt/tasks/generate-a11y-view-html.js b/js/grunt/tasks/generate-a11y-view-html.js index a519e661..0f7f3561 100644 --- a/js/grunt/tasks/generate-a11y-view-html.js +++ b/js/grunt/tasks/generate-a11y-view-html.js @@ -1,11 +1,11 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const generateA11yViewHTML = require( '../generateA11yViewHTML' ); ( async () => { diff --git a/js/grunt/tasks/generate-development-html.js b/js/grunt/tasks/generate-development-html.js index 532ef428..ced6833c 100644 --- a/js/grunt/tasks/generate-development-html.js +++ b/js/grunt/tasks/generate-development-html.js @@ -1,11 +1,11 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const generateDevelopmentHTML = require( '../generateDevelopmentHTML' ); ( async () => { diff --git a/js/grunt/tasks/generate-development-strings.js b/js/grunt/tasks/generate-development-strings.js index ef68cefa..825644d2 100644 --- a/js/grunt/tasks/generate-development-strings.js +++ b/js/grunt/tasks/generate-development-strings.js @@ -1,11 +1,11 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const generateDevelopmentStrings = require( '../../scripts/generateDevelopmentStrings' ); const fs = require( 'fs' ); diff --git a/js/grunt/tasks/generate-phet-io-api.js b/js/grunt/tasks/generate-phet-io-api.js index 04c01b37..1a57b2dd 100644 --- a/js/grunt/tasks/generate-phet-io-api.js +++ b/js/grunt/tasks/generate-phet-io-api.js @@ -1,12 +1,12 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ const grunt = require( 'grunt' ); -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const formatPhetioAPI = require( '../../phet-io/formatPhetioAPI' ); const getSimList = require( '../../common/getSimList' ); diff --git a/js/grunt/tasks/generate-test-html.js b/js/grunt/tasks/generate-test-html.js index 9052559e..6d1de8b5 100644 --- a/js/grunt/tasks/generate-test-html.js +++ b/js/grunt/tasks/generate-test-html.js @@ -1,11 +1,11 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const generateTestHTML = require( '../generateTestHTML' ); ( async () => { diff --git a/js/grunt/tasks/generate-used-strings-file.js b/js/grunt/tasks/generate-used-strings-file.js index 4bb44dea..8b346b70 100644 --- a/js/grunt/tasks/generate-used-strings-file.js +++ b/js/grunt/tasks/generate-used-strings-file.js @@ -1,11 +1,11 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const getPhetLibs = require( '../getPhetLibs' ); const fs = require( 'fs' ); diff --git a/js/grunt/tasks/getRepo.js b/js/grunt/tasks/getRepo.js new file mode 100644 index 00000000..9481649e --- /dev/null +++ b/js/grunt/tasks/getRepo.js @@ -0,0 +1,20 @@ +// Copyright 2024, University of Colorado Boulder + +/** + * @author Sam Reid (PhET Interactive Simulations) + */ +const grunt = require( 'grunt' ); +const parseGruntOptions = require( './parseGruntOptions' ); +const assert = require( 'assert' ); + +module.exports = () => { + + grunt.option.init( parseGruntOptions() ); + + const packageObject = grunt.file.readJSON( 'package.json' ); + + const repo = grunt.option( 'repo' ) || packageObject.name; + assert( typeof repo === 'string' && /^[a-z]+(-[a-z]+)*$/u.test( repo ), 'repo name should be composed of lower-case characters, optionally with dashes used as separators' ); + + return repo; +}; \ No newline at end of file diff --git a/js/grunt/tasks/getRequiredArg.js b/js/grunt/tasks/getRequiredArg.js deleted file mode 100644 index 19474477..00000000 --- a/js/grunt/tasks/getRequiredArg.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2024, University of Colorado Boulder - -/** - * @author Sam Reid (PhET Interactive Simulations) - */ -module.exports = argName => { - const args = process.argv.slice( 2 ); - const argIndex = args.indexOf( argName ); - - // Ensure the argument is provided - if ( argIndex === -1 ) { - throw new Error( `No ${argName} argument provided.` ); - } - -// Ensure a repository name is provided after --repo - const repo = args[ argIndex + 1 ]; - if ( !repo ) { - throw new Error( 'Repository name missing. Usage: --repo ' ); - } - - return repo; -}; \ No newline at end of file diff --git a/js/grunt/tasks/lint-all.js b/js/grunt/tasks/lint-all.js index d769f8d0..f1c4ca17 100644 --- a/js/grunt/tasks/lint-all.js +++ b/js/grunt/tasks/lint-all.js @@ -1,6 +1,6 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); const getBrands = require( './getBrands' ); const assert = require( 'assert' ); @@ -8,7 +8,7 @@ const assert = require( 'assert' ); * @author Sam Reid (PhET Interactive Simulations) */ const grunt = require( 'grunt' ); -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const lint = require( '../lint' ); diff --git a/js/grunt/tasks/lint.js b/js/grunt/tasks/lint.js index 97b7711e..b5f5d0eb 100644 --- a/js/grunt/tasks/lint.js +++ b/js/grunt/tasks/lint.js @@ -4,10 +4,10 @@ * @author Sam Reid (PhET Interactive Simulations) */ const grunt = require( 'grunt' ); -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); const lint = require( '../lint' ); -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const parseGruntOptions = require( './parseGruntOptions' ); diff --git a/js/grunt/tasks/modulify.js b/js/grunt/tasks/modulify.js index 1ff8423f..3cc72047 100644 --- a/js/grunt/tasks/modulify.js +++ b/js/grunt/tasks/modulify.js @@ -1,11 +1,11 @@ // Copyright 2024, University of Colorado Boulder // TODO: Name to avoid collision with other modulify? See https://github.com/phetsims/chipper/issues/1459 -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const modulify = require( '../modulify' ); const generateDevelopmentStrings = require( '../../scripts/generateDevelopmentStrings' ); diff --git a/js/grunt/tasks/output-js-project.js b/js/grunt/tasks/output-js-project.js index 6f9bda5b..0e2b59c4 100644 --- a/js/grunt/tasks/output-js-project.js +++ b/js/grunt/tasks/output-js-project.js @@ -1,13 +1,15 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const grunt = require( 'grunt' ); /** * @author Sam Reid (PhET Interactive Simulations) */ const Transpiler = require( '../../common/Transpiler' ); +const parseGruntOptions = require( './parseGruntOptions' ); const transpiler = new Transpiler( { silent: true } ); -const repos = getRequiredArg( '--repos' ); +grunt.option.init( parseGruntOptions() ); +const repos = grunt.option( 'repos' ); transpiler.transpileRepo( repos.split( ',' ) ); \ No newline at end of file diff --git a/js/grunt/tasks/output-js.js b/js/grunt/tasks/output-js.js index 7dd48df6..e4a88240 100644 --- a/js/grunt/tasks/output-js.js +++ b/js/grunt/tasks/output-js.js @@ -1,6 +1,6 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) @@ -8,6 +8,6 @@ const getRequiredArg = require( './getRequiredArg' ); const Transpiler = require( '../../common/Transpiler' ); const transpiler = new Transpiler( { silent: true } ); -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); transpiler.transpileRepo( repo ); \ No newline at end of file diff --git a/js/grunt/tasks/profile-file-size.js b/js/grunt/tasks/profile-file-size.js index c21fb4d1..6ef11c6c 100644 --- a/js/grunt/tasks/profile-file-size.js +++ b/js/grunt/tasks/profile-file-size.js @@ -1,11 +1,11 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const profileFileSize = require( '../grunt/profileFileSize' ); diff --git a/js/grunt/tasks/published-README.js b/js/grunt/tasks/published-README.js index 4bbd092e..b6df3a49 100644 --- a/js/grunt/tasks/published-README.js +++ b/js/grunt/tasks/published-README.js @@ -1,11 +1,11 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const generateREADME = require( './generateREADME' ); // used by multiple tasks ( async () => { diff --git a/js/grunt/tasks/report-media.js b/js/grunt/tasks/report-media.js index 11b76d99..8ce097be 100644 --- a/js/grunt/tasks/report-media.js +++ b/js/grunt/tasks/report-media.js @@ -1,11 +1,11 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const reportMedia = require( '../reportMedia' ); diff --git a/js/grunt/tasks/sort-imports.js b/js/grunt/tasks/sort-imports.js index fc845554..a67cb172 100644 --- a/js/grunt/tasks/sort-imports.js +++ b/js/grunt/tasks/sort-imports.js @@ -1,12 +1,12 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ const grunt = require( 'grunt' ); -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const sortImports = require( '../sortImports' ); diff --git a/js/grunt/tasks/unpublished-README.js b/js/grunt/tasks/unpublished-README.js index 6844a0c4..b54f37b6 100644 --- a/js/grunt/tasks/unpublished-README.js +++ b/js/grunt/tasks/unpublished-README.js @@ -1,11 +1,11 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const generateREADME = require( './generateREADME' ); // used by multiple tasks ( async () => { diff --git a/js/grunt/tasks/update-copyright-dates.js b/js/grunt/tasks/update-copyright-dates.js index d531b4e7..5a0c9a81 100644 --- a/js/grunt/tasks/update-copyright-dates.js +++ b/js/grunt/tasks/update-copyright-dates.js @@ -1,13 +1,13 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * TODO: https://github.com/phetsims/chipper/issues/1459 Grunt uses --brands=myBrands. But my parser was --brands myBrands. Equals sign probably broken. * TODO: https://github.com/phetsims/chipper/issues/1459 helpful CLI --help is only available in grunt, not in these mini tasks. * @author Sam Reid (PhET Interactive Simulations) */ -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); ( async () => { const updateCopyrightDates = require( '../updateCopyrightDates' ); diff --git a/js/grunt/tasks/update.js b/js/grunt/tasks/update.js index 82e57a00..820db3f6 100644 --- a/js/grunt/tasks/update.js +++ b/js/grunt/tasks/update.js @@ -1,12 +1,12 @@ // Copyright 2024, University of Colorado Boulder -const getRequiredArg = require( './getRequiredArg' ); +const getRepo = require( './getRepo' ); /** * @author Sam Reid (PhET Interactive Simulations) */ const grunt = require( 'grunt' ); -const repo = getRequiredArg( '--repo' ); +const repo = getRepo(); const generateREADME = require( '../generateREADME' ); const fs = require( 'fs' );