-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da4ccd5
commit 35f145a
Showing
8 changed files
with
783 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/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'; | ||
|
||
const currentNodeVersion = process.versions.node; | ||
const semver = currentNodeVersion.split('.'); | ||
const major = semver[0]; | ||
|
||
const prompts = require('prompts'); | ||
const chalk = require('chalk'); | ||
|
||
const program = require('commander'); | ||
const version = require('../package.json').version; | ||
|
||
program | ||
.version(version) | ||
.option('-v, --version', 'version') | ||
.parse(process.argv); | ||
|
||
(async () => { | ||
const response = await prompts({ | ||
type: 'confirm', | ||
name: 'value', | ||
message: `Do you want to install ${chalk.white.bgGreen( | ||
'π¨ FuzzyMail', | ||
)} in the current directory?\n${chalk.red(process.cwd())}`, | ||
}); | ||
|
||
if (response.value) { | ||
// If below Node 8. | ||
if (8 > major) { | ||
console.error( | ||
chalk.red( | ||
'You are running Node ' + | ||
currentNodeVersion + | ||
'.\n' + | ||
'Install FuzzyMail requires Node 8 or higher. \n' + | ||
'Kindly, update your version of Node.', | ||
), | ||
); | ||
process.exit(1); | ||
} | ||
|
||
// 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 => { | ||
throw err; | ||
}); | ||
|
||
/** | ||
* Run the entire program. | ||
* | ||
* Runs all the functions with async/await. | ||
*/ | ||
const run = require('./modules/run'); | ||
run(); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Cross platform clear console. | ||
* | ||
* Support for win32 and others. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = () => { | ||
process.stdout.write('win32' === process.platform ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Error handler | ||
*/ | ||
'use strict'; | ||
|
||
module.exports = err => { | ||
if (err) { | ||
console.log('ERROR: ' + err); // eslint-disable-line no-console | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* Prints next steps. | ||
* | ||
* @param {string} blockName The block name. | ||
* @param {string} blockDir The block directory. | ||
*/ | ||
|
||
const chalk = require('chalk'); | ||
|
||
module.exports = () => { | ||
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:', | ||
); | ||
|
||
// 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.', | ||
); | ||
|
||
// 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`, | ||
); | ||
|
||
// 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('2.')} Running: ${chalk.green('npm')} run dev`, '\n\n'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/** | ||
* Install WPGulp | ||
*/ | ||
|
||
const fs = require('fs'); | ||
const theCWD = process.cwd(); | ||
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'); | ||
|
||
module.exports = () => { | ||
// Init. | ||
clearConsole(); | ||
|
||
// Files. | ||
const filesToDownload = [ | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/.gitignore', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/LICENSE', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/README.md', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/gulpfile.js', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/package-lock.json', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/package.json', | ||
|
||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/index.html', | ||
|
||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/includes/footer.html', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/includes/header.html', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/includes/logo.html', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/includes/single-column.html', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/includes/socials.html', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/includes/title.html', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/includes/two-columns.html', | ||
|
||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/assets/css/email-framework.css', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/assets/css/fuzzy.css', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/assets/css/globals.css', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/assets/css/styles.css', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/assets/css/variables.css', | ||
|
||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/assets/img/socialmedia/email.png', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/assets/img/socialmedia/facebook.png', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/assets/img/socialmedia/instagram.png', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/assets/img/socialmedia/linkedin.png', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/assets/img/socialmedia/twitter.png', | ||
|
||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/assets/img/header.png', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/assets/img/logo.png', | ||
'https://raw.githubusercontent.com/luangjokaj/fuzzymail/master/src/assets/img/logo.svg', | ||
]; | ||
|
||
// Organise file structure | ||
const dotFiles = ['.gitignore']; | ||
const srcFiles = ['index.html']; | ||
const includesFiles = [ | ||
'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', | ||
]; | ||
const socialImgFiles = [ | ||
'email.png', | ||
'facebook.png', | ||
'instagram.png', | ||
'linkedin.png', | ||
'twitter.png', | ||
]; | ||
const imgFiles = ['header.png', 'logo.png', 'logo.svg']; | ||
|
||
// Start. | ||
console.log('\n'); | ||
console.log( | ||
'π¦ ', | ||
chalk.black.bgYellow(` 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'), | ||
); | ||
|
||
const spinner = ora({ text: '' }); | ||
spinner.start(`1. Creating π¨ FuzzyMail files inside β ${chalk.black.bgWhite(` ${theDir} `)}`); | ||
|
||
// 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', | ||
]); | ||
} | ||
|
||
dotFiles.map(x => | ||
fs.rename(`${theCWD}/${x.slice(1)}`, `${theCWD}/${x}`, err => handleError(err)), | ||
); | ||
srcFiles.map(x => fs.rename(`${theCWD}/${x}`, `${theCWD}/src/${x}`, err => handleError(err))); | ||
includesFiles.map(x => | ||
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)), | ||
); | ||
socialImgFiles.map(x => | ||
fs.rename(`${theCWD}/${x}`, `${theCWD}/src/assets/img/socialmedia/${x}`, err => handleError(err)), | ||
); | ||
imgFiles.map(x => | ||
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']); | ||
spinner.succeed(); | ||
|
||
// Done. | ||
printNextSteps(); | ||
}); | ||
}; |
Oops, something went wrong.