diff --git a/README.md b/README.md index 5484247..2b8d817 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,14 @@

-An initiative of [Pipoca Digital](http://www.pipocadigital.com.br) to help those people who want to create Static or WordPress websites easily. +An initiative of [Pipoca Digital](http://www.pipocadigital.com.br) to help those people who want to create WordPress websites easily. ## Table of contents -- [Highlights](#highlights) - [Getting started](#getting-started) - [Technologies](#technologies) - [Structure](#structure) -- [Tasks](#tasks) - [License](#license) -### Highlights -- Simple -- Free -- Fast -- Easy for begginers -- Uses cool stuff such as JS, Sass and Gulp - ### Getting started First of all, make sure you have installed the main dependencies: @@ -35,36 +26,14 @@ $ cd my-project-folder $ npm start --name "My cool project name" ``` -We can create two types of projects. A Front-end (`front`) and a WordPress (`wp`) project. - -#### Front-end Dev - -``` -$ npm run front:dev -``` - -1. Set the project format; -2. Generate your compiled files inside a folder called `www` and start your development server; -5. Open a new tab on your browser running a development server. - -#### Front-end Deploy - -``` -$ npm run front:build -``` - -1. Set the project format; -2. Generate your compiled files inside a folder called `www`. - -#### WordPress Dev +#### Dev ``` $ npm run wp:dev ``` -1. Set the project format; 2. Download WordPress inside a folder called `wordpress/` -3. Copy your style.css, plugins, wp-configs.php files to the correct place. +3. Copy your files to the correct place. 4. Generate your theme based on your compiled files. 5. After all it will open a new tab on your browser running a development server. @@ -74,16 +43,15 @@ To keep working on your WordPress project whithout donwload it everytime, just r $ npm run serve ``` -#### WordPress Deploy +#### Production ``` $ npm run wp:build ``` -1. Set the project format; -2. Download WordPress inside a folder called `wordpress/` -3. Copy your style.css, plugins, wp-configs.php files to the correct place. -4. Generate your theme based on your compiled files. +1. Download WordPress inside a folder called `wordpress/` +2. Copy your files to the correct place. +3. Generate your theme based on your compiled files. ### Technologies @@ -105,77 +73,39 @@ If everything from the Getting Started section goes well, you should have this: ├── bower.json ├── package.json ├── README.md -├── www ├── wordpress └── src - ├── js - │ ├── *.js - ├── images - │ └── {.jpg, .png, .svg, .gif, .ico} - ├── css - │ ├── components - │ │ └── _component-name.sass - │ ├── elements - │ │ └── _element-name.sass - │ ├── pages - │ │ └── page-name - │ │ └── *.sass - │ ├── settings - │ │ ├── _base.sass - │ │ ├── _colors.sass - │ │ ├── _measures.sass - │ │ └── _typography.sass - │ ├── tools - │ │ └── _mixins.sass - │ └── main.sass - ├── 404.php - ├── footer.php - ├── functions.php - ├── header.php - ├── index.php - ├── page.php - ├── search.php - └── style.css + ├── js + │ ├── *.js + ├── images + │ └── {.jpg, .png, .svg, .gif, .ico} + ├── css + │ ├── components + │ │ └── _component-name.sass + │ ├── elements + │ │ └── _element-name.sass + │ ├── pages + │ │ └── page-name + │ │ └── *.sass + │ ├── settings + │ │ ├── _base.sass + │ │ ├── _colors.sass + │ │ ├── _measures.sass + │ │ └── _typography.sass + │ ├── tools + │ │ └── _mixins.sass + │ └── main.sass + ├── 404.php + ├── footer.php + ├── functions.php + ├── header.php + ├── index.php + ├── page.php + ├── search.php + └── style.css ``` -### Gulp Tasks - -If you're running gulp globally, so you can use all the tasks below: - -##### Featured tasks... -1. `gulp`: - - Runs `gulp build`; - - Creates a watcher; - - Creates a webserver and open your brower; -2. `gulp init --name "Your project name"`: Renames the project; -3. `gulp wp`: Alias for `gulp wp-install` -4. `gulp build`: Run all the tasks below, except `wp-install and wp-build`. - -##### More tasks... -1. `gulp clean`: Remove all the files from generated directory; -2. `gulp fonts`: Copy `fonts/` from source to generated directory; -3. `gulp images`: Copy `images/` from source to generated directory; -4. `gulp libs`: Get dependencies from brower, concat inside a only file and paste into the generated `scripts -` directory; -5. `gulp pages`: Copy all `.php` files from source to generated directory; -6. `gulp scripts`: Check the quality of all `.js` files, apply babel2015 presets and copy the `js/` files from source to generated directory; -7. `gulp styles`: Copy `styles/` from source to generated directory; -7. `gulp set-format --name "Project type"`: Set the project format -8. `gulp wp-install`: - - Checks if the project has a name; - - It also checks if WordPress is already installed; - - If you confirm, it installs the latest version of WordPress; - - Runs `gulp wp-build`; - -9. `gulp wp-build`: - - Updates the DB configurations; - - Updates the authentication unique keys; - - Removes default themes from `wp-content/`; - - Copy files from `plugins/` to `wp-content/plugins/`; - -*Generated directory* could be: `www/` or `wordpress/` - - ### License -Grão de Milho is distributed under the [MIT License](#) + +Grão de Milho is distributed under the MIT License diff --git a/gulpfile.js b/gulpfile.js index 5cb60a4..1a09c09 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,43 +3,26 @@ const gulpSync = require('gulp-sync')(gulp); const requireDir = require('require-dir'); const packageJson = require('./package.json'); -let defaultTasks = ['build', 'watch', 'connect-sync']; - -if (packageJson.projectFormat === 'wordpress') { - defaultTasks.push('wp-pre-build'); -} - const baseConfig = { port: 3000, phpPort: 3838, localhost: 'localhost', packageJson: packageJson, - format: packageJson.projectFormat ? packageJson.projectFormat : 'default', compressed: true }; const wpThemePath = 'wordpress/wp-content/themes/' + packageJson.name; const paths = { - default: { - basePath: 'www/', - pagesDest: 'www/', - stylesDest: 'www/css', - fontsDest: 'www/fonts', - imagesDest: 'www/images', - scriptsDest: 'www/js' - }, - wordpress: { - basePath: 'wordpress/', - pluginsWp: 'plugins/**/*.*', - styleWp: 'src/style.css', - configWp: 'wp-config.php', - pagesDest: wpThemePath, - fontsDest: wpThemePath + '/fonts', - imagesDest: wpThemePath + '/images', - stylesDest: wpThemePath + '/css', - scriptsDest: wpThemePath + '/js', - themesWp: 'wordpress/wp-content/themes/' - } + basePath: 'wordpress/', + pluginsWp: 'plugins/**/*.*', + styleWp: 'src/style.css', + configWp: 'wp-config.php', + pagesDest: wpThemePath, + fontsDest: wpThemePath + '/fonts', + imagesDest: wpThemePath + '/images', + stylesDest: wpThemePath + '/css', + scriptsDest: wpThemePath + '/js', + themesWp: 'wordpress/wp-content/themes/' }; const devPaths = { @@ -50,19 +33,15 @@ const devPaths = { fonts: 'src/fonts/**/*.*' }; -gulp.paths = Object.assign(devPaths, paths[baseConfig.format]); +gulp.paths = Object.assign(devPaths, paths); gulp.config = baseConfig; // Gulp tasks requireDir('tasks'); -gulp.task('default', gulpSync.sync(defaultTasks)); - gulp.task('wp', gulpSync.sync(['wp-install'])); - -gulp.task('build', gulpSync.sync([ - 'clean', 'styles', 'scripts', 'pages', 'images', 'fonts', 'libs' -])); +gulp.task('default', gulpSync.sync(['build', 'watch', 'connect-sync'])); +gulp.task('build', gulpSync.sync(['clean', 'styles', 'scripts', 'pages', 'images', 'fonts', 'libs'])); gulp.task('watch', () => { gulp.watch(gulp.paths.styles, ['styles']); diff --git a/package.json b/package.json index 78d95ba..f7032c1 100644 --- a/package.json +++ b/package.json @@ -16,13 +16,10 @@ "serve": "gulp", "init": "gulp init --name", "start": "npm install && bower install && npm run init", - "wp": "gulp set-format --name \"wordpress\" && gulp wp-install && gulp wp-pre-build && npm run wp:plugins", + "wp": "gulp wp-install && gulp wp-pre-build && npm run wp:plugins", "wp:dev": "npm run wp && gulp", "wp:build": "npm run wp && gulp build", - "wp:plugins": "cp -r ./plugins ./wordpress/wp-content", - "front": "gulp set-format --name \"default\"", - "front:dev": "npm run front && gulp", - "front:build": "npm run front && gulp build" + "wp:plugins": "cp -r ./plugins ./wordpress/wp-content" }, "sasslintConfig": "sass-lint.yml", "devDependencies": { diff --git a/tasks/browser-sync.js b/tasks/browser-sync.js index a491123..b29b7ed 100755 --- a/tasks/browser-sync.js +++ b/tasks/browser-sync.js @@ -4,5 +4,5 @@ const browserSync = require('browser-sync'); gulp.task('browser-sync', function() { const baseDir = gulp.paths.basePath; - browserSync({server: { baseDir }}); + browserSync({server: {baseDir}}); }); diff --git a/tasks/set-format.js b/tasks/set-format.js deleted file mode 100644 index fcb2986..0000000 --- a/tasks/set-format.js +++ /dev/null @@ -1,38 +0,0 @@ -const gulp = require('gulp'); -const helper = require('./helpers'); -const fs = require('fs'); -const args = process.argv; - -gulp.task('set-format', function() { - const packageJsonFile = './package.json'; - - fs.readFile(packageJsonFile, 'utf8', function (error, data) { - const validParams = ['wordpress', 'default'] - const newFormatIndex = args.indexOf('--name'); - let newFormat = ''; - let updatedPackageJson; - - if (error) { - helper.log(error, 'danger'); - process.exit(1) - } - - if (newFormatIndex === -1) { - helper.log('Please, give us a valid project format using the `--name` param.', 'danger'); - process.exit(1) - } - - updatedPackageJson = JSON.parse(data); - - newFormat = args.slice(newFormatIndex + 1); - - if (newFormat.length === 0 || (validParams.indexOf(newFormat[0]) === -1)) { - helper.log('Please, give us a valid project format using the `--n` param.', 'danger'); - process.exit(1); - } - - updatedPackageJson.projectFormat = newFormat[0]; - helper.writeOn(packageJsonFile, JSON.stringify(updatedPackageJson, null, ' ')); - helper.log('Format updated.', 'success'); - }); -}); \ No newline at end of file