|
@@ -25,6 +25,7 @@ const isWin = process.platform === 'win32';
|
|
|
case "land-diff-svn": return landChangesSvn(args?.[1]);
|
|
|
case "deploy-preview": return deployPreview();
|
|
|
case "deploy-theme": return deployThemes([args?.[1]]);
|
|
|
+ case "build-com-zip": return buildComZip([args?.[1]]);
|
|
|
}
|
|
|
return showHelp();
|
|
|
})();
|
|
@@ -161,10 +162,45 @@ async function pushButtonDeploy(repoType) {
|
|
|
console.log("ERROR with deply script: ", err);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+/*
|
|
|
+ Build .zip file for .com
|
|
|
+*/
|
|
|
+async function buildComZip(themeSlug) {
|
|
|
+ let response;
|
|
|
+
|
|
|
+ console.log( `Building ${themeSlug} .zip` );
|
|
|
+
|
|
|
+ let themeVersion;
|
|
|
+ let wpVersionCompat;
|
|
|
+ let styleCss = fs.readFileSync(`${themeSlug}/style.css`, 'utf8');
|
|
|
+
|
|
|
+ // Gets the theme version (Version:) and minimum WP version (Tested up to:) from the theme's style.css
|
|
|
+ if (styleCss) {
|
|
|
+ const themeVersionFromCss = styleCss.match(/(?<=Version:\s*).*?(?=\s*\r?\n|\rg)/gs);
|
|
|
+ themeVersion = themeVersionFromCss[0].trim().replace('-wpcom', '');
|
|
|
+ wpVersionCompat = styleCss.match(/(?<=Tested up to:\s*).*?(?=\s*\r?\n|\rg)/gs);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (themeVersion && wpVersionCompat) {
|
|
|
+ await executeOnSandbox(`php ${sandboxRootFolder}bin/themes/theme-downloads/build-theme-zip.php --stylesheet=pub/${themeSlug} --themeversion=${themeVersion} --wpversioncompat=${wpVersionCompat}`, true);
|
|
|
+ } else {
|
|
|
+ console.log('Unable to build theme .zip.');
|
|
|
+ if (!themeVersion) {
|
|
|
+ console.log('Could not find theme version (Version:) in the theme style.css.');
|
|
|
+ }
|
|
|
+ if (!wpVersionCompat) {
|
|
|
+ console.log('Could not find WP compat version (Tested up to:) in the theme style.css.');
|
|
|
+ }
|
|
|
+ console.log('Please build the .zip file for the theme manually.', themeSlug);
|
|
|
+ open('https://mc.a8c.com/themes/downloads/');
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
async function buildComZips(themes) {
|
|
|
- //TODO: Figure out how to create these zip files automatically.
|
|
|
- console.log('Please build the .zip files for the themes manually.', themes);
|
|
|
- open('https://mc.a8c.com/themes/downloads/');
|
|
|
+ for ( let theme of themes ) {
|
|
|
+ await buildComZip(theme);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -252,7 +288,7 @@ async function deployThemes( themes ) {
|
|
|
if( ! deploySuccess ) {
|
|
|
console.log( 'Deploy was not successful. Trying again in 10 seconds...' );
|
|
|
await new Promise(resolve => setTimeout(resolve, 10000));
|
|
|
- }
|
|
|
+ }
|
|
|
else {
|
|
|
console.log( "Deploy successful." );
|
|
|
}
|