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.
55 lines
1.8 KiB
55 lines
1.8 KiB
#!/usr/bin/env node
|
|
|
|
import {exec} from 'child_process';
|
|
import config from 'config';
|
|
import Generator from "yeoman-generator";
|
|
import yeoman from 'yeoman-environment';
|
|
import {buildHubspot} from "./platforms/hubspot/hubspot-adapter.js";
|
|
|
|
const isDev = process.env.NODE_ENV === 'development' || (config.has('isDev') && config.get('isDev')); // Check README file in case you get "missing files" error.
|
|
const modulePath = isDev ? '' : 'node_modules/block-dev-tool/';
|
|
|
|
const blockName = config.has('blockName') ? config.get('blockName') : 'development';
|
|
|
|
class buildGenerator extends Generator {
|
|
async prompting() {
|
|
this.data = await this.prompt([
|
|
{
|
|
type: "list",
|
|
name: "platform",
|
|
message: "Choose Platform",
|
|
choices: ['WordPress', 'Hubspot', 'Hubspot Email', 'JavaScript', 'PHP'],
|
|
default: 'WordPress'
|
|
}
|
|
])
|
|
}
|
|
|
|
writing() {
|
|
new Promise((resolve => {
|
|
if (['WordPress', 'PHP'].includes(this.data.platform)) {
|
|
const backPath = modulePath ? modulePath.substr(-1).split('/').map(() => '..').join('/') : '';
|
|
exec(`cd ${modulePath}platforms/php && composer install && php build.php '${blockName}' '${backPath}'`, function (error, stdout) {
|
|
console.log(stdout);
|
|
resolve();
|
|
});
|
|
} else if (this.data.platform === 'Hubspot Email') {
|
|
buildHubspot(blockName)
|
|
.then(() => {
|
|
resolve();
|
|
});
|
|
} else if (this.data.platform === 'Hubspot') {
|
|
console.log('"Hubspot" Coming soon...');
|
|
resolve();
|
|
} else {
|
|
resolve();
|
|
}
|
|
}))
|
|
.then(() => {
|
|
console.log('--------------------\nDone!');
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
const build = new buildGenerator([], {env: yeoman.createEnv()}, {});
|
|
build.run().then(() => null);
|
|
|