From edbfd5c30688331c4a89cd1f24c336eac1137bf6 Mon Sep 17 00:00:00 2001 From: Luan Date: Wed, 31 Mar 2021 06:04:08 +0200 Subject: [PATCH] docs: update readme --- installer/index.js | 50 ++++----- installer/modules/clearConsole.js | 12 ++- installer/modules/handleError.js | 9 +- installer/modules/printNextSteps.js | 96 ++++++++++-------- installer/modules/run.js | 151 ++++++++++++++-------------- installer/package.json | 2 +- package-lock.json | 4 +- package.json | 2 +- 8 files changed, 166 insertions(+), 160 deletions(-) diff --git a/installer/index.js b/installer/index.js index 5ba272b..5ba4c1f 100755 --- a/installer/index.js +++ b/installer/index.js @@ -1,48 +1,38 @@ -#!/usr/bin/env node -/** - * Main Installer for FuzzyMail - * Check the node version if above 8 then run the app. - * - * Credits: - * Ahmad Awais - https://twitter.com/MrAhmadAwais/ - * Luan Gjokaj - https://twitter.com/luangjokaj/ - */ - -'use strict'; +"use strict"; const currentNodeVersion = process.versions.node; -const semver = currentNodeVersion.split('.'); +const semver = currentNodeVersion.split("."); const major = semver[0]; -const prompts = require('prompts'); -const chalk = require('chalk'); +const prompts = require("prompts"); +const chalk = require("chalk"); -const program = require('commander'); -const version = require('../package.json').version; +const program = require("commander"); +const version = require("../package.json").version; program - .version(version, '-v, --vers', 'output the current version') + .version(version, "-v, --vers", "output the current version") .parse(process.argv); (async () => { const response = await prompts({ - type: 'confirm', - name: 'value', + type: "confirm", + name: "value", message: `Do you want to install ${chalk.white.bgGreen( - 'šŸ“Ø FuzzyMail', + "šŸ“Ø FuzzyMail", )} in the current directory?\n${chalk.red(process.cwd())}`, }); if (response.value) { - // If below Node 8. + // If below Node 8 if (8 > major) { console.error( chalk.red( - 'You are running Node ' + + "You are running Node " + currentNodeVersion + - '.\n' + - 'Install FuzzyMail requires Node 8 or higher. \n' + - 'Kindly, update your version of Node.', + ".\n" + + "Install FuzzyMail requires Node 8 or higher. \n" + + "Kindly, update your version of Node.", ), ); process.exit(1); @@ -50,17 +40,17 @@ program // Makes the script crash on unhandled rejections instead of silently // ignoring them. In the future, promise rejections that are not handled will - // terminate the Node.js process with a non-zero exit code. - process.on('unhandledRejection', err => { + // terminate the Node.js process with a non-zero exit code + process.on("unhandledRejection", (err) => { throw err; }); /** - * Run the entire program. + * Run the entire program * - * Runs all the functions with async/await. + * Runs all the functions with async/await */ - const run = require('./modules/run'); + const run = require("./modules/run"); run(); } })(); diff --git a/installer/modules/clearConsole.js b/installer/modules/clearConsole.js index 8adbf10..9e7261f 100755 --- a/installer/modules/clearConsole.js +++ b/installer/modules/clearConsole.js @@ -1,11 +1,15 @@ /** - * Cross platform clear console. + * Cross platform clear console * - * Support for win32 and others. + * Support for win32 and others */ -'use strict'; +"use strict"; module.exports = () => { - process.stdout.write('win32' === process.platform ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H'); + process.stdout.write( + "win32" === process.platform + ? "\x1B[2J\x1B[0f" + : "\x1B[2J\x1B[3J\x1B[H", + ); }; diff --git a/installer/modules/handleError.js b/installer/modules/handleError.js index 0649c50..4434a14 100755 --- a/installer/modules/handleError.js +++ b/installer/modules/handleError.js @@ -1,10 +1,7 @@ -/** - * Error handler - */ -'use strict'; +"use strict"; -module.exports = err => { +module.exports = (err) => { if (err) { - console.log('ERROR: ' + err); // eslint-disable-line no-console + console.log("ERROR: " + err); } }; diff --git a/installer/modules/printNextSteps.js b/installer/modules/printNextSteps.js index 589b0e6..357b5ce 100755 --- a/installer/modules/printNextSteps.js +++ b/installer/modules/printNextSteps.js @@ -1,58 +1,68 @@ -/** - * Prints next steps. - * - * @param {string} blockName The block name. - * @param {string} blockDir The block directory. - */ - -const chalk = require('chalk'); +const chalk = require("chalk"); module.exports = () => { - console.log('\n\nāœ… ', chalk.black.bgGreen(' All done! Happy coding. \n')); + console.log("\n\nāœ… ", chalk.black.bgGreen(" All done! Happy coding. \n")); console.log( - 'Installer has added šŸ“Ø FuzzyMail files to the current directory. ', - '\nInside this directory, you can run this command:', + "Installer has added šŸ“Ø FuzzyMail files to the current directory. ", + "\nInside this directory, you can run this command:", ); - // Scripts. + // Scripts console.log( - '\nšŸ‘‰ ', - ' Type', - chalk.black.bgWhite(' npm run dev '), - '\n\n', - ' Use to compile and run your files.', - '\n', - ' Watches for any changes and reports back any errors in your code.', + "\nšŸ‘‰ ", + " Type", + chalk.black.bgWhite(" npm run dev "), + "\n\n", + " Use to compile and run your files.", + "\n", + " Watches for any changes and reports back any errors in your code.", ); - // Support. - console.log('\nāœŠ ', chalk.black.bgYellow(' Support FuzzyMail \n')); - console.log('Like FuzzyMail? Check out our other free and open source repositories: \n'); + // Support + console.log("\nāœŠ ", chalk.black.bgYellow(" Support FuzzyMail \n")); + console.log( + "Like FuzzyMail? Check out our other free and open source repositories: \n", + ); console.log( - ` ${chalk.yellow('WordPressify ā†’ ')} https://bit.ly/2KTqyQX`, - '\n', - ` ${chalk.gray('Development workflow for WordPress themes.')}`, - '\n', - ` ${chalk.yellow('GoPablo ā†’ ')} https://bit.ly/2Hgkfpy`, - '\n', - ` ${chalk.gray('GoPablo is a static site generator.')}`, - '\n', - ` ${chalk.yellow('ReactFondue ā†’ ')} https://bit.ly/2OXgStR`, - '\n', - ` ${chalk.gray('SEO optimized React applications with SSR.')}`, - '\n', - ` ${chalk.green('Powered by Riangle ā†’ ')} https://bit.ly/2P5i26I`, - '\n', - '\n', - ` ${chalk.red('Thank you for using šŸ“Ø FuzzyMail ā†’ ')} https://www.fuzzymail.co`, + ` ${chalk.yellow("Cherry ā†’ ")} https://bit.ly/3sEr75P`, + "\n", + ` ${chalk.gray("ā€¢ A design system to build the web.")}`, + "\n", + ` ${chalk.yellow("GoPablo ā†’ ")} http://bit.ly/2Hgkfpy`, + "\n", + ` ${chalk.gray("ā€¢ Create optimized static websites.")}`, + "\n", + ` ${chalk.yellow("WordPressify ā†’ ")} https://bit.ly/2KTqyQX`, + "\n", + ` ${chalk.gray("ā€¢ Automate your WordPress development workflow.")}`, + "\n", + ` ${chalk.yellow("Nextify ā†’ ")} https://bit.ly/3m4lVWm`, + "\n", + ` ${chalk.gray("ā€¢ React apps using Next.js and Emotion.")}`, + "\n", + ` ${chalk.yellow("FuzzyMail ā†’ ")} https://bit.ly/2P3Irlr`, + "\n", + ` ${chalk.gray("ā€¢ Responsive email template generator.")}`, + "\n", + ` ${chalk.green("Powered by Riangle ā†’ ")} https://bit.ly/2P5i26I`, + "\n", + "\n", + ` ${chalk.red( + "Thank you for using šŸ“Ø FuzzyMail ā†’ ", + )} https://www.fuzzymail.co`, ); - // Get started. - console.log('\n\nšŸŽÆ ', chalk.black.bgGreen(' Get Started ā†’ \n')); - console.log(' You can start: \n'); + // Get started + console.log("\n\nšŸŽÆ ", chalk.black.bgGreen(" Get Started ā†’ \n")); + console.log(" You can start: \n"); + console.log( + ` ${chalk.dim("1.")} Editing your new email template: ${chalk.green( + `${process.cwd()}/src`, + )}`, + ); console.log( - ` ${chalk.dim('1.')} Editing your new email template: ${chalk.green(`${process.cwd()}/src`)}`, + ` ${chalk.dim("2.")} Running: ${chalk.green("npm")} run dev`, + "\n\n", ); - console.log(` ${chalk.dim('2.')} Running: ${chalk.green('npm')} run dev`, '\n\n'); process.exit(); }; diff --git a/installer/modules/run.js b/installer/modules/run.js index d20c58b..d0cc24e 100755 --- a/installer/modules/run.js +++ b/installer/modules/run.js @@ -1,27 +1,23 @@ -/** - * Install WPGulp - */ - -const fs = require('fs'); +const fs = require("fs"); const theCWD = process.cwd(); -const theCWDArray = theCWD.split('/'); +const theCWDArray = theCWD.split("/"); const theDir = theCWDArray[theCWDArray.length - 1]; -const ora = require('ora'); -const execa = require('execa'); -const chalk = require('chalk'); -const download = require('download'); -const handleError = require('./handleError.js'); -const clearConsole = require('./clearConsole.js'); -const printNextSteps = require('./printNextSteps.js'); -const version = require('../package.json').version; +const ora = require("ora"); +const execa = require("execa"); +const chalk = require("chalk"); +const download = require("download"); +const handleError = require("./handleError.js"); +const clearConsole = require("./clearConsole.js"); +const printNextSteps = require("./printNextSteps.js"); +const version = require("../package.json").version; module.exports = () => { - // Init. + // Init clearConsole(); let upstreamUrl = `https://raw.githubusercontent.com/luangjokaj/fuzzymail/v${version}`; - // Files. + // Files const filesToDownload = [ `${upstreamUrl}/.gitignore`, `${upstreamUrl}/.editorconfig`, @@ -58,105 +54,114 @@ module.exports = () => { ]; // Organise file structure - const dotFiles = ['.gitignore', '.editorconfig']; - const srcFiles = ['index.html']; + const dotFiles = [".gitignore", ".editorconfig"]; + const srcFiles = ["index.html"]; const includesFiles = [ - 'footer.html', - 'header.html', - 'logo.html', - 'single-column.html', - 'socials.html', - 'title.html', - 'two-columns.html', + "footer.html", + "header.html", + "logo.html", + "single-column.html", + "socials.html", + "title.html", + "two-columns.html", ]; const cssFiles = [ - 'email-framework.css', - 'fuzzy.css', - 'globals.css', - 'styles.css', - 'variables.css', + "email-framework.css", + "fuzzy.css", + "globals.css", + "styles.css", + "variables.css", ]; const socialImgFiles = [ - 'email.png', - 'facebook.png', - 'instagram.png', - 'linkedin.png', - 'twitter.png', + "email.png", + "facebook.png", + "instagram.png", + "linkedin.png", + "twitter.png", ]; - const imgFiles = ['header.png', 'logo.png', 'logo.svg']; + const imgFiles = ["header.png", "logo.png", "logo.svg"]; - // Start. - console.log('\n'); + // Start + console.log("\n"); console.log( - 'šŸ“¦ ', + "šŸ“¦ ", chalk.black.bgYellow( - ` Downloading šŸ“Ø FuzzyMail files in: ā†’ ${chalk.bgGreen(` ${theDir} `)}\n` + ` Downloading šŸ“Ø FuzzyMail files in: ā†’ ${chalk.bgGreen( + ` ${theDir} `, + )}\n`, ), chalk.dim(`\n In the directory: ${theCWD}\n`), - chalk.dim('This might take a couple of minutes.\n') + chalk.dim("This might take a couple of minutes.\n"), ); - const spinner = ora({ text: '' }); + const spinner = ora({ text: "" }); spinner.start( `1. Creating šŸ“Ø FuzzyMail files inside ā†’ ${chalk.black.bgWhite( - ` ${theDir} ` - )}` + ` ${theDir} `, + )}`, ); - // Download. + // Download Promise.all(filesToDownload.map((x) => download(x, `${theCWD}`))).then( async () => { - if (!fs.existsSync('src')) { - await execa('mkdir', [ - 'src', - 'src/includes', - 'src/assets', - 'src/assets/css', - 'src/assets/img', - 'src/assets/img/socialmedia', + if (!fs.existsSync("src")) { + await execa("mkdir", [ + "src", + "src/includes", + "src/assets", + "src/assets/css", + "src/assets/img", + "src/assets/img/socialmedia", ]); } dotFiles.map((x) => fs.rename(`${theCWD}/${x.slice(1)}`, `${theCWD}/${x}`, (err) => - handleError(err) - ) + handleError(err), + ), ); srcFiles.map((x) => - fs.rename(`${theCWD}/${x}`, `${theCWD}/src/${x}`, (err) => handleError(err)) + fs.rename(`${theCWD}/${x}`, `${theCWD}/src/${x}`, (err) => + handleError(err), + ), ); includesFiles.map((x) => - fs.rename(`${theCWD}/${x}`, `${theCWD}/src/includes/${x}`, (err) => - handleError(err) - ) + fs.rename( + `${theCWD}/${x}`, + `${theCWD}/src/includes/${x}`, + (err) => handleError(err), + ), ); cssFiles.map((x) => - fs.rename(`${theCWD}/${x}`, `${theCWD}/src/assets/css/${x}`, (err) => - handleError(err) - ) + fs.rename( + `${theCWD}/${x}`, + `${theCWD}/src/assets/css/${x}`, + (err) => handleError(err), + ), ); socialImgFiles.map((x) => fs.rename( `${theCWD}/${x}`, `${theCWD}/src/assets/img/socialmedia/${x}`, - (err) => handleError(err) - ) + (err) => handleError(err), + ), ); imgFiles.map((x) => - fs.rename(`${theCWD}/${x}`, `${theCWD}/src/assets/img/${x}`, (err) => - handleError(err) - ) + fs.rename( + `${theCWD}/${x}`, + `${theCWD}/src/assets/img/${x}`, + (err) => handleError(err), + ), ); spinner.succeed(); - // The npm install. - spinner.start('2. Installing npm packages...'); - // await execa('npm', ['install', '--silent']); - await execa('npm', ['install']); + // The npm install + spinner.start("2. Installing npm packages..."); + await execa("npm", ["install"]); spinner.succeed(); - // Done. + // Done printNextSteps(); - } + }, ); }; diff --git a/installer/package.json b/installer/package.json index 0b41ab2..53b7579 100644 --- a/installer/package.json +++ b/installer/package.json @@ -1,6 +1,6 @@ { "name": "fuzzymail", - "version": "0.0.8-15", + "version": "0.0.8-16", "description": "Making emails fun again.", "keywords": [ "boilerplate", diff --git a/package-lock.json b/package-lock.json index 0f11374..e8b79e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "fuzzymail", - "version": "0.0.8-15", + "version": "0.0.8-16", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "0.0.8-15", + "version": "0.0.8-16", "license": "MIT", "dependencies": { "chalk": "^4.1.0", diff --git a/package.json b/package.json index 06af1fe..aa86a5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fuzzymail", - "version": "0.0.8-15", + "version": "0.0.8-16", "description": "Making emails fun again.", "keywords": [ "boilerplate",