Browse Source

Updated theme-utils.mjs help text (#6038)

* Updated theme-utils.mjs help text

Running `node theme-utils.mjs` (no arguments) or `node theme-utils.mjs
help` will now show a list of available commands.

Running `node theme-utils.mjs help <command>` will show the specific
help text for that command.

* Apply wpcom JS coding standards

* Refactor command structure into a common object

This helps tidy up the code for running a command as well as the help
text.
Mark Biek 3 years ago
parent
commit
bb8d208850
1 changed files with 222 additions and 120 deletions
  1. 222 120
      theme-utils.mjs

+ 222 - 120
theme-utils.mjs

@@ -8,39 +8,141 @@ const sandboxPublicThemesFolder = '/home/wpdev/public_html/wp-content/themes/pub
 const sandboxPremiumThemesFolder = '/home/wpdev/public_html/wp-content/themes/premium';
 const sandboxPremiumThemesFolder = '/home/wpdev/public_html/wp-content/themes/premium';
 const sandboxRootFolder = '/home/wpdev/public_html/';
 const sandboxRootFolder = '/home/wpdev/public_html/';
 const isWin = process.platform === 'win32';
 const isWin = process.platform === 'win32';
-const premiumThemes = [ 'videomaker', 'videomaker-white' ];
+const premiumThemes = ['videomaker', 'videomaker-white'];
 const coreThemes = ['twentyten', 'twentyeleven', 'twentytwelve', 'twentythirteen', 'twentyfourteen', 'twentyfifteen', 'twentysixteen', 'twentyseventeen', 'twentynineteen', 'twentytwenty', 'twentytwentyone', 'twentytwentytwo'];
 const coreThemes = ['twentyten', 'twentyeleven', 'twentytwelve', 'twentythirteen', 'twentyfourteen', 'twentyfifteen', 'twentysixteen', 'twentyseventeen', 'twentynineteen', 'twentytwenty', 'twentytwentyone', 'twentytwentytwo'];
 
 
+const commands = {
+	"push-button-deploy": {
+		helpText: `
+* Gets the last deployed hash from the sandbox
+* Version bump all themes that have changes since the last deployment
+* Commit the version bump change to github
+* Clean the sandbox and ensure it is up - to - date
+* Push all changed files(including removal of deleted files) since the last deployment
+* Update the 'last deployed' hash on the sandbox
+* Create a phabricator diff based on the changes since the last deployment.The description including the commit messages since the last deployment.
+* Open the Phabricator Diff in your browser
+* Create a tag in the github repository at this point of change which includes the phabricator link in the description
+* After pausing to allow testing, land and deploy the changes
+		`,
+		run: pushButtonDeploy
+	},
+	"clean-sandbox": {
+		helpText: 'Perform a hard reset, checkout trunk, and pull on the public themes working copy on your sandbox.',
+		run: cleanSandbox
+	},
+	"clean-premium-sandbox": {
+		helpText: 'Perform a hard reset, checkout trunk, and pull on the premium themes working copy on your sandbox.',
+		run: cleanPremiumSandbox
+	},
+	"clean-all-sandbox": {
+		helpText: 'Perform a hard reset, checkout trunk, and pull on both the public and premium themes working copies on your sandbox.',
+		run: cleanAllSandbox
+	},
+	"push-to-sandbox": {
+		helpText: 'Uses rsync to copy all modified files for all themes from the local machine to your sandbox.',
+		run: pushToSandbox
+	},
+	"push-changes-to-sandbox": {
+		helpText: 'Uses rsync to copy all modified files for any modified themes from the local machine to your sandbox.',
+		run: pushChangesToSandbox
+	},
+	"push-theme-to-sandbox": {
+		helpText: 'Uses rsync to copy all modified files for the specified theme from the local machine to your sandbox.',
+		additionalArgs: '<theme-slug>',
+		run: (args) => pushThemeToSandbox(args?.[1])
+	},
+	"push-premium-to-sandbox": {
+		helpText: 'Uses rsync to copy all modified files for all premium themes from the local machine to your sandbox. For the blockbase theme, all instances of the string "blockbase" are replaced with "blockbase-premium".',
+		run: pushPremiumToSandbox
+	},
+	"version-bump-themes": {
+		helpText: 'Bump the version of any theme that has had changes since the last deployment. This includes bumping the version of any parent themes and updating the changelog for the theme.',
+		run: versionBumpThemes
+	},
+	"land-diff": {
+		helpText: 'Run arc land to merge in the specified diff id.',
+		additionalArgs: '<arc diff id>',
+		run: (args) => landChanges(args?.[1])
+	},
+	"deploy-preview": {
+		helpText: 'Display a list of the changes to be deployed.',
+		run: deployPreview
+	},
+	"deploy-theme": {
+		helpText: 'This runs "deploy pub <theme>" on the provided list of themes.',
+		additionalArgs: '<array of theme slugs>',
+		run: (args) => deployThemes([args?.[1]])
+	},
+	"build-com-zip": {
+		helpText: 'Build the production zip file for the specified theme.',
+		additionalArgs: '<theme-slug>',
+		run: (args) => buildComZip([args?.[1]])
+	},
+	"pull-core-themes": {
+		helpText: 'Use rsync to copy any changed public CORE theme files from your sandbox to your local machine. CORE themes are any of the Twenty<whatever> themes.',
+		run: pullCoreThemes
+	},
+	"push-core-themes": {
+		helpText: 'Use rsync to copy any changed public CORE theme files from your local machine to your sandbox. CORE themes are any of the Twenty<whatever> themes.',
+		run: pushCoreThemes
+	},
+	"sync-core-theme": {
+		helpText: 'Given a theme slug and SVN revision, sync the theme from the specified revision to the latest. This command is generally run by deploy-sync-core-theme and not by itself.',
+		additionalArgs: '<theme-slug> <since-revision>',
+		run: (args) => syncCoreTheme(args?.[1], args?.[2])
+	},
+	"deploy-sync-core-theme": {
+		helpText: 'Given a theme slug and SVN revision, sync the theme from the specified revision to the latest. This command contains additional prompts and error checking not provided by sync-core-theme.',
+		additionalArgs: '<theme-slug> <since-revision>',
+		run: (args) => deploySyncCoreTheme(args?.[1], args?.[2])
+	},
+	"update-theme-changelog": {
+		helpText: 'Use the commit log to build a list of recent changes and add them as a new changelog entry. If add-changes is true, the updated readme.txt will be staged.',
+		additionalArgs: '<theme-slug> <add-changes, true/false>',
+		run: (args) => updateThemeChangelog(args?.[1], false, args?.[2])
+	},
+	"rebuild-theme-changelog": {
+		helpText: 'Rebuild the entire change long from the given starting hash.',
+		additionalArgs: '<theme-slug> <since>',
+		run: (args) => rebuildThemeChangelog(args?.[1], args?.[2])
+	},
+	"help": {
+		helpText: 'Displays the main help message.',
+		run: (args) => showHelp(args?.[1])
+	},
+};
+
 (async function start() {
 (async function start() {
 	let args = process.argv.slice(2);
 	let args = process.argv.slice(2);
 	let command = args?.[0];
 	let command = args?.[0];
-	switch (command) {
-		case "push-button-deploy": return pushButtonDeploy();
-		case "clean-sandbox": return cleanSandbox();
-		case "clean-premium-sandbox": return cleanPremiumSandbox();
-		case "clean-all-sandbox": return cleanAllSandbox();
-		case "push-to-sandbox": return pushToSandbox();
-		case "push-changes-to-sandbox": return pushChangesToSandbox();
-		case "push-theme-to-sandbox": return pushThemeToSandbox(args?.[1]);
-		case "push-premium-to-sandbox": return pushPremiumToSandbox();
-		case "version-bump-themes": return versionBumpThemes();
-		case "land-diff": return landChanges(args?.[1]);
-		case "deploy-preview": return deployPreview();
-		case "deploy-theme": return deployThemes([args?.[1]]);
-		case "build-com-zip": return buildComZip([args?.[1]]);
-		case "pull-core-themes": return pullCoreThemes();
-		case "push-core-themes": return pushCoreThemes();
-		case "sync-core-theme": return syncCoreTheme(args?.[1], args?.[2]);
-		case "deploy-sync-core-theme": return deploySyncCoreTheme(args?.[1], args?.[2]);
-		case "update-theme-changelog": return updateThemeChangelog(args?.[1], false, args?.[2]);
-		case "rebuild-theme-changelog": return rebuildThemeChangelog(args?.[1], args?.[2]);
+
+	if (!commands[command]) {
+		return showHelp();
 	}
 	}
-	return showHelp();
+
+	commands[command].run(args);
 })();
 })();
 
 
-function showHelp(){
-	// TODO: make this helpful
-	console.log('Help info can go here');
+function showHelp(command = '') {
+	if (!command || !commands.hasOwnProperty(command)) {
+		console.log(`
+node theme-utils.mjs [command]
+
+Available commands:
+_(theme-utils.mjs help [command] for more details)_
+
+\t${Object.keys(commands).join('\n\t')}
+	`);
+		return;
+	}
+
+	const { helpText, additionalArgs } = commands[command];
+	console.log(`
+${command} ${additionalArgs ?? ''}
+
+${helpText}
+	`);
 }
 }
 
 
 /*
 /*
@@ -97,7 +199,7 @@ async function deployPreview() {
 /*
 /*
  Execute the first phase of a deployment.
  Execute the first phase of a deployment.
 	* Gets the last deployed hash from the sandbox
 	* Gets the last deployed hash from the sandbox
-	* Version bump all themes have have changes since the last deployment
+	* Version bump all themes that have changes since the last deployment
 	* Commit the version bump change to github
 	* Commit the version bump change to github
 	* Clean the sandbox and ensure it is up-to-date
 	* Clean the sandbox and ensure it is up-to-date
 	* Push all changed files (including removal of deleted files) since the last deployment
 	* Push all changed files (including removal of deleted files) since the last deployment
@@ -116,7 +218,7 @@ async function pushButtonDeploy() {
 		default: false
 		default: false
 	}]);
 	}]);
 
 
-	if(!prompt.continue){
+	if (!prompt.continue) {
 		return;
 		return;
 	}
 	}
 
 
@@ -138,9 +240,9 @@ async function pushButtonDeploy() {
 			name: "continue",
 			name: "continue",
 			default: false
 			default: false
 		}]);
 		}]);
-	
-		if(!prompt.continue){
-			console.log(`Aborted Automated Deploy Process at variations building.` );
+
+		if (!prompt.continue) {
+			console.log(`Aborted Automated Deploy Process at variations building.`);
 			return;
 			return;
 		}
 		}
 
 
@@ -156,7 +258,7 @@ async function pushButtonDeploy() {
 		let hash = await getLastDeployedHash();
 		let hash = await getLastDeployedHash();
 		let thingsWentBump = await versionBumpThemes();
 		let thingsWentBump = await versionBumpThemes();
 
 
-		if( thingsWentBump ){
+		if (thingsWentBump) {
 			prompt = await inquirer.prompt([{
 			prompt = await inquirer.prompt([{
 				type: 'confirm',
 				type: 'confirm',
 				message: 'Are you good with the version bump and changelog updates? Make any manual adjustments now if necessary.',
 				message: 'Are you good with the version bump and changelog updates? Make any manual adjustments now if necessary.',
@@ -164,8 +266,8 @@ async function pushButtonDeploy() {
 				default: false
 				default: false
 			}]);
 			}]);
 
 
-			if(!prompt.continue){
-				console.log(`Aborted Automated Deploy Process at version bump changes.` );
+			if (!prompt.continue) {
+				console.log(`Aborted Automated Deploy Process at version bump changes.`);
 				return;
 				return;
 			}
 			}
 		}
 		}
@@ -176,7 +278,7 @@ async function pushButtonDeploy() {
 
 
 
 
 		//push changes (from version bump)
 		//push changes (from version bump)
-		if( thingsWentBump ){
+		if (thingsWentBump) {
 			prompt = await inquirer.prompt([{
 			prompt = await inquirer.prompt([{
 				type: 'confirm',
 				type: 'confirm',
 				message: 'Are you ready to push this version bump change to the source repository (Github)?',
 				message: 'Are you ready to push this version bump change to the source repository (Github)?',
@@ -184,8 +286,8 @@ async function pushButtonDeploy() {
 				default: false
 				default: false
 			}]);
 			}]);
 
 
-			if(!prompt.continue){
-				console.log(`Aborted Automated Deploy Process at version bump push change.` );
+			if (!prompt.continue) {
+				console.log(`Aborted Automated Deploy Process at version bump push change.`);
 				return;
 				return;
 			}
 			}
 
 
@@ -216,18 +318,18 @@ async function pushButtonDeploy() {
 			default: false
 			default: false
 		}]);
 		}]);
 
 
-		if(!prompt.continue){
-			console.log(`Aborted Automated Deploy Process Landing Phase\n\nYou will have to land these changes manually.  The ID of the diff to land: ${diffId}` );
+		if (!prompt.continue) {
+			console.log(`Aborted Automated Deploy Process Landing Phase\n\nYou will have to land these changes manually.  The ID of the diff to land: ${diffId}`);
 			return;
 			return;
 		}
 		}
 
 
 		await landChanges(diffId);
 		await landChanges(diffId);
 
 
-		let changedPublicThemes = changedThemes.filter( item=> ! premiumThemes.includes( item ) );
+		let changedPublicThemes = changedThemes.filter(item => !premiumThemes.includes(item));
 
 
 		try {
 		try {
 			await deployThemes(changedPublicThemes);
 			await deployThemes(changedPublicThemes);
-		} 
+		}
 		catch (err) {
 		catch (err) {
 			prompt = await inquirer.prompt([{
 			prompt = await inquirer.prompt([{
 				type: 'confirm',
 				type: 'confirm',
@@ -236,8 +338,8 @@ async function pushButtonDeploy() {
 				default: false
 				default: false
 			}]);
 			}]);
 
 
-			if(!prompt.continue){
-				console.log(`Aborted Automated Deploy during deploy phase.` );
+			if (!prompt.continue) {
+				console.log(`Aborted Automated Deploy during deploy phase.`);
 				return;
 				return;
 			}
 			}
 		}
 		}
@@ -265,8 +367,8 @@ async function deploySyncCoreTheme(theme, sinceRevision) {
 		default: false
 		default: false
 	}]);
 	}]);
 
 
-	if(!prompt.continue){
-		console.log(`Aborted Core Sync Deploy.` );
+	if (!prompt.continue) {
+		console.log(`Aborted Core Sync Deploy.`);
 		return;
 		return;
 	}
 	}
 
 
@@ -284,7 +386,7 @@ Reviewers:
 Subscribers:
 Subscribers:
 `;
 `;
 
 
-	let diffUrl = await createPhabricatorDiff (commitMessage);
+	let diffUrl = await createPhabricatorDiff(commitMessage);
 	let diffId = diffUrl.split('a8c.com/')[1];
 	let diffId = diffUrl.split('a8c.com/')[1];
 
 
 	prompt = await inquirer.prompt([{
 	prompt = await inquirer.prompt([{
@@ -294,8 +396,8 @@ Subscribers:
 		default: false
 		default: false
 	}]);
 	}]);
 
 
-	if(!prompt.continue){
-		console.log(`Aborted Automated Deploy Sync Process Landing Phase\n\nYou will have to land these changes manually.  The ID of the diff to land: ${diffId}` );
+	if (!prompt.continue) {
+		console.log(`Aborted Automated Deploy Sync Process Landing Phase\n\nYou will have to land these changes manually.  The ID of the diff to land: ${diffId}`);
 		return;
 		return;
 	}
 	}
 
 
@@ -311,7 +413,7 @@ Subscribers:
 */
 */
 async function buildComZip(themeSlug) {
 async function buildComZip(themeSlug) {
 
 
-	console.log( `Building ${themeSlug} .zip` );
+	console.log(`Building ${themeSlug} .zip`);
 
 
 	let styleCss = fs.readFileSync(`${themeSlug}/style.css`, 'utf8');
 	let styleCss = fs.readFileSync(`${themeSlug}/style.css`, 'utf8');
 
 
@@ -336,7 +438,7 @@ async function buildComZip(themeSlug) {
 }
 }
 
 
 async function buildComZips(themes) {
 async function buildComZips(themes) {
-	for ( let theme of themes ) {
+	for (let theme of themes) {
 		try {
 		try {
 			await buildComZip(theme);
 			await buildComZip(theme);
 		} catch (err) {
 		} catch (err) {
@@ -350,16 +452,16 @@ async function buildComZips(themes) {
   * The current branch is /trunk
   * The current branch is /trunk
   * That trunk is up-to-date with origin/trunk
   * That trunk is up-to-date with origin/trunk
 */
 */
-async function checkForDeployability(){
+async function checkForDeployability() {
 	let branchName = await executeCommand('git symbolic-ref --short HEAD');
 	let branchName = await executeCommand('git symbolic-ref --short HEAD');
-	if(branchName !== 'trunk' ) {
+	if (branchName !== 'trunk') {
 		return 'Only the /trunk branch can be deployed.';
 		return 'Only the /trunk branch can be deployed.';
 	}
 	}
 
 
 	await executeCommand('git remote update', true);
 	await executeCommand('git remote update', true);
 	let localMasterHash = await executeCommand('git rev-parse trunk')
 	let localMasterHash = await executeCommand('git rev-parse trunk')
 	let remoteMasterHash = await executeCommand('git rev-parse origin/trunk')
 	let remoteMasterHash = await executeCommand('git rev-parse origin/trunk')
-	if(localMasterHash !== remoteMasterHash) {
+	if (localMasterHash !== remoteMasterHash) {
 		return 'Local /trunk is out-of-date.  Pull changes to continue.'
 		return 'Local /trunk is out-of-date.  Pull changes to continue.'
 	}
 	}
 	return null;
 	return null;
@@ -368,7 +470,7 @@ async function checkForDeployability(){
 /*
 /*
  Land the changes from the given diff ID.  This is the "production merge".
  Land the changes from the given diff ID.  This is the "production merge".
 */
 */
-async function landChanges(diffId){
+async function landChanges(diffId) {
 	return executeCommand(`ssh -tt -A ${remoteSSH} "cd ${sandboxPublicThemesFolder}; /usr/local/bin/arc patch ${diffId}; /usr/local/bin/arc land; exit;"`, true);
 	return executeCommand(`ssh -tt -A ${remoteSSH} "cd ${sandboxPublicThemesFolder}; /usr/local/bin/arc patch ${diffId}; /usr/local/bin/arc land; exit;"`, true);
 }
 }
 
 
@@ -378,7 +480,7 @@ async function getChangedThemes(hash) {
 	let changedThemes = [];
 	let changedThemes = [];
 	for (let theme of themes) {
 	for (let theme of themes) {
 		let hasChanges = await checkThemeForChanges(theme, hash);
 		let hasChanges = await checkThemeForChanges(theme, hash);
-		if(hasChanges){
+		if (hasChanges) {
 			changedThemes.push(theme);
 			changedThemes.push(theme);
 		}
 		}
 	}
 	}
@@ -391,37 +493,37 @@ async function getChangedThemes(hash) {
  Can also be triggered to deploy a single theme with the command:
  Can also be triggered to deploy a single theme with the command:
  node ./theme-utils.mjs deploy-theme THEMENAME
  node ./theme-utils.mjs deploy-theme THEMENAME
 */
 */
-async function deployThemes( themes ) {
+async function deployThemes(themes) {
 
 
 	let response;
 	let response;
 
 
-	for ( let theme of themes ) {
+	for (let theme of themes) {
 
 
-		console.log( `Deploying ${theme}` );
+		console.log(`Deploying ${theme}`);
 
 
 		let deploySuccess = false;
 		let deploySuccess = false;
 		let attempt = 0;
 		let attempt = 0;
 
 
-		while ( ! deploySuccess && attempt <= 2 ) {
+		while (!deploySuccess && attempt <= 2) {
 
 
 			attempt++;
 			attempt++;
 			console.log(`\nattempt #${attempt}\n\n`);
 			console.log(`\nattempt #${attempt}\n\n`);
 
 
-			response = await executeOnSandbox( `deploy pub ${theme};exit;`, true, true );
+			response = await executeOnSandbox(`deploy pub ${theme};exit;`, true, true);
 
 
-			deploySuccess = response.includes( 'successfully deployed to' );
+			deploySuccess = response.includes('successfully deployed to');
 
 
-			if( ! deploySuccess ) {
-				console.log( 'Deploy was not successful.  Trying again in 10 seconds...' );
+			if (!deploySuccess) {
+				console.log('Deploy was not successful.  Trying again in 10 seconds...');
 				await new Promise(resolve => setTimeout(resolve, 10000));
 				await new Promise(resolve => setTimeout(resolve, 10000));
 			}
 			}
 			else {
 			else {
-				console.log( "Deploy successful." );
+				console.log("Deploy successful.");
 			}
 			}
 
 
 		}
 		}
 
 
-		if ( ! deploySuccess ) {
+		if (!deploySuccess) {
 
 
 			await inquirer.prompt([{
 			await inquirer.prompt([{
 				type: 'confirm',
 				type: 'confirm',
@@ -472,14 +574,14 @@ async function versionBumpThemes() {
 
 
 	for (let theme of themes) {
 	for (let theme of themes) {
 		let hasChanges = await checkThemeForChanges(theme, hash);
 		let hasChanges = await checkThemeForChanges(theme, hash);
-		if( ! hasChanges){
+		if (!hasChanges) {
 			// console.log(`${theme} has no changes`);
 			// console.log(`${theme} has no changes`);
 			continue;
 			continue;
 		}
 		}
 
 
 		versionBumpCount++;
 		versionBumpCount++;
 		let hasVersionBump = await checkThemeForVersionBump(theme, hash);
 		let hasVersionBump = await checkThemeForVersionBump(theme, hash);
-		if( hasVersionBump ){
+		if (hasVersionBump) {
 			continue;
 			continue;
 		}
 		}
 
 
@@ -490,7 +592,7 @@ async function versionBumpThemes() {
 
 
 	//version bump the root project if there were changes to any of the themes
 	//version bump the root project if there were changes to any of the themes
 	let rootHasVersionBump = await checkProjectForVersionBump(hash);
 	let rootHasVersionBump = await checkProjectForVersionBump(hash);
-	if ( versionBumpCount > 0 && ! rootHasVersionBump ) {
+	if (versionBumpCount > 0 && !rootHasVersionBump) {
 		await executeCommand(`npm version patch --no-git-tag-version && git add package.json package-lock.json`);
 		await executeCommand(`npm version patch --no-git-tag-version && git add package.json package-lock.json`);
 		changesWereMade = true;
 		changesWereMade = true;
 	}
 	}
@@ -499,10 +601,10 @@ async function versionBumpThemes() {
 }
 }
 
 
 export function getThemeMetadata(styleCss, attribute) {
 export function getThemeMetadata(styleCss, attribute) {
-	if ( !styleCss || !attribute ) {
+	if (!styleCss || !attribute) {
 		return null;
 		return null;
 	}
 	}
-	switch ( attribute ) {
+	switch (attribute) {
 		case 'Version':
 		case 'Version':
 			return styleCss
 			return styleCss
 				.match(/(?<=Version:\s*).*?(?=\s*\r?\n|\rg)/gs)[0]
 				.match(/(?<=Version:\s*).*?(?=\s*\r?\n|\rg)/gs)[0]
@@ -530,9 +632,9 @@ async function rebuildThemeChangelog(theme, since) {
 
 
 	let logs = '== Changelog ==\n';
 	let logs = '== Changelog ==\n';
 
 
-	for ( let hash of hashes ) {
+	for (let hash of hashes) {
 		let log = await executeCommand(`git log -n 1 --pretty=format:"* %s" ${hash}`);
 		let log = await executeCommand(`git log -n 1 --pretty=format:"* %s" ${hash}`);
-		if ( log.includes('Version Bump') ) {
+		if (log.includes('Version Bump')) {
 			let previousStyleString = await executeCommand(`git show ${hash}:${theme}/style.css 2>/dev/null`);
 			let previousStyleString = await executeCommand(`git show ${hash}:${theme}/style.css 2>/dev/null`);
 			let version = getThemeMetadata(previousStyleString, 'Version');
 			let version = getThemeMetadata(previousStyleString, 'Version');
 			logs += `\n= ${version} =\n`;
 			logs += `\n= ${version} =\n`;
@@ -547,12 +649,12 @@ async function rebuildThemeChangelog(theme, since) {
 	let readmeFilePath = `${theme}/readme.txt`;
 	let readmeFilePath = `${theme}/readme.txt`;
 
 
 	// Update readme.txt
 	// Update readme.txt
-	fs.readFile(readmeFilePath, 'utf8', function(err, data) {
+	fs.readFile(readmeFilePath, 'utf8', function (err, data) {
 		let changelogSection = '== Changelog ==';
 		let changelogSection = '== Changelog ==';
 		let regex = new RegExp('^.*' + changelogSection + '.*$', 'gm');
 		let regex = new RegExp('^.*' + changelogSection + '.*$', 'gm');
 		let formattedChangelog = data.replace(regex, logs);
 		let formattedChangelog = data.replace(regex, logs);
 
 
-		fs.writeFile(readmeFilePath, formattedChangelog, 'utf8', function(err) {
+		fs.writeFile(readmeFilePath, formattedChangelog, 'utf8', function (err) {
 			if (err) return console.log(err);
 			if (err) return console.log(err);
 		});
 		});
 	});
 	});
@@ -567,11 +669,11 @@ async function updateThemeChangelog(theme, addChanges) {
 	console.log(`Updating ${theme} changelog`);
 	console.log(`Updating ${theme} changelog`);
 
 
 	// Get theme version
 	// Get theme version
- 	let styleCss = fs.readFileSync(`${theme}/style.css`, 'utf8');
- 	let version = getThemeMetadata(styleCss, 'Version');
+	let styleCss = fs.readFileSync(`${theme}/style.css`, 'utf8');
+	let version = getThemeMetadata(styleCss, 'Version');
 
 
 	// Get list of updates with bullet points
 	// Get list of updates with bullet points
- 	let logs = await getCommitLogs('', true, theme);
+	let logs = await getCommitLogs('', true, theme);
 
 
 	// Get theme readme.txt
 	// Get theme readme.txt
 	let readmeFilePath = `${theme}/readme.txt`;
 	let readmeFilePath = `${theme}/readme.txt`;
@@ -588,12 +690,12 @@ async function updateThemeChangelog(theme, addChanges) {
 ${logs}`;
 ${logs}`;
 
 
 	// Update readme.txt
 	// Update readme.txt
-	fs.readFile(readmeFilePath, 'utf8', function(err, data) {
+	fs.readFile(readmeFilePath, 'utf8', function (err, data) {
 		let changelogSection = '== Changelog ==';
 		let changelogSection = '== Changelog ==';
 		let regex = new RegExp('^.*' + changelogSection + '.*$', 'gm');
 		let regex = new RegExp('^.*' + changelogSection + '.*$', 'gm');
 		let formattedChangelog = data.replace(regex, newChangelogEntry);
 		let formattedChangelog = data.replace(regex, newChangelogEntry);
 
 
-		fs.writeFile(readmeFilePath, formattedChangelog, 'utf8', function(err) {
+		fs.writeFile(readmeFilePath, formattedChangelog, 'utf8', function (err) {
 			if (err) return console.log(err);
 			if (err) return console.log(err);
 		});
 		});
 	});
 	});
@@ -610,7 +712,7 @@ ${logs}`;
  First increment the patch version in style.css
  First increment the patch version in style.css
  Then update any of these files with the new version: [package.json, style.scss, style-child-theme.scss]
  Then update any of these files with the new version: [package.json, style.scss, style-child-theme.scss]
 */
 */
-async function versionBumpTheme(theme, addChanges){
+async function versionBumpTheme(theme, addChanges) {
 
 
 	console.log(`${theme} needs a version bump`);
 	console.log(`${theme} needs a version bump`);
 
 
@@ -623,10 +725,10 @@ async function versionBumpTheme(theme, addChanges){
 	let filesToUpdate = await executeCommand(`find ${theme} -name package.json -o -name style.scss -o -name style-child-theme.scss -maxdepth 2`);
 	let filesToUpdate = await executeCommand(`find ${theme} -name package.json -o -name style.scss -o -name style-child-theme.scss -maxdepth 2`);
 	filesToUpdate = filesToUpdate.split('\n').filter(item => item != '');
 	filesToUpdate = filesToUpdate.split('\n').filter(item => item != '');
 
 
-	for ( let file of filesToUpdate ) {
+	for (let file of filesToUpdate) {
 		await executeCommand(`perl -pi -e 's/Version: (.*)$/"Version: '${currentVersion}'"/ge' ${file}`);
 		await executeCommand(`perl -pi -e 's/Version: (.*)$/"Version: '${currentVersion}'"/ge' ${file}`);
 		await executeCommand(`perl -pi -e 's/\\"version\\": (.*)$/"\\"version\\": \\"'${currentVersion}'\\","/ge' ${file}`);
 		await executeCommand(`perl -pi -e 's/\\"version\\": (.*)$/"\\"version\\": \\"'${currentVersion}'\\","/ge' ${file}`);
-		if (addChanges){
+		if (addChanges) {
 			await executeCommand(`git add ${file}`);
 			await executeCommand(`git add ${file}`);
 		}
 		}
 	}
 	}
@@ -637,23 +739,23 @@ async function versionBumpTheme(theme, addChanges){
  Used by versionBumpThemes
  Used by versionBumpThemes
  Compares the value of 'version' in style.css between the hash and current value
  Compares the value of 'version' in style.css between the hash and current value
 */
 */
-async function checkThemeForVersionBump(theme, hash){
+async function checkThemeForVersionBump(theme, hash) {
 	return executeCommand(`
 	return executeCommand(`
 		git show ${hash}:${theme}/style.css 2>/dev/null
 		git show ${hash}:${theme}/style.css 2>/dev/null
 	`)
 	`)
-	.catch( ( error ) => {
-		//This is a new theme, no need to bump versions so we'll just say we've already done it
-		return true;
-	} )
-	.then( ( previousStyleString ) => {
-		if( previousStyleString === true) {
-			return previousStyleString;
-		}
-		let previousVersion = getThemeMetadata(previousStyleString, 'Version');
-		let styleCss = fs.readFileSync(`${theme}/style.css`, 'utf8');
-		let currentVersion = getThemeMetadata(styleCss, 'Version');
-		return previousVersion != currentVersion;
-	});
+		.catch((error) => {
+			//This is a new theme, no need to bump versions so we'll just say we've already done it
+			return true;
+		})
+		.then((previousStyleString) => {
+			if (previousStyleString === true) {
+				return previousStyleString;
+			}
+			let previousVersion = getThemeMetadata(previousStyleString, 'Version');
+			let styleCss = fs.readFileSync(`${theme}/style.css`, 'utf8');
+			let currentVersion = getThemeMetadata(styleCss, 'Version');
+			return previousVersion != currentVersion;
+		});
 }
 }
 
 
 /*
 /*
@@ -661,7 +763,7 @@ async function checkThemeForVersionBump(theme, hash){
  Used by versionBumpThemes
  Used by versionBumpThemes
  Compares the value of 'version' in package.json between the hash and current value
  Compares the value of 'version' in package.json between the hash and current value
 */
 */
-async function checkProjectForVersionBump(hash){
+async function checkProjectForVersionBump(hash) {
 	let previousPackageString = await executeCommand(`
 	let previousPackageString = await executeCommand(`
 		git show ${hash}:./package.json 2>/dev/null
 		git show ${hash}:./package.json 2>/dev/null
 	`);
 	`);
@@ -674,7 +776,7 @@ async function checkProjectForVersionBump(hash){
  Determine if a theme has had changes since a given hash.
  Determine if a theme has had changes since a given hash.
  Used by versionBumpThemes
  Used by versionBumpThemes
 */
 */
-async function checkThemeForChanges(theme, hash){
+async function checkThemeForChanges(theme, hash) {
 	let comittedChanges = await executeCommand(`git diff --name-only ${hash} HEAD -- ${theme}`);
 	let comittedChanges = await executeCommand(`git diff --name-only ${hash} HEAD -- ${theme}`);
 	return comittedChanges != '';
 	return comittedChanges != '';
 }
 }
@@ -690,7 +792,7 @@ async function getActionableThemes() {
 	done`);
 	done`);
 	return result
 	return result
 		.split('\n')
 		.split('\n')
-		.map(item=>item.replace('/', ''));
+		.map(item => item.replace('/', ''));
 }
 }
 
 
 /*
 /*
@@ -755,15 +857,15 @@ async function cleanAllSandbox() {
 async function pushToSandbox() {
 async function pushToSandbox() {
 	console.log("Pushing All Themes to Sandbox.");
 	console.log("Pushing All Themes to Sandbox.");
 	let allThemes = await getActionableThemes();
 	let allThemes = await getActionableThemes();
-	allThemes = allThemes.filter( item=> ! premiumThemes.includes( item ) );
+	allThemes = allThemes.filter(item => !premiumThemes.includes(item));
 	console.log(`Syncing ${allThemes.length} themes`);
 	console.log(`Syncing ${allThemes.length} themes`);
-	for ( let theme of allThemes ) {
+	for (let theme of allThemes) {
 		await pushThemeToSandbox(theme);
 		await pushThemeToSandbox(theme);
 	}
 	}
 }
 }
 
 
 async function pushThemeToSandbox(theme) {
 async function pushThemeToSandbox(theme) {
-	console.log( `Syncing ${theme}` );
+	console.log(`Syncing ${theme}`);
 	return executeCommand(`
 	return executeCommand(`
 		rsync -avR --no-p --no-times --delete -m --exclude-from='.sandbox-ignore' ./${theme}/ wpcom-sandbox:${sandboxPublicThemesFolder}/
 		rsync -avR --no-p --no-times --delete -m --exclude-from='.sandbox-ignore' ./${theme}/ wpcom-sandbox:${sandboxPublicThemesFolder}/
 	`, true);
 	`, true);
@@ -790,8 +892,8 @@ async function pushPremiumToSandbox() {
 	];
 	];
 
 
 	// Change 'blockbase' to 'blockbase-premium' in the files noted
 	// Change 'blockbase' to 'blockbase-premium' in the files noted
-	for ( let theme of premiumThemes ) {
-		for ( let file of filesToModify ) {
+	for (let theme of premiumThemes) {
+		for (let file of filesToModify) {
 			await executeCommand(`perl -pi -e 's/blockbase/blockbase-premium/' ${theme}/${file}`, true);
 			await executeCommand(`perl -pi -e 's/blockbase/blockbase-premium/' ${theme}/${file}`, true);
 		}
 		}
 	}
 	}
@@ -802,8 +904,8 @@ async function pushPremiumToSandbox() {
 	`, true);
 	`, true);
 
 
 	// revert the local blockbase-premium changes
 	// revert the local blockbase-premium changes
-	for ( let theme of premiumThemes ) {
-		for ( let file of filesToModify ) {
+	for (let theme of premiumThemes) {
+		for (let file of filesToModify) {
 			await executeCommand(`
 			await executeCommand(`
 				git restore --source=HEAD --staged --worktree ./${theme}/${file}
 				git restore --source=HEAD --staged --worktree ./${theme}/${file}
 			`);
 			`);
@@ -821,17 +923,17 @@ async function pushChangesToSandbox() {
 	console.log("Pushing Changed Themes to Sandbox.");
 	console.log("Pushing Changed Themes to Sandbox.");
 	let hash = await getLastDeployedHash();
 	let hash = await getLastDeployedHash();
 	let changedThemes = await getChangedThemes(hash);
 	let changedThemes = await getChangedThemes(hash);
-	changedThemes = changedThemes.filter( item=> ! premiumThemes.includes( item ) );
+	changedThemes = changedThemes.filter(item => !premiumThemes.includes(item));
 	console.log(`Syncing ${changedThemes.length} themes`);
 	console.log(`Syncing ${changedThemes.length} themes`);
 
 
-	for ( let theme of changedThemes ) {
+	for (let theme of changedThemes) {
 		await pushThemeToSandbox(theme);
 		await pushThemeToSandbox(theme);
 	}
 	}
 }
 }
 
 
 async function pullCoreThemes() {
 async function pullCoreThemes() {
 	console.log("Pulling CORE themes from sandbox.");
 	console.log("Pulling CORE themes from sandbox.");
-	for (let theme of coreThemes ) {
+	for (let theme of coreThemes) {
 		await executeCommand(`
 		await executeCommand(`
 			rsync -avr --no-p --no-times --delete -m --exclude-from='.sandbox-ignore' wpcom-sandbox:${sandboxPublicThemesFolder}/${theme}/ ./${theme}/ 
 			rsync -avr --no-p --no-times --delete -m --exclude-from='.sandbox-ignore' wpcom-sandbox:${sandboxPublicThemesFolder}/${theme}/ ./${theme}/ 
 		`, true);
 		`, true);
@@ -840,7 +942,7 @@ async function pullCoreThemes() {
 
 
 async function pushCoreThemes() {
 async function pushCoreThemes() {
 	console.log("Pushing CORE themes to sandbox.");
 	console.log("Pushing CORE themes to sandbox.");
-	for (let theme of coreThemes ) {
+	for (let theme of coreThemes) {
 		await executeCommand(`
 		await executeCommand(`
 			rsync -avr --no-p --no-times --delete -m --exclude-from='.sandbox-ignore' ./${theme}/ wpcom-sandbox:${sandboxPublicThemesFolder}/${theme}/ 
 			rsync -avr --no-p --no-times --delete -m --exclude-from='.sandbox-ignore' ./${theme}/ wpcom-sandbox:${sandboxPublicThemesFolder}/${theme}/ 
 		`, true);
 		`, true);
@@ -848,11 +950,11 @@ async function pushCoreThemes() {
 }
 }
 
 
 async function syncCoreTheme(theme, sinceRevision) {
 async function syncCoreTheme(theme, sinceRevision) {
-	if(!theme){
+	if (!theme) {
 		console.log('Must supply theme to sync and revision to start from');
 		console.log('Must supply theme to sync and revision to start from');
 		return;
 		return;
 	}
 	}
-	if(!sinceRevision) {
+	if (!sinceRevision) {
 		sinceRevision = await executeOnSandbox(`cat ${sandboxPublicThemesFolder}/${theme}/.pub-svn-revision`);
 		sinceRevision = await executeOnSandbox(`cat ${sandboxPublicThemesFolder}/${theme}/.pub-svn-revision`);
 	}
 	}
 	let latestRevision = await executeCommand(`svn info -r HEAD https://core.svn.wordpress.org/trunk | grep Revision | egrep -o "[0-9]+"`);
 	let latestRevision = await executeCommand(`svn info -r HEAD https://core.svn.wordpress.org/trunk | grep Revision | egrep -o "[0-9]+"`);
@@ -878,7 +980,7 @@ async function syncCoreTheme(theme, sinceRevision) {
  This message contains the logs from all of the commits since the given hash.
  This message contains the logs from all of the commits since the given hash.
  Used by create*PhabricatorDiff
  Used by create*PhabricatorDiff
 */
 */
-async function buildPhabricatorCommitMessageSince(hash){
+async function buildPhabricatorCommitMessageSince(hash) {
 
 
 	let projectVersion = await executeCommand(`node -p "require('./package.json').version"`);
 	let projectVersion = await executeCommand(`node -p "require('./package.json').version"`);
 	let logs = await getCommitLogs(hash);
 	let logs = await getCommitLogs(hash);
@@ -917,7 +1019,7 @@ async function createPhabricatorDiff(commitMessage) {
 
 
 	console.log('Diff Created at: ', phabricatorUrl);
 	console.log('Diff Created at: ', phabricatorUrl);
 
 
-	if(phabricatorUrl) {
+	if (phabricatorUrl) {
 		open(phabricatorUrl);
 		open(phabricatorUrl);
 	}
 	}
 
 
@@ -928,10 +1030,10 @@ async function createPhabricatorDiff(commitMessage) {
  Utility to pull the Phabricator URL from the diff creation command.
  Utility to pull the Phabricator URL from the diff creation command.
  Used by createPhabricatorDiff
  Used by createPhabricatorDiff
 */
 */
-function getPhabricatorUrlFromResponse(response){
+function getPhabricatorUrlFromResponse(response) {
 	return response
 	return response
 		?.split('\n')
 		?.split('\n')
-		?.find( item => {
+		?.find(item => {
 			return item.includes('Revision URI: ');
 			return item.includes('Revision URI: ');
 		})
 		})
 		?.split("Revision URI: ")[1];
 		?.split("Revision URI: ")[1];
@@ -942,7 +1044,7 @@ function getPhabricatorUrlFromResponse(response){
  In the description include the commit logs since the given hash.
  In the description include the commit logs since the given hash.
  Include the (cleansed) Phabricator link.
  Include the (cleansed) Phabricator link.
 */
 */
-async function tagDeployment(options={}) {
+async function tagDeployment(options = {}) {
 
 
 	console.log('tagging deployment');
 	console.log('tagging deployment');
 
 
@@ -972,9 +1074,9 @@ Host wpcom-sandbox
 	HostName SANDBOXURL.wordpress.com
 	HostName SANDBOXURL.wordpress.com
 	ForwardAgent yes
 	ForwardAgent yes
 */
 */
-function executeOnSandbox(command, logResponse, enablePsudoterminal){
+function executeOnSandbox(command, logResponse, enablePsudoterminal) {
 
 
-	if(enablePsudoterminal){
+	if (enablePsudoterminal) {
 		return executeCommand(`ssh -tt -A ${remoteSSH} << EOF
 		return executeCommand(`ssh -tt -A ${remoteSSH} << EOF
 ${command}
 ${command}
 EOF`, logResponse);
 EOF`, logResponse);
@@ -1008,14 +1110,14 @@ export async function executeCommand(command, logResponse) {
 
 
 		child.stdout.on('data', (data) => {
 		child.stdout.on('data', (data) => {
 			response += data;
 			response += data;
-			if(logResponse){
+			if (logResponse) {
 				console.log(data.toString());
 				console.log(data.toString());
 			}
 			}
 		});
 		});
 
 
 		child.stderr.on('data', (data) => {
 		child.stderr.on('data', (data) => {
 			errResponse += data;
 			errResponse += data;
-			if(logResponse){
+			if (logResponse) {
 				console.log(data.toString());
 				console.log(data.toString());
 			}
 			}
 		});
 		});