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.
43 lines
1.2 KiB
43 lines
1.2 KiB
#!/usr/bin/env node
|
|
|
|
const {exec} = require('child_process');
|
|
const config = require('config');
|
|
const Generator = require("yeoman-generator");
|
|
|
|
const isDev = process.env.NODE_ENV === 'development'; // Check README file in case you get "missing files" error.
|
|
const modulePath = isDev ? '' : 'node_modules/create-block-dev-tool/';
|
|
|
|
const blockName = config.has('blockName') ? config.get('blockName') : 'development';
|
|
|
|
module.exports = class extends Generator {
|
|
async prompting() {
|
|
this.data = await this.prompt([
|
|
{
|
|
type: "list",
|
|
name: "platfrom",
|
|
message: "Choose Platform",
|
|
choices: ['WordPress', 'Hubspot', 'JavaScript', 'PHP'],
|
|
default: 'WordPress'
|
|
}
|
|
])
|
|
}
|
|
|
|
writing() {
|
|
new Promise((resolve => {
|
|
if (['WordPress', 'PHP'].includes(this.data.platfrom)) {
|
|
exec(`cd adapters/php && composer install && php build.php '${blockName}' '${modulePath}'`, function (error, stdout, stderr) {
|
|
console.log(stdout);
|
|
resolve();
|
|
});
|
|
} else if (this.data.platform === 'Hubspot') {
|
|
console.log('Coming soon...');
|
|
resolve();
|
|
} else {
|
|
resolve();
|
|
}
|
|
}))
|
|
.then(() => {
|
|
console.log('--------------------\nDone!');
|
|
});
|
|
}
|
|
}
|
|
|