├── .gitignore ├── .gruntjshintrc ├── .jshintrc ├── CHANGELOG.md ├── DONFramework.zip ├── Gruntfile.js ├── JAVASCRIPT-HELPER-VARIABLES.md ├── LICENSE ├── README.md ├── READY-TO-BUILD-SINGLE-PAGE.md └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | *.bak 3 | .sass-cache 4 | source/wp-config.php 5 | source/wp-content/advanced-cache.php 6 | source/wp-content/backup-db/ 7 | source/wp-content/backups/ 8 | source/wp-content/blogs.dir/ 9 | source/wp-content/cache/ 10 | source/wp-content/upgrade/ 11 | source/wp-content/uploads/ 12 | source/wp-content/wp-cache-config.php 13 | source/wp-content/plugins/hello.php 14 | node_modules 15 | 16 | /.htaccess 17 | /license.txt 18 | /readme.html 19 | /sitemap.xml 20 | /sitemap.xml.gz 21 | .DS_Store 22 | .DS_Store? 23 | ._* 24 | .Spotlight-V100 25 | .Trashes 26 | ehthumbs.db 27 | Thumbs.db -------------------------------------------------------------------------------- /.gruntjshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "boss": true, 3 | "curly": true, 4 | "eqeqeq": true, 5 | "eqnull": true, 6 | "immed": true, 7 | "jquery": true, 8 | "latedef": true, 9 | "newcap": true, 10 | "noarg": true, 11 | "node": true, 12 | "quotmark": true, 13 | "sub": true, 14 | "undef": true, 15 | "globals": { 16 | "exports": true, 17 | "module": false 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "boss": true, 3 | "browser": true, 4 | "curly": true, 5 | "eqeqeq": true, 6 | "eqnull": true, 7 | "immed": true, 8 | "jquery": true, 9 | "latedef": true, 10 | "newcap": true, 11 | "noarg": true, 12 | "quotmark": true, 13 | "sub": true, 14 | "undef": true, 15 | "globals": { 16 | "exports": true, 17 | "module": false 18 | } 19 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Changelog ## 2 | 3 | #### v1.2.0 - 14/10/2016 #### 4 | - Move images dir to assets dir #7 5 | - Add task to image minification in Grunt.js file #6 6 | - Correct prompt item name on menu #8 7 | 8 | #### v1.1.0 - 9/9/2016 #### 9 | - Change docs 10 | - Correct some strings 11 | -------------------------------------------------------------------------------- /DONFramework.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donini/wordpress-automation/c0b2639327ad3c6c06dd0b541db353af9ba35664/DONFramework.zip -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function( grunt ) { 2 | 'use strict'; 3 | 4 | // LOAD ALL GRUNT TASKS 5 | require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); 6 | 7 | //DEPLOY VARIABLES 8 | var deployConfig = { 9 | url: '', 10 | database: '', 11 | user: '', 12 | pass: '', 13 | server: '' 14 | }; 15 | 16 | // PROJECT INIT 17 | grunt.initConfig( { 18 | deployConfig: deployConfig, 19 | pkg: grunt.file.readJSON( 'package.json' ), 20 | // SHELL COMMANDS 21 | shell: { 22 | downloadInstallWP: { 23 | command: 'wp core download --path=source --locale=<%= pkg.locale %>' 24 | }, 25 | configureDatabaseWP: { 26 | command: [ 27 | 'cd source', 28 | 'wp core config --dbname=<%= pkg.database.dbname %> --dbuser=<%= pkg.database.dbuser %> --dbpass=<%= pkg.database.dbpassword %> --dbhost=<%= pkg.database.dbhost %> --dbprefix=<%= pkg.database.dbprefix %> --extra-php < --title=<%= pkg.title %> --admin_user=<%= pkg.admin_user %> --admin_password=<%= pkg.admin_pass %> --admin_email=<%= pkg.admin_email %>' 36 | ].join('&&') 37 | }, 38 | updateWP: { 39 | command: [ 40 | 'cd source', 41 | 'wp core update' 42 | ].join('&&') 43 | }, 44 | clearThemesWP: { 45 | command: [ 46 | 'cd source', 47 | 'wp theme activate DONFramework', 48 | 'wp theme delete twentyfifteen', 49 | 'wp theme delete twentyfourteen', 50 | 'wp theme delete twentysixteen', 51 | 'cd ../', 52 | 'rm -r DONFramework.zip' 53 | ].join('&&') 54 | }, 55 | setActiveThemeWP: { 56 | command: [ 57 | 'cd source', 58 | 'wp theme activate <%= pkg.name %>' 59 | ].join('&&') 60 | }, 61 | dumpDatabaseWP: { 62 | command: [ 63 | 'cd build', 64 | 'mkdir database', 65 | 'cd ../source', 66 | 'wp db export --add-drop-table ../build/database/dump_<%= pkg.name %>.sql' 67 | ].join('&&') 68 | } 69 | }, 70 | // CONCAT JS 71 | concat: { 72 | options: { 73 | stripBanners: true, 74 | banner: '/*! <%= pkg.title %> - v<%= pkg.version %> - \n'+ 75 | 'DONFramework - v<%= pkg.framework_version %>\n'+ 76 | '<%= grunt.template.today("yyyy-mm-dd") %>\n' + 77 | ' * <%= pkg.homepage %>\n' + 78 | ' * Copyright (c) Rodrigo Donini <%= grunt.template.today("yyyy") %>;' + 79 | ' */\n' 80 | }, 81 | theme: { 82 | src: ['source/wp-content/themes/<%= pkg.name %>/assets/js/src/*.js'], 83 | dest: 'source/wp-content/themes/<%= pkg.name %>/assets/js/don_child.js' 84 | }, 85 | themePlugins:{ 86 | src: ['source/wp-content/themes/<%= pkg.name %>/assets/js/vendor/**/*.js'], 87 | dest: 'source/wp-content/themes/<%= pkg.name %>/assets/js/don_child_plugins.js' 88 | } 89 | }, 90 | // VALIDADE JS 91 | jshint: { 92 | browser: { 93 | all: [ 94 | 'source/wp-content/themes/<%= pkg.name %>/assets/js/src/**/*.js', 95 | 'source/wp-content/themes/<%= pkg.name %>/assets/js/test/**/*.js' 96 | ], 97 | options: { 98 | jshintrc: '.jshintrc' 99 | } 100 | }, 101 | grunt: { 102 | all: [ 103 | 'Gruntfile.js' 104 | ], 105 | options: { 106 | jshintrc: '.gruntjshintrc' 107 | } 108 | } 109 | }, 110 | // COMPACT JS 111 | uglify: { 112 | all: { 113 | files: [ 114 | { 115 | 'source/wp-content/themes/<%= pkg.name %>/assets/js/don_child.min.js': ['source/wp-content/themes/<%= pkg.name %>/assets/js/don_child.js'] 116 | }, 117 | { 118 | 'source/wp-content/themes/<%= pkg.name %>/assets/js/don_plugins.min.js': ['source/wp-content/themes/<%= pkg.name %>/assets/js/don_child_plugins.js'] 119 | } 120 | ], 121 | options: { 122 | banner: '/*! <%= pkg.title %> - v<%= pkg.version %> - \n'+ 123 | 'DONFramework - v<%= pkg.framework_version %>\n'+ 124 | '<%= grunt.template.today("yyyy-mm-dd") %>\n' + 125 | ' * <%= pkg.homepage %>\n' + 126 | ' * Copyright (c) Rodrigo Donini <%= grunt.template.today("yyyy") %>;' + 127 | ' */\n', 128 | mangle: { 129 | except: ['jQuery'] 130 | } 131 | } 132 | } 133 | }, 134 | // GENERATE SPRITES 135 | sprites: { 136 | theme: { 137 | src: ['source/wp-content/themes/<%= pkg.name %>/assets/images/src/*.png'], 138 | css: 'source/wp-content/themes/<%= pkg.name %>/assets/css/sass/_don_child_sprite.scss', 139 | map: 'source/wp-content/themes/<%= pkg.name %>/assets/images/don_child_sprite.png' 140 | } 141 | }, 142 | // COMPILE SASS 143 | sass: { 144 | all: { 145 | files: 146 | [{ 147 | expand: true, 148 | cwd: 'source/wp-content/themes/<%= pkg.name %>/assets/css/sass/', 149 | src: ['*.scss'], 150 | dest: 'source/wp-content/themes/<%= pkg.name %>/assets/css/', 151 | ext: '.css' 152 | }] 153 | } 154 | }, 155 | // MINIFY CSS 156 | cssmin: { 157 | options: { 158 | banner: '/*! <%= pkg.title %> - v<%= pkg.version %> - \n'+ 159 | 'DONFramework - v<%= pkg.framework_version %>\n'+ 160 | '<%= grunt.template.today("yyyy-mm-dd") %>\n' + 161 | ' * <%= pkg.homepage %>\n' + 162 | ' * Copyright (c) Rodrigo Donini <%= grunt.template.today("yyyy") %>;' + 163 | ' */\n' 164 | }, 165 | minify: { 166 | 'source/wp-content/themes/<%= pkg.name %>/assets/css/don_child.min.css' : ['source/wp-content/themes/<%= pkg.name %>/assets/css/don_child.css'] 167 | } 168 | }, 169 | // REPLACE SOME STRINGS IN FILES 170 | 'string-replace': { 171 | main: { 172 | files: { 173 | 'source/wp-content/themes/<%= pkg.name %>/style.css' : 'source/wp-content/themes/DONFramework/style.css' 174 | }, 175 | options: { 176 | replacements: [{ 177 | pattern: /DONFramework/ig, 178 | replacement: '<%= pkg.name %>' 179 | }, 180 | { 181 | pattern: /--TEMPLATE--/ig, 182 | replacement: 'Template: DONFramework' 183 | }] 184 | } 185 | }, 186 | setThemePath: { 187 | files: { 188 | 'source/wp-content/themes/<%= pkg.name %>/functions.php' : 'source/wp-content/themes/<%= pkg.name %>/functions.php' 189 | }, 190 | options: { 191 | replacements: [{ 192 | pattern: /--TEMPLATE--/ig, 193 | replacement: '<%= pkg.name %>' 194 | }] 195 | } 196 | }, 197 | changeVersion: { 198 | files: { 199 | 'source/wp-content/themes/<%= pkg.name %>/functions.php' : 'source/wp-content/themes/<%= pkg.name %>/functions.php' 200 | }, 201 | options: { 202 | replacements: [{ 203 | pattern: /define\( 'DON_VERSION', '((\d)+.(\d)+.(\d)+)*' \);/ig, 204 | replacement: "define( 'DON_VERSION', '<%= pkg.framework_version %>' );" 205 | }, 206 | { 207 | pattern: /define\( 'DON_CHILD_VERSION', '((\d)+.(\d)+.(\d)+)*' \);/ig, 208 | replacement: "define( 'DON_CHILD_VERSION', '<%= pkg.version %>' );" 209 | }] 210 | } 211 | }, 212 | deployWpconfig: { 213 | files: { 214 | 'build/files/wp-config.php' : 'build/files/wp-config.php' 215 | }, 216 | options: { 217 | replacements: [{ 218 | pattern: /'DB_NAME', '(\w)*'/ig, 219 | replacement: "'DB_NAME', '<%= deployConfig.database %>'" 220 | }, 221 | { 222 | pattern: /'DB_USER', '(\w)*'/ig, 223 | replacement: "'DB_USER', '<%= deployConfig.user %>'" 224 | }, 225 | { 226 | pattern: /'DB_PASSWORD', '(\w)*'/ig, 227 | replacement: "'DB_PASSWORD', '<%= deployConfig.pass %>'" 228 | } 229 | , 230 | { 231 | pattern: /'DB_HOST', '(\w)*'/ig, 232 | replacement: "'DB_HOST', '<%= deployConfig.server %>'" 233 | }] 234 | } 235 | } 236 | }, 237 | // UNZIP MASTER THEME 238 | unzip: { 239 | 'source/wp-content/themes/': 'DONFramework.zip' 240 | }, 241 | // COPY CHILD THEME AND DEPLOY FILES 242 | copy: { 243 | main:{ 244 | files: [ 245 | // Replace folder name 246 | {expand: true, cwd: 'source/wp-content/themes/DONFramework', src: 'style.css', dest: 'source/wp-content/themes/<%= pkg.name %>/'}, 247 | {expand: true, cwd: 'source/wp-content/themes/DONFramework', src: 'screenshot.png', dest: 'source/wp-content/themes/<%= pkg.name %>/'}, 248 | {expand: true, cwd: 'source/wp-content/themes/DONFramework/child_theme', src: '**', dest: 'source/wp-content/themes/<%= pkg.name %>/'} 249 | ] 250 | }, 251 | deploy:{ 252 | files:[ 253 | {expand:true, cwd: 'source/', src:'**', dest:'build/files/'}, 254 | {expand:true, cwd: 'database/', src:'**', dest:'build/database/'} 255 | ] 256 | } 257 | }, 258 | // WATCH FOR FILES CHANGES 259 | watch:{ 260 | options:{ 261 | livereload: true 262 | }, 263 | sass:{ 264 | files: ['source/wp-content/themes/DONFramework/assets/css/sass/*.scss','source/wp-content/themes/<%= pkg.name %>/assets/css/sass/*.scss'], 265 | tasks: ['buildStyle'], 266 | options:{ 267 | livereload: true 268 | } 269 | }, 270 | scripts:{ 271 | files: ['source/wp-content/themes/DONFramework/assets/js/src/*.js', 272 | 'source/wp-content/themes/DONFramework/assets/js/vendor/*.js', 273 | 'source/wp-content/themes/<%= pkg.name %>/assets/js/src/*.js', 274 | 'source/wp-content/themes/<%= pkg.name %>/assets/js/vendor/*.js'], 275 | tasks: ['buildScript'], 276 | options:{ 277 | livereload: true 278 | } 279 | }, 280 | imagesDon:{ 281 | files: ['source/wp-content/themes/DONFramework/assets/images/src/*.png'], 282 | tasks: ['sprites:don'], 283 | options:{ 284 | livereload: true 285 | } 286 | }, 287 | imagesTheme:{ 288 | files: ['source/wp-content/themes/<%= pkg.name %>/assets/images/src/*.png'], 289 | tasks: ['sprites:theme'], 290 | options:{ 291 | livereload: true 292 | } 293 | }, 294 | livereload:{ 295 | files:[ 296 | 'source/wp-content/themes/<%= pkg.name %>/**/*.{php,html,jpg,jpeg,png,gif}', 297 | 'source/wp-content/themes/DONFramework/**/*.{php,html}' 298 | ] 299 | } 300 | }, 301 | // IMAGE OPTIMIZATION 302 | imagemin: { 303 | dist: { 304 | options: { 305 | optimizationLevel: 7, 306 | progressive: true 307 | }, 308 | files: [{ 309 | expand: true, 310 | filter: 'isFile', 311 | cwd: 'source/wp-content/themes/<%= pkg.name %>/assets/images/', 312 | src: '**/*.{png,jpg,gif}', 313 | dest: 'source/wp-content/themes/<%= pkg.name %>/assets/images/' 314 | }] 315 | } 316 | }, 317 | // CLEAN TEMP FILES 318 | clean: { 319 | preDeploy: { 320 | src: [ 'build' ] 321 | }, 322 | posDeploy: { 323 | src: [ 324 | 'build/files/wp-content/themes/DONFramework/child_theme', 325 | 'build/files/wp-content/themes/<%= pkg.name %>/assets/css/sass', 326 | 'build/files/wp-content/themes/<%= pkg.name %>/assets/js/src', 327 | 'build/files/wp-content/themes/<%= pkg.name %>/assets/js/vendor', 328 | 'build/files/wp-content/themes/<%= pkg.name %>/assets/images/src', 329 | 'build/**/*md' 330 | ] 331 | }, 332 | }, 333 | // PROMPT START MENU 334 | prompt: { 335 | startMenu: { 336 | options: { 337 | questions: [ 338 | { 339 | config: 'don.startMenu', 340 | type: 'list', 341 | message: 'What would you like to do?', 342 | default: 'exit', 343 | choices: [ 344 | { 345 | value: 'downloadInstallWP', 346 | name: '1) Download WordPress' 347 | }, 348 | { 349 | value: 'configureDatabaseWP', 350 | name: '2) Configure WordPress' 351 | }, 352 | { 353 | value: 'initialConfigsWP', 354 | name: '3) Install WordPress' 355 | }, 356 | { 357 | value: 'updateWP', 358 | name: '4) Update WordPress to last version' 359 | }, 360 | { 361 | value: 'create', 362 | name: '5) Create a new child theme' 363 | }, 364 | { 365 | value: 'buildAssets', 366 | name: '6) Build assets' 367 | }, 368 | { 369 | value: 'deploy', 370 | name: '7) Deploy application' 371 | }, 372 | { 373 | value: 'changeVersion', 374 | name: '8) Change project version' 375 | }, 376 | { 377 | value: 'watch', 378 | name: '9) Watch for file changes' 379 | }, 380 | { 381 | value: 'exit', 382 | name: '0) Exit' 383 | } 384 | ] 385 | } 386 | ] 387 | } 388 | }, 389 | downloadInstall: { 390 | options: { 391 | questions: [ 392 | { 393 | config: 'pkg.locale', 394 | default: 'en_US', 395 | type: 'input', 396 | message: 'What is the language of WordPress you want?' 397 | } 398 | ] 399 | } 400 | }, 401 | configureDatabase: { 402 | options: { 403 | questions: [ 404 | { 405 | config: 'pkg.database.dbname', 406 | type: 'input', 407 | message: 'Database:', 408 | validate: function (value) { 409 | var valid = (value !== ''); 410 | return valid || 'Database name cannot be empty!'.red.underline; 411 | } 412 | }, 413 | { 414 | config: 'pkg.database.dbuser', 415 | type: 'input', 416 | message: 'Database user:', 417 | validate: function (value) { 418 | var valid = (value !== ''); 419 | return valid || 'Database user cannot be empty!'.red.underline; 420 | } 421 | }, 422 | { 423 | config: 'pkg.database.dbpassword', 424 | type: 'input', 425 | message: 'Database password:' 426 | }, 427 | { 428 | config: 'pkg.database.dbhost', 429 | type: 'input', 430 | message: 'Database host:', 431 | validate: function (value) { 432 | var valid = (value !== ''); 433 | return valid || 'Database host cannot be empty!'.red.underline; 434 | } 435 | }, 436 | { 437 | config: 'pkg.database.dbprefix', 438 | type: 'input', 439 | default: 'wpd_', 440 | message: 'Tables prefix:' 441 | } 442 | ] 443 | } 444 | }, 445 | initialConfigs: { 446 | options: { 447 | questions: [ 448 | { 449 | config: 'pkg.homepage', 450 | type: 'input', 451 | message: 'What is the address of your site?' 452 | }, 453 | { 454 | config: 'pkg.title', 455 | type: 'input', 456 | message: 'What is the title of your site?' 457 | }, 458 | { 459 | config: 'pkg.admin_user', 460 | type: 'input', 461 | default: 'admin', 462 | message: 'What is the name of admin user?' 463 | }, 464 | { 465 | config: 'pkg.admin_pass', 466 | type: 'input', 467 | default: '12345', 468 | message: 'What is the password of the admin user?' 469 | }, 470 | { 471 | config: 'pkg.admin_email', 472 | type: 'input', 473 | default: 'admin@wordpress.local', 474 | message: 'What is the email of the admin user?' 475 | } 476 | ] 477 | } 478 | }, 479 | create: { 480 | options: { 481 | questions: [ 482 | { 483 | config: 'pkg.name', 484 | type: 'input', 485 | message: 'Theme name:', 486 | validate: function (value) { 487 | var valid = (value !== ''); 488 | return valid || 'Theme name cannot be empty!'.red.underline; 489 | } 490 | }, 491 | { 492 | config: 'pkg.code', 493 | type: 'input', 494 | message: 'Project code:', 495 | validate: function (value) { 496 | var valid = (value !== ''); 497 | return valid || 'Project code cannot be empty!'.red.underline; 498 | } 499 | } 500 | ] 501 | } 502 | }, 503 | changeVersion: { 504 | options: { 505 | questions: [ 506 | { 507 | config: 'pkg.version', 508 | type: 'input', 509 | message: 'Current project version = ' + '<%= pkg.version %>'.blue + '. Change current project version to: ', 510 | validate: function (value) { 511 | var valid = /(\d)*\.(\d)*\.(\d)*/g.test(value) 512 | return valid || 'Version number must be number.number.number'.red.underline; 513 | } 514 | } 515 | ] 516 | } 517 | }, 518 | deploy: { 519 | options: { 520 | questions: [ 521 | { 522 | config: 'deployConfig.url', 523 | type: 'input', 524 | message: 'Deploy url: ', 525 | validate: function (value) { 526 | var valid = (value !== ''); 527 | return valid || 'Parameter cannot be null'.red.underline; 528 | } 529 | }, 530 | { 531 | config: 'deployConfig.database', 532 | type: 'input', 533 | message: 'Deploy database: ', 534 | validate: function (value) { 535 | var valid = (value !== ''); 536 | return valid || 'Parameter cannot be null'.red.underline; 537 | } 538 | }, 539 | { 540 | config: 'deployConfig.user', 541 | type: 'input', 542 | message: 'Deploy database user: ', 543 | validate: function (value) { 544 | var valid = (value !== ''); 545 | return valid || 'Parameter cannot be null'.red.underline; 546 | } 547 | }, 548 | { 549 | config: 'deployConfig.pass', 550 | type: 'input', 551 | message: 'Deploy database password: ', 552 | validate: function (value) { 553 | var valid = (value !== ''); 554 | return valid || 'Parameter cannot be null'.red.underline; 555 | } 556 | }, 557 | { 558 | config: 'deployConfig.server', 559 | type: 'input', 560 | message: 'Deploy database server: ', 561 | validate: function (value) { 562 | var valid = (value !== ''); 563 | return valid || 'Parameter cannot be null'.red.underline; 564 | } 565 | } 566 | ] 567 | } 568 | } 569 | } 570 | } ); 571 | 572 | // DEFAULT TASK 573 | grunt.registerTask( 'default', function(){ 574 | var version = grunt.config('pkg.framework_version'); 575 | grunt.log.ok('DONFramework - '+version.cyan); 576 | grunt.task.run(['prompt:startMenu', '-']); 577 | }); 578 | 579 | 580 | /***************************************************************************************************************** 581 | * * 582 | * PRIVATE TASK LIST * 583 | * * 584 | ******************************************************************************************************************/ 585 | // STARTUP MENU HANDLING 586 | grunt.registerTask('-', function(){ 587 | var pkg = grunt.config('pkg'); 588 | grunt.file.write('package.json', JSON.stringify(pkg,null,2)); 589 | 590 | var nextTask = grunt.config('don.startMenu'); 591 | if(nextTask !== 'exit') 592 | grunt.task.run([nextTask, 'default']); 593 | }); 594 | 595 | // DOWNLOAD WORDPRESS 596 | grunt.registerTask( 'downloadInstallWP', function(){ 597 | var tasks = ['prompt:downloadInstall','shell:downloadInstallWP']; 598 | grunt.task.run(tasks); 599 | }).registerTask( 'getwp', function(){ 600 | var tasks = ['prompt:downloadInstall','shell:downloadInstallWP']; 601 | grunt.task.run(tasks); 602 | }); 603 | 604 | // CONFIGURE WP 605 | grunt.registerTask( 'configureDatabaseWP', function(){ 606 | var tasks = ['prompt:configureDatabase','shell:configureDatabaseWP']; 607 | grunt.task.run(tasks); 608 | }).registerTask( 'configwp', function(){ 609 | var tasks = ['prompt:configureDatabase','shell:configureDatabaseWP']; 610 | grunt.task.run(tasks); 611 | }); 612 | 613 | // INSTALL WP 614 | grunt.registerTask( 'initialConfigsWP', function(){ 615 | var tasks = ['prompt:initialConfigs','shell:initialConfigsWP']; 616 | grunt.task.run(tasks); 617 | }).registerTask( 'installwp', function(){ 618 | var tasks = ['prompt:initialConfigs','shell:initialConfigsWP']; 619 | grunt.task.run(tasks); 620 | }); 621 | 622 | // UPDATE WP 623 | grunt.registerTask( 'updateWP', function(){ 624 | var tasks = ['shell:updateWP']; 625 | grunt.task.run(tasks); 626 | }).registerTask( 'updatewp', function(){ 627 | var tasks = ['shell:updateWP']; 628 | grunt.task.run(tasks); 629 | }); 630 | 631 | // CREATES A NEW CHILD THEME 632 | grunt.registerTask( 'create', function(){ 633 | var tasks = ['prompt:create', 'unzip', 'shell:clearThemesWP', 'copy:main', 'string-replace:main', 'string-replace:setThemePath', 'shell:setActiveThemeWP', 'string-replace:changeVersion']; 634 | grunt.task.run(tasks); 635 | }).registerTask( 'c', function(){ 636 | var tasks = ['prompt:create', 'unzip', 'shell:clearThemesWP', 'copy:main', 'string-replace:main', 'string-replace:setThemePath', 'shell:setActiveThemeWP', 'string-replace:changeVersion']; 637 | grunt.task.run(tasks); 638 | }); 639 | 640 | // CALL WATCH 641 | grunt.registerTask( 'w', function(){ 642 | var tasks = ['watch']; 643 | grunt.task.run(tasks); 644 | }) 645 | 646 | // CHANGE PROJECT VERSION 647 | grunt.registerTask( 'changeVersion', function(){ 648 | var tasks = ['prompt:changeVersion', 'string-replace:changeVersion']; 649 | grunt.task.run(tasks); 650 | }).registerTask( 'cv', function(){ 651 | var tasks = ['prompt:changeVersion', 'string-replace:changeVersion']; 652 | grunt.task.run(tasks); 653 | }); 654 | 655 | // BUILD ALL ASSETS 656 | grunt.registerTask('buildAssets', function(){ 657 | var tasks = ['sprites', 'buildStyle', 'buildScript', 'imagemin']; 658 | grunt.task.run(tasks); 659 | }).registerTask('ba', function(){ 660 | var tasks = ['sprites', 'buildStyle', 'buildScript', 'imagemin']; 661 | grunt.task.run(tasks); 662 | }); 663 | 664 | // COMPILE SASS 665 | grunt.registerTask('buildStyle', function(){ 666 | var tasks = ['sass']; 667 | grunt.task.run(tasks); 668 | }).registerTask('bs', function(){ 669 | var tasks = ['sass']; 670 | grunt.task.run(tasks); 671 | }); 672 | 673 | // COMPILE JS 674 | grunt.registerTask('buildScript', function(){ 675 | var tasks = ['jshint', 'concat']; 676 | grunt.task.run(tasks); 677 | }).registerTask('bj', function(){ 678 | var tasks = ['jshint', 'concat']; 679 | grunt.task.run(tasks); 680 | }); 681 | 682 | // BUILD AND DEPLOY FILES 683 | grunt.registerTask('deploy', function(){ 684 | var tasks = ['prompt:deploy', 'clean:preDeploy', 'buildAssets', 'uglify', 'cssmin', 'copy:deploy', 'clean:posDeploy', 'string-replace:deployWpconfig', 'shell:dumpDatabaseWP']; 685 | grunt.option('force', true); 686 | grunt.task.run(tasks); 687 | }).registerTask('d', function(){ 688 | var tasks = ['prompt:deploy', 'clean:preDeploy', 'buildAssets', 'uglify', 'cssmin', 'copy:deploy', 'clean:posDeploy', 'string-replace:deployWpconfig', 'shell:dumpDatabaseWP']; 689 | grunt.option('force', true); 690 | grunt.task.run(tasks); 691 | }); 692 | 693 | grunt.util.linefeed = '\n'; 694 | }; -------------------------------------------------------------------------------- /JAVASCRIPT-HELPER-VARIABLES.md: -------------------------------------------------------------------------------- 1 | # WORDPRESS-AUTOMATION 2 | 3 | ## Javascript Helper Variables 4 | 5 | Inside project exists some javascript variables that delivering URL's of some resources of project, see bellow: 6 | 7 | * DONAjax.ajaxurl - references admin-ajax.php to AJAX calls 8 | * DONAjax.siteurl - references the root url of the site 9 | * DONAjax.themeurl - references the stylesheet directory uri -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Rodrigo Donini 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WORDPRESS-AUTOMATION 2 | 3 | This can be called "framework" that create automations for some common tasks in WordPress projects. It turn more easer the developer's life. 4 | 5 | Functions included: 6 | 7 | * [Download WordPress](#1-download-wordpress) 8 | * [Configure WordPress](#2-configure-wordpress) 9 | * [Install WordPress](#3-install-wordpress) 10 | * [Update WordPress](#4-update-wordpress) 11 | * [Create new theme](#5-create-new-theme-development) 12 | * [Build assets](#6-build-assets) 13 | * [Build styles](#build-styles) into one minified file 14 | * [Build javascript](#build-scripts) into one hint and minified file 15 | * Generate sprites of the images used in project 16 | * [Observe](#9-watch) files changes and automatically build assets and refreash browser 17 | * Prepare project to [deploy](#7-deploy-production) 18 | 19 | All this options can be accessed by [start menu](#start-menu). 20 | 21 | ## Requirements 22 | 23 | This libraries are required to run the automations, WP-CLI is required to run WordPress command line procedures, NodeJS is required to perform the GruntJS tasks such, wp-cli, hint javascript, generate sprites of images, live reload of project and SASS is required to perform pre-processing of css files. 24 | 25 | * WP-CLI ([All](http://wp-cli.org/docs/installing/)) 26 | * NodeJS ([Windows](http://nodejs.org/download/ "Node for windows")|[MAC OS](http://shapeshed.com/setting-up-nodejs-and-npm-on-mac-osx/ "Node for MAC")) 27 | * SASS ([All](http://sass-lang.com/install "SASS for all")) 28 | 29 | ## Installation 30 | 31 | After install all the requirements, type this command on terminal to install Gunt-CLI globally: 32 | 33 | ```shell 34 | npm install -g grunt-cli 35 | ``` 36 | 37 | And then this to install node dependences and prepare boilerplate to use: 38 | 39 | ```shell 40 | npm install 41 | ``` 42 | 43 | ## Commands 44 | 45 | All commands must run on root folder: 46 | 47 | ### Start menu 48 | 49 | To show the start menu, type: 50 | ```shell 51 | grunt 52 | ``` 53 | and select the option you want. 54 | 55 | ![alt text](http://www.donini.me/github/wpbp/wpbp_startmenu.png "Start menu all options") 56 | 57 | ### 1) Download WordPress 58 | 59 | This option will be download the lasted version of WordPress, if you want you can select the core language. 60 | 61 | To initialize download, use: 62 | ```shell 63 | grunt getwp 64 | ``` 65 | 66 | 67 | #### Parameters: 68 | 69 | *What is the language of WordPress you want?:* default is en_US 70 | 71 | ![alt text](http://www.donini.me/github/wpbp/wpbp_download.png "Download WordPress") 72 | 73 | ### 2) Configure WordPress 74 | 75 | This command just create the wp-config.php file with your settings. 76 | 77 | To configure, use: 78 | ```shell 79 | grunt configwp 80 | ``` 81 | 82 | ![alt text](http://www.donini.me/github/wpbp/wpbp_configure.png "Configure WordPress") 83 | 84 | #### Parameters: 85 | 86 | *Database:* database name 87 | *Database user:* username of database 88 | *Database password:* password of user 89 | *Database host:* host of IP address 90 | *Tables prefix host:* default wpd_ 91 | 92 | ### 3) Install WordPress 93 | 94 | This command will be create the database and install WordPress with settings you entered in option 2. 95 | 96 | To install, use: 97 | ```shell 98 | grunt installwp 99 | ``` 100 | 101 | ![alt text](http://www.donini.me/github/wpbp/wpbp_install.png "Install WordPress") 102 | 103 | #### Parameters: 104 | 105 | *What is the address of your site?* the url of of your project 106 | *What is the title of your site?* the title of your project (if title has spaces, use doublequotes) 107 | *What is the name of admin user?* the admin fo WordPress 108 | *What is the password of the admin user?* the password of admin user 109 | *What is the email of the admin user?* the e-mail of administrator 110 | 111 | ### 4) Update WordPress 112 | 113 | This command update the core WordPress of your project. 114 | 115 | To update, use: 116 | ```shell 117 | grunt updatewp 118 | ``` 119 | 120 | ### 5) Create new theme [DEVELOPMENT] 121 | 122 | To create a new custom theme, use: 123 | ```shell 124 | grunt create [OR] grunt c 125 | ``` 126 | 127 | ![alt text](http://www.donini.me/github/wpbp/wpbp_create.png "Create new theme parameters") 128 | 129 | #### Parameters: 130 | 131 | *Theme name:* the name of your theme/project 132 | *Project code:* the code of your project1 133 | 134 | ##### Observations: 135 | 136 | 1 This will be your url path to access project. Ex. http://localhost/PROJECT_CODE 137 | 138 | ### 6) Build Assets 139 | 140 | To build all styles2, javascript, minify images and create sprite file, type this: 141 | 142 | ```shell 143 | grunt buildAssets [OR] grunt ba 144 | ``` 145 | 146 | 2 At this moment those files are not minified, it's just were unified. 147 | 148 | #### Sub Commands 149 | 150 | ##### Build Styles 151 | 152 | It's possible to build only the styles, this procedure will be process .scss files and unify all css results into a single file. To do this, type: 153 | 154 | ```shell 155 | grunt buildStyle [OR] grunt bs 156 | ``` 157 | 158 | ##### Build Scripts 159 | 160 | It's possible to build only the javascript, this procedure will be unify all .js results into a single file. To do this, type: 161 | 162 | ```shell 163 | grunt buildScript [OR] grunt bj 164 | ``` 165 | 166 | ### 7) Deploy [PRODUCTION] 167 | 168 | This command prepare the project to deploy into production server, it build3 everything and minify files, type: 169 | 170 | ```shell 171 | grunt deploy [OR] grunt d 172 | ``` 173 | 174 | ![alt text](http://www.donini.me/github/wpbp/wpbp_deploy.png "Deploy parameters") 175 | 176 | #### Parameters: 177 | 178 | *Deploy url:* the final url of your project 179 | *Deploy database:* database name 180 | *Deploy database user:* username of database 181 | *Deploy database password:* password of user 182 | *Deploy database server:* host of IP address 183 | 184 | 3 The result of the compilation will be found 'build' folder at root, this contains WordPress files and an dump of database. The source files (of assets) will not be sent to this folder. 185 | 186 | ### 8) Change version 187 | 188 | It's possible to controll4 the versions of your theme/project, type: 189 | 190 | ```shell 191 | grunt changeVersion [OR] grunt cv 192 | ``` 193 | 194 | 4 Using this you prevent cache in assets files after each new deploy. 195 | 196 | ### 9) Watch 197 | 198 | This is one of the collest features of this framework, this command observing files changing and build all assets and tiggers refresh to the browser automatically, type: 199 | 200 | ```shell 201 | grunt watch [OR] grunt w 202 | ``` 203 | 204 | 5 Watch command observe changes only in .scss, .js, .php, .html, .png, .gif, .jpg files. 205 | 206 | ## Framework features 207 | 208 | * [Ready to build single-page](./READY-TO-BUILD-SINGLE-PAGE.md) 209 | * [Javascript helper variables](./JAVASCRIPT-HELPER-VARIABLES.md) 210 | 211 | ## Suggest new features and register issues 212 | 213 | Use the Issues menu of this repository to register issues, doubts and suggest new features. 214 | 215 | See [changelog](./CHANGELOG.md) of project. 216 | -------------------------------------------------------------------------------- /READY-TO-BUILD-SINGLE-PAGE.md: -------------------------------------------------------------------------------- 1 | # WORDPRESS-AUTOMATION 2 | 3 | ## Ready to build single-page 4 | 5 | It's very simple to create a single page, you just need create a parent page, like a 'Single page', and create some child pages, this child pages will be the sections of the single page. 6 | 7 | ![alt text](http://www.donini.me/github/wpbp/wpbp_section-container.png "Single Page - Section container") 8 | 9 | This parent page must be configured with the template 'Section-container'. This will render all the child pages defined in the manager, with their specific template. 10 | 11 | The file of template page must have the following structure: 12 | 13 | ```shell 14 | page-[SLUG-OF-PAGE].php 15 | ``` 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": "wp-automation", 3 | "name": "wp-automation", 4 | "title": "sasa", 5 | "description": "Custom theme created by Rodrigo Donini", 6 | "version": "1.0.0", 7 | "framework_version": "1.1.0", 8 | "homepage": "http://localhost/wp-automation", 9 | "locale": "en_US", 10 | "admin_user": "admin", 11 | "admin_pass": "12345", 12 | "admin_email": "admin@wordpress.local", 13 | "author": { 14 | "name": "Rodrigo Donini", 15 | "email": "me@donini.me" 16 | }, 17 | "database": { 18 | "dbname": "dp_wp_automation", 19 | "dbuser": "root", 20 | "dbpassword": "root", 21 | "dbhost": "localhost", 22 | "dbprefix": "wpd_" 23 | }, 24 | "devDependencies": { 25 | "connect-livereload": "*", 26 | "grunt": "*", 27 | "grunt-contrib-clean": "*", 28 | "grunt-contrib-concat": "*", 29 | "grunt-contrib-connect": "*", 30 | "grunt-contrib-copy": "*", 31 | "grunt-contrib-cssmin": "*", 32 | "grunt-contrib-imagemin": "*", 33 | "grunt-contrib-jshint": "*", 34 | "grunt-contrib-nodeunit": "*", 35 | "grunt-contrib-sass": "*", 36 | "grunt-contrib-uglify": "*", 37 | "grunt-contrib-watch": "*", 38 | "grunt-imagine": "*", 39 | "grunt-prompt": "*", 40 | "grunt-shell": "*", 41 | "grunt-string-replace": "*", 42 | "grunt-zip": "", 43 | "matchdep": "*" 44 | }, 45 | "keywords": [] 46 | } --------------------------------------------------------------------------------