Node build scaffolding

clipboard.png

  -sharp!/usr/bin/env node
const fs = require("fs");
const program = require("commander");
const download = require("download-git-repo");
const handlebars = require("handlebars");
const inquirer = require("inquirer");
const ora = require("ora");
const chalk = require("chalk");
const symbols = require("log-symbols");

program.version("1.0.0", "-v, --version")
    .command("init <name>")
    .action((name) => {
        if(!fs.existsSync(name)){
            inquirer.prompt([
                {
                    name: "description",
                    message: ""
                },
                {
                    name: "author",
                    message: ""
                }
            ]).then((answers) => {
                const spinner = ora("...");
                spinner.start();
                download("https://github.com/yuhaiyang1/webpack4.git", name, {clone: true}, (err) => {
                    if(err){
                        spinner.fail();
                        console.log(symbols.error, chalk.red(err));
                    }else{
                        spinner.succeed();
                        const fileName = `${name}/package.json`;
                        const meta = {
                            name,
                            description: answers.description,
                            author: answers.author
                        }
                        if(fs.existsSync(fileName)){
                            const content = fs.readFileSync(fileName).toString();
                            const result = handlebars.compile(content)(meta);
                            fs.writeFileSync(fileName, result);
                        }
                        console.log(symbols.success, chalk.green(""));
                    }
                })
            })
        }else{
            // 
            console.log(symbols.error, chalk.red(""));
        }
    })
program.parse(process.argv);
Nov.20,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e47c07-43bd5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e47c07-43bd5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?