Wrap build options/platforms in reusable function.
This commit is contained in:
@@ -3,10 +3,7 @@
|
|||||||
|
|
||||||
import config from 'config';
|
import config from 'config';
|
||||||
import prompts from "prompts";
|
import prompts from "prompts";
|
||||||
import {buildHubspotEmail} from "./platforms/hubspot/hubspot-email-adapter.js";
|
import {buildExportFiles, getConfigs} from "./helpers.js";
|
||||||
import {getConfigs} from "./helpers.js";
|
|
||||||
import {buildWordPress} from "./platforms/wordpress/wordpress-adapter.js";
|
|
||||||
import {buildHubspotPage} from "./platforms/hubspot/hubspot-page-adapter.js";
|
|
||||||
|
|
||||||
const {isDev, developmentBlockName} = getConfigs();
|
const {isDev, developmentBlockName} = getConfigs();
|
||||||
const blockName = !isDev && config.has('blockName') ? config.get('blockName') : developmentBlockName;
|
const blockName = !isDev && config.has('blockName') ? config.get('blockName') : developmentBlockName;
|
||||||
@@ -39,7 +36,7 @@ export const PLATFORM_OPTIONS = [{
|
|||||||
|
|
||||||
const data = await getExportData();
|
const data = await getExportData();
|
||||||
const selectedPlatform = PLATFORM_OPTIONS[data['platform']];
|
const selectedPlatform = PLATFORM_OPTIONS[data['platform']];
|
||||||
await buildExportFiles(selectedPlatform);
|
await buildExportFiles(blockName, selectedPlatform);
|
||||||
|
|
||||||
console.log('--------------------\nDone!');
|
console.log('--------------------\nDone!');
|
||||||
|
|
||||||
@@ -47,24 +44,6 @@ console.log('--------------------\nDone!');
|
|||||||
// Functions
|
// Functions
|
||||||
//
|
//
|
||||||
|
|
||||||
export async function buildExportFiles(platform) {
|
|
||||||
if (platform.name.startsWith('wordpress')) {
|
|
||||||
if (platform.name === 'wordpress-blocks') {
|
|
||||||
await buildWordPress(blockName, {block: true});
|
|
||||||
} else if (platform.name === 'wordpress-elementor') {
|
|
||||||
await buildWordPress(blockName, {elementor: true});
|
|
||||||
} else if (platform.name === 'wordpress-component-manager') {
|
|
||||||
await buildWordPress(blockName, {componentManager: true});
|
|
||||||
} else {
|
|
||||||
await buildWordPress(blockName);
|
|
||||||
}
|
|
||||||
} else if (platform.name === 'hubspot-email') {
|
|
||||||
await buildHubspotEmail(blockName)
|
|
||||||
} else if (platform.name === 'hubspot') {
|
|
||||||
await buildHubspotPage(blockName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getExportData() {
|
function getExportData() {
|
||||||
return prompts([
|
return prompts([
|
||||||
{
|
{
|
||||||
|
|||||||
+21
@@ -5,6 +5,9 @@ import memFs from 'mem-fs';
|
|||||||
import editor from 'mem-fs-editor';
|
import editor from 'mem-fs-editor';
|
||||||
import fsExtra from "fs-extra";
|
import fsExtra from "fs-extra";
|
||||||
import archiver from "archiver";
|
import archiver from "archiver";
|
||||||
|
import {buildWordPress} from "./platforms/wordpress/wordpress-adapter.js";
|
||||||
|
import {buildHubspotEmail} from "./platforms/hubspot/hubspot-email-adapter.js";
|
||||||
|
import {buildHubspotPage} from "./platforms/hubspot/hubspot-page-adapter.js";
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
@@ -152,3 +155,21 @@ export async function zipProject(srcDir, outputFileName = 'dist.zip') {
|
|||||||
// 'close', 'end' or 'finish' may be fired right after calling this method so register to them beforehand
|
// 'close', 'end' or 'finish' may be fired right after calling this method so register to them beforehand
|
||||||
await archive.finalize();
|
await archive.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function buildExportFiles(blockName, platform) {
|
||||||
|
if (platform.name.startsWith('wordpress')) {
|
||||||
|
if (platform.name === 'wordpress-acf-block') {
|
||||||
|
await buildWordPress(blockName, {block: true});
|
||||||
|
} else if (platform.name === 'wordpress-elementor') {
|
||||||
|
await buildWordPress(blockName, {elementor: true});
|
||||||
|
} else if (platform.name === 'wordpress-component-manager') {
|
||||||
|
await buildWordPress(blockName, {componentManager: true});
|
||||||
|
} else {
|
||||||
|
await buildWordPress(blockName);
|
||||||
|
}
|
||||||
|
} else if (platform.name === 'hubspot-email') {
|
||||||
|
await buildHubspotEmail(blockName)
|
||||||
|
} else if (platform.name === 'hubspot') {
|
||||||
|
await buildHubspotPage(blockName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user