You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

78 lines
2.1 KiB

#!/usr/bin/env node
// For development purposes - run `npm run build-platform`.
import config from 'config';
import prompts from "prompts";
import {buildHubspotEmail} from "./platforms/hubspot/hubspot-email-adapter.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 blockName = !isDev && config.has('blockName') ? config.get('blockName') : developmentBlockName;
export const PLATFORM_OPTIONS = [{
name: 'wordpress-blocks',
title: 'WordPress AFC Block'
}, {
name: 'wordpress',
title: 'WordPress'
}, {
name: 'wordpress-component-manager',
title: 'WordPress (Component Manager)'
}, {
name: 'wordpress-elementor',
title: 'WordPress Elementor'
}, {
name: 'hubspot',
title: 'Hubspot'
}, {
name: 'hubspot-email',
title: 'Hubspot Email'
}, {
name: 'javascript',
title: 'JavaScript'
}, {
name: 'php',
title: 'PHP'
}];
const data = await getExportData();
const selectedPlatform = PLATFORM_OPTIONS[data['platform']];
await buildExportFiles(selectedPlatform);
console.log('--------------------\nDone!');
//
// 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() {
return prompts([
{
type: "select",
name: "platform",
message: "Choose Platform",
choices: PLATFORM_OPTIONS.map(item => item.title),
default: 'WordPress'
}
]);
}