|
| 1 | +/** |
| 2 | + * Run the entire program. |
| 3 | + * |
| 4 | + * Runs all the functions with async/await. |
| 5 | + */ |
| 6 | + |
| 7 | +const ora = require( 'ora' ); |
| 8 | +const chalk = require( 'chalk' ); |
| 9 | +const clearConsole = require( './consoleClear' ); |
| 10 | +const cli = require( './cli' ); |
| 11 | +const getBlockName = require( './getBlockName' ); |
| 12 | +const getBlockDir = require( './getBlockDir' ); |
| 13 | +const prePrint = require( './prePrint' ); |
| 14 | +const createPluginDir = require( './createPluginDir' ); |
| 15 | +const npmInstallScripts = require( './npmInstallScripts' ); |
| 16 | +const initBlock = require( './initBlock' ); |
| 17 | +const updateNotifier = require( './updateNotifier' ); |
| 18 | + |
| 19 | +module.exports = async() => { |
| 20 | + // 0. Set the CLI. |
| 21 | + cli(); |
| 22 | + |
| 23 | + // 0. Clear the console. |
| 24 | + clearConsole(); |
| 25 | + |
| 26 | + // 0. Update notifier. |
| 27 | + updateNotifier(); |
| 28 | + |
| 29 | + // 1. Get the block name and direcotry by sending in the third argument. |
| 30 | + const blockName = await getBlockName( process.argv[ 2 ] ); |
| 31 | + const blockDir = await getBlockDir( blockName ); |
| 32 | + |
| 33 | + // 2. Pre print. |
| 34 | + await prePrint( blockName, blockDir ); |
| 35 | + |
| 36 | + // 3. Create the plugin directory. |
| 37 | + // Init the spinner. |
| 38 | + const spinner = new ora( { text: '', enabled: true } ); |
| 39 | + spinner.start( |
| 40 | + `1. Creating the plugin directory called → ${ chalk.black.bgWhite( |
| 41 | + ` ${ blockName } ` |
| 42 | + ) }` |
| 43 | + ); |
| 44 | + await createPluginDir( blockName ); |
| 45 | + spinner.succeed(); |
| 46 | + |
| 47 | + // 4. NPM install cgb-scripts. |
| 48 | + spinner.start( '2. Installing npm packages...' ); |
| 49 | + await npmInstallScripts( blockName, blockDir ); |
| 50 | + spinner.succeed(); |
| 51 | + |
| 52 | + // 5. Initialize the block. |
| 53 | + await initBlock( blockName, blockDir ); |
| 54 | +}; |
0 commit comments