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.
 
 
 
 

70 lines
1.7 KiB

#!/usr/bin/env node
// For development purposes - run `npm run build-platform`.
import config from 'config';
import prompts from "prompts";
import {buildHubspot} from "./platforms/hubspot/hubspot-adapter.js";
import {getConfigs} from "./helpers.js";
import {buildWordPress} from "./platforms/wordpress/wordpress-adapter.js";
const {isDev, developmentBlockName} = getConfigs();
const blockName = !isDev && config.has('blockName') ? config.get('blockName') : developmentBlockName;
export const PLATFORM_OPTIONS = [{
name: 'wordpress',
title: 'WordPress'
}, {
name: 'wordpress-blocks',
title: 'WordPress Block'
}, {
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 (['wordpress', 'php'].includes(platform.name)) {
if (platform.name === 'wordpress') {
await buildWordPress(blockName);
} else {
if (platform.name === 'wordpress-blocks') {
await buildWordPress(blockName, true);
}
}
} else if (platform.name === 'hubspot-email') {
await buildHubspot(blockName)
} else if (platform.name === 'hubspot') {
console.log('"Hubspot" Coming soon...');
}
}
function getExportData() {
return prompts([
{
type: "select",
name: "platform",
message: "Choose Platform",
choices: PLATFORM_OPTIONS.map(item => item.title),
default: 'WordPress'
}
]);
}