UNPKG

1.36 kBJavaScriptView Raw
1/**
2 * Run the entire program.
3 *
4 * Runs all the functions with async/await.
5 */
6
7'use strict';
8
9const ora = require( 'ora' );
10const chalk = require( 'chalk' );
11const cli = require( './cli' );
12const prePrint = require( './prePrint' );
13const initBlock = require( './initBlock' );
14const getBlockDir = require( './getBlockDir' );
15const clearConsole = require( './consoleClear' );
16const updateNotifier = require( './updateNotifier' );
17const createPluginDir = require( './createPluginDir' );
18const npmInstallScripts = require( './npmInstallScripts' );
19
20module.exports = async() => {
21 clearConsole();
22
23 // 0. Update notifier.
24 updateNotifier();
25
26 // 1. Set the CLI and get the blockName.
27 const blockName = cli();
28
29 // 2. Build the block direcotry path.
30 const blockDir = await getBlockDir( blockName );
31
32 // 2. Pre print.
33 await prePrint( blockName, blockDir );
34
35 // 3. Create the plugin directory.
36 // Init the spinner.
37 const spinner = ora( { text: '' } );
38
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
49 spinner.start( '2. Installing npm packages...' );
50 await npmInstallScripts( blockName, blockDir );
51 spinner.succeed();
52
53 // 5. Initialize the block.
54 await initBlock( blockName, blockDir );
55};