Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions theme-utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ import AjvDraft04 from 'ajv-draft-04';
import glob from 'fast-glob';
import chalk, { Chalk } from 'chalk';

const remoteSSH = 'wpcom-sandbox';
const sandboxPublicThemesFolder =
'/home/wpcom/public_html/wp-content/themes/pub';
const sandboxRootFolder = '/home/wpcom/public_html/';
const glotPressScript =
'~/public_html/bin/i18n/create-glotpress-project-for-theme.php';
const remoteSSH = process.env.REMOTE_SSH;
const publicThemesFolder = process.env.PUBLIC_THEMES_FOLDER;
const buildThemeZip = process.env.BUILD_THEME_ZIP;
const glotPressScript = process.env.GLOTPRESS_SCRIPT;
const isWin = process.platform === 'win32';
const coreThemes = [
'twentyten',
Expand Down Expand Up @@ -613,7 +611,7 @@ async function buildComZip( themeSlug ) {

if ( themeVersion && wpVersionCompat ) {
await executeOnSandbox(
`php ${ sandboxRootFolder }bin/themes/theme-downloads/build-theme-zip.php --stylesheet=pub/${ themeSlug } --themeversion=${ themeVersion } --wpversioncompat=${ wpVersionCompat };`,
`php ${ buildThemeZip } --stylesheet=pub/${ themeSlug } --themeversion=${ themeVersion } --wpversioncompat=${ wpVersionCompat };`,
true
);
} else {
Expand All @@ -632,7 +630,7 @@ async function buildComZip( themeSlug ) {
'Please build the .zip file for the theme manually.',
themeSlug
);
open( 'https://mc.a8c.com/themes/downloads/' );
open( process.env.THEME_DOWNLOADS_URL );
}
}

Expand Down Expand Up @@ -696,7 +694,7 @@ async function checkForDeployability() {
*/
async function landChanges( prId ) {
return executeCommand(
`ssh -tt -A ${ remoteSSH } "cd ${ sandboxPublicThemesFolder } && gh pr merge ${ prId } --squash; exit;"`,
`ssh -tt -A ${ remoteSSH } "cd ${ publicThemesFolder } && gh pr merge ${ prId } --squash; exit;"`,
true
);
}
Expand Down Expand Up @@ -793,7 +791,7 @@ async function deployThemes( themes ) {
*/
async function getLastDeployedHash() {
let result = await executeOnSandbox( `
cat ${ sandboxPublicThemesFolder }/.theme-utils/.pub-git-hash
cat ${ publicThemesFolder }/.theme-utils/.pub-git-hash
` );
return result;
}
Expand All @@ -804,7 +802,7 @@ async function getLastDeployedHash() {
async function updateLastDeployedHash() {
let hash = await executeCommand( `git rev-parse HEAD` );
await executeOnSandbox( `
echo '${ hash }' > ${ sandboxPublicThemesFolder }/.theme-utils/.pub-git-hash
echo '${ hash }' > ${ publicThemesFolder }/.theme-utils/.pub-git-hash
` );
}

Expand Down Expand Up @@ -1151,7 +1149,7 @@ async function cleanSandbox() {
console.log( 'Cleaning the Themes Sandbox' );
await executeOnSandbox(
`
cd ${ sandboxPublicThemesFolder };
cd ${ publicThemesFolder };
git reset --hard HEAD;
git clean -fd;
git checkout trunk;
Expand Down Expand Up @@ -1180,7 +1178,7 @@ async function pushThemeToSandbox( theme ) {
console.log( `Syncing ${ theme }` );
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:${ publicThemesFolder }/
`,
true
);
Expand Down Expand Up @@ -1219,7 +1217,7 @@ async function pullAllThemes() {
try {
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:${ publicThemesFolder }/${ theme }/ ./${ theme }/
`,
true
);
Expand All @@ -1234,7 +1232,7 @@ async function pullCoreThemes() {
for ( let theme of coreThemes ) {
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:${ publicThemesFolder }/${ theme }/ ./${ theme }/
`,
true
);
Expand All @@ -1246,7 +1244,7 @@ async function pushCoreThemes() {
for ( let theme of coreThemes ) {
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:${ publicThemesFolder }/${ theme }/
`,
true
);
Expand Down Expand Up @@ -1312,7 +1310,7 @@ async function createGithubPR( commitMessage ) {

let result = await executeOnSandbox(
`
cd ${ sandboxPublicThemesFolder };
cd ${ publicThemesFolder };
git branch -D deploy
git checkout -b deploy
git add --all
Expand Down Expand Up @@ -1393,8 +1391,8 @@ async function createGlotPressProject( changedThemes ) {

await executeOnSandbox(
`
cd ${ sandboxPublicThemesFolder };
php ${ glotPressScript } ${ sandboxPublicThemesFolder }/${ themeSlug };
cd ${ publicThemesFolder };
php ${ glotPressScript } ${ publicThemesFolder }/${ themeSlug };
`,
true
);
Expand Down