|
|
@ -10,10 +10,6 @@ const __filename = fileURLToPath(import.meta.url); |
|
|
const __dirname = path.dirname(__filename); |
|
|
const __dirname = path.dirname(__filename); |
|
|
|
|
|
|
|
|
export async function buildWordPress(blockName, args = {}) { |
|
|
export async function buildWordPress(blockName, args = {}) { |
|
|
const isBlock = args.platform === 'wordpress-acf-block'; |
|
|
|
|
|
const isElementor = args.platform === 'wordpress-elementor'; |
|
|
|
|
|
const isComponentManager = args.platform === 'wordpress-component-manager' |
|
|
|
|
|
|
|
|
|
|
|
const {modulesPath, projectPath} = getConfigs(); |
|
|
const {modulesPath, projectPath} = getConfigs(); |
|
|
|
|
|
|
|
|
const distPath = path.join(projectPath, 'exports', args.platform); |
|
|
const distPath = path.join(projectPath, 'exports', args.platform); |
|
|
@ -37,12 +33,7 @@ export async function buildWordPress(blockName, args = {}) { |
|
|
ownerClass: owner.replace(/ /ig, '_'), |
|
|
ownerClass: owner.replace(/ /ig, '_'), |
|
|
ownerFilename: owner.toLowerCase().replace(/ /ig, '-'), |
|
|
ownerFilename: owner.toLowerCase().replace(/ /ig, '-'), |
|
|
templateFormat: 'php', |
|
|
templateFormat: 'php', |
|
|
include_acf_block: isBlock, |
|
|
|
|
|
include_native_gutenberg_block: false, |
|
|
|
|
|
include_script: true, |
|
|
include_script: true, |
|
|
include_elementor_widget: isElementor, |
|
|
|
|
|
isElementor, |
|
|
|
|
|
isComponentManager, |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
await copyFile(blockFilePath, path.join(distPath, data.blockFilename + '.block.json')); |
|
|
await copyFile(blockFilePath, path.join(distPath, data.blockFilename + '.block.json')); |
|
|
@ -84,15 +75,6 @@ export async function buildWordPress(blockName, args = {}) { |
|
|
json: await readJSONFile(path.join(projectPath, 'data', 'default.json'), "utf8"), |
|
|
json: await readJSONFile(path.join(projectPath, 'data', 'default.json'), "utf8"), |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// await createFiles(Object.assign({}, data, {defaultData: phpDataObject}), [{
|
|
|
|
|
|
// from: `templates/helpers/Template_Defaults.php`,
|
|
|
|
|
|
// to: `helpers/${data.blockClassModel}_Defaults.php`,
|
|
|
|
|
|
// }], {
|
|
|
|
|
|
// pathDist: distPath,
|
|
|
|
|
|
// generatorsPath: path.join(__dirname),
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
if (isElementor) { |
|
|
|
|
|
await createFiles(data, [{ |
|
|
await createFiles(data, [{ |
|
|
from: `templates/helpers/Template_Elementor_Widget.php`, |
|
|
from: `templates/helpers/Template_Elementor_Widget.php`, |
|
|
to: `helpers/${data.blockClassModel}_Elementor_Widget.php`, |
|
|
to: `helpers/${data.blockClassModel}_Elementor_Widget.php`, |
|
|
@ -100,25 +82,7 @@ export async function buildWordPress(blockName, args = {}) { |
|
|
pathDist: distPath, |
|
|
pathDist: distPath, |
|
|
generatorsPath: path.join(__dirname) |
|
|
generatorsPath: path.join(__dirname) |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isBlock) { |
|
|
|
|
|
await createFiles(data, [{ |
|
|
|
|
|
from: `templates/Template_Component.php`, |
|
|
|
|
|
to: `${data.blockClassModel}_Component.php`, |
|
|
|
|
|
}], { |
|
|
|
|
|
pathDist: distPath, |
|
|
|
|
|
generatorsPath: path.join(__dirname) |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// await createFiles(data, [{
|
|
|
|
|
|
// from: `templates/helpers/Template_API.php`,
|
|
|
|
|
|
// to: `helpers/${data.blockClassModel}_API.php`,
|
|
|
|
|
|
// }], {
|
|
|
|
|
|
// pathDist: distPath,
|
|
|
|
|
|
// generatorsPath: path.join(__dirname)
|
|
|
|
|
|
// });
|
|
|
|
|
|
} else { |
|
|
|
|
|
await createFiles(data, [{ |
|
|
await createFiles(data, [{ |
|
|
from: `templates/Template_Basic_Component.php`, |
|
|
from: `templates/Template_Basic_Component.php`, |
|
|
to: `${data.blockClassModel}_Component.php`, |
|
|
to: `${data.blockClassModel}_Component.php`, |
|
|
@ -127,7 +91,6 @@ export async function buildWordPress(blockName, args = {}) { |
|
|
generatorsPath: path.join(__dirname) |
|
|
generatorsPath: path.join(__dirname) |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function execCommand(cmd = '') { |
|
|
export function execCommand(cmd = '') { |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
|