Skip to content

Commit

Permalink
convert ReleaseBranch to typescript, #369
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Dec 19, 2024
1 parent 3905928 commit 5c50338
Show file tree
Hide file tree
Showing 17 changed files with 719 additions and 830 deletions.
8 changes: 8 additions & 0 deletions js/browser-and-node/types/Dependencies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2024, University of Colorado Boulder
/**
* Collection of usable types for build tools
* @author Michael Kauzmann (PhET Interactive Simulations)
*/

type Dependencies = Record<string, { sha: string; branch?: string }>;
export default Dependencies;
2 changes: 1 addition & 1 deletion js/build-server/taskWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const writePhetHtaccess = require( './writePhetHtaccess' );
const writePhetioHtaccess = require( '../common/writePhetioHtaccess' );
const deployImages = require( './deployImages' );
const persistentQueue = require( './persistentQueue' );
const ReleaseBranch = require( '../common/ReleaseBranch' );
const ReleaseBranch = require( '../common/ReleaseBranch' ).default;
const loadJSON = require( '../common/loadJSON' );

/**
Expand Down
6 changes: 0 additions & 6 deletions js/common/ChipperVersion.d.ts

This file was deleted.

48 changes: 22 additions & 26 deletions js/common/ChipperVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
const assert = require( 'assert' );
const fs = require( 'fs' );

/**
* TODO: remove this workaround jsdoc once this file is in TypeScript, https://github.com/phetsims/perennial/issues/369
* @type
*/
module.exports = ( function() {

class ChipperVersion {
/**
* @public
* @constructor
Expand All @@ -23,7 +19,7 @@ module.exports = ( function() {
* @param {number} maintenance - The maintenance part of the version (the 2 in 3.1.2)
* @param {boolean} chipperSupportsOutputJSGruntTasks - Flag that indicates whether grunt supports the family of commands like `output-js-project`
*/
function ChipperVersion( major, minor, maintenance, chipperSupportsOutputJSGruntTasks ) {
constructor( major, minor, maintenance, chipperSupportsOutputJSGruntTasks ) {

assert( typeof major === 'number' && major >= 0 && major % 1 === 0, 'major version should be a non-negative integer' );
assert( typeof minor === 'number' && minor >= 0 && minor % 1 === 0, 'minor version should be a non-negative integer' );
Expand All @@ -36,22 +32,22 @@ module.exports = ( function() {
this.chipperSupportsOutputJSGruntTasks = chipperSupportsOutputJSGruntTasks;
}

// Can't rely on inherit existing
ChipperVersion.prototype = {
constructor: ChipperVersion,

/**
* Returns a string form of the version.
* @public
*
* @returns {string}
*/
toString: function() {
return `${this.major}.${this.minor}.${this.maintenance}`;
}
};
/**
* Returns a string form of the version.
* @public
*
* @returns {string}
*/
toString() {
return `${this.major}.${this.minor}.${this.maintenance}`;
}

ChipperVersion.getFromPackageJSON = function( packageJSON ) {
/**
* @public
* @param packageJSON
* @returns {ChipperVersion}
*/
static getFromPackageJSON( packageJSON ) {
const versionString = packageJSON.version;

const matches = versionString.match( /(\d+)\.(\d+)\.(\d+)/ );
Expand All @@ -66,19 +62,19 @@ module.exports = ( function() {
const chipperSupportsOutputJSGruntTasks = packageJSON.phet && packageJSON.phet.chipperSupportsOutputJSGruntTasks;

return new ChipperVersion( major, minor, maintenance, chipperSupportsOutputJSGruntTasks );
};
}

/**
* Returns the chipper version of the currently-checked-out chipper repository.
* @public
*
* @returns {ChipperVersion}
*/
ChipperVersion.getFromRepository = function() {
static getFromRepository() {
return ChipperVersion.getFromPackageJSON(
JSON.parse( fs.readFileSync( '../chipper/package.json', 'utf8' ) )
);
};
}
}

return ChipperVersion;
} )();
module.exports = ChipperVersion;
2 changes: 1 addition & 1 deletion js/common/Maintenance.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const rc = require( '../grunt/rc' );
const ChipperVersion = require( './ChipperVersion' );
const ModifiedBranch = require( './ModifiedBranch' );
const Patch = require( './Patch' );
const ReleaseBranch = require( './ReleaseBranch' );
const ReleaseBranch = require( './ReleaseBranch' ).default;
const build = require( './build' );
const checkoutMain = require( './checkoutMain' );
const checkoutTarget = require( './checkoutTarget' );
Expand Down
2 changes: 1 addition & 1 deletion js/common/ModifiedBranch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

const Patch = require( './Patch' );
const ReleaseBranch = require( './ReleaseBranch' );
const ReleaseBranch = require( './ReleaseBranch' ).default;
const SimVersion = require( '../browser-and-node/SimVersion' ).default;
const checkoutDependencies = require( './checkoutDependencies' );
const getDependencies = require( './getDependencies' );
Expand Down
6 changes: 0 additions & 6 deletions js/common/ReleaseBranch.d.ts

This file was deleted.

Loading

0 comments on commit 5c50338

Please sign in to comment.