import path from "path"; import {copyFile, readFile, writeFile} from "fs/promises"; import {capitalize, getConfigs} from "../../helpers.js"; import {buildHubspotJSONFiles, createDistFolder, handlebarsToHubl,} from "./hubspot-email-adapter.js"; const {modulesPath, projectPath} = getConfigs(); export async function buildHubspotPage(blockName) { const distPath = await createDistFolder(blockName); const srcPath = path.join(projectPath, 'src'); // Template let handlebars = await readFile(path.join(srcPath, `${blockName}.template.hbs`), "utf8"); await writeFile(path.join(distPath, 'module.html'), handlebarsToHubl(handlebars)); // Assets await copyFile(path.join(srcPath, 'styles', `${blockName}.min.css`), path.join(distPath, 'module.css')); await copyFile(path.join(srcPath, 'scripts', `${blockName}.min.js`), path.join(distPath, 'module.js')); // await copy(path.join(projectPath, 'src', 'images'), path.join(distPath, 'images')); // JSON await buildHubspotJSONFiles(distPath, { global: false, host_template_types: ["PAGE"], label: capitalize(blockName), is_available_for_new_content: true }); }