Skip to content

Commit

Permalink
πŸš€ RELEASE: First
Browse files Browse the repository at this point in the history
  • Loading branch information
luangjokaj committed Aug 20, 2019
1 parent da4ccd5 commit 35f145a
Show file tree
Hide file tree
Showing 8 changed files with 783 additions and 194 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [![GoPablo](src/assets/img/logo.svg)](https://www.fuzzymail.co/)
# [![FuzzyMail](src/assets/img/logo.svg)](https://www.fuzzymail.co/)
[![Dependencies](https://david-dm.org/luangjokaj/fuzzymail/status.svg)](https://david-dm.org/luangjokaj/fuzzymail)

[FuzzyMail](https://www.fuzzymail.co/) is Email template generator. Making emails fun again ✌
Expand Down Expand Up @@ -83,3 +83,7 @@ All styles will be inlined, ready to upload the generated ZIP on mailchimp or el

**Credits:**
- HTML Templates http://emailframe.work/

# Changelog
**v0.0.1**
- πŸš€ RELEASE: First release.
67 changes: 67 additions & 0 deletions installer/index.js
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();
}
})();
11 changes: 11 additions & 0 deletions installer/modules/clearConsole.js
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');
};
10 changes: 10 additions & 0 deletions installer/modules/handleError.js
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
}
};
57 changes: 57 additions & 0 deletions installer/modules/printNextSteps.js
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');
};
137 changes: 137 additions & 0 deletions installer/modules/run.js
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();
});
};
Loading

0 comments on commit 35f145a

Please sign in to comment.