-
-
Notifications
You must be signed in to change notification settings - Fork 303
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
03900de
commit 9ca9ef4
Showing
8 changed files
with
720 additions
and
155 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,10 @@ rtlcss | |
imagemin | ||
npm | ||
npx | ||
execa | ||
fs | ||
editorconfig | ||
eslintignore | ||
eslintrc | ||
gitignore | ||
Dotfiles |
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,43 @@ | ||
#!/usr/bin/env node | ||
/** | ||
* Main Install WPGulp app | ||
* | ||
* Check the node version if above 8 then run the app. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const chalk = require( 'chalk' ); | ||
const currentNodeVersion = process.versions.node; | ||
const semver = currentNodeVersion.split( '.' ); | ||
const major = semver[0]; | ||
|
||
// If below Node 8. | ||
if ( 8 > major ) { | ||
// eslint-disable-next-line no-console | ||
console.error( | ||
chalk.red( | ||
'You are running Node ' + | ||
currentNodeVersion + | ||
'.\n' + | ||
'Install WPGulp 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,43 @@ | ||
/** | ||
* Prints next steps. | ||
* | ||
* @param {string} blockName The block name. | ||
* @param {string} blockDir The block directory. | ||
*/ | ||
|
||
const chalk = require( 'chalk' ); | ||
|
||
/* eslint-disable no-console */ | ||
module.exports = () => { | ||
console.log( '\n\n✅ ', chalk.black.bgGreen( ' All done! Use your code for good. \n' ) ); | ||
console.log( `Installer ${chalk.dim( '(install-wpgulp)' )} has added WPGulp files to the current directory. ` ); | ||
console.log( '\nInside this directory, you can run this command:\n' ); | ||
|
||
// Scripts. | ||
console.log( | ||
'\n👉 ', | ||
' Type', | ||
chalk.black.bgWhite( ' npm start ' ), | ||
'\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\n✊ ', chalk.black.bgYellow( ' Support WPGulp → \n' ) ); | ||
console.log( | ||
'Like WPGulp? You can now support this free and open source project i.e. more updates and better maintenance: \n' | ||
); | ||
console.log( | ||
` ${chalk.yellow( 'Support for one hour or more →' )} https://AhmdA.ws/CGB99`, | ||
'\n', | ||
` ${chalk.yellow( 'More ways to support →' )} https://AhmdA.ws/CGBSupport` | ||
); | ||
|
||
// Get started. | ||
console.log( '\n\n🎯 ', chalk.black.bgGreen( ' Get Started → \n' ) ); | ||
console.log( ' I suggest that you begin by: \n' ); | ||
console.log( ` ${chalk.dim( '1.' )} Editing the ${chalk.green( 'wpgulp.config.js' )} file` ); | ||
console.log( ` ${chalk.dim( '2.' )} Running ${chalk.green( 'npm' )} start`, '\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,60 @@ | ||
/** | ||
* 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/ahmadawais/WPGulp/master/src/.editorconfig', | ||
'https://raw.githubusercontent.com/ahmadawais/WPGulp/master/src/.eslintignore', | ||
'https://raw.githubusercontent.com/ahmadawais/WPGulp/master/src/.eslintrc.js', | ||
'https://raw.githubusercontent.com/ahmadawais/WPGulp/master/src/.gitignore', | ||
'https://raw.githubusercontent.com/ahmadawais/WPGulp/master/src/gulpfile.babel.js', | ||
'https://raw.githubusercontent.com/ahmadawais/WPGulp/master/src/package.json', | ||
'https://raw.githubusercontent.com/ahmadawais/WPGulp/master/src/wpgulp.config.js' | ||
]; | ||
|
||
// Dotfiles (if any). | ||
const dotFiles = ['.editorconfig', '.eslintignore', '.eslintrc.js', '.gitignore']; | ||
|
||
// Start. | ||
console.log('\n'); // eslint-disable-line no-console | ||
console.log( | ||
'📦 ', | ||
chalk.black.bgYellow(` Downloading WPGulp files in: → ${chalk.black.bgWhite(` ${theDir} `)}`), | ||
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 WPGulp files inside → ${chalk.black.bgWhite(` ${theDir} `)}`); | ||
|
||
// Download. | ||
Promise.all(filesToDownload.map(x => download(x, `${theCWD}`))).then(async () => { | ||
dotFiles.map(x => fs.rename(`${theCWD}/${x.slice(1)}`, `${theCWD}/${x}`, err => handleError(err))); | ||
spinner.succeed(); | ||
|
||
// The npm install. | ||
spinner.start('2. Installing npm packages...'); | ||
await execa('npm', ['install', '--silent']); | ||
spinner.succeed(); | ||
|
||
// Done. | ||
printNextSteps(); | ||
}); | ||
}; |
Oops, something went wrong.