From f256ebe0fbb83d1b6b2584b55f753ddbb7c73966 Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Tue, 15 Oct 2024 09:04:35 -0600 Subject: [PATCH] Convert to TypeScript, see https://github.com/phetsims/chipper/issues/1465 --- js/grunt/buildRunnable.ts | 3 +-- .../{getDependencies.js => getDependencies.ts} | 15 +++++++-------- js/grunt/getStringRepos.ts | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) rename js/grunt/{getDependencies.js => getDependencies.ts} (87%) diff --git a/js/grunt/buildRunnable.ts b/js/grunt/buildRunnable.ts index b34f1b452..ab3f0104d 100644 --- a/js/grunt/buildRunnable.ts +++ b/js/grunt/buildRunnable.ts @@ -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' ); diff --git a/js/grunt/getDependencies.js b/js/grunt/getDependencies.ts similarity index 87% rename from js/grunt/getDependencies.js rename to js/grunt/getDependencies.ts index c4109fe00..e2704a020 100644 --- a/js/grunt/getDependencies.js +++ b/js/grunt/getDependencies.ts @@ -7,7 +7,6 @@ * @author Jonathan Olson */ - const assert = require( 'assert' ); const ChipperStringUtils = require( '../common/ChipperStringUtils' ); const execute = require( '../../../perennial-alias/js/common/execute' ); @@ -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.} - 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 { 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 = { comment: `# ${repo} ${version} ${new Date().toString()}` }; @@ -76,4 +75,4 @@ module.exports = async function getDependencies( repo ) { } return dependenciesInfo; -}; \ No newline at end of file +} \ No newline at end of file diff --git a/js/grunt/getStringRepos.ts b/js/grunt/getStringRepos.ts index 7f1528629..8962396ac 100644 --- a/js/grunt/getStringRepos.ts +++ b/js/grunt/getStringRepos.ts @@ -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 => {