Skip to content

Commit

Permalink
Convert to TypeScript, see #1465
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Oct 15, 2024
1 parent 77ca0ec commit f256ebe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
3 changes: 1 addition & 2 deletions js/grunt/buildRunnable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ import _ from 'lodash';
import getInitializationScript from './getInitializationScript';
import packageXHTML from './packageXHTML';
import reportUnusedStrings from './reportUnusedStrings';
import getDependencies from './getDependencies';

const assert = require( 'assert' );
const ChipperStringUtils = require( '../common/ChipperStringUtils' );
const getLicenseEntry = require( '../common/getLicenseEntry' );
const copyDirectory = require( './copyDirectory' );
const copySupplementalPhetioFiles = require( './copySupplementalPhetioFiles' );

const getA11yViewHTMLFromTemplate = require( './getA11yViewHTMLFromTemplate' );
const getAllThirdPartyEntries = require( './getAllThirdPartyEntries' );
const getDependencies = require( './getDependencies' );
const getLocalesFromRepository = require( './getLocalesFromRepository' );
const getPhetLibs = require( './getPhetLibs' );
const getPreloads = require( './getPreloads' );
Expand Down
15 changes: 7 additions & 8 deletions js/grunt/getDependencies.js → js/grunt/getDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* @author Jonathan Olson <[email protected]>
*/


const assert = require( 'assert' );
const ChipperStringUtils = require( '../common/ChipperStringUtils' );
const execute = require( '../../../perennial-alias/js/common/execute' );
Expand All @@ -21,25 +20,25 @@ const simNameRegex = /^[^/]+$/;

/**
* Returns an object in the dependencies.json format. Keys are repo names (or 'comment'). Repo keys have 'sha' and 'branch' fields.
* @public
*
* @param {string} repo
* @returns {Promise.<Object>} - In the dependencies.json format. JSON.stringify if you want to output to a file
* @returns - In the dependencies.json format. JSON.stringify if you want to output to a file
*/
module.exports = async function getDependencies( repo ) {
export default async function getDependencies( repo: string ): Promise<object> {

const packageObject = grunt.file.readJSON( `../${repo}/package.json` );
const version = packageObject.version;

// Accumulate dependencies for all brands
const dependencies = getPhetLibs( repo ).filter( dependency => dependency !== 'babel' ); // Remove babel since it should be kept at main
// @ts-expect-error
const dependencies: string[] = getPhetLibs( repo ).filter( dependency => dependency !== 'babel' ); // Remove babel since it should be kept at main

// We need to check dependencies for the main brand, so we can know what is guaranteed to be public
// @ts-expect-error
const mainDependencies = getPhetLibs( repo, 'phet' ).filter( dependency => dependency !== 'babel' );

grunt.log.debug( `Scanning dependencies from:\n${dependencies.toString()}` );

const dependenciesInfo = {
const dependenciesInfo: Record<string, unknown> = {
comment: `# ${repo} ${version} ${new Date().toString()}`
};

Expand Down Expand Up @@ -76,4 +75,4 @@ module.exports = async function getDependencies( repo ) {
}

return dependenciesInfo;
};
}
2 changes: 1 addition & 1 deletion js/grunt/getStringRepos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

const fs = require( 'fs' );
const getDependencies = require( './getDependencies' );
import getDependencies from './getDependencies';
import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.js';

module.exports = async ( repo: string ): Promise<IntentionalAny> => {
Expand Down

0 comments on commit f256ebe

Please sign in to comment.